diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index fec33fb..8fa931a 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -44,6 +44,7 @@ jobs: fail-fast: false matrix: os: [macos-10.15, macos-11.0] + retrace-test: [v1, v2, v2wrapper] if: "!contains(github.event.head_commit.message, 'skip ci')" steps: @@ -68,9 +69,5 @@ jobs: for var in OPENSSL_PREFIX PKG_CONFIG_PATH LDFLAGS CPPFLAGS PATH; do echo "${var}=${!var}" | tee -a "${GITHUB_ENV}"; done cd /usr/local/include sudo ln -s "${OPENSSL_PREFIX}/include/openssl" . - - name: Configure - run: | - ./autogen.sh - ./configure --enable-tests - name: Build - run: ./ci/main.sh + run: ./ci/main.sh ${{ matrix.retrace-test }} diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 7631267..976ef7f 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -38,6 +38,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest] + retrace-test: [v1, v2, v2wrapper] if: "!contains(github.event.head_commit.message, 'skip ci')" steps: @@ -47,4 +48,5 @@ jobs: - uses: cachix/install-nix-action@v15 with: nix_path: nixpkgs=channel:nixos-unstable - - run: nix-build + - run: | + nix build .#${{ matrix.retrace-test }} || { nix log /nix/store/*-retrace-unstable.drv ; exit 1 ; } diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 2d77db4..023bf99 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -46,6 +46,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-18.04, ubuntu-20.04] + retrace-test: [v1, v2, v2wrapper] if: "!contains(github.event.head_commit.message, 'skip ci')" steps: @@ -59,9 +60,5 @@ jobs: run: | ./ci/before_install.sh ./ci/install.sh cmocka libnereon - - name: Configure - run: | - ./autogen.sh - ./configure --enable-tests - name: Build - run: ./ci/main.sh + run: ./ci/main.sh ${{ matrix.retrace-test }} diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 5983b7f..40ae3b4 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -45,6 +45,8 @@ jobs: runs-on: windows-latest strategy: fail-fast: false + matrix: + retrace-test: [v1, v2, v2wrapper] if: "!contains(github.event.head_commit.message, 'skip ci')" defaults: @@ -70,10 +72,5 @@ jobs: ./ci/before_install.sh ./ci/install.sh libnereon - - name: Configure - run: | - ./autogen.sh - ./configure --enable-tests - - name: Build - run: ./ci/main.sh + run: ./ci/main.sh ${{ matrix.retrace-test }} diff --git a/ci/main.sh b/ci/main.sh index 10cdd0a..585597c 100755 --- a/ci/main.sh +++ b/ci/main.sh @@ -7,30 +7,53 @@ CFLAGS="-I${CMOCKA_INSTALL}/include" export LD_LIBRARY_PATH CFLAGS LDFLAGS -install_retrace() { +. ci/lib.sh + +: "${SUDO:=$(get_sudo)}" + +test_retrace() { + { [[ ! -r Makefile ]] || make clean ; } && \ sh autogen.sh && \ - ./configure \ - --disable-silent-rules \ - --with-cmocka="${CMOCKA_INSTALL}" \ - --enable-tests && \ - make clean && \ - make - - sudo make install + ./configure "$@" && \ + make ${MAKE_FLAGS:+$MAKE_FLAGS} + + $SUDO make install make check } -test_retrace() { - make clean - ./configure \ +test_retracev1() { + test_retrace \ + --disable-silent-rules \ + --with-cmocka="${CMOCKA_INSTALL}" \ + --enable-tests +} + +test_retracev2() { + MAKE_FLAGS=V=1 test_retrace \ --enable-v2 \ - --enable-tests && \ - make clean - make V=1 + --enable-tests +} - sudo make install - make check +test_retracev2wrapper() { + MAKE_FLAGS=V=1 test_retrace \ + --enable-v2 \ + --enable-v2_wrapper \ + --enable-tests +} + +main() { + # Run these tests by default + if [[ $# -lt 1 ]] + then + test_retracev1 + test_retracev2 + test_retracev2wrapper + else + for arg in "$@" + do + test_retrace"$arg" + done + fi } -install_retrace -test_retrace +main "$@" diff --git a/flake.nix b/flake.nix index 7372026..2e51e5a 100644 --- a/flake.nix +++ b/flake.nix @@ -11,7 +11,10 @@ let pkgs = nixpkgs.legacyPackages.${system}; in - { - defaultPackage = pkgs.callPackage ./default.nix { }; + rec { + packages.v1 = pkgs.callPackage ./nix/default.nix { }; + packages.v2 = pkgs.callPackage ./nix/v2.nix { }; + packages.v2wrapper = pkgs.callPackage ./nix/v2wrapper.nix { }; + defaultPackage = packages.v1; }); } diff --git a/default.nix b/nix/default.nix similarity index 87% rename from default.nix rename to nix/default.nix index c31c6bb..e0f8c5d 100644 --- a/default.nix +++ b/nix/default.nix @@ -7,14 +7,16 @@ stdenv.mkDerivation rec { pname = "retrace"; version = "unstable"; - src = ./.; + src = ./..; buildInputs = with pkgs; [ openssl ]; configureFlags = [ + "--disable-silent-rules" "--enable-tests" + "--with-cmocka=${pkgs.cmocka}" ]; nativeBuildInputs = with pkgs; [ @@ -26,6 +28,8 @@ stdenv.mkDerivation rec { cmocka ]; + doCheck = true; + outputs = [ "out" "lib" "dev" ]; meta = with lib; { diff --git a/nix/v2.nix b/nix/v2.nix new file mode 100644 index 0000000..423ae63 --- /dev/null +++ b/nix/v2.nix @@ -0,0 +1,9 @@ +{ pkgs ? import { } +, lib ? pkgs.lib +, stdenv ? pkgs.stdenv +}: + +(pkgs.callPackage ./default.nix { }).overrideAttrs (oldAttrs: { + configureFlags = oldAttrs.configureFlags ++ [ "--enable-v2" ]; + makeFlags = [ "V=1" ]; +}) diff --git a/nix/v2wrapper.nix b/nix/v2wrapper.nix new file mode 100644 index 0000000..72d4a67 --- /dev/null +++ b/nix/v2wrapper.nix @@ -0,0 +1,8 @@ +{ pkgs ? import { } +, lib ? pkgs.lib +, stdenv ? pkgs.stdenv +}: + +(pkgs.callPackage ./v2.nix { }).overrideAttrs (oldAttrs: { + configureFlags = oldAttrs.configureFlags ++ [ "--enable-v2_wrapper" ]; +})