Skip to content

Commit

Permalink
Add new 'r'/'release' command, DEBUG/RELEASE builds, 'dbgflags'/'rele…
Browse files Browse the repository at this point in the history
…aseflags' variables.
  • Loading branch information
vr1s committed Mar 10, 2023
1 parent 0d8db69 commit b46030b
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Version 1.6.0 and later:
dragon update
```

Version 1.5.1 and older:
To reinstall a broken installation:

```sh
rm -rf ~/.dragon
Expand Down
15 changes: 12 additions & 3 deletions bin/dragon
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,7 @@ while ! [[ -z $1 ]]; do
$C1 -c
drexit
;;
r | remote ) shift
remote $*
drexit
r | release ) release=1
;;
relink ) rm -r "$DRAGON_DATA_DIR/sign/"
;;
Expand Down Expand Up @@ -206,6 +204,17 @@ if [[ $build -eq 1 ]]; then
if [[ $norm -eq 0 ]]; then
find . -name '*.ninja' -type f -delete
fi
else
if [[ $gen -eq 1 ]]; then
rm -rf "$DRAGON_DATA_DIR/ninja/build.ninja" 2>/dev/null
mkdir -p "$DRAGON_DATA_DIR/"{ninja,modules}

generate

if [[ $DRAGONGEN_FAILURE -eq 1 ]]; then
cleanbuildfail
fi
fi
fi


Expand Down
8 changes: 8 additions & 0 deletions docs/source/commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ Building a package
``dragon b``, ``dragon build``, or ``dragon make`` builds a package


Building a package for release
^^^^^^^^^^^^^^^^^^^^^

The ``r`` / ``release`` command can be added to the ``build`` command to define "NDEBUG" and undefine "DEBUG" within compiled code.

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.


Clean Building a package
*********************

Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
author = 'cynder'

# The full version, including alpha/beta/rc tags
release = '1.7.1'
release = '1.7.2'

# -- General configuration ---------------------------------------------------

Expand Down
6 changes: 6 additions & 0 deletions docs/source/dragonmake.rst
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ None of these are required by default, but you may need some of them for various
* - cflags
- String/List
- List (or a space seperated string) with cflags used at compilation time
* - releaseflags
- String/List
- List (or a space seperated string) with cflags used on release (dragon b r) builds
* - dbgflags
- String/List
- List (or a space seperated string) with cflags used on debug builds (without r/release command)
* - frameworks
- List
- List of frameworks to link against
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from setuptools import setup

