Skip to content

Commit

Permalink
fix bap-asli-plugin path and add tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
katrinafyi committed Sep 12, 2023
1 parent 0f95387 commit 7d30f4f
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 10 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ jobs:
with:
name: pac-nix
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix-build ./pkgs.nix -A ${{matrix.pkg}} -o result-${{matrix.pkg}}
- run: nix-build -A ${{matrix.pkg}}
- name: nix-build -A ${{matrix.pkg}}.tests
run: |
if nix-instantiate --eval -A ${{matrix.pkg}}.tests; then
nix-build -A ${{matrix.pkg}}.tests
fi
- run: ls -l
update-check:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion asli.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ocamlPackages.buildDunePackage rec {
checkInputs = [ ocamlPackages.alcotest ];
buildInputs = [ pkgs.z3 ];
nativeBuildInputs = (with pkgs; [ ott ]) ++ (with ocamlPackages; [ menhir ]);
propagatedBuildInputs = with ocamlPackages; [ linenoise pprint zarith z3 ocaml_pcre ];
propagatedBuildInputs = [ pkgs.pcre ] ++ (with ocamlPackages; [ linenoise pprint zarith z3 ocaml_pcre ]);
doCheck = lib.versionAtLeast ocaml.version "4.09";

configurePhase = ''
Expand Down
4 changes: 2 additions & 2 deletions bap-asli-plugin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ stdenv.mkDerivation rec {
runHook preBuild
bapbuild -package asli.libASL asli.plugin
mkdir -p $out/share/bap-asli-plugin
cp asli.plugin $out/share/bap-asli-plugin/asli.plugin
mkdir -p $out/lib/bap
cp asli.plugin $out/lib/bap
runHook postBuild
'';
Expand Down
8 changes: 7 additions & 1 deletion bap-aslp.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ stdenv, makeBinaryWrapper, bap-plugins, asli, bap-asli-plugin }:
{ stdenv, makeBinaryWrapper, bap-plugins, asli, bap-asli-plugin, testers, bap-aslp }:
let _bap = (bap-plugins.override { plugins = [ bap-asli-plugin ]; });
in stdenv.mkDerivation {
pname = "bap-aslp";
Expand Down Expand Up @@ -31,4 +31,10 @@
--append-flags --asli-specs=$ASLI_PATH/tests/override.asl
done
'';

passthru.tests.asli = testers.testVersion {
package = bap-aslp;
command = "bap-aslp --help";
version = "asli-specs";
};
}
9 changes: 8 additions & 1 deletion bap-plugins.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@
paths = [ ocamlPackages.bap ];
buildInputs = [ makeWrapper ];
postBuild = ''
for x in ${toString plugins}; do
if ! [[ -d "$x/lib/bap" ]]; then
echo "$x/lib/bap" plugin path does not exist >&2
false
fi
done
for b in $out/bin/*; do
wrapProgram $b \
--append-flags "${toString (map (x: "-L ${x}") plugins)}"
--append-flags "${toString (map (x: "-L ${x + "/lib/bap"}") plugins)}"
done
'';
}
5 changes: 3 additions & 2 deletions bap-uq-pac.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{ fetchFromGitHub, ocamlPackages }:
ocamlPackages.bap.overrideAttrs rec {
ocamlPackages.bap.overrideAttrs (final: prev: {
version = "unstable-2022-11-22";
# buildInputs = (prev.buildInputs or []) ++ [ asli ];
src = fetchFromGitHub {
owner = "UQ-PAC";
repo = "bap";
rev = "acfdc1067afa847fa1eadac9700eae349434dc3b";
sha256 = "sha256-FkfwMTbA9QS3vy4rs5Ua4egZg6/gQy3YzUG8xEyFo4A=";
};
}
})
1 change: 1 addition & 0 deletions default.nix
4 changes: 2 additions & 2 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ do-upgrade() {
[[ $MODE == upgrade ]]
}

PKGS=./pkgs.nix
PKGS=. # uses default.nix in current directory
TMP=$(mktemp)

PID=$$
Expand Down Expand Up @@ -66,7 +66,7 @@ update-github() {
if do-upgrade; then
nix-update -f "$PKGS" $attr --version branch=$branch --commit "${ARGS[@]}"
else
current=$(nix-instantiate --eval -E "(import ./$PKGS {}).$attr.src.rev" | jq -r)
current=$(nix-instantiate --eval $PKGS -A $attr.src.rev | jq -r)
COMPARE="https://api.github.com/repos/$repo/compare/$current...$branch"
compare=$(curl "$COMPARE")

Expand Down

0 comments on commit 7d30f4f

Please sign in to comment.