Switch to meson subprojects and wraps

* Remove tree-sitter/sdb git submodules and move them to meson subprojects/wraps
* Use meson subprojects/wraps to get capstone
* Remove capstone patches as they are already applied to rizinorg/capstone repository
* Use meson from master branch to create the release tarball, as all released versions so far have a bug that prevent wrap-git to be patched correctly when creating the tarball with meson dist
* Add check_meson_subproject script to do a quick check if the currently downloaded subprojects are updated
* Add subprojects_check meson option to skip the check_meson_subproject script
* Update documentation to remove references to git submodules.
This commit is contained in:
Riccardo Schirone 2021-02-03 12:31:11 -01:00 committed by GitHub
parent a8d4a8a9a9
commit f8291ee3c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 519 additions and 516 deletions

View file

@ -4,6 +4,7 @@ version: 'git.{build}'
# Skip Github tags
skip_tags: true
# Environment variables
environment:
NINJA_URL: https://github.com/ninja-build/ninja/releases/download/v1.9.0/ninja-win.zip
@ -59,8 +60,6 @@ init:
# Required software for building
install:
# Download submodules
- cmd: git submodule update --init --recursive
# Update environment variables
- ps: $env:RZ_VERSION = ( python sys\\version.py )
- ps: $env:DIST_FOLDER = "rizin-$env:builder-$env:RZ_VERSION"
@ -72,9 +71,9 @@ install:
build_script:
- appveyor AddMessage "Compiling rizin %RZ_VERSION% (%builder%)"
- cmd: if %builder% == vs2017_64 ( set "PATH=C:\mingw\bin;C:\mingw\msys\1.0\bin;%PYTHON%;%PATH%" && call "%VSVARSALLPATH2017%" x64 && %PYTHON%\Scripts\meson --buildtype=release --prefix="%CD%\%DIST_FOLDER%" --default-library=static -Dstatic_runtime=true -Duse_webui=true build && %PYTHON%\Scripts\ninja -C build install && 7z a %ARTIFACT_ZIP% %DIST_FOLDER% )
- cmd: if %builder% == vs2017_64 ( set "PATH=C:\mingw\bin;C:\mingw\msys\1.0\bin;%PYTHON%;%PATH%" && call "%VSVARSALLPATH2017%" x64 && %PYTHON%\Scripts\meson --buildtype=release --prefix="%CD%\%DIST_FOLDER%" --default-library=static -Db_vscrt=static_from_buildtype -Duse_webui=true build && %PYTHON%\Scripts\ninja -C build install && 7z a %ARTIFACT_ZIP% %DIST_FOLDER% )
- cmd: if %builder% == vs2019_64 ( choco install mingw && refreshenv && set "PATH=C:\mingw\bin;C:\mingw\msys\1.0\bin;%PYTHON%;%PATH%" && call "%VSVARSALLPATH2019%" x64 && %PYTHON%\Scripts\meson --buildtype=release --prefix="%CD%\%DIST_FOLDER%" --default-library=static -Dstatic_runtime=true -Duse_webui=true build && %PYTHON%\Scripts\ninja -C build install && 7z a %ARTIFACT_ZIP% %DIST_FOLDER% )
- cmd: if %builder% == vs2019_64 ( choco install mingw && refreshenv && set "PATH=C:\mingw\bin;C:\mingw\msys\1.0\bin;%PYTHON%;%PATH%" && call "%VSVARSALLPATH2019%" x64 && %PYTHON%\Scripts\meson --buildtype=release --prefix="%CD%\%DIST_FOLDER%" --default-library=static -Db_vscrt=static_from_buildtype -Duse_webui=true build && %PYTHON%\Scripts\ninja -C build install && 7z a %ARTIFACT_ZIP% %DIST_FOLDER% )
- cmd: if %builder% == vs2017_64_dyn ( set "PATH=C:\mingw\bin;C:\mingw\msys\1.0\bin;%PYTHON%;%PATH%" && call "%VSVARSALLPATH2017%" x64 && %PYTHON%\Scripts\meson --buildtype=release --prefix="%CD%\%DIST_FOLDER%" -Duse_webui=true build && %PYTHON%\Scripts\ninja -C build install && 7z a %ARTIFACT_ZIP% %DIST_FOLDER% )

View file

@ -34,7 +34,7 @@ jobs:
macos-meson-clang-tests,
linux-gcc-tests-asan,
capstone-v3,
capstone-v5
capstone-next
]
include:
- name: linux-meson-clang-tests
@ -89,11 +89,11 @@ jobs:
enabled: ${{ github.event_name != 'pull_request' || contains(github.head_ref, 'capstone') }}
timeout: 45
cflags: '-Werror -Wno-cpp'
- name: capstone-v5
- name: capstone-next
os: ubuntu-20.04
build_system: meson
compiler: gcc
meson_options: -Duse_capstone_version=v5
meson_options: -Duse_capstone_version=next
run_tests: false
enabled: ${{ github.event_name != 'pull_request' || contains(github.head_ref, 'capstone') }}
timeout: 45
@ -102,8 +102,6 @@ jobs:
steps:
- uses: actions/checkout@v2
if: matrix.enabled
with:
submodules: recursive
- name: Install pkg-config and cabextract with Homebrew
if: matrix.os == 'macos-latest' && matrix.enabled
run: brew install pkg-config cabextract
@ -228,11 +226,6 @@ jobs:
cd rizin
git fetch origin ${{ github.ref }}
git checkout -b local_branch FETCH_HEAD
git submodule init
git submodule update
- name: Fetch capstone manually
run: git clone -b v4 https://github.com/rizinorg/capstone shlr/capstone
working-directory: rizin
- name: Checkout our Testsuite Binaries
run: git clone https://github.com/rizinorg/rizin-testbins test/bins
working-directory: rizin
@ -297,12 +290,6 @@ jobs:
cd rizin
git fetch origin ${{ github.ref }}
git checkout -b local_branch FETCH_HEAD
git submodule init
git submodule update
- name: Fetch capstone manually
if: matrix.container == 'debian:wheezy'
run: git clone -b v4 https://github.com/rizinorg/capstone shlr/capstone
working-directory: rizin
- name: Checkout our Testsuite Binaries
run: git clone https://github.com/rizinorg/rizin-testbins test/bins
working-directory: rizin
@ -343,8 +330,6 @@ jobs:
cd rizin
git fetch origin ${{ github.ref }}
git checkout -b local_branch FETCH_HEAD
git submodule init
git submodule update
- name: Checkout our Testsuite Binaries
run: git clone https://github.com/rizinorg/rizin-testbins test/bins
working-directory: rizin
@ -388,11 +373,11 @@ jobs:
steps:
- name: Install python and other dependencies
run: sudo apt-get --assume-yes install python3-wheel python3-setuptools python3-pip
- name: Download meson from git (temporary)
run: pip3 install --user git+https://github.com/mesonbuild/meson
- name: Install meson and ninja
run: pip3 install --user meson ninja PyYAML
run: pip3 install --user ninja PyYAML
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Extract rizin version
shell: bash
run: echo "##[set-output name=version;]$(python sys/version.py)"
@ -417,8 +402,6 @@ jobs:
needs: [build-and-test]
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Install pkg-config with Homebrew
run: brew install pkg-config
- name: Install meson and ninja
@ -445,14 +428,12 @@ jobs:
include:
- name: vs2019_static
compiler: cl
meson_options: --default-library=static -Dstatic_runtime=true
meson_options: --default-library=static -Db_vscrt=static_from_buildtype
- name: clang_cl
compiler: clang-cl
meson_options: --default-library=shared
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- uses: actions/setup-python@v2
- name: Install dependencies
run: |
@ -499,8 +480,6 @@ jobs:
name: [x86_64, arm, aarch64]
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Install dependencies
run: sudo apt-get --assume-yes install pax wget unzip python3-wheel python3-setuptools python3-pip && pip3 install --user meson ninja
- name: Compile with meson
@ -619,8 +598,6 @@ jobs:
needs: [build-windows]
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- uses: actions/setup-python@v2
- name: Install pkg-config
shell: pwsh
@ -667,8 +644,6 @@ jobs:
]
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Extract rizin version
shell: bash
run: echo "##[set-output name=branch;]$(python sys/version.py)"
@ -766,8 +741,6 @@ jobs:
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Login to DockerHub
uses: docker/login-action@v1
with:

