Skip to content

Commit e4c80b4

Browse files
authored
Merge branch 'master' into types
2 parents 771aec6 + 28cba47 commit e4c80b4

File tree

21 files changed

+141
-114
lines changed

21 files changed

+141
-114
lines changed

bin/dragon

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,17 @@ if [[ -z $DRAGON_ROOT_DIR ]]; then
88
export DRAGON_ROOT_DIR=$HOME/$DRAGON_DIR
99
fi
1010

11+
TOOLPATH=$(python3 -c 'from dragon.util import tool_path; print(tool_path())')
12+
13+
# Load in basic functions
14+
source $TOOLPATH/util
15+
1116
# Run setup wizard if dragon root dir is empty or nonexistent
1217
if [[ -z "$(ls -A $DRAGON_ROOT_DIR 2> /dev/null)" ]]; then
1318
python3 -m dragon.wizard
1419
drexit 0
1520
fi
1621

17-
TOOLPATH=$(python3 -c 'from dragon.util import tool_path; print(tool_path())')
18-
19-
# Load in colors and basic functions
20-
source $TOOLPATH/util
21-
source $TOOLPATH/dragoncolors
22-
2322
# Check deps are good to go
2423
source $TOOLPATH/prerun_checks
2524

@@ -97,8 +96,6 @@ while ! [[ -z $1 ]]; do
9796
set -xv
9897
export DGEN_DEBUG=1
9998
;;
100-
only ) only=1
101-
;;
10299
c | clean ) clean=1
103100
;;
104101
vn ) NINJA_ARGS="-v"
@@ -117,7 +114,7 @@ while ! [[ -z $1 ]]; do
117114
# --------
118115
# Commands
119116
# --------
120-
u | update | upgrade ) source $TOOLPATH/upgrader
117+
up | update | upgrade ) source $TOOLPATH/upgrader
121118
drexit
122119
;;
123120
rs | respring ) python3 -m dragon.device run sbreload
@@ -137,8 +134,7 @@ while ! [[ -z $1 ]]; do
137134
r | release ) release=1
138135
;;
139136
ro | rootless ) rootless=1
140-
;;
141-
relink ) rm -r "$DRAGON_DATA_DIR/sign/"
137+
PkgPrefix="/var/jb"
142138
;;
143139
h | help | -h ) usage
144140
drexit

src/buildgen/makefile_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22

3-
import re, textwrap
3+
import textwrap
44
from .writer import Writer
55

66

src/dragon/config/defaults.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ InternalDefaults:
4848
internalreleaseflags: '-DNDEBUG'
4949
internalcflags: '$cinclude $debug $fwSearch $cflags $btarg -O$optim $sysroot $header_includes $arc $triple $theosshim $macros $prefix $warnings $modulesinternal $internaldbgflags $internalreleaseflags $dbgflags $releaseflags'
5050
internalswiftflags: '-color-diagnostics -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos -g -L/usr/lib/swift -swift-version 5 -module-name $name'
51-
internalfflags: '$internalcflags $typeldflags $frameworks $libs $libflags $lopts $libSearch $ldflags $libs'
52-
internalldflags: '$internalcflags $typeldflags $frameworks $libs $libflags $lopts $libSearch $ldflags $libs'
51+
internalfflags: '$internalcflags $typeldflags $frameworks $libs $libflags $lopts $libSearch $ldflags'
52+
internalldflags: '$internalcflags $typeldflags $frameworks $libs $libflags $lopts $libSearch $ldflags'
5353
internalsigntarget: '$signdir/$build_target_file.unsigned'
5454
internalsymtarget: '$signdir/$build_target_file.unsym'
5555
pwd: '.'
@@ -58,4 +58,4 @@ InternalDefaults:
5858
Rootless:
5959
rootless_prefix: '/var/jb'
6060
rpathflags: '-rpath $rootless_prefix/Library/Frameworks -rpath $rootless_prefix/usr/lib'
61-
internalldflags: '$internalcflags $typeldflags $frameworks $libs $libflags $lopts $libSearch $ldflags $libs $rpathflags'
61+
internalldflags: '$internalcflags $typeldflags $frameworks $libs $libflags $lopts $libSearch $ldflags $rpathflags'

src/dragon/config/rules.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ bundle:
6565
name: "Bundle Resources"
6666
desc: "Copying Bundle Resources"
6767
cmd: "mkdir -p $dragon_data_dir/_$location/ && cp -R $resource_dir/ $dragon_data_dir/_$location"
68-
plist:
69-
name: "plutil compilation"
70-
desc: "Compiling $in"
71-
cmd: "$plutil -convert binary1 $in -o $out"
7268
debug:
7369
name: "DsymUtil"
7470
desc: "Generating Debug Symbols for $name"

