├── .gitignore ├── LICENSE ├── Makefile ├── RHDownloadReveal.m ├── RHRevealLoader.l.mm ├── RHRevealLoader.plist ├── RHRevealLoader.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── Readme.md ├── build.sh ├── control ├── layout └── Library │ └── PreferenceLoader │ └── Preferences │ ├── RHRevealLoader.plist │ ├── reveal-logo.png │ └── reveal-logo@2x.png ├── publish.sh ├── release.sh ├── releases ├── Packages.bz2 ├── Packages.gz ├── Release └── debs │ └── com.rheard.reveal-loader_1.0.0-1_iphoneos-arm.deb ├── ssh-askpass ├── theos ├── .bootstrap ├── LICENSE ├── Prefix.pch ├── bin │ ├── bootstrap.sh │ ├── deb_build_num.sh │ ├── denicify.pl │ ├── dpkg-deb │ ├── fakeroot.sh │ ├── install.copyFile │ ├── install.exec │ ├── install.mergeDir │ ├── ldid │ ├── lib │ │ ├── Logos │ │ │ ├── Class.pm │ │ │ ├── Generator.pm │ │ │ ├── Generator │ │ │ │ ├── Base │ │ │ │ │ ├── Class.pm │ │ │ │ │ ├── Generator.pm │ │ │ │ │ ├── Group.pm │ │ │ │ │ ├── Method.pm │ │ │ │ │ ├── StaticClassGroup.pm │ │ │ │ │ └── Subclass.pm │ │ │ │ ├── MobileSubstrate │ │ │ │ │ ├── Class.pm │ │ │ │ │ ├── Generator.pm │ │ │ │ │ ├── Method.pm │ │ │ │ │ └── Subclass.pm │ │ │ │ ├── Thunk.pm │ │ │ │ └── internal │ │ │ │ │ ├── Class.pm │ │ │ │ │ ├── Generator.pm │ │ │ │ │ ├── Method.pm │ │ │ │ │ └── Subclass.pm │ │ │ ├── Group.pm │ │ │ ├── Ivar.pm │ │ │ ├── Method.pm │ │ │ ├── Patch.pm │ │ │ ├── Patch │ │ │ │ └── Source │ │ │ │ │ └── Generator.pm │ │ │ ├── StaticClassGroup.pm │ │ │ ├── Subclass.pm │ │ │ └── Util.pm │ │ ├── NIC │ │ │ ├── Bridge │ │ │ │ ├── Context.pm │ │ │ │ ├── Directory.pm │ │ │ │ ├── File.pm │ │ │ │ ├── NICBase.pm │ │ │ │ ├── NICType.pm │ │ │ │ ├── Symlink.pm │ │ │ │ ├── Tie │ │ │ │ │ └── WrappedMethod.pm │ │ │ │ ├── _BridgedObject.pm │ │ │ │ └── _Undefined.pm │ │ │ ├── Formats │ │ │ │ ├── NIC1.pm │ │ │ │ ├── NICTar.pm │ │ │ │ └── NICTar │ │ │ │ │ ├── Directory.pm │ │ │ │ │ ├── File.pm │ │ │ │ │ ├── Symlink.pm │ │ │ │ │ └── _TarMixin.pm │ │ │ ├── NICBase.pm │ │ │ ├── NICBase │ │ │ │ ├── Directory.pm │ │ │ │ ├── File.pm │ │ │ │ └── Symlink.pm │ │ │ ├── NICType.pm │ │ │ └── Tie │ │ │ │ ├── Method.pm │ │ │ │ └── PrefixedHandleRedirect.pm │ │ ├── aliased.pm │ │ └── parent.pm │ ├── logify.pl │ ├── logos.pl │ ├── nic.pl │ ├── nicify.pl │ ├── package_version.sh │ ├── target.pl │ └── vercmp.pl ├── documentation │ ├── Makefile │ └── makefiles.docbook ├── extras │ └── vim │ │ ├── README │ │ ├── ftplugin │ │ └── logos.vim │ │ ├── indent │ │ └── logos.vim │ │ └── syntax │ │ └── logos.vim ├── include │ ├── DHCommon.h │ ├── DHHookCommon.h │ ├── logos │ │ └── logos.h │ └── substrate.h ├── lib │ ├── .keep │ ├── libsubstrate.dylib │ └── libsubstrate.dylib.1 ├── makefiles │ ├── aggregate.mk │ ├── application.mk │ ├── bundle.mk │ ├── common.mk │ ├── framework.mk │ ├── install │ │ ├── deb_local.mk │ │ ├── deb_remote.mk │ │ ├── none_local.mk │ │ └── none_remote.mk │ ├── instance │ │ ├── application.mk │ │ ├── bundle.mk │ │ ├── framework.mk │ │ ├── library.mk │ │ ├── null.mk │ │ ├── rules.mk │ │ ├── shared │ │ │ └── bundle.mk │ │ ├── subproject.mk │ │ ├── tool.mk │ │ └── tweak.mk │ ├── legacy.mk │ ├── library.mk │ ├── master │ │ ├── aggregate.mk │ │ ├── application.mk │ │ ├── bundle.mk │ │ ├── framework.mk │ │ ├── library.mk │ │ ├── null.mk │ │ ├── rules.mk │ │ ├── subproject.mk │ │ ├── tool.mk │ │ └── tweak.mk │ ├── messages.mk │ ├── null.mk │ ├── package.mk │ ├── package │ │ ├── deb.mk │ │ └── none.mk │ ├── platform │ │ ├── Darwin-arm.mk │ │ ├── Darwin.mk │ │ └── Linux.mk │ ├── rules.mk │ ├── stage.mk │ ├── subproject.mk │ ├── targets │ │ ├── Darwin-arm │ │ │ ├── iphone.mk │ │ │ └── native.mk │ │ ├── Darwin │ │ │ ├── iphone.mk │ │ │ ├── macosx.mk │ │ │ ├── native.mk │ │ │ └── simulator.mk │ │ ├── Linux │ │ │ ├── iphone.mk │ │ │ ├── linux.mk │ │ │ └── native.mk │ │ └── _common │ │ │ ├── darwin.mk │ │ │ ├── darwin_flat_bundle.mk │ │ │ ├── darwin_hierarchial_bundle.mk │ │ │ └── linux.mk │ ├── tool.mk │ └── tweak.mk ├── mod │ └── .keep └── templates │ └── iphone │ ├── application.nic.tar │ ├── library.nic.tar │ ├── preference_bundle.nic.tar │ ├── tool.nic.tar │ └── tweak.nic.tar └── third-party ├── libcurl ├── curl │ ├── curl.h │ ├── curlbuild.h │ ├── curlrules.h │ ├── curlver.h │ ├── easy.h │ ├── mprintf.h │ ├── multi.h │ ├── stdcheaders.h │ └── typecheck-gcc.h └── libcurl.a └── partialzip ├── CMakeLists.txt ├── README ├── include ├── common.h └── partial │ └── partial.h ├── partial.c └── test.c /.gitignore: -------------------------------------------------------------------------------- 1 | obj 2 | .theos 3 | _ 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Reveal Loader 2 | 3 | Copyright (c) 2014 Richard Heard. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 1. Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 3. The name of the author may not be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | export THEOS_PACKAGE_DIR_NAME=./releases/debs 2 | export TARGET=:clang:latest:5.1 3 | export ARCHS=armv7 armv7s arm64 4 | export ADDITIONAL_CFLAGS = -Ithird-party/partialzip/include -Ithird-party/libcurl 5 | export SSH_ASKPASS = ./ssh-askpass 6 | 7 | include theos/makefiles/common.mk 8 | 9 | TWEAK_NAME = RHRevealLoader 10 | RHRevealLoader_FILES = RHRevealLoader.mm 11 | 12 | TOOL_NAME = extrainst_ 13 | extrainst__INSTALL_PATH = /DEBIAN 14 | extrainst__FILES = RHDownloadReveal.m third-party/partialzip/partial.c 15 | extrainst__LIBRARIES = z 16 | extrainst__FRAMEWORKS = Security 17 | extrainst__OBJ_FILES = third-party/libcurl/libcurl.a 18 | 19 | include $(THEOS_MAKE_PATH)/tweak.mk 20 | include $(THEOS_MAKE_PATH)/tool.mk 21 | 22 | after-install:: 23 | install.exec "killall -9 SpringBoard" 24 | -------------------------------------------------------------------------------- /RHDownloadReveal.m: -------------------------------------------------------------------------------- 1 | // 2 | // RHDownloadReveal.m 3 | // RHDownloadReveal 4 | // 5 | // Created by Richard Heard on 21/03/2014. 6 | // Copyright (c) 2014 Richard Heard. All rights reserved. 7 | // 8 | 9 | #include 10 | #include 11 | 12 | #include "common.h" 13 | #include 14 | char endianness = IS_LITTLE_ENDIAN; 15 | 16 | #ifdef __OBJC__ 17 | #import 18 | #endif 19 | 20 | //download libReveal using partialzip 21 | 22 | NSString *downloadURL = @"http://download.revealapp.com/Reveal.app.zip"; 23 | NSString *zipPath = @"Reveal.app/Contents/SharedSupport/iOS-Libraries/libReveal.dylib"; 24 | 25 | NSString *folder = @"/Library/RHRevealLoader"; 26 | NSString *filename = @"libReveal.dylib"; 27 | 28 | struct partialFile { 29 | unsigned char *pos; 30 | size_t fileSize; 31 | size_t downloadedBytes; 32 | float lastPercentageLogged; 33 | }; 34 | 35 | 36 | size_t data_callback(ZipInfo* info, CDFile* file, unsigned char *buffer, size_t size, void *userInfo) { 37 | struct partialFile *pfile = (struct partialFile *)userInfo; 38 | memcpy(pfile->pos, buffer, size); 39 | pfile->pos += size; 40 | pfile->downloadedBytes += size; 41 | 42 | float newPercentage = (int)(((float)pfile->downloadedBytes/(float)pfile->fileSize) * 100.f); 43 | if (newPercentage > pfile->lastPercentageLogged){ 44 | if ((int)newPercentage % 5 == 0 || pfile->lastPercentageLogged == 0.0f){ 45 | printf("Downloading.. %g%%\n", newPercentage); 46 | pfile->lastPercentageLogged = newPercentage; 47 | } 48 | } 49 | 50 | return size; 51 | } 52 | 53 | int main(int argc, const char *argv[], const char *envp[]){ 54 | NSString *libraryPath = [folder stringByAppendingPathComponent:filename]; 55 | 56 | if (argc > 1 && strcmp(argv[1], "upgrade") != 0) { 57 | printf("CYDIA upgrade, nuking existing %s\n", [libraryPath UTF8String]); 58 | [[NSFileManager defaultManager] removeItemAtPath:libraryPath error:nil]; 59 | } 60 | 61 | if (![[NSFileManager defaultManager] fileExistsAtPath:libraryPath]) { 62 | //download libReveal.dylib 63 | printf("Downloading '%s /%s' to '%s'.\n", [downloadURL UTF8String], [zipPath UTF8String], [libraryPath UTF8String]); 64 | 65 | 66 | ZipInfo* info = PartialZipInit([downloadURL UTF8String]); 67 | if(!info) { 68 | printf("Cannot find %s\n", [downloadURL UTF8String]); 69 | return 0; 70 | } 71 | 72 | CDFile *file = PartialZipFindFile(info, [zipPath UTF8String]); 73 | if(!file) { 74 | printf("Cannot find %s in %s\n", [zipPath UTF8String], [downloadURL UTF8String]); 75 | return 0; 76 | } 77 | 78 | int dataLen = file->size; 79 | 80 | unsigned char *data = malloc(dataLen+1); 81 | struct partialFile pfile = (struct partialFile){data, dataLen, 0}; 82 | 83 | PartialZipGetFile(info, file, data_callback, &pfile); 84 | *(pfile.pos) = '\0'; 85 | 86 | PartialZipRelease(info); 87 | 88 | NSData *dylibData = [NSData dataWithBytes:data length:dataLen]; 89 | 90 | if (![[NSFileManager defaultManager] createDirectoryAtPath:folder withIntermediateDirectories:YES attributes:nil error:nil]){ 91 | printf("Failed to create folder %s\n", [folder UTF8String]); 92 | return 0; 93 | } 94 | 95 | if (![dylibData writeToFile:libraryPath atomically:YES]){ 96 | printf("Failed to write file to path %s\n", [libraryPath UTF8String]); 97 | return 0; 98 | } 99 | 100 | free(data); 101 | printf("Successfully downloaded %s to path %s\n", [downloadURL UTF8String], [libraryPath UTF8String]); 102 | 103 | } else { 104 | printf("libReveal.dylib already exists at path %s\n", [libraryPath UTF8String]); 105 | } 106 | 107 | return 0; 108 | } 109 | -------------------------------------------------------------------------------- /RHRevealLoader.l.mm: -------------------------------------------------------------------------------- 1 | // 2 | // RHRevealLoader.xm 3 | // RHRevealLoader 4 | // 5 | // Created by Richard Heard on 21/03/2014. 6 | // Copyright (c) 2014 Richard Heard. All rights reserved. 7 | // 8 | 9 | #include 10 | %ctor { 11 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 12 | NSDictionary *prefs = [[NSDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/com.rheard.RHRevealLoader.plist"] retain]; 13 | NSString *libraryPath = @"/Library/RHRevealLoader/libReveal.dylib"; 14 | 15 | if([[prefs objectForKey:[NSString stringWithFormat:@"RHRevealEnabled-%@", [[NSBundle mainBundle] bundleIdentifier]]] boolValue]) { 16 | if ([[NSFileManager defaultManager] fileExistsAtPath:libraryPath]){ 17 | dlopen([libraryPath UTF8String], RTLD_NOW); 18 | [[NSNotificationCenter defaultCenter] postNotificationName:@"IBARevealRequestStart" object:nil]; 19 | NSLog(@"RHRevealLoader loaded %@", libraryPath); 20 | } 21 | } 22 | 23 | [pool drain]; 24 | } 25 | -------------------------------------------------------------------------------- /RHRevealLoader.plist: -------------------------------------------------------------------------------- 1 | { Filter = { Bundles = ( "com.apple.UIKit" ); }; } 2 | -------------------------------------------------------------------------------- /RHRevealLoader.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | ## Reveal iOS Jailbreak Tweak 2 | Reveal Loader dynamically loads libReveal.dylib (Reveal.app support) into iOS apps on jailbroken devices. Configuration is via the Reveal menu in Settings.app 3 | 4 | Reveal is an OS X application that allows you to remotely introspect a running applications view hierarchy and edit various view properties. 5 | 6 | Generally you have to include their debugging framework in your application at build time in-order to perform debugging actions, however with this tweak installed this is no longer necessary. 7 | 8 | For more info see [revealapp.com](http://revealapp.com) 9 | 10 | 11 | ## How to Install 12 | Reveal Loader is available directly inside Cydia. Just search for the "Reveal Loader" development package. 13 | 14 | ## How to Install - Custom 15 | See [here](http://www.ijailbreak.com/cydia/how-to-add-a-cydia-repository/) for how to add a Repository to Cydia. 16 | 17 | Navigate to 'Cydia > Sources Tab > Edit > Add' and enter the below source URL. 18 | 19 | `http://rheard.com/cydia` 20 | 21 | Finally, search for Reveal Loader on the Packages Tab and select install. 22 | 23 | ## How to Use 24 | Open 'Settings > Reveal > Enabled Applications' and toggle the application or applications that you want to debug to on. 25 | 26 | Launch the target application and it should appear inside Reveal.app on your Mac. 27 | 28 | (You will likely need to quit and relaunch the target application) 29 | 30 | ## Be Social 31 | Follow me on [Twitter](https://twitter.com/intent/follow?screen_name=heardrwt) (@heardrwt) 32 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | make clean 3 | make 4 | make package 5 | make install THEOS_DEVICE_IP=rPad.local 6 | 7 | -------------------------------------------------------------------------------- /control: -------------------------------------------------------------------------------- 1 | Package: com.rheard.reveal-loader 2 | Conflicts: com.rheard.rhrevealloader 3 | Replaces: com.rheard.rhrevealloader 4 | Name: Reveal Loader 5 | Version: 1.0.0 6 | Architecture: iphoneos-arm 7 | Depends: mobilesubstrate, preferenceloader, applist 8 | Maintainer: Richard Heard 9 | Author: Richard Heard 10 | Section: Tweaks 11 | Description: dynamically loads Reveal into applications 12 | RevealLoader dynamically loads libReveal.dylib (Reveal.app support) into iOS apps 13 | on jailbroken devices. Configuration is via the Reveal menu in Settings.app 14 | For more info, see http://github.com/heardrwt/RevealLoader and http://revealapp.com 15 | Tag: role::developer, purpose::extension 16 | -------------------------------------------------------------------------------- /layout/Library/PreferenceLoader/Preferences/RHRevealLoader.plist: -------------------------------------------------------------------------------- 1 | { 2 | entry = { 3 | cell = PSLinkCell; 4 | label = Reveal; 5 | icon = "reveal-logo.png"; 6 | items = ( 7 | { 8 | bundle = AppList; 9 | isController = 1; 10 | cell = PSLinkCell; 11 | label = "Enabled Applications"; 12 | ALSettingsPath = "/var/mobile/Library/Preferences/com.rheard.RHRevealLoader.plist"; 13 | ALSettingsKeyPrefix = "RHRevealEnabled-"; 14 | "ALSettingsDefaultValue" = ""; 15 | ALAllowsSelection = 1; 16 | ALSectionDescriptors = ( 17 | { 18 | items = (); 19 | "footer-title" = "Select which applications to load Reveal into."; 20 | }, 21 | { 22 | title = "User Applications"; 23 | predicate = "isSystemApplication = FALSE"; 24 | "icon-size" = 29; 25 | "suppress-hidden-apps" = 1; 26 | "cell-class-name" = ALSwitchCell; 27 | }, 28 | { 29 | title = "System Applications"; 30 | predicate = "isSystemApplication = TRUE AND NOT (displayIdentifier IN {'com.iptm.bigboss.sbsettings', 'com.booleanmagic.overboard', 'eu.heinelt.ifile'})"; 31 | "icon-size" = 29; 32 | "suppress-hidden-apps" = 1; 33 | "cell-class-name" = ALSwitchCell; 34 | }, 35 | ); 36 | }, 37 | { 38 | cell = PSGroupCell; 39 | footerText = "This tweak is not officially supported. For more information about Reveal.app and runtime debugging see http://revealapp.com"; 40 | }, 41 | { 42 | cell = PSGroupCell; 43 | footerText = "\nRHRevealLoader\n\nCopyright (c) 2014 Richard Heard. All rights reserved.\n \nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n"; 44 | }, 45 | ); 46 | }; 47 | } -------------------------------------------------------------------------------- /layout/Library/PreferenceLoader/Preferences/reveal-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heardrwt/RevealLoader/d422e26bc92749634547d520651710bce6744f7e/layout/Library/PreferenceLoader/Preferences/reveal-logo.png -------------------------------------------------------------------------------- /layout/Library/PreferenceLoader/Preferences/reveal-logo@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heardrwt/RevealLoader/d422e26bc92749634547d520651710bce6744f7e/layout/Library/PreferenceLoader/Preferences/reveal-logo@2x.png -------------------------------------------------------------------------------- /publish.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | scp -r $(< .theos/last_package) heardrwt@ssh.rheard.com:~/domains/rheard.com/cydia/debs/ 5 | 6 | #rebuild remote 7 | echo 'cd ~/domains/rheard.com/cydia/ && apt-ftparchive packages debs | bzip2 -c > Packages.bz2' | ssh heardrwt@ssh.rheard.com /bin/bash 8 | echo 'cd ~/domains/rheard.com/cydia/ && apt-ftparchive packages debs | gzip -c > Packages.gz' | ssh heardrwt@ssh.rheard.com /bin/bash 9 | 10 | -------------------------------------------------------------------------------- /release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | make clean 5 | make 6 | make package 7 | 8 | brew install dpkg 9 | 10 | cd releases 11 | 12 | dpkg-scanpackages debs | bzip2 -c > Packages.bz2 13 | dpkg-scanpackages debs | gzip -c > Packages.gz 14 | 15 | -------------------------------------------------------------------------------- /releases/Packages.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heardrwt/RevealLoader/d422e26bc92749634547d520651710bce6744f7e/releases/Packages.bz2 -------------------------------------------------------------------------------- /releases/Packages.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heardrwt/RevealLoader/d422e26bc92749634547d520651710bce6744f7e/releases/Packages.gz -------------------------------------------------------------------------------- /releases/Release: -------------------------------------------------------------------------------- 1 | Origin: rheard.com/cydia 2 | Label: rheard.com/cydia 3 | Suite: stable 4 | Version: 1.0 5 | Codename: rheard-com-cydia 6 | Architectures: iphoneos-arm 7 | Components: main 8 | Description: rheard.com/cydia 9 | -------------------------------------------------------------------------------- /releases/debs/com.rheard.reveal-loader_1.0.0-1_iphoneos-arm.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heardrwt/RevealLoader/d422e26bc92749634547d520651710bce6744f7e/releases/debs/com.rheard.reveal-loader_1.0.0-1_iphoneos-arm.deb -------------------------------------------------------------------------------- /ssh-askpass: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Script: ssh-askpass 3 | # Author: Mark Carver 4 | # Created: 2011-09-14 5 | # Licensed under GPL 3.0 6 | 7 | # A ssh-askpass command for Mac OS X 8 | # Based from author: Joseph Mocker, Sun Microsystems 9 | # http://blogs.oracle.com/mock/entry/and_now_chicken_of_the 10 | 11 | # To use this script: 12 | # Install this script running INSTALL as root 13 | # 14 | # If you plan on manually installing this script, please note that you will have 15 | # to set the following variable for SSH to recognize where the script is located: 16 | # export SSH_ASKPASS="/path/to/ssh-askpass" 17 | 18 | TITLE="${SSH_ASKPASS_TITLE:-SSH}"; 19 | TEXT="$(whoami)'s password:"; 20 | IFS=$(printf "\n"); 21 | CODE=("on GetCurrentApp()"); 22 | CODE=(${CODE[*]} "tell application \"System Events\" to get short name of first process whose frontmost is true"); 23 | CODE=(${CODE[*]} "end GetCurrentApp"); 24 | CODE=(${CODE[*]} "tell application GetCurrentApp()"); 25 | CODE=(${CODE[*]} "activate"); 26 | CODE=(${CODE[*]} "display dialog \"${@:-$TEXT}\" default answer \"\" with title \"${TITLE}\" with icon caution with hidden answer"); 27 | CODE=(${CODE[*]} "text returned of result"); 28 | CODE=(${CODE[*]} "end tell"); 29 | SCRIPT="/usr/bin/osascript" 30 | for LINE in ${CODE[*]}; do 31 | SCRIPT="${SCRIPT} -e $(printf "%q" "${LINE}")"; 32 | done; 33 | eval "${SCRIPT}"; 34 | -------------------------------------------------------------------------------- /theos/.bootstrap: -------------------------------------------------------------------------------- 1 | 2 -------------------------------------------------------------------------------- /theos/LICENSE: -------------------------------------------------------------------------------- 1 | Theos (and by extension, Logos) is available under the provisions of the GNU 2 | General Public License, version 3 (or later), available here: 3 | http://www.gnu.org/licenses/gpl-3.0.html. 4 | 5 | Projects created using Theos and/or Logos are not considered derivative works 6 | (from a licensing standpoint, or, for that matter, any other standpoint) and 7 | are, as such, not required to be licensed under the GNU GPL. 8 | 9 | The included project templates are license-free. The use of a template does 10 | not confer a license to your project. 11 | -------------------------------------------------------------------------------- /theos/Prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #if TARGET_IPHONE || TARGET_IPHONE_SIMULATOR 4 | #import 5 | #endif 6 | 7 | #define CLASS(cls) objc_getClass(#cls) 8 | 9 | #ifdef DEBUG 10 | #define __DEBUG__ 11 | #endif 12 | 13 | #ifdef __DEBUG__ 14 | #define CMLog(format, ...) NSLog(@"(%s) in [%s:%d] ::: %@", __PRETTY_FUNCTION__, __FILE__, __LINE__, [NSString stringWithFormat:format, ## __VA_ARGS__]) 15 | #define MARK CMLog(@"%s", __PRETTY_FUNCTION__); 16 | #define START_TIMER NSTimeInterval start = [NSDate timeIntervalSinceReferenceDate]; 17 | #define END_TIMER(msg) NSTimeInterval stop = [NSDate timeIntervalSinceReferenceDate]; CMLog([NSString stringWithFormat:@"%@ Time = %f", msg, stop-start]) 18 | #else 19 | #define CMLog(format, ...) 20 | #define MARK 21 | #define START_TIMER 22 | #define END_TIMER(msg) 23 | //#define NSLog(...) 24 | #endif 25 | 26 | #define NB [NSBundle mainBundle] 27 | #define UD [NSUserDefaults standardUserDefaults] 28 | #define FM [NSFileManager defaultManager] 29 | #endif 30 | -------------------------------------------------------------------------------- /theos/bin/bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | bootstrap_version=2 3 | 4 | ARGV0=$0 5 | [[ -z "$THEOS" ]] && THEOS=$(cd $(dirname $0); cd ..; pwd) 6 | THEOSDIR="$THEOS" 7 | 8 | function makeSubstrateStub() { 9 | PROJECTDIR=$(mktemp -d /tmp/theos.XXXXXX) 10 | cd $PROJECTDIR 11 | ln -s "$THEOSDIR" theos 12 | 13 | cat > Makefile << __EOF 14 | override TARGET_CODESIGN:= 15 | ifneq (\$(target),native) 16 | override ARCHS=arm 17 | endif 18 | 19 | include theos/makefiles/common.mk 20 | FRAMEWORK_NAME = CydiaSubstrate 21 | CydiaSubstrate_FILES = Hooker.cc 22 | CydiaSubstrate_INSTALL_PATH = /Library/Frameworks 23 | CydiaSubstrate_LDFLAGS = -dynamiclib -install_name /Library/Frameworks/CydiaSubstrate.framework/CydiaSubstrate 24 | ifeq (\$(THEOS_CURRENT_INSTANCE),CydiaSubstrate) 25 | override AUXILIARY_LDFLAGS:= 26 | endif 27 | LIBRARY_NAME = libsubstrate 28 | libsubstrate_FILES = Hooker.cc 29 | libsubstrate_INSTALL_PATH = /usr/lib 30 | ifeq (\$(THEOS_PLATFORM_NAME),macosx) 31 | libsubstrate_LDFLAGS = -Wl,-allow_sub_type_mismatches 32 | endif 33 | include \$(THEOS_MAKE_PATH)/framework.mk 34 | include \$(THEOS_MAKE_PATH)/library.mk 35 | 36 | after-libsubstrate-all:: 37 | @\$(TARGET_STRIP) -x -c \$(THEOS_OBJ_DIR)/libsubstrate.dylib 38 | @mkdir -p \$(THEOS_PROJECT_DIR)/_out 39 | @cp \$(THEOS_OBJ_DIR)/libsubstrate.dylib \$(THEOS_PROJECT_DIR)/_out/libsubstrate.dylib 40 | 41 | after-CydiaSubstrate-all:: 42 | @\$(TARGET_STRIP) -x -c \$(THEOS_SHARED_BUNDLE_BINARY_PATH)/CydiaSubstrate 43 | @mkdir -p \$(THEOS_PROJECT_DIR)/_out 44 | @cp \$(THEOS_SHARED_BUNDLE_BINARY_PATH)/CydiaSubstrate \$(THEOS_PROJECT_DIR)/_out/CydiaSubstrate 45 | __EOF 46 | 47 | cat > Hooker.cc << __EOF 48 | typedef void *id; 49 | typedef void *SEL; 50 | typedef void *Class; 51 | typedef id (*IMP)(id, SEL); 52 | 53 | bool MSDebug = false; 54 | extern "C" { 55 | typedef const void *MSImageRef; 56 | void MSHookFunction(void *symbol, void *replace, void **result) { }; 57 | void *MSFindSymbol(const void *image, const char *name) { return (void*)0; } 58 | MSImageRef MSGetImageByName(const char *file) { return (MSImageRef)0; } 59 | 60 | #ifdef __APPLE__ 61 | #ifdef __arm__ 62 | IMP MSHookMessage(Class _class, SEL sel, IMP imp, const char *prefix = (char *)0) { return (IMP)0; } 63 | #endif 64 | void MSHookMessageEx(Class _class, SEL sel, IMP imp, IMP *result) { } 65 | #endif 66 | } 67 | __EOF 68 | 69 | unset MAKE MAKELEVEL 70 | unset TARGET_CC TARGET_CXX TARGET_LD TARGET_STRIP TARGET_CODESIGN_ALLOCATE TARGET_CODESIGN TARGET_CODESIGN_FLAGS 71 | unset THEOS_BUILD_DIR THEOS_OBJ_DIR THEOS_OBJ_DIR_NAME 72 | unset THEOS_PROJECT_DIR 73 | echo -n " Compiling iPhoneOS CydiaSubstrate stub..." 74 | ( echo -n " default target?"; make libsubstrate target=iphone &> /dev/null; ) || 75 | echo -n " failed, what?" 76 | echo 77 | 78 | if [[ "$(uname -s)" == "Darwin" && "$(uname -p)" != "arm" ]]; then 79 | echo " Compiling native CydiaSubstrate stub..." 80 | make CydiaSubstrate target=native > /dev/null 81 | fi 82 | 83 | files=(_out/*) 84 | if [[ ${#files[*]} -eq 0 ]]; then 85 | echo "I didn't actually end up with a file here... I should probably bail out." 86 | exit 1 87 | elif [[ ${#files[*]} -eq 1 ]]; then 88 | cp _out/* libsubstrate.dylib 89 | else 90 | lipo _out/* -create -output libsubstrate.dylib 91 | fi 92 | 93 | cp libsubstrate.dylib "$THEOSDIR/lib/libsubstrate.dylib" 94 | 95 | cd "$THEOSDIR" 96 | rm -rf $PROJECTDIR 97 | } 98 | 99 | function copySystemSubstrate() { 100 | if [[ -f "/Library/Frameworks/CydiaSubstrate.framework/CydiaSubstrate" ]]; then 101 | echo " Copying system CydiaSybstrate..." 102 | cp "/Library/Frameworks/CydiaSubstrate.framework/CydiaSubstrate" "$THEOSDIR/lib/libsubstrate.dylib" 103 | return 0 104 | else 105 | return 1 106 | fi 107 | } 108 | 109 | function makeSubstrateHeader() { 110 | echo " Generating substrate.h header..." 111 | cat > "$THEOSDIR/include/substrate.h" << __EOF 112 | #include 113 | #include 114 | #include 115 | #ifdef __cplusplus 116 | #define _default(x) = x 117 | extern "C" { 118 | #else 119 | #define _default(x) 120 | #endif 121 | typedef const void *MSImageRef; 122 | void MSHookFunction(void *symbol, void *replace, void **result); 123 | void *MSFindSymbol(const void *image, const char *name); 124 | MSImageRef MSGetImageByName(const char *file); 125 | 126 | #ifdef __APPLE__ 127 | #ifdef __arm__ 128 | IMP MSHookMessage(Class _class, SEL sel, IMP imp, const char *prefix _default(NULL)); 129 | #endif 130 | void MSHookMessageEx(Class _class, SEL sel, IMP imp, IMP *result); 131 | #endif 132 | #ifdef __cplusplus 133 | } 134 | #endif 135 | __EOF 136 | } 137 | 138 | function copySystemSubstrateHeader() { 139 | if [[ -f "/Library/Frameworks/CydiaSubstrate.framework/Headers/CydiaSubstrate.h" ]]; then 140 | echo " Copying system CydiaSubstrate header..." 141 | cp "/Library/Frameworks/CydiaSubstrate.framework/Headers/CydiaSubstrate.h" "$THEOSDIR/include/substrate.h" 142 | return 0 143 | else 144 | return 1 145 | fi 146 | } 147 | 148 | function checkWritability() { 149 | if ! touch "$THEOSDIR/.perm" &> /dev/null; then 150 | retval=1 151 | return 1 152 | fi 153 | rm "$THEOSDIR/.perm" &> /dev/null 154 | return 0 155 | } 156 | 157 | function getCurrentBootstrapVersion { 158 | v=1 159 | if [[ -f "$THEOSDIR/.bootstrap" ]]; then 160 | v=$(< "$THEOSDIR/.bootstrap") 161 | fi 162 | echo -n "$v" 163 | } 164 | 165 | function bootstrapSubstrate { 166 | [ -f "$THEOSDIR/lib/libsubstrate.dylib" ] || copySystemSubstrate || makeSubstrateStub 167 | [ -f "$THEOSDIR/include/substrate.h" ] || copySystemSubstrateHeader || makeSubstrateHeader 168 | echo -n "$bootstrap_version" > "$THEOSDIR/.bootstrap" 169 | } 170 | 171 | if ! checkWritability; then 172 | echo "$THEOSDIR is not writable. Please run \`$ARGV0 $@\` manually, with privileges." 1>&2 173 | exit 1 174 | fi 175 | 176 | # The use of 'p' denotes a query. 177 | # http://en.wikipedia.org/wiki/P_convention 178 | 179 | if [[ "$1" == "substrate" ]]; then 180 | echo "Bootstrapping CydiaSubstrate..." 181 | bootstrapSubstrate 182 | elif [[ "$1" == "version-p" ]]; then 183 | echo -n $(getCurrentBootstrapVersion) 184 | elif [[ "$1" == "newversion-p" ]]; then 185 | echo -n "$bootstrap_version" 186 | elif [[ "$1" == "update-p" ]]; then 187 | test $(getCurrentBootstrapVersion) -lt $bootstrap_version; exit $? 188 | #elif [[ "$1" == "update" ]]; then 189 | #echo "Updating CydiaSubstrate..." 190 | #bootstrapSubstrate 191 | fi 192 | -------------------------------------------------------------------------------- /theos/bin/deb_build_num.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | GETONLY=0 3 | if [[ $1 == "-g" ]]; then 4 | GETONLY=1 5 | shift 6 | fi 7 | 8 | if [[ $# -lt 2 ]]; then 9 | echo "Syntax: $0 [-g] packagename versionname" >&2 10 | exit 1 11 | fi 12 | 13 | if [[ ! -d $TOP_DIR/.debmake ]]; then 14 | mkdir $TOP_DIR/.debmake 15 | fi 16 | 17 | PACKAGE=$1 18 | VERSION=$2 19 | INFOFILE=$TOP_DIR/.debmake/$PACKAGE-$VERSION 20 | if [[ ! -e $INFOFILE ]]; then 21 | echo -n 1 > $INFOFILE 22 | echo -n 1 23 | exit 0 24 | else 25 | CURNUM=$(cat $INFOFILE) 26 | if [[ $GETONLY -eq 0 ]]; then 27 | let CURNUM++ 28 | echo -n $CURNUM > $INFOFILE 29 | fi 30 | echo $CURNUM 31 | fi 32 | -------------------------------------------------------------------------------- /theos/bin/denicify.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use warnings; 4 | use FindBin; 5 | use lib "$FindBin::Bin/lib"; 6 | 7 | use Module::Load::Conditional 'can_load'; 8 | 9 | $nicfile = $ARGV[0] if($ARGV[0]); 10 | $outputdir = $ARGV[1]; 11 | if(!$nicfile || !$outputdir) { 12 | exitWithError("Syntax: $0 nicfile outputdir"); 13 | } 14 | 15 | ### LOAD THE NICFILE! ### 16 | open(my $nichandle, "<", $nicfile); 17 | my $line = <$nichandle>; 18 | my $nicversion = 1; 19 | if($line =~ /^nic (\w+)$/) { 20 | $nicversion = $1; 21 | } 22 | seek($nichandle, 0, 0); 23 | 24 | my $NICPackage = "NIC$nicversion"; 25 | exitWithError("I don't understand NIC version $nicversion!") if(!can_load(modules => {"NIC::Formats::$NICPackage" => undef})); 26 | my $NIC = "NIC::Formats::$NICPackage"->new(); 27 | $NIC->load($nichandle); 28 | $NIC->addConstraint("package"); 29 | close($nichandle); 30 | ### YAY! ### 31 | 32 | $NIC->build($outputdir); 33 | $NIC->dumpPreamble("pre.NIC"); 34 | 35 | sub exitWithError { 36 | my $error = shift; 37 | print STDERR "[error] ", $error, $/; 38 | exit 1; 39 | } 40 | -------------------------------------------------------------------------------- /theos/bin/dpkg-deb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use warnings; 4 | use File::Find; 5 | use File::Spec; 6 | use Cwd; 7 | use Getopt::Long; 8 | use Pod::Usage; 9 | use Archive::Tar; 10 | use IO::Compress::Gzip; 11 | use IO::Compress::Bzip2; 12 | 13 | package NIC::Archive::Tar::File; 14 | use parent "Archive::Tar::File"; 15 | sub new { 16 | my $class = shift; 17 | my $self = Archive::Tar::File->new(@_); 18 | bless($self, $class); 19 | return $self; 20 | } 21 | 22 | sub full_path { 23 | my $self = shift; 24 | my $full_path = $self->SUPER::full_path(); $full_path = '' unless defined $full_path; 25 | $full_path =~ s#^#./# if $full_path ne "" && $full_path ne "." && $full_path !~ m#^\./#; 26 | return $full_path; 27 | } 28 | 1; 29 | package main; 30 | 31 | our $VERSION = '2.0'; 32 | 33 | our $_PROGNAME = "dm.pl"; 34 | 35 | my $ADMINARCHIVENAME = "control.tar.gz"; 36 | my $DATAARCHIVENAME = "data.tar"; 37 | my $ARCHIVEVERSION = "2.0"; 38 | 39 | $Archive::Tar::DO_NOT_USE_PREFIX = 1; # use GNU extensions (not POSIX prefix) 40 | 41 | our $compression = "gzip"; 42 | Getopt::Long::Configure("bundling", "auto_version"); 43 | GetOptions('compression|Z=s' => \$compression, 44 | 'build|b' => sub { }, 45 | 'help|?' => sub { pod2usage(1); }, 46 | 'man' => sub { pod2usage(-exitstatus => 0, -verbose => 2); }) 47 | or pod2usage(2); 48 | 49 | pod2usage(1) if(@ARGV < 2); 50 | 51 | my $pwd = Cwd::cwd(); 52 | my $indir = File::Spec->rel2abs($ARGV[0]); 53 | my $outfile = $ARGV[1]; 54 | 55 | die "ERROR: '$indir' is not a directory or does not exist.\n" unless -d $indir; 56 | 57 | my $controldir = File::Spec->catpath("", $indir, "DEBIAN"); 58 | 59 | die "ERROR: control directory '$controldir' is not a directory or does not exist.\n" unless -d $controldir; 60 | my $mode = (lstat($controldir))[2]; 61 | die sprintf("ERROR: control directory has bad permissions %03lo (must be >=0755 and <=0775)\n", $mode & 07777) if(($mode & 07757) != 0755); 62 | 63 | my $controlfile = File::Spec->catfile($controldir, "control"); 64 | die "ERROR: control file '$controlfile' is not a plain file\n" unless -f $controlfile; 65 | my %control_data = read_control_file($controlfile); 66 | 67 | die "ERROR: package name has characters that aren't lowercase alphanums or '-+.'.\n" if($control_data{"package"} =~ m/[^a-z0-9+-.]/); 68 | die "ERROR: package version ".$control_data{"version"}." doesn't contain any digits.\n" if($control_data{"version"} !~ m/[0-9]/); 69 | 70 | foreach my $m ("preinst", "postinst", "prerm", "postrm", "extrainst_") { 71 | $_ = File::Spec->catfile($controldir, $m); 72 | next unless -e $_; 73 | die "ERROR: maintainer script '$m' is not a plain file or symlink\n" unless(-f $_ || -l $_); 74 | $mode = (lstat)[2]; 75 | die sprintf("ERROR: maintainer script '$m' has bad permissions %03lo (must be >=0555 and <=0775)\n", $mode & 07777) if(($mode & 07557) != 0555) 76 | } 77 | 78 | print "$_PROGNAME: building package `".$control_data{"package"}.":".$control_data{"architecture"}."' in `$outfile'\n"; 79 | 80 | open(my $ar, '>', $outfile) or die $!; 81 | 82 | print $ar "!\n"; 83 | print_ar_record($ar, "debian-binary", time, 0, 0, 0100644, 4); 84 | print_ar_file($ar, "$ARCHIVEVERSION\n", 4); 85 | 86 | { 87 | my $tar = Archive::Tar->new(); 88 | $tar->add_files(tar_filelist($controldir)); 89 | my $comp; 90 | my $zFd = IO::Compress::Gzip->new(\$comp, -Level => 9); 91 | $tar->write($zFd); 92 | $zFd->close(); 93 | print_ar_record($ar, $ADMINARCHIVENAME, time, 0, 0, 0100644, length($comp)); 94 | print_ar_file($ar, $comp, length($comp)); 95 | } { 96 | my $tar = Archive::Tar->new(); 97 | $tar->add_files(tar_filelist($indir)); 98 | my $comp; 99 | my $zFd = compressed_fd(\$comp); 100 | $tar->write($zFd); 101 | $zFd->close(); 102 | print_ar_record($ar, compressed_filename($DATAARCHIVENAME), time, 0, 0, 0100644, length($comp)); 103 | print_ar_file($ar, $comp, length($comp)); 104 | } 105 | 106 | close $ar; 107 | 108 | sub print_ar_record { 109 | my ($fh, $filename, $timestamp, $uid, $gid, $mode, $size) = @_; 110 | printf $fh "%-16s%-12lu%-6lu%-6lu%-8lo%-10ld`\n", $filename, $timestamp, $uid, $gid, $mode, $size; 111 | $fh->flush(); 112 | } 113 | 114 | sub print_ar_file { 115 | my ($fh, $data, $size) = @_; 116 | syswrite $fh, $data; 117 | print $fh "\n" if($size % 2 == 1); 118 | $fh->flush(); 119 | } 120 | 121 | sub tar_filelist { 122 | chdir(shift); 123 | my @filelist; 124 | my @symlinks; 125 | 126 | find({wanted => sub { 127 | return if m#^./DEBIAN#; 128 | my $tf = NIC::Archive::Tar::File->new(file=>$_); 129 | push @symlinks, $tf if -l; 130 | push @filelist, $tf if ! -l; 131 | }, no_chdir => 1}, "."); 132 | return (@filelist, @symlinks); 133 | } 134 | 135 | sub read_control_file { 136 | my $filename = shift; 137 | open(my $fh, '<', $filename) or die "ERROR: can't open control file '$filename'\n"; 138 | my %data; 139 | while(<$fh>) { 140 | if(m/^(.*?): (.*)/) { 141 | $data{lc($1)} = $2; 142 | } 143 | } 144 | close $fh; 145 | return %data; 146 | } 147 | 148 | sub compressed_fd { 149 | my $sref = shift; 150 | return IO::Compress::Gzip->new($sref, -Level => 9) if $::compression eq "gzip"; 151 | return IO::Compress::Bzip2->new($sref) if $::compression eq "bzip2"; 152 | open my $fh, ">", $sref; 153 | return $fh; 154 | } 155 | 156 | sub compressed_filename { 157 | my $fn = shift; 158 | my $suffix = ""; 159 | $suffix = ".gz" if $::compression eq "gzip"; 160 | $suffix = ".bz2" if $::compression eq "bzip2"; 161 | return $fn.$suffix; 162 | } 163 | 164 | __END__ 165 | 166 | =head1 NAME 167 | 168 | dm.pl 169 | 170 | =head1 SYNOPSIS 171 | 172 | dm.pl [options] 173 | 174 | =head1 OPTIONS 175 | 176 | =over 8 177 | 178 | =item B<-b> 179 | 180 | This option exists solely for compatibility with dpkg-deb. 181 | 182 | =item B<-ZEcompressionE> 183 | 184 | Specify the package compression type. Valid values are gzip (default), bzip2 and cat (no compression.) 185 | 186 | =item B<--help>, B<-?> 187 | 188 | Print a brief help message and exit. 189 | 190 | =item B<--man> 191 | 192 | Print a manual page and exit. 193 | 194 | =back 195 | 196 | =head1 DESCRIPTION 197 | 198 | B creates Debian software packages (.deb files) and is a drop-in replacement for dpkg-deb. 199 | 200 | =cut 201 | -------------------------------------------------------------------------------- /theos/bin/fakeroot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | required=0 3 | persistence=/tmp/dhbxxx 4 | 5 | while getopts ":p:rc" flag; do 6 | case "$flag" in 7 | :) echo "$0: Option -$OPTARG requires an argument." 1>&2 8 | exit 1 9 | ;; 10 | \?) echo "$0: Option -$OPTARG unrecognized." 1>&2 11 | exit 1 12 | ;; 13 | p) persistence="$OPTARG" ;; 14 | r) required=1 ;; 15 | c) delpersistence=1 ;; 16 | esac 17 | done 18 | shift $((OPTIND-1)) 19 | cmd=$* 20 | 21 | mkdir -p $(dirname $persistence) 22 | touch $persistence 23 | 24 | if [[ $delpersistence -eq 1 ]]; then 25 | rm -f $persistence 26 | exit 0 27 | fi 28 | 29 | if [[ "$USER" == "root" ]]; then 30 | fakeroot="" 31 | elif type fauxsu &> /dev/null; then 32 | fakeroot="fauxsu -p $persistence -- " 33 | elif type fakeroot-ng &> /dev/null; then 34 | fakeroot="fakeroot-ng -p $persistence -- " 35 | elif type fakeroot &> /dev/null; then 36 | fakeroot="fakeroot -i $persistence -s $persistence -- " 37 | else 38 | if [[ $required -eq 1 ]]; then 39 | fakeroot="" 40 | else 41 | fakeroot=": " 42 | fi 43 | fi 44 | 45 | #echo $fakeroot $cmd 46 | $fakeroot $cmd 47 | -------------------------------------------------------------------------------- /theos/bin/install.copyFile: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [[ TARGET_INSTALL_REMOTE -eq 1 ]]; then 3 | scp -P $THEOS_DEVICE_PORT "$1" root@$THEOS_DEVICE_IP:$2 4 | else 5 | cp "$1" "$2" 6 | fi 7 | -------------------------------------------------------------------------------- /theos/bin/install.exec: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [[ TARGET_INSTALL_REMOTE -eq 1 ]]; then 3 | exec ssh -p $THEOS_DEVICE_PORT root@$THEOS_DEVICE_IP "$@" 4 | else 5 | exec sh -c "$@" 6 | fi 7 | -------------------------------------------------------------------------------- /theos/bin/install.mergeDir: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd "$1" 3 | # Use fakeroot.sh to ensure that permissions are preserved, and install.exec to ensure that we are running tar -x on the right system. 4 | fakeroot.sh -r tar -c . | install.exec "tar -x -C \"$2\"" 5 | -------------------------------------------------------------------------------- /theos/bin/ldid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heardrwt/RevealLoader/d422e26bc92749634547d520651710bce6744f7e/theos/bin/ldid -------------------------------------------------------------------------------- /theos/bin/lib/Logos/Class.pm: -------------------------------------------------------------------------------- 1 | package Logos::Class; 2 | use strict; 3 | 4 | sub new { 5 | my $proto = shift; 6 | my $class = ref($proto) || $proto; 7 | my $self = {}; 8 | $self->{NAME} = undef; 9 | $self->{EXPR} = undef; 10 | $self->{METAEXPR} = undef; 11 | $self->{TYPE} = undef; 12 | $self->{META} = 0; 13 | $self->{INST} = 0; 14 | $self->{OVERRIDDEN} = 0; 15 | $self->{REQUIRED} = 0; 16 | $self->{METHODS} = []; 17 | $self->{NUM_METHODS} = 0; 18 | $self->{GROUP} = undef; 19 | bless($self, $class); 20 | return $self; 21 | } 22 | 23 | ##################### # 24 | # Setters and Getters # 25 | # ##################### 26 | sub name { 27 | my $self = shift; 28 | if(@_) { $self->{NAME} = shift; } 29 | return $self->{NAME}; 30 | } 31 | 32 | sub expression { 33 | my $self = shift; 34 | if(@_) { 35 | $self->{EXPR} = shift; 36 | $self->type("id"); 37 | $self->{OVERRIDDEN} = 1; 38 | } 39 | return $self->{EXPR}; 40 | } 41 | 42 | sub metaexpression { 43 | my $self = shift; 44 | if(@_) { 45 | $self->{METAEXPR} = shift; 46 | $self->{OVERRIDDEN} = 1; 47 | } 48 | return $self->{METAEXPR}; 49 | } 50 | 51 | sub type { 52 | my $self = shift; 53 | if(@_) { $self->{TYPE} = shift; } 54 | return $self->{TYPE} if $self->{TYPE}; 55 | return $self->{NAME}."*"; 56 | } 57 | 58 | sub hasmetahooks { 59 | my $self = shift; 60 | if(@_) { $self->{META} = shift; } 61 | return $self->{META}; 62 | } 63 | 64 | sub hasinstancehooks { 65 | my $self = shift; 66 | if(@_) { $self->{INST} = shift; } 67 | return $self->{INST}; 68 | } 69 | 70 | sub group { 71 | my $self = shift; 72 | if(@_) { $self->{GROUP} = shift; } 73 | return $self->{GROUP}; 74 | } 75 | 76 | sub required { 77 | my $self = shift; 78 | if(@_) { $self->{REQUIRED} = shift; } 79 | return $self->{REQUIRED}; 80 | } 81 | 82 | sub overridden { 83 | my $self = shift; 84 | return $self->{OVERRIDDEN}; 85 | } 86 | 87 | sub methods { 88 | my $self = shift; 89 | return $self->{METHODS}; 90 | } 91 | 92 | sub initRequired { 93 | my $self = shift; 94 | return $self->required || scalar @{$self->{METHODS}} > 0; 95 | } 96 | 97 | ##### # 98 | # END # 99 | # ##### 100 | 101 | sub addMethod { 102 | my $self = shift; 103 | my $hook = shift; 104 | push(@{$self->{METHODS}}, $hook); 105 | $self->{NUM_METHODS}++; 106 | } 107 | 108 | 1; 109 | -------------------------------------------------------------------------------- /theos/bin/lib/Logos/Generator.pm: -------------------------------------------------------------------------------- 1 | package Logos::Generator; 2 | use strict; 3 | use Logos::Generator::Thunk; 4 | use Scalar::Util qw(blessed); 5 | use Module::Load::Conditional qw(can_load); 6 | $Module::Load::Conditional::VERBOSE = 1; 7 | our $GeneratorPackage = ""; 8 | 9 | my %cache; 10 | 11 | sub for { 12 | my $object = shift; 13 | my $dequalified = undef; 14 | my $cachekey; 15 | if(defined $object) { 16 | $cachekey = $object; 17 | my $class = blessed($object); 18 | ($dequalified = $class) =~ s/.*::// if defined $class 19 | } 20 | $cachekey = "-" if !$cachekey; 21 | $dequalified .= "Generator" if !defined $dequalified; 22 | return $cache{$cachekey} if $cache{$cachekey}; 23 | 24 | my $qualified = $GeneratorPackage."::".$dequalified; 25 | my $fallback = "Logos::Generator::Base::".$dequalified; 26 | 27 | my $shouldFallBack = 0; 28 | can_load(modules=>{$qualified=>undef},verbose=>0) || ($shouldFallBack = 1); 29 | can_load(modules=>{$fallback=>undef},verbose=>1) if $shouldFallBack; 30 | 31 | my $thunk = Logos::Generator::Thunk->for(($shouldFallBack ? $fallback : $qualified), $object); 32 | $cache{$cachekey} = $thunk; 33 | return $thunk; 34 | } 35 | 36 | sub use { 37 | my $generatorName = shift; 38 | if($generatorName =~ /^(\w+)@(.+)$/) { 39 | $generatorName = $1; 40 | unshift @INC, $2; 41 | } 42 | $GeneratorPackage = "Logos::Generator::".$generatorName; 43 | ::fileError(-1, "I can't find the $generatorName Generator!") if(!can_load(modules => { 44 | $GeneratorPackage."::Generator" => undef 45 | })); 46 | } 47 | 48 | 1; 49 | -------------------------------------------------------------------------------- /theos/bin/lib/Logos/Generator/Base/Class.pm: -------------------------------------------------------------------------------- 1 | package Logos::Generator::Base::Class; 2 | use Logos::Generator; 3 | use strict; 4 | 5 | sub _initExpression { 6 | my $self = shift; 7 | my $class = shift; 8 | return $class->expression if $class->expression; 9 | return "objc_getClass(\"".$class->name."\")"; 10 | } 11 | 12 | sub _metaInitExpression { 13 | my $self = shift; 14 | my $class = shift; 15 | return $class->metaexpression if $class->metaexpression; 16 | return "object_getClass(".$self->variable($class).")"; 17 | } 18 | 19 | 20 | sub variable { 21 | my $self = shift; 22 | my $class = shift; 23 | return Logos::sigil("class").$class->group->name."\$".$class->name; 24 | } 25 | 26 | sub metaVariable { 27 | my $self = shift; 28 | my $class = shift; 29 | return Logos::sigil("metaclass").$class->group->name."\$".$class->name; 30 | } 31 | 32 | sub declarations { 33 | my $self = shift; 34 | my $class = shift; 35 | my $return = ""; 36 | for(@{$class->methods}) { 37 | $return .= Logos::Generator::for($_)->declarations; 38 | } 39 | return $return; 40 | } 41 | 42 | sub initializers { 43 | my $self = shift; 44 | my $class = shift; 45 | my $return = ""; 46 | for(@{$class->methods}) { 47 | $return .= Logos::Generator::for($_)->initializers; 48 | } 49 | return $return; 50 | } 51 | 52 | 1; 53 | -------------------------------------------------------------------------------- /theos/bin/lib/Logos/Generator/Base/Generator.pm: -------------------------------------------------------------------------------- 1 | package Logos::Generator::Base::Generator; 2 | use strict; 3 | 4 | sub findPreamble { 5 | my $self = shift; 6 | my $aref = shift; 7 | my @matches = grep(/\s*#\s*(import|include)\s*[<"]logos\/logos\.h[">]/, @$aref); 8 | return @matches > 0; 9 | } 10 | 11 | sub preamble { 12 | return "#include "; 13 | } 14 | 15 | sub generateClassList { 16 | my $self = shift; 17 | my $return = ""; 18 | map $return .= "\@class $_; ", @_; 19 | return $return; 20 | } 21 | 22 | sub classReferenceWithScope { 23 | my $self = shift; 24 | my $classname = shift; 25 | my $scope = shift; 26 | my $prefix = Logos::sigil($scope eq "+" ? "static_metaclass_lookup" : "static_class_lookup"); 27 | return $prefix.$classname."()"; 28 | } 29 | 30 | 1; 31 | -------------------------------------------------------------------------------- /theos/bin/lib/Logos/Generator/Base/Group.pm: -------------------------------------------------------------------------------- 1 | package Logos::Generator::Base::Group; 2 | use strict; 3 | 4 | sub declarations { 5 | my $self = shift; 6 | my $group = shift; 7 | my $return = ""; 8 | foreach(@{$group->classes}) { 9 | $return .= Logos::Generator::for($_)->declarations if $_->initRequired; 10 | } 11 | return $return; 12 | } 13 | 14 | sub initializers { 15 | my $self = shift; 16 | my $group = shift; 17 | my $return = "{"; 18 | foreach(@{$group->classes}) { 19 | $return .= Logos::Generator::for($_)->initializers if $_->initRequired; 20 | } 21 | $return .= "}"; 22 | return $return; 23 | } 24 | 25 | 1; 26 | -------------------------------------------------------------------------------- /theos/bin/lib/Logos/Generator/Base/Method.pm: -------------------------------------------------------------------------------- 1 | package Logos::Generator::Base::Method; 2 | use strict; 3 | use Logos::Util; 4 | 5 | sub originalFunctionName { 6 | my $self = shift; 7 | my $method = shift; 8 | return Logos::sigil(($method->scope eq "+" ? "meta_" : "")."orig").$method->groupIdentifier."\$".$method->class->name."\$".$method->_new_selector; 9 | } 10 | 11 | sub newFunctionName { 12 | my $self = shift; 13 | my $method = shift; 14 | return Logos::sigil(($method->scope eq "+" ? "meta_" : "")."method").$method->groupIdentifier."\$".$method->class->name."\$".$method->_new_selector; 15 | } 16 | 17 | sub definition { 18 | ::fileError(-1, "generator does not implement Method::definition"); 19 | } 20 | 21 | sub originalCall { 22 | ::fileError(-1, "generator does not implement Method::originalCall"); 23 | } 24 | 25 | sub buildLogCall { 26 | my $self = shift; 27 | my $method = shift; 28 | my $args = shift; 29 | # Log preamble 30 | my $build = "NSLog(\@\"".$method->scope."[<".$method->class->name.": %p>"; 31 | my $argnamelist = ""; 32 | if($method->numArgs > 0) { 33 | # For each argument, add its keyword and a format char to the log string. 34 | map $build .= " ".$method->selectorParts->[$_].":".Logos::Method::formatCharForArgType($method->argtypes->[$_]), (0..$method->numArgs - 1); 35 | # This builds a list of args by making sure the format char isn't -- (or, what we're using for non-operational types) 36 | # Map (in list context) "format char == -- ? nothing : arg name" over the indices of the arg list. 37 | my @newarglist = map(Logos::Method::printArgForArgType($method->argtypes->[$_], $method->argnames->[$_]), (0..$method->numArgs - 1)); 38 | my @existingargs = grep(defined($_), @newarglist); 39 | if(scalar(@existingargs) > 0) { 40 | $argnamelist = ", ".join(", ", grep(defined($_), @existingargs)); 41 | } 42 | } else { 43 | # Space and then the only keyword in the selector. 44 | $build .= " ".$method->selector; 45 | } 46 | 47 | my @extraFormatSpecifiers; 48 | my @extraArguments; 49 | for(Logos::Util::smartSplit(qr/\s*,\s*/, $args)) { 50 | my ($popen, $pclose) = matchedParenthesisSet($_); 51 | my $type = "id"; 52 | if(defined $popen) { 53 | $type = substr($_, $popen, $pclose-$popen-1); 54 | } 55 | push(@extraFormatSpecifiers, Logos::Method::formatCharForArgType($type)); 56 | my $n = Logos::Method::printArgForArgType($type, "($_)"); 57 | push(@extraArguments, $n) if $n; 58 | } 59 | 60 | # Log postamble 61 | $build .= "]"; 62 | $build .= ": ".join(", ", @extraFormatSpecifiers) if @extraFormatSpecifiers > 0; 63 | $build .= "\", self".$argnamelist; 64 | $build .= ", ".join(", ", @extraArguments) if @extraArguments > 0; 65 | $build .= ")"; 66 | } 67 | 68 | sub declarations { 69 | ::fileError(-1, "generator does not implement Method::declarations"); 70 | } 71 | 72 | sub initializers { 73 | ::fileError(-1, "generator does not implement Method::initializers"); 74 | } 75 | 76 | 1; 77 | -------------------------------------------------------------------------------- /theos/bin/lib/Logos/Generator/Base/StaticClassGroup.pm: -------------------------------------------------------------------------------- 1 | package Logos::Generator::Base::StaticClassGroup; 2 | use strict; 3 | 4 | sub _methodForClassWithScope { 5 | my $self = shift; 6 | my $class = shift; 7 | my $scope = shift; 8 | my $return = ""; 9 | my $methodname = Logos::sigil($scope eq "+" ? "static_metaclass_lookup" : "static_class_lookup").$class; 10 | my $lookupMethod = $scope eq "+" ? "objc_getMetaClass" : "objc_getClass"; 11 | 12 | # This is a dirty assumption - we believe that we will always be using a compiler that defines __GNUC__ and respects GNU C attributes. 13 | return "static __inline__ __attribute__((always_inline)) Class ".$methodname."(void) { static Class _klass; if(!_klass) { _klass = ".$lookupMethod."(\"".$class."\"); } return _klass; }"; 14 | } 15 | 16 | sub declarations { 17 | my $self = shift; 18 | my $group = shift; 19 | my $return = ""; 20 | return "" if scalar(keys %{$group->usedMetaClasses}) + scalar(keys %{$group->usedClasses}) + scalar(keys %{$group->declaredOnlyClasses}) == 0; 21 | foreach(keys %{$group->usedMetaClasses}) { 22 | $return .= $self->_methodForClassWithScope($_, "+"); 23 | } 24 | foreach(keys %{$group->usedClasses}) { 25 | $return .= $self->_methodForClassWithScope($_, "-"); 26 | } 27 | return $return; 28 | } 29 | 30 | sub initializers { 31 | return ""; 32 | } 33 | 34 | 1; 35 | -------------------------------------------------------------------------------- /theos/bin/lib/Logos/Generator/Base/Subclass.pm: -------------------------------------------------------------------------------- 1 | package Logos::Generator::Base::Subclass; 2 | use strict; 3 | 4 | sub declarations { 5 | ::fileError(-1, "generator does not implement Subclass::declarations"); 6 | } 7 | 8 | sub initializers { 9 | ::fileError(-1, "generator does not implement Subclass::initializers"); 10 | } 11 | 12 | 1; 13 | -------------------------------------------------------------------------------- /theos/bin/lib/Logos/Generator/MobileSubstrate/Class.pm: -------------------------------------------------------------------------------- 1 | package Logos::Generator::MobileSubstrate::Class; 2 | use strict; 3 | use parent qw(Logos::Generator::Base::Class); 4 | 5 | sub initializers { 6 | my $self = shift; 7 | my $class = shift; 8 | my $return = ""; 9 | if($class->required || $class->overridden || $class->hasinstancehooks || $class->hasmetahooks) { 10 | $return .= "Class ".$self->variable($class)." = ".$self->_initExpression($class)."; "; 11 | } 12 | if($class->hasmetahooks) { 13 | $return .= "Class ".$self->metaVariable($class)." = ".$self->_metaInitExpression($class)."; "; 14 | } 15 | $return .= $self->SUPER::initializers($class); 16 | return $return; 17 | } 18 | 19 | 1; 20 | -------------------------------------------------------------------------------- /theos/bin/lib/Logos/Generator/MobileSubstrate/Generator.pm: -------------------------------------------------------------------------------- 1 | package Logos::Generator::MobileSubstrate::Generator; 2 | use strict; 3 | use parent qw(Logos::Generator::Base::Generator); 4 | 5 | sub findPreamble { 6 | my $self = shift; 7 | my $aref = shift; 8 | my @matches = grep(/\s*#\s*(import|include)\s*[<"]substrate\.h[">]/, @$aref); 9 | return $self->SUPER::findPreamble($aref) && @matches > 0; 10 | } 11 | 12 | sub preamble { 13 | my $self = shift; 14 | return join("\n", ($self->SUPER::preamble(), "#include ")); 15 | } 16 | 17 | 1; 18 | -------------------------------------------------------------------------------- /theos/bin/lib/Logos/Generator/MobileSubstrate/Method.pm: -------------------------------------------------------------------------------- 1 | package Logos::Generator::MobileSubstrate::Method; 2 | use strict; 3 | use parent qw(Logos::Generator::Base::Method); 4 | 5 | sub _originalMethodPointerDeclaration { 6 | my $self = shift; 7 | my $method = shift; 8 | if(!$method->isNew) { 9 | my $build = "static "; 10 | my $classargtype = $method->class->type; 11 | $classargtype = "Class" if $method->scope eq "+"; 12 | my $name = "(*".$self->originalFunctionName($method).")(".$classargtype.", SEL"; 13 | my $argtypelist = join(", ", @{$method->argtypes}); 14 | $name .= ", ".$argtypelist if $argtypelist; 15 | 16 | $name .= ")"; 17 | $build .= Logos::Method::declarationForTypeWithName($method->return, $name); 18 | return $build; 19 | } 20 | return undef; 21 | } 22 | 23 | sub _methodPrototype { 24 | my $self = shift; 25 | my $method = shift; 26 | my $includeArgNames = 0 || shift; 27 | my $build = "static "; 28 | my $classargtype = $method->class->type; 29 | $classargtype = "Class" if $method->scope eq "+"; 30 | my $arglist = ""; 31 | if($includeArgNames == 1) { 32 | map $arglist .= ", ".Logos::Method::declarationForTypeWithName($method->argtypes->[$_], $method->argnames->[$_]), (0..$method->numArgs - 1); 33 | } else { 34 | my $typelist = join(", ", @{$method->argtypes}); 35 | $arglist = ", ".$typelist if $typelist; 36 | } 37 | 38 | my $name = $self->newFunctionName($method)."(".$classargtype.($includeArgNames?" self":"").", SEL".($includeArgNames?" _cmd":"").$arglist.")"; 39 | $build .= Logos::Method::declarationForTypeWithName($method->return, $name); 40 | return $build; 41 | } 42 | 43 | sub definition { 44 | my $self = shift; 45 | my $method = shift; 46 | my $build = ""; 47 | $build .= $self->_methodPrototype($method, 1); 48 | return $build; 49 | } 50 | 51 | sub originalCall { 52 | my $self = shift; 53 | my $method = shift; 54 | my $customargs = shift; 55 | return "" if $method->isNew; 56 | 57 | my $build = $self->originalFunctionName($method)."(self, _cmd"; 58 | if(defined $customargs && $customargs ne "") { 59 | $build .= ", ".$customargs; 60 | } elsif($method->numArgs > 0) { 61 | $build .= ", ".join(", ",@{$method->argnames}); 62 | } 63 | $build .= ")"; 64 | return $build; 65 | } 66 | 67 | sub declarations { 68 | my $self = shift; 69 | my $method = shift; 70 | my $build = ""; 71 | my $orig = $self->_originalMethodPointerDeclaration($method); 72 | $build .= $orig."; " if $orig; 73 | $build .= $self->_methodPrototype($method)."; "; 74 | return $build; 75 | } 76 | 77 | sub initializers { 78 | my $self = shift; 79 | my $method = shift; 80 | my $cgen = Logos::Generator::for($method->class); 81 | my $classvar = ($method->scope eq "+" ? $cgen->metaVariable : $cgen->variable); 82 | if(!$method->isNew) { 83 | return "MSHookMessageEx(".$classvar.", \@selector(".$method->selector."), (IMP)&".$self->newFunctionName($method).", (IMP*)&".$self->originalFunctionName($method).");"; 84 | } else { 85 | my $r = ""; 86 | $r .= "{ "; 87 | if(!$method->type) { 88 | $r .= "char _typeEncoding[1024]; unsigned int i = 0; "; 89 | for ($method->return, "id", "SEL", @{$method->argtypes}) { 90 | my $typeEncoding = Logos::Method::typeEncodingForArgType($_); 91 | if(defined $typeEncoding) { 92 | my @typeEncodingBits = split(//, $typeEncoding); 93 | my $i = 0; 94 | for my $char (@typeEncodingBits) { 95 | $r .= "_typeEncoding[i".($i > 0 ? " + $i" : "")."] = '$char'; "; 96 | $i++; 97 | } 98 | $r .= "i += ".(scalar @typeEncodingBits)."; "; 99 | } else { 100 | $r .= "memcpy(_typeEncoding + i, \@encode($_), strlen(\@encode($_))); i += strlen(\@encode($_)); "; 101 | } 102 | } 103 | $r .= "_typeEncoding[i] = '\\0'; "; 104 | } else { 105 | $r .= "const char *_typeEncoding = \"".$method->type."\"; "; 106 | } 107 | $r .= "class_addMethod(".$classvar.", \@selector(".$method->selector."), (IMP)&".$self->newFunctionName($method).", _typeEncoding); "; 108 | $r .= "}"; 109 | return $r; 110 | } 111 | } 112 | 113 | 1; 114 | -------------------------------------------------------------------------------- /theos/bin/lib/Logos/Generator/MobileSubstrate/Subclass.pm: -------------------------------------------------------------------------------- 1 | package Logos::Generator::MobileSubstrate::Subclass; 2 | use strict; 3 | use parent qw(Logos::Generator::MobileSubstrate::Class); 4 | 5 | # declarations is inherited from Class. 6 | 7 | sub _initExpression { 8 | my $self = shift; 9 | my $class = shift; 10 | my $cgen = Logos::Generator::for($class->superclass); 11 | return "objc_allocateClassPair(".$cgen->variable.", \"".$class->name."\", 0)"; 12 | } 13 | 14 | sub initializers { 15 | my $self = shift; 16 | my $class = shift; 17 | my $return = ""; 18 | $return .= "{ "; 19 | $return .= $self->SUPER::initializers($class)." "; 20 | # 21 | foreach(@{$class->ivars}) { 22 | $return .= Logos::Generator::for($_)->initializers; 23 | } 24 | # 25 | foreach(keys %{$class->protocols}) { 26 | $return .= "class_addProtocol(".$self->variable($class).", objc_getProtocol(\"$_\")); "; 27 | } 28 | $return .= "objc_registerClassPair(".$self->variable($class)."); "; 29 | $return .= "}"; 30 | return $return; 31 | } 32 | 33 | 1; 34 | -------------------------------------------------------------------------------- /theos/bin/lib/Logos/Generator/Thunk.pm: -------------------------------------------------------------------------------- 1 | package Logos::Generator::Thunk; 2 | use strict; 3 | 4 | our $AUTOLOAD; 5 | 6 | my %subrefCache; 7 | 8 | sub AUTOLOAD { 9 | my $self = shift; 10 | my $method = $AUTOLOAD; 11 | return if $method eq "DESTROY"; 12 | 13 | $method =~ s/.*:://; 14 | my $fullyQualified = $self->{PACKAGE}."::".$method; 15 | my $subref = $subrefCache{$fullyQualified}; 16 | 17 | $subref = $self->can($method) if !$subref; 18 | 19 | unshift @_, $self->{OBJECT} if $self->{OBJECT}; 20 | goto &$subref; 21 | } 22 | 23 | sub can { 24 | my $self = shift; 25 | my $method = shift; 26 | my $subref = $self->SUPER::can($method); 27 | return $subref if $subref; 28 | 29 | $method =~ s/.*:://; 30 | my $fullyQualified = $self->{PACKAGE}."::".$method; 31 | return $subrefCache{$fullyQualified} if $subrefCache{$fullyQualified}; 32 | 33 | $subref = sub {unshift @_, $self->{PACKAGE}; goto &{$self->{PACKAGE}->can($method)}}; 34 | $subrefCache{$fullyQualified} = $subref; 35 | 36 | return $subref; 37 | } 38 | 39 | sub DESTROY { 40 | my $self = shift; 41 | $self->SUPER::destroy(); 42 | } 43 | 44 | sub for { 45 | my $proto = shift; 46 | my $class = ref($proto) || $proto; 47 | my $self = {}; 48 | $self->{PACKAGE} = shift; 49 | $self->{OBJECT} = shift; 50 | bless($self, $class); 51 | return $self; 52 | } 53 | 54 | 1; 55 | -------------------------------------------------------------------------------- /theos/bin/lib/Logos/Generator/internal/Class.pm: -------------------------------------------------------------------------------- 1 | package Logos::Generator::internal::Class; 2 | use strict; 3 | use parent qw(Logos::Generator::Base::Class); 4 | 5 | sub superVariable { 6 | my $self = shift; 7 | my $class = shift; 8 | return Logos::sigil("superclass").$class->group->name."\$".$class->name; 9 | } 10 | 11 | sub superMetaVariable { 12 | my $self = shift; 13 | my $class = shift; 14 | return Logos::sigil("supermetaclass").$class->group->name."\$".$class->name; 15 | } 16 | 17 | sub declarations { 18 | my $self = shift; 19 | my $class = shift; 20 | my $return = ""; 21 | if($class->hasinstancehooks) { 22 | $return .= "static Class ".$self->superVariable($class)."; "; 23 | } 24 | if($class->hasmetahooks) { 25 | $return .= "static Class ".$self->superMetaVariable($class)."; "; 26 | } 27 | $return .= $self->SUPER::declarations($class); 28 | return $return; 29 | } 30 | 31 | sub initializers { 32 | my $self = shift; 33 | my $class = shift; 34 | my $return = ""; 35 | if($class->overridden || $class->hasinstancehooks || $class->hasmetahooks) { 36 | $return .= "Class ".$self->variable($class)." = ".$self->_initExpression($class)."; "; 37 | } 38 | if($class->hasmetahooks) { 39 | $return .= "Class ".$self->metaVariable($class)." = ".$self->_metaInitExpression($class)."; "; 40 | } 41 | if ($class->hasinstancehooks) { 42 | $return .= $self->superVariable($class)." = class_getSuperclass(".$self->variable($class)."); "; 43 | } 44 | if ($class->hasmetahooks) { 45 | $return .= $self->superMetaVariable($class)." = class_getSuperclass(".$self->metaVariable($class)."); "; 46 | } 47 | $return .= $self->SUPER::initializers($class); 48 | return $return; 49 | } 50 | 51 | 1; 52 | -------------------------------------------------------------------------------- /theos/bin/lib/Logos/Generator/internal/Generator.pm: -------------------------------------------------------------------------------- 1 | package Logos::Generator::internal::Generator; 2 | use strict; 3 | use parent qw(Logos::Generator::Base::Generator); 4 | 5 | sub findPreamble { 6 | my $self = shift; 7 | my $aref = shift; 8 | my @matches = grep(/\s*#\s*(import|include)\s*[<"]objc\/message\.h[">]/, @$aref); 9 | return $self->SUPER::findPreamble($aref) && @matches > 0; 10 | } 11 | 12 | sub preamble { 13 | my $self = shift; 14 | return join("\n", ($self->SUPER::preamble(), "#include ")); 15 | } 16 | 17 | 1; 18 | -------------------------------------------------------------------------------- /theos/bin/lib/Logos/Generator/internal/Method.pm: -------------------------------------------------------------------------------- 1 | package Logos::Generator::internal::Method; 2 | use strict; 3 | use parent qw(Logos::Generator::Base::Method); 4 | 5 | sub superFunctionName { 6 | my $self = shift; 7 | my $method = shift; 8 | return Logos::sigil(($method->scope eq "+" ? "meta_" : "")."super").$method->groupIdentifier."\$".$method->class->name."\$".$method->_new_selector; 9 | } 10 | 11 | sub originalCallParams { 12 | my $self = shift; 13 | my $method = shift; 14 | my $customargs = shift; 15 | return "" if $method->isNew; 16 | 17 | my $build = "(self, _cmd"; 18 | if(defined $customargs && $customargs ne "") { 19 | $build .= ", ".$customargs; 20 | } elsif($method->numArgs > 0) { 21 | $build .= ", ".join(", ",@{$method->argnames}); 22 | } 23 | $build .= ")"; 24 | return $build; 25 | } 26 | 27 | sub definition { 28 | my $self = shift; 29 | my $method = shift; 30 | my $build = ""; 31 | my $classargtype = ""; 32 | my $classref = ""; 33 | my $cgen = Logos::Generator::for($method->class); 34 | if($method->scope eq "+") { 35 | $classargtype = "Class"; 36 | $classref = $cgen->superMetaVariable; 37 | } else { 38 | $classargtype = $method->class->type; 39 | $classref = $cgen->superVariable; 40 | } 41 | my $arglist = ""; 42 | map $arglist .= ", ".Logos::Method::declarationForTypeWithName($method->argtypes->[$_], $method->argnames->[$_]), (0..$method->numArgs - 1); 43 | my $parameters = "(".$classargtype." self, SEL _cmd".$arglist.")"; 44 | if(!$method->isNew) { 45 | my $argtypelist = join(", ", @{$method->argtypes}); 46 | 47 | $build .= "static ".Logos::Method::declarationForTypeWithName($method->return, $self->superFunctionName($method).$parameters)." {"; 48 | my $pointerType = "(*)(".$classargtype.", SEL"; 49 | $pointerType .= ", ".$argtypelist if $argtypelist; 50 | $pointerType .= ")"; 51 | $build .= "return ((".Logos::Method::declarationForTypeWithName($method->return, $pointerType).")class_getMethodImplementation(".$classref.", \@selector(".$method->selector.")))"; 52 | $build .= $self->originalCallParams($method).";"; 53 | $build .= "}"; 54 | 55 | } 56 | $build .= "static ".Logos::Method::declarationForTypeWithName($method->return, $self->newFunctionName($method).$parameters); 57 | return $build; 58 | } 59 | 60 | sub originalCall { 61 | my $self = shift; 62 | my $method = shift; 63 | my $customargs = shift; 64 | return $self->originalFunctionName($method).$self->originalCallParams($method, $customargs); 65 | } 66 | 67 | sub declarations { 68 | my $self = shift; 69 | my $method = shift; 70 | my $build = ""; 71 | if(!$method->isNew) { 72 | my $classargtype = ""; 73 | if($method->scope eq "+") { 74 | $classargtype = "Class"; 75 | } else { 76 | $classargtype = $method->class->type; 77 | } 78 | $build .= "static "; 79 | my $name = ""; 80 | $name .= "(*".$self->originalFunctionName($method).")(".$classargtype.", SEL"; 81 | my $argtypelist = join(", ", @{$method->argtypes}); 82 | $name .= ", ".$argtypelist if $argtypelist; 83 | $name .= ")"; 84 | $build .= Logos::Method::declarationForTypeWithName($method->return, $name).";"; 85 | } 86 | return $build; 87 | } 88 | 89 | sub initializers { 90 | my $self = shift; 91 | my $method = shift; 92 | my $cgen = Logos::Generator::for($method->class); 93 | my $classvar = ($method->scope eq "+" ? $cgen->metaVariable : $cgen->variable); 94 | my $r = "{ "; 95 | if(!$method->isNew) { 96 | my $classargtype = ""; 97 | if($method->scope eq "+") { 98 | $classargtype = "Class"; 99 | } else { 100 | $classargtype = $method->class->type; 101 | } 102 | my $_pointertype = "(*)(".$classargtype.", SEL"; 103 | my $argtypelist = join(", ", @{$method->argtypes}); 104 | $_pointertype .= ", ".$argtypelist if $argtypelist; 105 | $_pointertype .= ")"; 106 | my $pointertype = Logos::Method::declarationForTypeWithName($method->return, $_pointertype); 107 | $r .= "Class _class = ".$classvar.";"; 108 | $r .= "Method _method = class_getInstanceMethod(_class, \@selector(".$method->selector."));"; 109 | $r .= "if (_method) {"; 110 | $r .= $self->originalFunctionName($method)." = ".$self->superFunctionName($method).";"; 111 | $r .= "if (!class_addMethod(_class, \@selector(".$method->selector."), (IMP)&".$self->newFunctionName($method).", method_getTypeEncoding(_method))) {"; 112 | $r .= $self->originalFunctionName($method)." = (".$pointertype.")method_getImplementation(_method);"; 113 | $r .= $self->originalFunctionName($method)." = (".$pointertype.")method_setImplementation(_method, (IMP)&".$self->newFunctionName($method).");"; 114 | $r .= "}"; 115 | $r .= "}"; 116 | } else { 117 | if(!$method->type) { 118 | $r .= "char _typeEncoding[1024]; unsigned int i = 0; "; 119 | for ($method->return, "id", "SEL", @{$method->argtypes}) { 120 | my $typeEncoding = Logos::Method::typeEncodingForArgType($_); 121 | if(defined $typeEncoding) { 122 | my @typeEncodingBits = split(//, $typeEncoding); 123 | my $i = 0; 124 | for my $char (@typeEncodingBits) { 125 | $r .= "_typeEncoding[i".($i > 0 ? " + $i" : "")."] = '$char'; "; 126 | $i++; 127 | } 128 | $r .= "i += ".(scalar @typeEncodingBits)."; "; 129 | } else { 130 | $r .= "memcpy(_typeEncoding + i, \@encode($_), strlen(\@encode($_))); i += strlen(\@encode($_)); "; 131 | } 132 | } 133 | $r .= "_typeEncoding[i] = '\\0'; "; 134 | } else { 135 | $r .= "const char *_typeEncoding = \"".$method->type."\"; "; 136 | } 137 | $r .= "class_addMethod(".$classvar.", \@selector(".$method->selector."), (IMP)&".$self->newFunctionName($method).", _typeEncoding); "; 138 | } 139 | $r .= "}"; 140 | return $r; 141 | } 142 | 143 | 1; 144 | -------------------------------------------------------------------------------- /theos/bin/lib/Logos/Generator/internal/Subclass.pm: -------------------------------------------------------------------------------- 1 | package Logos::Generator::internal::Subclass; 2 | use strict; 3 | use parent qw(Logos::Generator::internal::Class); 4 | 5 | # declarations is inherited from Class. 6 | 7 | sub _initExpression { 8 | my $self = shift; 9 | my $class = shift; 10 | return "objc_allocateClassPair(objc_getClass(\"".$class->superclass."\"), \"".$class->name."\", 0)"; 11 | } 12 | 13 | sub initializers { 14 | my $self = shift; 15 | my $class = shift; 16 | my $return = ""; 17 | $return .= "{ "; 18 | $return .= $self->SUPER::initializers($class)." "; 19 | # 20 | foreach(@{$class->ivars}) { 21 | $return .= Logos::Generator::for($_)->initializers; 22 | } 23 | # 24 | foreach(keys %{$class->protocols}) { 25 | $return .= "class_addProtocol(".$self->variable($class).", objc_getProtocol(\"$_\")); "; 26 | } 27 | $return .= "objc_registerClassPair(".$self->variable($class)."); "; 28 | $return .= "}"; 29 | return $return; 30 | } 31 | 32 | 1; 33 | -------------------------------------------------------------------------------- /theos/bin/lib/Logos/Group.pm: -------------------------------------------------------------------------------- 1 | package Logos::Group; 2 | use strict; 3 | 4 | sub new { 5 | my $proto = shift; 6 | my $class = ref($proto) || $proto; 7 | my $self = {}; 8 | $self->{NAME} = undef; 9 | $self->{EXPLICIT} = 1; 10 | $self->{INITIALIZED} = 0; 11 | $self->{INITLINE} = -1; 12 | $self->{CLASSES} = []; 13 | bless($self, $class); 14 | return $self; 15 | } 16 | 17 | ##################### # 18 | # Setters and Getters # 19 | # ##################### 20 | sub name { 21 | my $self = shift; 22 | if(@_) { $self->{NAME} = shift; } 23 | return $self->{NAME}; 24 | } 25 | 26 | sub explicit { 27 | my $self = shift; 28 | if(@_) { $self->{EXPLICIT} = shift; } 29 | return $self->{EXPLICIT}; 30 | } 31 | 32 | sub initialized { 33 | my $self = shift; 34 | if(@_) { $self->{INITIALIZED} = shift; } 35 | return $self->{INITIALIZED}; 36 | } 37 | 38 | sub initRequired { 39 | my $self = shift; 40 | for(@{$self->{CLASSES}}) { 41 | return 1 if $_->initRequired; 42 | } 43 | return 0; 44 | } 45 | 46 | sub identifier { 47 | my $self = shift; 48 | return main::sanitize($self->{NAME}); 49 | } 50 | 51 | sub initLine { 52 | my $self = shift; 53 | if(@_) { $self->{INITLINE} = shift; } 54 | return $self->{INITLINE}; 55 | } 56 | 57 | sub classes { 58 | my $self = shift; 59 | return $self->{CLASSES}; 60 | } 61 | ##### # 62 | # END # 63 | # ##### 64 | 65 | sub addClass { 66 | my $self = shift; 67 | my $class = shift; 68 | $class->group($self); 69 | push(@{$self->{CLASSES}}, $class); 70 | } 71 | 72 | sub addClassNamed { 73 | my $self = shift; 74 | my $name = shift; 75 | 76 | my $class = $self->getClassNamed($name); 77 | return $class if defined($class); 78 | 79 | $class = ::Class()->new(); 80 | $class->name($name); 81 | $self->addClass($class); 82 | return $class; 83 | } 84 | 85 | sub getClassNamed { 86 | my $self = shift; 87 | my $name = shift; 88 | foreach(@{$self->{CLASSES}}) { 89 | return $_ if $_->name eq $name; 90 | } 91 | return undef; 92 | } 93 | 94 | 1; 95 | -------------------------------------------------------------------------------- /theos/bin/lib/Logos/Ivar.pm: -------------------------------------------------------------------------------- 1 | package Logos::Ivar; 2 | use strict; 3 | 4 | sub new { 5 | my $proto = shift; 6 | my $class = ref($proto) || $proto; 7 | my $self = {}; 8 | $self->{NAME} = shift; 9 | $self->{TYPE} = shift; 10 | $self->{CLASS} = undef; 11 | bless($self, $class); 12 | return $self; 13 | } 14 | 15 | ##################### # 16 | # Setters and Getters # 17 | # ##################### 18 | sub name { 19 | my $self = shift; 20 | if(@_) { $self->{NAME} = shift; } 21 | return $self->{NAME}; 22 | } 23 | 24 | sub type { 25 | my $self = shift; 26 | if(@_) { $self->{TYPE} = shift; } 27 | return $self->{TYPE}; 28 | } 29 | 30 | sub class { 31 | my $self = shift; 32 | if(@_) { $self->{CLASS} = shift; } 33 | return $self->{CLASS}; 34 | } 35 | ##### # 36 | # END # 37 | # ##### 38 | 39 | 1; 40 | -------------------------------------------------------------------------------- /theos/bin/lib/Logos/Patch.pm: -------------------------------------------------------------------------------- 1 | package Logos::Patch; 2 | use strict; 3 | 4 | sub new { 5 | my $proto = shift; 6 | my $class = ref($proto) || $proto; 7 | my $self = {}; 8 | $self->{LINE} = -1; 9 | $self->{RANGE} = []; 10 | $self->{SOURCE} = undef; 11 | $self->{SQUASH} = 0; 12 | bless($self, $class); 13 | return $self; 14 | } 15 | 16 | ##################### # 17 | # Setters and Getters # 18 | # ##################### 19 | sub line { 20 | my $self = shift; 21 | if(@_) { $self->{LINE} = shift; } 22 | return $self->{LINE}; 23 | } 24 | 25 | sub range { 26 | my $self = shift; 27 | if(@_) { @{$self->{RANGE}} = @_; } 28 | return $self->{RANGE}; 29 | } 30 | 31 | sub start { 32 | my $self = shift; 33 | if(@_) { $self->{RANGE}[0] = shift; } 34 | return $self->{RANGE}[0]; 35 | } 36 | 37 | sub end { 38 | my $self = shift; 39 | if(@_) { $self->{RANGE}[1] = shift; } 40 | return $self->{RANGE}[1]; 41 | } 42 | 43 | sub source { 44 | my $self = shift; 45 | if(@_) { $self->{SOURCE} = shift; } 46 | return $self->{SOURCE}; 47 | } 48 | 49 | sub squash { 50 | my $self = shift; 51 | if(@_) { $self->{SQUASH} = shift; } 52 | return $self->{SQUASH}; 53 | } 54 | 55 | ##### # 56 | # END # 57 | # ##### 58 | 59 | sub evalSource { 60 | my $self = shift; 61 | my $source = shift; 62 | my $sourceref = ref($source); 63 | my @lines; 64 | if($sourceref) { 65 | if($sourceref eq "ARRAY") { 66 | for(@$source) { 67 | splice(@lines, scalar @lines, 0, $self->evalSource($_)); 68 | } 69 | } else { 70 | push(@lines, $source->eval()); 71 | } 72 | } else { 73 | push(@lines, $source); 74 | } 75 | return @lines; 76 | } 77 | 78 | sub apply { 79 | my $self = shift; 80 | my $lref = shift; 81 | my $line = $self->{LINE}; 82 | my ($start, $end) = @{$self->{RANGE}}; 83 | my $source = $self->{SOURCE}; 84 | my @lines = $self->evalSource($source); 85 | if(!defined $start) { 86 | push(@lines, ::generateLineDirectiveForPhysicalLine($line)); 87 | if($self->{SQUASH}) { 88 | push(@$lref, join('', @lines)); 89 | } else { 90 | splice(@$lref, $line, 0, @lines); 91 | } 92 | } else { 93 | substr($lref->[$line], $start, $end-$start) = join('', @lines); 94 | } 95 | return; 96 | } 97 | 98 | 1; 99 | -------------------------------------------------------------------------------- /theos/bin/lib/Logos/Patch/Source/Generator.pm: -------------------------------------------------------------------------------- 1 | package Logos::Patch::Source::Generator; 2 | use strict; 3 | 4 | sub new { 5 | my $proto = shift; 6 | my $class = ref($proto) || $proto; 7 | my $self = {}; 8 | $self->{OBJECT} = shift; 9 | $self->{METHOD} = shift; 10 | my @args = @_; 11 | $self->{ARGS} = \@args; 12 | bless($self, $class); 13 | return $self; 14 | } 15 | 16 | sub eval { 17 | #no strict 'refs'; 18 | my $self = shift; 19 | my @args = @{$self->{ARGS}}; 20 | splice(@args, 0, 0, $self->{OBJECT}) if $self->{OBJECT}; 21 | return Logos::Generator::for($self->{OBJECT})->can($self->{METHOD})->(@args); 22 | #my $thunk = Logos::Generator::for($self->{OBJECT})->can($self->{METHOD})-(>${$self->{ARGS}});; 23 | #my $mname = $self->{METHOD}; 24 | #return $thunk->$mname(@{$self->{ARGS}}); 25 | } 26 | 27 | 1; 28 | -------------------------------------------------------------------------------- /theos/bin/lib/Logos/StaticClassGroup.pm: -------------------------------------------------------------------------------- 1 | package Logos::StaticClassGroup; 2 | use Logos::Group; 3 | our @ISA = ('Logos::Group'); 4 | 5 | sub new { 6 | my $proto = shift; 7 | my $class = ref($proto) || $proto; 8 | my $self = Logos::Group->new(); 9 | $self->name("_staticClass"); 10 | $self->explicit(0); 11 | $self->{DECLAREDONLYCLASSES} = {}; 12 | $self->{USEDCLASSES} = {}; 13 | $self->{USEDMETACLASSES} = {}; 14 | bless($self, $class); 15 | return $self; 16 | } 17 | 18 | sub addUsedClass { 19 | my $self = shift; 20 | my $class = shift; 21 | $self->{USEDCLASSES}{$class}++; 22 | } 23 | 24 | sub addUsedMetaClass { 25 | my $self = shift; 26 | my $class = shift; 27 | $self->{USEDMETACLASSES}{$class}++; 28 | } 29 | 30 | sub addDeclaredOnlyClass { 31 | my $self = shift; 32 | my $class = shift; 33 | $self->{DECLAREDONLYCLASSES}{$class}++; 34 | } 35 | 36 | sub declaredOnlyClasses { 37 | my $self = shift; 38 | return $self->{DECLAREDONLYCLASSES}; 39 | } 40 | 41 | sub usedClasses { 42 | my $self = shift; 43 | return $self->{USEDCLASSES}; 44 | } 45 | 46 | sub usedMetaClasses { 47 | my $self = shift; 48 | return $self->{USEDMETACLASSES}; 49 | } 50 | 51 | 1; 52 | -------------------------------------------------------------------------------- /theos/bin/lib/Logos/Subclass.pm: -------------------------------------------------------------------------------- 1 | package Logos::Subclass; 2 | use Logos::Class; 3 | our @ISA = ('Logos::Class'); 4 | 5 | sub new { 6 | my $proto = shift; 7 | my $class = ref($proto) || $proto; 8 | my $self = $class->SUPER::new(); 9 | $self->{SUPERCLASS} = undef; 10 | $self->{PROTOCOLS} = {}; 11 | $self->{IVARS} = []; 12 | $self->{OVERRIDDEN} = 1; 13 | bless($self, $class); 14 | return $self; 15 | } 16 | 17 | ##################### # 18 | # Setters and Getters # 19 | # ##################### 20 | sub superclass { 21 | my $self = shift; 22 | if(@_) { $self->{SUPERCLASS} = shift; } 23 | return $self->{SUPERCLASS}; 24 | } 25 | 26 | sub ivars { 27 | my $self = shift; 28 | return $self->{IVARS}; 29 | } 30 | 31 | sub protocols { 32 | my $self = shift; 33 | return $self->{PROTOCOLS}; 34 | } 35 | 36 | sub initRequired { 37 | my $self = shift; 38 | return 1; # Subclasses must always be initialized. 39 | } 40 | 41 | ##### # 42 | # END # 43 | # ##### 44 | 45 | sub addProtocol { 46 | my $self = shift; 47 | my $protocol = shift; 48 | $self->{PROTOCOLS}{$protocol}++; 49 | } 50 | 51 | sub addIvar { 52 | my $self = shift; 53 | my $ivar = shift; 54 | $ivar->class($self); 55 | push(@{$self->{IVARS}}, $ivar); 56 | } 57 | 58 | sub getIvarNamed { 59 | my $self = shift; 60 | my $name = shift; 61 | foreach(@{$self->{IVARS}}) { 62 | return $_ if $_->name eq $name; 63 | } 64 | return undef; 65 | } 66 | 67 | 1; 68 | -------------------------------------------------------------------------------- /theos/bin/lib/Logos/Util.pm: -------------------------------------------------------------------------------- 1 | package Logos::Util; 2 | use 5.006; 3 | use strict; 4 | our @ISA = ('Exporter'); 5 | our @EXPORT = qw(quotes fallsBetween sanitize matchedParenthesisSet nestedParenString smartSplit); 6 | our $errorhandler = \&_defaultErrorHandler; 7 | 8 | sub _defaultErrorHandler { 9 | die shift; 10 | } 11 | 12 | sub quotes { 13 | my ($line) = @_; 14 | my @quotes = (); 15 | while($line =~ /(? 0) { 24 | my $start = shift; 25 | my $end = shift; 26 | return 1 if ($start < $idx && (!defined($end) || $end > $idx)) 27 | } 28 | return 0; 29 | } 30 | 31 | sub sanitize { 32 | my $input = shift; 33 | my $output = $input; 34 | $output =~ s/[^\w]//g; 35 | return $output; 36 | } 37 | 38 | sub matchedParenthesisSet { 39 | my $in = shift; 40 | my $atstart = shift; 41 | $atstart = 1 if !defined $atstart; 42 | 43 | my $opening = -1; 44 | my $closing = -1; 45 | if(!$atstart || $in =~ /^\s*\(/) { 46 | # If we encounter a ) that puts us back at zero, we found a ( 47 | # and have reached its closing ). 48 | my $parenmatch = $in; 49 | my $pdepth = 0; 50 | my @pquotes = quotes($parenmatch); 51 | while($parenmatch =~ /[;()]/g) { 52 | next if fallsBetween($-[0], @pquotes); 53 | 54 | if($& eq "(") { 55 | if($pdepth == 0) { $opening = $+[0]; } 56 | $pdepth++; 57 | } elsif($& eq ")") { 58 | $pdepth--; 59 | if($pdepth == 0) { $closing = $+[0]; last; } 60 | } 61 | } 62 | } 63 | 64 | return undef if $opening == -1; 65 | &$errorhandler("missing closing parenthesis") if $closing == -1; 66 | return ($opening, $closing); 67 | } 68 | 69 | sub nestedParenString { 70 | my $in = shift; 71 | my ($opening, $closing) = matchedParenthesisSet($in); 72 | 73 | my @ret; 74 | if(defined $opening) { 75 | $ret[0] = substr($in, $opening, $closing - $opening - 1); 76 | $in = substr($in, $closing); 77 | } 78 | $ret[1] = $in; 79 | return @ret; 80 | } 81 | 82 | sub smartSplit { 83 | my $re = shift; 84 | my $in = shift; 85 | return () if !$in || $in eq ""; 86 | 87 | my $limit = shift; 88 | $limit = 0 if !defined $limit; 89 | 90 | my @quotes = quotes($in); 91 | my @parens = matchedParenthesisSet($in, 0); 92 | 93 | my $lstart = 0; 94 | my @pieces = (); 95 | my $piece = ""; 96 | while($in =~ /$re/g) { 97 | next if (defined $parens[0] && fallsBetween($-[0], @parens)) || fallsBetween($-[0], @quotes); 98 | $piece = substr($in, $lstart, $-[0]-$lstart); 99 | push(@pieces, $piece); 100 | $lstart = $+[0]; 101 | $limit--; 102 | last if($limit == 1); # One item left? Bail out and throw the rest of the string into it! 103 | } 104 | $piece = substr($in, $lstart); 105 | push(@pieces, $piece); 106 | return @pieces; 107 | } 108 | 109 | 1; 110 | -------------------------------------------------------------------------------- /theos/bin/lib/NIC/Bridge/Context.pm: -------------------------------------------------------------------------------- 1 | package NIC::Bridge::Context; 2 | use strict; 3 | use warnings; 4 | use subs qw(warn exit); 5 | use Module::Load::Conditional qw(can_load); 6 | use NIC::Tie::PrefixedHandleRedirect; 7 | use NIC::Bridge::NICBase; 8 | 9 | our %handlers = ( 10 | PROMPT => sub { }, 11 | ); 12 | 13 | sub import { 14 | my $package = shift; 15 | my %arg = @_; 16 | for(keys %arg) { 17 | $handlers{$_} = $arg{$_}; 18 | } 19 | } 20 | 21 | our $bridge = undef; 22 | our $global_ret = undef; 23 | our $errored_out = undef; 24 | 25 | sub NIC { 26 | return $bridge; 27 | } 28 | 29 | sub warn(@) { 30 | print STDERR "[".$bridge->{FOR}->name."/warning] ",@_,$/; 31 | } 32 | 33 | sub error(@) { 34 | print STDERR "[".$bridge->{FOR}->name."/error] ",@_,$/; 35 | $errored_out = 1; 36 | die; 37 | } 38 | 39 | sub exit { 40 | $global_ret = shift; 41 | die; 42 | } 43 | 44 | sub prompt { 45 | __PACKAGE__->_prompt($bridge->{FOR}, undef, @_); 46 | } 47 | 48 | sub _prompt { 49 | my $self = shift; 50 | my $nic = shift; 51 | 52 | my $n = scalar @_; 53 | my $opts = $_[$n-1]; 54 | if(ref $opts eq "HASH") { 55 | $n--; 56 | } else { 57 | $opts = {}; 58 | } 59 | 60 | my $variable; 61 | $variable = shift unless $n == 1; 62 | my $promptstring = shift; 63 | 64 | $handlers{PROMPT}->($nic, $variable, $promptstring, $opts->{default}); 65 | } 66 | 67 | sub _wrap { 68 | my $self = shift; 69 | my @r = map { 70 | my $wrap = $_; 71 | my $_wrapType = $wrap ? (ref $wrap) : "_Undefined"; 72 | if(!$_wrapType || (ref($wrap) && $wrap->isa("NIC::Bridge::_BridgedObject"))) { 73 | return $wrap; 74 | } else { 75 | $_wrapType =~ s/.*:://; 76 | my $wrappingClass = "NIC::Bridge::$_wrapType"; 77 | can_load(modules=>{$wrappingClass=>undef}, verbose=>0) or return undef; 78 | my $wrapper = $wrappingClass->new($self, $wrap); 79 | return $wrapper; 80 | } 81 | } (@_); 82 | return @r if wantarray; 83 | return (@r > 0 ? $r[0] : undef); 84 | } 85 | 86 | sub _unwrap { 87 | my $self = shift; 88 | my @r = map { (ref($_) && $_->isa("NIC::Bridge::_BridgedObject")) ? $_->{FOR} : $_; } (@_); 89 | return @r if wantarray; 90 | return (@r > 0 ? $r[0] : undef); 91 | } 92 | 93 | sub _execute { 94 | my $self = shift; 95 | my $nic = shift; 96 | my $script = shift; 97 | my $ret = 1; 98 | { 99 | local $global_ret; 100 | local $errored_out; 101 | local $bridge = NIC::Bridge::NICBase->new($self, $nic); 102 | local $SIG{__DIE__} = sub { }; 103 | tie *OVERRIDE, "NIC::Tie::PrefixedHandleRedirect", *STDERR, $nic->name; 104 | my $stdout = select(*OVERRIDE); 105 | eval("#line 1 ".$nic->name."/control.pl\n".$script); 106 | select($stdout); 107 | if(defined $errored_out) { 108 | $ret = 0; 109 | } elsif(defined $global_ret) { 110 | $ret = $global_ret; 111 | print STDERR "[".$nic->name."/error] Control script exited with status $ret.",$/; 112 | } elsif($@) { 113 | $ret = 0; 114 | print STDERR "[".$nic->name."/error] Control script exited due to an error: $@"; 115 | } 116 | } 117 | return $ret; 118 | } 119 | 120 | 1; 121 | -------------------------------------------------------------------------------- /theos/bin/lib/NIC/Bridge/Directory.pm: -------------------------------------------------------------------------------- 1 | package NIC::Bridge::Directory; 2 | use strict; 3 | use warnings; 4 | use parent qw(NIC::Bridge::NICType); 5 | 6 | 1; 7 | -------------------------------------------------------------------------------- /theos/bin/lib/NIC/Bridge/File.pm: -------------------------------------------------------------------------------- 1 | package NIC::Bridge::File; 2 | use strict; 3 | use warnings; 4 | use parent qw(NIC::Bridge::NICType); 5 | use NIC::Tie::Method; 6 | 7 | sub data :lvalue { 8 | my $self = shift; 9 | tie my $tied, 'NIC::Tie::Method', $self->{FOR}, "data"; 10 | $tied; 11 | } 12 | 13 | 1; 14 | -------------------------------------------------------------------------------- /theos/bin/lib/NIC/Bridge/NICBase.pm: -------------------------------------------------------------------------------- 1 | package NIC::Bridge::NICBase; 2 | use strict; 3 | use warnings; 4 | use parent qw(NIC::Bridge::_BridgedObject); 5 | use NIC::NICBase::Directory; 6 | use NIC::NICBase::File; 7 | use NIC::NICBase::Symlink; 8 | 9 | sub variables { 10 | my $self = shift; 11 | return keys %{$self->{FOR}->{VARIABLES}}; 12 | } 13 | 14 | sub variable :lvalue { 15 | my $self = shift; 16 | $self->{FOR}->variable(@_); 17 | } 18 | 19 | sub mkdir { 20 | my $self = shift; 21 | my $dirname = shift; 22 | my $mode = shift; 23 | my $ref = $self->{FOR}->_getContent($dirname); 24 | NIC::NICBase::Directory->take($ref); 25 | $ref->mode($mode) if $mode; 26 | return $self->{CONTEXT}->_wrap($ref); 27 | } 28 | 29 | sub mkfile { 30 | my $self = shift; 31 | my $name = shift; 32 | my $mode = shift; 33 | my $ref = $self->{FOR}->_getContent($name); 34 | NIC::NICBase::File->take($ref); 35 | $ref->mode($mode) if $mode; 36 | return $self->{CONTEXT}->_wrap($ref); 37 | } 38 | 39 | sub symlink { 40 | my $self = shift; 41 | my $oldfile = shift; 42 | my $newfile = shift; 43 | my $ref = $self->{FOR}->_getContent($newfile); 44 | 45 | my $realtarget = ref($oldfile) ? $self->{CONTEXT}->_unwrap($oldfile) : $self->{FOR}->_getContentWithoutCreate($oldfile); 46 | $realtarget = $oldfile if !$realtarget; 47 | 48 | NIC::NICBase::Symlink->take($ref, $realtarget); 49 | 50 | return $self->{CONTEXT}->_wrap($ref); 51 | } 52 | 53 | sub lookup { 54 | my $self = shift; 55 | my $name = shift; 56 | return $self->{CONTEXT}->_wrap($self->{FOR}->_getContentWithoutCreate($name)); 57 | } 58 | 59 | sub setConstraint { 60 | my $self = shift; 61 | my $constraint = shift; 62 | $self->{FOR}->addConstraint($constraint); 63 | } 64 | 65 | sub clearConstraint { 66 | my $self = shift; 67 | my $constraint = shift; 68 | $self->{FOR}->removeConstraint($constraint); 69 | } 70 | 71 | sub prompt { 72 | my $self = shift; 73 | $self->{CONTEXT}->_prompt($self->{FOR}, @_); 74 | } 75 | 76 | 1; 77 | -------------------------------------------------------------------------------- /theos/bin/lib/NIC/Bridge/NICType.pm: -------------------------------------------------------------------------------- 1 | package NIC::Bridge::NICType; 2 | use strict; 3 | use warnings; 4 | use parent qw(NIC::Bridge::_BridgedObject); 5 | use NIC::Tie::Method; 6 | 7 | sub name :lvalue { 8 | my $self = shift; 9 | tie my $tied, 'NIC::Tie::Method', $self->{FOR}, "name"; 10 | $tied; 11 | } 12 | 13 | sub mode :lvalue { 14 | my $self = shift; 15 | tie my $tied, 'NIC::Tie::Method', $self->{FOR}, "mode"; 16 | $tied; 17 | } 18 | 19 | sub constraints { 20 | my $self = shift; 21 | return $self->{FOR}->constraints; 22 | } 23 | 24 | sub constrain { 25 | my $self = shift; 26 | $self->{FOR}->addConstraint(shift); 27 | } 28 | 29 | 1; 30 | -------------------------------------------------------------------------------- /theos/bin/lib/NIC/Bridge/Symlink.pm: -------------------------------------------------------------------------------- 1 | package NIC::Bridge::Symlink; 2 | use strict; 3 | use warnings; 4 | use parent qw(NIC::Bridge::NICType); 5 | use NIC::Bridge::Tie::WrappedMethod; 6 | 7 | sub target :lvalue { 8 | my $self = shift; 9 | tie my $tied, 'NIC::Bridge::Tie::WrappedMethod', $self->{CONTEXT}, $self->{FOR}, "target"; 10 | $tied; 11 | } 12 | 13 | 1; 14 | -------------------------------------------------------------------------------- /theos/bin/lib/NIC/Bridge/Tie/WrappedMethod.pm: -------------------------------------------------------------------------------- 1 | package NIC::Bridge::Tie::WrappedMethod; 2 | use strict; 3 | use warnings; 4 | use parent qw(Tie::Scalar); 5 | 6 | sub TIESCALAR { 7 | my $class = shift; 8 | my $self = { CONTEXT => shift, FOR => shift, METHOD => shift }; 9 | bless($self, $class); 10 | return $self; 11 | } 12 | 13 | sub FETCH { 14 | my $self = shift; 15 | my $obj = $self->{FOR}; 16 | my $ret = $self->{FOR}->can($self->{METHOD})->($self->{FOR}); 17 | return $self->{CONTEXT}->_wrap($ret); 18 | } 19 | 20 | sub STORE { 21 | my $self = shift; 22 | my $obj = $self->{FOR}; 23 | my $in = shift; 24 | $self->{FOR}->can($self->{METHOD})->($self->{FOR}, $self->{CONTEXT}->_unwrap($in)); 25 | } 26 | 27 | 1; 28 | 29 | -------------------------------------------------------------------------------- /theos/bin/lib/NIC/Bridge/_BridgedObject.pm: -------------------------------------------------------------------------------- 1 | package NIC::Bridge::_BridgedObject; 2 | use strict; 3 | use warnings; 4 | 5 | use overload '""' => sub { 6 | my $self = shift; 7 | return "[".($self->{FOR}//"(undefined)")."]"; 8 | }; 9 | 10 | sub new { 11 | my $proto = shift; 12 | my $class = ref($proto) || $proto; 13 | my $self = { CONTEXT => shift, FOR => shift }; 14 | bless($self, $proto); 15 | return $self; 16 | } 17 | 18 | 19 | 1; 20 | -------------------------------------------------------------------------------- /theos/bin/lib/NIC/Bridge/_Undefined.pm: -------------------------------------------------------------------------------- 1 | package NIC::Bridge::_Undefined; 2 | use strict; 3 | use warnings; 4 | use parent qw(NIC::Bridge::_BridgedObject); 5 | 6 | use overload "bool" => sub { 7 | return 0; 8 | }; 9 | 10 | our $AUTOLOAD; 11 | sub AUTOLOAD { 12 | my $method = $AUTOLOAD; 13 | $method =~ s/.*:://; 14 | NIC::Bridge::Context::error("Method '$method' called on nonexistent NIC Bridge object."); 15 | } 16 | 17 | sub DESTROY { 18 | my $self = shift; 19 | } 20 | 21 | 1; 22 | -------------------------------------------------------------------------------- /theos/bin/lib/NIC/Formats/NIC1.pm: -------------------------------------------------------------------------------- 1 | package NIC::Formats::NIC1; 2 | use parent NIC::NICBase; 3 | use strict; 4 | 5 | sub new { 6 | my $proto = shift; 7 | my $class = ref($proto) || $proto; 8 | 9 | my $fh = shift; 10 | my $self = NIC::NICBase->new(@_); 11 | bless($self, $class); 12 | 13 | $self->load($fh); 14 | return $self; 15 | } 16 | 17 | sub _processLine { 18 | my $self = shift; 19 | my $fh = shift; 20 | local $_ = shift; 21 | if(/^name \"(.*)\"$/) { 22 | $self->name($1); 23 | } elsif(/^dir (.+)$/) { 24 | $self->registerDirectory($1); 25 | } elsif(/^file (\d+) (.+)$/) { 26 | my $lines = $1; 27 | my $filename = $2; 28 | my $fref = $self->registerFile($filename); 29 | my $filedata = ""; 30 | while($lines > 0) { 31 | $filedata .= <$fh>; 32 | $lines--; 33 | } 34 | $fref->data($filedata); 35 | } elsif(/^prompt (\w+) \"(.*?)\"( \"(.*?)\")?$/) { 36 | my $key = $1; 37 | my $prompt = $2; 38 | my $default = $4 || undef; 39 | $self->registerPrompt($key, $prompt, $default); 40 | } elsif(/^symlink \"(.+)\" \"(.+)\"$/) { 41 | my $name = $1; 42 | my $dest = $2; 43 | $self->registerSymlink($name, $dest); 44 | } elsif(/^constrain file \"(.+)\" to (.+)$/) { 45 | my $constraint = $2; 46 | my $filename = $1; 47 | $self->registerFileConstraint($filename, $constraint); 48 | } 49 | } 50 | 51 | sub load { 52 | my $self = shift; 53 | my $fh = shift; 54 | while(<$fh>) { 55 | $self->_processLine($fh, $_); 56 | } 57 | $self->resolveSymlinks; 58 | } 59 | 60 | 1; 61 | -------------------------------------------------------------------------------- /theos/bin/lib/NIC/Formats/NICTar.pm: -------------------------------------------------------------------------------- 1 | package NIC::Formats::NICTar; 2 | use parent NIC::NICBase; 3 | use strict; 4 | use NIC::Formats::NICTar::File; 5 | use NIC::Formats::NICTar::Directory; 6 | use NIC::Formats::NICTar::Symlink; 7 | use Archive::Tar; 8 | use File::Temp; 9 | use File::Path; 10 | use File::Spec; 11 | use NIC::Bridge::Context; 12 | $Archive::Tar::WARN = 0; 13 | 14 | sub new { 15 | my $proto = shift; 16 | my $fh_or_tar = shift; 17 | my $class = ref($proto) || $proto; 18 | 19 | my $tar = ref($fh_or_tar) eq "Archive::Tar" ? $fh_or_tar : Archive::Tar->new($fh_or_tar); 20 | return undef if(!$tar); 21 | 22 | my $control = _fileFromTar(undef, $tar, "NIC/control"); 23 | return undef if(!$control); 24 | 25 | my $self = NIC::NICBase->new(@_); 26 | $self->{_TAR} = $tar; 27 | bless($self, $class); 28 | 29 | $self->_processData($control->get_content); 30 | $self->load(); 31 | 32 | return $self; 33 | } 34 | 35 | sub _fileClass { "NIC::Formats::NICTar::File"; } 36 | sub _directoryClass { "NIC::Formats::NICTar::Directory"; } 37 | sub _symlinkClass { "NIC::Formats::NICTar::Symlink"; } 38 | 39 | sub _fileFromTar { 40 | my $self = shift; 41 | my $tar = $self ? $self->{_TAR} : shift; 42 | my $filename = shift; 43 | my @_tarfiles = $tar->get_files("./$filename", $filename); 44 | return (scalar @_tarfiles > 0) ? $_tarfiles[0] : undef; 45 | } 46 | 47 | sub _processData { 48 | my $self = shift; 49 | my $data = shift; 50 | for(split /\n\r?/, $data) { 51 | $self->_processLine($_); 52 | } 53 | } 54 | 55 | sub _processLine { 56 | my $self = shift; 57 | local $_ = shift; 58 | if(/^name\s+\"(.*)\"$/ || /^name\s+(.*)$/) { 59 | $self->name($1); 60 | } elsif(/^prompt (\w+) \"(.*?)\"( \"(.*?)\")?$/) { 61 | my $key = $1; 62 | my $prompt = $2; 63 | my $default = $4 || undef; 64 | $self->registerPrompt($key, $prompt, $default); 65 | } elsif(/^constrain (file )?\"(.+)\" to (.+)$/) { 66 | my $constraint = $3; 67 | my $filename = $2; 68 | $self->registerFileConstraint($filename, $constraint); 69 | } elsif(/^ignore (\w+)$/) { 70 | $self->ignoreVariable($1); 71 | } 72 | } 73 | 74 | sub load { 75 | my $self = shift; 76 | for($self->{_TAR}->get_files()) { 77 | next if !$_->full_path || $_->full_path =~ /^(\.\/)?NIC(\/|$)/; 78 | my $n = $_->full_path; 79 | $n =~ s/^\.\///; 80 | next if length $n == 0; 81 | if($_->is_dir) { 82 | my $ref = $self->registerDirectory($n); 83 | $ref->tarfile($_); 84 | } elsif($_->is_symlink) { 85 | my $target = $_->linkname; 86 | $target =~ s/^\.\///; 87 | 88 | my $ref = $self->registerSymlink($n, $target); 89 | $ref->tarfile($_); 90 | } elsif($_->is_file) { 91 | my $ref = $self->registerFile($n); 92 | $ref->tarfile($_); 93 | } 94 | } 95 | $self->resolveSymlinks; 96 | } 97 | 98 | sub _execPackageScript { 99 | my $self = shift; 100 | my $script = shift; 101 | my $tarfile = $self->_fileFromTar("NIC/$script"); 102 | return if !$tarfile || $tarfile->mode & 0500 != 0500; 103 | my $filename = File::Spec->catfile($self->{_TEMPDIR}, $script); 104 | my $nicfile = NIC::NICType->new($self, $filename); 105 | $self->_fileClass->take($nicfile); 106 | $nicfile->tarfile($tarfile); 107 | $nicfile->create(); 108 | my $ret = system $filename $script; 109 | return ($ret >> 8) == 0 110 | } 111 | 112 | sub prebuild { 113 | my $self = shift; 114 | return $self->_execPackageScript("prebuild"); 115 | } 116 | 117 | sub postbuild { 118 | my $self = shift; 119 | return $self->_execPackageScript("postbuild"); 120 | } 121 | 122 | sub exec { 123 | my $self = shift; 124 | my $_controlpl = $self->_fileFromTar("NIC/control.pl"); 125 | if($_controlpl) { 126 | return NIC::Bridge::Context->_execute($self, $_controlpl->get_content); 127 | } 128 | return 1; 129 | } 130 | 131 | sub build { 132 | my $self = shift; 133 | 134 | for(keys %{$self->{VARIABLES}}) { 135 | $ENV{"NIC_".$_} = $self->variable($_); 136 | } 137 | 138 | $self->{_TEMPDIR} = File::Temp::tempdir(); 139 | 140 | $self->SUPER::build(@_); 141 | 142 | File::Path::rmtree($self->{_TEMPDIR}); 143 | $self->{_TEMPDIR} = undef; 144 | } 145 | 146 | 1; 147 | -------------------------------------------------------------------------------- /theos/bin/lib/NIC/Formats/NICTar/Directory.pm: -------------------------------------------------------------------------------- 1 | package NIC::Formats::NICTar::Directory; 2 | use parent qw(NIC::Formats::NICTar::_TarMixin NIC::NICBase::Directory); 3 | use strict; 4 | 5 | sub _take_init { 6 | my $self = shift; 7 | $self->NIC::NICBase::Directory::_take_init(@_); 8 | $self->NIC::Formats::NICTar::_TarMixin::_take_init(@_); 9 | } 10 | 11 | 1; 12 | -------------------------------------------------------------------------------- /theos/bin/lib/NIC/Formats/NICTar/File.pm: -------------------------------------------------------------------------------- 1 | package NIC::Formats::NICTar::File; 2 | use parent qw(NIC::Formats::NICTar::_TarMixin NIC::NICBase::File); 3 | use strict; 4 | 5 | sub _take_init { 6 | my $self = shift; 7 | $self->NIC::NICBase::File::_take_init(@_); 8 | $self->NIC::Formats::NICTar::_TarMixin::_take_init(@_); 9 | } 10 | 11 | sub data { 12 | my $self = shift; 13 | return $self->SUPER::data(@_) // $self->tarfile->get_content; 14 | } 15 | 16 | 1; 17 | -------------------------------------------------------------------------------- /theos/bin/lib/NIC/Formats/NICTar/Symlink.pm: -------------------------------------------------------------------------------- 1 | package NIC::Formats::NICTar::Symlink; 2 | use parent NIC::NICBase::Symlink; 3 | use strict; 4 | 5 | sub tarfile { 6 | my $self = shift; 7 | if(@_) { $self->{TARFILE} = shift; } 8 | return $self->{TARFILE}; 9 | } 10 | 11 | 1; 12 | -------------------------------------------------------------------------------- /theos/bin/lib/NIC/Formats/NICTar/_TarMixin.pm: -------------------------------------------------------------------------------- 1 | package NIC::Formats::NICTar::_TarMixin; 2 | use strict; 3 | 4 | sub _take_init { 5 | my $self = shift; 6 | $self->{TARFILE} = undef; 7 | } 8 | 9 | sub tarfile { 10 | my $self = shift; 11 | if(@_) { $self->{TARFILE} = shift; } 12 | return $self->{TARFILE}; 13 | } 14 | 15 | sub _mode { 16 | my $self = shift; 17 | return $self->tarfile->mode; 18 | } 19 | 20 | 1; 21 | -------------------------------------------------------------------------------- /theos/bin/lib/NIC/NICBase.pm: -------------------------------------------------------------------------------- 1 | package NIC::NICBase; 2 | use strict; 3 | use warnings; 4 | 5 | use NIC::NICBase::File; 6 | use NIC::NICBase::Directory; 7 | use NIC::NICBase::Symlink; 8 | 9 | use List::Util qw(first); 10 | 11 | sub new { 12 | my $proto = shift; 13 | my $class = ref($proto) || $proto; 14 | my $self = {}; 15 | $self->{NAME} = shift; 16 | $self->{CONTENTS} = []; 17 | $self->{VARIABLES} = {}; 18 | $self->{CONSTRAINTS} = {}; 19 | $self->{PROMPTS} = []; 20 | $self->{IGNORED_VARS} = {}; 21 | bless($self, $class); 22 | 23 | return $self; 24 | } 25 | 26 | sub _fileClass { "NIC::NICBase::File"; } 27 | sub _directoryClass { "NIC::NICBase::Directory"; } 28 | sub _symlinkClass { "NIC::NICBase::Symlink"; } 29 | 30 | sub _getContentWithoutCreate { 31 | my $self = shift; 32 | my $name = shift; 33 | return first { $_->name eq $name } @{$self->{CONTENTS}}; 34 | } 35 | 36 | sub _getContent { 37 | my $self = shift; 38 | my $ref = $self->_getContentWithoutCreate(@_); 39 | return $ref if $ref; 40 | $ref = NIC::NICType->new($self, @_); 41 | push(@{$self->{CONTENTS}}, $ref); 42 | return $ref; 43 | } 44 | 45 | sub _generate { 46 | my $self = shift; 47 | my $class = shift; 48 | my $name = shift; 49 | my $ref = $self->_getContent($name, @_); 50 | if($ref->type == NIC::NICType::TYPE_UNKNOWN) { 51 | $class->take($ref, @_); 52 | } 53 | return $ref; 54 | } 55 | 56 | sub registerDirectory { 57 | my $self = shift; 58 | my $dir = $self->_generate($self->_directoryClass, @_); 59 | return $dir; 60 | } 61 | 62 | sub registerFile { 63 | my $self = shift; 64 | my $file = $self->_generate($self->_fileClass, @_); 65 | return $file; 66 | } 67 | 68 | sub registerSymlink { 69 | my $self = shift; 70 | my $symlink = $self->_generate($self->_symlinkClass, @_); 71 | return $symlink; 72 | } 73 | 74 | sub registerPrompt { 75 | my($self, $key, $prompt, $default) = @_; 76 | push(@{$self->{PROMPTS}}, { 77 | name => $key, 78 | prompt => $prompt, 79 | default => $default 80 | }); 81 | } 82 | 83 | sub registerFileConstraint { 84 | my $self = shift; 85 | my $filename = shift; 86 | my $constraint = shift; 87 | $self->_getContent($filename)->addConstraint($constraint); 88 | } 89 | 90 | sub resolveSymlinks { 91 | my $self = shift; 92 | for(@{$self->{CONTENTS}}) { 93 | next unless $_->type == NIC::NICType::TYPE_SYMLINK; 94 | next if $_->target_type != NIC::NICType::TYPE_UNKNOWN; 95 | my $ref = $self->_getContentWithoutCreate($_->target); 96 | $_->target($ref) if $ref; 97 | } 98 | } 99 | 100 | sub variable: lvalue { 101 | my $self = shift; 102 | my $key = shift; 103 | $self->{VARIABLES}->{$key}; 104 | } 105 | 106 | sub name { 107 | my $self = shift; 108 | if(@_) { $self->{NAME} = shift; } 109 | return $self->{NAME} // "(unnamed template)"; 110 | } 111 | 112 | sub prompts { 113 | my $self = shift; 114 | return @{$self->{PROMPTS}}; 115 | } 116 | 117 | sub addConstraint { 118 | my $self = shift; 119 | my $constraint = shift; 120 | $self->{CONSTRAINTS}->{$constraint} = 1; 121 | } 122 | 123 | sub removeConstraint { 124 | my $self = shift; 125 | my $constraint = shift; 126 | delete $self->{CONSTRAINTS}->{$constraint}; 127 | } 128 | 129 | sub _constraintMatch { 130 | my $self = shift; 131 | my $constraint = shift; 132 | my $negated = 0; 133 | if(substr($constraint, 0, 1) eq "!") { 134 | $negated = 1; 135 | substr($constraint, 0, 1, ""); 136 | } 137 | return 0 if(!$negated && (!defined $self->{CONSTRAINTS}->{$constraint} || $self->{CONSTRAINTS}->{$constraint} != 1)); 138 | return 0 if($negated && (defined $self->{CONSTRAINTS}->{$constraint} || $self->{CONSTRAINTS}->{$constraint} != 0)); 139 | return 1; 140 | } 141 | 142 | sub _meetsConstraints { 143 | my $self = shift; 144 | my $content = shift; 145 | foreach ($content->constraints) { 146 | return 0 if !$self->_constraintMatch($_); 147 | } 148 | return 1; 149 | } 150 | 151 | sub substituteVariables { 152 | my $self = shift; 153 | my $line = shift; 154 | foreach my $key (keys %{$self->{VARIABLES}}) { 155 | my $value = $self->{VARIABLES}->{$key}; 156 | $line =~ s/\@\@$key\@\@/$value/g; 157 | } 158 | return $line; 159 | } 160 | 161 | sub ignoreVariable { 162 | my $self = shift; 163 | my $var = shift; 164 | $self->{IGNORED_VARS}->{$var}++; 165 | } 166 | 167 | sub variableIgnored { 168 | my $self = shift; 169 | my $var = shift; 170 | return defined $self->{IGNORED_VARS}->{$var}; 171 | } 172 | 173 | sub prebuild { 174 | 175 | } 176 | 177 | sub postbuild { 178 | 179 | } 180 | 181 | sub exec { 182 | return 1; 183 | } 184 | 185 | sub build { 186 | my $self = shift; 187 | my $dir = shift; 188 | mkdir($dir) or die "Failed to create the directory '$dir': $!\n"; 189 | chdir($dir) or die $!; 190 | $self->prebuild(); 191 | foreach my $content (sort { $a->type <=> $b->type } (@{$self->{CONTENTS}})) { 192 | next if $content->type == NIC::NICType::TYPE_UNKNOWN; 193 | next if !$self->_meetsConstraints($content); 194 | $content->create(); 195 | } 196 | $self->postbuild(); 197 | } 198 | 199 | sub dumpPreamble { 200 | my $self = shift; 201 | my $preamblefn = shift; 202 | open(my $pfh, ">", $preamblefn); 203 | print $pfh "name \"".$self->{NAME}."\"",$/; 204 | foreach my $prompt (@{$self->{PROMPTS}}) { 205 | print $pfh "prompt ".$prompt->{name}." \"".$prompt->{prompt}."\""; 206 | print $pfh " \"".$prompt->{default}."\"" if defined $prompt->{default}; 207 | print $pfh $/; 208 | } 209 | foreach my $filename (keys %{$self->{FILES}}) { 210 | my $file = $self->{FILES}->{$filename}; 211 | if(!defined $file->{constraints}) { 212 | next; 213 | } 214 | foreach (@{$file->{constraints}}) { 215 | print $pfh "constrain file \"".$filename."\" to ".$_,$/ 216 | } 217 | } 218 | close($pfh); 219 | } 220 | 221 | 1; 222 | -------------------------------------------------------------------------------- /theos/bin/lib/NIC/NICBase/Directory.pm: -------------------------------------------------------------------------------- 1 | package NIC::NICBase::Directory; 2 | use strict; 3 | use warnings; 4 | use parent qw(NIC::NICType); 5 | use File::Path qw(mkpath); 6 | 7 | sub type { 8 | my $self = shift; 9 | return NIC::NICType::TYPE_DIRECTORY; 10 | } 11 | 12 | sub _mode { 13 | return 0755; 14 | } 15 | 16 | sub create { 17 | my $self = shift; 18 | mkpath($self->{OWNER}->substituteVariables($self->{NAME}), { mode => $self->mode }) or return 0; 19 | return 1; 20 | } 21 | 22 | 23 | 1; 24 | 25 | -------------------------------------------------------------------------------- /theos/bin/lib/NIC/NICBase/File.pm: -------------------------------------------------------------------------------- 1 | package NIC::NICBase::File; 2 | use strict; 3 | use warnings; 4 | use parent qw(NIC::NICType); 5 | 6 | sub _take_init { 7 | my $self = shift; 8 | $self->{DATA} = undef; 9 | } 10 | 11 | sub type { 12 | my $self = shift; 13 | return NIC::NICType::TYPE_FILE; 14 | } 15 | 16 | sub _mode { 17 | return 0644; 18 | } 19 | 20 | sub data { 21 | my $self = shift; 22 | $self->{DATA} = shift if @_; 23 | $self->{DATA}; 24 | } 25 | 26 | sub create { 27 | my $self = shift; 28 | my $filename = $self->{OWNER}->substituteVariables($self->name); 29 | open(my $nicfile, ">", $filename) or return 0; 30 | print $nicfile $self->{OWNER}->substituteVariables($self->data); 31 | close($nicfile); 32 | chmod($self->mode, $filename); 33 | return 1; 34 | } 35 | 36 | 1; 37 | -------------------------------------------------------------------------------- /theos/bin/lib/NIC/NICBase/Symlink.pm: -------------------------------------------------------------------------------- 1 | package NIC::NICBase::Symlink; 2 | use strict; 3 | use warnings; 4 | use parent qw(NIC::NICType); 5 | use Scalar::Util qw(refaddr); 6 | 7 | use overload '""' => sub { 8 | my $self = shift; 9 | my $ref = ref($self); 10 | $ref =~ s/^.*::(\w+)$/$1/g; 11 | my $target = (ref($self->target) && refaddr($self) == refaddr($self->target)) ? "itself" : "\"".$self->target."\""; 12 | return '"'.$self->name."\" ($ref to $target)"; 13 | }; 14 | 15 | sub _take_init { 16 | my $self = shift; 17 | $self->{TARGET} = shift // undef; 18 | } 19 | 20 | sub type { 21 | my $self = shift; 22 | return NIC::NICType::TYPE_SYMLINK; 23 | } 24 | 25 | sub target { 26 | my $self = shift; 27 | if(@_) { $self->{TARGET} = shift; } 28 | return $self->{TARGET}; 29 | } 30 | 31 | sub target_type { 32 | my $self = shift; 33 | my $t = $self->{TARGET}; 34 | return ref($t) ? $t->type : NIC::NICType::TYPE_UNKNOWN; 35 | } 36 | 37 | sub target_name { 38 | my $self = shift; 39 | my $t = $self->{TARGET}; 40 | return ref($t) ? $t->name : $t; 41 | } 42 | 43 | sub create { 44 | my $self = shift; 45 | my $name = $self->{OWNER}->substituteVariables($self->{NAME}); 46 | my $dest = $self->{OWNER}->substituteVariables($self->target_name); 47 | symlink($dest, $name) or return 0; 48 | return 1; 49 | } 50 | 51 | 1; 52 | 53 | -------------------------------------------------------------------------------- /theos/bin/lib/NIC/NICType.pm: -------------------------------------------------------------------------------- 1 | package NIC::NICType; 2 | use strict; 3 | use warnings; 4 | 5 | use constant { 6 | TYPE_UNKNOWN => 0, 7 | TYPE_DIRECTORY => 1, 8 | TYPE_FILE => 2, 9 | TYPE_SYMLINK => 3 10 | }; 11 | 12 | use overload '""' => sub { 13 | my $self = shift; 14 | my $ref = ref($self); 15 | $ref =~ s/^.*::(\w+)$/$1/g; 16 | return '"'.$self->name."\" ($ref, mode ".sprintf("%4.04o", $self->mode).")"; 17 | }; 18 | 19 | sub new { 20 | my $proto = shift; 21 | my $class = ref($proto) || $proto; 22 | my $self = {}; 23 | $self->{OWNER} = shift // undef; 24 | $self->{NAME} = shift // undef; 25 | $self->{MODE} = undef; 26 | $self->{CONSTRAINTS} = []; 27 | bless($self, $class); 28 | 29 | return $self; 30 | } 31 | 32 | sub _take_init { 33 | } 34 | 35 | sub take { 36 | my $proto = shift; 37 | my $class = ref($proto) || $proto; 38 | my $obj = shift; 39 | bless($obj, $class); 40 | $obj->_take_init(@_); 41 | } 42 | 43 | sub name { 44 | my $self = shift; 45 | if(@_) { $self->{NAME} = shift; } 46 | return $self->{NAME}; 47 | } 48 | 49 | sub _mode { 50 | return 0; 51 | } 52 | 53 | sub mode { 54 | my $self = shift; 55 | if(@_) { $self->{MODE} = shift; } 56 | return $self->{MODE} // $self->_mode; 57 | } 58 | 59 | sub type { 60 | my $self = shift; 61 | return TYPE_UNKNOWN; 62 | } 63 | 64 | sub constraints { 65 | my $self = shift; 66 | return @{$self->{CONSTRAINTS}}; 67 | } 68 | 69 | sub addConstraint { 70 | my $self = shift; 71 | my $constraint = shift; 72 | push(@{$self->{CONSTRAINTS}}, $constraint); 73 | } 74 | 75 | sub create { 76 | return 0; 77 | } 78 | 79 | 1; 80 | -------------------------------------------------------------------------------- /theos/bin/lib/NIC/Tie/Method.pm: -------------------------------------------------------------------------------- 1 | package NIC::Tie::Method; 2 | use parent qw(Tie::Scalar); 3 | 4 | sub TIESCALAR { 5 | my $class = shift; 6 | my $for = shift; 7 | my $method = shift; 8 | my $self = { FOR => $for, METHOD => $method }; 9 | bless($self, $class); 10 | return $self; 11 | } 12 | 13 | sub FETCH { 14 | my $self = shift; 15 | my $obj = $self->{FOR}; 16 | { unshift @_, $obj; goto &{$self->{FOR}->can($self->{METHOD})}; } 17 | } 18 | 19 | sub STORE { 20 | my $self = shift; 21 | my $obj = $self->{FOR}; 22 | { unshift @_, $obj; goto &{$self->{FOR}->can($self->{METHOD})}; } 23 | } 24 | 25 | 1; 26 | 27 | -------------------------------------------------------------------------------- /theos/bin/lib/NIC/Tie/PrefixedHandleRedirect.pm: -------------------------------------------------------------------------------- 1 | package NIC::Tie::PrefixedHandleRedirect; 2 | use strict; 3 | use parent qw(Tie::Handle); 4 | sub TIEHANDLE { 5 | my $proto = shift; 6 | my $fh = shift; 7 | my $prefix = shift; 8 | return bless [$fh, $prefix], $proto; 9 | } 10 | 11 | sub _token { 12 | return "[".$_[0]->[1]."] "; 13 | } 14 | 15 | sub PRINT { 16 | my $t = $_[0]->_token; 17 | my $fh = $_[0]->[0]; 18 | shift; 19 | my $str = $t.join('', @_); 20 | $str =~ s#$/+$##g; 21 | $str =~ s#$/#$/$t#g; 22 | print $fh $str,$/; 23 | } 24 | 25 | sub PRINTF { 26 | my $t = $_[0]->_token; 27 | my $fh = $_[0]->[0]; 28 | shift; 29 | my $str = $t.sprintf(shift, @_); 30 | $str =~ s#$/+$##g; 31 | $str =~ s#$/#$/$t#g; 32 | print $fh $str,$/; 33 | } 34 | 1; 35 | -------------------------------------------------------------------------------- /theos/bin/lib/parent.pm: -------------------------------------------------------------------------------- 1 | package parent; 2 | use strict; 3 | use vars qw($VERSION); 4 | $VERSION = '0.225'; 5 | 6 | sub import { 7 | my $class = shift; 8 | 9 | my $inheritor = caller(0); 10 | 11 | if ( @_ and $_[0] eq '-norequire' ) { 12 | shift @_; 13 | } else { 14 | for ( my @filename = @_ ) { 15 | if ( $_ eq $inheritor ) { 16 | warn "Class '$inheritor' tried to inherit from itself\n"; 17 | }; 18 | 19 | s{::|'}{/}g; 20 | require "$_.pm"; # dies if the file is not found 21 | } 22 | } 23 | 24 | { 25 | no strict 'refs'; 26 | push @{"$inheritor\::ISA"}, @_; 27 | }; 28 | }; 29 | 30 | "All your base are belong to us" 31 | 32 | __END__ 33 | 34 | =encoding utf8 35 | 36 | =head1 NAME 37 | 38 | parent - Establish an ISA relationship with base classes at compile time 39 | 40 | =head1 SYNOPSIS 41 | 42 | package Baz; 43 | use parent qw(Foo Bar); 44 | 45 | =head1 DESCRIPTION 46 | 47 | Allows you to both load one or more modules, while setting up inheritance from 48 | those modules at the same time. Mostly similar in effect to 49 | 50 | package Baz; 51 | BEGIN { 52 | require Foo; 53 | require Bar; 54 | push @ISA, qw(Foo Bar); 55 | } 56 | 57 | By default, every base class needs to live in a file of its own. 58 | If you want to have a subclass and its parent class in the same file, you 59 | can tell C not to load any modules by using the C<-norequire> switch: 60 | 61 | package Foo; 62 | sub exclaim { "I CAN HAS PERL" } 63 | 64 | package DoesNotLoadFooBar; 65 | use parent -norequire, 'Foo', 'Bar'; 66 | # will not go looking for Foo.pm or Bar.pm 67 | 68 | This is equivalent to the following code: 69 | 70 | package Foo; 71 | sub exclaim { "I CAN HAS PERL" } 72 | 73 | package DoesNotLoadFooBar; 74 | push @DoesNotLoadFooBar::ISA, 'Foo', 'Bar'; 75 | 76 | This is also helpful for the case where a package lives within 77 | a differently named file: 78 | 79 | package MyHash; 80 | use Tie::Hash; 81 | use parent -norequire, 'Tie::StdHash'; 82 | 83 | This is equivalent to the following code: 84 | 85 | package MyHash; 86 | require Tie::Hash; 87 | push @ISA, 'Tie::StdHash'; 88 | 89 | If you want to load a subclass from a file that C would 90 | not consider an eligible filename (that is, it does not end in 91 | either C<.pm> or C<.pmc>), use the following code: 92 | 93 | package MySecondPlugin; 94 | require './plugins/custom.plugin'; # contains Plugin::Custom 95 | use parent -norequire, 'Plugin::Custom'; 96 | 97 | =head1 DIAGNOSTICS 98 | 99 | =over 4 100 | 101 | =item Class 'Foo' tried to inherit from itself 102 | 103 | Attempting to inherit from yourself generates a warning. 104 | 105 | package Foo; 106 | use parent 'Foo'; 107 | 108 | =back 109 | 110 | =head1 HISTORY 111 | 112 | This module was forked from L to remove the cruft 113 | that had accumulated in it. 114 | 115 | =head1 CAVEATS 116 | 117 | =head1 SEE ALSO 118 | 119 | L 120 | 121 | =head1 AUTHORS AND CONTRIBUTORS 122 | 123 | Rafaël Garcia-Suarez, Bart Lateur, Max Maischein, Anno Siegel, Michael Schwern 124 | 125 | =head1 MAINTAINER 126 | 127 | Max Maischein C< corion@cpan.org > 128 | 129 | Copyright (c) 2007-10 Max Maischein C<< >> 130 | Based on the idea of C, which was introduced with Perl 5.004_04. 131 | 132 | =head1 LICENSE 133 | 134 | This module is released under the same terms as Perl itself. 135 | 136 | =cut 137 | -------------------------------------------------------------------------------- /theos/bin/logify.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # logify.pl 3 | ############ 4 | # Converts an Objective-C header file (or anything containing a @interface and method definitions) 5 | #+into a Logos input file which causes all function calls to be logged. 6 | # 7 | # Accepts input on stdin or via filename specified on the commandline. 8 | 9 | # Lines are only processed if we were in an @interface, so you can run this on a file containing 10 | # an @implementation, as well. 11 | use strict; 12 | 13 | use FindBin; 14 | use lib "$FindBin::Bin/lib"; 15 | 16 | use Logos::Method; 17 | use Logos::Util; 18 | $Logos::Util::errorhandler = sub { 19 | die "$ARGV:$.: error: missing closing parenthesis$/" 20 | }; 21 | 22 | my $interface = 0; 23 | while(my $line = <>) { 24 | if($line =~ m/^[+-]\s*\((.*?)\).*?(?=;)/ && $interface == 1) { 25 | print logLineForDeclaration($&); 26 | } elsif($line =~ m/^\s*\@property\s*\((.*?)\)\s*(.*?)\b([\$a-zA-Z_][\$_a-zA-Z0-9]*)(?=;)/ && $interface == 1) { 27 | my @attributes = smartSplit(qr/\s*,\s*/, $1); 28 | my $propertyName = $3; 29 | my $type = $2; 30 | my $readonly = scalar(grep(/readonly/, @attributes)); 31 | my %methods = ("setter" => "set".ucfirst($propertyName).":", "getter" => $propertyName); 32 | foreach my $attribute (@attributes) { 33 | next if($attribute !~ /=/); 34 | my @x = smartSplit(qr/\s*=\s*/, $attribute); 35 | $methods{$x[0]} = $x[1]; 36 | } 37 | if($readonly == 0) { 38 | print logLineForDeclaration("- (void)".$methods{"setter"}."($type)$propertyName"); 39 | } 40 | print logLineForDeclaration("- ($type)".$methods{"getter"}); 41 | } elsif($line =~ m/^\@interface\s+(.*?)\s*[:(]/ && $interface == 0) { 42 | print "%hook $1\n"; 43 | $interface = 1; 44 | } elsif($line =~ m/^\@end/ && $interface == 1) { 45 | print "%end\n"; 46 | $interface = 0; 47 | } 48 | } 49 | 50 | sub logLineForDeclaration { 51 | my $declaration = shift; 52 | $declaration =~ m/^[+-]\s*\((.*?)\).*?/; 53 | my $rtype = $1; 54 | my $innards = "%log; "; 55 | if($rtype ne "void") { 56 | $innards .= "$rtype r = %orig; "; 57 | $innards .= "NSLog(@\" = ".Logos::Method::formatCharForArgType($rtype)."\", ".Logos::Method::printArgForArgType($rtype, "r")."); " if defined Logos::Method::printArgForArgType($rtype, "r"); 58 | $innards .= "return r; "; 59 | } else { 60 | $innards .= "%orig; "; 61 | } 62 | return "$declaration { $innards}\n"; 63 | } 64 | -------------------------------------------------------------------------------- /theos/bin/nicify.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | use File::Find; 6 | use File::Spec; 7 | use Archive::Tar; 8 | use Cwd qw(abs_path getcwd); 9 | 10 | use FindBin; 11 | use lib "$FindBin::Bin/lib"; 12 | use NIC::Formats::NICTar; 13 | 14 | package NIC::Archive::Tar::File; 15 | use parent "Archive::Tar::File"; 16 | sub new { 17 | my $class = shift; 18 | my $self = Archive::Tar::File->new(@_); 19 | bless($self, $class); 20 | return $self; 21 | } 22 | 23 | sub _prefix_and_file { 24 | my $self = shift; 25 | my $path = shift; 26 | my ($prefix, $file) = $self->SUPER::_prefix_and_file($path); 27 | $prefix =~ s/^/\.\// if $prefix ne "" && $prefix ne "." && $prefix !~ /^\.\//; 28 | return ($prefix, $file); 29 | } 30 | 1; 31 | package main; 32 | 33 | if(@ARGV == 0) { 34 | exitWithError("Syntax: $FindBin::Script "); 35 | } 36 | 37 | my $cwd = abs_path(getcwd()); 38 | my $tar = Archive::Tar->new(); 39 | my $controlfile = undef; 40 | our @tarfiles = ( 41 | NIC::Archive::Tar::File->new(data=>"./", "", {type=>Archive::Tar::Constant::DIR, uid=>0, gid=>0, mode=>0755}), 42 | NIC::Archive::Tar::File->new(data=>"./NIC/", "", {type=>Archive::Tar::Constant::DIR, uid=>0, gid=>0, mode=>0777}) 43 | ); 44 | 45 | chdir $ARGV[0]; 46 | 47 | my $control_in = undef; 48 | 49 | if(-f "pre.NIC") { 50 | warning("Using legacy pre.NIC as ./NIC/control."); 51 | $control_in = "./pre.NIC"; 52 | } elsif(-f "NIC/control") { 53 | $control_in = "./NIC/control"; 54 | } 55 | 56 | if(!$control_in) { 57 | exitWithError("No control file found at NIC/control."); 58 | exit 1; 59 | } 60 | 61 | $controlfile = NIC::Archive::Tar::File->new(file=>$control_in); 62 | $controlfile->prefix("./NIC"); 63 | $controlfile->name("control"); 64 | push(@tarfiles, $controlfile); 65 | 66 | find({wanted => \&wanted, preprocess => \&preprocess, follow => 0, no_chdir => 1}, "."); 67 | 68 | $tar->add_files(@tarfiles); 69 | 70 | chdir($cwd); 71 | my $newnic = NIC::Formats::NICTar->new($tar); 72 | if(!defined $newnic->name) { 73 | exitWithError("Template has no name. Please insert a `name \"\"` directive into $control_in."); 74 | } 75 | 76 | { my $_ = scalar @{$newnic->{CONTENTS}}; info("$_ entr".($_==1?"y.":"ies.")); } 77 | { my $_ = scalar @{$newnic->{PROMPTS}}; info("$_ prompt".($_==1?".":"s.")); } 78 | my $constraints = 0; 79 | { 80 | my %constrainthash; 81 | for(@{$newnic->{CONTENTS}}) { 82 | for my $c ($_->constraints) { 83 | $constrainthash{$c}++; 84 | } 85 | } 86 | $constraints = scalar keys %constrainthash; 87 | } 88 | { my $_ = $constraints; info("$_ constraint".($_==1?".":"s.")); } 89 | 90 | my $fixedfn = join("_", File::Spec->splitdir($newnic->name)); 91 | my $filename = $fixedfn.".nic.tar"; 92 | $tar->write($filename) and info("Archived template \"".$newnic->name."\" to $filename."); 93 | 94 | sub preprocess { 95 | my @list = @_; 96 | if($File::Find::dir eq "./NIC") { 97 | @list = grep !/^control$/, @list; 98 | } 99 | @list = grep !/^pre.NIC$/ && !/^\.svn$/ && !/^\.git$/ && !/^_MTN$/ && !/\.nic\.tar$/ && !/^\.DS_Store$/ && !/^\._/, @list; 100 | return @list; 101 | } 102 | 103 | sub wanted { 104 | local $_ = $File::Find::name; 105 | my $mode = (stat)[2]; 106 | 107 | my $tarfile = undef; 108 | if(-d) { 109 | s/$/\// if !/\/$/; 110 | return if /^\.\/$/; 111 | return if /^\.\/NIC\/?$/; 112 | $tarfile = NIC::Archive::Tar::File->new(data=>$_, "", {mode=>$mode, uid=>0, gid=>0, type=>Archive::Tar::Constant::DIR}); 113 | } elsif(-f && ! -l) { 114 | $tarfile = NIC::Archive::Tar::File->new(file=>$_); 115 | $tarfile->mode($mode); 116 | $tarfile->uid(0); 117 | $tarfile->gid(0); 118 | } elsif(-l) { 119 | $tarfile = NIC::Archive::Tar::File->new(data=>$_, "", {linkname=>readlink($_), uid=>0, gid=>0, type=>Archive::Tar::Constant::SYMLINK}); 120 | } 121 | push(@tarfiles, $tarfile) if $tarfile; 122 | } 123 | 124 | sub slurp { 125 | my $fn = shift; 126 | open(my($fh), "<", $fn); 127 | local $/ = undef; 128 | my $d = <$fh>; 129 | return $d; 130 | } 131 | 132 | sub info { 133 | my $text = shift; 134 | print STDERR "[info] ", $text, $/; 135 | } 136 | 137 | sub warning { 138 | my $text = shift; 139 | print STDERR "[warning] ", $text, $/; 140 | } 141 | 142 | sub exitWithError { 143 | my $error = shift; 144 | print STDERR "[error] ", $error, $/; 145 | exit 1; 146 | } 147 | 148 | -------------------------------------------------------------------------------- /theos/bin/package_version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function build_num_from_file { 4 | version=$(< "$1") 5 | version=${version##*-} 6 | version=${version%%+*} 7 | version=${version%%~*} 8 | echo -n "$version" 9 | } 10 | 11 | while getopts ":N:V:" flag; do 12 | case "$flag" in 13 | :) echo "$0: Option -$OPTARG requires an argument." 1>&2 14 | exit 1 15 | ;; 16 | \?) echo "$0: What're you talking about?" 1>&2 17 | exit 1 18 | ;; 19 | N) package="$OPTARG" ;; 20 | V) version="$OPTARG" ;; 21 | esac 22 | done 23 | 24 | if [[ ! -d "${THEOS_PROJECT_DIR}/.theos/packages" ]]; then 25 | if [[ -d "${THEOS_PROJECT_DIR}/.debmake" ]]; then 26 | mkdir -p "${THEOS_PROJECT_DIR}/.theos" 27 | mv "${THEOS_PROJECT_DIR}/.debmake" "${THEOS_PROJECT_DIR}/.theos/packages" 28 | else 29 | mkdir -p "${THEOS_PROJECT_DIR}/.theos/packages" 30 | fi 31 | fi 32 | 33 | versionfile="${THEOS_PROJECT_DIR}/.theos/packages/$package-$version" 34 | build_number=0 35 | 36 | if [[ ! -e "$versionfile" ]]; then 37 | build_number=1 38 | else 39 | build_number=$(build_num_from_file "$versionfile") 40 | let build_number++ 41 | fi 42 | 43 | echo -n "$build_number" > "$versionfile" 44 | echo "$build_number" 45 | -------------------------------------------------------------------------------- /theos/bin/target.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use File::Temp; 3 | 4 | my @o; 5 | for(reverse @ARGV) { 6 | my $i = 0; 7 | for my $a (split /:/) { 8 | if(length $a > 0) { 9 | @o = () if($i == 0 && $o[$i] && $o[$i] ne $a); 10 | $o[$i] = $a; 11 | } 12 | $i++; 13 | } 14 | } 15 | #print join(':', map { $_ eq "" ? "-" : $_ } @o); 16 | my $i = 0; 17 | my ($fh, $tempfile) = File::Temp::tempfile(); 18 | binmode($fh, ":utf8"); 19 | 20 | for(@o) { 21 | print $fh "export __THEOS_TARGET_ARG_$i := $_\n"; 22 | ++$i; 23 | } 24 | 25 | close($fh); 26 | print $tempfile,$/; 27 | -------------------------------------------------------------------------------- /theos/bin/vercmp.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use warnings; 3 | use strict; 4 | if(@ARGV < 3) { 5 | exit 1; 6 | } 7 | my @afirst = split(/\./, $ARGV[0]); 8 | my $op = $ARGV[1]; 9 | my @asecond = split(/\./, $ARGV[2]); 10 | 11 | push(@afirst, 0) while(@afirst < @asecond); 12 | push(@asecond, 0) while(@asecond < @afirst); 13 | 14 | my $v1 = 0; 15 | my $v2 = 0; 16 | map { ($v1 *= 100) += $_ } (@afirst); 17 | map { ($v2 *= 100) += $_ } (@asecond); 18 | 19 | print "1" if $v1 > $v2 && $op eq "gt"; 20 | print "1" if $v1 < $v2 && $op eq "lt"; 21 | print "1" if $v1 >= $v2 && $op eq "ge"; 22 | print "1" if $v1 <= $v2 && $op eq "le"; 23 | print "1" if $v1 == $v2 && $op eq "eq"; 24 | -------------------------------------------------------------------------------- /theos/documentation/Makefile: -------------------------------------------------------------------------------- 1 | all: makefiles.html 2 | 3 | %.html: %.docbook 4 | xsltproc --output $@ /usr/share/sgml/docbook/xsl-stylesheets/xhtml/docbook.xsl $< 5 | 6 | clean: 7 | rm *.html 8 | -------------------------------------------------------------------------------- /theos/extras/vim/README: -------------------------------------------------------------------------------- 1 | Place the following in filetype.vim. 2 | 3 | au BufNewFile,BufRead *.xm,*.xmm,*.l.mm setf logos 4 | -------------------------------------------------------------------------------- /theos/extras/vim/ftplugin/logos.vim: -------------------------------------------------------------------------------- 1 | " Vim filetype plugin file 2 | " Language: Logos (Objective-C++) 3 | " Maintainer: Dustin Howett 4 | " Latest Revision: December 22, 2009 5 | 6 | if exists("b:did_ftplugin") 7 | finish 8 | endif 9 | 10 | " Behaves just like Objective-C 11 | runtime! ftplugin/objc.vim 12 | -------------------------------------------------------------------------------- /theos/extras/vim/indent/logos.vim: -------------------------------------------------------------------------------- 1 | " Vim filetype plugin file 2 | " Language: Logos (Objective-C++) 3 | " Maintainer: Dustin Howett 4 | " Latest Revision: December 22, 2009 5 | 6 | runtime! indent/objc.vim 7 | -------------------------------------------------------------------------------- /theos/extras/vim/syntax/logos.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: Logos (Objective-C++) 3 | " Maintainer: Dustin Howett 4 | " Latest Revision: April 2, 2011 5 | 6 | if exists("b:current_syntax") 7 | finish 8 | endif 9 | 10 | runtime! syntax/objc.vim 11 | 12 | syn match logosDirective '%\(hook\|group\|subclass\|ctor\)' display 13 | 14 | syn match logosDirective '%end' display 15 | 16 | syn match logosDirective '%class' display skipwhite nextgroup=logosClassName 17 | 18 | syn match logosDirective '%log' display contained containedin=logosHook,logosSubclass,logosGroup 19 | syn match logosDirective '%orig' display contained containedin=logosHook,logosSubclass,logosGroup 20 | 21 | syn match logosDirective '%init' display 22 | syn match logosDirective '%new' display 23 | syn region logosInit matchgroup=logosDirective start='%init(' end=')' contains=cParen 24 | 25 | syn region logosNew oneline matchgroup=logosNew start='%new(' end=')' contains=logosTypeEncoding,logosTypeEncodingUnion 26 | 27 | syn match logosTypeEncoding '[*@#:\[\]^?{}A-Za-z0-9$=]' display contained 28 | syn region logosTypeEncodingUnion oneline matchgroup=logosTypeEncoding start='(' end=')' contained transparent 29 | 30 | syn region logosInfixClass oneline matchgroup=logosInfixClass start='%c(' end=')' contains=logosClassName containedin=objcMessage 31 | syn match logosClassName '[A-Za-z$_][A-Za-z0-9_$]*' display contained 32 | 33 | syn region logosHook start="%hook" end="%end" fold transparent keepend extend 34 | syn region logosGroup start="%group" end="%end" fold transparent keepend extend 35 | syn region logosSubclass start="%subclass" end="%end" fold transparent keepend extend 36 | 37 | syn match logosError '\(@interface\|@implementation\)' contained containedin=logosHook,logosSubclass,logosGroup 38 | syn match logosError '\(%hook\|%group\|%subclass\)' contained containedin=objcImp,objcHeader 39 | 40 | syn match logosDirectiveArgument '\(%\(hook\|subclass\|group\)\)\@<=\s\+\k\+' display contained containedin=logosHook,logosSubclass,logosGroup 41 | syn match logosSubclassSuperclassName '\(%subclass\s\+\k\+\s*:\)\@<=\s*\k\+' display contained containedin=logosHook,logosSubclass,logosGroup 42 | 43 | syn cluster cParenGroup add=logosNew,logosInfixClass,logosInit 44 | syn cluster cParenGroup add=logosTypeEncoding,logosTypeEncodingUnion 45 | syn cluster cParenGroup add=logosClassName 46 | syn cluster cParenGroup add=logosDirectiveArgument,logosSubclassSuperclassName 47 | syn cluster cParenGroup add=logosError 48 | syn cluster cParenGroup add=logosHook,logosGroup,logosSubclass 49 | 50 | syn cluster cPreProcGroup add=logosClassName,logosDirective,logosTypeEncoding,logosTypeEncodingUnion 51 | 52 | syn cluster cMultiGroup add=logosTypeEncoding,logosTypeEncodingUnion,logosClassName 53 | 54 | syn sync match logosHookSync grouphere logosHook "%hook" 55 | syn sync match logosGroupSync grouphere logosGroup "%group" 56 | syn sync match logosSubclassSync grouphere logosSubclass "%subclass" 57 | syn sync match logosEndSync grouphere NONE "%end" 58 | 59 | let b:current_syntax = "logos" 60 | hi def link logosDirective PreProc 61 | hi def link logosDirectiveArgument String 62 | hi def link logosError Error 63 | 64 | hi def link logosTypeEncoding logosDirectiveArgument 65 | hi def link logosGroupName logosDirectiveArgument 66 | hi def link logosClassName logosDirectiveArgument 67 | hi def link logosSubclassSuperclassName logosClassName 68 | hi def link logosNew logosDirective 69 | hi def link logosInfixClass logosDirective 70 | -------------------------------------------------------------------------------- /theos/include/DHCommon.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | /* Common, useful things. 5 | * A bit has been lifted from rpetrich's Captain Hook macros. Thanks, Ryan! 6 | */ 7 | #define _Constructor __attribute__((constructor)) 8 | #define DHLateClass(name) @class name; static Class $ ## name = objc_getClass(#name) 9 | #define DHEarlyClass(name) static Class $ ## name = [name class] 10 | #define DHClass(name) $ ## name 11 | 12 | static inline void _DHRelease(id object) __attribute__((always_inline)); 13 | static inline void _DHRelease(id object) { 14 | [object release]; 15 | } 16 | #define DHScopeReleased __attribute__((cleanup(_DHRelease))) 17 | #define DHScopedAutoreleasePool() NSAutoreleasePool *DHScopedAutoreleasePool __attribute__((cleanup(_DHRelease),unused)) = [[NSAutoreleasePool alloc] init] 18 | 19 | // vim:ft=objc 20 | -------------------------------------------------------------------------------- /theos/include/DHHookCommon.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | #import 5 | 6 | /* 7 | * Many thanks to ashikase+saurik for the original HOOK/CALL_ORIG macros. 8 | */ 9 | 10 | /* 11 | * All hook names are created/specified with $ in place of : for selector names. 12 | * init::: -> init$$$ 13 | * destroyChildren:withMethod: -> destroyChildren$withMethod$ 14 | * init -> init 15 | */ 16 | 17 | /* 18 | * HOOK(class, name, type, args...) 19 | * 20 | * Example: 21 | * HOOK(Class, init, id) { 22 | * ... 23 | * } 24 | * 25 | * HOOK(Class, initWithFrame$andOtherThing$, id, CGRect frame, id otherThing) { 26 | * ... 27 | * } 28 | * 29 | * Creates a static variable (in the form of _class$name) to store the original message address, and a function to replace it, 30 | * in the form of $class$name. 31 | * type is the return type, and args are all the message arguments, in order; args is optional. 32 | */ 33 | #define HOOK(class, name, type, args...) \ 34 | static type (*_ ## class ## $ ## name)(class *self, SEL sel, ## args); \ 35 | static type $ ## class ## $ ## name(class *self, SEL sel, ## args) 36 | 37 | #define IMPLEMENTATION(class, name, type, args...) \ 38 | static type $ ## class ## $ ## name(class *self, SEL sel, ## args) 39 | /* 40 | * CALL_ORIG(class, name, args...) 41 | * 42 | * Example: 43 | * CALL_ORIG(Class, init); 44 | * CALL_ORIG(Class, initWithFrame$andOtherThing$, frame, otherThing); 45 | * 46 | * Calls an original implementation (_class$name). 47 | */ 48 | #define CALL_ORIG(class, name, args...) \ 49 | _ ## class ## $ ## name(self, sel, ## args) 50 | 51 | /* 52 | * GET_CLASS(class) 53 | * 54 | * Example: 55 | * GET_CLASS(UIToolbarButton); 56 | * 57 | * Simply creates a variable (named $class) to store a class for the HOOK_MESSAGE_* macros. 58 | * To avoid having to call objc_getClass over and over, and to provide a uniform naming scheme. 59 | */ 60 | #define GET_CLASS(class) \ 61 | Class $ ## class = objc_getClass(#class) 62 | 63 | /* 64 | * HOOK_MESSAGE(class, sel) 65 | * 66 | * Example: 67 | * HOOK_MESSAGE(Class, init); 68 | * 69 | * Saves the original implementation of sel to a static variable named after _class$sel (created with HOOK), after 70 | * replacing it with $class$sel (created with HOOK). 71 | * 72 | * This exists because sometimes you just want to hook a message with no args, without having to specify a replacement 73 | * or call __getsel 74 | */ 75 | #define HOOK_MESSAGE(class, sel) \ 76 | _ ## class ## $ ## sel = MSHookMessage(DHClass(class), @selector(sel), &$ ## class ## $ ## sel) 77 | 78 | #define ADD_MESSAGE(class, sel) \ 79 | MSHookMessage(DHClass(class), @selector(sel), &$ ## class ## $ ## sel) 80 | 81 | /* 82 | * HOOK_MESSAGE_WITH_SINGLE_ARG(class, sel) 83 | * 84 | * Example: 85 | * HOOK_MESSAGE_WITH_SINGLE_ARG(Class, initWithFrame); 86 | * 87 | * Shorthand for HOOK_MESSAGE_REPLACEMENT(Class, sel:, sel$) 88 | */ 89 | #define HOOK_MESSAGE_WITH_SINGLE_ARG(class, sel) \ 90 | _ ## class ## $ ## sel ## $ = MSHookMessage(DHClass(class), @selector(sel:), &$ ## class ## $ ## sel ## $) 91 | 92 | static inline SEL __getsel(const char *in) __attribute__((always_inline)); 93 | static inline SEL __getsel(const char *in) { 94 | int len = strlen(in) + 1; 95 | char selector[len]; 96 | for(int i = 0; i < len; i++) 97 | selector[i] = (in[i] == '$' ? ':' : in[i]); 98 | return sel_getUid(selector); 99 | } 100 | /* 101 | * HOOK_MESSAGE_AUTO(class, replace) 102 | * 103 | * Example: 104 | * HOOK_MESSAGE_AUTO(Class, initWithFrame$andOtherThing$andAnotherThing$); 105 | * 106 | * Beware, __getsel (string copy/transform) is called every time this macro is used. 107 | * Automatically turns a replacement selector in the $ format into a SEL, as a shorter form of HOOK_MESSAGE_REPLACEMENT. 108 | * 109 | * Saves the original implementation to a static variable named after _class$replace (created with HOOK), after 110 | * replacing it with $class$replace (created with HOOK). 111 | */ 112 | #define HOOK_MESSAGE_AUTO(class, replace) \ 113 | _ ## class ## $ ## replace = MSHookMessage(DHClass(class), __getsel(#replace), &$ ## class ## $ ## replace) 114 | #define ADD_MESSAGE_AUTO(class, replace) \ 115 | MSHookMessage(DHClass(class), __getsel(#replace), &$ ## class ## $ ## replace) 116 | 117 | /* 118 | * HOOK_MESSAGE_REPLACEMENT(class, sel, replace) 119 | * 120 | * Example: 121 | * HOOK_MESSAGE_REPLACEMENT(Class, initWithFrame:andOtherThing:andAnotherThing:, initWithFrame$andOtherThing$andAnotherThing$); 122 | * 123 | * Saves the original implementation to a static variable named after _class$replace (created with HOOK), after 124 | * replacing it with $class$replace (created with HOOK). 125 | */ 126 | #define HOOK_MESSAGE_REPLACEMENT(class, sel, replace) \ 127 | _ ## class ## $ ## replace = MSHookMessage(DHClass(class), @selector(sel), &$ ## class ## $ ## replace) 128 | 129 | #define ADD_MESSAGE_REPLACEMENT(class, sel, replace) \ 130 | MSHookMessage(DHClass(class), @selector(sel), &$ ## class ## $ ## replace) 131 | 132 | #define HOOK_MESSAGE_ARGS HOOK_MESSAGE_WITH_SINGLE_ARG 133 | #define HOOK_MESSAGE_EX HOOK_MESSAGE_AUTO 134 | #define HOOK_MESSAGE_F HOOK_MESSAGE_REPLACEMENT 135 | #define ADD_MESSAGE_F ADD_MESSAGE_REPLACEMENT 136 | 137 | #define DHGetClass GET_CLASS 138 | #define DHHookMessageWithReplacement HOOK_MESSAGE_REPLACEMENT 139 | #define DHHookMessageWithAutoRename HOOK_MESSAGE_AUTO 140 | #define DHHookMessage HOOK_MESSAGE_AUTO 141 | #define DHAddMessage ADD_MESSAGE_AUTO 142 | -------------------------------------------------------------------------------- /theos/include/logos/logos.h: -------------------------------------------------------------------------------- 1 | #ifndef __LOGOS_H 2 | #define __LOGOS_H 3 | 4 | // As an unfortunate matter of course, logos/logos.h can not include any preprocessor definitions that are to be used by Logos. 5 | // This is therefore a placeholder for functions defined in a future liblogos.a. 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /theos/include/substrate.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #ifdef __cplusplus 5 | #define _default(x) = x 6 | extern "C" { 7 | #else 8 | #define _default(x) 9 | #endif 10 | typedef const void *MSImageRef; 11 | void MSHookFunction(void *symbol, void *replace, void **result); 12 | void *MSFindSymbol(const void *image, const char *name); 13 | MSImageRef MSGetImageByName(const char *file); 14 | 15 | #ifdef __APPLE__ 16 | #ifdef __arm__ 17 | IMP MSHookMessage(Class _class, SEL sel, IMP imp, const char *prefix _default(NULL)); 18 | #endif 19 | void MSHookMessageEx(Class _class, SEL sel, IMP imp, IMP *result); 20 | #endif 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | -------------------------------------------------------------------------------- /theos/lib/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heardrwt/RevealLoader/d422e26bc92749634547d520651710bce6744f7e/theos/lib/.keep -------------------------------------------------------------------------------- /theos/lib/libsubstrate.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heardrwt/RevealLoader/d422e26bc92749634547d520651710bce6744f7e/theos/lib/libsubstrate.dylib -------------------------------------------------------------------------------- /theos/lib/libsubstrate.dylib.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heardrwt/RevealLoader/d422e26bc92749634547d520651710bce6744f7e/theos/lib/libsubstrate.dylib.1 -------------------------------------------------------------------------------- /theos/makefiles/aggregate.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(_THEOS_AGGREGATE_MK_LOADED),) 2 | _THEOS_AGGREGATE_MK_LOADED := 1 3 | 4 | ifeq ($(THEOS_CURRENT_INSTANCE),) 5 | include $(THEOS_MAKE_PATH)/master/aggregate.mk 6 | endif 7 | endif 8 | -------------------------------------------------------------------------------- /theos/makefiles/application.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(THEOS_CURRENT_INSTANCE),) 2 | include $(THEOS_MAKE_PATH)/master/application.mk 3 | else 4 | ifeq ($(_THEOS_CURRENT_TYPE),application) 5 | include $(THEOS_MAKE_PATH)/instance/application.mk 6 | endif 7 | endif 8 | -------------------------------------------------------------------------------- /theos/makefiles/bundle.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(THEOS_CURRENT_INSTANCE),) 2 | include $(THEOS_MAKE_PATH)/master/bundle.mk 3 | else 4 | ifeq ($(_THEOS_CURRENT_TYPE),bundle) 5 | include $(THEOS_MAKE_PATH)/instance/bundle.mk 6 | endif 7 | endif 8 | -------------------------------------------------------------------------------- /theos/makefiles/framework.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(THEOS_CURRENT_INSTANCE),) 2 | include $(THEOS_MAKE_PATH)/master/framework.mk 3 | else 4 | ifeq ($(_THEOS_CURRENT_TYPE),framework) 5 | include $(THEOS_MAKE_PATH)/instance/framework.mk 6 | endif 7 | endif 8 | -------------------------------------------------------------------------------- /theos/makefiles/install/deb_local.mk: -------------------------------------------------------------------------------- 1 | internal-install:: 2 | @if [ -z "$(_THEOS_PACKAGE_LAST_FILENAME)" ]; then \ 3 | echo "$(MAKE) install requires that you build a package before you try to install it." >&2; \ 4 | exit 1; \ 5 | fi 6 | @if [ ! -f "$(_THEOS_PACKAGE_LAST_FILENAME)" ]; then \ 7 | echo "Could not find \"$(_THEOS_PACKAGE_LAST_FILENAME)\" to install. Aborting." >&2; \ 8 | exit 1; \ 9 | fi 10 | install.exec "dpkg -i \"$(_THEOS_PACKAGE_LAST_FILENAME)\"" 11 | -------------------------------------------------------------------------------- /theos/makefiles/install/deb_remote.mk: -------------------------------------------------------------------------------- 1 | internal-install:: 2 | @if [ -z "$(_THEOS_PACKAGE_LAST_FILENAME)" ]; then \ 3 | echo "$(MAKE) install requires that you build a package before you try to install it." >&2; \ 4 | exit 1; \ 5 | fi 6 | @if [ ! -f "$(_THEOS_PACKAGE_LAST_FILENAME)" ]; then \ 7 | echo "Could not find \"$(_THEOS_PACKAGE_LAST_FILENAME)\" to install. Aborting." >&2; \ 8 | exit 1; \ 9 | fi 10 | install.exec "cat > /tmp/_theos_install.deb; dpkg -i /tmp/_theos_install.deb && rm /tmp/_theos_install.deb" < "$(_THEOS_PACKAGE_LAST_FILENAME)" 11 | -------------------------------------------------------------------------------- /theos/makefiles/install/none_local.mk: -------------------------------------------------------------------------------- 1 | internal-install:: stage 2 | install.mergeDir "$(THEOS_STAGING_DIR)" "/" 3 | -------------------------------------------------------------------------------- /theos/makefiles/install/none_remote.mk: -------------------------------------------------------------------------------- 1 | none_local.mk -------------------------------------------------------------------------------- /theos/makefiles/instance/application.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(_THEOS_RULES_LOADED),) 2 | include $(THEOS_MAKE_PATH)/rules.mk 3 | endif 4 | 5 | .PHONY: internal-application-all_ internal-application-stage_ internal-application-compile 6 | 7 | ifeq ($(findstring UIKit,$($(THEOS_CURRENT_INSTANCE)_FRAMEWORKS))$(findstring AppKit,$($(THEOS_CURRENT_INSTANCE)_FRAMEWORKS)),) 8 | _THEOS_INTERNAL_LDFLAGS += -framework UIKit 9 | ifeq ($(_THEOS_APPLICATION_WARNED_IMPLICIT_UIKIT_$(THEOS_CURRENT_INSTANCE)),) 10 | internal-application-all_:: 11 | @echo "$(THEOS_CURRENT_INSTANCE): warning: Implicit UIKit linkage for application instances is deprecated. Please add \"UIKit\" to $(THEOS_CURRENT_INSTANCE)_FRAMEWORKS." >&2 12 | export _THEOS_APPLICATION_WARNED_IMPLICIT_UIKIT_$(THEOS_CURRENT_INSTANCE) = 1 13 | endif 14 | endif 15 | 16 | # Bundle Setup 17 | LOCAL_INSTALL_PATH ?= $(strip $($(THEOS_CURRENT_INSTANCE)_INSTALL_PATH)) 18 | ifeq ($(LOCAL_INSTALL_PATH),) 19 | LOCAL_INSTALL_PATH = /Applications 20 | endif 21 | 22 | ifeq ($($(THEOS_CURRENT_INSTANCE)_BUNDLE_NAME),) 23 | LOCAL_BUNDLE_NAME = $(THEOS_CURRENT_INSTANCE) 24 | else 25 | LOCAL_BUNDLE_NAME = $($(THEOS_CURRENT_INSTANCE)_BUNDLE_NAME) 26 | endif 27 | 28 | _LOCAL_BUNDLE_FULL_NAME = $(LOCAL_BUNDLE_NAME).app 29 | _THEOS_SHARED_BUNDLE_BUILD_PATH = $(THEOS_OBJ_DIR)/$(_LOCAL_BUNDLE_FULL_NAME) 30 | _THEOS_SHARED_BUNDLE_STAGE_PATH = $(THEOS_STAGING_DIR)$(LOCAL_INSTALL_PATH)/$(_LOCAL_BUNDLE_FULL_NAME) 31 | _LOCAL_INSTANCE_TARGET := $(_LOCAL_BUNDLE_FULL_NAME)$(_THEOS_TARGET_BUNDLE_BINARY_SUBDIRECTORY)/$(THEOS_CURRENT_INSTANCE)$(TARGET_EXE_EXT) 32 | include $(THEOS_MAKE_PATH)/instance/shared/bundle.mk 33 | # End Bundle Setup 34 | 35 | ifeq ($(_THEOS_MAKE_PARALLEL_BUILDING), no) 36 | internal-application-all_:: $(_OBJ_DIR_STAMPS) shared-instance-bundle-all $(THEOS_OBJ_DIR)/$(_LOCAL_INSTANCE_TARGET) 37 | else 38 | internal-application-all_:: $(_OBJ_DIR_STAMPS) shared-instance-bundle-all 39 | $(ECHO_NOTHING)$(MAKE) -f $(_THEOS_PROJECT_MAKEFILE_NAME) --no-print-directory --no-keep-going \ 40 | internal-application-compile \ 41 | _THEOS_CURRENT_TYPE=$(_THEOS_CURRENT_TYPE) THEOS_CURRENT_INSTANCE=$(THEOS_CURRENT_INSTANCE) _THEOS_CURRENT_OPERATION=compile \ 42 | THEOS_BUILD_DIR="$(THEOS_BUILD_DIR)" _THEOS_MAKE_PARALLEL=yes$(ECHO_END) 43 | 44 | internal-application-compile: $(THEOS_OBJ_DIR)/$(_LOCAL_INSTANCE_TARGET) 45 | endif 46 | 47 | $(eval $(call _THEOS_TEMPLATE_DEFAULT_LINKING_RULE,$(_LOCAL_INSTANCE_TARGET))) 48 | 49 | internal-application-stage_:: shared-instance-bundle-stage 50 | 51 | $(eval $(call __mod,instance/application.mk)) 52 | -------------------------------------------------------------------------------- /theos/makefiles/instance/bundle.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(_THEOS_RULES_LOADED),) 2 | include $(THEOS_MAKE_PATH)/rules.mk 3 | endif 4 | 5 | .PHONY: internal-bundle-all_ internal-bundle-stage_ internal-bundle-compile 6 | 7 | _THEOS_INTERNAL_LDFLAGS += -dynamiclib 8 | 9 | # Bundle Setup 10 | LOCAL_BUNDLE_NAME = $(or $($(THEOS_CURRENT_INSTANCE)_BUNDLE_NAME),$(THEOS_CURRENT_INSTANCE)) 11 | LOCAL_BUNDLE_EXTENSION = $(or $($(THEOS_CURRENT_INSTANCE)_BUNDLE_EXTENSION),bundle) 12 | 13 | _LOCAL_BUNDLE_FULL_NAME = $(LOCAL_BUNDLE_NAME).$(LOCAL_BUNDLE_EXTENSION) 14 | _THEOS_SHARED_BUNDLE_BUILD_PATH = $(THEOS_OBJ_DIR)/$(_LOCAL_BUNDLE_FULL_NAME) 15 | _THEOS_SHARED_BUNDLE_STAGE_PATH = $(THEOS_STAGING_DIR)$($(THEOS_CURRENT_INSTANCE)_INSTALL_PATH)/$(_LOCAL_BUNDLE_FULL_NAME) 16 | _LOCAL_INSTANCE_TARGET := $(_LOCAL_BUNDLE_FULL_NAME)$(_THEOS_TARGET_BUNDLE_BINARY_SUBDIRECTORY)/$(THEOS_CURRENT_INSTANCE)$(TARGET_EXE_EXT) 17 | include $(THEOS_MAKE_PATH)/instance/shared/bundle.mk 18 | # End Bundle Setup 19 | 20 | ifeq ($(_THEOS_MAKE_PARALLEL_BUILDING), no) 21 | internal-bundle-all_:: $(_OBJ_DIR_STAMPS) shared-instance-bundle-all $(THEOS_OBJ_DIR)/$(_LOCAL_INSTANCE_TARGET) 22 | else 23 | internal-bundle-all_:: $(_OBJ_DIR_STAMPS) shared-instance-bundle-all 24 | $(ECHO_NOTHING)$(MAKE) -f $(_THEOS_PROJECT_MAKEFILE_NAME) --no-print-directory --no-keep-going \ 25 | internal-bundle-compile \ 26 | _THEOS_CURRENT_TYPE=$(_THEOS_CURRENT_TYPE) THEOS_CURRENT_INSTANCE=$(THEOS_CURRENT_INSTANCE) _THEOS_CURRENT_OPERATION=compile \ 27 | THEOS_BUILD_DIR="$(THEOS_BUILD_DIR)" _THEOS_MAKE_PARALLEL=yes$(ECHO_END) 28 | 29 | internal-bundle-compile: $(THEOS_OBJ_DIR)/$(_LOCAL_INSTANCE_TARGET) 30 | endif 31 | 32 | ifneq ($(OBJ_FILES_TO_LINK),) 33 | 34 | $(eval $(call _THEOS_TEMPLATE_DEFAULT_LINKING_RULE,$(_LOCAL_INSTANCE_TARGET),nowarn)) 35 | 36 | else # OBJ_FILES_TO_LINK == "" 37 | 38 | $(THEOS_OBJ_DIR)/$(_LOCAL_INSTANCE_TARGET): 39 | $(NOTICE_EMPTY_LINKING) 40 | 41 | endif # OBJ_FILES_TO_LINK 42 | 43 | internal-bundle-stage_:: shared-instance-bundle-stage 44 | 45 | $(eval $(call __mod,instance/bundle.mk)) 46 | -------------------------------------------------------------------------------- /theos/makefiles/instance/framework.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(_THEOS_RULES_LOADED),) 2 | include $(THEOS_MAKE_PATH)/rules.mk 3 | endif 4 | 5 | .PHONY: internal-framework-all_ internal-framework-stage_ internal-framework-compile 6 | 7 | 8 | # Bundle Setup 9 | LOCAL_INSTALL_PATH ?= $(or $(strip $($(THEOS_CURRENT_INSTANCE)_INSTALL_PATH)),/Library/Frameworks) 10 | LOCAL_BUNDLE_NAME = $(or $($(THEOS_CURRENT_INSTANCE)_BUNDLE_NAME),$($(THEOS_CURRENT_INSTANCE)_FRAMEWORK_NAME),$(THEOS_CURRENT_INSTANCE)) 11 | 12 | _LOCAL_BUNDLE_FULL_NAME = $(LOCAL_BUNDLE_NAME).framework 13 | _THEOS_SHARED_BUNDLE_BUILD_PATH = $(THEOS_OBJ_DIR)/$(_LOCAL_BUNDLE_FULL_NAME) 14 | _THEOS_SHARED_BUNDLE_STAGE_PATH = $(THEOS_STAGING_DIR)$(LOCAL_INSTALL_PATH)/$(_LOCAL_BUNDLE_FULL_NAME) 15 | _LOCAL_INSTANCE_TARGET := $(_LOCAL_BUNDLE_FULL_NAME)$(_THEOS_TARGET_BUNDLE_BINARY_SUBDIRECTORY)/$(THEOS_CURRENT_INSTANCE) 16 | include $(THEOS_MAKE_PATH)/instance/shared/bundle.mk 17 | # End Bundle Setup 18 | 19 | _THEOS_INTERNAL_LDFLAGS += -dynamiclib -install_name "$(LOCAL_INSTALL_PATH)/$(_LOCAL_INSTANCE_TARGET)" 20 | 21 | ifeq ($(_THEOS_MAKE_PARALLEL_BUILDING), no) 22 | internal-framework-all_:: $(_OBJ_DIR_STAMPS) shared-instance-bundle-all $(THEOS_OBJ_DIR)/$(_LOCAL_INSTANCE_TARGET) 23 | else 24 | internal-framework-all_:: $(_OBJ_DIR_STAMPS) shared-instance-bundle-all 25 | $(ECHO_NOTHING)$(MAKE) -f $(_THEOS_PROJECT_MAKEFILE_NAME) --no-print-directory --no-keep-going \ 26 | internal-framework-compile \ 27 | _THEOS_CURRENT_TYPE=$(_THEOS_CURRENT_TYPE) THEOS_CURRENT_INSTANCE=$(THEOS_CURRENT_INSTANCE) _THEOS_CURRENT_OPERATION=compile \ 28 | THEOS_BUILD_DIR="$(THEOS_BUILD_DIR)" _THEOS_MAKE_PARALLEL=yes$(ECHO_END) 29 | 30 | internal-framework-compile: $(THEOS_OBJ_DIR)/$(_LOCAL_INSTANCE_TARGET) 31 | endif 32 | 33 | $(eval $(call _THEOS_TEMPLATE_DEFAULT_LINKING_RULE,$(_LOCAL_INSTANCE_TARGET))) 34 | 35 | internal-framework-stage_:: shared-instance-bundle-stage 36 | 37 | $(eval $(call __mod,instance/framework.mk)) 38 | -------------------------------------------------------------------------------- /theos/makefiles/instance/library.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(_THEOS_RULES_LOADED),) 2 | include $(THEOS_MAKE_PATH)/rules.mk 3 | endif 4 | 5 | .PHONY: internal-library-all_ internal-library-stage_ internal-library-compile 6 | 7 | LOCAL_INSTALL_PATH ?= $(strip $($(THEOS_CURRENT_INSTANCE)_INSTALL_PATH)) 8 | ifeq ($(LOCAL_INSTALL_PATH),) 9 | LOCAL_INSTALL_PATH = /usr/lib 10 | endif 11 | 12 | _THEOS_INTERNAL_LDFLAGS += $(call TARGET_LDFLAGS_DYNAMICLIB,$(THEOS_CURRENT_INSTANCE)$(TARGET_LIB_EXT)) 13 | _THEOS_INTERNAL_CFLAGS += $(TARGET_CFLAGS_DYNAMICLIB) 14 | 15 | ifeq ($(_THEOS_MAKE_PARALLEL_BUILDING), no) 16 | internal-library-all_:: $(_OBJ_DIR_STAMPS) $(THEOS_OBJ_DIR)/$(THEOS_CURRENT_INSTANCE)$(TARGET_LIB_EXT) 17 | else 18 | internal-library-all_:: $(_OBJ_DIR_STAMPS) 19 | $(ECHO_NOTHING)$(MAKE) -f $(_THEOS_PROJECT_MAKEFILE_NAME) --no-print-directory --no-keep-going \ 20 | internal-library-compile \ 21 | _THEOS_CURRENT_TYPE=$(_THEOS_CURRENT_TYPE) THEOS_CURRENT_INSTANCE=$(THEOS_CURRENT_INSTANCE) _THEOS_CURRENT_OPERATION=compile \ 22 | THEOS_BUILD_DIR="$(THEOS_BUILD_DIR)" _THEOS_MAKE_PARALLEL=yes$(ECHO_END) 23 | 24 | internal-library-compile: $(THEOS_OBJ_DIR)/$(THEOS_CURRENT_INSTANCE)$(TARGET_LIB_EXT) 25 | endif 26 | 27 | $(eval $(call _THEOS_TEMPLATE_DEFAULT_LINKING_RULE,$(THEOS_CURRENT_INSTANCE)$(TARGET_LIB_EXT))) 28 | 29 | internal-library-stage_:: 30 | $(ECHO_NOTHING)mkdir -p "$(THEOS_STAGING_DIR)$(LOCAL_INSTALL_PATH)/"$(ECHO_END) 31 | $(ECHO_NOTHING)cp $(THEOS_OBJ_DIR)/$(THEOS_CURRENT_INSTANCE)$(TARGET_LIB_EXT) "$(THEOS_STAGING_DIR)$(LOCAL_INSTALL_PATH)/"$(ECHO_END) 32 | 33 | $(eval $(call __mod,instance/library.mk)) 34 | -------------------------------------------------------------------------------- /theos/makefiles/instance/null.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(_THEOS_RULES_LOADED),) 2 | include $(THEOS_MAKE_PATH)/rules.mk 3 | endif 4 | 5 | .PHONY: internal-null-all_ internal-null-stage_ 6 | 7 | internal-null-all_:: 8 | 9 | internal-null-stage_:: 10 | 11 | $(eval $(call __mod,instance/null.mk)) 12 | -------------------------------------------------------------------------------- /theos/makefiles/instance/shared/bundle.mk: -------------------------------------------------------------------------------- 1 | # Input Variables 2 | # THEOS_SHARED_BUNDLE_INSTALL_NAME: bundle name and extension 3 | # THEOS_SHARED_BUNDLE_INSTALL_PATH: bundle install path 4 | # _THEOS_SHARED_BUNDLE_STAGE_PATH: bundle resource path (typically just INSTALL_PATH/INSTALL_NAME) 5 | # 6 | # Instance Variables: 7 | # xxx_RESOURCE_FILES: list of resource files to install (why would you use this in favour of xxx_RESOURCE_DIRS? eh.) 8 | # xxx_RESOURCE_DIRS: folders to copy resources from 9 | # note a deviation from gnustep-make's xxx_RESOURCE_DIRS which simply specifies resource subdirectories to create 10 | # defaults to Resources/ if it exists. 11 | 12 | .PHONY: shared-instance-bundle-stage 13 | 14 | ifeq ($(_THEOS_CURRENT_OPERATION),stage) 15 | THEOS_SHARED_BUNDLE_BINARY_PATH = $(_THEOS_SHARED_BUNDLE_STAGE_PATH)/$(_THEOS_TARGET_BUNDLE_BINARY_SUBDIRECTORY) 16 | THEOS_SHARED_BUNDLE_RESOURCE_PATH = $(_THEOS_SHARED_BUNDLE_STAGE_PATH)/$(_THEOS_TARGET_BUNDLE_RESOURCE_SUBDIRECTORY) 17 | else 18 | THEOS_SHARED_BUNDLE_BINARY_PATH = $(_THEOS_SHARED_BUNDLE_BUILD_PATH)/$(_THEOS_TARGET_BUNDLE_BINARY_SUBDIRECTORY) 19 | THEOS_SHARED_BUNDLE_RESOURCE_PATH = $(_THEOS_SHARED_BUNDLE_BUILD_PATH)/$(_THEOS_TARGET_BUNDLE_RESOURCE_SUBDIRECTORY) 20 | endif 21 | 22 | $(_THEOS_SHARED_BUNDLE_BUILD_PATH)/$(_THEOS_TARGET_BUNDLE_BINARY_SUBDIRECTORY) $(_THEOS_SHARED_BUNDLE_BUILD_PATH)/$(_THEOS_TARGET_BUNDLE_RESOURCE_SUBDIRECTORY) $(_THEOS_SHARED_BUNDLE_BUILD_PATH)/$(_THEOS_TARGET_BUNDLE_INFO_PLIST_SUBDIRECTORY):: 23 | $(ECHO_NOTHING)mkdir -p "$@"$(ECHO_END) 24 | 25 | _RESOURCE_FILES := $(or $($(THEOS_CURRENT_INSTANCE)_BUNDLE_RESOURCES),$($(THEOS_CURRENT_INSTANCE)_RESOURCE_FILES)) 26 | _RESOURCE_DIRS := $(or $($(THEOS_CURRENT_INSTANCE)_BUNDLE_RESOURCE_DIRS),$($(THEOS_CURRENT_INSTANCE)_RESOURCE_DIRS)) 27 | ifeq ($(_RESOURCE_DIRS),) 28 | ifeq ($(call __exists,Resources),$(_THEOS_TRUE)) 29 | _RESOURCE_DIRS := Resources 30 | else 31 | _RESOURCE_DIRS := 32 | endif 33 | endif 34 | 35 | shared-instance-bundle-all:: $(_THEOS_SHARED_BUNDLE_BUILD_PATH)/$(_THEOS_TARGET_BUNDLE_BINARY_SUBDIRECTORY) $(_THEOS_SHARED_BUNDLE_BUILD_PATH)/$(_THEOS_TARGET_BUNDLE_RESOURCE_SUBDIRECTORY) $(_THEOS_SHARED_BUNDLE_BUILD_PATH)/$(_THEOS_TARGET_BUNDLE_INFO_PLIST_SUBDIRECTORY) 36 | ifneq ($(_RESOURCE_FILES),) 37 | $(ECHO_COPYING_RESOURCE_FILES)for f in $(_RESOURCE_FILES); do \ 38 | if [ -f "$$f" -o -d "$$f" ]; then \ 39 | rsync -a "$$f" "$(_THEOS_SHARED_BUNDLE_BUILD_PATH)$(_THEOS_TARGET_BUNDLE_RESOURCE_SUBDIRECTORY)/" $(_THEOS_RSYNC_EXCLUDE_COMMANDLINE); \ 40 | else \ 41 | echo "Warning: ignoring missing bundle resource $$f."; \ 42 | fi; \ 43 | done$(ECHO_END) 44 | endif 45 | ifneq ($(_RESOURCE_DIRS),) 46 | $(ECHO_COPYING_RESOURCE_DIRS)for d in $(_RESOURCE_DIRS); do \ 47 | if [ -d "$$d" ]; then \ 48 | rsync -a "$$d/" "$(_THEOS_SHARED_BUNDLE_BUILD_PATH)$(_THEOS_TARGET_BUNDLE_RESOURCE_SUBDIRECTORY)/" $(_THEOS_RSYNC_EXCLUDE_COMMANDLINE); \ 49 | else \ 50 | echo "Warning: ignoring missing bundle resource directory $$d."; \ 51 | fi; \ 52 | done$(ECHO_END) 53 | endif 54 | ifneq ($(_THEOS_TARGET_BUNDLE_INFO_PLIST_SUBDIRECTORY),$(_THEOS_TARGET_BUNDLE_RESOURCE_SUBDIRECTORY)) 55 | $(ECHO_NOTHING)if [ -f "$(_THEOS_SHARED_BUNDLE_BUILD_PATH)$(_THEOS_TARGET_BUNDLE_RESOURCE_SUBDIRECTORY)/Info.plist" ]; then\ 56 | mv "$(_THEOS_SHARED_BUNDLE_BUILD_PATH)$(_THEOS_TARGET_BUNDLE_RESOURCE_SUBDIRECTORY)/Info.plist" "$(_THEOS_SHARED_BUNDLE_BUILD_PATH)$(_THEOS_TARGET_BUNDLE_INFO_PLIST_SUBDIRECTORY)/Info.plist";\ 57 | fi$(ECHO_END) 58 | endif 59 | 60 | shared-instance-bundle-stage:: 61 | $(ECHO_NOTHING)mkdir -p "$(_THEOS_SHARED_BUNDLE_STAGE_PATH)"$(ECHO_END) 62 | $(ECHO_NOTHING)rsync -a "$(_THEOS_SHARED_BUNDLE_BUILD_PATH)/" "$(_THEOS_SHARED_BUNDLE_STAGE_PATH)"$(ECHO_END) 63 | -------------------------------------------------------------------------------- /theos/makefiles/instance/subproject.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(_THEOS_RULES_LOADED),) 2 | include $(THEOS_MAKE_PATH)/rules.mk 3 | endif 4 | 5 | .PHONY: internal-subproject-all_ internal-subproject-stage_ internal-subproject-compile 6 | 7 | ifeq ($(_THEOS_MAKE_PARALLEL_BUILDING), no) 8 | internal-subproject-all_:: $(_OBJ_DIR_STAMPS) $(THEOS_OBJ_DIR)/$(THEOS_CURRENT_INSTANCE).$(THEOS_SUBPROJECT_PRODUCT) 9 | else 10 | internal-subproject-all_:: $(_OBJ_DIR_STAMPS) 11 | $(ECHO_NOTHING)$(MAKE) -f $(_THEOS_PROJECT_MAKEFILE_NAME) --no-print-directory --no-keep-going \ 12 | internal-subproject-compile \ 13 | _THEOS_CURRENT_TYPE=$(_THEOS_CURRENT_TYPE) THEOS_CURRENT_INSTANCE=$(THEOS_CURRENT_INSTANCE) _THEOS_CURRENT_OPERATION=compile \ 14 | THEOS_BUILD_DIR="$(THEOS_BUILD_DIR)" _THEOS_MAKE_PARALLEL=yes$(ECHO_END) 15 | 16 | internal-subproject-compile: $(THEOS_OBJ_DIR)/$(THEOS_CURRENT_INSTANCE).$(THEOS_SUBPROJECT_PRODUCT) 17 | endif 18 | 19 | $(THEOS_OBJ_DIR)/$(THEOS_CURRENT_INSTANCE).$(THEOS_SUBPROJECT_PRODUCT): $(OBJ_FILES_TO_LINK) 20 | $(ECHO_LINKING)$(TARGET_LD) -nostdlib -r -d $(ADDITIONAL_LDFLAGS) $(_THEOS_TARGET_LDFLAGS) $(LDFLAGS) -o $@ $^$(ECHO_END) 21 | @echo "$(_THEOS_INTERNAL_LDFLAGS)" > $(THEOS_OBJ_DIR)/$(THEOS_CURRENT_INSTANCE).ldflags 22 | 23 | $(eval $(call __mod,instance/subproject.mk)) 24 | -------------------------------------------------------------------------------- /theos/makefiles/instance/tool.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(_THEOS_RULES_LOADED),) 2 | include $(THEOS_MAKE_PATH)/rules.mk 3 | endif 4 | 5 | .PHONY: internal-tool-all_ internal-tool-stage_ internal-tool-compile 6 | 7 | ifeq ($(_THEOS_MAKE_PARALLEL_BUILDING), no) 8 | internal-tool-all_:: $(_OBJ_DIR_STAMPS) $(THEOS_OBJ_DIR)/$(THEOS_CURRENT_INSTANCE)$(TARGET_EXE_EXT) 9 | else 10 | internal-tool-all_:: $(_OBJ_DIR_STAMPS) 11 | $(ECHO_NOTHING)$(MAKE) -f $(_THEOS_PROJECT_MAKEFILE_NAME) --no-print-directory --no-keep-going \ 12 | internal-tool-compile \ 13 | _THEOS_CURRENT_TYPE=$(_THEOS_CURRENT_TYPE) THEOS_CURRENT_INSTANCE=$(THEOS_CURRENT_INSTANCE) _THEOS_CURRENT_OPERATION=compile \ 14 | THEOS_BUILD_DIR="$(THEOS_BUILD_DIR)" _THEOS_MAKE_PARALLEL=yes$(ECHO_END) 15 | 16 | internal-tool-compile: $(THEOS_OBJ_DIR)/$(THEOS_CURRENT_INSTANCE)$(TARGET_EXE_EXT) 17 | endif 18 | 19 | $(eval $(call _THEOS_TEMPLATE_DEFAULT_LINKING_RULE,$(THEOS_CURRENT_INSTANCE)$(TARGET_EXE_EXT))) 20 | 21 | LOCAL_INSTALL_PATH = $(strip $($(THEOS_CURRENT_INSTANCE)_INSTALL_PATH)) 22 | ifeq ($(LOCAL_INSTALL_PATH),) 23 | LOCAL_INSTALL_PATH = $($(THEOS_CURRENT_INSTANCE)_PACKAGE_TARGET_DIR) 24 | ifeq ($(LOCAL_INSTALL_PATH),) 25 | LOCAL_INSTALL_PATH = /usr/bin 26 | endif 27 | endif 28 | 29 | internal-tool-stage_:: 30 | $(ECHO_NOTHING)mkdir -p "$(THEOS_STAGING_DIR)$(LOCAL_INSTALL_PATH)"$(ECHO_END) 31 | $(ECHO_NOTHING)cp $(THEOS_OBJ_DIR)/$(THEOS_CURRENT_INSTANCE)$(TARGET_EXE_EXT) "$(THEOS_STAGING_DIR)$(LOCAL_INSTALL_PATH)"$(ECHO_END) 32 | 33 | $(eval $(call __mod,instance/tool.mk)) 34 | -------------------------------------------------------------------------------- /theos/makefiles/instance/tweak.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(_THEOS_RULES_LOADED),) 2 | include $(THEOS_MAKE_PATH)/rules.mk 3 | endif 4 | 5 | .PHONY: internal-tweak-all_ internal-tweak-stage_ 6 | 7 | LOCAL_INSTALL_PATH ?= $(strip $($(THEOS_CURRENT_INSTANCE)_INSTALL_PATH)) 8 | ifeq ($(LOCAL_INSTALL_PATH),) 9 | LOCAL_INSTALL_PATH = /Library/MobileSubstrate/DynamicLibraries 10 | endif 11 | 12 | _THEOS_INTERNAL_LDFLAGS += -lsubstrate 13 | 14 | include $(THEOS_MAKE_PATH)/instance/library.mk 15 | 16 | internal-tweak-all_:: internal-library-all_ 17 | 18 | ifneq ($(strip $($(THEOS_CURRENT_INSTANCE)_BUNDLE_RESOURCE_DIRS) $($(THEOS_CURRENT_INSTANCE)_BUNDLE_RESOURCE_FILES)),) 19 | _LOCAL_BUNDLE_INSTALL_PATH = $(or $($(THEOS_CURRENT_INSTANCE)_BUNDLE_INSTALL_PATH),/Library/Application Support/$(THEOS_CURRENT_INSTANCE)) 20 | _LOCAL_BUNDLE_NAME = $(or $($(THEOS_CURRENT_INSTANCE)_BUNDLE_NAME),$(THEOS_CURRENT_INSTANCE)) 21 | _LOCAL_BUNDLE_EXTENSION = $(or $($(THEOS_CURRENT_INSTANCE)_BUNDLE_EXTENSION),bundle) 22 | 23 | _THEOS_SHARED_BUNDLE_BUILD_PATH = $(THEOS_OBJ_DIR)/$(_LOCAL_BUNDLE_NAME).$(_LOCAL_BUNDLE_EXTENSION) 24 | _THEOS_SHARED_BUNDLE_STAGE_PATH = $(THEOS_STAGING_DIR)$(_LOCAL_BUNDLE_INSTALL_PATH)/$(_LOCAL_BUNDLE_NAME).$(_LOCAL_BUNDLE_EXTENSION) 25 | include $(THEOS_MAKE_PATH)/instance/shared/bundle.mk 26 | 27 | internal-tweak-all_:: shared-instance-bundle-all 28 | internal-tweak-stage_:: shared-instance-bundle-stage 29 | endif 30 | 31 | internal-tweak-stage_:: $(_EXTRA_TARGET) internal-library-stage_ 32 | $(ECHO_NOTHING)if [ -f $(THEOS_CURRENT_INSTANCE).plist ]; then cp $(THEOS_CURRENT_INSTANCE).plist "$(THEOS_STAGING_DIR)$(LOCAL_INSTALL_PATH)/"; fi$(ECHO_END) 33 | 34 | $(eval $(call __mod,instance/tweak.mk)) 35 | -------------------------------------------------------------------------------- /theos/makefiles/legacy.mk: -------------------------------------------------------------------------------- 1 | FRAMEWORKDIR = $(THEOS) 2 | FW_BINDIR = $(THEOS_BIN_PATH) 3 | FW_MAKEDIR = $(THEOS_MAKE_PATH) 4 | FW_INCDIR = $(THEOS_INCLUDE_PATH) 5 | FW_LIBDIR = $(THEOS_LIBRARY_PATH) 6 | FW_MODDIR = $(THEOS_MODULE_PATH) 7 | 8 | FW_PROJECT_DIR = $(THEOS_PROJECT_DIR) 9 | 10 | export FRAMEWORKDIR FW_BINDIR FW_MAKEDIR FW_INCDIR FW_LIBDIR FW_MODDIR 11 | export FW_PROJECT_DIR 12 | 13 | FW_PLATFORM_NAME = $(THEOS_PLATFORM_NAME) 14 | FW_TARGET_NAME = $(THEOS_TARGET_NAME) 15 | 16 | FW_STAGING_DIR = $(THEOS_STAGING_DIR) 17 | 18 | ifneq ($(FW_BUILD_DIR),) 19 | THEOS_BUILD_DIR ?= $(FW_BUILD_DIR) 20 | else 21 | FW_BUILD_DIR = $(THEOS_BUILD_DIR) 22 | endif 23 | 24 | ifneq ($(FW_OBJ_DIR_NAME),) 25 | THEOS_OBJ_DIR_NAME ?= $(FW_OBJ_DIR_NAME) 26 | endif 27 | 28 | FW_OBJ_DIR = $(THEOS_OBJ_DIR) 29 | 30 | ifneq ($(FW_SUBPROJECT_PRODUCT),) 31 | THEOS_SUBPROJECT_PRODUCT ?= $(FW_SUBPROJECT_PRODUCT) 32 | else 33 | FW_SUBPROJECT_PRODUCT = $(THEOS_SUBPROJECT_PRODUCT) 34 | endif 35 | 36 | FW_INSTANCE = $(THEOS_CURRENT_INSTANCE) 37 | 38 | FW_SHARED_BUNDLE_RESOURCE_PATH = $(THEOS_SHARED_BUNDLE_RESOURCE_PATH) 39 | FW_PACKAGE_NAME = $(THEOS_PACKAGE_NAME) 40 | FW_PACKAGE_ARCH = $(THEOS_PACKAGE_ARCH) 41 | FW_PACKAGE_VERSION = $(THEOS_PACKAGE_BASE_VERSION) 42 | FW_PACKAGE_DEBVERSION = $(THEOS_PACKAGE_VERSION) 43 | FW_PACKAGE_FILENAME = $(THEOS_PACKAGE_FILENAME) 44 | 45 | ifneq ($(FW_DEVICE_IP),) 46 | THEOS_DEVICE_IP ?= $(FW_DEVICE_IP) 47 | endif 48 | 49 | ifneq ($(FW_DEVICE_PORT),) 50 | THEOS_DEVICE_PORT ?= $(FW_DEVICE_PORT) 51 | endif 52 | 53 | -------------------------------------------------------------------------------- /theos/makefiles/library.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(THEOS_CURRENT_INSTANCE),) 2 | include $(THEOS_MAKE_PATH)/master/library.mk 3 | else 4 | ifeq ($(_THEOS_CURRENT_TYPE),library) 5 | include $(THEOS_MAKE_PATH)/instance/library.mk 6 | endif 7 | endif 8 | -------------------------------------------------------------------------------- /theos/makefiles/master/aggregate.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(_THEOS_RULES_LOADED),) 2 | include $(THEOS_MAKE_PATH)/rules.mk 3 | endif 4 | 5 | SUBPROJECTS := $(strip $(call __schema_var_all,,SUBPROJECTS)) 6 | ifneq ($(SUBPROJECTS),) 7 | internal-all internal-clean:: _OPERATION = $(subst internal-,,$@) 8 | internal-stage internal-after-install:: _OPERATION = $@ 9 | internal-all internal-clean internal-stage internal-after-install:: _OPERATION_NAME = $(subst internal-,,$@) 10 | 11 | internal-all internal-clean internal-stage internal-after-install:: 12 | @abs_build_dir=$(_THEOS_ABSOLUTE_BUILD_DIR); \ 13 | for d in $(SUBPROJECTS); do \ 14 | echo "Making $(_OPERATION_NAME) in $$d..."; \ 15 | if [ "$${abs_build_dir}" = "." ]; then \ 16 | lbuilddir="."; \ 17 | else \ 18 | lbuilddir="$${abs_build_dir}/$$d"; \ 19 | fi; \ 20 | if $(MAKE) -C $$d -f $(_THEOS_PROJECT_MAKEFILE_NAME) $(_THEOS_NO_PRINT_DIRECTORY_FLAG) --no-keep-going $(_OPERATION) \ 21 | THEOS_BUILD_DIR="$$lbuilddir" \ 22 | ; then\ 23 | :; \ 24 | else exit $$?; \ 25 | fi; \ 26 | done; 27 | endif 28 | 29 | $(eval $(call __mod,master/aggregate.mk)) 30 | -------------------------------------------------------------------------------- /theos/makefiles/master/application.mk: -------------------------------------------------------------------------------- 1 | APPLICATION_NAME := $(strip $(APPLICATION_NAME)) 2 | 3 | ifeq ($(_THEOS_RULES_LOADED),) 4 | include $(THEOS_MAKE_PATH)/rules.mk 5 | endif 6 | 7 | internal-all:: $(APPLICATION_NAME:=.all.application.variables); 8 | 9 | internal-stage:: $(APPLICATION_NAME:=.stage.application.variables); 10 | 11 | # Maybe, disabled for further discussion 12 | # install.exec "uicache" 13 | internal-after-install:: 14 | 15 | APPLICATIONS_WITH_SUBPROJECTS = $(strip $(foreach application,$(APPLICATION_NAME),$(patsubst %,$(application),$(call __schema_var_all,$(application)_,SUBPROJECTS)))) 16 | ifneq ($(APPLICATIONS_WITH_SUBPROJECTS),) 17 | internal-clean:: $(APPLICATIONS_WITH_SUBPROJECTS:=.clean.application.subprojects) 18 | endif 19 | 20 | $(APPLICATION_NAME): 21 | @$(MAKE) -f $(_THEOS_PROJECT_MAKEFILE_NAME) --no-print-directory --no-keep-going $@.all.application.variables 22 | 23 | $(eval $(call __mod,master/application.mk)) 24 | -------------------------------------------------------------------------------- /theos/makefiles/master/bundle.mk: -------------------------------------------------------------------------------- 1 | BUNDLE_NAME := $(strip $(BUNDLE_NAME)) 2 | 3 | ifeq ($(_THEOS_RULES_LOADED),) 4 | include $(THEOS_MAKE_PATH)/rules.mk 5 | endif 6 | 7 | internal-all:: $(BUNDLE_NAME:=.all.bundle.variables); 8 | 9 | internal-stage:: $(BUNDLE_NAME:=.stage.bundle.variables); 10 | 11 | BUNDLES_WITH_SUBPROJECTS = $(strip $(foreach bundle,$(BUNDLE_NAME),$(patsubst %,$(bundle),$(call __schema_var_all,$(bundle)_,SUBPROJECTS)))) 12 | ifneq ($(BUNDLES_WITH_SUBPROJECTS),) 13 | internal-clean:: $(BUNDLES_WITH_SUBPROJECTS:=.clean.bundle.subprojects) 14 | endif 15 | 16 | $(BUNDLE_NAME): 17 | @$(MAKE) -f $(_THEOS_PROJECT_MAKEFILE_NAME) --no-print-directory --no-keep-going $@.all.bundle.variables 18 | 19 | $(eval $(call __mod,master/bundle.mk)) 20 | -------------------------------------------------------------------------------- /theos/makefiles/master/framework.mk: -------------------------------------------------------------------------------- 1 | FRAMEWORK_NAME := $(strip $(FRAMEWORK_NAME)) 2 | 3 | ifeq ($(_THEOS_RULES_LOADED),) 4 | include $(THEOS_MAKE_PATH)/rules.mk 5 | endif 6 | 7 | internal-all:: $(FRAMEWORK_NAME:=.all.framework.variables); 8 | 9 | internal-stage:: $(FRAMEWORK_NAME:=.stage.framework.variables); 10 | 11 | FRAMEWORKS_WITH_SUBPROJECTS = $(strip $(foreach framework,$(FRAMEWORK_NAME),$(patsubst %,$(framework),$(call __schema_var_all,$(framework)_,SUBPROJECTS)))) 12 | ifneq ($(FRAMEWORKS_WITH_SUBPROJECTS),) 13 | internal-clean:: $(FRAMEWORKS_WITH_SUBPROJECTS:=.clean.framework.subprojects) 14 | endif 15 | 16 | $(FRAMEWORK_NAME): 17 | @$(MAKE) -f $(_THEOS_PROJECT_MAKEFILE_NAME) --no-print-directory --no-keep-going $@.all.framework.variables 18 | 19 | $(eval $(call __mod,master/framework.mk)) 20 | -------------------------------------------------------------------------------- /theos/makefiles/master/library.mk: -------------------------------------------------------------------------------- 1 | LIBRARY_NAME := $(strip $(LIBRARY_NAME)) 2 | 3 | ifeq ($(_THEOS_RULES_LOADED),) 4 | include $(THEOS_MAKE_PATH)/rules.mk 5 | endif 6 | 7 | internal-all:: $(LIBRARY_NAME:=.all.library.variables); 8 | 9 | internal-stage:: $(LIBRARY_NAME:=.stage.library.variables); 10 | 11 | LIBRARYS_WITH_SUBPROJECTS = $(strip $(foreach library,$(LIBRARY_NAME),$(patsubst %,$(library),$(call __schema_var_all,$(library)_,SUBPROJECTS)))) 12 | ifneq ($(LIBRARYS_WITH_SUBPROJECTS),) 13 | internal-clean:: $(LIBRARYS_WITH_SUBPROJECTS:=.clean.library.subprojects) 14 | endif 15 | 16 | $(LIBRARY_NAME): 17 | @$(MAKE) -f $(_THEOS_PROJECT_MAKEFILE_NAME) --no-print-directory --no-keep-going $@.all.library.variables 18 | 19 | $(eval $(call __mod,master/library.mk)) 20 | -------------------------------------------------------------------------------- /theos/makefiles/master/null.mk: -------------------------------------------------------------------------------- 1 | NULL_NAME := $(strip $(NULL_NAME)) 2 | 3 | ifeq ($(_THEOS_RULES_LOADED),) 4 | include $(THEOS_MAKE_PATH)/rules.mk 5 | endif 6 | 7 | internal-all:: $(NULL_NAME:=.all.null.variables); 8 | 9 | internal-stage:: $(NULL_NAME:=.stage.null.variables); 10 | 11 | NULLS_WITH_SUBPROJECTS = $(strip $(foreach null,$(NULL_NAME),$(patsubst %,$(null),$(call __schema_var_all,$(null)_,SUBPROJECTS)))) 12 | ifneq ($(NULLS_WITH_SUBPROJECTS),) 13 | internal-clean:: $(NULLS_WITH_SUBPROJECTS:=.clean.null.subprojects) 14 | endif 15 | 16 | $(NULL_NAME): 17 | @$(MAKE) -f $(_THEOS_PROJECT_MAKEFILE_NAME) --no-print-directory --no-keep-going $@.all.null.variables 18 | 19 | $(eval $(call __mod,master/null.mk)) 20 | -------------------------------------------------------------------------------- /theos/makefiles/master/rules.mk: -------------------------------------------------------------------------------- 1 | __THEOS_RULES_MK_VERSION := 1 2 | ifneq ($(__THEOS_RULES_MK_VERSION),$(__THEOS_COMMON_MK_VERSION)) 3 | all:: 4 | @echo Theos version mismatch! common.mk [version $(or $(__THEOS_COMMON_MK_VERSION),0)] loaded in tandem with rules.mk [version $(or $(__THEOS_RULES_MK_VERSION),0)] Check that \$$\(THEOS\) is set properly! 5 | @exit 1 6 | endif 7 | 8 | .PHONY: all before-all internal-all after-all \ 9 | clean before-clean internal-clean after-clean 10 | ifeq ($(THEOS_BUILD_DIR),.) 11 | all:: before-all internal-all after-all 12 | else 13 | all:: $(THEOS_BUILD_DIR) before-all internal-all after-all 14 | endif 15 | 16 | clean:: before-clean internal-clean after-clean 17 | 18 | before-all:: 19 | ifneq ($(SYSROOT),) 20 | @[ -d "$(SYSROOT)" ] || { echo "Your current SYSROOT, \"$(SYSROOT)\", appears to be missing."; exit 1; } 21 | endif 22 | 23 | internal-all:: 24 | 25 | after-all:: 26 | 27 | before-clean:: 28 | 29 | internal-clean:: 30 | rm -rf $(THEOS_OBJ_DIR) 31 | ifeq ($(MAKELEVEL),0) 32 | rm -rf "$(THEOS_STAGING_DIR)" 33 | endif 34 | 35 | after-clean:: 36 | 37 | ifeq ($(MAKELEVEL),0) 38 | ifneq ($(THEOS_BUILD_DIR),.) 39 | _THEOS_ABSOLUTE_BUILD_DIR = $(call __clean_pwd,$(THEOS_BUILD_DIR)) 40 | else 41 | _THEOS_ABSOLUTE_BUILD_DIR = . 42 | endif 43 | else 44 | _THEOS_ABSOLUTE_BUILD_DIR = $(strip $(THEOS_BUILD_DIR)) 45 | endif 46 | 47 | .PRECIOUS: %.variables %.subprojects 48 | 49 | %.variables: _INSTANCE = $(basename $(basename $*)) 50 | %.variables: _OPERATION = $(subst .,,$(suffix $(basename $*))) 51 | %.variables: _TYPE = $(subst -,_,$(subst .,,$(suffix $*))) 52 | %.variables: __SUBPROJECTS = $(strip $(call __schema_var_all,$(_INSTANCE)_,SUBPROJECTS)) 53 | %.variables: 54 | @ \ 55 | abs_build_dir=$(_THEOS_ABSOLUTE_BUILD_DIR); \ 56 | if [ "$(__SUBPROJECTS)" != "" ]; then \ 57 | echo Making $(_OPERATION) in subprojects of $(_TYPE) $(_INSTANCE)...; \ 58 | for d in $(__SUBPROJECTS); do \ 59 | d="$${d%:*}"; \ 60 | if [ "$${abs_build_dir}" = "." ]; then \ 61 | lbuilddir="."; \ 62 | else \ 63 | lbuilddir="$${abs_build_dir}/$$d"; \ 64 | fi; \ 65 | if $(MAKE) -C $$d -f $(_THEOS_PROJECT_MAKEFILE_NAME) $(_THEOS_NO_PRINT_DIRECTORY_FLAG) --no-keep-going $(_OPERATION) \ 66 | THEOS_BUILD_DIR="$$lbuilddir" \ 67 | ; then\ 68 | :; \ 69 | else exit $$?; \ 70 | fi; \ 71 | done; \ 72 | fi; \ 73 | echo Making $(_OPERATION) for $(_TYPE) $(_INSTANCE)...; \ 74 | $(MAKE) -f $(_THEOS_PROJECT_MAKEFILE_NAME) --no-print-directory --no-keep-going \ 75 | internal-$(_TYPE)-$(_OPERATION) \ 76 | _THEOS_CURRENT_TYPE="$(_TYPE)" \ 77 | THEOS_CURRENT_INSTANCE="$(_INSTANCE)" \ 78 | _THEOS_CURRENT_OPERATION="$(_OPERATION)" \ 79 | THEOS_BUILD_DIR="$(_THEOS_ABSOLUTE_BUILD_DIR)" 80 | 81 | %.subprojects: _INSTANCE = $(basename $(basename $*)) 82 | %.subprojects: _OPERATION = $(subst .,,$(suffix $(basename $*))) 83 | %.subprojects: _TYPE = $(subst -,_,$(subst .,,$(suffix $*))) 84 | %.subprojects: __SUBPROJECTS = $(strip $(call __schema_var_all,$(_INSTANCE)_,SUBPROJECTS)) 85 | %.subprojects: 86 | @ \ 87 | abs_build_dir=$(_THEOS_ABSOLUTE_BUILD_DIR); \ 88 | if [ "$(__SUBPROJECTS)" != "" ]; then \ 89 | echo Making $(_OPERATION) in subprojects of $(_TYPE) $(_INSTANCE)...; \ 90 | for d in $(__SUBPROJECTS); do \ 91 | d="$${d%:*}"; \ 92 | if [ "$${abs_build_dir}" = "." ]; then \ 93 | lbuilddir="."; \ 94 | else \ 95 | lbuilddir="$${abs_build_dir}/$$d"; \ 96 | fi; \ 97 | if $(MAKE) -C $$d -f $(_THEOS_PROJECT_MAKEFILE_NAME) $(_THEOS_NO_PRINT_DIRECTORY_FLAG) --no-keep-going $(_OPERATION) \ 98 | THEOS_BUILD_DIR="$$lbuilddir" \ 99 | ; then\ 100 | :; \ 101 | else exit $$?; \ 102 | fi; \ 103 | done; \ 104 | fi 105 | 106 | $(eval $(call __mod,master/rules.mk)) 107 | 108 | ifeq ($(_THEOS_TOP_INVOCATION_DONE),) 109 | export _THEOS_TOP_INVOCATION_DONE = 1 110 | endif 111 | -------------------------------------------------------------------------------- /theos/makefiles/master/subproject.mk: -------------------------------------------------------------------------------- 1 | SUBPROJECT_NAME := $(strip $(SUBPROJECT_NAME)) 2 | 3 | ifeq ($(_THEOS_RULES_LOADED),) 4 | include $(THEOS_MAKE_PATH)/rules.mk 5 | endif 6 | 7 | internal-all:: $(SUBPROJECT_NAME:=.all.subproject.variables); 8 | 9 | internal-stage:: $(SUBPROJECT_NAME:=.stage.subproject.variables); 10 | 11 | SUBPROJECTS_WITH_SUBPROJECTS = $(strip $(foreach subproject,$(SUBPROJECT_NAME),$(patsubst %,$(subproject),$(call __schema_var_all,$(subproject)_,SUBPROJECTS)))) 12 | ifneq ($(SUBPROJECTS_WITH_SUBPROJECTS),) 13 | internal-clean:: $(SUBPROJECTS_WITH_SUBPROJECTS:=.clean.subproject.subprojects) 14 | endif 15 | 16 | $(SUBPROJECT_NAME): 17 | @$(MAKE) -f $(_THEOS_PROJECT_MAKEFILE_NAME) --no-print-directory --no-keep-going $@.all.subproject.variables 18 | 19 | $(eval $(call __mod,master/subproject.mk)) 20 | -------------------------------------------------------------------------------- /theos/makefiles/master/tool.mk: -------------------------------------------------------------------------------- 1 | TOOL_NAME := $(strip $(TOOL_NAME)) 2 | 3 | ifeq ($(_THEOS_RULES_LOADED),) 4 | include $(THEOS_MAKE_PATH)/rules.mk 5 | endif 6 | 7 | internal-all:: $(TOOL_NAME:=.all.tool.variables); 8 | 9 | internal-stage:: $(TOOL_NAME:=.stage.tool.variables); 10 | 11 | TOOLS_WITH_SUBPROJECTS = $(strip $(foreach tool,$(TOOL_NAME),$(patsubst %,$(tool),$(call __schema_var_all,$(tool)_,SUBPROJECTS)))) 12 | ifneq ($(TOOLS_WITH_SUBPROJECTS),) 13 | internal-clean:: $(TOOLS_WITH_SUBPROJECTS:=.clean.tool.subprojects) 14 | endif 15 | 16 | $(TOOL_NAME): 17 | @$(MAKE) -f $(_THEOS_PROJECT_MAKEFILE_NAME) --no-print-directory --no-keep-going $@.all.tool.variables 18 | 19 | $(eval $(call __mod,master/tool.mk)) 20 | -------------------------------------------------------------------------------- /theos/makefiles/master/tweak.mk: -------------------------------------------------------------------------------- 1 | TWEAK_NAME := $(strip $(TWEAK_NAME)) 2 | 3 | ifeq ($(_THEOS_RULES_LOADED),) 4 | include $(THEOS_MAKE_PATH)/rules.mk 5 | endif 6 | 7 | before-all:: 8 | @[ -f "$(THEOS_LIBRARY_PATH)/libsubstrate.dylib" ] || bootstrap.sh substrate 9 | 10 | internal-all:: $(TWEAK_NAME:=.all.tweak.variables); 11 | 12 | internal-stage:: $(TWEAK_NAME:=.stage.tweak.variables); 13 | 14 | TWEAKS_WITH_SUBPROJECTS = $(strip $(foreach tweak,$(TWEAK_NAME),$(patsubst %,$(tweak),$(call __schema_var_all,$(tweak)_,SUBPROJECTS)))) 15 | ifneq ($(TWEAKS_WITH_SUBPROJECTS),) 16 | internal-clean:: $(TWEAKS_WITH_SUBPROJECTS:=.clean.tweak.subprojects) 17 | endif 18 | 19 | $(TWEAK_NAME): 20 | @$(MAKE) -f $(_THEOS_PROJECT_MAKEFILE_NAME) --no-print-directory --no-keep-going $@.all.tweak.variables 21 | 22 | $(eval $(call __mod,master/tweak.mk)) 23 | -------------------------------------------------------------------------------- /theos/makefiles/messages.mk: -------------------------------------------------------------------------------- 1 | ifneq ($(call __theos_bool,$(or $(messages),$(MESSAGES))),$(_THEOS_TRUE)) 2 | ECHO_COMPILING = @(echo " Compiling $<..."; 3 | ECHO_LINKING = @(echo " Linking $(_THEOS_CURRENT_TYPE) $(THEOS_CURRENT_INSTANCE)..."; 4 | ECHO_STRIPPING = @(echo " Stripping $(THEOS_CURRENT_INSTANCE)..."; 5 | ECHO_SIGNING = @(echo " Signing $(THEOS_CURRENT_INSTANCE)..."; 6 | ECHO_PREPROCESSING = @(echo " Preprocessing $<..."; 7 | ECHO_COPYING_RESOURCE_FILES = @(echo " Copying resource files into the $(_THEOS_CURRENT_TYPE) wrapper..."; 8 | ECHO_COPYING_RESOURCE_DIRS = @(echo " Copying resource directories into the $(_THEOS_CURRENT_TYPE) wrapper..."; 9 | ECHO_NOTHING = @( 10 | 11 | STDERR_NULL_REDIRECT = 2> /dev/null 12 | 13 | ECHO_END = ) 14 | 15 | _THEOS_VERBOSE := $(_THEOS_FALSE) 16 | else 17 | ECHO_COMPILING = 18 | ECHO_LINKING = 19 | ECHO_STRIPPING = 20 | ECHO_SIGNING = 21 | ECHO_PREPROCESSING = 22 | ECHO_COPYING_RESOURCE_FILES = 23 | ECHO_COPYING_RESOURCE_DIRS = 24 | ECHO_NOTHING = 25 | STDERR_NULL_REDIRECT = 26 | ECHO_END = 27 | 28 | _THEOS_VERBOSE := $(_THEOS_TRUE) 29 | endif 30 | 31 | WARNING_EMPTY_LINKING = @(echo " Warning! No files to link. Please check your Makefile! Make sure you set $(THEOS_CURRENT_INSTANCE)_FILES (or similar variables)") 32 | 33 | # (bundle) 34 | NOTICE_EMPTY_LINKING = @(echo " Notice: No files to link - creating a bundle containing only resources") 35 | 36 | $(eval $(call __mod,messages.mk)) 37 | -------------------------------------------------------------------------------- /theos/makefiles/null.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(THEOS_CURRENT_INSTANCE),) 2 | include $(THEOS_MAKE_PATH)/master/null.mk 3 | else 4 | ifeq ($(_THEOS_CURRENT_TYPE),null) 5 | include $(THEOS_MAKE_PATH)/instance/null.mk 6 | endif 7 | endif 8 | -------------------------------------------------------------------------------- /theos/makefiles/package.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(_THEOS_PACKAGE_RULES_LOADED),) 2 | _THEOS_PACKAGE_RULES_LOADED := 1 3 | 4 | ## Packaging Core Rules 5 | .PHONY: package internal-package-check before-package internal-package after-package 6 | 7 | package:: internal-package-check stage before-package internal-package after-package 8 | before-package:: $(THEOS_PACKAGE_DIR) 9 | internal-package internal-package-check:: 10 | @: 11 | 12 | # __THEOS_LAST_PACKAGE_FILENAME is to be set by a rule variable in the package format makefile. 13 | after-package:: 14 | @echo "$(__THEOS_LAST_PACKAGE_FILENAME)" > "$(_THEOS_LOCAL_DATA_DIR)/last_package" 15 | 16 | THEOS_PACKAGE_NAME := 17 | THEOS_PACKAGE_ARCH := 18 | THEOS_PACKAGE_BASE_VERSION := 19 | # THEOS_PACKAGE_VERSION is set in common.mk (to give its warning.) 20 | 21 | -include $(THEOS_MAKE_PATH)/package/$(_THEOS_PACKAGE_FORMAT).mk 22 | $(eval $(call __mod,package/$(_THEOS_PACKAGE_FORMAT).mk)) 23 | 24 | ifeq ($(_THEOS_PACKAGE_FORMAT_LOADED),) 25 | $(error I simply cannot figure out how to create $(_THEOS_PACKAGE_FORMAT)-format packages.) 26 | endif 27 | 28 | export THEOS_PACKAGE_NAME THEOS_PACKAGE_ARCH THEOS_PACKAGE_BASE_VERSION 29 | 30 | # These are here to be used by the package makefile included above. 31 | # We want them after the package makefile so that we can use variables set within it. 32 | 33 | # eval PACKAGE_VERSION *now* (to clear out references to VERSION.*: they have no bearing on 34 | # the 'base' version we calculate.) 35 | VERSION.INC_BUILD_NUMBER := X 36 | VERSION.EXTRAVERSION := X 37 | __USERVER_FOR_BUILDNUM := $(PACKAGE_VERSION) 38 | __BASEVER_FOR_BUILDNUM = $(or $(__USERVER_FOR_BUILDNUM),$(THEOS_PACKAGE_BASE_VERSION)) 39 | 40 | 41 | # We simplify the version vars so that they are evaluated only when completely necessary. 42 | # This is because they can include things like incrementing build numbers. 43 | 44 | # I am committing a willful departure from the THEOS_ naming convention, because I believe 45 | # that offering these via an easy-to-use interface makes more sense than hiding them behind 46 | # a really stupidly long name. 47 | # VERSION.* are meant to be used in user PACKAGE_VERSIONs. 48 | VERSION.INC_BUILD_NUMBER = $(shell THEOS_PROJECT_DIR="$(THEOS_PROJECT_DIR)" "$(THEOS_BIN_PATH)/package_version.sh" -N "$(THEOS_PACKAGE_NAME)" -V "$(__BASEVER_FOR_BUILDNUM)") 49 | VERSION.EXTRAVERSION = $(if $(PACKAGE_BUILDNAME),+$(PACKAGE_BUILDNAME)) 50 | _THEOS_PACKAGE_DEFAULT_VERSION_FORMAT = $(THEOS_PACKAGE_BASE_VERSION)-$(VERSION.INC_BUILD_NUMBER)$(VERSION.EXTRAVERSION) 51 | 52 | # Copy the actual value of PACKAGE_VERSION to __PACKAGE_VERSION and replace PACKAGE_VERSION with 53 | # a mere reference (to a simplified copy.) 54 | # We're doing this to clean up the user's PACKAGE_VERSION and make it safe for reuse. 55 | # (otherwise, they might trigger build number increases without meaning to.) 56 | # Defer the simplification until __PACKAGE_VERSION is used - do not do it before the eval 57 | # However, we want to do the schema calculation and value stuff before the eval, so that 58 | # __PACKAGE_VERSION becomes an exact copy of the PACKAGE_VERSION variable we chose. 59 | $(eval __PACKAGE_VERSION = $$(call __simplify,__PACKAGE_VERSION,$(value $(call __schema_var_name_last,,PACKAGE_VERSION)))) 60 | override PACKAGE_VERSION = $(__PACKAGE_VERSION) 61 | 62 | _THEOS_INTERNAL_PACKAGE_VERSION = $(call __simplify,_THEOS_INTERNAL_PACKAGE_VERSION,$(or $(__PACKAGE_VERSION),$(_THEOS_PACKAGE_DEFAULT_VERSION_FORMAT),1)) 63 | 64 | ## Installation Core Rules 65 | install:: before-install internal-install after-install 66 | 67 | export TARGET_INSTALL_REMOTE 68 | _THEOS_INSTALL_TYPE := local 69 | ifeq ($(TARGET_INSTALL_REMOTE),$(_THEOS_TRUE)) 70 | _THEOS_INSTALL_TYPE := remote 71 | ifeq ($(THEOS_DEVICE_IP),) 72 | internal-install:: 73 | $(info $(MAKE) install requires that you set THEOS_DEVICE_IP in your environment. It is also recommended that you have public-key authentication set up for root over SSH, or you will be entering your password a lot.) 74 | @exit 1 75 | endif # THEOS_DEVICE_IP == "" 76 | THEOS_DEVICE_PORT ?= 22 77 | export THEOS_DEVICE_IP THEOS_DEVICE_PORT 78 | endif # TARGET_INSTALL_REMOTE == true 79 | 80 | after-install:: internal-after-install 81 | before-install internal-install internal-after-install:: 82 | @: 83 | 84 | -include $(THEOS_MAKE_PATH)/install/$(_THEOS_PACKAGE_FORMAT)_$(_THEOS_INSTALL_TYPE).mk 85 | $(eval $(call __mod,install/$(_THEOS_PACKAGE_FORMAT)_$(_THEOS_INSTALL_TYPE).mk)) 86 | 87 | endif # _THEOS_PACKAGE_RULES_LOADED 88 | -------------------------------------------------------------------------------- /theos/makefiles/package/deb.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(_THEOS_PACKAGE_FORMAT_LOADED),) 2 | _THEOS_PACKAGE_FORMAT_LOADED := 1 3 | 4 | _THEOS_DEB_PACKAGE_CONTROL_PATH := $(or $(wildcard $(THEOS_PROJECT_DIR)/control),$(wildcard $(THEOS_PROJECT_DIR)/layout/DEBIAN/control)) 5 | _THEOS_DEB_CAN_PACKAGE := $(if $(_THEOS_DEB_PACKAGE_CONTROL_PATH),$(_THEOS_TRUE),$(_THEOS_FALSE)) 6 | 7 | _THEOS_DEB_HAS_DPKG_DEB := $(call __executable,dpkg-deb) 8 | ifneq ($(_THEOS_DEB_HAS_DPKG_DEB),$(_THEOS_TRUE)) 9 | internal-package-check:: 10 | @echo "$(MAKE) package requires dpkg-deb."; exit 1 11 | endif 12 | 13 | ifeq ($(_THEOS_DEB_CAN_PACKAGE),$(_THEOS_TRUE)) # Control file found (or layout/ found.) 14 | THEOS_PACKAGE_NAME := $(shell grep -i "^Package:" "$(_THEOS_DEB_PACKAGE_CONTROL_PATH)" | cut -d' ' -f2-) 15 | THEOS_PACKAGE_ARCH := $(shell grep -i "^Architecture:" "$(_THEOS_DEB_PACKAGE_CONTROL_PATH)" | cut -d' ' -f2-) 16 | THEOS_PACKAGE_BASE_VERSION := $(shell grep -i "^Version:" "$(_THEOS_DEB_PACKAGE_CONTROL_PATH)" | cut -d' ' -f2-) 17 | 18 | $(_THEOS_ESCAPED_STAGING_DIR)/DEBIAN: 19 | $(ECHO_NOTHING)mkdir -p "$(THEOS_STAGING_DIR)/DEBIAN"$(ECHO_END) 20 | ifeq ($(_THEOS_HAS_STAGING_LAYOUT),1) # If we have a layout/ directory, copy layout/DEBIAN to the staging directory. 21 | $(ECHO_NOTHING)[ -d "$(THEOS_PROJECT_DIR)/layout/DEBIAN" ] && rsync -a "$(THEOS_PROJECT_DIR)/layout/DEBIAN/" "$(THEOS_STAGING_DIR)/DEBIAN" $(_THEOS_RSYNC_EXCLUDE_COMMANDLINE) || true$(ECHO_END) 22 | endif # _THEOS_HAS_STAGING_LAYOUT 23 | 24 | $(_THEOS_ESCAPED_STAGING_DIR)/DEBIAN/control: $(_THEOS_ESCAPED_STAGING_DIR)/DEBIAN 25 | $(ECHO_NOTHING)sed -e '/^[Vv]ersion:/d' "$(_THEOS_DEB_PACKAGE_CONTROL_PATH)" > "$@"$(ECHO_END) 26 | $(ECHO_NOTHING)echo "Version: $(_THEOS_INTERNAL_PACKAGE_VERSION)" >> "$@"$(ECHO_END) 27 | $(ECHO_NOTHING)echo "Installed-Size: $(shell du $(_THEOS_PLATFORM_DU_EXCLUDE) DEBIAN -ks "$(THEOS_STAGING_DIR)" | cut -f 1)" >> "$@"$(ECHO_END) 28 | 29 | before-package:: $(_THEOS_ESCAPED_STAGING_DIR)/DEBIAN/control 30 | 31 | _THEOS_DEB_PACKAGE_FILENAME = $(THEOS_PACKAGE_DIR)/$(THEOS_PACKAGE_NAME)_$(_THEOS_INTERNAL_PACKAGE_VERSION)_$(THEOS_PACKAGE_ARCH).deb 32 | internal-package:: 33 | $(ECHO_NOTHING)COPYFILE_DISABLE=1 $(FAKEROOT) -r dpkg-deb -b "$(THEOS_STAGING_DIR)" "$(_THEOS_DEB_PACKAGE_FILENAME)" $(STDERR_NULL_REDIRECT)$(ECHO_END) 34 | 35 | # This variable is used in package.mk 36 | after-package:: __THEOS_LAST_PACKAGE_FILENAME = $(_THEOS_DEB_PACKAGE_FILENAME) 37 | 38 | else # _THEOS_DEB_CAN_PACKAGE == 0 39 | internal-package:: 40 | @echo "$(MAKE) package requires you to have a layout/ directory in the project root, containing the basic package structure, or a control file in the project root describing the package."; exit 1 41 | 42 | endif # _THEOS_DEB_CAN_PACKAGE 43 | endif # _THEOS_PACKAGE_FORMAT_LOADED 44 | -------------------------------------------------------------------------------- /theos/makefiles/package/none.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(_THEOS_PACKAGE_FORMAT_LOADED),) 2 | _THEOS_PACKAGE_FORMAT_LOADED := 1 3 | 4 | # This package format does nothing - it simply relies upon the internal-package rule in package.mk to do nothing for it. 5 | endif # _THEOS_PACKAGE_FORMAT_LOADED 6 | -------------------------------------------------------------------------------- /theos/makefiles/platform/Darwin-arm.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(_THEOS_PLATFORM_LOADED),) 2 | _THEOS_PLATFORM_LOADED := 1 3 | THEOS_PLATFORM_NAME := iphone 4 | 5 | _THEOS_PLATFORM_DEFAULT_TARGET := iphone 6 | _THEOS_PLATFORM_DU_EXCLUDE := --exclude 7 | _THEOS_PLATFORM_MD5SUM := md5sum 8 | endif 9 | -------------------------------------------------------------------------------- /theos/makefiles/platform/Darwin.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(_THEOS_PLATFORM_LOADED),) 2 | _THEOS_PLATFORM_LOADED := 1 3 | THEOS_PLATFORM_NAME := macosx 4 | 5 | THEOS_PLATFORM_SDK_ROOT ?= $(shell xcode-select -print-path) 6 | 7 | _THEOS_PLATFORM_DEFAULT_TARGET := iphone 8 | _THEOS_PLATFORM_DU_EXCLUDE := -I 9 | _THEOS_PLATFORM_MD5SUM := md5 10 | endif 11 | -------------------------------------------------------------------------------- /theos/makefiles/platform/Linux.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(_THEOS_PLATFORM_LOADED),) 2 | _THEOS_PLATFORM_LOADED := 1 3 | THEOS_PLATFORM_NAME := linux 4 | 5 | _THEOS_PLATFORM_DEFAULT_TARGET := iphone 6 | _THEOS_PLATFORM_DU_EXCLUDE := --exclude 7 | _THEOS_PLATFORM_MD5SUM := md5sum 8 | endif 9 | -------------------------------------------------------------------------------- /theos/makefiles/rules.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(_THEOS_RULES_LOADED),) 2 | _THEOS_RULES_LOADED := 1 3 | 4 | ifeq ($(THEOS_CURRENT_INSTANCE),) 5 | include $(THEOS_MAKE_PATH)/master/rules.mk 6 | else 7 | include $(THEOS_MAKE_PATH)/instance/rules.mk 8 | endif 9 | 10 | ifeq ($(_THEOS_MAKE_PARALLEL_BUILDING), no) 11 | .NOTPARALLEL: 12 | else 13 | ifneq ($(_THEOS_MAKE_PARALLEL), yes) 14 | .NOTPARALLEL: 15 | endif 16 | endif 17 | 18 | %.mm: %.l.mm 19 | $(THEOS_BIN_PATH)/logos.pl $< > $@ 20 | 21 | %.mm: %.xmm 22 | $(THEOS_BIN_PATH)/logos.pl $< > $@ 23 | 24 | %.mm: %.xm 25 | $(THEOS_BIN_PATH)/logos.pl $< > $@ 26 | 27 | %.m: %.xm 28 | $(THEOS_BIN_PATH)/logos.pl $< > $@ 29 | 30 | ifneq ($(THEOS_BUILD_DIR),.) 31 | $(THEOS_BUILD_DIR): 32 | @mkdir -p $(THEOS_BUILD_DIR) 33 | endif 34 | 35 | $(THEOS_OBJ_DIR): 36 | @cd $(THEOS_BUILD_DIR); mkdir -p $(THEOS_OBJ_DIR_NAME) 37 | 38 | $(THEOS_OBJ_DIR)/.stamp: $(THEOS_OBJ_DIR) 39 | @touch $@ 40 | 41 | $(THEOS_OBJ_DIR)/%/.stamp: $(THEOS_OBJ_DIR) 42 | @mkdir -p $(dir $@); touch $@ 43 | 44 | Makefile: ; 45 | $(_THEOS_RELATIVE_MAKE_PATH)%.mk: ; 46 | $(THEOS_MAKE_PATH)/%.mk: ; 47 | $(THEOS_MAKE_PATH)/master/%.mk: ; 48 | $(THEOS_MAKE_PATH)/instance/%.mk: ; 49 | $(THEOS_MAKE_PATH)/instance/shared/%.mk: ; 50 | $(THEOS_MAKE_PATH)/platform/%.mk: ; 51 | $(THEOS_MAKE_PATH)/targets/%.mk: ; 52 | $(THEOS_MAKE_PATH)/targets/%/%.mk: ; 53 | 54 | ifneq ($(THEOS_PACKAGE_DIR_NAME),) 55 | $(THEOS_PACKAGE_DIR): 56 | @cd $(THEOS_BUILD_DIR); mkdir -p $(THEOS_PACKAGE_DIR_NAME) 57 | endif 58 | 59 | endif 60 | 61 | # TODO MAKE A BUNCH OF THINGS PHONY 62 | $(eval $(call __mod,rules.mk)) 63 | -------------------------------------------------------------------------------- /theos/makefiles/stage.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(_THEOS_STAGING_RULES_LOADED),) 2 | _THEOS_STAGING_RULES_LOADED := 1 3 | 4 | .PHONY: stage before-stage internal-stage after-stage 5 | 6 | # For the toplevel invocation of make, mark 'all' and the *-stage rules as prerequisites. 7 | # We do not do this for anything else, because otherwise, all the staging rules would run for every subproject. 8 | ifeq ($(_THEOS_TOP_INVOCATION_DONE),) 9 | stage:: all before-stage internal-stage after-stage 10 | else # _THEOS_TOP_INVOCATION_DONE 11 | stage:: internal-stage 12 | endif 13 | 14 | # Only do the master staging rules if we're the toplevel make invocation. 15 | ifeq ($(_THEOS_TOP_INVOCATION_DONE),) 16 | before-stage:: 17 | $(ECHO_NOTHING)rm -rf "$(THEOS_STAGING_DIR)"$(ECHO_END) 18 | $(ECHO_NOTHING)$(FAKEROOT) -c$(ECHO_END) 19 | $(ECHO_NOTHING)mkdir -p "$(THEOS_STAGING_DIR)"$(ECHO_END) 20 | else # _THEOS_TOP_INVOCATION_DONE 21 | before-stage:: 22 | @: 23 | endif # _THEOS_TOP_INVOCATION_DONE 24 | 25 | internal-stage:: 26 | $(ECHO_NOTHING)[ -d layout ] && rsync -a "layout/" "$(THEOS_STAGING_DIR)" --exclude "DEBIAN" $(_THEOS_RSYNC_EXCLUDE_COMMANDLINE) || true$(ECHO_END) 27 | 28 | after-stage:: 29 | @: 30 | 31 | endif # _THEOS_STAGING_RULES_LOADED 32 | -------------------------------------------------------------------------------- /theos/makefiles/subproject.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(THEOS_CURRENT_INSTANCE),) 2 | include $(THEOS_MAKE_PATH)/master/subproject.mk 3 | else 4 | ifeq ($(_THEOS_CURRENT_TYPE),subproject) 5 | include $(THEOS_MAKE_PATH)/instance/subproject.mk 6 | endif 7 | endif 8 | -------------------------------------------------------------------------------- /theos/makefiles/targets/Darwin-arm/iphone.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(_THEOS_TARGET_LOADED),) 2 | _THEOS_TARGET_LOADED := 1 3 | THEOS_TARGET_NAME := iphone 4 | 5 | _THEOS_TARGET_CC := arm-apple-darwin9-gcc 6 | _THEOS_TARGET_CXX := arm-apple-darwin9-g++ 7 | _THEOS_TARGET_ARG_ORDER := 1 2 8 | ifeq ($(__THEOS_TARGET_ARG_1),clang) 9 | _THEOS_TARGET_CC := clang 10 | _THEOS_TARGET_CXX := clang++ 11 | _THEOS_TARGET_ARG_ORDER := 2 3 12 | else ifeq ($(__THEOS_TARGET_ARG_1),gcc) 13 | _THEOS_TARGET_ARG_ORDER := 2 3 14 | endif 15 | 16 | _SDKVERSION := $(or $(__THEOS_TARGET_ARG_$(word 1,$(_THEOS_TARGET_ARG_ORDER))),$(SDKVERSION)) 17 | _THEOS_TARGET_SDK_VERSION := $(or $(_SDKVERSION),latest) 18 | 19 | _SDK_DIR := $(THEOS)/sdks 20 | _IOS_SDKS := $(sort $(patsubst $(_SDK_DIR)/iPhoneOS%.sdk,%,$(wildcard $(_SDK_DIR)/iPhoneOS*.sdk))) 21 | _LATEST_SDK := $(word $(words $(_IOS_SDKS)),$(_IOS_SDKS)) 22 | 23 | ifeq ($(_THEOS_TARGET_SDK_VERSION),latest) 24 | override _THEOS_TARGET_SDK_VERSION := $(_LATEST_SDK) 25 | endif 26 | 27 | # We have to figure out the target version here, as we need it in the calculation of the deployment version. 28 | _TARGET_VERSION_GE_6_0 = $(call __simplify,_TARGET_VERSION_GE_6_0,$(shell $(THEOS_BIN_PATH)/vercmp.pl $(_THEOS_TARGET_SDK_VERSION) ge 6.0)) 29 | _TARGET_VERSION_GE_3_0 = $(call __simplify,_TARGET_VERSION_GE_3_0,$(shell $(THEOS_BIN_PATH)/vercmp.pl $(_THEOS_TARGET_SDK_VERSION) ge 3.0)) 30 | _TARGET_VERSION_GE_4_0 = $(call __simplify,_TARGET_VERSION_GE_4_0,$(shell $(THEOS_BIN_PATH)/vercmp.pl $(_THEOS_TARGET_SDK_VERSION) ge 4.0)) 31 | _THEOS_TARGET_IPHONEOS_DEPLOYMENT_VERSION := $(or $(__THEOS_TARGET_ARG_$(word 2,$(_THEOS_TARGET_ARG_ORDER))),$(TARGET_IPHONEOS_DEPLOYMENT_VERSION),$(_SDKVERSION),3.0) 32 | 33 | ifeq ($(_THEOS_TARGET_IPHONEOS_DEPLOYMENT_VERSION),latest) 34 | override _THEOS_TARGET_IPHONEOS_DEPLOYMENT_VERSION := $(_LATEST_SDK) 35 | endif 36 | 37 | _DEPLOY_VERSION_GE_3_0 = $(call __simplify,_DEPLOY_VERSION_GE_3_0,$(shell $(THEOS_BIN_PATH)/vercmp.pl $(_THEOS_TARGET_IPHONEOS_DEPLOYMENT_VERSION) ge 3.0)) 38 | _DEPLOY_VERSION_LT_4_3 = $(call __simplify,_DEPLOY_VERSION_LT_4_3,$(shell $(THEOS_BIN_PATH)/vercmp.pl $(_THEOS_TARGET_IPHONEOS_DEPLOYMENT_VERSION) lt 4.3)) 39 | 40 | ifeq ($(_TARGET_VERSION_GE_4_0),1) 41 | ifeq ($(_THEOS_TARGET_CC),arm-apple-darwin9-gcc) 42 | ifeq ($(_THEOS_TARGET_WARNED_TARGETGCC),) 43 | $(warning Targeting iOS 4.0 and higher is not supported with iphone-gcc. Forcing clang.) 44 | export _THEOS_TARGET_WARNED_TARGETGCC := 1 45 | endif 46 | override _THEOS_TARGET_CC := clang 47 | override _THEOS_TARGET_CXX := clang++ 48 | endif 49 | endif 50 | 51 | ifeq ($(_TARGET_VERSION_GE_6_0)$(_DEPLOY_VERSION_GE_3_0)$(_DEPLOY_VERSION_LT_4_3),111) 52 | ifeq ($(_THEOS_TARGET_WARNED_DEPLOY),) 53 | $(warning Deploying to iOS 3.0 while building for 6.0 will generate armv7-only binaries.) 54 | export _THEOS_TARGET_WARNED_DEPLOY := 1 55 | endif 56 | endif 57 | 58 | SYSROOT ?= $(_SDK_DIR)/iPhoneOS$(_THEOS_TARGET_SDK_VERSION).sdk 59 | 60 | TARGET_CC ?= $(_THEOS_TARGET_CC) 61 | TARGET_CXX ?= $(_THEOS_TARGET_CXX) 62 | TARGET_LD ?= $(_THEOS_TARGET_CXX) 63 | TARGET_STRIP ?= strip 64 | TARGET_STRIP_FLAGS ?= -x 65 | TARGET_CODESIGN_ALLOCATE ?= codesign_allocate 66 | TARGET_CODESIGN ?= ldid 67 | TARGET_CODESIGN_FLAGS ?= -S 68 | 69 | TARGET_PRIVATE_FRAMEWORK_PATH = $(SYSROOT)/System/Library/PrivateFrameworks 70 | 71 | include $(THEOS_MAKE_PATH)/targets/_common/darwin.mk 72 | include $(THEOS_MAKE_PATH)/targets/_common/darwin_flat_bundle.mk 73 | 74 | ifeq ($(_TARGET_VERSION_GE_6_0),1) # >= 6.0 { 75 | ARCHS ?= armv7 76 | else # } < 6.0 { 77 | ifeq ($(_TARGET_VERSION_GE_3_0,1) # >= 3.0 { 78 | ifeq ($(_THEOS_TARGET_CC),arm-apple-darwin9-gcc) # iphone-gcc doesn't support armv7 79 | ARCHS ?= armv6 80 | else 81 | ARCHS ?= armv6 armv7 82 | endif 83 | else # } < 3.0 { 84 | ARCHS ?= armv6 85 | endif # } 86 | endif # } 87 | 88 | SDKFLAGS := -isysroot "$(SYSROOT)" $(foreach ARCH,$(ARCHS),-arch $(ARCH)) -D__IPHONE_OS_VERSION_MIN_REQUIRED=__IPHONE_$(subst .,_,$(_THEOS_TARGET_IPHONEOS_DEPLOYMENT_VERSION)) -miphoneos-version-min=$(_THEOS_TARGET_IPHONEOS_DEPLOYMENT_VERSION) 89 | _THEOS_TARGET_CFLAGS := $(SDKFLAGS) 90 | _THEOS_TARGET_LDFLAGS := $(SDKFLAGS) -multiply_defined suppress 91 | 92 | TARGET_INSTALL_REMOTE := $(_THEOS_FALSE) 93 | _THEOS_TARGET_DEFAULT_PACKAGE_FORMAT := deb 94 | endif 95 | -------------------------------------------------------------------------------- /theos/makefiles/targets/Darwin-arm/native.mk: -------------------------------------------------------------------------------- 1 | iphone.mk -------------------------------------------------------------------------------- /theos/makefiles/targets/Darwin/iphone.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(_THEOS_TARGET_LOADED),) 2 | _THEOS_TARGET_LOADED := 1 3 | THEOS_TARGET_NAME := iphone 4 | 5 | ifeq ($(__THEOS_TARGET_ARG_1),clang) 6 | _THEOS_TARGET_CC := clang 7 | _THEOS_TARGET_CXX := clang++ 8 | _THEOS_TARGET_ARG_ORDER := 2 3 9 | else 10 | _THEOS_TARGET_CC := gcc 11 | _THEOS_TARGET_CXX := g++ 12 | _THEOS_TARGET_ARG_ORDER := 1 2 13 | endif 14 | 15 | # A version specified as a target argument overrides all previous definitions. 16 | _SDKVERSION := $(or $(__THEOS_TARGET_ARG_$(word 1,$(_THEOS_TARGET_ARG_ORDER))),$(SDKVERSION)) 17 | _THEOS_TARGET_SDK_VERSION := $(or $(_SDKVERSION),latest) 18 | 19 | _SDK_DIR := $(THEOS_PLATFORM_SDK_ROOT)/Platforms/iPhoneOS.platform/Developer/SDKs 20 | _IOS_SDKS := $(sort $(patsubst $(_SDK_DIR)/iPhoneOS%.sdk,%,$(wildcard $(_SDK_DIR)/iPhoneOS*.sdk))) 21 | _LATEST_SDK := $(word $(words $(_IOS_SDKS)),$(_IOS_SDKS)) 22 | 23 | ifeq ($(_THEOS_TARGET_SDK_VERSION),latest) 24 | override _THEOS_TARGET_SDK_VERSION := $(_LATEST_SDK) 25 | endif 26 | 27 | # We have to figure out the target version here, as we need it in the calculation of the deployment version. 28 | _TARGET_VERSION_GE_6_0 = $(call __simplify,_TARGET_VERSION_GE_6_0,$(shell $(THEOS_BIN_PATH)/vercmp.pl $(_THEOS_TARGET_SDK_VERSION) ge 6.0)) 29 | _TARGET_VERSION_GE_3_0 = $(call __simplify,_TARGET_VERSION_GE_3_0,$(shell $(THEOS_BIN_PATH)/vercmp.pl $(_THEOS_TARGET_SDK_VERSION) ge 3.0)) 30 | _THEOS_TARGET_IPHONEOS_DEPLOYMENT_VERSION := $(or $(__THEOS_TARGET_ARG_$(word 2,$(_THEOS_TARGET_ARG_ORDER))),$(TARGET_IPHONEOS_DEPLOYMENT_VERSION),$(_SDKVERSION),3.0) 31 | 32 | ifeq ($(_THEOS_TARGET_IPHONEOS_DEPLOYMENT_VERSION),latest) 33 | override _THEOS_TARGET_IPHONEOS_DEPLOYMENT_VERSION := $(_LATEST_SDK) 34 | endif 35 | 36 | _DEPLOY_VERSION_GE_3_0 = $(call __simplify,_DEPLOY_VERSION_GE_3_0,$(shell $(THEOS_BIN_PATH)/vercmp.pl $(_THEOS_TARGET_IPHONEOS_DEPLOYMENT_VERSION) ge 3.0)) 37 | _DEPLOY_VERSION_LT_4_3 = $(call __simplify,_DEPLOY_VERSION_LT_4_3,$(shell $(THEOS_BIN_PATH)/vercmp.pl $(_THEOS_TARGET_IPHONEOS_DEPLOYMENT_VERSION) lt 4.3)) 38 | 39 | ifeq ($(_TARGET_VERSION_GE_6_0)$(_DEPLOY_VERSION_GE_3_0)$(_DEPLOY_VERSION_LT_4_3),111) 40 | ifeq ($(ARCHS)$(_THEOS_TARGET_WARNED_DEPLOY),) 41 | $(warning Deploying to iOS 3.0 while building for 6.0 will generate armv7-only binaries.) 42 | export _THEOS_TARGET_WARNED_DEPLOY := 1 43 | endif 44 | endif 45 | 46 | SYSROOT ?= $(THEOS_PLATFORM_SDK_ROOT)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$(_THEOS_TARGET_SDK_VERSION).sdk 47 | 48 | TARGET_CC ?= xcrun -sdk iphoneos $(_THEOS_TARGET_CC) 49 | TARGET_CXX ?= xcrun -sdk iphoneos $(_THEOS_TARGET_CXX) 50 | TARGET_LD ?= xcrun -sdk iphoneos $(_THEOS_TARGET_CXX) 51 | TARGET_STRIP ?= xcrun -sdk iphoneos strip 52 | TARGET_STRIP_FLAGS ?= -x 53 | TARGET_CODESIGN_ALLOCATE ?= "$(shell xcrun -sdk iphoneos -find codesign_allocate)" 54 | TARGET_CODESIGN ?= ldid 55 | TARGET_CODESIGN_FLAGS ?= -S 56 | 57 | TARGET_PRIVATE_FRAMEWORK_PATH = $(SYSROOT)/System/Library/PrivateFrameworks 58 | 59 | include $(THEOS_MAKE_PATH)/targets/_common/darwin.mk 60 | include $(THEOS_MAKE_PATH)/targets/_common/darwin_flat_bundle.mk 61 | 62 | ifeq ($(_TARGET_VERSION_GE_6_0),1) # >= 6.0 { 63 | ifeq ($(_DEPLOY_VERSION_GE_3_0)$(_DEPLOY_VERSION_LT_4_3),11) # 3.0 <= Deploy < 4.3 { 64 | ARCHS ?= armv7 65 | else # } else { 66 | ARCHS ?= armv7 armv7s 67 | endif # } 68 | else # } < 6.0 { 69 | ifeq ($(_TARGET_VERSION_GE_3_0),1) # >= 3.0 { 70 | ARCHS ?= armv6 armv7 71 | else # } < 3.0 { 72 | ARCHS ?= armv6 73 | endif # } 74 | endif # } 75 | 76 | SDKFLAGS := -isysroot "$(SYSROOT)" $(foreach ARCH,$(ARCHS),-arch $(ARCH)) -D__IPHONE_OS_VERSION_MIN_REQUIRED=__IPHONE_$(subst .,_,$(_THEOS_TARGET_IPHONEOS_DEPLOYMENT_VERSION)) -miphoneos-version-min=$(_THEOS_TARGET_IPHONEOS_DEPLOYMENT_VERSION) 77 | _THEOS_TARGET_CFLAGS := $(SDKFLAGS) 78 | _THEOS_TARGET_LDFLAGS := $(SDKFLAGS) -multiply_defined suppress 79 | 80 | TARGET_INSTALL_REMOTE := $(_THEOS_TRUE) 81 | _THEOS_TARGET_DEFAULT_PACKAGE_FORMAT := deb 82 | endif 83 | -------------------------------------------------------------------------------- /theos/makefiles/targets/Darwin/macosx.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(_THEOS_TARGET_LOADED),) 2 | _THEOS_TARGET_LOADED := 1 3 | THEOS_TARGET_NAME := macosx 4 | 5 | ifeq ($(__THEOS_TARGET_ARG_1),clang) 6 | _THEOS_TARGET_CC := clang 7 | _THEOS_TARGET_CXX := clang++ 8 | _THEOS_TARGET_ARG_ORDER := 2 9 | else 10 | _THEOS_TARGET_CC := gcc 11 | _THEOS_TARGET_CXX := g++ 12 | _THEOS_TARGET_ARG_ORDER := 1 13 | endif 14 | 15 | _THEOS_TARGET_MACOSX_DEPLOYMENT_VERSION := $(__THEOS_TARGET_ARG_$(_THEOS_TARGET_ARG_ORDER)) 16 | TARGET_CC ?= xcrun -sdk macosx $(_THEOS_TARGET_CC) 17 | TARGET_CXX ?= xcrun -sdk macosx $(_THEOS_TARGET_CXX) 18 | TARGET_LD ?= xcrun -sdk macosx $(_THEOS_TARGET_CXX) 19 | TARGET_STRIP ?= xcrun -sdk macosx strip 20 | TARGET_STRIP_FLAGS ?= -x 21 | TARGET_CODESIGN_ALLOCATE ?= "$(shell xcrun -sdk macosx -find codesign_allocate)" 22 | TARGET_CODESIGN ?= 23 | TARGET_CODESIGN_FLAGS ?= 24 | 25 | TARGET_PRIVATE_FRAMEWORK_PATH = /System/Library/PrivateFrameworks 26 | 27 | include $(THEOS_MAKE_PATH)/targets/_common/darwin.mk 28 | include $(THEOS_MAKE_PATH)/targets/_common/darwin_hierarchial_bundle.mk 29 | 30 | ARCHS ?= i386 x86_64 31 | SDKFLAGS := $(foreach ARCH,$(ARCHS),-arch $(ARCH)) $(if $(_THEOS_TARGET_MACOSX_DEPLOYMENT_VERSION),-mmacosx-version-min=$(_THEOS_TARGET_MACOSX_DEPLOYMENT_VERSION)) 32 | _THEOS_TARGET_CFLAGS := $(SDKFLAGS) 33 | _THEOS_TARGET_LDFLAGS := $(SDKFLAGS) -multiply_defined suppress 34 | 35 | export TARGET_INSTALL_REMOTE := $(_THEOS_FALSE) 36 | export _THEOS_TARGET_DEFAULT_PACKAGE_FORMAT := deb 37 | endif 38 | -------------------------------------------------------------------------------- /theos/makefiles/targets/Darwin/native.mk: -------------------------------------------------------------------------------- 1 | macosx.mk -------------------------------------------------------------------------------- /theos/makefiles/targets/Darwin/simulator.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(_THEOS_TARGET_LOADED),) 2 | _THEOS_TARGET_LOADED := 1 3 | THEOS_TARGET_NAME := iphone_simulator 4 | 5 | ifeq ($(__THEOS_TARGET_ARG_1),clang) 6 | _THEOS_TARGET_CC := clang 7 | _THEOS_TARGET_CXX := clang++ 8 | _THEOS_TARGET_ARG_ORDER := 2 3 9 | else 10 | _THEOS_TARGET_CC := gcc 11 | _THEOS_TARGET_CXX := g++ 12 | _THEOS_TARGET_ARG_ORDER := 1 2 13 | endif 14 | 15 | # A version specified as a target argument overrides all previous definitions. 16 | _SDKVERSION := $(or $(__THEOS_TARGET_ARG_$(word 1,$(_THEOS_TARGET_ARG_ORDER))),$(SDKVERSION)) 17 | _THEOS_TARGET_IPHONEOS_DEPLOYMENT_VERSION := $(or $(__THEOS_TARGET_ARG_$(word 2,$(_THEOS_TARGET_ARG_ORDER))),$(TARGET_IPHONEOS_DEPLOYMENT_VERSION),$(_SDKVERSION),3.0) 18 | _THEOS_TARGET_SDK_VERSION := $(or $(_SDKVERSION),latest) 19 | 20 | _SDK_DIR := $(THEOS_PLATFORM_SDK_ROOT)/Platforms/iPhoneSimulator.platform/Developer/SDKs 21 | _IOS_SDKS := $(sort $(patsubst $(_SDK_DIR)/iPhoneSimulator%.sdk,%,$(wildcard $(_SDK_DIR)/iPhoneSimulator*.sdk))) 22 | _LATEST_SDK := $(word $(words $(_IOS_SDKS)),$(_IOS_SDKS)) 23 | 24 | ifeq ($(_THEOS_TARGET_SDK_VERSION),latest) 25 | override _THEOS_TARGET_SDK_VERSION := $(_LATEST_SDK) 26 | endif 27 | 28 | ifeq ($(_THEOS_TARGET_IPHONEOS_DEPLOYMENT_VERSION),latest) 29 | override _THEOS_TARGET_IPHONEOS_DEPLOYMENT_VERSION := $(_LATEST_SDK) 30 | endif 31 | 32 | SYSROOT ?= $(THEOS_PLATFORM_SDK_ROOT)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator$(_THEOS_TARGET_SDK_VERSION).sdk 33 | 34 | TARGET_CC ?= xcrun -sdk iphonesimulator $(_THEOS_TARGET_CC) 35 | TARGET_CXX ?= xcrun -sdk iphonesimulator $(_THEOS_TARGET_CXX) 36 | TARGET_LD ?= xcrun -sdk iphonesimulator $(_THEOS_TARGET_CXX) 37 | TARGET_STRIP ?= xcrun -sdk iphonesimulator strip 38 | TARGET_STRIP_FLAGS ?= -x 39 | TARGET_CODESIGN_ALLOCATE ?= "$(shell xcrun -sdk iphonesimulator -find codesign_allocate)" 40 | TARGET_CODESIGN ?= 41 | TARGET_CODESIGN_FLAGS ?= 42 | 43 | TARGET_PRIVATE_FRAMEWORK_PATH = $(SYSROOT)/System/Library/PrivateFrameworks 44 | 45 | include $(THEOS_MAKE_PATH)/targets/_common/darwin.mk 46 | include $(THEOS_MAKE_PATH)/targets/_common/darwin_flat_bundle.mk 47 | 48 | ifeq ($(IPHONE_SIMULATOR_ROOT),) 49 | internal-install:: 50 | $(info $(MAKE) install for the simulator requires that you set IPHONE_SIMULATOR_ROOT to the root directory of the simulated OS.) 51 | @exit 1 52 | else 53 | internal-install:: stage 54 | install.mergeDir "$(THEOS_STAGING_DIR)" "$(IPHONE_SIMULATOR_ROOT)" 55 | endif 56 | 57 | ARCHS ?= i386 58 | 59 | _TARGET_VERSION_GE_3_2 = $(call __simplify,_TARGET_VERSION_GE_3_2,$(shell $(THEOS_BIN_PATH)/vercmp.pl $(_THEOS_TARGET_SDK_VERSION) ge 3.2)) 60 | _TARGET_VERSION_GE_4_0 = $(call __simplify,_TARGET_VERSION_GE_4_0,$(shell $(THEOS_BIN_PATH)/vercmp.pl $(_THEOS_TARGET_SDK_VERSION) ge 4.0)) 61 | _TARGET_OSX_VERSION_FLAG = -mmacosx-version-min=$(if $(_TARGET_VERSION_GE_4_0),10.6,10.5) 62 | _TARGET_OBJC_ABI_CFLAGS = $(if $(_TARGET_VERSION_GE_3_2),-fobjc-abi-version=2 -fobjc-legacy-dispatch) 63 | _TARGET_OBJC_ABI_LDFLAGS = $(if $(_TARGET_VERSION_GE_3_2),-Xlinker -objc_abi_version -Xlinker 2) 64 | 65 | SDKFLAGS := -isysroot $(SYSROOT) $(foreach ARCH,$(ARCHS),-arch $(ARCH)) -D__IPHONE_OS_VERSION_MIN_REQUIRED=__IPHONE_$(subst .,_,$(_THEOS_TARGET_IPHONEOS_DEPLOYMENT_VERSION)) $(_TARGET_OSX_VERSION_FLAG) 66 | 67 | _THEOS_TARGET_CFLAGS := $(SDKFLAGS) $(_TARGET_OBJC_ABI_CFLAGS) 68 | _THEOS_TARGET_LDFLAGS := $(SDKFLAGS) -multiply_defined suppress $(_TARGET_OBJC_ABI_LDFLAGS) 69 | endif 70 | -------------------------------------------------------------------------------- /theos/makefiles/targets/Linux/iphone.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(_THEOS_TARGET_LOADED),) 2 | _THEOS_TARGET_LOADED := 1 3 | THEOS_TARGET_NAME := iphone 4 | 5 | SDKTARGET ?= arm-apple-darwin9 6 | SDKBINPATH ?= /opt/iphone-sdk-3.0/prefix/bin 7 | SYSROOT ?= /opt/iphone-sdk-3.0/sysroot 8 | 9 | PREFIX := $(SDKBINPATH)/$(SDKTARGET)- 10 | 11 | TARGET_CC ?= $(PREFIX)gcc 12 | TARGET_CXX ?= $(PREFIX)g++ 13 | TARGET_LD ?= $(PREFIX)g++ 14 | TARGET_STRIP ?= $(PREFIX)strip 15 | TARGET_STRIP_FLAGS ?= -x 16 | TARGET_CODESIGN_ALLOCATE ?= $(PREFIX)codesign_allocate 17 | TARGET_CODESIGN ?= ldid 18 | TARGET_CODESIGN_FLAGS ?= -S 19 | 20 | include $(THEOS_MAKE_PATH)/targets/_common/darwin.mk 21 | include $(THEOS_MAKE_PATH)/targets/_common/darwin_flat_bundle.mk 22 | 23 | TARGET_PRIVATE_FRAMEWORK_PATH = $(SYSROOT)/System/Library/PrivateFrameworks 24 | 25 | SDKFLAGS := -isysroot $(SYSROOT) 26 | _THEOS_TARGET_CFLAGS := $(SDKFLAGS) 27 | _THEOS_TARGET_LDFLAGS := $(SDKFLAGS) -multiply_defined suppress 28 | 29 | TARGET_INSTALL_REMOTE := $(_THEOS_TRUE) 30 | _THEOS_TARGET_DEFAULT_PACKAGE_FORMAT := deb 31 | endif 32 | -------------------------------------------------------------------------------- /theos/makefiles/targets/Linux/linux.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(_THEOS_TARGET_LOADED),) 2 | _THEOS_TARGET_LOADED := 1 3 | THEOS_TARGET_NAME := linux 4 | 5 | ifneq ($(__THEOS_TARGET_ARG_1),) 6 | CROSS_COMPILE := $(__THEOS_TARGET_ARG_1)- 7 | endif 8 | 9 | TARGET_CC ?= $(CROSS_COMPILE)gcc 10 | TARGET_CXX ?= $(CROSS_COMPILE)g++ 11 | TARGET_LD ?= $(CROSS_COMPILE)g++ 12 | TARGET_STRIP ?= $(CROSS_COMPILE)strip 13 | TARGET_STRIP_FLAGS ?= 14 | TARGET_CODESIGN_ALLOCATE ?= 15 | TARGET_CODESIGN ?= 16 | TARGET_CODESIGN_FLAGS ?= 17 | 18 | include $(THEOS_MAKE_PATH)/targets/_common/linux.mk 19 | 20 | endif 21 | -------------------------------------------------------------------------------- /theos/makefiles/targets/Linux/native.mk: -------------------------------------------------------------------------------- 1 | linux.mk -------------------------------------------------------------------------------- /theos/makefiles/targets/_common/darwin.mk: -------------------------------------------------------------------------------- 1 | # Variables that are common to all Darwin-based targets. 2 | TARGET_EXE_EXT := 3 | TARGET_LIB_EXT := .dylib 4 | 5 | TARGET_LDFLAGS_DYNAMICLIB = -dynamiclib -install_name "$(LOCAL_INSTALL_PATH)/$(1)" 6 | TARGET_CFLAGS_DYNAMICLIB = 7 | 8 | _THEOS_TARGET_ONLY_OBJCFLAGS := -std=c99 9 | 10 | _THEOS_TARGET_SUPPORTS_BUNDLES := 1 11 | -------------------------------------------------------------------------------- /theos/makefiles/targets/_common/darwin_flat_bundle.mk: -------------------------------------------------------------------------------- 1 | _THEOS_TARGET_BUNDLE_INFO_PLIST_SUBDIRECTORY := 2 | _THEOS_TARGET_BUNDLE_RESOURCE_SUBDIRECTORY := 3 | _THEOS_TARGET_BUNDLE_BINARY_SUBDIRECTORY := 4 | -------------------------------------------------------------------------------- /theos/makefiles/targets/_common/darwin_hierarchial_bundle.mk: -------------------------------------------------------------------------------- 1 | _THEOS_TARGET_BUNDLE_INFO_PLIST_SUBDIRECTORY := /Contents 2 | _THEOS_TARGET_BUNDLE_RESOURCE_SUBDIRECTORY := /Contents/Resources 3 | _THEOS_TARGET_BUNDLE_BINARY_SUBDIRECTORY := /Contents/MacOS 4 | -------------------------------------------------------------------------------- /theos/makefiles/targets/_common/linux.mk: -------------------------------------------------------------------------------- 1 | # Variables that are common to all Linux-based targets. 2 | TARGET_EXE_EXT := 3 | TARGET_LIB_EXT := .so 4 | 5 | TARGET_LDFLAGS_DYNAMICLIB = -shared -Wl,-soname,$(1) 6 | TARGET_CFLAGS_DYNAMICLIB = -fPIC 7 | -------------------------------------------------------------------------------- /theos/makefiles/tool.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(THEOS_CURRENT_INSTANCE),) 2 | include $(THEOS_MAKE_PATH)/master/tool.mk 3 | else 4 | ifeq ($(_THEOS_CURRENT_TYPE),tool) 5 | include $(THEOS_MAKE_PATH)/instance/tool.mk 6 | endif 7 | endif 8 | -------------------------------------------------------------------------------- /theos/makefiles/tweak.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(THEOS_CURRENT_INSTANCE),) 2 | include $(THEOS_MAKE_PATH)/master/tweak.mk 3 | else 4 | ifeq ($(_THEOS_CURRENT_TYPE),tweak) 5 | include $(THEOS_MAKE_PATH)/instance/tweak.mk 6 | endif 7 | endif 8 | -------------------------------------------------------------------------------- /theos/mod/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heardrwt/RevealLoader/d422e26bc92749634547d520651710bce6744f7e/theos/mod/.keep -------------------------------------------------------------------------------- /theos/templates/iphone/tool.nic.tar: -------------------------------------------------------------------------------- 1 | .000755000000000000 012022775274 10765 5ustar00dustinstaff000000000000NIC000777000000000000 012022775274 11323 5ustar00dustinstaff000000000000.control000644000765000024 12712022773542 13065 0ustar00dustinstaff000000000000./NICname "iphone/tool" 2 | constrain file "control" to package 3 | constrain "theos" to link_theos 4 | Makefile100644000000000000 20712022772543 12461 0ustar00dustinstaff000000000000.include @@THEOS@@/makefiles/common.mk 5 | 6 | TOOL_NAME = @@PROJECTNAME@@ 7 | @@PROJECTNAME@@_FILES = main.mm 8 | 9 | include $(THEOS_MAKE_PATH)/tool.mk 10 | control100644000000000000 33312016326345 12422 0ustar00dustinstaff000000000000.Package: @@PACKAGENAME@@ 11 | Name: @@FULLPROJECTNAME@@ 12 | Depends: 13 | Version: 0.0.1 14 | Architecture: iphoneos-arm 15 | Description: An awesome tool of some sort!! 16 | Maintainer: @@USER@@ 17 | Author: @@USER@@ 18 | Section: System 19 | Tag: role::hacker 20 | main.mm100644000000000000 11412016326345 12273 0ustar00dustinstaff000000000000.int main(int argc, char **argv, char **envp) { 21 | return 0; 22 | } 23 | 24 | // vim:ft=objc 25 | theos000644000000000000 012022775274 14041 2@@THEOS_PATH@@ustar00dustinstaff000000000000. -------------------------------------------------------------------------------- /third-party/libcurl/curl/curlver.h: -------------------------------------------------------------------------------- 1 | #ifndef __CURL_CURLVER_H 2 | #define __CURL_CURLVER_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at http://curl.haxx.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | ***************************************************************************/ 24 | 25 | /* This header file contains nothing but libcurl version info, generated by 26 | a script at release-time. This was made its own header file in 7.11.2 */ 27 | 28 | /* This is the global package copyright */ 29 | #define LIBCURL_COPYRIGHT "1996 - 2013 Daniel Stenberg, ." 30 | 31 | /* This is the version number of the libcurl package from which this header 32 | file origins: */ 33 | #define LIBCURL_VERSION "7.33.0" 34 | 35 | /* The numeric version number is also available "in parts" by using these 36 | defines: */ 37 | #define LIBCURL_VERSION_MAJOR 7 38 | #define LIBCURL_VERSION_MINOR 33 39 | #define LIBCURL_VERSION_PATCH 0 40 | 41 | /* This is the numeric version of the libcurl version number, meant for easier 42 | parsing and comparions by programs. The LIBCURL_VERSION_NUM define will 43 | always follow this syntax: 44 | 45 | 0xXXYYZZ 46 | 47 | Where XX, YY and ZZ are the main version, release and patch numbers in 48 | hexadecimal (using 8 bits each). All three numbers are always represented 49 | using two digits. 1.2 would appear as "0x010200" while version 9.11.7 50 | appears as "0x090b07". 51 | 52 | This 6-digit (24 bits) hexadecimal number does not show pre-release number, 53 | and it is always a greater number in a more recent release. It makes 54 | comparisons with greater than and less than work. 55 | */ 56 | #define LIBCURL_VERSION_NUM 0x072100 57 | 58 | /* 59 | * This is the date and time when the full source package was created. The 60 | * timestamp is not stored in git, as the timestamp is properly set in the 61 | * tarballs by the maketgz script. 62 | * 63 | * The format of the date should follow this template: 64 | * 65 | * "Mon Feb 12 11:35:33 UTC 2007" 66 | */ 67 | #define LIBCURL_TIMESTAMP "Mon Oct 14 14:42:58 UTC 2013" 68 | 69 | #endif /* __CURL_CURLVER_H */ 70 | -------------------------------------------------------------------------------- /third-party/libcurl/curl/easy.h: -------------------------------------------------------------------------------- 1 | #ifndef __CURL_EASY_H 2 | #define __CURL_EASY_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2008, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at http://curl.haxx.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | ***************************************************************************/ 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | CURL_EXTERN CURL *curl_easy_init(void); 29 | CURL_EXTERN CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...); 30 | CURL_EXTERN CURLcode curl_easy_perform(CURL *curl); 31 | CURL_EXTERN void curl_easy_cleanup(CURL *curl); 32 | 33 | /* 34 | * NAME curl_easy_getinfo() 35 | * 36 | * DESCRIPTION 37 | * 38 | * Request internal information from the curl session with this function. The 39 | * third argument MUST be a pointer to a long, a pointer to a char * or a 40 | * pointer to a double (as the documentation describes elsewhere). The data 41 | * pointed to will be filled in accordingly and can be relied upon only if the 42 | * function returns CURLE_OK. This function is intended to get used *AFTER* a 43 | * performed transfer, all results from this function are undefined until the 44 | * transfer is completed. 45 | */ 46 | CURL_EXTERN CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...); 47 | 48 | 49 | /* 50 | * NAME curl_easy_duphandle() 51 | * 52 | * DESCRIPTION 53 | * 54 | * Creates a new curl session handle with the same options set for the handle 55 | * passed in. Duplicating a handle could only be a matter of cloning data and 56 | * options, internal state info and things like persistent connections cannot 57 | * be transferred. It is useful in multithreaded applications when you can run 58 | * curl_easy_duphandle() for each new thread to avoid a series of identical 59 | * curl_easy_setopt() invokes in every thread. 60 | */ 61 | CURL_EXTERN CURL* curl_easy_duphandle(CURL *curl); 62 | 63 | /* 64 | * NAME curl_easy_reset() 65 | * 66 | * DESCRIPTION 67 | * 68 | * Re-initializes a CURL handle to the default values. This puts back the 69 | * handle to the same state as it was in when it was just created. 70 | * 71 | * It does keep: live connections, the Session ID cache, the DNS cache and the 72 | * cookies. 73 | */ 74 | CURL_EXTERN void curl_easy_reset(CURL *curl); 75 | 76 | /* 77 | * NAME curl_easy_recv() 78 | * 79 | * DESCRIPTION 80 | * 81 | * Receives data from the connected socket. Use after successful 82 | * curl_easy_perform() with CURLOPT_CONNECT_ONLY option. 83 | */ 84 | CURL_EXTERN CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen, 85 | size_t *n); 86 | 87 | /* 88 | * NAME curl_easy_send() 89 | * 90 | * DESCRIPTION 91 | * 92 | * Sends data over the connected socket. Use after successful 93 | * curl_easy_perform() with CURLOPT_CONNECT_ONLY option. 94 | */ 95 | CURL_EXTERN CURLcode curl_easy_send(CURL *curl, const void *buffer, 96 | size_t buflen, size_t *n); 97 | 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /third-party/libcurl/curl/mprintf.h: -------------------------------------------------------------------------------- 1 | #ifndef __CURL_MPRINTF_H 2 | #define __CURL_MPRINTF_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at http://curl.haxx.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | ***************************************************************************/ 24 | 25 | #include 26 | #include /* needed for FILE */ 27 | 28 | #include "curl.h" 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | CURL_EXTERN int curl_mprintf(const char *format, ...); 35 | CURL_EXTERN int curl_mfprintf(FILE *fd, const char *format, ...); 36 | CURL_EXTERN int curl_msprintf(char *buffer, const char *format, ...); 37 | CURL_EXTERN int curl_msnprintf(char *buffer, size_t maxlength, 38 | const char *format, ...); 39 | CURL_EXTERN int curl_mvprintf(const char *format, va_list args); 40 | CURL_EXTERN int curl_mvfprintf(FILE *fd, const char *format, va_list args); 41 | CURL_EXTERN int curl_mvsprintf(char *buffer, const char *format, va_list args); 42 | CURL_EXTERN int curl_mvsnprintf(char *buffer, size_t maxlength, 43 | const char *format, va_list args); 44 | CURL_EXTERN char *curl_maprintf(const char *format, ...); 45 | CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args); 46 | 47 | #ifdef _MPRINTF_REPLACE 48 | # undef printf 49 | # undef fprintf 50 | # undef sprintf 51 | # undef vsprintf 52 | # undef snprintf 53 | # undef vprintf 54 | # undef vfprintf 55 | # undef vsnprintf 56 | # undef aprintf 57 | # undef vaprintf 58 | # define printf curl_mprintf 59 | # define fprintf curl_mfprintf 60 | #ifdef CURLDEBUG 61 | /* When built with CURLDEBUG we define away the sprintf functions since we 62 | don't want internal code to be using them */ 63 | # define sprintf sprintf_was_used 64 | # define vsprintf vsprintf_was_used 65 | #else 66 | # define sprintf curl_msprintf 67 | # define vsprintf curl_mvsprintf 68 | #endif 69 | # define snprintf curl_msnprintf 70 | # define vprintf curl_mvprintf 71 | # define vfprintf curl_mvfprintf 72 | # define vsnprintf curl_mvsnprintf 73 | # define aprintf curl_maprintf 74 | # define vaprintf curl_mvaprintf 75 | #endif 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | 81 | #endif /* __CURL_MPRINTF_H */ 82 | -------------------------------------------------------------------------------- /third-party/libcurl/curl/stdcheaders.h: -------------------------------------------------------------------------------- 1 | #ifndef __STDC_HEADERS_H 2 | #define __STDC_HEADERS_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2010, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at http://curl.haxx.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | ***************************************************************************/ 24 | 25 | #include 26 | 27 | size_t fread (void *, size_t, size_t, FILE *); 28 | size_t fwrite (const void *, size_t, size_t, FILE *); 29 | 30 | int strcasecmp(const char *, const char *); 31 | int strncasecmp(const char *, const char *, size_t); 32 | 33 | #endif /* __STDC_HEADERS_H */ 34 | -------------------------------------------------------------------------------- /third-party/libcurl/libcurl.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heardrwt/RevealLoader/d422e26bc92749634547d520651710bce6744f7e/third-party/libcurl/libcurl.a -------------------------------------------------------------------------------- /third-party/partialzip/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | INCLUDE(FindCURL) 2 | INCLUDE(FindZLIB) 3 | 4 | cmake_minimum_required(VERSION 2.6) 5 | 6 | SET(BUILD_PARTIAL TRUE) 7 | 8 | IF(NOT ZLIB_FOUND) 9 | message(STATUS "zlib is required for partial!") 10 | SET(BUILD_PARTIAL FALSE) 11 | ENDIF(NOT ZLIB_FOUND) 12 | 13 | IF(NOT CURL_FOUND) 14 | message(STATUS "curl is required for partial!") 15 | SET(BUILD_PARTIAL FALSE) 16 | ENDIF(NOT CURL_FOUND) 17 | 18 | IF(BUILD_PARTIAL) 19 | include_directories(${ZLIB_INCLUDE_DIR}) 20 | include_directories(${CURL_INCLUDE_DIR}) 21 | include_directories(include) 22 | 23 | IF(WIN32) 24 | add_definitions(-DCURL_STATICLIB) 25 | ENDIF(WIN32) 26 | 27 | add_library(partial partial.c) 28 | target_link_libraries(partial ${CURL_LIBRARIES} ${ZLIB_LIBRARIES}) 29 | 30 | add_executable(test test.c) 31 | target_link_libraries(test partial) 32 | ENDIF(BUILD_PARTIAL) 33 | 34 | -------------------------------------------------------------------------------- /third-party/partialzip/README: -------------------------------------------------------------------------------- 1 | Use cmake 2.6 to create the Makefiles for this. 2 | 3 | Requires libcurl 7.19.4 for file:// URL support. 4 | 5 | test.c contains an example that is designed for a simple test.zip containing 6 | only a text.txt. 7 | 8 | -------------------------------------------------------------------------------- /third-party/partialzip/include/common.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_H 2 | #define COMMON_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #ifdef WIN32 11 | #define fseeko fseeko64 12 | #define ftello ftello64 13 | #define off_t off64_t 14 | #define mkdir(x, y) mkdir(x) 15 | #define PATH_SEPARATOR "\\" 16 | #else 17 | #define PATH_SEPARATOR "/" 18 | #endif 19 | 20 | #define TRUE 1 21 | #define FALSE 0 22 | 23 | #define FLIPENDIAN(x) flipEndian((unsigned char *)(&(x)), sizeof(x)) 24 | #define FLIPENDIANLE(x) flipEndianLE((unsigned char *)(&(x)), sizeof(x)) 25 | 26 | #define IS_BIG_ENDIAN 0 27 | #define IS_LITTLE_ENDIAN 1 28 | 29 | #define TIME_OFFSET_FROM_UNIX 2082844800L 30 | #define APPLE_TO_UNIX_TIME(x) ((x) - TIME_OFFSET_FROM_UNIX) 31 | #define UNIX_TO_APPLE_TIME(x) ((x) + TIME_OFFSET_FROM_UNIX) 32 | 33 | #define ASSERT(x, m) if(!(x)) { fflush(stdout); fprintf(stderr, "error: %s\n", m); perror("error"); fflush(stderr); exit(1); } 34 | 35 | extern char endianness; 36 | 37 | static inline void flipEndian(unsigned char* x, int length) { 38 | int i; 39 | unsigned char tmp; 40 | 41 | if(endianness == IS_BIG_ENDIAN) { 42 | return; 43 | } else { 44 | for(i = 0; i < (length / 2); i++) { 45 | tmp = x[i]; 46 | x[i] = x[length - i - 1]; 47 | x[length - i - 1] = tmp; 48 | } 49 | } 50 | } 51 | 52 | static inline void flipEndianLE(unsigned char* x, int length) { 53 | int i; 54 | unsigned char tmp; 55 | 56 | if(endianness == IS_LITTLE_ENDIAN) { 57 | return; 58 | } else { 59 | for(i = 0; i < (length / 2); i++) { 60 | tmp = x[i]; 61 | x[i] = x[length - i - 1]; 62 | x[length - i - 1] = tmp; 63 | } 64 | } 65 | } 66 | 67 | static inline void hexToBytes(const char* hex, uint8_t** buffer, size_t* bytes) { 68 | *bytes = strlen(hex) / 2; 69 | *buffer = (uint8_t*) malloc(*bytes); 70 | size_t i; 71 | for(i = 0; i < *bytes; i++) { 72 | uint32_t byte; 73 | sscanf(hex, "%2x", &byte); 74 | (*buffer)[i] = byte; 75 | hex += 2; 76 | } 77 | } 78 | 79 | static inline void hexToInts(const char* hex, unsigned int** buffer, size_t* bytes) { 80 | *bytes = strlen(hex) / 2; 81 | *buffer = (unsigned int*) malloc((*bytes) * sizeof(int)); 82 | size_t i; 83 | for(i = 0; i < *bytes; i++) { 84 | sscanf(hex, "%2x", &((*buffer)[i])); 85 | hex += 2; 86 | } 87 | } 88 | 89 | struct io_func_struct; 90 | 91 | typedef int (*readFunc)(struct io_func_struct* io, off_t location, size_t size, void *buffer); 92 | typedef int (*writeFunc)(struct io_func_struct* io, off_t location, size_t size, void *buffer); 93 | typedef void (*closeFunc)(struct io_func_struct* io); 94 | 95 | typedef struct io_func_struct { 96 | void* data; 97 | readFunc read; 98 | writeFunc write; 99 | closeFunc close; 100 | } io_func; 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /third-party/partialzip/include/partial/partial.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | typedef struct EndOfCD { 6 | uint32_t signature; 7 | uint16_t diskNo; 8 | uint16_t CDDiskNo; 9 | uint16_t CDDiskEntries; 10 | uint16_t CDEntries; 11 | uint32_t CDSize; 12 | uint32_t CDOffset; 13 | uint16_t lenComment; 14 | } __attribute__ ((packed)) EndOfCD; 15 | 16 | typedef struct CDFile { 17 | uint32_t signature; 18 | uint16_t version; 19 | uint16_t versionExtract; 20 | uint16_t flags; 21 | uint16_t method; 22 | uint16_t modTime; 23 | uint16_t modDate; 24 | uint32_t crc32; 25 | uint32_t compressedSize; 26 | uint32_t size; 27 | uint16_t lenFileName; 28 | uint16_t lenExtra; 29 | uint16_t lenComment; 30 | uint16_t diskStart; 31 | uint16_t internalAttr; 32 | uint32_t externalAttr; 33 | uint32_t offset; 34 | } __attribute__ ((packed)) CDFile; 35 | 36 | typedef struct LocalFile { 37 | uint32_t signature; 38 | uint16_t versionExtract; 39 | uint16_t flags; 40 | uint16_t method; 41 | uint16_t modTime; 42 | uint16_t modDate; 43 | uint32_t crc32; 44 | uint32_t compressedSize; 45 | uint32_t size; 46 | uint16_t lenFileName; 47 | uint16_t lenExtra; 48 | } __attribute__ ((packed)) LocalFile; 49 | 50 | typedef struct ZipInfo ZipInfo; 51 | 52 | typedef size_t (*PartialZipGetFileCallback)(ZipInfo* info, CDFile* file, unsigned char *buffer, size_t size, void *userInfo); 53 | 54 | struct ZipInfo { 55 | char* url; 56 | uint64_t length; 57 | CURL* hCurl; 58 | char* centralDirectory; 59 | size_t centralDirectoryRecvd; 60 | EndOfCD* centralDirectoryDesc; 61 | char centralDirectoryEnd[0xffff + sizeof(EndOfCD)]; 62 | size_t centralDirectoryEndRecvd; 63 | }; 64 | 65 | #ifdef __cplusplus 66 | extern "C" { 67 | #endif 68 | 69 | ZipInfo* PartialZipInit(const char* url); 70 | 71 | CDFile* PartialZipFindFile(ZipInfo* info, const char* fileName); 72 | unsigned char* PartialZipCopyFileName(ZipInfo* info, CDFile* file); 73 | 74 | CDFile* PartialZipListFiles(ZipInfo* info); 75 | 76 | bool PartialZipGetFile(ZipInfo* info, CDFile* file, PartialZipGetFileCallback callback, void *userInfo); 77 | bool PartialZipGetFiles(ZipInfo* info, CDFile* files[], size_t count, PartialZipGetFileCallback callback, void *userInfo); 78 | 79 | void PartialZipRelease(ZipInfo* info); 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | 85 | -------------------------------------------------------------------------------- /third-party/partialzip/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "common.h" 3 | #include 4 | 5 | char endianness = IS_LITTLE_ENDIAN; 6 | 7 | size_t data_callback(ZipInfo* info, CDFile* file, unsigned char *buffer, size_t size, void *userInfo) 8 | { 9 | char **pos = userInfo; 10 | memcpy(*pos, buffer, size); 11 | *pos += size; 12 | } 13 | 14 | int main(int argc, char* argv[]) { 15 | ZipInfo* info = PartialZipInit("file://test.zip"); 16 | if(!info) 17 | { 18 | printf("Cannot find /tmp/test.zip\n"); 19 | return 0; 20 | } 21 | 22 | CDFile* file = PartialZipFindFile(info, "test.txt"); 23 | if(!file) 24 | { 25 | printf("Cannot find test.txt in /tmp/test.zip\n"); 26 | return 0; 27 | } 28 | 29 | int dataLen = file->size; 30 | unsigned char *data = malloc(dataLen+1); 31 | unsigned char *pos = data; 32 | PartialZipGetFile(info, file, data_callback, &pos); 33 | *pos = '\0'; 34 | 35 | PartialZipRelease(info); 36 | 37 | printf("%s\n", data); 38 | 39 | free(data); 40 | 41 | return 0; 42 | } 43 | 44 | --------------------------------------------------------------------------------