Skip to content

Commit

Permalink
Fix supported types
Browse files Browse the repository at this point in the history
  • Loading branch information
L1ghtmann committed Jan 13, 2024
1 parent 28cba47 commit b0c42ce
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 33 deletions.
58 changes: 30 additions & 28 deletions src/dragon/config/types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,23 @@ Types:
app:
variables:
install_location: '/Applications/'
target: '$dragon_data_dir/$stagedir/$location/$name.app/$name'
build_target_file: '$dragon_data_dir/$stagedir/$location/$name.app/$name'
stage2:
- 'cp -R Resources/* $dragon_data_dir/$stagedir/$location/$name.app/'
application:
variables:
install_location: '/Applications/'
target: '$dragon_data_dir/$stagedir/$location/$name.app/$name'
build_target_file: '$dragon_data_dir/$stagedir/$location/$name.app/$name'
stage2:
- 'cp -R Resources/* $dragon_data_dir/$stagedir/$location/$name.app/'
tweak-jailed:
variables:
install_location: '/Applications/'
target: '$dragon_data_dir/$stagedir/$location/$name.app/$name'
build_target_file: '$dragon_data_dir/$stagedir/$location/$name.app/$name'
embed-libs:
- CydiaSubstrate
stage2:
- 'cp -R Resources/* $dragon_data_dir/$stagedir/$location/$name.app/'
tweak:
variables:
install_location: '/Library/MobileSubstrate/DynamicLibraries/'
Expand All @@ -38,7 +44,7 @@ Types:
stage2:
- 'mkdir -p $dragon_data_dir/_/Library/PreferenceLoader/Preferences/'
- 'cp entry.plist $dragon_data_dir/_/Library/PreferenceLoader/Preferences/$name.plist 2> /dev/null'
- 'cp -R Resources/ $dragon_data_dir/$stagedir/$location'
- 'cp -R Resources/* $dragon_data_dir/$stagedir/$location'
bundle:
variables:
install_location: '/Library/$name/'
Expand All @@ -49,7 +55,12 @@ Types:
- UIKit
stage2:
- 'cp -R Resources/ $dragon_data_dir/$stagedir/$location/$name.bundle/'

resource-bundle:
variables:
install_location: '/Library/$name/$name.bundle/'
build_target_file: 'build.ninja'
stage2:
- 'true;'
framework:
variables:
install_location: '/Library/Frameworks/$name.framework'
Expand All @@ -60,32 +71,12 @@ Types:
frameworks:
- Foundation
stage2:
- 'cp -R Resources/ $dragon_data_dir/$stagedir/$location'
- 'cp -R Resources/* $dragon_data_dir/$stagedir/$location'
- 'cp -R $dragon_data_dir/$stagedir$location $dragon_root_dir/frameworks/$name.framework'
- 'if ! [ -z "$public_headers" ]; then
mkdir -p $dragon_data_dir/$stagedir/$location/Headers;
cp $public_headers $dragon_data_dir/$stagedir/$location/Headers;
fi'
resource-bundle:
variables:
install_location: '/Library/$name/$name.bundle/'
build_target_file: 'build.ninja'
stage2:
- 'true;'
stage:
variables:
build_target_file: 'build.ninja'
stage2:
- 'true;'
library:
variables:
install_location: '/usr/lib'
build_target_file: '$dragon_data_dir/$stagedir/$location/$name.dylib'
ldflags: '-install_name $location$name.dylib'
lopts: '-dynamiclib -ggdb'
ldflags: '-install_name @rpath/$name.dylib'
stage2:
- 'true;'
cli:
variables:
install_location: '/usr/bin'
Expand All @@ -101,15 +92,26 @@ Types:
tool:
variables:
install_location: '/usr/bin'
lopts: ''
build_target_file: '$dragon_data_dir/$stagedir/$location/$name'
stage2:
- 'true;'
library:
variables:
install_location: '/usr/lib'
build_target_file: '$dragon_data_dir/$stagedir/$location/$name.dylib'
ldflags: '-install_name @rpath$name.dylib'
lopts: '-dynamiclib -ggdb'
stage2:
- 'true;'
static:
variables:
install_location: '/usr/lib'
lopts: ''
build_target_file: '$dragon_data_dir/$stagedir/$location/$name.a'
stage2:
- 'true;'
stage:
variables:
build_target_file: 'build.ninja'
stage2:
- 'true;'
raw:
17 changes: 17 additions & 0 deletions src/dragon/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,16 @@ def get_from_selector(prompt, values, default):
// Don’t forget to also add them to {} in your Makefile!
"""

CLI_ents_plist = """<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>platform-application</key>
<true/>
<key>com.apple.private.security.container-required</key>
<false/>
</dict>
</plist>
"""

class Project:
def __init__(self, root_directory):
Expand Down Expand Up @@ -403,6 +413,13 @@ def _new_for_type(self, type, proj_root):
self.variables['files'] = [f'{self.name}.x']
with open(f'{self.name}.x', 'w') as out:
out.write('// Insert your code here!\n')
elif type == 'cli':
self.variables['entfile'] = 'ents.plist'
with open('ents.plist', 'w') as out:
out.write(CLI_ents_plist)
self.variables['files'] = [f'{self.name}.m']
with open(f'{self.name}.m', 'w') as out:
out.write('// Insert your code here!\n')
elif type == 'framework':
if not os.path.exists('Resources'):
os.mkdir('Resources')
Expand Down
2 changes: 1 addition & 1 deletion src/dragon/shscripts/building
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ build()
ninja -t compdb > compile_commands.json
fi

cp -R layout/* $DRAGON_DIR/_/ 2>/dev/null
cp -R $projroot/layout/* layout/* $DRAGON_DIR/_/ 2>/dev/null

# mv build.ninja $DRAGON_DIR/ninja # Was this renamed "ninja" for use elsewhere?
mv build.ninja $DRAGON_DIR/build.ninja
Expand Down
15 changes: 11 additions & 4 deletions src/dragongen/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,23 +338,30 @@ def rules_and_build_statements(self) -> (list, list):
arch_specific_object_files))

build_state.extend([
# lipo if needed, else use a dummy rule to rename it to what the next rule expects
# the dummy rule could be optimized out, but its probably more developmentally clear
# lipo if needed, else use a copy rule to rename it to what the next rule expects
# the copy rule could be optimized out, but its probably more developmentally clear
# to have it there anyways /shrug
Build('$internalsymtarget',
'lipo' if len(self.project_variables['archs']) > 1 else 'dummy',
'lipo' if len(self.project_variables['archs']) > 1 else 'copy',
[f'$builddir/$name.{a}' for a in self.project_variables['archs']]),
# Debug symbols
Build('$internalsigntarget', 'debug', '$internalsymtarget'),
# Codesign
Build('$build_target_file', 'sign', '$internalsigntarget'),
Build('$build_target_file', 'dummy' if self.project_variables['type'] == 'static' else 'sign', '$internalsigntarget'),
# 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")

if self.project_variables['type'] == 'static':
# use a dummy rule to rename it to what the next rule expects
# the dummy rule could be optimized out, but its probably more developmentally clear
# to have it there anyways /shrug
used_rules.remove("sign")
used_rules.add("dummy")

rule_list.extend(get_generic_rule(r) for r in used_rules)
Expand Down

0 comments on commit b0c42ce

Please sign in to comment.