src/dragon/config/types.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Types:
2626
install_location: '/Library/MobileSubstrate/DynamicLibraries/'
2727
build_target_file: '$dragon_data_dir/$stagedir/$location$name.dylib'
2828
lopts: '-dynamiclib -ggdb -framework CydiaSubstrate'
29+
ldflags: '-install_name @rpath/$name.dylib'
2930
frameworks:
3031
- UIKit
3132
stage2:
@@ -37,6 +38,7 @@ Types:
3738
libs:
3839
- 'substrate'
3940
lopts: '-dynamiclib -ggdb -framework Preferences'
41+
ldflags: '-install_name $install_location/$name'
4042
frameworks:
4143
- UIKit
4244
stage2:
@@ -48,6 +50,7 @@ Types:
4850
install_location: '/Library/$name/'
4951
build_target_file: '$dragon_data_dir/$stagedir/$location/$name.bundle/$name'
5052
lopts: '-dynamiclib -ggdb'
53+
ldflags: '-install_name $install_location/$name.bundle/$name'
5154
frameworks:
5255
- UIKit
5356
stage2:
@@ -64,6 +67,7 @@ Types:
6467
build_target_file: '$dragon_data_dir/$stagedir/$location/$name'
6568
public_headers: '$dragon_root_dir/include/'
6669
lopts: '-dynamiclib -ggdb'
70+
ldflags: '-install_name @rpath/$name.framework/$name'
6771
frameworks:
6872
- Foundation
6973
stage2:
@@ -95,7 +99,7 @@ Types:
9599
variables:
96100
install_location: '/usr/lib'
97101
build_target_file: '$dragon_data_dir/$stagedir/$location/$name.dylib'
98-
ldflags: '-install_name $location$name.dylib'
102+
ldflags: '-install_name @rpath/$name.dylib'
99103
lopts: '-dynamiclib -ggdb'
100104
stage2:
101105
- 'true;'

src/dragon/device.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def run_cmd(self, cmd, quiet=False):
111111
if not self.test_connection():
112112
dberror("Device", f'Could not connect to device at {self.host}:{self.port}')
113113
if self.host == "localhost" and self.port == 4444:
114-
dberror("Device", f'To configure a new device, run "dragon s"')
114+
dberror("Device", 'To configure a new device, run "dragon s"')
115115
self.connection_failure_resolver()
116116
return
117117

src/dragon/editor.py

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
# if you're here to contribute to this file, im sorry. ::::)
99

10-
import os, sys, pwd
10+
import os, pwd
1111
import ruyaml as yaml
1212
from shared.util import dbstate
1313

@@ -437,30 +437,16 @@ def _new_for_type(self, type, proj_root):
437437
elif type == 'prefs':
438438
self.variables['prefix'] = get_input('Class name prefix (three or more characters unique to this project)',
439439
self.name)
440-
if not os.path.exists(proj_root + os.path.sep + 'layout'):
441-
os.mkdir(proj_root + os.path.sep + 'layout')
442-
if not os.path.exists(proj_root + os.path.sep + 'layout' + os.path.sep + 'Library'):
443-
os.mkdir(proj_root + os.path.sep + 'layout' + os.path.sep + 'Library')
444-
if not os.path.exists(
445-
proj_root + os.path.sep + 'layout' + os.path.sep + 'Library' + os.path.sep + 'PreferenceLoader'):
446-
os.mkdir(
447-
proj_root + os.path.sep + 'layout' + os.path.sep + 'Library' + os.path.sep + 'PreferenceLoader')
448-
if not os.path.exists(
449-
proj_root + os.path.sep + 'layout' + os.path.sep + 'Library' + os.path.sep + 'PreferenceLoader' + os.path.sep + 'Preferences'):
450-
os.mkdir(
451-
proj_root + os.path.sep + 'layout' + os.path.sep + 'Library' + os.path.sep + 'PreferenceLoader' + os.path.sep + 'Preferences')
452-
with open(
453-
proj_root + os.path.sep + 'layout' + os.path.sep + 'Library' + os.path.sep + 'PreferenceLoader' + os.path.sep + 'Preferences' + os.path.sep + self.name + '.plist',
454-
'w') as out:
440+
layoutPath = os.path.join(proj_root, 'layout', 'Library', 'PreferenceLoader', 'Preferences')
441+
if not os.path.exists(layoutPath):
442+
os.makedirs(layoutPath, exist_ok=True)
443+
with open(os.path.join(layoutPath, self.name + '.plist'), 'w') as out:
455444
out.write(Prefs_LPLP_NamePlist.format(self.name, self.variables['prefix'], self.name))
456445
if not os.path.exists('Resources'):
457446
os.mkdir('Resources')
458-
with open('Resources/icon.png', 'wb') as out:
459-
out.write(b'')
460-
with open('Resources/icon@2x.png', 'wb') as out:
461-
out.write(b'')
462-
with open('Resources/icon@3x.png', 'wb') as out:
463-
out.write(b'')
447+
for f in ['icon.png', 'icon@2x.png', 'icon@3x.png']:
448+
with open(os.path.join('Resources', f), 'wb') as out:
449+
out.write(b'')
464450
with open('Resources/Info.plist', 'w') as out:
465451
out.write(Prefs_R_InfoPlist.format(self.name, self.variables['id'], self.variables['prefix']))
466452
with open('Resources/Root.plist', 'w') as out:
@@ -490,7 +476,7 @@ def _new_for_type(self, type, proj_root):
490476
for file in _l:
491477
with open(f'Resources/{file}', 'wb') as out:
492478
out.write(b'')
493-
with open(f'Resources/Info.plist', 'w') as out:
479+
with open('Resources/Info.plist', 'w') as out:
494480
out.write(InfoPlist.format(self.variables['id']))
495481