View file

@ -16,8 +16,6 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
submodules: recursive
- name: Update package database
run: sudo apt --assume-yes update
@ -53,9 +51,7 @@ jobs:
- name: Exclude external lib
run: |
grep -Rl 'rizin/shlr/capstone' reports | xargs rm -fv
grep -Rl 'rizin/shlr/sdb' reports | xargs rm -fv
grep -Rl 'rizin/shlr/tree-sitter' reports | xargs rm -fv
grep -Rl 'rizin/subprojects' reports | xargs rm -fv
- name: Merge all files
run: npx @microsoft/sarif-multitool merge reports/**/*.sarif

View file

@ -18,7 +18,6 @@ jobs:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2
submodules: recursive
- name: Install python and other dependencies
run: sudo apt-get --assume-yes install python3-wheel python3-setuptools

View file

@ -3,9 +3,7 @@ name: Rizin CI tree-sitter test
on:
pull_request:
paths:
- 'shlr/tree-sitter/*'
- 'shlr/tree-sitter/lib/*'
- 'shlr/tree-sitter/lib/**/*'
- 'subprojects/tree-sitter.wrap'
- 'shlr/rizin-shell-parser/*'
- 'shlr/rizin-shell-parser/**/*'
branches:

View file

@ -20,8 +20,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Checkout TinyCC repository
run: |

8
.gitignore vendored
View file

@ -129,4 +129,12 @@ vgcore.*
librz/include/sdb
peda-session-*
/.vs
subprojects/capstone-3.0.5
subprojects/capstone-4.0.2
subprojects/capstone-next
subprojects/capstone-bundled
subprojects/sdb
subprojects/tree-sitter-0.17.3
subprojects/tree-sitter-0.18.0
subprojects/packagecache
.cache/

6
.gitmodules vendored
View file

@ -1,6 +0,0 @@
[submodule "shlr/sdb"]
path = shlr/sdb
url = https://github.com/rizinorg/sdb
[submodule "shlr/tree-sitter"]
path = shlr/tree-sitter
url = https://github.com/tree-sitter/tree-sitter

View file

