Dragon: Difference between revisions

From iPhone Development Wiki
m (Kritanta moved page DragonBuild to Dragon: project rename)
No edit summary
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Overview ==
== Overview ==


DragonBuild consists of 2 main components:
dragon consists of 2 main components:


* A packaging system
* A packaging system
Line 12: Line 12:
=== Prerequisites ===
=== Prerequisites ===


Requires <code>ninja</code>, <code>perl</code>, and <code>python3</code>
Requires <code>python3</code>
 
python3 requires modules <code>pyyaml</code>.


=== Installation ===
=== Installation ===


<code>git clone https://github.com/DragonBuild/DragonBuild.git</code>
<code>pip install dragon</code>
 
Add the following to your shell's profile
 
<code>export DRAGONBUILD=path/to/dragonbuild</code> <code>alias dragon=$DRAGONBUILD/dragon</code>
 
Optionally, you can set an IP or name to install to via <code>export DRBIP=&quot;iphonename&quot;</code> or <code>export DRBIP=192.168.your.ip</code>


== Usage ==
== Usage ==
Line 47: Line 39:


This should serve as a guideline for how a project should be laid out. You can declare as many projects as you want, it's all going to be crammed into the same deb.
This should serve as a guideline for how a project should be laid out. You can declare as many projects as you want, it's all going to be crammed into the same deb.
Note: You dont need to create a control file if the relevant info is included in this one.


<source lang="yaml">---
<source lang="yaml">---
## This represents the overall project name.  
 
name: Name
# This represents the overall project name.  
# Everything in here will be built into a .deb package for installation
# Replace TweakName with the name of your project, of course
name: TweakName
icmd: killall -9 SpringBoard
icmd: killall -9 SpringBoard
id: com.mycompany.tweakname
version: 1.3
author: kritanta
depends: mobilesubstrate, preferenceloader


## This represents a Tweak .dylib and .plist.
TweakName:
Name:
     type: tweak
     type: tweak
    ## A list of logos files. See variables section for more info.
    logos_files:
        - $wildcard("./", "*.xm")
    ## A list, excluding logos files, of files to compile. See variables section for more info.
     files:
     files:
         - "*.m"
         - "*.xm"
    ## Min ios
          
    targetios: 11.0
# Now for preferences!
    ## List of archs we want to build for
TweakNamePrefs:
    archs:
        - arm64
         - arm64e
## Now for prefs!
NamePrefs:
    ## Specify the directory, since it's a subproject
     dir: nameprefs
     dir: nameprefs
    ## Tell dragon that it's a bundle
     type: prefs
     type: bundle
    ## You can specify files from anywhere in your tweak, or use directory specific wildcards
     files:
     files:
         - nameprefs/BlahRootListController.m
         - BlahRootListController.m
         - nameprefs/ACellYouUse.m
         - ACellYouUse.m
         - SomeFileFromYourMainTweak.m
         - ../SomeFileFromYourMainTweak.m
    archs:
          
        - arm64
# Subproject example
        - arm64e
ASubTweakName:
    ## Specify that we need the prefs framework for this bundle
    frameworks:
        - Preferences
    ## Required code for preferences
    ## The defaults assume that your bundles are for prefs.
    ## You can override install location and omit stage to make a regular bundle
    stage:
         - mkdir -p .dragon/_/Library/PreferenceLoader/Preferences/
        - cp entry.plist .dragon/_/Library/PreferenceLoader/Preferences/$name.plist
## If you have a tweak subproject that, for example, hooks another process, you can compile it into the same deb
## This is the minimal amount of info you can provide and have your project compile.
SomeOtherTweak:
     dir: othertweak
     dir: othertweak
     type: tweak
     type: tweak
     logos_files:
     files:
         - othertweak/Tweak.xm     
         - Tweak.xm     
</source>
</source>


Line 263: Line 239:
Yaml parsing is done via python3.
Yaml parsing is done via python3.


== DragonBuild Command Line Arguments ==
== dragon Command Line Arguments ==


All of these can be combined and ran at the same time, if needed.
All of these can be combined and ran at the same time, if needed.


=== Building and Installing your Tweak ===


All of these arguments can be specified using only the first character (<code>dragon c b i</code> for example)
All of these arguments can be specified using only the first character (<code>dragon c b i</code> for example)


<code>dragon build</code> to build (<code>dragon make</code> also works)
<source>
dragon v1.3 -=-=-
  usage: dragon [commands]
 
Building -=-=-
  do - Build and Install
  c|clean - clean old build files.
  b|build|make - build and package your project
  r|remote - Build using remote server
  sr|rconf - Setup remote server


<code>dragon install</code> to install.
Installation -=-=-
  s|device - Set build device IP/Port
  i|install - Install to build device
  sim - Install to the simulator instead of a device
  rs|respring - Respring the current build device
  dr|devicerun - Run anything after this flag on device
  sn|send <file> - Install a .deb to the device


<code>dragon do</code> combines both of these.
Tools -=-=-
  d|debug [Process Name] - Start a debugging server on device and connect to it (Can be used with the install flag as well)
  exp|export - Tell ninja to create a compile_commands.json
  f|flutter - Build with flutter before doing anything else
  ch|checkra1n - Open Checkra1n GUI
  chc|checkra1ncli - Open Checkra1n CLI


<code>dragon release</code> loads <code>DragonRelease</code> after loading <code>DragonMake</code>, allows for setting variables specific to release builds.
Debugging -=-=-
  vn - Print clang/ld/etc. commands and flags
  vd - echo every bash command in the main dragon file
  vg - DragonGen verbositiy.
  norm - Doesn't delete build.ninja after building.
  ddebug - Enable all debug flags


