Skip to content

Commit

Permalink
meson: Compute version from VCS tags if unspecified
Browse files Browse the repository at this point in the history
  • Loading branch information
oleavr committed Apr 22, 2024
1 parent 88a06bc commit d55c59c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
9 changes: 8 additions & 1 deletion compat/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def main(argv):
command.add_argument("role", help="project vs subproject", choices=["project", "subproject"])
command.add_argument("builddir", help="build directory", type=Path)
command.add_argument("top_builddir", help="top build directory", type=Path)
command.add_argument("frida_version", help="the Frida version")
command.add_argument("host_os", help="operating system binaries are being built for")
command.add_argument("host_arch", help="architecture binaries are being built for")
command.add_argument("host_toolchain", help="the kind of toolchain being used",
Expand All @@ -43,6 +44,7 @@ def main(argv):
command.set_defaults(func=lambda args: setup(args.role,
args.builddir,
args.top_builddir,
args.frida_version,
args.host_os,
args.host_arch,
args.host_toolchain,
Expand Down Expand Up @@ -86,6 +88,7 @@ def parse_array_option_value(v: str) -> set[str]:
def setup(role: Role,
builddir: Path,
top_builddir: Path,
frida_version: str,
host_os: str,
host_arch: str,
host_toolchain: str,
Expand Down Expand Up @@ -224,7 +227,7 @@ def setup(role: Role,
target=AGENT_TARGET),
]

state = State(role, builddir, top_builddir, host_os, host_arch, host_toolchain, outputs)
state = State(role, builddir, top_builddir, frida_version, host_os, host_arch, host_toolchain, outputs)
serialized_state = base64.b64encode(pickle.dumps(state)).decode('ascii')

variable_names, output_names = zip(*[(output.identifier, output.name) \
Expand All @@ -237,6 +240,7 @@ class State:
role: Role
builddir: Path
top_builddir: Path
frida_version: str
host_os: str
host_arch: str
host_toolchain: str
Expand Down Expand Up @@ -290,6 +294,9 @@ def call_internal_meson(argv, *args, **kwargs):
if not (workdir / "build.ninja").exists():
if options is None:
options = load_meson_options(state.top_builddir, state.role, set(subprojects.keys()))
version_opt = next((opt for opt in options if opt.startswith("-Dfrida_version=")), None)
if version_opt is None:
options += [f"-Dfrida_version={state.frida_version}"]

if state.host_os == "windows":
if state.host_toolchain == "microsoft":
Expand Down
1 change: 1 addition & 0 deletions compat/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ if no_overridden_compat_bits
meson.is_subproject() ? 'subproject' : 'project',
meson.current_build_dir(),
meson.global_build_root(),
frida_version,
host_os,
host_abi,
host_toolchain,
Expand Down
11 changes: 6 additions & 5 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ Vala compiler from:
https://github.com/frida/vala''')
endif

releng = meson.global_source_root() / 'releng'
if not import('fs').exists(releng)
releng = meson.project_source_root() / 'releng'
endif

frida_version = get_option('frida_version')
if frida_version == ''
frida_version = meson.project_version()
frida_version = run_command(releng / 'frida_version.py', meson.project_source_root(), check: true).stdout().strip()
endif
tokens = frida_version.split('.')
frida_major_version = tokens[0].to_int()
Expand Down Expand Up @@ -554,10 +559,6 @@ if get_option('devkits').length() != 0
if get_option('default_library') != 'static'
error('Devkits can only be generated from static libraries')
endif
releng = meson.global_source_root() / 'releng'
if not import('fs').exists(releng)
releng = meson.project_source_root() / 'releng'
endif
mkdevkit = find_program(releng / 'mkdevkit.py')
uninstalled_dir = meson.global_build_root() / 'meson-uninstalled'
devkit_options = [
Expand Down

0 comments on commit d55c59c

Please sign in to comment.