@ -1,21 +1,11 @@
# Clone the Rizin project and keep it updated
Rizin uses submodules, so make sure to clone them as well. The first time you
download Rizin you can use:
```
$ git clone --recurse-submodules https://github.com/rizinorg/rizin
```
or:
The first time you download Rizin you can use:
```
$ git clone https://github.com/rizinorg/rizin
$ cd rizin
$ git submodule init
$ git submodule update
```
After that, use `git pull --recurse-submodules` to update both the Rizin
codebase and submodules, or `git submodule update` to just update the
submodules.
After that, use `git pull` to update the Rizin codebase.
# Build
@ -163,8 +153,7 @@ corresponding package manager's method for removing a package to uninstall Rizin
# Update
Firstly, use `git pull --recurse-submodules` to update both the Rizin
codebase and its submodules to the latest version.
Firstly, use `git pull` to update the Rizin codebase to the latest version.
To re-build Rizin after you have updated your source code, you can use:
```

View file

@ -75,7 +75,7 @@ RUN apt-get update && \
cd /mnt && \
git clone -b "$RZ_PIPE_PY_VERSION" https://github.com/rizinorg/rz-pipe && \
pip3 install ./rz-pipe/python && \
git clone -b "$RZ_VERSION" --recurse-submodules https://github.com/rizinorg/rizin.git && \
git clone -b "$RZ_VERSION" https://github.com/rizinorg/rizin.git && \
cd rizin && \
meson build && \
meson compile -C build && \

View file

@ -25,9 +25,9 @@ Use `meson` to compile and install Rizin. Please make sure to get an updated
`meson` (e.g. get it with `pip install meson` if your system does not provide
one that is at least version 0.55.0).
Clone this repository and make sure to clone the submodules as well:
Clone this repository:
```
$ git clone --recurse-submodules https://github.com/rizinorg/rizin
$ git clone https://github.com/rizinorg/rizin
```
Then compile and install with:

View file

@ -6,15 +6,26 @@ Thank you for taking the time to package Rizin!
There are some things to consider when packaging Rizin for your distribution.
We will look at each step below.
Cloning Source
Releases vs Git content
--------------
Rizin uses git submodules to track versions of dependencies. You can check out
the Rizin source and all dependencies using
`git clone --recursive https://github.com/rizinorg/rizin`.
If you package a Rizin Release, you will find the tarball with all
dependencies used by Rizin in the
[Release page](https://github.com/rizinorg/rizin/releases) and you can go to
the next step in this document.
If you change branches run `git submodule update --init --recursive` to ensure
you are tracking the correct versions of the submodules.
If you want to package a particular git version, keep in mind that Rizin uses
meson subprojects to track versions of dependencies. Subprojects are usually
downloaded during the meson setup step, however if you can't download
additional code while building the package for your distribution you can
predownload everything with the following command:
```
$ git clone https://github.com/rizinorg/rizin
$ cd rizin
$ meson subprojects download
```
If you want to prepare a special tarball to use within your distribution,
have a look at [`meson dist`](https://mesonbuild.com/Creating-releases.html).
See [BUILDING.md][] for more details.

View file

@ -4,15 +4,16 @@ Capstone
Capstone Engine is the disassembler engine used by Rizin by default for
some architectures.
Rizin supports capstone 3, 4 and 5.
Rizin supports capstone 3, 4 and next.
* capstone3: legacy support (only for Debian probably)
* capstone4: stable release at the moment of writing this
* capstone5: next branch, still under development
* capstone-next: next branch, still under development
By default Rizin will build statically against a bundled version of capstone4
(with some custom patches applied). Please be aware that by default Rizin will
download Capstone in the source directory `shlr/capstone`.
(with some custom patches applied). Please be aware that by default Rizin
will download Capstone through meson subprojects in the source directory
`subprojects/capstone`.
Using system capstone
---------------------
@ -35,20 +36,5 @@ $ meson -Duse_capstone_version=v3 build-capstonev3
```
or
```
$ meson -Duse_capstone_version=v5 build-capstonev5
```
Test different capstone versions
----------------------
As mentioned before, by default Rizin downloads capstone code in the source
directory `shlr/capstone`, so if you want to test the same set of changes on
multiple Capstone versions, you have to specify the `capstone_in_builddir`
option.
```
$ meson -Dcapstone_in_builddir=true -Duse_capstone_version=v3 build-capstonev3
```
The above command, for example, will download the Capstone code in the *build*
directory `build-capstonev3/shlr/capstone` instead of the *source* one.
$ meson -Duse_capstone_version=next build-capstonev5
```

View file

@ -2,6 +2,9 @@ project('rizin', 'c',
version: 'v0.2.0-git',
license: 'LGPL3',
meson_version: '>=0.55.0',
default_options: [
'b_vscrt=from_buildtype',
]
)
py3_exe = import('python').find_installation()
@ -11,11 +14,12 @@ pkgconfig_mod = import('pkgconfig')
# Python scripts used during the build process
create_tags_rz_py = files('sys/create_tags_rz.py')
syscall_preprocessing_py = files('sys/syscall_preprocessing.py')
check_meson_subproject_py = files('sys/check_meson_subproject.py')
git_exe_repo_py = files('sys/meson_git_wrapper.py')
is_static_build = get_option('static_runtime')
if is_static_build and get_option('default_library') != 'static'
error('Cannot use `static_runtime` when libraries are dynamically built. Set `--default-library=true` if you want to build statically.')
error('Cannot use `static_runtime` when libraries are dynamically built. Set `--default-library=static` if you want to build statically.')
endif
# Get rizin version and compute various version parts
@ -51,11 +55,6 @@ gittip = ''
git_dir_exists = run_command(py3_exe, '-c', '__import__("sys").exit(0 if __import__("os").path.isdir(".git") else 1)')
if git_exe.found() and git_dir_exists.returncode() == 0
sdb_src_exists = run_command(py3_exe, '-c', '__import__("sys").exit(0 if __import__("os").listdir("shlr/sdb/") else 1)')
if sdb_src_exists.returncode() == 1
error('Source code for SDB not found. Did you forget to run `git submodule update --init`?')
endif
# Get gittip
git_rev_parse = run_command(py3_exe, git_exe_repo_py, git_exe, repo, 'rev-parse', 'HEAD')
if git_rev_parse.returncode() == 0
@ -111,6 +110,7 @@ endif
platform_inc = include_directories(platform_inc)
if is_static_build and cc.get_id() == 'msvc'
# Use -Db_vscrt=static_from_buildtype to avoid warnings due to multiple /M options
add_project_arguments('/MT', language: 'c')
endif
@ -134,7 +134,7 @@ if cc.get_id() == 'clang-cl'
endif
if get_option('default_library') == 'shared'
if host_machine.system() != 'windows' or cc.get_id()!='msvc' and cc.get_id()!='clang-cl'
if cc.has_argument('-fvisibility=hidden')
add_project_arguments('-fvisibility=hidden', language: 'c')
endif
endif
@ -422,83 +422,14 @@ if not zlib_dep.found() or not get_option('use_sys_zlib')
)
endif
# handle sdb dependency
# NOTE: copying most of the stuff from sdb to here for the moment, since we
# should use subpackages to handle this well
sdb_files = [
'shlr/sdb/src/array.c',
'shlr/sdb/src/base64.c',
'shlr/sdb/src/buffer.c',
'shlr/sdb/src/set.c',
'shlr/sdb/src/cdb.c',
'shlr/sdb/src/cdb_make.c',
'shlr/sdb/src/diff.c',
'shlr/sdb/src/disk.c',
'shlr/sdb/src/fmt.c',
'shlr/sdb/src/ht_uu.c',
'shlr/sdb/src/ht_up.c',
'shlr/sdb/src/ht_pp.c',
'shlr/sdb/src/journal.c',
'shlr/sdb/src/json.c',
'shlr/sdb/src/lock.c',
'shlr/sdb/src/ls.c',
'shlr/sdb/src/match.c',
'shlr/sdb/src/ns.c',
'shlr/sdb/src/num.c',
'shlr/sdb/src/query.c',
'shlr/sdb/src/sdb.c',
'shlr/sdb/src/sdbht.c',
'shlr/sdb/src/text.c',
'shlr/sdb/src/util.c'
]
sdb_inc = [platform_inc, include_directories('shlr/sdb/src')]
# Create sdb_version.h
r = run_command(py3_exe, 'sys/sdb_version.py', 'shlr/sdb/config.mk')
if r.returncode() == 0
sdb_version = r.stdout().strip().split('\n')[0]
else
sdb_version = 'unknown'
r = run_command(py3_exe, check_meson_subproject_py, 'sdb')
if r.returncode() == 1 and get_option('subprojects_check')
error('Subproject sdb is not updated. Please make sure to run `meson subprojects update` or set option `subprojects_check=false` if you want to compile against currently downloaded subproject.')
endif
run_command(py3_exe, '-c', 'with open("shlr/sdb/src/sdb_version.h", "w") as f: f.write("#define SDB_VERSION \"' + sdb_version + '\"")')
sdb_inc_files = [
'shlr/sdb/src/buffer.h',
'shlr/sdb/src/cdb.h',
'shlr/sdb/src/set.h',
'shlr/sdb/src/cdb_make.h',
'shlr/sdb/src/config.h',
'shlr/sdb/src/ht_inc.h',
'shlr/sdb/src/ht_pp.h',
'shlr/sdb/src/ht_up.h',
'shlr/sdb/src/ht_uu.h',
'shlr/sdb/src/ls.h',
'shlr/sdb/src/sdb.h',
'shlr/sdb/src/sdbht.h',
'shlr/sdb/src/sdb_version.h',
'shlr/sdb/src/types.h'
]
install_headers(sdb_inc_files, install_dir: rizin_incdir / 'sdb')
librzsdb = static_library('rzsdb', sdb_files,
include_directories: sdb_inc,
implicit_include_directories: false,
)
sdb_dep = declare_dependency(
link_whole: librzsdb,
include_directories: sdb_inc
)
sdb_exe = executable('sdb', ['shlr/sdb/src/main.c'] + sdb_files,
include_directories: [
include_directories(['shlr/sdb/src'])
],
implicit_include_directories: false,
native: true,
)
sdb_proj = subproject('sdb', default_options: ['default_library=static', 'sdb_includedir=' + rizin_incdir])
sdb_dep = sdb_proj.get_variable('sdb_dep')
sdb_exe = sdb_proj.get_variable('sdb_native_exe')
sdb_gen_cmd = [
sdb_exe,
@ -507,7 +438,6 @@ sdb_gen_cmd = [
'@INPUT@'
]
# handle spp dependency
spp_files = [
'shlr/spp/spp.c'
]
@ -544,7 +474,6 @@ endif
rpath_exe = ''
rpath_lib = ''
if use_rpath
message('RPATH will be used to link libraries and executables')
rpath_exe = '$ORIGIN/../' + get_option('libdir')
rpath_lib = '$ORIGIN'
endif

View file

@ -1,9 +1,10 @@
option('packager', type: 'string', value: '', description: 'Extra packager name')
option('packager_version', type: 'string', value: '', description: 'Extra packager version')
option('cli', type: 'feature', value: 'auto', description: 'Build CLI programs (“auto” means they will be built when not a subproject)')
option('static_runtime', type: 'boolean', value: false, description: 'Set to true when building a static version of Rizin')
option('static_runtime', type: 'boolean', value: false, description: 'Set to true when you want static libraries/dependencies and runtime in Rizin')
option('local', type: 'feature', value: 'auto', description: 'Adds support for local/side-by-side installation (sets rpath if needed)')
option('blob', type: 'boolean', value: false, description: 'Compile just one binary which dispatch to the right handlers based on the name used to call it')
option('subprojects_check', type: 'boolean', value: true, description: 'Check if git subprojects are up-to-date. Might be useful to disable this when developing on a different subproject version')
option('rizin_wwwroot', type: 'string', value: '', description: 'Install path for www files')
option('rizin_sdb', type: 'string', value: '', description: '')
@ -19,10 +20,8 @@ option('rizin_bindings', type: 'string', value: '', description: 'Path where riz
option('rizin_version_commit', type: 'string', value: '')
option('rizin_gittip', type: 'string', value: '')
option('checks_level', type: 'integer', value: 9999, description: 'Value between 0 and 3 to enable different level of assert (see RZ_CHECKS_LEVEL). By default its value depends on buildtype (2 on debug, 1 on release).')
option('capstone_in_builddir', type: 'boolean', value: false, description: 'When true, capstone is downloaded in the build directory and not in the source one')
option('use_sys_capstone', type: 'boolean', value: false)
option('use_capstone_version', type: 'combo', choices: ['v3', 'v4', 'v5'], value: 'v4')
option('use_capstone5', type: 'boolean', value: false, description: 'Deprecated. See use_capstone_version')
option('use_capstone_version', type: 'combo', choices: ['v3', 'v4', 'next', 'bundled'], value: 'bundled', description: 'Specify which version of capstone to use')
option('use_sys_magic', type: 'boolean', value: false)
option('use_sys_zip', type: 'boolean', value: false)
option('use_sys_zlib', type: 'boolean', value: false)
@ -33,7 +32,7 @@ option('use_sys_tree_sitter', type: 'boolean', value: false)
option('use_libuv', type: 'boolean', value: true)
option('debugger', type: 'boolean', value: true)
option('use_webui', type: 'boolean', value: false, description: 'install different WebUIs for rizin')
option('use_webui', type: 'boolean', value: false, description: 'Install different WebUIs for rizin')
option('enable_tests', type: 'boolean', value: true, description: 'Build unit tests in test/unit')
option('enable_rz_test', type: 'boolean', value: true, description: 'Build rz_test executable for regression testing')

View file

@ -1,17 +0,0 @@
diff --git a/arch/X86/X86Mapping.c b/arch/X86/X86Mapping.c
index f7d35d2..06827c3 100644
--- a/arch/X86/X86Mapping.c
+++ b/arch/X86/X86Mapping.c
@@ -2767,9 +2767,9 @@ static bool intel_regs_sorted = false;
// this is to handle instructions embedding accumulate registers into AsmStrs[]
x86_reg X86_insn_reg_intel(unsigned int id, enum cs_ac_type *access)
{
- unsigned int first = 0;
- unsigned int last = ARR_SIZE(insn_regs_intel) - 1;
- unsigned int mid = ARR_SIZE(insn_regs_intel) / 2;
+ int first = 0;
+ int last = ARR_SIZE(insn_regs_intel) - 1;
+ int mid = ARR_SIZE(insn_regs_intel) / 2;
if (!intel_regs_sorted) {
memcpy (insn_regs_intel_sorted, insn_regs_intel,

View file

@ -1,51 +0,0 @@
diff --git a/MCInst.c b/MCInst.c
index 7041022..d173d98 100644
--- a/MCInst.c
+++ b/MCInst.c
@@ -23,6 +23,7 @@ void MCInst_Init(MCInst *inst)
inst->Operands[i].Kind = kInvalid;
}
+ memset (inst, 0, sizeof (MCInst));
inst->Opcode = 0;
inst->OpcodePub = 0;
inst->size = 0;
diff --git a/cs.c b/cs.c
index d2ffecc..f12051a 100644
--- a/cs.c
+++ b/cs.c
@@ -840,7 +840,7 @@ size_t CAPSTONE_API cs_disasm(csh ud, const uint8_t *buffer, size_t size, uint64
size_org = size;
total_size = sizeof(cs_insn) * cache_size;
- total = cs_mem_malloc(total_size);
+ total = cs_mem_calloc(1, total_size);
if (total == NULL) {
// insufficient memory
handle->errnum = CS_ERR_MEM;
@@ -858,7 +858,7 @@ size_t CAPSTONE_API cs_disasm(csh ud, const uint8_t *buffer, size_t size, uint64
if (handle->detail) {
// allocate memory for @detail pointer
- insn_cache->detail = cs_mem_malloc(sizeof(cs_detail));
+ insn_cache->detail = cs_mem_calloc(1, sizeof(cs_detail));
} else {
insn_cache->detail = NULL;
}
@@ -946,6 +946,7 @@ size_t CAPSTONE_API cs_disasm(csh ud, const uint8_t *buffer, size_t size, uint64
if (f == cache_size) {
// full cache, so expand the cache to contain incoming insns
cache_size = cache_size * 8 / 5; // * 1.6 ~ golden ratio
+ unsigned int old_size = total_size;
total_size += (sizeof(cs_insn) * cache_size);
tmp = cs_mem_realloc(total, total_size);
if (tmp == NULL) { // insufficient memory
@@ -960,7 +961,7 @@ size_t CAPSTONE_API cs_disasm(csh ud, const uint8_t *buffer, size_t size, uint64
handle->errnum = CS_ERR_MEM;
return 0;
}
-
+ memset ((char *)total + (sizeof(cs_insn) * old_size), 0, (total_size - old_size));
total = tmp;
// continue to fill in the cache after the last instruction
insn_cache = (cs_insn *)((char *)total + sizeof(cs_insn) * c);

View file

@ -1,28 +0,0 @@
diff --git a/arch/X86/X86ATTInstPrinter.c b/arch/X86/X86ATTInstPrinter.c
index 01bb3e2..f850d07 100644
--- a/arch/X86/X86ATTInstPrinter.c
+++ b/arch/X86/X86ATTInstPrinter.c
@@ -640,6 +640,9 @@ static void printPCRelImm(MCInst *MI, unsigned OpNo, SStream *O)
if (MI->Opcode == X86_CALLpcrel16 || MI->Opcode == X86_JMP_2)
imm = imm & 0xffff;
+ if (MI->csh->mode == CS_MODE_16)
+ imm |= (MI->address >> 16) << 16;
+
if (imm < 0) {
SStream_concat(O, "0x%"PRIx64, imm);
} else {
diff --git a/arch/X86/X86IntelInstPrinter.c b/arch/X86/X86IntelInstPrinter.c
index b7ac142..a1b3739 100644
--- a/arch/X86/X86IntelInstPrinter.c
+++ b/arch/X86/X86IntelInstPrinter.c
@@ -857,6 +857,9 @@ static void printPCRelImm(MCInst *MI, unsigned OpNo, SStream *O)
if (MI->Opcode == X86_CALLpcrel16 || MI->Opcode == X86_JMP_2)
imm = imm & 0xffff;
+ if (MI->csh->mode == CS_MODE_16)
+ imm |= (MI->address >> 16) << 16;
+
printImm(MI, O, imm, true);
if (MI->csh->detail) {

View file

@ -1,14 +0,0 @@
diff --git a/arch/Sparc/SparcGenAsmWriter.inc b/arch/Sparc/SparcGenAsmWriter.inc
index 9ed9760..9694d05 100644
--- a/arch/Sparc/SparcGenAsmWriter.inc
+++ b/arch/Sparc/SparcGenAsmWriter.inc
@@ -1202,6 +1202,9 @@ static char *getRegisterName(unsigned RegNo)
//for (i = 0; i < sizeof(RegAsmOffset)/2; i++)
// printf("%s = %u\n", AsmStrs+RegAsmOffset[i], i + 1);
//printf("*************************\n");
+if (RegNo < 1 || RegNo > sizeof (RegAsmOffset) / sizeof (*RegAsmOffset)) {
+ return NULL;
+}
return AsmStrs+RegAsmOffset[RegNo-1];
#else
return NULL;

View file

@ -1,14 +0,0 @@
diff --git a/SStream.c b/SStream.c
index 90cef53..7ee9fd9 100644
--- a/SStream.c
+++ b/SStream.c
@@ -31,6 +31,9 @@ void SStream_Init(SStream *ss)
void SStream_concat0(SStream *ss, const char *s)
{
#ifndef CAPSTONE_DIET
+ if (!ss || !s) {
+ return;
+ }
unsigned int len = (unsigned int) strlen(s);
memcpy(ss->buffer + ss->index, s, len);

View file

@ -1,211 +1,35 @@
# handle capstone dependency
capstone_dep = dependency('capstone', version: '>=3.0.4', required: false, static: is_static_build)
if not capstone_dep.found() or not get_option('use_sys_capstone')
if get_option('capstone_in_builddir')
capstone_path = join_paths(meson.current_build_dir(), 'capstone')
else
capstone_path = 'capstone'
endif
capstone_version = get_option('use_capstone_version')
use_capstone5 = get_option('use_capstone5')
if use_capstone5
warning('use_capstone5 is deprecated. Use -Duse_capstone_version=v5 instead.')
capstone_version = 'v5'
endif
res = run_command(py3_exe, '-c', '__import__("sys").exit(__import__("os").path.exists("@0@"))'.format(capstone_path))
if res.returncode() == 0
if not git_exe.found()
error('Cannot load capstone library. Either provide capstone in ./shlr/capstone or install git, so it can be downloaded')
if capstone_version == 'bundled'
r = run_command(py3_exe, check_meson_subproject_py, 'capstone-bundled')
if r.returncode() == 1 and get_option('subprojects_check')
error('Subproject capstone-bundled is not updated. Please make sure to run `meson subprojects update` or set option `subprojects_check=false` if you want to compile against currently downloaded subproject.')
endif
# NOTE: when you update CS_TIP or CS_BRA, also update them in shlr/Makefile
if capstone_version == 'v5'
CS_TIP = 'd956ceddabcbe544ee8f074ba75c86c6381b34e6'
CS_BRA = 'next'
elif capstone_version == 'v3'
CS_TIP = '61bf71c771680033651f16cff832446e421847b1'
CS_BRA = 'v3'
elif capstone_version == 'v4'
CS_TIP = '2edae851d9fee511a57d4da32d5acecedd95d7ed'
CS_BRA = 'v4'
else
error('Wrong capstone version selected. Please use one of the supported versions.')
capstone_proj = subproject('capstone-bundled', default_options: ['default_library=static'])
elif capstone_version == 'next'
r = run_command(py3_exe, check_meson_subproject_py, 'capstone-next')
if r.returncode() == 1 and get_option('subprojects_check')
error('Subproject capstone-next is not updated. Please make sure to run `meson subprojects update` or set option `subprojects_check=false` if you want to compile against currently downloaded subproject.')
endif
capstone_git_user = 'aquynh'
message('Cloning capstone ' + CS_BRA + ' branch, commit ' + CS_TIP + ', into ' + capstone_path)
git_cmd = 'clone -b @0@ https://github.com/@1@/capstone.git @2@'.format(CS_BRA, capstone_git_user, capstone_path)
clone_cmd = run_command(git_exe, git_cmd.split())
if clone_cmd.returncode() != 0
error('Cannot execute git clone command')
endif
reset_cmd = run_command(py3_exe, git_exe_repo_py, git_exe, capstone_path, 'reset', '--hard', CS_TIP)
if reset_cmd.returncode() != 0
error('Cannot execute git reset command')
endif
patches_files = [
'capstone-calloc.patch',
'fix-x86-16.patch',
'sparc-crash.patch',
'sstream-null.patch'
]
message('Patching capstone with rizin\'s patches')
foreach file : patches_files
patch_path = join_paths(meson.current_source_dir(), 'capstone-patches', file)
patch_cmd = run_command(py3_exe, git_exe_repo_py, git_exe, capstone_path, 'apply', '-p1', patch_path)
if patch_cmd.returncode() != 0
warning('Cannot apply patch ' + file)
endif
endforeach
capstone_proj = subproject('capstone-next', default_options: ['default_library=static'])
elif capstone_version == 'v3'
capstone_proj = subproject('capstone-v3', default_options: ['default_library=static'])
elif capstone_version == 'v4'
capstone_proj = subproject('capstone-v4', default_options: ['default_library=static'])
else
error('Wrong capstone version selected. Please use one of the supported versions.')
endif
rel_cs_files = [
'arch/AArch64/AArch64BaseInfo.c',
'arch/AArch64/AArch64Disassembler.c',
'arch/AArch64/AArch64InstPrinter.c',
'arch/AArch64/AArch64Mapping.c',
'arch/AArch64/AArch64Module.c',
'arch/ARM/ARMDisassembler.c',
'arch/ARM/ARMInstPrinter.c',
'arch/ARM/ARMMapping.c',
'arch/ARM/ARMModule.c',
'arch/Mips/MipsDisassembler.c',
'arch/Mips/MipsInstPrinter.c',
'arch/Mips/MipsMapping.c',
'arch/Mips/MipsModule.c',
'arch/PowerPC/PPCDisassembler.c',
'arch/PowerPC/PPCInstPrinter.c',
'arch/PowerPC/PPCMapping.c',
'arch/PowerPC/PPCModule.c',
'arch/Sparc/SparcDisassembler.c',
'arch/Sparc/SparcInstPrinter.c',
'arch/Sparc/SparcMapping.c',
'arch/Sparc/SparcModule.c',
'arch/SystemZ/SystemZDisassembler.c',
'arch/SystemZ/SystemZInstPrinter.c',
'arch/SystemZ/SystemZMapping.c',
'arch/SystemZ/SystemZMCTargetDesc.c',
'arch/SystemZ/SystemZModule.c',
'arch/X86/X86ATTInstPrinter.c',
'arch/X86/X86Disassembler.c',
'arch/X86/X86DisassemblerDecoder.c',
'arch/X86/X86IntelInstPrinter.c',
'arch/X86/X86Mapping.c',
'arch/X86/X86Module.c',
'arch/XCore/XCoreDisassembler.c',
'arch/XCore/XCoreInstPrinter.c',
'arch/XCore/XCoreMapping.c',
'arch/XCore/XCoreModule.c',
'cs.c',
'MCInst.c',
'MCInstrDesc.c',
'MCRegisterInfo.c',
'SStream.c',
'utils.c',
]
rel_cs4_files = [
'arch/M680X/M680XDisassembler.c',
'arch/M680X/M680XInstPrinter.c',
'arch/M680X/M680XModule.c',
'arch/M68K/M68KDisassembler.c',
'arch/M68K/M68KInstPrinter.c',
'arch/M68K/M68KModule.c',
'arch/TMS320C64x/TMS320C64xDisassembler.c',
'arch/TMS320C64x/TMS320C64xInstPrinter.c',
'arch/TMS320C64x/TMS320C64xMapping.c',
'arch/TMS320C64x/TMS320C64xModule.c',
]
rel_cs5_files = [
'arch/X86/X86InstPrinterCommon.c',
]
cs_files = []
foreach rel_cs_file : rel_cs_files
cs_files += [join_paths(capstone_path, rel_cs_file)]
endforeach
if capstone_version == 'v4' or capstone_version == 'v5'
foreach rel_cs_file : rel_cs4_files
cs_files += [join_paths(capstone_path, rel_cs_file)]
endforeach
endif
if capstone_version == 'v5'
foreach rel_cs_file : rel_cs5_files
cs_files += [join_paths(capstone_path, rel_cs_file)]
endforeach
endif
capstone_includes = [platform_inc, include_directories('capstone/include')]
if capstone_version == 'v4' or capstone_version == 'v5'
capstone_includes += [include_directories('capstone/include/capstone')]
endif
librzcapstone = static_library('rzcapstone', cs_files,
c_args: [
'-DCAPSTONE_X86_ATT_DISABLE_NO',
'-DCAPSTONE_X86_REDUCE_NO',
'-DCAPSTONE_USE_SYS_DYN_MEM',
'-DCAPSTONE_DIET_NO',
'-DCAPSTONE_HAS_ARM',
'-DCAPSTONE_HAS_ARM64',
'-DCAPSTONE_HAS_M68K',
'-DCAPSTONE_HAS_M680X',
'-DCAPSTONE_HAS_MIPS',
'-DCAPSTONE_HAS_POWERPC',
'-DCAPSTONE_HAS_SPARC',
'-DCAPSTONE_HAS_SYSZ',
'-DCAPSTONE_HAS_X86',
'-DCAPSTONE_HAS_XCORE',
'-DCAPSTONE_HAS_TMS320C64X',
],
include_directories: capstone_includes,
implicit_include_directories: false
)
capstone_dep = declare_dependency(
link_with: librzcapstone,
include_directories: capstone_includes
)
capstone_dep = capstone_proj.get_variable('capstone_dep')
endif
# handle tree-sitter
tree_sitter_cflags = ''
if cc.has_argument('-std=gnu99')
tree_sitter_cflags = '-std=gnu99'
elif cc.has_argument('-std=c99')
tree_sitter_cflags = '-std=c99'
endif
tree_sitter_dep = dependency('tree-sitter', required: false, static: is_static_build)
if not tree_sitter_dep.found() or not get_option('use_sys_tree_sitter')
message('Use bundled tree-sitter')
tree_sitter_path = 'tree-sitter'
tree_sitter_vc_path = 'tree-sitter.vc'
tree_sitter_files = [
join_paths(tree_sitter_path, 'lib/src/lib.c'),
]
tree_sitter_inc = [platform_inc, include_directories('tree-sitter/lib/src'), include_directories('tree-sitter/lib/include')]
libtree_sitter = static_library('tree_sitter', tree_sitter_files,
include_directories: tree_sitter_inc,
implicit_include_directories: false,
c_args: tree_sitter_cflags,
)
tree_sitter_dep = declare_dependency(
compile_args: tree_sitter_cflags,
link_with: libtree_sitter,
include_directories: tree_sitter_inc
)
tree_sitter_proj = subproject('tree-sitter', default_options: ['default_library=static'])
tree_sitter_dep = tree_sitter_proj.get_variable('tree_sitter_dep')
endif
@ -319,7 +143,6 @@ tcc_dep = declare_dependency(
# handle lz4 dependency
lz4_dep = dependency('liblz4', required: false, static: is_static_build)
if not lz4_dep.found() or not get_option('use_sys_lz4')
message('Use bundled lz4')
lz4_files = [
'lz4/lz4.c',
]
@ -335,16 +158,12 @@ if not lz4_dep.found() or not get_option('use_sys_lz4')
link_with: librzlz4,
include_directories: lz4_inc
)
else
message('Use system-provided lz4 library')
endif
# handle zip dependency
zip_dep = dependency('libzip', required: false, static: is_static_build)
if not zip_dep.found() or not get_option('use_sys_zip')
message('Use bundled zip')
zip_files = [
'zip/zip/zip_add.c',
'zip/zip/zip_add_dir.c',
@ -442,8 +261,6 @@ if not zip_dep.found() or not get_option('use_sys_zip')
link_with: librzzip,
include_directories: zip_inc
)
else
message('Use system-provided zip library')
endif
# handle winkd dependency

@ -1 +0,0 @@
Subproject commit da41756a25714ffe352c6520d2b9af781fb5a601

@ -1 +0,0 @@
Subproject commit 1dc127e5dae7550a58a09886a19fdea19196bcf1

View file

@ -0,0 +1,5 @@
[wrap-git]
url = https://github.com/rizinorg/capstone.git
revision = 48ed89e6d9cf517972d0110aa31d6b95bed36de6
patch_directory = capstone-bundled
directory = capstone-bundled

View file

@ -0,0 +1,5 @@
[wrap-git]
url = https://github.com/aquynh/capstone.git
revision = d956ceddabcbe544ee8f074ba75c86c6381b34e6
directory = capstone-next
patch_directory = capstone-next

View file

@ -0,0 +1,6 @@
[wrap-file]
source_url = https://github.com/aquynh/capstone/archive/3.0.5.tar.gz
source_filename = 3.0.5.tar.gz
source_hash = 913dd695e7c5a2b972a6f427cb31f2e93677ec1c38f39dda37d18a91c70b6df1
patch_directory = capstone-3.0.5
directory = capstone-3.0.5

View file

@ -0,0 +1,6 @@
[wrap-file]
source_url = https://github.com/aquynh/capstone/archive/4.0.2.tar.gz
source_filename = 4.0.2.tar.gz
source_hash = 7c81d798022f81e7507f1a60d6817f63aa76e489aa4e7055255f21a22f5e526a
patch_directory = capstone-4.0.2
directory = capstone-4.0.2

View file

@ -0,0 +1,75 @@
project('capstone', 'c', meson_version: '>=0.55.0')
cs_files = [
'arch/AArch64/AArch64BaseInfo.c',
'arch/AArch64/AArch64Disassembler.c',
'arch/AArch64/AArch64InstPrinter.c',
'arch/AArch64/AArch64Mapping.c',
'arch/AArch64/AArch64Module.c',
'arch/ARM/ARMDisassembler.c',
'arch/ARM/ARMInstPrinter.c',
'arch/ARM/ARMMapping.c',
'arch/ARM/ARMModule.c',
'arch/Mips/MipsDisassembler.c',
'arch/Mips/MipsInstPrinter.c',
'arch/Mips/MipsMapping.c',
'arch/Mips/MipsModule.c',
'arch/PowerPC/PPCDisassembler.c',
'arch/PowerPC/PPCInstPrinter.c',
'arch/PowerPC/PPCMapping.c',
'arch/PowerPC/PPCModule.c',
'arch/Sparc/SparcDisassembler.c',
'arch/Sparc/SparcInstPrinter.c',
'arch/Sparc/SparcMapping.c',
'arch/Sparc/SparcModule.c',
'arch/SystemZ/SystemZDisassembler.c',
'arch/SystemZ/SystemZInstPrinter.c',
'arch/SystemZ/SystemZMapping.c',
'arch/SystemZ/SystemZMCTargetDesc.c',
'arch/SystemZ/SystemZModule.c',
'arch/X86/X86ATTInstPrinter.c',
'arch/X86/X86Disassembler.c',
'arch/X86/X86DisassemblerDecoder.c',
'arch/X86/X86IntelInstPrinter.c',
'arch/X86/X86Mapping.c',
'arch/X86/X86Module.c',
'arch/XCore/XCoreDisassembler.c',
'arch/XCore/XCoreInstPrinter.c',
'arch/XCore/XCoreMapping.c',
'arch/XCore/XCoreModule.c',
'cs.c',
'MCInst.c',
'MCInstrDesc.c',
'MCRegisterInfo.c',
'SStream.c',
'utils.c',
]
capstone_includes = [include_directories('include')]
libcapstone = library('capstone', cs_files,
c_args: [
'-DCAPSTONE_X86_ATT_DISABLE_NO',
'-DCAPSTONE_X86_REDUCE_NO',
'-DCAPSTONE_USE_SYS_DYN_MEM',
'-DCAPSTONE_DIET_NO',
'-DCAPSTONE_HAS_ARM',
'-DCAPSTONE_HAS_ARM64',
'-DCAPSTONE_HAS_M68K',
'-DCAPSTONE_HAS_M680X',
'-DCAPSTONE_HAS_MIPS',
'-DCAPSTONE_HAS_POWERPC',
'-DCAPSTONE_HAS_SPARC',
'-DCAPSTONE_HAS_SYSZ',
'-DCAPSTONE_HAS_X86',
'-DCAPSTONE_HAS_XCORE',
'-DCAPSTONE_HAS_TMS320C64X',
],
include_directories: capstone_includes,
implicit_include_directories: false
)
capstone_dep = declare_dependency(
link_with: libcapstone,
include_directories: capstone_includes
)

View file

@ -0,0 +1,85 @@
project('capstone', 'c', meson_version: '>=0.55.0')
cs_files = [
'arch/AArch64/AArch64BaseInfo.c',
'arch/AArch64/AArch64Disassembler.c',
'arch/AArch64/AArch64InstPrinter.c',
'arch/AArch64/AArch64Mapping.c',
'arch/AArch64/AArch64Module.c',
'arch/ARM/ARMDisassembler.c',
'arch/ARM/ARMInstPrinter.c',
'arch/ARM/ARMMapping.c',
'arch/ARM/ARMModule.c',
'arch/M680X/M680XDisassembler.c',
'arch/M680X/M680XInstPrinter.c',
'arch/M680X/M680XModule.c',
'arch/M68K/M68KDisassembler.c',
'arch/M68K/M68KInstPrinter.c',
'arch/M68K/M68KModule.c',
'arch/Mips/MipsDisassembler.c',
'arch/Mips/MipsInstPrinter.c',
'arch/Mips/MipsMapping.c',
'arch/Mips/MipsModule.c',
'arch/PowerPC/PPCDisassembler.c',
'arch/PowerPC/PPCInstPrinter.c',
'arch/PowerPC/PPCMapping.c',
'arch/PowerPC/PPCModule.c',
'arch/Sparc/SparcDisassembler.c',
'arch/Sparc/SparcInstPrinter.c',
'arch/Sparc/SparcMapping.c',
'arch/Sparc/SparcModule.c',
'arch/SystemZ/SystemZDisassembler.c',
'arch/SystemZ/SystemZInstPrinter.c',
'arch/SystemZ/SystemZMapping.c',
'arch/SystemZ/SystemZMCTargetDesc.c',
'arch/SystemZ/SystemZModule.c',
'arch/TMS320C64x/TMS320C64xDisassembler.c',
'arch/TMS320C64x/TMS320C64xInstPrinter.c',
'arch/TMS320C64x/TMS320C64xMapping.c',
'arch/TMS320C64x/TMS320C64xModule.c',
'arch/X86/X86ATTInstPrinter.c',
'arch/X86/X86Disassembler.c',
'arch/X86/X86DisassemblerDecoder.c',
'arch/X86/X86IntelInstPrinter.c',
'arch/X86/X86Mapping.c',
'arch/X86/X86Module.c',
'arch/XCore/XCoreDisassembler.c',
'arch/XCore/XCoreInstPrinter.c',
'arch/XCore/XCoreMapping.c',
'arch/XCore/XCoreModule.c',
'cs.c',
'MCInst.c',
'MCInstrDesc.c',
'MCRegisterInfo.c',
'SStream.c',
'utils.c',
]
capstone_includes = [include_directories('include'), include_directories('include/capstone')]
libcapstone = library('capstone', cs_files,
c_args: [
'-DCAPSTONE_X86_ATT_DISABLE_NO',
'-DCAPSTONE_X86_REDUCE_NO',
'-DCAPSTONE_USE_SYS_DYN_MEM',
'-DCAPSTONE_DIET_NO',
'-DCAPSTONE_HAS_ARM',
'-DCAPSTONE_HAS_ARM64',
'-DCAPSTONE_HAS_M68K',
'-DCAPSTONE_HAS_M680X',
'-DCAPSTONE_HAS_MIPS',
'-DCAPSTONE_HAS_POWERPC',
'-DCAPSTONE_HAS_SPARC',
'-DCAPSTONE_HAS_SYSZ',
'-DCAPSTONE_HAS_X86',
'-DCAPSTONE_HAS_XCORE',
'-DCAPSTONE_HAS_TMS320C64X',
],
include_directories: capstone_includes,
implicit_include_directories: false
)
capstone_dep = declare_dependency(
link_with: libcapstone,
include_directories: capstone_includes
)

View file

@ -0,0 +1,85 @@
project('capstone', 'c', meson_version: '>=0.55.0')
cs_files = [
'arch/AArch64/AArch64BaseInfo.c',
'arch/AArch64/AArch64Disassembler.c',
'arch/AArch64/AArch64InstPrinter.c',
'arch/AArch64/AArch64Mapping.c',
'arch/AArch64/AArch64Module.c',
'arch/ARM/ARMDisassembler.c',
'arch/ARM/ARMInstPrinter.c',
'arch/ARM/ARMMapping.c',
'arch/ARM/ARMModule.c',
'arch/M680X/M680XDisassembler.c',
'arch/M680X/M680XInstPrinter.c',
'arch/M680X/M680XModule.c',
'arch/M68K/M68KDisassembler.c',
'arch/M68K/M68KInstPrinter.c',
'arch/M68K/M68KModule.c',
'arch/Mips/MipsDisassembler.c',
'arch/Mips/MipsInstPrinter.c',
'arch/Mips/MipsMapping.c',
'arch/Mips/MipsModule.c',
'arch/PowerPC/PPCDisassembler.c',
'arch/PowerPC/PPCInstPrinter.c',
'arch/PowerPC/PPCMapping.c',
'arch/PowerPC/PPCModule.c',
'arch/Sparc/SparcDisassembler.c',
'arch/Sparc/SparcInstPrinter.c',
'arch/Sparc/SparcMapping.c',
'arch/Sparc/SparcModule.c',
'arch/SystemZ/SystemZDisassembler.c',
'arch/SystemZ/SystemZInstPrinter.c',
'arch/SystemZ/SystemZMapping.c',
'arch/SystemZ/SystemZMCTargetDesc.c',
'arch/SystemZ/SystemZModule.c',
'arch/TMS320C64x/TMS320C64xDisassembler.c',
'arch/TMS320C64x/TMS320C64xInstPrinter.c',
'arch/TMS320C64x/TMS320C64xMapping.c',
'arch/TMS320C64x/TMS320C64xModule.c',
'arch/X86/X86ATTInstPrinter.c',
'arch/X86/X86Disassembler.c',
'arch/X86/X86DisassemblerDecoder.c',
'arch/X86/X86IntelInstPrinter.c',
'arch/X86/X86Mapping.c',
'arch/X86/X86Module.c',
'arch/XCore/XCoreDisassembler.c',
'arch/XCore/XCoreInstPrinter.c',
'arch/XCore/XCoreMapping.c',
'arch/XCore/XCoreModule.c',
'cs.c',
'MCInst.c',
'MCInstrDesc.c',
'MCRegisterInfo.c',
'SStream.c',
'utils.c',
]
capstone_includes = [include_directories('include'), include_directories('include/capstone')]
libcapstone = library('capstone', cs_files,
c_args: [
'-DCAPSTONE_X86_ATT_DISABLE_NO',
'-DCAPSTONE_X86_REDUCE_NO',
'-DCAPSTONE_USE_SYS_DYN_MEM',
'-DCAPSTONE_DIET_NO',
'-DCAPSTONE_HAS_ARM',
'-DCAPSTONE_HAS_ARM64',
'-DCAPSTONE_HAS_M68K',
'-DCAPSTONE_HAS_M680X',
'-DCAPSTONE_HAS_MIPS',
'-DCAPSTONE_HAS_POWERPC',
'-DCAPSTONE_HAS_SPARC',
'-DCAPSTONE_HAS_SYSZ',
'-DCAPSTONE_HAS_X86',
'-DCAPSTONE_HAS_XCORE',
'-DCAPSTONE_HAS_TMS320C64X',
],
include_directories: capstone_includes,
implicit_include_directories: false
)
capstone_dep = declare_dependency(
link_with: libcapstone,
include_directories: capstone_includes
)

View file

@ -0,0 +1,86 @@
project('capstone', 'c', meson_version: '>=0.55.0')
cs_files = [
'arch/AArch64/AArch64BaseInfo.c',
'arch/AArch64/AArch64Disassembler.c',
'arch/AArch64/AArch64InstPrinter.c',
'arch/AArch64/AArch64Mapping.c',
'arch/AArch64/AArch64Module.c',
'arch/ARM/ARMDisassembler.c',
'arch/ARM/ARMInstPrinter.c',
'arch/ARM/ARMMapping.c',
'arch/ARM/ARMModule.c',
'arch/M680X/M680XDisassembler.c',
'arch/M680X/M680XInstPrinter.c',
'arch/M680X/M680XModule.c',
'arch/M68K/M68KDisassembler.c',
'arch/M68K/M68KInstPrinter.c',
'arch/M68K/M68KModule.c',
'arch/Mips/MipsDisassembler.c',
'arch/Mips/MipsInstPrinter.c',
'arch/Mips/MipsMapping.c',
'arch/Mips/MipsModule.c',
'arch/PowerPC/PPCDisassembler.c',
'arch/PowerPC/PPCInstPrinter.c',
'arch/PowerPC/PPCMapping.c',
'arch/PowerPC/PPCModule.c',
'arch/Sparc/SparcDisassembler.c',
'arch/Sparc/SparcInstPrinter.c',
'arch/Sparc/SparcMapping.c',
'arch/Sparc/SparcModule.c',
'arch/SystemZ/SystemZDisassembler.c',
'arch/SystemZ/SystemZInstPrinter.c',
'arch/SystemZ/SystemZMapping.c',
'arch/SystemZ/SystemZMCTargetDesc.c',
'arch/SystemZ/SystemZModule.c',
'arch/TMS320C64x/TMS320C64xDisassembler.c',
'arch/TMS320C64x/TMS320C64xInstPrinter.c',
'arch/TMS320C64x/TMS320C64xMapping.c',
'arch/TMS320C64x/TMS320C64xModule.c',
'arch/X86/X86ATTInstPrinter.c',
'arch/X86/X86Disassembler.c',
'arch/X86/X86DisassemblerDecoder.c',
'arch/X86/X86IntelInstPrinter.c',
'arch/X86/X86Mapping.c',
'arch/X86/X86Module.c',
'arch/X86/X86InstPrinterCommon.c',
'arch/XCore/XCoreDisassembler.c',
'arch/XCore/XCoreInstPrinter.c',
'arch/XCore/XCoreMapping.c',
'arch/XCore/XCoreModule.c',
'cs.c',
'MCInst.c',
'MCInstrDesc.c',
'MCRegisterInfo.c',
'SStream.c',
'utils.c',
]
capstone_includes = [include_directories('include'), include_directories('include/capstone')]
libcapstone = library('capstone', cs_files,
c_args: [
'-DCAPSTONE_X86_ATT_DISABLE_NO',
'-DCAPSTONE_X86_REDUCE_NO',
'-DCAPSTONE_USE_SYS_DYN_MEM',
'-DCAPSTONE_DIET_NO',
'-DCAPSTONE_HAS_ARM',
'-DCAPSTONE_HAS_ARM64',
'-DCAPSTONE_HAS_M68K',
'-DCAPSTONE_HAS_M680X',
'-DCAPSTONE_HAS_MIPS',
'-DCAPSTONE_HAS_POWERPC',
'-DCAPSTONE_HAS_SPARC',
'-DCAPSTONE_HAS_SYSZ',
'-DCAPSTONE_HAS_X86',
'-DCAPSTONE_HAS_XCORE',
'-DCAPSTONE_HAS_TMS320C64X',
],
include_directories: capstone_includes,
implicit_include_directories: false
)
capstone_dep = declare_dependency(
link_with: libcapstone,
include_directories: capstone_includes
)

View file

@ -0,0 +1,29 @@
project('tree-sitter', 'c')
cc = meson.get_compiler('c')
tree_sitter_cflags = ''
if cc.has_argument('-std=gnu99')
tree_sitter_cflags = '-std=gnu99'
elif cc.has_argument('-std=c99')
tree_sitter_cflags = '-std=c99'
endif
tree_sitter_path = 'tree-sitter'
tree_sitter_files = ['lib/src/lib.c']
tree_sitter_inc = [include_directories('lib/src'), include_directories('lib/include')]
libtree_sitter = static_library('tree_sitter', tree_sitter_files,
include_directories: tree_sitter_inc,
implicit_include_directories: false,
c_args: tree_sitter_cflags,
install: not meson.is_subproject()
)
tree_sitter_dep = declare_dependency(
compile_args: tree_sitter_cflags,
link_with: libtree_sitter,
include_directories: tree_sitter_inc
)

3
subprojects/sdb.wrap Normal file
View file

@ -0,0 +1,3 @@
[wrap-git]
url = https://github.com/rizinorg/sdb.git
revision = 080b835aad6840702152d8f5685091ea2691f10a

View file

@ -0,0 +1,6 @@
[wrap-file]
source_url = https://github.com/tree-sitter/tree-sitter/archive/0.18.0.tar.gz
source_filename = 0.18.0.tar.gz
source_hash = 574458dbc8b6761027d3090bc2fd474f17ea77d875d4713ed9260d0def125bce
patch_directory = tree-sitter-0.18.0
directory = tree-sitter-0.18.0

View file

@ -0,0 +1,42 @@
#!/usr/bin/env python
#
# This script is necessary to make sure people notice a subproject has been
# changed and need to be updated. Meson does not warn you now (0.56.0)
""" Portable python script to check if subproject is up-to-date and warn if not """
import sys
import os
subproject = sys.argv[1]
meson_root = os.environ['MESON_SOURCE_ROOT']
subproject_filename = os.path.join(meson_root, 'subprojects', subproject + '.wrap')
try:
f = open(subproject_filename, 'r')
is_wrap_git = False
revision = None
directory = subproject
for l in f:
if 'wrap-git' in l:
is_wrap_git = True
elif l.startswith('revision'):
revision = l.split('=')[1].strip()
elif l.startswith('directory'):
directory = l.split('=')[1].strip()
if not is_wrap_git or not revision:
sys.exit(0)
subproject_dir = os.path.join(meson_root, 'subprojects', directory)
subproject_git_dir = os.path.join(subproject_dir, '.git')
if os.path.isdir(subproject_dir) and os.path.isdir(subproject_git_dir):
head = open(os.path.join(subproject_git_dir, 'HEAD'), 'r').read().strip()
if head != revision:
sys.exit(1)
sys.exit(0)
except FileNotFoundError:
sys.exit(0)