diff --git a/meson.build b/meson.build index 4aacd30..96fd12e 100644 --- a/meson.build +++ b/meson.build @@ -102,6 +102,7 @@ unpacked_objects = custom_target( 'x', '@INPUT@' ], + install: false, ) patched_relocations = custom_target( @@ -109,17 +110,20 @@ patched_relocations = custom_target( input: unpacked_objects, output: patched_object_files, command: [ - python, meson.project_source_root() / 'scripts/patch_relocations.py', - meson.current_build_dir(), - '@INPUT@', + python, + meson.project_source_root() / 'scripts' / 'patch_relocations.py', + meson.global_build_root(), # Where ar extracted the .obj files + '@OUTDIR@', # Where patched .o files should go + '@INPUT@', # The extracted .obj files ], + install: false, ) shiggy_dep = declare_dependency( link_with: static_library( 'shiggy', meson.project_source_root() / 'src' / 'shims.c', - include_directories : include_directories('include'), + include_directories: include_directories('include'), objects: patched_relocations, ) -) \ No newline at end of file +) diff --git a/scripts/patch_relocations.py b/scripts/patch_relocations.py index 1854d82..d6279d2 100644 --- a/scripts/patch_relocations.py +++ b/scripts/patch_relocations.py @@ -1,9 +1,10 @@ import sys, struct, shutil, os -def patch_relocs(build_dir, object_files): +def patch_relocs(build_dir, out_dir, object_files): patched = 0 for f in object_files: - outfile = os.path.join(build_dir, os.path.basename(f).replace('.obj', '.o')) + f = os.path.join(build_dir, os.path.basename(f)) + outfile = os.path.join(out_dir, os.path.basename(f).replace('.obj', '.o')) shutil.copy(f, outfile) with open(outfile, 'rb+') as file: @@ -36,6 +37,7 @@ def patch_relocs(build_dir, object_files): if __name__ == '__main__': build_dir = sys.argv[1] - object_files = sys.argv[2:] + out_dir = sys.argv[2] + object_files = sys.argv[3:] - patch_relocs(build_dir, object_files) + patch_relocs(build_dir, out_dir, object_files)