Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates debug symbol handling #139

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/dragon/config/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
8 changes: 6 additions & 2 deletions src/dragon/config/rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
22 changes: 18 additions & 4 deletions src/dragongen/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -357,18 +363,24 @@ 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'),
])

# 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
Expand Down Expand Up @@ -428,6 +440,7 @@ def generate_ninja_outline(self) -> list:
Var('logos'),
Var('optool'),
Var('swift'),
Var('strip'),
___,
Var('targetvers'),
Var('targetos'),
Expand All @@ -443,6 +456,7 @@ def generate_ninja_outline(self) -> list:
Var('debug'),
Var('entfile'),
Var('entflag'),
Var('stripflags'),
Var('optim'),
Var('warnings'),
___,
Expand Down
2 changes: 2 additions & 0 deletions src/dragongen/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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

Expand Down
Loading