diff --git a/README.md b/README.md index 4e413616a..e07b129c9 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/bin/dragon b/bin/dragon index f4e4b9c17..0e98ffbd6 100644 --- a/bin/dragon +++ b/bin/dragon @@ -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/" ;; @@ -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 diff --git a/docs/source/commands.rst b/docs/source/commands.rst index 487ba8731..29598d3d0 100644 --- a/docs/source/commands.rst +++ b/docs/source/commands.rst @@ -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 ********************* diff --git a/docs/source/conf.py b/docs/source/conf.py index 80818056c..47e39459d 100755 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -23,7 +23,7 @@ author = 'cynder' # The full version, including alpha/beta/rc tags -release = '1.7.1' +release = '1.7.2' # -- General configuration --------------------------------------------------- diff --git a/docs/source/dragonmake.rst b/docs/source/dragonmake.rst index 6bdf0d09c..be326aef3 100644 --- a/docs/source/dragonmake.rst +++ b/docs/source/dragonmake.rst @@ -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 diff --git a/setup.py b/setup.py index a36590aa3..d1eba4ad4 100644 --- a/setup.py +++ b/setup.py @@ -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/', diff --git a/src/dragon/config/banner.txt b/src/dragon/config/banner.txt index 771bc1de2..8fa6145ff 100644 --- a/src/dragon/config/banner.txt +++ b/src/dragon/config/banner.txt @@ -10,7 +10,7 @@ ████ ▀█¬ ▐███████ ▐███▌ ▐██ ▐██ ▐██ ██▀ ▐██ ██▄ ██▌ ▐██ ▐██ ██ ██ ▀███, ;.┌████████─▌ ████ ▀████▀██ ▐██ ▀████▀██ ▀███▀██▌ ▀█████▀ ██ ██ ████ ▄▀╓██████████ ╫▌▄███▌ ▄▄▄.▄██ - └████, ╓▄██└▄█████████▌▌ █████▀ ▀▀▀▀ version 1.7.1 + └████, ╓▄██└▄█████████▌▌ █████▀ ▀▀▀▀ version 1.7.2 █████████┌▄███████████═ ▄████▀ ~ cynder ╙████████████████████▓████▀ └▀████████████████████▀ this project was made possible by Lorenzo Pane. diff --git a/src/dragon/config/defaults.yml b/src/dragon/config/defaults.yml index 4d9098051..bf0f88d1e 100644 --- a/src/dragon/config/defaults.yml +++ b/src/dragon/config/defaults.yml @@ -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' diff --git a/src/dragon/shscripts/generator b/src/dragon/shscripts/generator index b73f26c13..8880c8c04 100644 --- a/src/dragon/shscripts/generator +++ b/src/dragon/shscripts/generator @@ -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 diff --git a/src/dragon/shscripts/util b/src/dragon/shscripts/util index d81c7a6c2..71435a2c5 100644 --- a/src/dragon/shscripts/util +++ b/src/dragon/shscripts/util @@ -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}" diff --git a/src/dragongen/generation.py b/src/dragongen/generation.py index d60321d12..82b0d0591 100644 --- a/src/dragongen/generation.py +++ b/src/dragongen/generation.py @@ -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. """ @@ -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 @@ -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'), @@ -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)