Skip to content

Commit

Permalink
build: Fix meson-build global_arguments
Browse files Browse the repository at this point in the history
* Added a CI-task to check if rizin could be used as subproject
* Fixed some new global-arguments in meson-build
  • Loading branch information
amibranch committed Nov 3, 2024
1 parent c6a3512 commit 1f9ff4a
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 2 deletions.
50 changes: 50 additions & 0 deletions .github/subproject_test/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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'),
]

# TODO: extend to perform actually linking test as well!
tester_source = custom_target('main.c',
command: ['echo', '''
#include <stdio.h>
int main(void) {
print("hello world\n");
return 0;
}
'''],
output: 'main.c',
capture: true,
)


subproj_tester = executable('subproj_tester',
tester_source,
dependencies: rz_deps,
pie: true,
install: true,
)

36 changes: 36 additions & 0 deletions .github/subproject_test/subprojects/rizin.wrap
Original file line number Diff line number Diff line change
@@ -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

81 changes: 81 additions & 0 deletions .github/workflows/subproject.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Subproject build

on:
push:
paths:
- '**.c'
- '**.h'
- '**.in'
- '**.inc'
- '**/meson.build'
- 'subprojects/**'
- 'test/**'
- '.github/workflows/subproject.yml'
- '.github/subproject_test/**'
branches:
- 'dev'
- 'stable'
- 'container-*'
pull_request:
paths:
- '**.c'
- '**.h'
- '**.in'
- '**.inc'
- '**/meson.build'
- 'subprojects/**'
- '.github/workflows/subproject.yml'
- '.github/subproject_test/**'
branches:
- 'dev'
- 'stable'
- 'release-*'

# Automatically cancel any previous workflow on new push.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true

jobs:
build:
name: meson-subproject
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: Checkout rizin
run: |
git clone https://github.com/${{ github.repository }} rizin_local
cd rizin_local
git fetch origin ${{ github.ref }}
git checkout -b local_branch FETCH_HEAD
- name: Replace branch in wrap-file
run: |
# FIXME: find a better solution!
sed -i 's@\${REPOSITORY}@file://'"$PWD"'/rizin_local@' .github/subproject_test/subprojects/rizin.wrap
sed -i 's@\${BRANCH}@local_branch@' .github/subproject_test/subprojects/rizin.wrap
#sed -i 's@\${REPOSITORY}@https://github.com/'"${{ github.repository }}"'@' .github/subproject_test/subprojects/rizin.wrap
#sed -i 's@\${BRANCH}@'"${{ github.ref }}"'@' .github/subproject_test/subprojects/rizin.wrap
#sed -i 's@\${BRANCH}@'"${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"'@' .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 -C build install

- name: Run unit tests
run: meson -C build test
- name: Execute test-binary
run: |
subproj_tester
4 changes: 2 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 1f9ff4a

Please sign in to comment.