Skip to content

Commit b46030b

Browse files
committed
Add new 'r'/'release' command, DEBUG/RELEASE builds, 'dbgflags'/'releaseflags' variables.
1 parent 0d8db69 commit b46030b

File tree

11 files changed

+58
-25
lines changed

11 files changed

+58
-25
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Version 1.6.0 and later:
4949
dragon update
5050
```
5151

52-
Version 1.5.1 and older:
52+
To reinstall a broken installation:
5353

5454
```sh
5555
rm -rf ~/.dragon

bin/dragon

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,7 @@ while ! [[ -z $1 ]]; do
135135
$C1 -c
136136
drexit
137137
;;
138-
r | remote ) shift
139-
remote $*
140-
drexit
138+
r | release ) release=1
141139
;;
142140
relink ) rm -r "$DRAGON_DATA_DIR/sign/"
143141
;;
@@ -206,6 +204,17 @@ if [[ $build -eq 1 ]]; then
206204
if [[ $norm -eq 0 ]]; then
207205
find . -name '*.ninja' -type f -delete
208206
fi
207+
else
208+
if [[ $gen -eq 1 ]]; then
209+
rm -rf "$DRAGON_DATA_DIR/ninja/build.ninja" 2>/dev/null
210+
mkdir -p "$DRAGON_DATA_DIR/"{ninja,modules}
211+
212+
generate
213+
214+
if [[ $DRAGONGEN_FAILURE -eq 1 ]]; then
215+
cleanbuildfail
216+
fi
217+
fi
209218
fi
210219

211220

docs/source/commands.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ Building a package
2121
``dragon b``, ``dragon build``, or ``dragon make`` builds a package
2222

2323

24+
Building a package for release
25+
^^^^^^^^^^^^^^^^^^^^^
26+
27+
The ``r`` / ``release`` command can be added to the ``build`` command to define "NDEBUG" and undefine "DEBUG" within compiled code.
28+
29+
Passing this flag will also cause the contents of the DragonMake variable ``dbgflags`` to be ignored, and the contents of ``releaseflags`` to be used instead.
30+
31+
2432
Clean Building a package
2533
*********************
2634

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
author = 'cynder'
2424

2525
# The full version, including alpha/beta/rc tags
26-
release = '1.7.1'
26+
release = '1.7.2'
2727

2828
# -- General configuration ---------------------------------------------------
2929

docs/source/dragonmake.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,12 @@ None of these are required by default, but you may need some of them for various
217217
* - cflags
218218
- String/List
219219
- List (or a space seperated string) with cflags used at compilation time
220+
* - releaseflags
221+
- String/List
222+
- List (or a space seperated string) with cflags used on release (dragon b r) builds
223+
* - dbgflags
224+
- String/List
225+
- List (or a space seperated string) with cflags used on debug builds (without r/release command)
220226
* - frameworks
221227
- List
222228
- List of frameworks to link against

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from setuptools import setup
44

