Skip to content

Commit

Permalink
feat: enable nix build
Browse files Browse the repository at this point in the history
  • Loading branch information
uulm-janbaudisch committed May 2, 2024
1 parent 0de109a commit 40fd7d3
Show file tree
Hide file tree
Showing 4 changed files with 249 additions and 51 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI

on:
- push

jobs:
Build:
strategy:
fail-fast: false
matrix:
target:
- triple: x86_64-unknown-linux-gnu
runner: ubuntu-latest
- triple: x86_64-apple-darwin
runner: macos-13
- triple: aarch64-apple-darwin
runner: macos-latest
runs-on: ${{ matrix.target.runner }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Nix
uses: DeterminateSystems/nix-installer-action@v10
- name: Cache
uses: DeterminateSystems/magic-nix-cache-action@v4
- name: Build
run: nix build .#bundled
- name: Upload
uses: actions/upload-artifact@v4
with:
name: ddnnife-d4-${{ matrix.target.triple }}
path: result
60 changes: 9 additions & 51 deletions .github/workflows/CI.yml → .github/workflows/Windows.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: CI

on: [workflow_dispatch, push]
on:
- push

env:
CARGO_TERM_COLOR: always
Expand All @@ -9,66 +10,35 @@ env:
CMAKE_CXX_COMPILER_LAUNCHER: sccache
RUSTC_WRAPPER: sccache
SCCACHE_GHA_ENABLED: true
# FIXME: cc-rs on mac currently won't set the C++ standard correctly (https://github.com/dtolnay/cxx/issues/1217).
CXXFLAGS: -std=c++17

jobs:
Format:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Format
run: cargo fmt --check

Build:
strategy:
fail-fast: false
matrix:
target:
- os: linux
runner: ubuntu-latest
triple: x86_64-unknown-linux-gnu
shell: bash
coverage: true
- os: macos
runner: macos-latest
triple: x86_64-apple-darwin
shell: bash
- os: windows
runner: windows-latest
triple: x86_64-pc-windows-gnu
shell: msys2
msystem: ucrt64
- triple: x86_64-pc-windows-gnu
toolchain:
- stable
d4:
- include
- exclude
runs-on: ${{ matrix.target.runner }}
runs-on: windows-latest
defaults:
run:
shell: ${{ matrix.target.shell }} {0}
shell: msys2 {0}
env:
CARGO_BUILD_TARGET: ${{ matrix.target.triple }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup MSYS2 (Windows)
if: ${{ matrix.target.os == 'windows' }}
uses: msys2/setup-msys2@v2
with:
path-type: inherit
msystem: ${{ matrix.target.msystem }}
msystem: ucrt64
pacboy: git m4 cmake:p ninja:p
- name: Install dependencies (Linux)
if: ${{ matrix.target.os == 'linux' }}
run: sudo apt-get install ninja-build libtbb-dev libhwloc-dev libboost-program-options-dev
- name: Install dependencies (macOS)
if: ${{ matrix.target.os == 'macos' }}
run: brew install ninja boost hwloc tbb
- name: Install dependencies (Windows)
if: ${{ matrix.target.os == 'windows' }}
- name: Install dependencies
run: |
pacboy -S --noconfirm toolchain:p tbb:p hwloc:p boost:p
mv /${{ matrix.target.msystem }}/lib/libtbb12.dll.a /${{ matrix.target.msystem }}/lib/libtbb.dll.a
Expand All @@ -91,29 +61,18 @@ jobs:
run: |
cd $(mktemp -d)
git clone --recursive https://github.com/kahypar/mt-kahypar.git .
git checkout c51ffeaa3b1040530bf821b7f323e3790b147b33
cmake -B build -D CMAKE_INSTALL_PREFIX=$BUILD_ROOT -D MT_KAHYPAR_DISABLE_BOOST=true
cmake --build build --target mtkahypar
cmake --install build
mkdir -p $BUILD_ROOT/licenses/mt-kahypar
cp LICENSE $BUILD_ROOT/licenses/mt-kahypar/
# TODO: currently, macOS is only supported on master, move below clone to check out latest version when released.
# git checkout $(git describe --tags $(git rev-list --tags --max-count=1))
- name: Build (including d4)
if: ${{ matrix.d4 == 'include' }}
run: cargo build
- name: Build (excluding d4)
if: ${{ matrix.d4 == 'exclude' }}
run: cargo build --no-default-features
- name: Test
# FIXME: Some tests are currently not platform independent and fail on macos and windows and without d4
if: ${{ matrix.d4 == 'include' && matrix.target.os != 'macos' && matrix.target.os != 'windows' }}
run: cargo test
- name: Install coverage tool
if: ${{ matrix.target.coverage }}
uses: taiki-e/install-action@cargo-llvm-cov
- name: Coverage
if: ${{ matrix.target.coverage && matrix.d4 == 'include' }}
run: cargo llvm-cov
- name: Package
run: |
mkdir -p $BUILD_ROOT/bin
Expand All @@ -130,8 +89,7 @@ jobs:
if: ${{ matrix.d4 == 'exclude' }}
run: |
cp doc/built/${{ matrix.target.os }}.md $BUILD_ROOT/README.md
- name: Package dependencies (Windows)
if: ${{ matrix.target.os == 'windows' }}
- name: Package dependencies
run: |
./package-msys.bash $BUILD_ROOT $BUILD_ROOT/bin/*
rm -f $BUILD_ROOT/bin/b2
Expand Down
127 changes: 127 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

81 changes: 81 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
description = "Packages and development environments for d4";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
crane = {
url = "github:ipetkov/crane/v0.16.3";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay/stable";
inputs.nixpkgs.follows = "nixpkgs";
};
d4 = {
url = "github:SoftVarE-Group/d4v2/nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, nixpkgs, crane, rust-overlay, d4, ... }:
let
systems = nixpkgs.lib.systems.doubles.unix;
eachSystem = nixpkgs.lib.genAttrs systems;
in {
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt;

packages = eachSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};

lib = pkgs.lib;
toolchain = pkgs.rust-bin.stable.latest.default;
craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
in {
default = self.packages.${system}.ddnnife;

ddnnife = craneLib.buildPackage {
pname = "ddnnife";
version = "0.7.0";

src = pkgs.fetchFromGitHub {
owner = "SoftVarE-Group";
repo = "d-dnnf-reasoner";
rev = "main";
hash = "sha256-uUzzuKOmTeGAyIHJpRTrarNx5uSBTtXUzn0pJS7SZM4=";
};

strictDeps = true;

buildInputs =
[ pkgs.boost.dev pkgs.gmp.dev d4.packages.${system}.mt-kahypar ];

nativeBuildInputs = [ pkgs.gnum4 pkgs.pkg-config ];

doCheck = false;

meta = with lib; {
description = "A d-DNNF reasoner";
homepage = "https://github.com/SoftVarE-Group/d-dnnf-reasoner";
license = licenses.lgpl3Plus;
platforms = systems;
};
};

container = pkgs.dockerTools.buildLayeredImage {
name = "ddnnife";
contents = [ self.packages.${system}.ddnnife ];
config.Entrypoint = [ "/bin/ddnnife" ];
};

bundled = pkgs.buildEnv {
name = "bundled";
paths =
[ self.packages.${system}.ddnnife d4.packages.${system}.bundled-deps ];
};
});
};
}

0 comments on commit 40fd7d3

Please sign in to comment.