496482
try:

src/dragon/lo.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
from ruyaml import YAML
22
import platform
33
from urllib import request
4-
import json, os, shutil, ssl, sys, tarfile
5-
import click
6-
import urllib.request
4+
import json, os, ssl, sys, tarfile
75
from tqdm import tqdm
86
from dragon.util import dprintline, OutputColors, OutputWeight
97

@@ -60,7 +58,7 @@ def fetch():
6058
metadata = yaml.load(fd)
6159
version = metadata['version']
6260
if version == response['tag_name']:
63-
log(f'Latest LLVM-ObjCS build already installed')
61+
log('Latest LLVM-ObjCS build already installed')
6462
return
6563
for asset in response['assets']:
6664
n = asset['name']

src/dragon/shscripts/building

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,35 @@ build()
7777
true
7878
else
7979
cp -R $DRAGON_DIR/_ "$DRAGON_DATA_DIR" 2>/dev/null
80+
81+
if [[ $release -eq 1 ]]; then
82+
if command -v plutil &> /dev/null; then
83+
cmd=plutil
84+
elif command -v ply &> /dev/null; then
85+
cmd=ply
86+
elif command -v plistutill &> /dev/null; then
87+
cmd=plistutil
88+
fi
89+
90+
if ! [[ -z $cmd ]]; then
91+
prefix_print "Converting plist/xml resources to binary"
92+
find "$DRAGON_DATA_DIR" \( -name \*.plist -o -name \*.strings \) | while read i; do
93+
head="$(od -c "$i" | head)"
94+
clean_head="${head//[^[:alpha:]]/}"
95+
magic_bytes="${clean_head:0:6}"
96+
97+
if ! [[ $magic_bytes == bplist ]]; then
98+
if [[ $cmd == plutil ]]; then
99+
plutil -convert binary1 "$i"
100+
elif [[ $cmd == ply ]]; then
101+
ply -c binary "$i"
102+
else
103+
plistutil -i "$i" -f bin -o "$i"
104+
fi
105+
fi
106+
done
107+
fi
108+
fi
80109
fi
81110

82111
cd "$projroot" || drexit

