Skip to content

Commit

Permalink
meson: Omit .vapi from publicly visible dependency
Browse files Browse the repository at this point in the history
So that consuming projects don't need a Vala compiler to use us as a
subproject.
  • Loading branch information
oleavr committed Mar 14, 2024
1 parent 489eed9 commit 5827e47
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/api/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

def main():
parser = argparse.ArgumentParser(description="Generate refined Frida API definitions")
parser.add_argument('--output', dest='output_type', choices=['bundle', 'header', 'vapi'], default='bundle')
parser.add_argument('--output', dest='output_type', choices=['bundle', 'header', 'vapi', 'vapi-stamp'], default='bundle')
parser.add_argument('api_version', metavar='api-version', type=str)
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'))
Expand All @@ -19,13 +19,18 @@ def main():

args = parser.parse_args()

output_type = args.output_type
api_version = args.api_version
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 == 'vapi-stamp':
(output_dir / f"frida-core-{api_version}.vapi.stamp").write_bytes(b"")
return

toplevel_names = [
"frida.vala",
"control-service.vala",
Expand All @@ -42,7 +47,6 @@ def main():

enable_header = False
enable_vapi = False
output_type = args.output_type
if output_type == 'bundle':
enable_header = True
enable_vapi = True
Expand Down
12 changes: 11 additions & 1 deletion src/api/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ core_public_vapi = custom_target('frida-core-vapi',
install_dir: get_option('datadir') / 'vala' / 'vapi',
)

core_public_vapi_stamp = custom_target('frida-core-vapi-stamp',
input: core_public_vapi,
output: f'frida-core-@[email protected]',
command: [
generate_api,
'--output=vapi-stamp',
generate_api_args,
],
)

core_public_lib = custom_target('frida-core-library',
input: [core] + internal_libs,
output: f'libfrida-core-@[email protected]',
Expand All @@ -61,7 +71,7 @@ if host_os == 'android'
endif

core_public_dep = declare_dependency(
sources: [core_public_h, core_public_vapi] + core_public_extra_headers,
sources: [core_public_h, core_public_vapi_stamp, core_public_extra_headers],
include_directories: include_directories('.'),
link_args: backend_libs_private,
link_with: core_public_lib,
Expand Down

0 comments on commit 5827e47

Please sign in to comment.