55
setup(name='dragon',
6-
version='1.7.1',
6+
version='1.7.2',
77
description='A powerful toolkit targeting Apple development, research, and packaging.',
88
author='cynder',
99
url='https://dragon.cynder.me/',

src/dragon/config/banner.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
████ ▀█¬ ▐███████ ▐███▌ ▐██ ▐██ ▐██ ██▀ ▐██ ██▄ ██▌ ▐██ ▐██ ██ ██
1111
▀███, ;.┌████████─▌ ████ ▀████▀██ ▐██ ▀████▀██ ▀███▀██▌ ▀█████▀ ██ ██
1212
████ ▄▀╓██████████ ╫▌▄███▌ ▄▄▄.▄██
13-
└████, ╓▄██└▄█████████▌▌ █████▀ ▀▀▀▀ version 1.7.1
13+
└████, ╓▄██└▄█████████▌▌ █████▀ ▀▀▀▀ version 1.7.2
1414
█████████┌▄███████████═ ▄████▀ ~ cynder
1515
╙████████████████████▓████▀
1616
└▀████████████████████▀ this project was made possible by Lorenzo Pane.

src/dragon/config/defaults.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ Defaults:
5050
# Touching these without a firm grasp of what you're doing is likely to break things
5151
# They serve to abstract how we slap together all of the clang args
5252
InternalDefaults:
53-
internalcflags: '$cinclude $debug $fwSearch $cflags $btarg -O$optim $sysroot $header_includes $arc $triple $theosshim $macros $prefix $warnings $modulesinternal'
53+
internaldbgflags: '-DDEBUG'
54+
internalreleaseflags: '-DNDEBUG'
55+
internalcflags: '$cinclude $debug $fwSearch $cflags $btarg -O$optim $sysroot $header_includes $arc $triple $theosshim $macros $prefix $warnings $modulesinternal $internaldbgflags $internalreleaseflags $dbgflags $releaseflags'
5456
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'
5557
internalfflags: '$internalcflags $typeldflags $frameworks $libs $libflags $lopts $libSearch $ldflags $libs'
5658
internalldflags: '$internalcflags $typeldflags $frameworks $libs $libflags $lopts $libSearch $ldflags $libs'

src/dragon/shscripts/generator

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,20 @@ generate()
66

77
echo $simtarg | grep "1" > /dev/null && gen_print "Targeting Simulator + simject"
88

9-
eval $(DGEN_DEBUG=${DGEN_DEBUG} TARG_SIM=${simtarg} python3 -m dragongen.generation)
9+
10+
if [[ $release -eq 1 ]]; then
11+
gen_print "---"
12+
gen_print "Building For RELEASE"
13+
gen_print "(#ifdef DEBUG == false, #ifdef NDEBUG == true)"
14+
gen_print "---"
15+
else
16+
gen_print "---"
17+
gen_print "Building For DEBUG"
18+
gen_print "(#ifdef DEBUG == true, #ifdef NDEBUG = false)"
19+
gen_print "---"
20+
fi
21+
22+
eval $(DGEN_DEBUG=${DGEN_DEBUG} TARG_SIM=${simtarg} RELEASE=${release} python3 -m dragongen.generation)
1023

1124
export TWEAK_NAME=$package_name
1225
export INSTALL_CMD=$install_command

src/dragon/shscripts/util

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ usage()
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}"
8181
echo ""
82+
echo -e " ${PackageColor}r${NC}|release - ${BoldColor}Create a release build (defines NDEBUG, enables 'releaseflags' value)${NC}"
83+
echo ""
8284
echo -e "${PrefixColor}Installation ${BoldColor}-=-=-${NC}"
8385
echo -e " ${PackageColor}s${NC}|device - ${BoldColor}Set build device IP/Port${NC}"
8486
echo -e " ${PackageColor}i${NC}|install - ${BoldColor}Install to build device${NC}"

src/dragongen/generation.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,9 @@
77
(c) 2020 cynder
88
Please refer to the LICENSE file included with this project regarding the usage of code herein.
99
10-
Author credits:
11-
- @cynder
12-
- @l0renzo
13-
14-
Some guidelines for work on this file moving forward:
15-
- `dragon test` before pushing, always
16-
- Avoid re-typing variables and use type hints where possible
17-
- Avoid lines longer than 80-90 chars
18-
- Code should make a 'good attempt' to stick to PEP-8 guidelines
19-
- Avoid anything in the global namespace
20-
- Use descriptive variable names. Code should be extremely self-documenting
21-
- Comment any lines of code that are confusing
22-
- Don't code-golf
23-
24-
Things to keep in mind when working on this file:
25-
10+
this file looks moderately sane thanks to wonderful work by @l0renzo
2611
12+
any remaining or new travesties are my own fabrications.
2713
2814
"""
2915

@@ -41,6 +27,8 @@
4127

4228
_IS_THEOS_MAKEFILE_ = False
4329

30+
_RELEASE_BUILD = False
31+
4432
# These are used like so:
4533
# a_build_object = Build("output files here", "rule name here", "input files here")
4634
# outputs = a_build_object.outputs
@@ -428,6 +416,9 @@ def generate_ninja_outline(self) -> list:
428416
Var('lfflags'),
429417
Var('swiftflags'),
430418
___,
419+
Var('internalreleaseflags') if _RELEASE_BUILD else Var('internaldbgflags'),
420+
Var('releaseflags') if _RELEASE_BUILD else Var('dbgflags'),
421+
___,
431422
Var('theosshim'),
432423
Var('internalcflags'),
433424
Var('internalldflags'),
@@ -640,6 +631,8 @@ def main():
640631
try:
641632
if os.environ['DGEN_DEBUG']:
642633
log.LOG_LEVEL = LogLevel.DEBUG
634+
if os.environ['RELEASE'] == "1":
635+
_RELEASE_BUILD = True
643636
main()
644637
except FileNotFoundError as exception:
645638
print('Error: No project files found', file=sys.stderr)

0 commit comments

Comments
 (0)