fix: separate builddir from outdir

This commit is contained in:
Tropical
2026-03-14 22:34:44 -05:00
parent 242b74cae7
commit 7adc6c4788
2 changed files with 15 additions and 9 deletions

View File

@@ -102,6 +102,7 @@ unpacked_objects = custom_target(
'x', 'x',
'@INPUT@' '@INPUT@'
], ],
install: false,
) )
patched_relocations = custom_target( patched_relocations = custom_target(
@@ -109,17 +110,20 @@ patched_relocations = custom_target(
input: unpacked_objects, input: unpacked_objects,
output: patched_object_files, output: patched_object_files,
command: [ command: [
python, meson.project_source_root() / 'scripts/patch_relocations.py', python,
meson.current_build_dir(), meson.project_source_root() / 'scripts' / 'patch_relocations.py',
'@INPUT@', 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( shiggy_dep = declare_dependency(
link_with: static_library( link_with: static_library(
'shiggy', 'shiggy',
meson.project_source_root() / 'src' / 'shims.c', meson.project_source_root() / 'src' / 'shims.c',
include_directories : include_directories('include'), include_directories: include_directories('include'),
objects: patched_relocations, objects: patched_relocations,
) )
) )

View File

@@ -1,9 +1,10 @@
import sys, struct, shutil, os import sys, struct, shutil, os
def patch_relocs(build_dir, object_files): def patch_relocs(build_dir, out_dir, object_files):
patched = 0 patched = 0
for f in object_files: 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) shutil.copy(f, outfile)
with open(outfile, 'rb+') as file: with open(outfile, 'rb+') as file:
@@ -36,6 +37,7 @@ def patch_relocs(build_dir, object_files):
if __name__ == '__main__': if __name__ == '__main__':
build_dir = sys.argv[1] 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)