diff --git a/src/dragon/config/defaults.yml b/src/dragon/config/defaults.yml index eb341d30a..cdd1e5e62 100644 --- a/src/dragon/config/defaults.yml +++ b/src/dragon/config/defaults.yml @@ -25,6 +25,7 @@ Defaults: idflag: '' entflag: '-S' entfile: '' + stripflags: '-x' resource_dir: 'Resources' fw_dirs: - $dragon_root_dir/sdks/iPhoneOS.sdk/System/Library/PrivateFrameworks/ diff --git a/src/dragon/config/rules.yml b/src/dragon/config/rules.yml index da5efce07..526ffe32e 100644 --- a/src/dragon/config/rules.yml +++ b/src/dragon/config/rules.yml @@ -59,7 +59,7 @@ copy: cmd: "cp $in $out" lipo: name: "Lipo Utility" - desc: "Merging architechtures" + desc: "Merging architectures" cmd: "$lipo -create $in -output $out" bundle: name: "Bundle Resources" @@ -68,7 +68,7 @@ bundle: debug: name: "DsymUtil" desc: "Generating Debug Symbols for $name" - cmd: "cp $in $out" + cmd: "$dsym $in" sign: name: "$codesign" desc: "Signing $name" @@ -77,3 +77,7 @@ stage: name: "Staging Commands" desc: "Running Stage for $name" cmd: "$stage && $stage2" +strip: + name: "Strip" + desc: "Stripping $name" + cmd: "$strip $stripflags $in" \ No newline at end of file diff --git a/src/dragongen/generation.py b/src/dragongen/generation.py index 5748d5c73..31df90a7b 100644 --- a/src/dragongen/generation.py +++ b/src/dragongen/generation.py @@ -227,6 +227,8 @@ def generate_vars(self, module_variables: dict, target: str) -> dict: project_dict['ld'] = toolchain.ld if 'codesign' not in project_dict: project_dict['codesign'] = toolchain.codesign + if 'strip' not in project_dict: + project_dict['strip'] = toolchain.strip # TODO: lazy hack if 'cxxflags' in project_dict: @@ -282,7 +284,11 @@ def rules_and_build_statements(self) -> (list, list): build_state = [] rule_list = [] - used_rules = {'debug', 'sign', 'stage', 'lipo'} + used_rules = {'sign', 'stage', 'lipo'} + if _RELEASE_BUILD: + used_rules.add('strip') + else: + used_rules.add('debug') subdir: str = self.project_variables['dir'] + '/' filedict = classify({key: self.project_variables[key] for key in FILE_RULES}) linker_conds = set() @@ -357,10 +363,15 @@ def rules_and_build_statements(self) -> (list, list): Build('$internalsymtarget', 'lipo' if len(self.project_variables['archs']) > 1 else 'copy', [f'$builddir/$name.{a}' for a in self.project_variables['archs']]), + # expecting a .unsigned + Build('$internalsigntarget', 'copy', '$internalsymtarget'), # Debug symbols - Build('$internalsigntarget', 'debug', '$internalsymtarget'), + # debug & strip run on a file as-is -- Ninja will skip that sort of build rule + # as there's nothing to track. we use a 'phonytarget' to tie the debug/strip step + # to the sign step, which is always run, via an implicit, secondary dependency (| dep) + Build('phonytarget', 'strip' if _RELEASE_BUILD else 'debug', '$internalsigntarget'), # Codesign - Build('$build_target_file', 'dummy' if self.project_variables['type'] == 'static' else 'sign', '$internalsigntarget'), + Build('$build_target_file', 'dummy' if self.project_variables['type'] == 'static' else 'sign', '$internalsigntarget|phonytarget'), # Stage commands (these are actually ran at a different point in the 'runner') Build('stage', 'stage', 'build.ninja'), ]) @@ -368,7 +379,8 @@ def rules_and_build_statements(self) -> (list, list): # Fix used_rules, TODO: maybe this could be optimized elsewhere? if len(self.project_variables['archs']) <= 1: used_rules.remove("lipo") - used_rules.add("copy") + + used_rules.add("copy") if self.project_variables['type'] == 'static': # use a dummy rule to rename it to what the next rule expects @@ -428,6 +440,7 @@ def generate_ninja_outline(self) -> list: Var('logos'), Var('optool'), Var('swift'), + Var('strip'), ___, Var('targetvers'), Var('targetos'), @@ -443,6 +456,7 @@ def generate_ninja_outline(self) -> list: Var('debug'), Var('entfile'), Var('entflag'), + Var('stripflags'), Var('optim'), Var('warnings'), ___, diff --git a/src/dragongen/toolchain.py b/src/dragongen/toolchain.py index fbe1df63e..f62e52988 100644 --- a/src/dragongen/toolchain.py +++ b/src/dragongen/toolchain.py @@ -12,6 +12,7 @@ def __init__(self): self.plutil = "plutil" self.lipo = "lipo" self.tapi = "tapi" + self.strip = "strip" @classmethod def locate_macos_toolchain(cls, use_objcs: bool): @@ -67,6 +68,7 @@ def locate_linux_toolchain(cls, use_objcs: bool): tc.dsym = tc_dir + 'dsymutil' tc.lipo = tc_dir + 'lipo' tc.tapi = tc_dir + 'tapi' + tc.strip = tc_dir + 'strip' return tc