src/dragon/shscripts/packaging

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,21 @@ create_package()
6464
mv $DRAGON_DIR/_/.dragonbuilding $DRAGON_DIR/_/DEBIAN
6565
if [[ -f control ]]; then
6666
echo -e "$(cat control)" > $DRAGON_DIR/_/DEBIAN/control 2>/dev/null
67+
# TODO: remove this ASAP when DragonMake is generated by default for Theos projs
68+
# right now, there is no way to modify the control values w/o file modification
69+
if [[ $rootless == 1 ]]; then
70+
sed -i'' 's/Architecture: .*/Architecture: iphoneos-arm64/g' $DRAGON_DIR/_/DEBIAN/control
71+
fi
6772
else
6873
python3 -m dragongen.control DragonMake ./$DRAGON_DIR/_/DEBIAN/control
6974
fi
75+
if [[ $rootless == 1 ]]; then
76+
tmp=$(mktemp -d)
77+
find $DRAGON_DIR/_/ -mindepth 1 -maxdepth 1 ! -name 'DEBIAN' -exec mv {} $tmp \;
78+
mkdir -p $DRAGON_DIR/_/$PkgPrefix
79+
mv $tmp/* $DRAGON_DIR/_/$PkgPrefix
80+
rm -r $tmp
81+
fi
7082
du -d 0 $DRAGON_DIR/_ | xargs -I '{}' echo 'Installed-Size: {}' | cut -d ' ' -f 1,2 >> $DRAGON_DIR/_/DEBIAN/control
7183
chmod -R 0755 $DRAGON_DIR/_/DEBIAN/*
7284
mkdir -p $DRAGON_DIR/packages

src/dragon/shscripts/prerun_checks

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ if [[ $PLATFORM == Darwin ]]; then
3131
fi
3232
# iOS
3333
else
34-
if [[ -f /.procursus_strapped ]]; then
34+
if [[ -f /.procursus_strapped || -f /var/jb/.procursus_strapped ]]; then
3535
if ! [[ -x $(command -v sudo) ]]; then
3636
prefix_print "Please install sudo before proceeding."
3737
drexit 1
@@ -106,15 +106,12 @@ elif [[ ${PLATFORM,,} == linux ]]; then
106106
;;
107107
esac
108108

109-
curl -LO https://github.com/sbingner/llvm-project/releases/latest/download/linux-ios-arm64e-clang-toolchain.tar.lzma
110-
TMP=$(mktemp -d)
111-
tar -xvf linux-ios-arm64e-clang-toolchain.tar.lzma -C $TMP
112-
mkdir -p $DRAGON_ROOT_DIR/toolchain/linux/iphone
113-
mv $TMP/ios-arm64e-clang-toolchain/* $DRAGON_ROOT_DIR/toolchain/linux/iphone/
114-
rm -r linux-ios-arm64e-clang-toolchain.tar.lzma $TMP
109+
curl -LO https://github.com/L1ghtmann/llvm-project/releases/download/test-e99a150/iOSToolchain.tar.xz
110+
tar -xvf iOSToolchain.tar.xz -C $DRAGON_ROOT_DIR/toolchain/
111+
rm iOSToolchain.tar.xz
115112
elif ! [[ -x $DRAGON_ROOT_DIR/toolchain/linux/iphone/bin/ldid ]]; then
116113
prefix_print "You appear to be missing ldid, but have the toolchain. Not sure how we got here honestly ..."
117-
prefix_print "Please build or download ldid from https://github.com/sbingner/ldid or https://github.com/ProcursusTeam/ldid and place it in $DRAGON_ROOT_DIR/toolchain/linux/iphone/bin/."
114+
prefix_print "Please build or download ldid from https://github.com/ProcursusTeam/ldid and place it in $DRAGON_ROOT_DIR/toolchain/linux/iphone/bin/."
118115
drexit 1
119116
fi
120117
else

src/dragon/shscripts/util

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,24 +78,42 @@ usage()
7878
echo -e " ${PackageColor}do${NC} - ${BoldColor}Build and Install${NC}"
7979
echo -e " ${PackageColor}c${NC} | clean - ${BoldColor}Clear build cache${NC}"
8080
echo -e " ${PackageColor}b${NC} | build|make - ${BoldColor}Compile, link, and package your project${NC}"
81+
echo -e " ${PackageColor}g${NC} | gen|generate - ${BoldColor}Create build files without actually building${NC}"
82+
echo ""
83+
echo -e "${PrefixColor}Configuration ${BoldColor}-=-=-${NC}"
84+
echo -e " ${PackageColor}r${NC} | release - ${BoldColor}Create a release build (defines NDEBUG, enables 'releaseflags' value)${NC}"
85+
echo -e " ${PackageColor}ro${NC} | rootless - ${BoldColor}Build for rootless package scheme${NC}"
86+
echo -e " ${PackageColor}ddebug${NC} - ${BoldColor}Enable verbose debug logs${NC}"
87+
echo -e " ${PackageColor}vn${NC} - ${BoldColor}Enable verbose ninja(-build)${NC}"
88+
echo -e " ${PackageColor}vd${NC} - ${BoldColor}Enable verbose dragon${NC}"
89+
echo -e " ${PackageColor}vg${NC} - ${BoldColor}Enable verbose dragongen${NC}"
90+
echo -e " ${PackageColor}norm${NC} - ${BoldColor}Retain build.ninja after building${NC}"
8191
echo ""
8292
echo "Common invocations are 'dragon c b i' (clean all, build, install) or 'dragon do' (build and install)"
8393
echo ""
8494
echo -e "${PrefixColor}Distribution ${BoldColor}-=-=-${NC}"
85-
echo -e " ${PackageColor}r${NC} | release - ${BoldColor}Create a release build (defines NDEBUG, enables 'releaseflags' value)${NC}"
86-
echo -e " ${PackageColor}i${NC} | install - ${BoldColor}Install latest build to build device${NC}"
87-
echo -e " ${PackageColor}u${NC} | uninstall - ${BoldColor}Uninstall latest build from build device${NC}"
88-
echo -e " ${PackageColor}sn${NC} | send <file> - ${BoldColor}Install an arbitrary .deb to the device${NC}"
89-
echo -e " ${PackageColor}sim${NC} - ${BoldColor}Install to the simulator instead of a device${NC}"
95+
echo -e " ${PackageColor}i${NC} | install - ${BoldColor}Install latest build to build device${NC}"
96+
echo -e " ${PackageColor}u${NC} | uninstall - ${BoldColor}Uninstall latest build from build device${NC}"
97+
echo -e " ${PackageColor}sn${NC} | send <file> - ${BoldColor}Install an arbitrary .deb to the device${NC}"
98+
echo -e " ${PackageColor}sim${NC} | simulator - ${BoldColor}Install to the simulator instead of a device${NC}"
9099
echo ""
91100
echo -e "${PrefixColor}Device Management ${BoldColor}-=-=-${NC}"
92101
echo -e " ${PackageColor}s${NC} | device - ${BoldColor}Set build device IP/Port${NC}"
93102
echo -e " ${PackageColor}rs${NC} | respring - ${BoldColor}Respring the current build device${NC}"
94103
echo -e " ${PackageColor}dr${NC} | devicerun - ${BoldColor}Run anything after this flag on device${NC}"
95104
echo ""
96105
echo -e "${PrefixColor}Tools ${BoldColor}-=-=-${NC}"
97-
echo -e " ${PackageColor}d${NC} | debug [Process] - ${BoldColor}Start a debugging server on device and connect to it (Can be used with the install flag as well)${NC}"
98-
echo -e " ${PackageColor}exp${NC}| export - ${BoldColor}Tell ninja to create a compile_commands.json${NC}"
106+
echo -e " ${PackageColor}debug [Process]${NC} - ${BoldColor}Start a debugging server on device and connect to it (Can be used with the install flag as well)${NC}"
107+
echo -e " ${PackageColor}exp${NC} | export - ${BoldColor}Tell ninja to create a compile_commands.json${NC}"
108+
echo -e " ${PackageColor}lo${NC} | objcs - ${BoldColor}Configure llvm-objcs for use with dragon${NC}"
109+
echo -e " ${PackageColor}sr${NC} | rconf - ${BoldColor}Setup remote project build${NC}"
110+
echo -e " ${PackageColor}up${NC} | update|upgrade - ${BoldColor}Update dragon${NC}"
111+
echo -e " ${PackageColor}test${NC} - ${BoldColor}Run the test suite${NC}"
112+
echo -e " ${PackageColor}time${NC} - ${BoldColor}Print time for each bash subcommand to run${NC}"
113+
echo ""
114+
echo -e "${PrefixColor}Misc ${BoldColor}-=-=-${NC}"
115+
echo -e " ${PackageColor}v${NC} | -v - ${BoldColor}Prints version information${NC}"
116+
echo -e " ${PackageColor}h${NC} | -h|help - ${BoldColor}Prints this help page${NC}"
99117
echo ""
100118
echo -e "${PrefixColor}-=-=-${NC}"
101119
echo ""

src/dragon/shscripts/variables

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,18 @@ export build=0
77
export gen=0
88
export clean=0
99
export exportt=0
10-
export only=0
1110
export norm=0
1211
export debug=0
1312
export debugproc=""
1413
export ddebug=0
15-
export flutter=0
1614
export DRAGON_DPKG=1
1715
export DRAGON_POSTINST=0
1816

1917
export simtarg=0
2018

2119
export release=0
2220
export rootless=0
21+
export PkgPrefix=""
2322

2423
export ToolchainPath=""
2524
export ToolchainPrefix=""

0 commit comments

Comments
 (0)