From 1f74daff185b4d4beb2efdb95fc332fb20996e7e Mon Sep 17 00:00:00 2001 From: amibranch Date: Sun, 3 Nov 2024 19:15:36 +0000 Subject: [PATCH] build: Fix meson-build global_arguments * Added a CI-task to check if rizin could be used as subproject * Fixed some new global-arguments in meson-build --- .github/subproject_test/meson.build | 53 +++++++++++++++++++ .../subproject_test/subprojects/rizin.wrap | 36 +++++++++++++ .github/workflows/ci.yml | 28 ++++++++++ meson.build | 4 +- test/integration/meson.build | 8 +-- 5 files changed, 121 insertions(+), 8 deletions(-) create mode 100644 .github/subproject_test/meson.build create mode 100644 .github/subproject_test/subprojects/rizin.wrap diff --git a/.github/subproject_test/meson.build b/.github/subproject_test/meson.build new file mode 100644 index 00000000000..befc3c5efe4 --- /dev/null +++ b/.github/subproject_test/meson.build @@ -0,0 +1,53 @@ +project('subpoj_tester', 'c') + +rz_deps = [ + dependency('rz_core'), + dependency('rz_reg'), + dependency('rz_flag'), + dependency('rz_hash'), + dependency('rz_bin'), + dependency('rz_bp'), + dependency('rz_io'), + dependency('rz_search'), + dependency('rz_sign'), + dependency('rz_cons'), + dependency('rz_lang'), + dependency('rz_socket'), + dependency('rz_type'), + dependency('rz_debug'), + dependency('rz_il'), + dependency('rz_demangler'), + dependency('rz_util'), + dependency('rz_main'), + dependency('rz_crypto'), + dependency('rz_config'), + dependency('rz_egg'), + dependency('rz_syscall'), + dependency('rz_magic'), + ] + +tester_source = custom_target('main.c', + command: ['echo', ''' +#include + +int main(void) { + RzCore *core = rz_core_new(); + rz_cons_printf("hello world\n"); + rz_core_free(core); + return 0; +} + '''], + output: 'main.c', + capture: true, + ) + + +subproj_tester = executable('subproj_tester', + tester_source, + dependencies: rz_deps, + pie: true, + ) + +test('basic', subproj_tester) + + diff --git a/.github/subproject_test/subprojects/rizin.wrap b/.github/subproject_test/subprojects/rizin.wrap new file mode 100644 index 00000000000..2c1b24ea836 --- /dev/null +++ b/.github/subproject_test/subprojects/rizin.wrap @@ -0,0 +1,36 @@ +[wrap-git] + +url=${REPOSITORY} +revision=${BRANCH} + +depth = 1 + +[provide] +rz_core = rz_core_dep +rz_reg = rz_reg_dep +rz_flag = rz_flag_dep +rz_hash = rz_hash_dep +rz_bin = rz_bin_dep +rz_bp = rz_bp_dep +rz_io = rz_io_dep +rz_search = rz_search_dep +rz_sign = rz_sign_dep +rz_cons = rz_cons_dep +rz_lang = rz_lang_dep +rz_socket = rz_socket_dep +rz_type = rz_type_dep +rz_debug = rz_debug_dep +#rz_ghidra = rz_ghidra_dep +rz_il = rz_il_dep +rz_demangler = rz_demangler_dep +rz_util = rz_util_dep +rz_main = rz_main_dep +rz_asm = rz_asm_dep +rz_crypto = rz_crypto_dep +rz_config = rz_config_dep +rz_egg = rz_egg_dep +rz_syscall = rz_syscall_dep +rz_magic = rz_magic_dep +rz_parse = rz_parse_dep +rz_analysis = rz_analysis_dep + diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 217cf3c3826..69c696741e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1061,3 +1061,31 @@ jobs: push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.docker_meta.outputs.tags }} labels: ${{ steps.docker_meta.outputs.labels }} + meson-subproject: + name: Test use as meson subproject + needs: [ build-and-test ] + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - name: Install dependencies + run: | + sudo apt-get --assume-yes update + sudo apt-get --assume-yes install python3-wheel python3-setuptools pkgconf libcurl4-openssl-dev libpkgconf-dev libarchive-dev + sudo python3 -m pip install ninja meson + - name: Replace branch in wrap-file + run: | + # NOTE: This is a workaround, as meson wrap files cannot be used on remote tracking + git checkout -b "_ci_local_branch" + sed -i 's@\${REPOSITORY}@file://'"$PWD"'@' .github/subproject_test/subprojects/rizin.wrap + sed -i 's@\${BRANCH}@_ci_local_branch@' .github/subproject_test/subprojects/rizin.wrap + - name: Meson setup + run: meson setup build .github/subproject_test/ + - name: Checkout our Testsuite Binaries + uses: actions/checkout@v4 + with: + repository: rizinorg/rizin-testbins + path: .github/subproject_teyt/subprojects/rizin/test/bins + - name: Ninja compile and install + run: ninja -C build && sudo meson install -C build + - name: Run unit tests + run: meson test -C build diff --git a/meson.build b/meson.build index 19c5760123b..1b1e34643d5 100644 --- a/meson.build +++ b/meson.build @@ -84,10 +84,10 @@ endif # Hence, we have to disable them for the newer once. # Older compilers don't have these warnings and should not be included with #pragma if cc.has_argument('-Wenum-conversion') - add_global_arguments('-DCC_SUPPORTS_W_ENUM_CONVERION', language: ['c', 'cpp']) + add_project_arguments('-DCC_SUPPORTS_W_ENUM_CONVERION', language: ['c', 'cpp']) endif if cc.has_argument('-Wenum-compare') - add_global_arguments('-DCC_SUPPORTS_W_ENUM_COMPARE', language: ['c', 'cpp']) + add_project_arguments('-DCC_SUPPORTS_W_ENUM_COMPARE', language: ['c', 'cpp']) endif if cc.has_argument('--std=gnu99') diff --git a/test/integration/meson.build b/test/integration/meson.build index 4a9b00e0958..ba93d65ea57 100644 --- a/test/integration/meson.build +++ b/test/integration/meson.build @@ -1,10 +1,6 @@ -if get_option('enable_tests') +if get_option('enable_tests') and cli_enabled test_conf_data = configuration_data() - if cli_enabled - test_conf_data.set_quoted('RIZIN_BUILD_PATH', rizin_exe.full_path()) - else - test_conf_data.set_quoted('RIZIN_BUILD_PATH', meson.current_build_dir()) - endif + test_conf_data.set_quoted('RIZIN_BUILD_PATH', rizin_exe.full_path()) test_conf_data.set_quoted('TEST_BUILD_TYPES_DIR', fs.as_posix(types_build_dir)) test_config_h = configure_file( input: 'test_config.h.in',