Skip to content

Commit

Permalink
meson: Install the generated .gir
Browse files Browse the repository at this point in the history
  • Loading branch information
oleavr committed Mar 19, 2024
1 parent 1e6d665 commit d8e0ad5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/api/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@

def main():
parser = argparse.ArgumentParser(description="Generate refined Frida API definitions")
parser.add_argument('--output', dest='output_type', choices=['bundle', 'header', 'vapi', 'vapi-stamp'], default='bundle')
parser.add_argument('--output', dest='output_type', choices=['bundle', 'header', 'gir', 'vapi', 'vapi-stamp'], default='bundle')
parser.add_argument('api_version', metavar='api-version', type=str)
parser.add_argument('core_gir', metavar='/path/to/Frida-x.y.gir', type=argparse.FileType('r', encoding='utf-8'))
parser.add_argument('core_vapi', metavar='/path/to/frida-core.vapi', type=argparse.FileType('r', encoding='utf-8'))
parser.add_argument('core_header', metavar='/path/to/frida-core.h', type=argparse.FileType('r', encoding='utf-8'))
parser.add_argument('base_vapi', metavar='/path/to/frida-base.vapi', type=argparse.FileType('r', encoding='utf-8'))
Expand All @@ -21,12 +22,17 @@ def main():

output_type = args.output_type
api_version = args.api_version
core_gir = args.core_gir.read()
core_vapi = args.core_vapi.read()
core_header = args.core_header.read()
base_vapi = args.base_vapi.read()
base_header = args.base_header.read()
output_dir = Path(args.output_dir)

if output_type == 'gir':
(output_dir / f"Frida-{api_version}.gir").write_text(core_gir, encoding='utf-8')
return

if output_type == 'vapi-stamp':
(output_dir / f"frida-core-{api_version}.vapi.stamp").write_bytes(b"")
return
Expand Down
15 changes: 14 additions & 1 deletion src/api/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ generate_api = [python, files('generate.py')]

generate_api_args = [
api_version,
core_build_dir / core_gir_name,
core_build_dir / 'frida-core.vapi',
core_build_dir / 'frida-core.h',
base_build_dir / f'frida-base-@[email protected]',
Expand All @@ -21,6 +22,18 @@ core_public_h = custom_target('frida-core-header',
install_dir: header_install_dir,
)

core_public_gir = custom_target('frida-core-gir',
input: [core, base],
output: [core_gir_name],
command: [
generate_api,
'--output=gir',
generate_api_args,
],
install: true,
install_dir: girdir,
)

core_public_vapi = custom_target('frida-core-vapi',
input: [core, base],
output: [
Expand Down Expand Up @@ -71,7 +84,7 @@ if host_os == 'android'
endif

core_public_dep = declare_dependency(
sources: [core_public_h, core_public_vapi_stamp, core_public_extra_headers],
sources: [core_public_h, core_public_gir, core_public_vapi_stamp, core_public_extra_headers],
include_directories: include_directories('.'),
link_args: backend_libs_private,
link_with: core_public_lib,
Expand Down
4 changes: 3 additions & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,8 @@ core_vala_args = [
'--pkg=json-glib-1.0',
]

core_gir_name = f'Frida-@[email protected]'

core = library('frida-core', core_sources,
c_args: frida_component_cflags,
vala_args: [
Expand All @@ -533,7 +535,7 @@ core = library('frida-core', core_sources,
gumjs_inspector_vala_args,
'--pkg=gmodule-2.0',
],
vala_gir: 'Frida-' + api_version + '.gir',
vala_gir: core_gir_name,
link_args: backend_libs_private,
link_with: backend_libs,
dependencies: core_deps + internal_deps,
Expand Down

0 comments on commit d8e0ad5

Please sign in to comment.