Skip to content

Commit

Permalink
uses dune as the main build system
Browse files Browse the repository at this point in the history
Switches to dune as the main build system but keeps support for
OASIS with ocamlbuild and omake backends.

The implementation utilizes the dune sites and plugins system, but it
still supports plugins that are built with bapbuild. To ease the
transition, the OASIS-built BAP is also able to load dune
plugins. Later the OASIS build system will be removed from BAP but the
support for bundled with bapbuild plugins will remain.

Since dune sites impose their own restrictions we had to introduce a
new bap-common package that manages all the sites, starting from
plugins and ending with semantic files.
  • Loading branch information
ivg committed Dec 23, 2022
1 parent 79fd1a2 commit 07aa0fe
Show file tree
Hide file tree
Showing 539 changed files with 9,464 additions and 2,747 deletions.
60 changes: 11 additions & 49 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
#uses omake to build and test on ubuntu only

name: build-and-test
name: Run Tests
on:
- pull_request

jobs:
build:
runs-on: ubuntu-18.04

env:
OPAMJOBS: 2
OPAMRETRES: 8
runs-on: ubuntu-latest

steps:
- name: Checkout code
Expand All @@ -19,50 +13,18 @@ jobs:
- name: Install OCaml
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: 4.08.x
ocaml-compiler: 4.14.x
dune-cache: true
opam-disable-sandboxing: true
opam-local-packages: |
*.opam
!bap-radare2.opam
!bap-ghidra.opam
!bap-extra.opam
- name: Add the testing Repository
run: opam repo add bap git+https://github.com/BinaryAnalysisPlatform/opam-repository#testing

- name: Pin OASIS
run: opam pin add oasis https://github.com/BinaryAnalysisPlatform/oasis.git

- name: Install system dependencies
run: opam depext -u bap-extra

- name: Pin BAP
run: opam pin add bap . --no-action

- name: Install rest of the system dependencies
run: opam depext -u bap

- name: Install Ghidra
run: |
sudo add-apt-repository ppa:ivg/ghidra -y
sudo apt-get install libghidra-dev -y
sudo apt-get install libghidra-data -y
- name: Install opam dependencies
run: |
opam install bap --deps-only
opam install omake
- name: Configure BAP
run: |
opam exec -- ./configure-omake \
--enable-tests \
--with-llvm-version=9 \
--with-llvm-config=llvm-config-9
- name: Build BAP
run: opam exec -- make

- name: Install BAP
run: opam exec -- make reinstall

- name: Run Unit Tests
run: opam exec -- make test
run: opam install bap.dev --inplace-build

- name: Run Functional Tests
run: opam exec -- make check
Expand All @@ -77,7 +39,7 @@ jobs:
if: ${{ always() }}
with:
name: unit-tests-log
path: _build/oUnit-*.log
path: _build/default/lib_test/*/oUnit-*.log

- uses: actions/upload-artifact@v2
if: ${{ always() }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jobs:
- ubuntu-20.04
- macos-11
ocaml-compiler:
- 4.11.x
- 4.08.x
- 4.14.x

runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.os == 'macos-11'}}
Expand All @@ -28,39 +28,52 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: Install Dejagnu
if: matris.os == ubuntu-20.04
run: |
sudo apt-get install dejagnu -y
- name: Use OCaml ${{ matrix.ocaml-compiler }}
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}
dune-cache: ${{ matrix.os != 'macos-11' }}

- name: Add the testing Repository
- name: Add the testing Repository for ppx_bap
run: opam repo add bap git+https://github.com/BinaryAnalysisPlatform/opam-repository#testing

- name: Pin BAP
run: opam pin add bap . --no-action

- name: Configure Homebrew LLVM
if: matrix.os == 'macos-11'
run: |
rm -rf /usr/local/bin/2to3
rm -f $(opam var lib)/ocaml/version
brew unlink gcc@9
brew update
brew upgrade
echo 'LLVM_CONFIG=/usr/local/opt/llvm@9/bin/llvm-config' >> $GITHUB_ENV
- name: Install system dependencies
run: opam depext -u bap
- name: Pin BAP
run: opam pin add bap . --deps-only

- name: Configure OASIS
run: |
./configure --enable-everything \
--disable-ghidra \
--disable-ida \
--prefix=$(opam var prefix) \
--with-llvm-config=llvm-config
- name: Install opam dependencies
run: opam install bap --deps-only
run: make && make reinstall

- name: Run Functional Tests
run: make check

- name: Build and Install BAP
run: opam install bap
- uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: bap-log
path: ~/.local/state/bap

- uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: opam-log-${{ matrix.os }}-${{ matrix.ocaml-compiler }}
path: ~/.opam/log
name: fun-tests-log
path: |
testsuite/*.log
testsuite/logs
56 changes: 56 additions & 0 deletions .github/workflows/build-opam-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Build Local Packages

on:
pull_request:

jobs:
build:
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
ocaml-compiler:
- 4.08.x
- 4.14.x

runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.os == 'macos-11'}}

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Ghidra and Dejagnu
run: |
sudo add-apt-repository ppa:ivg/ghidra -y
sudo apt-get install libghidra-dev -y
sudo apt-get install libghidra-data -y
sudo apt-get install dejagnu -y
- name: Use OCaml ${{ matrix.ocaml-compiler }}
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}
dune-cache: true

- name: Install BAP
- run: opam install .


- name: Run Functional Tests
run: make check

- uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: bap-log
path: ~/.local/state/bap

- uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: fun-tests-log
path: |
testsuite/*.log
testsuite/logs
4 changes: 3 additions & 1 deletion .github/workflows/check-the-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ jobs:
- name: Setup OCaml
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: 4.08.x
ocaml-compiler: 4.14.x
opam-pin: false
opam-depext: false
dune-cache: true

- name: Check the Style
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,8 @@ bap_main_config.ml
tools/postinstall.ml
OMakefile
/testsuite/
/config.status
/config.status.in
/_opam/
/plugins/api/api_sites.ml
/plugins/stub_resolver/stub_resolver_sites.ml
96 changes: 0 additions & 96 deletions .merlin

This file was deleted.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ testsuite:
git clone https://github.com/BinaryAnalysisPlatform/bap-testsuite.git testsuite

check: testsuite
make REVISION=5909f59c5c29a7b143573bd49b8101a68ccded32 -C testsuite
make REVISION=0db9ed25bcb56bb6fc36ef3f662fb9d60ead37e7 -C testsuite

.PHONY: indent check-style status-clean

Expand Down
37 changes: 37 additions & 0 deletions bap-abi.opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
version: "dev"
synopsis: "BAP plugin and library for ABI-specific transformations"
maintainer: ["Ivan Gotovchits <[email protected]>"]
authors: ["The BAP Team"]
license: "MIT"
tags: ["bap" "bap-pass" "bap-plugin"]
homepage: "https://github.com/BinaryAnalysisPlatform/bap"
bug-reports: "https://github.com/BinaryAnalysisPlatform/bap/issues"
depends: [
"dune" {>= "3.1"}
"bap-main" {= version}
"bap-std" {= version}
"core_kernel" {>= "v0.14" & < "v0.16"}
"bap-common" {= version}
"ppx_bap" {= version}
"regular" {= version}
"odoc" {with-doc}
]
build: [
["dune" "subst"] {dev}
[
"dune"
"build"
"-p"
name
"-j"
jobs
"--promote-install-files=false"
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
["dune" "install" "-p" name "--create-install-files" name]
]
dev-repo: "git+https://github.com/BinaryAnalysisPlatform/bap.git"
Loading

0 comments on commit 07aa0fe

Please sign in to comment.