build: Add Meson build system

This commit is contained in:
Ole André Vadla Ravnås committed 2024-02-27 11:44:42 +01:00
1 parent a5c78bdd22
commit e91888dd1e
16 files changed
+208 -6

No files matched your search

+10 -4
View File
@@ -1,5 +1,11 @@
/build
/dist
/node_modules
/build/
/deps/
/dist/
/node_modules/
/npm-debug.log
/prebuilds
/prebuilds/
/subprojects/frida-core/
/subprojects/frida-gum.wrap
/subprojects/frida-gum/
/subprojects/nan-*/
/subprojects/packagecache/
+3
View File
@@ -0,0 +1,3 @@
[submodule "releng"]
path = releng
url = https://github.com/frida/releng.git
+6
View File
@@ -0,0 +1,6 @@
all: .DEFAULT
.DEFAULT:
@gmake ${.MAKEFLAGS} ${.TARGETS}
.PHONY: all
+16
View File
@@ -0,0 +1,16 @@
PYTHON ?= $(shell which python3 >/dev/null && echo python3 || echo python)
all $(MAKECMDGOALS):
@$(PYTHON) \
-c "import sys; sys.path.insert(0, sys.argv[1]); from releng.meson_make import main; main()" \
"$(shell pwd)" \
./build \
$(MAKECMDGOALS)
git-submodules:
@if [ ! -f releng/meson/meson.py ]; then \
git submodule update --init --recursive; \
fi
-include git-submodules
.PHONY: all $(MAKECMDGOALS)
Vendored Executable
+18
View File
@@ -0,0 +1,18 @@
#!/bin/sh
[ -z "$PYTHON" ] && PYTHON=$(which python3 >/dev/null && echo python3 || echo python)
cd $(dirname $0)
srcroot=$(pwd)
if [ ! -f releng/meson/meson.py ]; then
git submodule update --init --recursive || exit $?
fi
cd - >/dev/null
exec "$PYTHON" \
-c "import sys; sys.path.insert(0, sys.argv[1]); from releng.meson_configure import main; main()" \
"$srcroot" \
"$@"
+22
View File
@@ -0,0 +1,22 @@
@setlocal
@echo off
rem:: Based on: https://github.com/microsoft/terminal/issues/217#issuecomment-737594785
goto :_start_
:set_real_dp0
set dp0=%~dp0
set "dp0=%dp0:~0,-1%"
goto :eof
:_start_
call :set_real_dp0
if not exist "%dp0%\releng\meson\meson.py" (
pushd "%dp0%" & git submodule update --init --recursive & popd
if %errorlevel% neq 0 exit /b %errorlevel%
)
endlocal & goto #_undefined_# 2>nul || title %COMSPEC% & python ^
-c "import sys; sys.path.insert(0, sys.argv[1]); from releng.meson_configure import main; main()" ^
"%dp0%" ^
%*
+1
View File
@@ -4,6 +4,7 @@ export const binding = bindings({
bindings: "frida_binding",
try: [
["module_root", "build", "bindings"],
["module_root", "build", "src", "bindings"],
["module_root", "build", "Debug", "bindings"],
["module_root", "build", "Release", "bindings"],
["module_root", "out", "Debug", "bindings"],
+23
View File
@@ -0,0 +1,23 @@
@setlocal
@echo off
rem:: Based on: https://github.com/microsoft/terminal/issues/217#issuecomment-737594785
goto :_start_
:set_real_dp0
set dp0=%~dp0
set "dp0=%dp0:~0,-1%"
goto :eof
:_start_
call :set_real_dp0
if not exist "%dp0%\releng\meson\meson.py" (
pushd "%dp0%" & git submodule update --init --recursive & popd
if %errorlevel% neq 0 exit /b %errorlevel%
)
endlocal & goto #_undefined_# 2>nul || title %COMSPEC% & python ^
-c "import sys; sys.path.insert(0, sys.argv[1]); from releng.meson_make import main; main()" ^
"%dp0%" ^
.\build ^
%*
+16
View File
@@ -0,0 +1,16 @@
project('frida-node', 'cpp',
version: '1.0.0',
)
fs = import('fs')
node_incdir = fs.parent(fs.parent(find_program('node').full_path())) / 'include' / 'node'
if not fs.exists(node_incdir)
error('Node.js development headers not found')
endif
frida_core_dep = dependency('frida-core-1.0', default_options: [
'compiler_backend=disabled',
])
nan_dep = dependency('nan')
subdir('src')
+1 -2
View File
@@ -47,8 +47,7 @@
"prepare": "npm run build",
"build": "tsc",
"watch": "tsc -w",
"install": "prebuild-install || node-gyp rebuild",
"prebuild": "prebuild --strip",
"install": "node scripts/install.js",
"test": "node --expose-gc node_modules/mocha/bin/_mocha -r ts-node/register test/*.ts"
},
"binary": {
Submodule
+1
Submodule releng added at 02542d995f.
+23
View File
@@ -0,0 +1,23 @@
const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');
const pkgRoot = path.dirname(path.dirname(__filename));
const binding = path.join(pkgRoot, 'build', 'src', 'frida_binding.node');
if (fs.existsSync(binding)) {
process.exit(0);
}
try {
execSync('prebuild-install', { stdio: 'inherit' });
process.exit(0);
} catch (e) {
}
try {
execSync('node-gyp rebuild', { stdio: 'inherit' });
process.exit(0);
} catch (e) {
}
process.exit(1);
+37
View File
@@ -0,0 +1,37 @@
sources = [
'addon.cc',
'device_manager.cc',
'device.cc',
'application.cc',
'process.cc',
'spawn.cc',
'child.cc',
'crash.cc',
'bus.cc',
'session.cc',
'script.cc',
'relay.cc',
'portal_membership.cc',
'portal_service.cc',
'endpoint_parameters.cc',
'authentication.cc',
'iostream.cc',
'cancellable.cc',
'signals.cc',
'glib_object.cc',
'runtime.cc',
'uv_context.cc',
'glib_context.cc',
]
shared_module('frida_binding', sources,
name_prefix: '',
name_suffix: 'node',
override_options: [
'cpp_std=c++20',
'cpp_eh=none',
'cpp_rtti=false',
],
include_directories: include_directories(node_incdir),
dependencies: [frida_core_dep, nan_dep],
)
+7
View File
@@ -0,0 +1,7 @@
[wrap-git]
url = https://github.com/frida/frida-core.git
revision = main
depth = 1
[provide]
dependency_names = frida-core-1.0
+11
View File
@@ -0,0 +1,11 @@
[wrap-file]
directory = nan-2.18.0
source_url = https://github.com/nodejs/nan/archive/refs/tags/v2.18.0.tar.gz
source_filename = nan-v2.18.0.tar.gz
source_hash = 376361b98b931840804f8a145b28fa32c8da2634a3f93c2cbc7fdb14c6274b71
diff_files = nan.patch
[provide]
dependency_names = nan
+13
View File
@@ -0,0 +1,13 @@
diff -Nur nan-2.18.0-orig/meson.build nan-2.18.0/meson.build
--- nan-2.18.0-orig/meson.build 1970-01-01 01:00:00.000000000 +0100
+++ nan-2.18.0/meson.build 2024-02-27 10:43:03.643648729 +0100
@@ -0,0 +1,9 @@
+project('nan', 'cpp',
+ version: '2.18.0',
+)
+
+nan_dep = declare_dependency(
+ include_directories: include_directories('.'),
+)
+
+meson.override_dependency('nan', nan_dep)