<code>dragon clean</code> performs a clean rebuild of the entire project and subprojects.
-=-=-
</source>


=== Generating compile commands for clangd or other tools ===
=== Generating compile commands for clangd or other tools ===


<code>dragon export</code>
<code>dragon export</code>

Latest revision as of 21:55, 30 April 2021

Overview

dragon consists of 2 main components:

  • A packaging system
  • A ninja buildfile generator

It uses Theos components for logos processing, but does not require an existing theos installation.

Setup

Prerequisites

Requires python3

Installation

pip install dragon

Usage

Dragon projects are configured via a single DragonMake file, regardless of how many subprojects you have.

You can specify subprojects and their information here. This allows for compiling slices in parallel easily, along with keeping things much more organized.

DragonMake Syntax

DragonMake follows fairly standard YAML syntax, with a singular escape character, $.

For single line variables, you can use bash syntax to evaluate a command with $$(command args)

A single $ denotes a ninja variable. For using bash syntax in variables, one can use $$ to represent a $ . For example, one could use $$PWD to get the value of an environment variable in a command.

Using the below items will parse output through xargs and add entries to the list the item is in: $wildcard("directory", "*.extension") will find all files in a specific directory.

$eval("bash command") is also provided, in the event more complex manipulation is needed.

Example Project

This should serve as a guideline for how a project should be laid out. You can declare as many projects as you want, it's all going to be crammed into the same deb.

Note: You dont need to create a control file if the relevant info is included in this one.

---

# This represents the overall project name. 
# Everything in here will be built into a .deb package for installation
# Replace TweakName with the name of your project, of course
name: TweakName
icmd: killall -9 SpringBoard
id: com.mycompany.tweakname
version: 1.3
author: kritanta
depends: mobilesubstrate, preferenceloader

TweakName:
    type: tweak
    files:
        - "*.xm"
        
# Now for preferences!
TweakNamePrefs:
    dir: nameprefs
    type: prefs
    files:
        - BlahRootListController.m
        - ACellYouUse.m
        - ../SomeFileFromYourMainTweak.m
        
# Subproject example
ASubTweakName:
    dir: othertweak
    type: tweak
    files:
        - Tweak.xm

DragonMake Variables

Please pay attention to the provided example to understand how these should be laid out in a file.

Name Type Description Default
name str Name of the whole project N/A
icmd str Command to run on device after install sbreload
name str Name of the item being build. Specified as yourNameHere: with the rest of the item specific variables below N/A
type str Type of project being built. One of "tweak"/"bundle"/"library". N/A
logos_files list List of files that require the logos preprocessor []
files list List of files to be compiled, excluding logos files. []
targetios str Minimum iOS Version Required []
archs list Architechtures to compile for []
sysroot str Root of the Patched SDK to build with $DRAGONBUILD/sdks/iPhoneOS.sdk
cc str c/c++ compiler to use clang+
ld str linker to use clang+
ldid str ldid binary to sign with ldid
dsym str dsymutil binary to symbolicate with dsymutil
logos str logos.pl file to use for preprocessing $DRAGONBUILD/bin/logos.pl
stage str/list Console command(s) to run before after build and before packaging
arc str -fobjc-arc, if enabling so is desired -fobjc-arc
targ str build target -DTARGET_IPHONE=1
warnings str Warnings flag -Wall
optim str Optimzation level. Higher levels can break obfuscators. 0
debug str debug flags -fcolor-diagnostics
libs list List of libraries to link the binary against
frameworks list List of Frameworks to compile with ['CoreFoundation', 'Foundation', 'UIKit', 'CoreGraphics', 'QuartzCore', 'CoreImage', 'AudioToolbox']
cflags str additional flags to pass to clang and the linker
ldflags str additional flags to pass to the linker
ldidflags str custom option for ldid '-S'
install_location str override variable for bundles/libraries to allow specifying install location
framework_search_dirs list Framework Search Dirs. Changing this variable overrides defaults. ['$sysroot/System/Library/Frameworks', '$sysroot/System/Library/PrivateFrameworks', '$dragondir/frameworks']
additional_framework_search_dirs list Allows adding framework search dirs without overwriting old ones. []
library_search_dirs list Library search dirs. Just like the framework search ['$dragondir/lib', '.']
additional_library_search_dirs list Add to lib search without overwriting []

Yaml parsing is done via python3.

dragon Command Line Arguments

All of these can be combined and ran at the same time, if needed.


All of these arguments can be specified using only the first character (dragon c b i for example)

dragon v1.3 -=-=-
  usage: dragon [commands]

Building -=-=-
  do - Build and Install
  c|clean - clean old build files.
  b|build|make - build and package your project
  r|remote - Build using remote server
  sr|rconf - Setup remote server

Installation -=-=-
  s|device - Set build device IP/Port
  i|install - Install to build device
  sim - Install to the simulator instead of a device
  rs|respring - Respring the current build device
  dr|devicerun - Run anything after this flag on device
  sn|send <file> - Install a .deb to the device

Tools -=-=-
  d|debug [Process Name] - Start a debugging server on device and connect to it (Can be used with the install flag as well)
  exp|export - Tell ninja to create a compile_commands.json
  f|flutter - Build with flutter before doing anything else
  ch|checkra1n - Open Checkra1n GUI
  chc|checkra1ncli - Open Checkra1n CLI

Debugging -=-=-
  vn - Print clang/ld/etc. commands and flags
  vd - echo every bash command in the main dragon file
  vg - DragonGen verbositiy.
  norm - Doesn't delete build.ninja after building.
  ddebug - Enable all debug flags

-=-=-

Generating compile commands for clangd or other tools

dragon export