diff --git a/libs/libiggy_orbis.a b/libs/libiggy_orbis.a new file mode 100644 index 0000000..d345d72 Binary files /dev/null and b/libs/libiggy_orbis.a differ diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..bb2737c --- /dev/null +++ b/meson.build @@ -0,0 +1,135 @@ +project('shiggy', 'c', + version: '1.0', +) + +pymod = import('python') +python = pymod.find_installation('python3', required: true) + +ar = find_program('ar') +cc = meson.get_compiler('c') + +iggy_object_files = [ + 'ORBIS_rrAtomics.obj', + 'ORBIS_rrCpu.obj', + 'ORBIS_rrThreads.obj', + 'ORBIS_rrTime.obj', + 'as3_component_helpers.obj', + 'as3vm.obj', + 'as3vm_abc_decode.obj', + 'as3vm_abc_dump.obj', + 'as3vm_class.obj', + 'as3vm_classes_base_dummy.obj', + 'as3vm_classes_flash_dummy.obj', + 'as3vm_convert.obj', + 'as3vm_create.obj', + 'as3vm_debugger_interface.obj', + 'as3vm_dump_value.obj', + 'as3vm_gc.obj', + 'as3vm_imp_array.obj', + 'as3vm_imp_math.obj', + 'as3vm_imp_misc.obj', + 'as3vm_imp_string.obj', + 'as3vm_interpreter.obj', + 'as3vm_names.obj', + 'as3vm_op_strings.obj', + 'as3vm_property.obj', + 'as3vm_util.obj', + 'as3vm_verifier.obj', + 'avm2_microcode.obj', + 'dtoa.obj', + 'gr_strokepath.obj', + 'iggy_allocation.obj', + 'iggy_api_functions.obj', + 'iggy_api_functions_global.obj', + 'iggy_arena_allocator.obj', + 'iggy_debug.obj', + 'iggy_file_reader.obj', + 'iggy_font_provider.obj', + 'iggy_main.obj', + 'iggy_mixer.obj', + 'iggy_platform_audio.obj', + 'iggy_platform_deps.obj', + 'iggy_sound.obj', + 'iggy_unicode.obj', + 'radss_orbis.obj', + 'rrCore.obj', + 'rrMath.obj', + 'rrMem.obj', + 'rrSyncCheck.obj', + 'rrstring.obj', + 'stb_truetype_wrapper.obj', + 'swf_as3_bitmap_data.obj', + 'swf_as3_misc.obj', + 'swf_as3_textfield.obj', + 'swf_as3vm.obj', + 'swf_as3vm_flash_display.obj', + 'swf_as3vm_flash_events.obj', + 'swf_cache.obj', + 'swf_decode.obj', + 'swf_draw.obj', + 'swf_draw_filltype.obj', + 'swf_draw_filter.obj', + 'swf_draw_interface.obj', + 'swf_draw_lib.obj', + 'swf_draw_renderstate.obj', + 'swf_draw_shape.obj', + 'swf_draw_text.obj', + 'swf_draw_texture.obj', + 'swf_draw_triangulate.obj', + 'swf_fontcache.obj', + 'swf_jpeg.obj', + 'swf_math.obj', + 'swf_play.obj', + 'swf_playhead.obj', + 'swf_polygonalize.obj', + 'swf_state.obj', + 'triangulate_ears.obj', + 'zlib.obj', +] + +object_file_paths = [] +foreach file : iggy_object_files + object_file_paths += meson.current_build_dir() / file +endforeach + +patched_object_files = [] +foreach file : iggy_object_files + patched_object_files += file.replace('.obj', '.o') +endforeach + + +unpack = custom_target( + 'unpack-archive', + input: meson.project_source_root() / 'libs' / 'libiggy_orbis.a', + output: iggy_object_files, + command: [ + ar, + 'x', + '@INPUT@' + ], +) + +patch_relocations = custom_target( + 'patch-relocations', + input: object_file_paths, + output: patched_object_files, + command: [ + python, meson.project_source_root() / 'scripts/patch_relocations.py', + ], +) + +libshiggy = static_library( + 'shiggy', + meson.project_source_root() / 'src' / 'shims.c', +) + +custom_target( + 'add-patched-objects', + input: [patch_relocations, libshiggy], + output: 'libshiggy.stamp', + command: [ + ar, + 'r', + ] + [libshiggy.full_path()] + patched_object_files + ['&&', 'touch', '@OUTPUT@'], + build_by_default: true, +) \ No newline at end of file diff --git a/scripts/patch_relocations.py b/scripts/patch_relocations.py new file mode 100644 index 0000000..f260f0a --- /dev/null +++ b/scripts/patch_relocations.py @@ -0,0 +1,38 @@ +import sys, struct, glob, shutil + +def patch_relocs(): + patched = 0 + for f in glob.glob("*.obj"): + outfile = f.replace('.obj', '.o') + shutil.copy(f, outfile) + + with open(outfile, 'rb+') as file: + file.seek(0) + if file.read(4) != b'\x7fELF': + continue + + file.seek(40) + hdr = struct.unpack('