image: openbsd/latest
packages:
    - devel/meson
    - devel/pkgconf
    - devel/gmake
    - devel/llvm
    - archivers/cabextract
    - lang/python
environment:
    CXX: clang++
    CC: clang
sources:
    - https://github.com/rizinorg/rizin
    - https://github.com/rizinorg/rizin-testbins
tasks:
    - rzpipe: |
        /usr/local/bin/python3 -m ensurepip --user
        /usr/local/bin/python3 -m pip install --user 'git+https://github.com/rizinorg/rz-pipe#egg=rzpipe&subdirectory=python'
    - build: |
        cd rizin
        meson --prefix=${HOME} build
        ninja -C build
    - install: |
        cd rizin
        export PATH=${HOME}/bin:${PATH}
        export LD_LIBRARY_PATH=${HOME}/lib:${HOME}/lib64:${LD_LIBRARY_PATH}
        export PKG_CONFIG_PATH=${HOME}/lib/pkgconfig:${PKG_CONFIG_PATH}
        ninja -C build install
    - unittest: |
        cd rizin
        export PATH=${HOME}/bin:/usr/local/bin:${PATH}
        export LD_LIBRARY_PATH=${HOME}/lib:${HOME}/lib64:${LD_LIBRARY_PATH}
        export PKG_CONFIG_PATH=${HOME}/lib/pkgconfig:${PKG_CONFIG_PATH}
        # Workaround until the feature request is solved
        # https://todo.sr.ht/~sircmpwn/builds.sr.ht/274
        ln -s ${HOME}/rizin-testbins test/bins
        # Running the unit tests
        ninja -C build test
    - test: |
        cd rizin
        export PATH=${HOME}/bin:/usr/local/bin:${PATH}
        export LD_LIBRARY_PATH=${HOME}/lib:${HOME}/lib64:${LD_LIBRARY_PATH}
        export PKG_CONFIG_PATH=${HOME}/lib/pkgconfig:${PKG_CONFIG_PATH}
        # Workaround until the feature request is solved
        # https://todo.sr.ht/~sircmpwn/builds.sr.ht/274
        ln -s ${HOME}/rizin-testbins test/bins
        cd test
        # Running the unit tests
        rz-test -L -o results.json