setup(name='dragon',
version='1.7.1',
version='1.7.2',
description='A powerful toolkit targeting Apple development, research, and packaging.',
author='cynder',
url='https://dragon.cynder.me/',
Expand Down
2 changes: 1 addition & 1 deletion src/dragon/config/banner.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
████ ▀█¬ ▐███████ ▐███▌ ▐██ ▐██ ▐██ ██▀ ▐██ ██▄ ██▌ ▐██ ▐██ ██ ██
▀███, ;.┌████████─▌ ████ ▀████▀██ ▐██ ▀████▀██ ▀███▀██▌ ▀█████▀ ██ ██
████ ▄▀╓██████████ ╫▌▄███▌ ▄▄▄.▄██
└████, ╓▄██└▄█████████▌▌ █████▀ ▀▀▀▀ version 1.7.1
└████, ╓▄██└▄█████████▌▌ █████▀ ▀▀▀▀ version 1.7.2
█████████┌▄███████████═ ▄████▀ ~ cynder
╙████████████████████▓████▀
└▀████████████████████▀ this project was made possible by Lorenzo Pane.
Expand Down
4 changes: 3 additions & 1 deletion src/dragon/config/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ Defaults:
# Touching these without a firm grasp of what you're doing is likely to break things
# They serve to abstract how we slap together all of the clang args
InternalDefaults:
internalcflags: '$cinclude $debug $fwSearch $cflags $btarg -O$optim $sysroot $header_includes $arc $triple $theosshim $macros $prefix $warnings $modulesinternal'
internaldbgflags: '-DDEBUG'
internalreleaseflags: '-DNDEBUG'
internalcflags: '$cinclude $debug $fwSearch $cflags $btarg -O$optim $sysroot $header_includes $arc $triple $theosshim $macros $prefix $warnings $modulesinternal $internaldbgflags $internalreleaseflags $dbgflags $releaseflags'
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'
internalfflags: '$internalcflags $typeldflags $frameworks $libs $libflags $lopts $libSearch $ldflags $libs'
internalldflags: '$internalcflags $typeldflags $frameworks $libs $libflags $lopts $libSearch $ldflags $libs'
Expand Down
15 changes: 14 additions & 1 deletion src/dragon/shscripts/generator
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,20 @@ generate()

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

eval $(DGEN_DEBUG=${DGEN_DEBUG} TARG_SIM=${simtarg} python3 -m dragongen.generation)

if [[ $release -eq 1 ]]; then
gen_print "---"
gen_print "Building For RELEASE"
gen_print "(#ifdef DEBUG == false, #ifdef NDEBUG == true)"
gen_print "---"
else
gen_print "---"
gen_print "Building For DEBUG"
gen_print "(#ifdef DEBUG == true, #ifdef NDEBUG = false)"
gen_print "---"
fi

eval $(DGEN_DEBUG=${DGEN_DEBUG} TARG_SIM=${simtarg} RELEASE=${release} python3 -m dragongen.generation)

export TWEAK_NAME=$package_name
export INSTALL_CMD=$install_command
Expand Down
2 changes: 2 additions & 0 deletions src/dragon/shscripts/util
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ usage()
echo -e " ${PackageColor}c${NC}|clean - ${BoldColor}Clear build cache${NC}"
echo -e " ${PackageColor}b${NC}|build|make - ${BoldColor}Compile, link, and package your project${NC}"
echo ""
echo -e " ${PackageColor}r${NC}|release - ${BoldColor}Create a release build (defines NDEBUG, enables 'releaseflags' value)${NC}"
echo ""
echo -e "${PrefixColor}Installation ${BoldColor}-=-=-${NC}"
echo -e " ${PackageColor}s${NC}|device - ${BoldColor}Set build device IP/Port${NC}"
echo -e " ${PackageColor}i${NC}|install - ${BoldColor}Install to build device${NC}"
Expand Down
25 changes: 9 additions & 16 deletions src/dragongen/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,9 @@
(c) 2020 cynder
Please refer to the LICENSE file included with this project regarding the usage of code herein.
Author credits:
- @cynder
- @l0renzo
Some guidelines for work on this file moving forward:
- `dragon test` before pushing, always
- Avoid re-typing variables and use type hints where possible
- Avoid lines longer than 80-90 chars
- Code should make a 'good attempt' to stick to PEP-8 guidelines
- Avoid anything in the global namespace
- Use descriptive variable names. Code should be extremely self-documenting
- Comment any lines of code that are confusing
- Don't code-golf
Things to keep in mind when working on this file:
this file looks moderately sane thanks to wonderful work by @l0renzo
any remaining or new travesties are my own fabrications.
"""

Expand All @@ -41,6 +27,8 @@

_IS_THEOS_MAKEFILE_ = False

_RELEASE_BUILD = False

# These are used like so:
# a_build_object = Build("output files here", "rule name here", "input files here")
# outputs = a_build_object.outputs
Expand Down Expand Up @@ -428,6 +416,9 @@ def generate_ninja_outline(self) -> list:
Var('lfflags'),
Var('swiftflags'),
___,
Var('internalreleaseflags') if _RELEASE_BUILD else Var('internaldbgflags'),
Var('releaseflags') if _RELEASE_BUILD else Var('dbgflags'),
___,
Var('theosshim'),
Var('internalcflags'),
Var('internalldflags'),
Expand Down Expand Up @@ -640,6 +631,8 @@ def main():
try:
if os.environ['DGEN_DEBUG']:
log.LOG_LEVEL = LogLevel.DEBUG
if os.environ['RELEASE'] == "1":
_RELEASE_BUILD = True
main()
except FileNotFoundError as exception:
print('Error: No project files found', file=sys.stderr)
Expand Down

0 comments on commit b46030b

Please sign in to comment.