├── .gitignore ├── CheckEnv.py ├── LICENSE.md ├── Patches └── libressl-2.2.1.patch ├── README.md ├── SDK3Build.py ├── Utils ├── Python │ ├── ARCommandsParser.py │ ├── ARFuncs.py │ ├── ARSDK_PrebuildActions.py │ ├── Android_BuildLibrary.py │ ├── Android_CreateFiles.py │ ├── Android_GenLibraryDoc.py │ ├── Common_BuildConfigureLibrary.py │ ├── Common_CheckBootstrap.py │ ├── Common_CheckConfigure.py │ ├── Common_GenAutotoolsLibraryDoc.py │ ├── Common_GitUtils.py │ ├── Common_HandlePrebuiltDep.py │ ├── Common_RemoveVersionsFromSo.py │ ├── Common_RunAntScript.py │ ├── Darwin_RunXcodeBuild.py │ ├── Java_GenLibraryDoc.py │ ├── Unix_BuildBinary.py │ ├── Unix_BuildLibrary.py │ ├── Unix_GenLibraryDoc.py │ ├── commandLine.py │ ├── iOS_BuildLibrary.py │ ├── iOS_GenLibraryDoc.py │ ├── iOS_HandlePrebuiltDep.py │ └── xmlreader.py ├── cleanupSDKRepo.bash ├── copyDoc.bash ├── generateDocIndex.bash ├── m4 │ └── ARSDK.m4 └── updateGitStatus.bash ├── atom.mk ├── binaries.xml ├── libraries.xml ├── prebuilt.xml ├── repos.xml └── targets.xml /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | Ant/ 3 | Build/ 4 | Install/ 5 | /.alreadyLaunched 6 | *.pyc 7 | *.log 8 | .tmpAndroidProcess/ 9 | AndroidStudio/ -------------------------------------------------------------------------------- /CheckEnv.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | ''' 3 | Copyright (C) 2014 Parrot SA 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 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Parrot nor the names 15 | of its contributors may be used to endorse or promote products 16 | derived from this software without specific prior written 17 | permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 22 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 26 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 27 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | SUCH DAMAGE. 31 | ''' 32 | 33 | import sys 34 | import os 35 | 36 | MYDIR=os.path.abspath(os.path.dirname(sys.argv[0])) 37 | if '' == MYDIR: 38 | MYDIR=os.getcwd() 39 | sys.path.append('%(MYDIR)s/Utils/Python' % locals()) 40 | 41 | from ARFuncs import * 42 | import xmlreader 43 | import tempfile 44 | 45 | #This is a message to announce the new build system 46 | ARPrint ('\n\nThis script is deprecated and doesn\'t work anymore.\n') 47 | ARPrint ('Please download repo (http://source.android.com/source/downloading.html#installing-repo).') 48 | ARPrint ('Then run \'repo init -u https://github.com/Parrot-Developers/arsdk_manifests.git\' in an empty folder.') 49 | ARPrint ('Then run \'repo sync\' to get all sources.') 50 | ARPrint ('After that, you\'ll be able to run \'./build.sh\' to build the SDK.') 51 | ARPrint ('\n\nYou can find a full documentation here: http://developer.parrot.com/docs/bebop/#go-deeper\n\n') 52 | exit(0) 53 | # After that comment, this is the old build. Left here in memory of the old time we spent building the SDK with it. RIP 54 | 55 | 56 | uname = ARExecuteGetStdout(["uname"], printErrorMessage=False).lower() 57 | 58 | 59 | targets = [ 60 | { 61 | 'name' : 'Generic', 62 | 'platforms' : ['darwin', 'linux'], 63 | 'mandatoryPlatform' : False, 64 | 'bins' : ['git', 'wget', 'jar', 'automake', 'autoconf', 'libtool'], 65 | 'libs' : [], 66 | 'envs' : [], 67 | 'cmds' : [], 68 | 'CC' : None, 69 | }, 70 | { 71 | 'name' : 'iOS', 72 | 'platforms' : ['darwin'], 73 | 'mandatoryPlatform' : True, 74 | 'bins' : ['xcrun', 'xcodebuild'], 75 | 'libs' : [], 76 | 'envs' : [], 77 | 'cmds' : [], 78 | 'CC' : None, 79 | }, 80 | { 81 | 'name' : 'Unix', 82 | 'platforms' : ['darwin', 'linux'], 83 | 'mandatoryPlatform' : False, 84 | 'bins' : ['gcc', 'yasm', 'nasm'], 85 | 'libs' : ['-lz', '-pthread'], 86 | 'envs' : [], 87 | 'cmds' : [], 88 | 'CC' : 'gcc', 89 | }, 90 | { 91 | 'name' : 'Android', 92 | 'platforms' : ['darwin', 'linux'], 93 | 'mandatoryPlatform' : False, 94 | 'bins' : ['rpl', 'javac', 'arm-linux-androideabi-gcc', 'mipsel-linux-android-gcc', 'i686-linux-android-gcc'], 95 | 'libs' : ['-llog'], 96 | 'envs' : ['ANDROID_NDK_PATH', 'ANDROID_SDK_PATH'], 97 | 'cmds' : [ 98 | {'cmd': '$ANDROID_SDK_PATH/tools/android list targets | grep "API level:" | grep 19', 99 | 'desc': 'Check if Android SDK 19 is installed', 100 | 'fix': 'Missing Android SDK for API 19 (Android 4.4.2), please install it.' 101 | }, 102 | ], 103 | 'CC' : 'arm-linux-androideabi-gcc', 104 | }, 105 | ] 106 | 107 | doPrint = True 108 | verbose = False 109 | statusTarget = None 110 | if len(sys.argv) > 1: 111 | if sys.argv[1] == '-v': 112 | verbose = True 113 | else: 114 | statusTarget = sys.argv[1] 115 | doPrint = False 116 | if not statusTarget in ['Generic', 'iOS', 'Android', 'Unix']: 117 | ARPrint('Unknown options, this script only support `-v`, `Generic`, `iOS`, `Android` and `Unix`') 118 | sys.exit(1) 119 | 120 | 121 | hasColors = ARExecute('tput colors >/dev/null 2>&1', failOnError=False, printErrorMessage=False) 122 | 123 | class logcolors: 124 | FAIL = '\033[31m' if hasColors else 'FA:' 125 | PASS = '\033[32m' if hasColors else 'OK:' 126 | NONE = '\033[33m' if hasColors else 'NT:' 127 | DEF = '\033[39m' if hasColors else '' 128 | 129 | def ARCEPrint(msg, noNewLine=False): 130 | if verbose: 131 | ARPrint(msg, noNewLine=noNewLine) 132 | 133 | def ARVBPrint(msg, noNewLine=False): 134 | if doPrint: 135 | ARPrint(msg, noNewLine=noNewLine) 136 | 137 | def ARPrintStatus(msg, status=False, unknown=False, padTo=20): 138 | if unknown: 139 | ARVBPrint(logcolors.NONE, noNewLine=True) 140 | elif status: 141 | ARVBPrint(logcolors.PASS, noNewLine=True) 142 | else: 143 | ARVBPrint(logcolors.FAIL, noNewLine=True) 144 | ARVBPrint(msg, noNewLine=True) 145 | if len(msg) < padTo: 146 | ARVBPrint(' '*(padTo-len(msg)), noNewLine=True) 147 | ARVBPrint(logcolors.DEF, noNewLine=True) 148 | 149 | def ARAppendToMessage(orig, msg, leftPad=22): 150 | if len(orig) == 0: 151 | return msg 152 | return orig + '\n' + ' '*leftPad + msg 153 | 154 | ARVBPrint('-- Checking if your environment will build the ARSDK for different platforms --') 155 | ARVBPrint('') 156 | ARVBPrint('[[ ' + logcolors.PASS + 'Should work' + logcolors.DEF + ', ' + logcolors.FAIL + 'Won\'t work' + logcolors.DEF + ', ' + logcolors.NONE + 'Not tested, may work' + logcolors.DEF + ' ]]') 157 | ARVBPrint('') 158 | 159 | if sys.version_info < (2, 7): 160 | ARVBPrint(logcolors.FAIL + ' Bad python version.' + logcolors.DEF + ' The SDK requires python 2.7 or higher (python 3 versions are supported)') 161 | ARVBPrint('') 162 | sys.exit(1) 163 | 164 | 165 | if ' ' in MYDIR: 166 | ARVBPrint(logcolors.FAIL + ' Bad folder name.' + logcolors.DEF + ' The SDK needs an absolute path without spaces. There is at least one space in the current path :') 167 | ARVBPrint( ' "' + MYDIR + '"') 168 | ARVBPrint('') 169 | sys.exit(1) 170 | 171 | DirLastPath=os.path.basename(MYDIR) 172 | if DirLastPath != 'ARSDKBuildUtils': 173 | ARVBPrint(logcolors.FAIL + ' Bad folder name.' + logcolors.DEF + ' The SDK needs to be in a folder named "ARSDKBuildUtils", but the current folder is named "'+DirLastPath+'".') 174 | ARVBPrint('') 175 | sys.exit(1) 176 | 177 | 178 | 179 | for t in targets: 180 | status = True 181 | unknown = False 182 | msg = '' 183 | ARCEPrint ('Checking target %s ...' % t['name']) 184 | ARCEPrint ('--------------------------') 185 | ARCEPrint ('Checking platform ...', noNewLine=True) 186 | if uname in t['platforms'] or not t['mandatoryPlatform']: 187 | if not uname in t['platforms']: 188 | ARCEPrint(' Unknown (%s)' % uname) 189 | msg = ARAppendToMessage(msg, 'Unknown platform `%s`, the target `%s` has only been tested on %s ' % (uname, t['name'], t['platforms'])) 190 | unknown = True 191 | else: 192 | ARCEPrint(' OK (%s)' % uname) 193 | for b in t['bins']: 194 | ARCEPrint('Checking if binary `%s` is available in PATH ...' % b, noNewLine=True) 195 | if not ARExistsInPath(b): 196 | ARCEPrint(' NO') 197 | msg = ARAppendToMessage(msg, 'Missing binary `%s`' % b) 198 | status = False 199 | else: 200 | ARCEPrint(' YES') 201 | for l in t['libs']: 202 | ARCEPrint('Checking if library `%s` is available for linking ...' % l, noNewLine=True) 203 | (sfHandle, sfPath) = tempfile.mkstemp(suffix='.c') 204 | (binHandle, binPath) = tempfile.mkstemp(suffix='.out') 205 | os.close(binHandle) 206 | os.remove(binPath) 207 | sfFile = os.fdopen(sfHandle, 'w') 208 | sfFile.write('int main(int argc, char *argv[]) { return 0; }\n') 209 | sfFile.close() 210 | compiler = t['CC'] 211 | if not compiler or not ARExistsInPath(compiler): 212 | ARCEPrint(' NO COMPILER FOUND') 213 | status = False 214 | else: 215 | if not ARExecute('%(compiler)s -o %(binPath)s %(sfPath)s %(l)s >/dev/null 2>&1' % locals(), printErrorMessage=False, failOnError=False): 216 | ARCEPrint(' NO') 217 | status = False 218 | msg = ARAppendToMessage(msg, 'Missing library `%s`' % l) 219 | else: 220 | ARCEPrint(' YES') 221 | if os.path.exists(binPath): 222 | os.remove(binPath) 223 | os.remove(sfPath) 224 | 225 | for e in t['envs']: 226 | ARCEPrint('Checking if the environment variable `%s` is set ...' % e, noNewLine=True) 227 | if not e in os.environ: 228 | ARCEPrint(' NO') 229 | msg = ARAppendToMessage(msg, 'Missing environment variable `%s`' % e) 230 | status = False 231 | else: 232 | ARCEPrint(' YES') 233 | for f in t['cmds']: 234 | ARCEPrint('Checking if the command `%s` (%s) works ...' % (f['cmd'], f['desc']), noNewLine=True) 235 | if not ARExecute(f['cmd'] + ' >/dev/null 2>&1', printErrorMessage=False, failOnError=False): 236 | ARCEPrint(' NO') 237 | status = False 238 | msg = ARAppendToMessage(msg, f['fix']) 239 | else: 240 | ARCEPrint(' YES') 241 | 242 | else: 243 | status = False 244 | ARCEPrint(' Bad (%s)' % uname) 245 | msg = ARAppendToMessage(msg, 'Bad platform `%s`, you need to be on %s to build the target `%s`' % (uname, t['platforms'], t['name'])) 246 | ARCEPrint('') 247 | ARPrintStatus (t['name'], status, unknown) 248 | t['status'] = status 249 | t['unknown'] = unknown 250 | ARVBPrint(': ', noNewLine=True) 251 | if not msg: 252 | msg = 'OK !' 253 | ARVBPrint(msg) 254 | ARCEPrint('') 255 | if t['name'] == 'Generic': 256 | globalStatus = status 257 | if not globalStatus: 258 | ARVBPrint('ERROR !') 259 | break 260 | 261 | ARVBPrint('') 262 | 263 | if not globalStatus: 264 | ARVBPrint(logcolors.FAIL + 'Basic configuration is not met' + logcolors.DEF + ', the SDK3Build.py script will probably fail even before trying to build a target. Fix errors for virtual target "Generic" before launching the script') 265 | ARVBPrint('') 266 | 267 | 268 | 269 | if statusTarget: 270 | for t in targets: 271 | if t['name'] == statusTarget: 272 | status = 0 if not t['unknown'] and t['status'] else 1 273 | sys.exit(status) 274 | sys.exit(1) 275 | 276 | sys.exit(0) 277 | 278 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (C) 2014 Parrot SA 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in 10 | the documentation and/or other materials provided with the 11 | distribution. 12 | * Neither the name of Parrot nor the names 13 | of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written 15 | permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 21 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 23 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 24 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 25 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 27 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | SUCH DAMAGE. -------------------------------------------------------------------------------- /Patches/libressl-2.2.1.patch: -------------------------------------------------------------------------------- 1 | diff --git libressl-2.2.1/crypto/compat/reallocarray.c libressl-2.2.1-new/crypto/compat/reallocarray.c 2 | index aa70686..41a3326 100644 3 | --- libressl-2.2.1/crypto/compat/reallocarray.c 4 | +++ libressl-2.2.1-new/crypto/compat/reallocarray.c 5 | @@ -19,6 +19,7 @@ 6 | #include 7 | #include 8 | #include 9 | +#include 10 | 11 | /* 12 | * This is sqrt(SIZE_MAX+1), as s1*s2 <= SIZE_MAX 13 | diff --git libressl-2.2.1/include/machine/endian.h libressl-2.2.1-new/include/machine/endian.h 14 | index 5ec39af..6f6d31f 100644 15 | --- libressl-2.2.1/include/machine/endian.h 16 | +++ libressl-2.2.1-new/include/machine/endian.h 17 | @@ -21,6 +21,9 @@ 18 | #define BYTE_ORDER BIG_ENDIAN 19 | #endif 20 | 21 | +#elif defined(__ANDROID__) 22 | +#include_next 23 | + 24 | #elif defined(__linux__) 25 | #include 26 | 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Important note 2 | ------------- 3 | 4 | Please note that, as the version 3.8 (included) this repository is not in charge of the build anymore. To build the SDK please read the documentation 5 | 6 | Usage 7 | ------------- 8 | If you want to use the SDK directly in your iOS or Android projects, please read the [How to use documentation](http://developer.parrot.com/docs/bebop/#how-to-use). 9 | If you prefer to browse the code and build your own SDK, please read [the install documentation](http://developer.parrot.com/docs/bebop/#go-deeper). 10 | 11 | Questions 12 | ---- 13 | **If you have any questions, please open a new DroneSDK topic on the [Parrot Developer forum](http://forum.developer.parrot.com/).** -------------------------------------------------------------------------------- /SDK3Build.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | ''' 3 | Copyright (C) 2014 Parrot SA 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 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Parrot nor the names 15 | of its contributors may be used to endorse or promote products 16 | derived from this software without specific prior written 17 | permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 22 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 26 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 27 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | SUCH DAMAGE. 31 | ''' 32 | # PYTHON_ARGCOMPLETE_OK 33 | 34 | #Generic imports 35 | import os 36 | import sys 37 | import subprocess 38 | import shutil 39 | try: 40 | import argcomplete 41 | hasArgComplete = True 42 | except ImportError: 43 | hasArgComplete = False 44 | 45 | MYDIR=os.path.abspath(os.path.dirname(sys.argv[0])) 46 | if '' == MYDIR: 47 | MYDIR=os.getcwd() 48 | 49 | sys.path.append('%(MYDIR)s/Utils/Python' % locals()) 50 | 51 | #Custom imports 52 | from xml.dom.minidom import parseString 53 | 54 | from ARFuncs import * 55 | from time import localtime, strftime 56 | from Common_GitUtils import * 57 | import commandLine 58 | import xmlreader 59 | import time 60 | 61 | 62 | #This is a message to announce the new build system 63 | ARPrint ('\n\nThis script is deprecated and doesn\'t work anymore.\n') 64 | ARPrint ('Please download repo (http://source.android.com/source/downloading.html#installing-repo).') 65 | ARPrint ('Then run \'repo init -u https://github.com/Parrot-Developers/arsdk_manifests.git\' in an empty folder.') 66 | ARPrint ('Then run \'repo sync\' to get all sources.') 67 | ARPrint ('After that, you\'ll be able to run \'./build.sh\' to build the SDK.') 68 | ARPrint ('\n\nYou can find a full documentation here: http://developer.parrot.com/docs/bebop/#go-deeper\n\n') 69 | exit(0) 70 | # After that comment, this is the old build. Left here in memory of the old time we spent building the SDK with it. RIP 71 | 72 | start = time.time() 73 | 74 | DEBUG_MODE = False 75 | 76 | # 77 | # Init the log file 78 | # 79 | ARInitLogFile() 80 | 81 | # 82 | # Get extra xml dirs 83 | # 84 | xmlDirs = [ MYDIR ] 85 | try: 86 | extraXmlDirs = os.environ['ARSDK_EXTRA_XML_DIRS'].split(':') 87 | xmlDirs.extend(extraXmlDirs) 88 | xmlDirs.remove('') 89 | except: 90 | pass 91 | 92 | # 93 | # Parse XML 94 | # 95 | (repos, targets, prebuilts, libraries, binaries) = xmlreader.parseAll(xmlDirs) 96 | 97 | if DEBUG_MODE: 98 | ARPrint ('Debug mode enabled : dump XML contents') 99 | repos.dump() 100 | targets.dump() 101 | prebuilts.dump() 102 | libraries.dump() 103 | binaries.dump() 104 | EXIT(0) 105 | 106 | # 107 | # Parse command line args 108 | # 109 | parser = commandLine.CommandLineParser(targets, libraries, binaries) 110 | if hasArgComplete: 111 | argcomplete.autocomplete(parser.parser) 112 | parser.parse(sys.argv) 113 | 114 | # 115 | # Dump command line args into log file 116 | # 117 | parser.dump() 118 | 119 | # 120 | # Export useful tools if available 121 | # (e.g. colormake) 122 | # 123 | ARMakeArgs = '-j ' + str(parser.threads) 124 | ARSetEnvIfExists('ARMAKE', 'colormake', 'make', args=ARMakeArgs) 125 | 126 | # Import targets functions for library/binary/doc 127 | # This block will try to import the functions for all targets declared in targets.xml file 128 | # Adding a new target requires the following modifications : 129 | # 1> Add the target in targets.xml filr 130 | # 2> Adapt libraries.xml / binaries.xml to support this target 131 | # 3> Create the Target_BuildLibrary.py script in Utils/Python dir 132 | # -> This file must contain a Target_BuildLibrary(target, lib, clean=False, debug=False) function 133 | # 4> (Optionnal) Create the Target_BuildBinary.py script in Utils/Python dir 134 | # -> This file must contain a Target_BuildBinary(target, bin, clean=False, debug=False) function 135 | # 5> (Optionnal) Create the Target_GenLibraryDoc.py script in Utils/Python dir 136 | # -> This file must contain a Target_GenLibraryDoc(target, lib, clean=False) function 137 | BUILD_LIB_FUNCS = {} 138 | BUILD_BIN_FUNCS = {} 139 | GEN_DOC_FUNCS = {} 140 | for t in targets.list: 141 | try: 142 | _name = t.name + '_BuildLibrary' 143 | _module = __import__ (_name) 144 | BUILD_LIB_FUNCS[t.name] = getattr (_module, _name) 145 | except ImportError: 146 | pass 147 | try: 148 | _name = t.name + '_BuildBinary' 149 | _module = __import__ (_name) 150 | BUILD_BIN_FUNCS[t.name] = getattr (_module, _name) 151 | except ImportError: 152 | pass 153 | try: 154 | _name = t.name + '_GenLibraryDoc' 155 | _module = __import__ (_name) 156 | GEN_DOC_FUNCS[t.name] = getattr (_module, _name) 157 | except ImportError: 158 | pass 159 | 160 | # 161 | # Do force clean if needed 162 | # 163 | if parser.isForceClean: 164 | ARLog("Force clean !") 165 | TARGETDIR = '%(MYDIR)s/Targets' % locals() 166 | ARDeleteIfExists (TARGETDIR) 167 | # Do all-cleanup if needed 168 | if parser.isForceCleanup: 169 | allRepoDirs=[] 170 | for repo in repos.list: 171 | if not repo.ext: 172 | allRepoDirs.append(repo.getDir()) 173 | cleanScript = '%(MYDIR)s/Utils/cleanupSDKRepo.bash' % locals() 174 | ARExecute(cleanScript + ' ' + ARListAsBashArg(allRepoDirs)) 175 | exit(0) 176 | 177 | # 178 | # Do all repo work: 179 | # - Clone non existant repositories 180 | # - Checkout the requested branch/tag/commit 181 | # - If on a branch, pull it 182 | # 183 | if not parser.noGit: 184 | checkAllReposUpToDate(repos, MYDIR, parser.repoBaseUrl, parser.defaultBaseRepoUrl, extraScripts=parser.extraGitScripts) 185 | else: 186 | ARLog('Skipping git checks') 187 | 188 | if parser.doNothing: 189 | ARLog('Nothing to be done') 190 | exit(0) 191 | 192 | # Android case --> Force minimum api level and target api level 193 | ARSetEnv('AR_ANDROID_MIN_VERSION', '14') 194 | ARSetEnv('AR_ANDROID_API_VERSION', '19') 195 | 196 | # 197 | # Actual build loop 198 | # 199 | allOk = True 200 | for target in parser.activeTargets: 201 | libraries.clearCache() 202 | binaries.clearCache() 203 | if parser.activeLibs: 204 | if target.name in BUILD_LIB_FUNCS: 205 | for lib in parser.activeLibs: 206 | if not BUILD_LIB_FUNCS[target.name](target, lib, clean=parser.isClean, debug=parser.isDebug, nodeps=parser.noDeps, inhouse=parser.isInHouse, requestedArchs=parser.archs, isMp=parser.multiProcess): 207 | allOk = False 208 | else: 209 | ARLog('Unable to build libraries for target %(target)s' % locals()) 210 | if parser.genDoc and not parser.isClean: 211 | if target.name in GEN_DOC_FUNCS: 212 | for lib in parser.activeLibs: 213 | GEN_DOC_FUNCS[target.name](target, lib) 214 | TargetDocIndexScript = ARPathFromHere('Utils/generateDocIndex.bash') 215 | TargetDocIndexPath = ARPathFromHere('Targets/%(target)s/Build/Doc' % locals()) 216 | ARExecute('%(TargetDocIndexScript)s %(TargetDocIndexPath)s %(target)s' % locals()) 217 | else: 218 | ARLog('Unable to generate documentation for target %(target)s' % locals()) 219 | 220 | if parser.activeBins: 221 | if target.name in BUILD_BIN_FUNCS: 222 | for bin in parser.activeBins: 223 | if not BUILD_BIN_FUNCS[target.name](target, bin, clean=parser.isClean, debug=parser.isDebug, nodeps=parser.noDeps, inhouse=parser.isInHouse, requestedArchs=parser.archs): 224 | target.failed = True 225 | allOk = False 226 | else: 227 | ARLog('Unable to build binaries for target %(target)s' % locals()) 228 | 229 | for scrinfo in target.postbuildScripts: 230 | scr = scrinfo['path'] 231 | if allOk: 232 | if not ARExecute(scr + ' >/dev/null 2>&1', failOnError=False): 233 | ARPrint('Error while running ' + scr + '. Run manually to see the output') 234 | target.failed = True 235 | scrinfo['done'] = False 236 | allOk=False 237 | else: 238 | scrinfo['done'] = True 239 | if not allOk: 240 | break 241 | 242 | if parser.installDoc and allOk: 243 | DocCopyScript = ARPathFromHere('Utils/copyDoc.bash') 244 | for target in parser.activeTargets: 245 | ARExecute ('%(DocCopyScript)s %(target)s' % locals()) 246 | 247 | hasColors = ARExecute('tput colors >/dev/null 2>&1', failOnError=False, printErrorMessage=False) 248 | if ARExistsInPath('stty'): 249 | termSizeStr = ARExecuteGetStdout(['stty', 'size'], failOnError=False, printErrorMessage=False) 250 | termSizeArr = termSizeStr.split(' ') 251 | try: 252 | termCols = int(termSizeArr[1]) - 1 253 | except: 254 | termCols = 80 255 | else: 256 | termCols = 80 257 | 258 | 259 | class logcolors: 260 | FAIL = '\033[31m' if hasColors else 'FA:' 261 | PASS = '\033[32m' if hasColors else 'OK:' 262 | REQ = '\033[33m' if hasColors else 'ND:' 263 | NONE = '\033[34m' if hasColors else 'NR:' 264 | UNAI = '\033[30m' if hasColors else 'NA:' 265 | DEF = '\033[39m' if hasColors else '' 266 | 267 | def SDKPrintStatus(msg, available, requested, tried, built, padToLen=20, newline=False, currentCol=0, baseCol=0): 268 | colorLen = 3 if not hasColors else 0 269 | padLen = padToLen - len(msg) 270 | while padLen <= 0: 271 | padLen += padToLen 272 | printLen = len(msg) + padLen + colorLen 273 | 274 | futureCol = currentCol + printLen 275 | 276 | if futureCol > termCols: 277 | newline = True 278 | 279 | if newline: 280 | ARPrint('') 281 | ARPrint(' '*baseCol, True) 282 | futureCol = printLen + baseCol 283 | 284 | if not available: 285 | ARPrint(logcolors.UNAI, True) 286 | elif not requested and not tried: 287 | ARPrint(logcolors.NONE, True) 288 | elif not tried: 289 | ARPrint(logcolors.REQ, True) 290 | elif not built: 291 | ARPrint(logcolors.FAIL, True) 292 | else: 293 | ARPrint(logcolors.PASS, True) 294 | ARPrint(msg, True) 295 | if padLen > 0: 296 | ARPrint(' '*padLen, True) 297 | ARPrint(logcolors.DEF, True) 298 | 299 | return futureCol 300 | 301 | 302 | ARPrint('') 303 | ARPrint('Status :') 304 | ARPrint(' --> Legend : ' + logcolors.FAIL + 'FAIL ' + logcolors.PASS + 'PASS ' + logcolors.REQ + 'NOT_BUILT ' + logcolors.NONE + 'NOT_REQUESTED ' + logcolors.UNAI + 'NOT_AVAILABLE ' + logcolors.DEF) 305 | ARPrint(' --> Binaries are postfixed with `*`') 306 | ARPrint(' --> Postbuild scripts are postfixed with `+`') 307 | ARPrint('') 308 | offset = 13 if hasColors else 16 309 | for t in targets.list: 310 | targetRequested = t in parser.activeTargets 311 | targetTried = bool(t.triedToBuildLibraries) 312 | targetBuilt = len(t.alreadyBuiltLibraries) == len(t.triedToBuildLibraries) and not t.failed 313 | SDKPrintStatus(t.name, True, targetRequested, targetTried, targetBuilt, padToLen=10) 314 | ARPrint(' : ', True) 315 | count=offset 316 | first=False 317 | for l in libraries.list: 318 | libAvailable = l.isAvailableForTarget(t) 319 | libRequested = l in parser.activeLibs and targetRequested 320 | libTried = t.hasTriedToBuild(l) 321 | libBuilt = t.hasAlreadyBuilt(l) 322 | count = SDKPrintStatus(l.name, libAvailable, libRequested, libTried, libBuilt, padToLen=20, newline=first, currentCol=count, baseCol=offset) 323 | first=False 324 | first=True 325 | for b in binaries.list: 326 | binAvailable = b.isAvailableForTarget(t) 327 | binRequested = b in parser.activeBins and targetRequested 328 | binTried = t.hasTriedToBuildBinary(b) 329 | binBuilt = t.hasAlreadyBuiltBinary(b) 330 | count = SDKPrintStatus(b.name + '*', binAvailable, binRequested, binTried, binBuilt, padToLen=20, newline=first, currentCol=count, baseCol=offset) 331 | first=False 332 | first=True 333 | for scrinfo in t.postbuildScripts: 334 | scrAvailable = True 335 | scrRequescted = targetRequested 336 | scrTried = scrinfo['done'] is not None 337 | scrBuilt = bool(scrinfo['done']) 338 | count = SDKPrintStatus(scrinfo['name'] + '+', scrAvailable, scrRequescted, scrTried, scrBuilt, padToLen=20, newline=first, currentCol=count, baseCol=offset) 339 | first=False 340 | 341 | 342 | ARPrint('') 343 | ARPrint('') 344 | 345 | ARLog('End of build') 346 | if not allOk: 347 | ARLog('-- Errors were found during build ! --') 348 | 349 | end = time.time() 350 | 351 | seconds = int(end - start) 352 | hours, tmp = divmod(seconds, 3600) 353 | minutes, seconds = divmod(tmp, 60) 354 | 355 | strh='' 356 | strm='' 357 | strs = str(seconds) + 's' 358 | if hours > 0: 359 | strh = str(hours) + 'h ' 360 | strm = str(minutes) + 'm ' 361 | if minutes > 0: 362 | strm = str(minutes) + 'm ' 363 | ARLog('Build took %(strh)s%(strm)s%(strs)s' % locals()) 364 | 365 | sys.exit (0 if allOk else 1) 366 | -------------------------------------------------------------------------------- /Utils/Python/ARFuncs.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Copyright (C) 2014 Parrot SA 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in 11 | the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Parrot nor the names 14 | of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written 16 | permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 28 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | SUCH DAMAGE. 30 | ''' 31 | import sys 32 | import subprocess 33 | import os 34 | import inspect 35 | import shutil 36 | import re 37 | import filecmp 38 | import errno 39 | 40 | # Print a message 41 | def ARPrint(msg, noNewLine=False): 42 | sys.stdout.write(msg) 43 | if not noNewLine: 44 | sys.stdout.write('\n') 45 | 46 | # Exit the script with an optional error code 47 | def EXIT(code): 48 | if code != 0: 49 | ARPrint('-- ABORTING --') 50 | sys.exit(code) 51 | 52 | # Class to handle 'cd' and 'cd -' 53 | class Chdir: 54 | def __init__(self, newPath, create=True, verbose=True): 55 | self.savedPath = os.getcwd() 56 | if not os.path.exists(newPath) and create: 57 | os.makedirs(newPath) 58 | os.chdir(newPath) 59 | self.verbose = verbose 60 | if verbose: 61 | try: 62 | ARLog('Entering <%(newPath)s>' % locals()) 63 | except: 64 | pass 65 | def exit(self): 66 | os.chdir(self.savedPath) 67 | if self.verbose: 68 | try: 69 | ARLog('Returning to <'+self.savedPath+'>') 70 | except: 71 | pass 72 | 73 | # Execute a bash command 74 | def ARExecute(cmdline, isShell=True, failOnError=False, printErrorMessage=True): 75 | try: 76 | if printErrorMessage: 77 | ARLog('Running <%(cmdline)s>' % locals()) 78 | subprocess.check_call(cmdline, shell=isShell) 79 | return True 80 | except subprocess.CalledProcessError as e: 81 | if printErrorMessage: 82 | ARPrint('Error while running <%(cmdline)s>' % locals()) 83 | if failOnError: 84 | EXIT(e.returncode) 85 | else: 86 | return False 87 | 88 | # Execute a bash command, and return the stdout output 89 | def ARExecuteGetStdout(args, isShell=False, failOnError=True, printErrorMessage=True): 90 | if printErrorMessage: 91 | ARLog('Running <' + ARListAsBashArg(args) + '>') 92 | p = subprocess.Popen(args, shell=isShell, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True) 93 | out, err = p.communicate() 94 | ret = p.wait() 95 | if ret: 96 | if printErrorMessage: 97 | ARLog('Error while running <' + ARListAsBashArg(args) + '>') 98 | if failOnError: 99 | EXIT(ret) 100 | return '' 101 | return out.strip() 102 | 103 | # Checks if a given commands exists in path 104 | def ARExistsInPath(program, isShell=True): 105 | try: 106 | subprocess.check_call('which %(program)s 2>/dev/null 1>/dev/null' % locals(), shell=isShell) 107 | return True 108 | except subprocess.CalledProcessError as e: 109 | return False 110 | 111 | # Set an environment variable 112 | def ARSetEnv(var, val): 113 | os.environ[var] = val 114 | 115 | # Set an environment variable if not currenly defined 116 | # return True if the variable was added 117 | def ARSetEnvIfEmpty(var, val): 118 | if os.environ.get(var) is None: 119 | os.environ[var] = val 120 | return True 121 | return False 122 | 123 | # Unset an environment variable 124 | def ARUnsetEnv(var): 125 | if var in os.environ: 126 | os.environ.pop(var) 127 | 128 | # Set an environment variable to 'ideal' if it exists in path, else to 'fallback' 129 | def ARSetEnvIfExists(var, ideal, fallback, args=''): 130 | if ARExistsInPath(ideal): 131 | ARSetEnv(var, ideal + ' ' + args) 132 | else: 133 | ARSetEnv(var, fallback + ' ' + args) 134 | 135 | # Append a message to a file 136 | def ARAppendToFile(filename, message, doPrint=True): 137 | arfile = open(filename, 'a') 138 | arfile.write(message + '\n') 139 | arfile.close() 140 | if doPrint: 141 | ARPrint(message) 142 | 143 | # Log a message(append to the default logfile + output to console) 144 | def ARLog(message): 145 | LOGFILE = os.environ.get('ARLOGF') 146 | if not LOGFILE: 147 | LOGFILE = ARPathFromHere('build.log') 148 | ARAppendToFile(LOGFILE, message) 149 | 150 | # Init the default log file 151 | def ARInitLogFile(): 152 | LOGFILE = ARPathFromHere('build.log') 153 | ARSetEnv('ARLOGF', LOGFILE) 154 | ARDeleteIfExists(LOGFILE) 155 | 156 | # Get the absolute path from a relative path 157 | def ARPathFromHere(path): 158 | MYDIR=os.path.abspath(os.path.dirname(sys.argv[0])) 159 | if '' == MYDIR: 160 | MYDIR=os.getcwd() 161 | return '%(MYDIR)s/%(path)s' % locals() 162 | 163 | # Get the absolute path from a relative path 164 | def ARPathFromPwd(path): 165 | MYDIR=os.getcwd() 166 | return '%(MYDIR)s/%(path)s' % locals() 167 | 168 | # Transform a python list to a bash args list 169 | def ARListAsBashArg(lst): 170 | return ' '.join(lst) 171 | 172 | # Checks if file A is newer than file B 173 | def ARFileIsNewerThan(fileA, fileB): 174 | if not os.path.exists(fileA): 175 | return False 176 | if not os.path.exists(fileB): 177 | return True 178 | return os.stat(fileA).st_mtime > os.stat(fileB).st_mtime 179 | 180 | # Called at the beginning of a function to log its start with all its arguments 181 | def StartDumpArgs(**kwargs): 182 | CallerName = inspect.stack()[1][3] 183 | if len(kwargs) > 0: 184 | ARLog('Start running %(CallerName)s with args:' % locals()) 185 | else: 186 | ARLog('Start running %(CallerName)s' % locals()) 187 | 188 | for key, value in kwargs.items(): 189 | ARLog(' -- %(key)s -> %(value)s' % locals()) 190 | 191 | # Called at the end of a function to log its return status and all its arguments 192 | # (use 'return EndDumpArgs(res=True/False, args)') 193 | def EndDumpArgs(res, **kwargs): 194 | CallerName = inspect.stack()[1][3] 195 | START_MSG = 'Finished' 196 | if not res: 197 | START_MSG = 'Error while' 198 | 199 | if len(kwargs) > 0: 200 | ARLog('%(START_MSG)s running %(CallerName)s with args:' % locals()) 201 | else: 202 | ARLog('%(START_MSG)s running %(CallerName)s' % locals()) 203 | 204 | for key, value in kwargs.items(): 205 | ARLog(' -- %(key)s -> %(value)s' % locals()) 206 | 207 | return res 208 | 209 | # Copy and replace a file 210 | def ARCopyAndReplaceFile(SrcFile, DstFile): 211 | if not os.path.exists(SrcFile): 212 | raise Exception('%(SrcFile)s does not exist' % locals()) 213 | if not os.path.exists(os.path.dirname(DstFile)): 214 | os.makedirs(os.path.dirname(DstFile)) 215 | shutil.copy2(SrcFile, DstFile) 216 | 217 | def ar_copytree(src, dst, symlinks=False, ignore=None): 218 | names = os.listdir(src) 219 | if ignore is not None: 220 | ignored_names = ignore(src, names) 221 | else: 222 | ignored_names = set() 223 | 224 | if not os.path.exists(dst): 225 | os.makedirs(dst) 226 | errors = [] 227 | for name in names: 228 | if name in ignored_names: 229 | continue 230 | srcname = os.path.join(src, name) 231 | dstname = os.path.join(dst, name) 232 | try: 233 | if symlinks and os.path.islink(srcname): 234 | linkto = os.readlink(srcname) 235 | os.symlink(linkto, dstname) 236 | elif os.path.isdir(srcname): 237 | ar_copytree(srcname, dstname, symlinks, ignore) 238 | else: 239 | shutil.copy2(srcname, dstname) 240 | # XXX What about devices, sockets etc.? 241 | except (IOError, os.error) as why: 242 | errors.append((srcname, dstname, str(why))) 243 | # catch the Error from the recursive copytree so that we can 244 | # continue with other files 245 | except shutil.Error as err: 246 | errors.extend(err.args[0]) 247 | try: 248 | shutil.copystat(src, dst) 249 | except shutil.WindowsError: 250 | # can't copy file access times on Windows 251 | pass 252 | except OSError as why: 253 | errors.extend((src, dst, str(why))) 254 | if errors: 255 | raise shutil.Error(errors) 256 | 257 | # Recursive copy and replace of a directory. 258 | # Can optionnaly delete the previous content of the destination directory 259 | # instead of merging 260 | def ARCopyAndReplace(SrcRootDir, DstRootDir, deletePrevious=False, ignoreRegexpsForDeletion=[]): 261 | if not os.path.exists(SrcRootDir): 262 | raise Exception('%(SrcRootDir)s does not exist' % locals()) 263 | if deletePrevious: 264 | if ignoreRegexpsForDeletion: 265 | ARDeleteRecursivelyNonMatching(DstRootDir, regex=ignoreRegexpsForDeletion) 266 | else: 267 | ARDeleteIfExists(DstRootDir) 268 | ar_copytree(SrcRootDir, DstRootDir, symlinks=True) 269 | 270 | else: 271 | if not os.path.exists(DstRootDir): 272 | os.makedirs(DstRootDir) 273 | for SrcDir, directories, files in os.walk(SrcRootDir): 274 | DstDir = SrcDir.replace(SrcRootDir, DstRootDir) 275 | if not os.path.exists(DstDir): 276 | os.mkdir(DstDir) 277 | for _file in files: 278 | SrcFile = os.path.join(SrcDir, _file) 279 | DstFile = os.path.join(DstDir, _file) 280 | ARDeleteIfExists(DstFile) 281 | shutil.copy2(SrcFile, DstFile) 282 | 283 | # Delete one or multiple files/directories 284 | # Do not throw an error if the file/directory does not exists 285 | def ARDeleteIfExists(*args): 286 | for fileOrDir in args: 287 | if os.path.exists(fileOrDir): 288 | if os.path.isdir(fileOrDir): 289 | shutil.rmtree(fileOrDir) 290 | else: 291 | os.remove(fileOrDir) 292 | 293 | # Delete a file if it does not match any given regex 294 | def ARDeleteFileIfNonMatching(path, regex=[]): 295 | if os.path.exists(path): 296 | name = os.path.basename(path) 297 | for exp in regex: 298 | if re.match(exp, name): 299 | break 300 | else: 301 | ARDeleteIfExists(path) 302 | 303 | # Delete a directory contents except for files matching any given regex in a list 304 | # Also deletes empty directories 305 | def ARDeleteRecursivelyNonMatching(path, regex=[]): 306 | if not os.path.isdir(path): 307 | ARDeleteFileIfNonMatching(path, regex=regex) 308 | else: 309 | for tst in os.listdir(path): 310 | ARDeleteRecursivelyNonMatching(os.path.join(path, tst), regex=regex) 311 | try: 312 | os.rmdir(path) 313 | except OSError as e: 314 | if e.errno != errno.ENOTEMPTY: 315 | raise e 316 | 317 | # Gets the number of available CPUs 318 | # If the real number can not be determined, return 1 319 | def ARGetNumberOfCpus(): 320 | try: 321 | import multiprocessing 322 | return multiprocessing.cpu_count() 323 | except (ImportError, NotImplementedError): 324 | pass 325 | return 1 326 | 327 | def ARReplaceEnvVars(source): 328 | envMatches = re.findall(r'%\{.*?\}%', source) 329 | for _match in envMatches: 330 | Match = _match.replace('%{', '').replace('}%', '') 331 | try: 332 | EnvMatch = os.environ[Match] 333 | source = source.replace(_match, EnvMatch) 334 | except (KeyError): 335 | ARLog('Environment variable %(Match)s is not set !' % locals()) 336 | return None 337 | return source 338 | 339 | def ARReplaceFileIfDifferent(oldFile, newFile): 340 | if not os.path.exists(oldFile) or not filecmp.cmp(oldFile, newFile): 341 | ARDeleteIfExists(oldFile) 342 | os.rename(newFile, oldFile) 343 | else: 344 | ARDeleteIfExists(newFile) 345 | 346 | def ARCapitalize (arstr): 347 | nameParts = arstr.split('_') 348 | name = '' 349 | for part in nameParts: 350 | if len(part) > 1: 351 | name = name + part[0].upper() + part[1:] 352 | elif len(part) == 1: 353 | name = name + part[0].upper() 354 | return name 355 | 356 | def ARUncapitalize (arstr): 357 | if len(arstr) > 1: 358 | return arstr[0].lower() + arstr[1:] 359 | elif len(arstr) == 1: 360 | return arstr[0].lower() 361 | else: 362 | return '' 363 | 364 | def ARStringIsInteger(arstr): 365 | try: 366 | int(arstr) 367 | return True 368 | except ValueError: 369 | return False 370 | 371 | # 372 | # Name generation functions 373 | # 374 | 375 | def ARMacroName (Module, Submodule, Name): 376 | # MODULE_SUBMODULE_NAME 377 | return Module.upper () + '_' + Submodule.upper () + '_' + Name.upper () 378 | 379 | def ARFunctionName (Module, Submodule, Name): 380 | # MODULE_Submodule_Name 381 | return Module.upper () + '_' + ARCapitalize (Submodule) + '_' + ARCapitalize (Name) 382 | 383 | def ARTypeName (Module, Submodule, Name): 384 | # MODULE_Submodule[_Name]_t 385 | if '' != Name: 386 | return Module.upper () + '_' + ARCapitalize (Submodule) + '_' + ARCapitalize (Name) + '_t' 387 | else: 388 | return Module.upper () + '_' + ARCapitalize (Submodule) + '_t' 389 | 390 | def ARGlobalName (Module, Submodule, Name): 391 | # MODULE_Submodule_Name 392 | return Module.upper () + '_' + ARCapitalize (Submodule) + '_' + ARCapitalize (Name) 393 | 394 | def ARGlobalConstName (Module, Submodule, Name): 395 | # cMODULE_Submodule_Name 396 | return 'c' + Module.upper () + '_' + ARCapitalize (Submodule) + '_' + ARCapitalize (Name) 397 | 398 | def AREnumValue (Module, Submodule, Enum, Name): 399 | # MODULE_SUBMODULE_ENUM_NAME 400 | if Enum.upper () == 'ERROR' and (Name.upper () == 'OK' or Name.upper () == 'ERROR'): 401 | return Module.upper () + '_' + Submodule.upper () + '_' + Name.upper () 402 | else: 403 | return Module.upper () + '_' + Submodule.upper () + '_' + Enum.upper () + '_' + Name.upper () 404 | 405 | def AREnumName (Module, Submodule, Enum): 406 | # eMODULE_SUBMODULE_ENUM 407 | return 'e' + Module.upper () + '_' + Submodule.upper () + '_' + Enum.upper () 408 | 409 | def ARFlagValue (Module, Submodule, Enum, Name): 410 | return Module.upper () + '_FLAG_' + Submodule.upper () + '_' + Enum.upper () + '_' + Name.upper () 411 | 412 | def ARJavaEnumType (Module, Submodule, Enum): 413 | # MODULE_SUBMODULE_ENUM_"ENUM" 414 | return Module.upper () + '_' + Submodule.upper () + '_' + Enum.upper () + '_ENUM' 415 | 416 | def ARJavaMultiSetType (Module, Submodule, multiset): 417 | # ModuleSubmoduleName 418 | return Module+ ARCapitalize (Submodule) + ARCapitalize (multiset) 419 | 420 | def ARJavaEnumValDef (Module, Submodule, Enum, Name, oldFormat=False): 421 | # MODULE_SUBMODULE_ENUM_NAME 422 | if oldFormat: 423 | return AREnumValue (Module, Submodule, Enum, Name) 424 | elif Name[0].isdigit(): 425 | return Enum.upper() + '_' + Name.upper () 426 | else: 427 | return Name.upper () 428 | 429 | def ARJavaEnumValue (Module, Submodule, Enum, Name, oldFormat=False): 430 | # MODULE_SUBMODULE_ENUM_"ENUM".MODULE_SUBMODULE_ENUM_NAME 431 | return ARJavaEnumType (Module, Submodule, Enum) + '.' + ARJavaEnumValDef (Module, Submodule, Enum, Name, oldFormat) 432 | -------------------------------------------------------------------------------- /Utils/Python/ARSDK_PrebuildActions.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | ''' 3 | Copyright (C) 2014 Parrot SA 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 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Parrot nor the names 15 | of its contributors may be used to endorse or promote products 16 | derived from this software without specific prior written 17 | permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 22 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 26 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 27 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | SUCH DAMAGE. 31 | ''' 32 | import sys 33 | import os 34 | import re 35 | from optparse import OptionParser 36 | 37 | # Generated file disclaimer 38 | GENERATED_FILE_DISCLAIMER='''/* 39 | Copyright (C) 2014 Parrot SA 40 | 41 | Redistribution and use in source and binary forms, with or without 42 | modification, are permitted provided that the following conditions 43 | are met: 44 | * Redistributions of source code must retain the above copyright 45 | notice, this list of conditions and the following disclaimer. 46 | * Redistributions in binary form must reproduce the above copyright 47 | notice, this list of conditions and the following disclaimer in 48 | the documentation and/or other materials provided with the 49 | distribution. 50 | * Neither the name of Parrot nor the names 51 | of its contributors may be used to endorse or promote products 52 | derived from this software without specific prior written 53 | permission. 54 | 55 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 56 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 57 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 58 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 59 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 60 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 61 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 62 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 63 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 64 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 65 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 66 | SUCH DAMAGE. 67 | */ 68 | /* 69 | * GENERATED FILE 70 | * Do not modify this file, it will be erased during the next configure run 71 | */ 72 | ''' 73 | 74 | from ARFuncs import * 75 | 76 | ################################# 77 | # Add Prebuild processing here # 78 | ################################# 79 | 80 | ################################# 81 | # Generate JAVA Enums from C # 82 | # Enums # 83 | ################################# 84 | 85 | class AREnumType: 86 | def __init__(self): 87 | self.name = '' 88 | self.entries = [] 89 | self.hasToString = False 90 | self.toStringFileName = '' 91 | self.toStringPrototype = '' 92 | def addEntry(self, entry): 93 | self.entries.append(entry) 94 | def setName(self, name): 95 | self.name = name 96 | def setToStringFileName(self, fname, prototype): 97 | self.hasToString = True 98 | self.toStringFileName = fname 99 | self.toStringPrototype = prototype 100 | 101 | class AREnumEntry: 102 | "Represent an enum entry in C" 103 | def __init__(self, name, value, comment): 104 | self.name = name 105 | self.value = value 106 | self.comment = comment 107 | 108 | def readEnumEntriesFromFile(filename, inputDir, outputDir): 109 | ALL_LINES = [line.strip() for line in open(filename)] 110 | DATA_LINES = [] 111 | # Strip empty lines 112 | for line in ALL_LINES: 113 | if line: 114 | DATA_LINES.append(line) 115 | # Loop over lines to find enums 116 | currentEnumType = AREnumType() 117 | allEnums = [] 118 | foundEnum = False 119 | noEnumInThisFile = False 120 | previousValue = -1 # So next value is zero 121 | for line in DATA_LINES: 122 | 123 | if line == '// ARSDK_NO_ENUM_PREPROCESS //': 124 | noEnumInThisFile = True 125 | break 126 | 127 | if not foundEnum: 128 | if line.startswith('typedef enum'): 129 | foundEnum = True 130 | previousValue = -1 131 | elif 'ToString' in line: 132 | _, _, enumName = line.partition('(') 133 | enumName, _, _ = enumName.partition(' ') 134 | for enum in allEnums: 135 | if enum.name == enumName: 136 | cFileName = os.path.dirname(filename) + '/' + os.path.basename(filename).replace('.h', '.c') 137 | cFileName = cFileName.replace(inputDir, outputDir) 138 | prototype = line.rstrip(';') 139 | enum.setToStringFileName(cFileName, prototype) 140 | break 141 | else: 142 | if line.startswith('}'): 143 | foundEnum = False 144 | enumName, _, _ = line.partition(';') 145 | _, _, enumName = enumName.partition('}') 146 | enumName = enumName.strip() 147 | currentEnumType.setName(enumName) 148 | allEnums.append(currentEnumType) 149 | currentEnumType = AREnumType() 150 | elif not line.startswith('{'): 151 | if re.match('[\ \t]*[/*]', line) is not None: 152 | continue 153 | # Get name 154 | name, _, _ = line.partition(' ') 155 | name = name.strip(',') 156 | # Get value 157 | _, _, value = line.partition('=') 158 | value, _, _ = value.partition(',') 159 | value = value.strip() 160 | if not value: 161 | value = str(previousValue + 1) 162 | while not ARStringIsInteger(value): 163 | for prevEntry in currentEnumType.entries: 164 | if prevEntry.name == value: 165 | value = prevEntry.value 166 | break 167 | break 168 | previousValue = int(value) 169 | # Get comment 170 | _, _, comment = line.partition('/**<') 171 | comment, _, _ = comment.partition('*/') 172 | comment = comment.strip() 173 | # If the comment is not in /**< */ format, try ///< format 174 | if comment == '': 175 | _, _, comment = line.partition('///<') 176 | comment = comment.strip() 177 | entry = AREnumEntry(name, value, comment) 178 | currentEnumType.addEntry(entry) 179 | 180 | if noEnumInThisFile: 181 | return [] 182 | else: 183 | return allEnums 184 | 185 | def entryConstructor(entry, last=False): 186 | retVal = ' ' 187 | if entry.comment != '': 188 | retVal += '/** ' + entry.comment + ' */\n ' 189 | if entry.comment == '': 190 | retVal += entry.name + ' (' + entry.value + ')' 191 | else: 192 | retVal += entry.name + ' (' + entry.value + ', "' + entry.comment + '")' 193 | if last: 194 | retVal += ';' 195 | else: 196 | retVal += ',' 197 | retVal += '\n' 198 | return retVal 199 | 200 | def writeEnumToJavaFile(enumType, outDir, javaPackage): 201 | CLASS_NAME = enumType.name.lstrip('e') + '_ENUM' 202 | JFILE_NAME = outDir + CLASS_NAME + '.java' 203 | jfile = open(JFILE_NAME, 'w') 204 | 205 | jfile.write(GENERATED_FILE_DISCLAIMER) 206 | jfile.write('\n') 207 | jfile.write('package ' + javaPackage + ';\n') 208 | jfile.write('\n') 209 | jfile.write('import java.util.HashMap;\n') 210 | jfile.write('\n') 211 | jfile.write('/**\n') 212 | jfile.write(' * Java copy of the ' + enumType.name + ' enum\n') 213 | jfile.write(' */\n') 214 | jfile.write('public enum ' + CLASS_NAME + ' {\n') 215 | unknownEnumEntry = AREnumEntry(enumType.name + "_UNKNOWN_ENUM_VALUE", "Integer.MIN_VALUE", "Dummy value for all unknown cases") 216 | jfile.write(entryConstructor(unknownEnumEntry)) 217 | for entry in enumType.entries[:-1]: 218 | jfile.write(entryConstructor(entry)) 219 | entry = enumType.entries[-1] 220 | jfile.write(entryConstructor(entry, True)) 221 | jfile.write('\n') 222 | jfile.write(' private final int value;\n') 223 | jfile.write(' private final String comment;\n'); 224 | jfile.write(' static HashMap valuesList;\n') 225 | jfile.write('\n') 226 | jfile.write(' ' + CLASS_NAME + ' (int value) {\n') 227 | jfile.write(' this.value = value;\n') 228 | jfile.write(' this.comment = null;\n') 229 | jfile.write(' }\n') 230 | jfile.write('\n') 231 | jfile.write(' ' + CLASS_NAME + ' (int value, String comment) {\n') 232 | jfile.write(' this.value = value;\n') 233 | jfile.write(' this.comment = comment;\n') 234 | jfile.write(' }\n') 235 | jfile.write('\n') 236 | jfile.write(' /**\n') 237 | jfile.write(' * Gets the int value of the enum\n') 238 | jfile.write(' * @return int value of the enum\n') 239 | jfile.write(' */\n') 240 | jfile.write(' public int getValue () {\n') 241 | jfile.write(' return value;\n') 242 | jfile.write(' }\n') 243 | jfile.write('\n') 244 | jfile.write(' /**\n') 245 | jfile.write(' * Gets the ' + CLASS_NAME + ' instance from a C enum value\n') 246 | jfile.write(' * @param value C value of the enum\n') 247 | jfile.write(' * @return The ' + CLASS_NAME + ' instance, or null if the C enum value was not valid\n') 248 | jfile.write(' */\n') 249 | jfile.write(' public static ' + CLASS_NAME + ' getFromValue (int value) {\n') 250 | jfile.write(' if (null == valuesList) {\n') 251 | jfile.write(' ' + CLASS_NAME + ' [] valuesArray = ' + CLASS_NAME + '.values ();\n') 252 | jfile.write(' valuesList = new HashMap (valuesArray.length);\n') 253 | jfile.write(' for (' + CLASS_NAME + ' entry : valuesArray) {\n') 254 | jfile.write(' valuesList.put (entry.getValue (), entry);\n') 255 | jfile.write(' }\n') 256 | jfile.write(' }\n') 257 | jfile.write(' ' + CLASS_NAME + ' retVal = valuesList.get (value);\n') 258 | jfile.write(' if (retVal == null) {\n') 259 | jfile.write(' retVal = ' + unknownEnumEntry.name + ';\n') 260 | jfile.write(' }\n') 261 | jfile.write(' return retVal;') 262 | jfile.write(' }\n') 263 | jfile.write('\n') 264 | jfile.write(' /**\n') 265 | jfile.write(' * Returns the enum comment as a description string\n') 266 | jfile.write(' * @return The enum description\n') 267 | jfile.write(' */\n') 268 | jfile.write(' public String toString () {\n') 269 | jfile.write(' if (this.comment != null) {\n') 270 | jfile.write(' return this.comment;\n') 271 | jfile.write(' }\n') 272 | jfile.write(' return super.toString ();\n') 273 | jfile.write(' }\n') 274 | jfile.write('}\n') 275 | jfile.close() 276 | 277 | def writeToStringFunction(enumType, libName): 278 | if not enumType.hasToString: 279 | return 280 | CNAME = os.path.basename(enumType.toStringFileName) 281 | HNAME = libName + '/' + CNAME.replace('.c', '.h') 282 | VARNAME, _, _ = enumType.toStringPrototype.partition(')') 283 | _, _, VARNAME = VARNAME.partition(enumType.name + ' ') 284 | 285 | cfile = open(enumType.toStringFileName, 'w') 286 | 287 | cfile.write(GENERATED_FILE_DISCLAIMER) 288 | cfile.write('\n') 289 | cfile.write('/**\n') 290 | cfile.write(' * @file ' + CNAME + '\n') 291 | cfile.write(' * @brief ToString function for ' + enumType.name + ' enum\n') 292 | cfile.write(' */\n') 293 | cfile.write('\n') 294 | cfile.write('#include <' + HNAME + '>\n') 295 | cfile.write('\n') 296 | cfile.write(enumType.toStringPrototype + '\n') 297 | cfile.write('{\n') 298 | cfile.write(' switch (' + VARNAME + ')\n') 299 | cfile.write(' {\n') 300 | for entry in enumType.entries: 301 | cfile.write(' case ' + entry.name + ':\n') 302 | cfile.write(' return "' + entry.comment + '";\n') 303 | cfile.write(' break;\n') 304 | cfile.write(' default:\n') 305 | cfile.write(' break;\n') 306 | cfile.write(' }\n') 307 | cfile.write(' return "Unknown value";\n') 308 | cfile.write('}\n') 309 | 310 | cfile.close() 311 | 312 | ################################# 313 | # Generate JAVA Enums from C # 314 | # Main # 315 | ################################# 316 | 317 | ################################# 318 | # Generic infos about the lib # 319 | ################################# 320 | 321 | def generateFiles(topDir, libName, outdir, options): 322 | # Directories 323 | INPUT_DIR = topDir + '/Includes/' + libName + '/' 324 | 325 | # Java/JNI package 326 | LIB_MODULE=libName.replace('lib', '') 327 | JAVA_PACKAGE = 'com.parrot.arsdk.' + LIB_MODULE.lower() 328 | JAVA_PACKAGE_DIR = JAVA_PACKAGE.replace('.', '/') 329 | 330 | 331 | OUTPUT_DIR = outdir + '/Sources/' 332 | JAVA_OUT_DIR = outdir + '/JNI/java/' + JAVA_PACKAGE_DIR + '/' 333 | 334 | 335 | # Create dir if neededif not os.path.exists(OUTPUT_DIR): 336 | if not os.path.exists(OUTPUT_DIR): 337 | os.makedirs(OUTPUT_DIR) 338 | if not os.path.exists(INPUT_DIR): 339 | os.makedirs(INPUT_DIR) 340 | if not os.path.exists(JAVA_OUT_DIR): 341 | os.makedirs(JAVA_OUT_DIR) 342 | 343 | for fname in os.listdir(INPUT_DIR): 344 | if fname.endswith('.h'): 345 | completeFile = INPUT_DIR + fname 346 | allEnums = readEnumEntriesFromFile(completeFile, INPUT_DIR, OUTPUT_DIR) 347 | for enumType in allEnums: 348 | if not options.java_disabled: 349 | writeEnumToJavaFile(enumType, JAVA_OUT_DIR, JAVA_PACKAGE) 350 | if not options.tostr_disabled: 351 | writeToStringFunction(enumType, libName) 352 | 353 | def main(): 354 | parser = OptionParser() 355 | parser.add_option("-r", "--root", dest="root", 356 | default='', 357 | help="root directory") 358 | parser.add_option("-l", "--lib", dest="lib", 359 | default='', 360 | help="libAR* library name") 361 | parser.add_option("-o", "--outdir", dest="outdir", 362 | default='', 363 | help="output directory") 364 | parser.add_option("--disable-java", dest="java_disabled", 365 | action="store_true", 366 | default=False, 367 | help="disable Java generation") 368 | parser.add_option("--disable-tostr", dest="tostr_disabled", 369 | action="store_true", 370 | default=False, 371 | help="disable toString generation") 372 | (options, args) = parser.parse_args() 373 | if (options.root == '') and (options.lib == ''): 374 | confDir=sys.argv[1] 375 | configureAcFile = open(confDir + '/configure.ac', 'rb') 376 | AC_INIT_LINE=configureAcFile.readline().decode("utf-8") 377 | while not AC_INIT_LINE.startswith('AC_INIT') and '' != AC_INIT_LINE: 378 | AC_INIT_LINE=configureAcFile.readline().decode("utf-8") 379 | if '' == AC_INIT_LINE: 380 | ARPrint('Unable to read from configure.ac file !') 381 | sys.exit(1) 382 | AC_ARGS=re.findall(r'\[[^]]*\]', AC_INIT_LINE) 383 | libName=AC_ARGS[0].replace('[', '').replace(']', '') 384 | topDir=confDir + '/..' 385 | elif (options.root == '') or (options.lib == ''): 386 | ARPrint('--lib and --root must be present together !') 387 | sys.exit(1) 388 | else: 389 | libName=options.lib 390 | topDir=options.root 391 | outdir = options.outdir if options.outdir else topDir + '/gen' 392 | generateFiles(topDir, libName, outdir, options) 393 | generateFiles(outdir, libName, outdir, options) 394 | 395 | if __name__ == '__main__': 396 | main() 397 | 398 | #END 399 | -------------------------------------------------------------------------------- /Utils/Python/Android_CreateFiles.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Copyright (C) 2014 Parrot SA 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in 11 | the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Parrot nor the names 14 | of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written 16 | permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 28 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | SUCH DAMAGE. 30 | ''' 31 | from ARFuncs import * 32 | 33 | def Android_AppendDepsPrebuiltAndroidMk(target, lib, mkfile, array, suffix, rootDir): 34 | 35 | for soName in lib.soLibs: 36 | libPrefix = 'lib' if not soName.startswith('lib') else '' 37 | libPrefixUpper = libPrefix.upper() 38 | 39 | soNameUpper = libPrefixUpper + soName.upper() 40 | soNameLower = libPrefix + soName.lower() 41 | pbName = '%(soNameUpper)s-prebuilt' % locals() 42 | if not pbName in array: 43 | mkfile.write('# %(soNameUpper)s\n' % locals()) 44 | mkfile.write('include $(CLEAR_VARS)\n') 45 | mkfile.write('\n') 46 | mkfile.write('LOCAL_MODULE := %(pbName)s\n' % locals()) 47 | 48 | mkfile.write('LOCAL_SRC_FILES := %(rootDir)s/$(TARGET_ARCH_ABI)/lib/%(soName)s' % locals() + '\n') 49 | 50 | mkfile.write('\n') 51 | mkfile.write('include $(PREBUILT_SHARED_LIBRARY)\n') 52 | mkfile.write('\n') 53 | array.append(pbName) 54 | 55 | 56 | def Android_CreateApplicationMk(projectRoot, abis): 57 | appMkName = '%(projectRoot)s/jni/Application.mk' % locals() 58 | appMkTmpName = '%(projectRoot)s/jni/Application.mk.new' % locals() 59 | appMk = open(appMkTmpName, 'w') 60 | appMk.write('APP_ABI := ') 61 | for abi in abis: 62 | appMk.write (abi + ' ') 63 | appMk.write('\n') 64 | appMk.write('APP_PLATFORM := android-' + os.environ.get('AR_ANDROID_MIN_VERSION') + '\n') 65 | appMk.close() 66 | ARReplaceFileIfDifferent(appMkName, appMkTmpName) 67 | 68 | def Android_CreateAndroidManifest(projectRoot, lib): 69 | androidManifestName = '%(projectRoot)s/AndroidManifest.xml' % locals() 70 | androidManifestTmpName = '%(projectRoot)s/AndroidManifest.xml.new' % locals() 71 | libLower = lib.name.lower() 72 | androidMinVersion = os.environ.get('AR_ANDROID_MIN_VERSION') 73 | androidTargetVersion = os.environ.get('AR_ANDROID_API_VERSION') 74 | androidManifest = open(androidManifestTmpName, 'w') 75 | androidManifest.write('\n') 76 | androidManifest.write('\n') 81 | androidManifest.write('\n') 82 | androidManifest.write(' \n' % locals()) 85 | androidManifest.write('\n') 86 | androidManifest.close() 87 | ARReplaceFileIfDifferent(androidManifestName, androidManifestTmpName) 88 | 89 | def Android_CreateAndroidMk(target, projectRoot, installRoot, lib, debug, hasNative=True, inhouse=False): 90 | JniRootDir = '%(projectRoot)s/jni/' % locals() 91 | andMkName = '%(JniRootDir)s/Android.mk' % locals() 92 | andMkTmpName = '%(JniRootDir)s/Android.mk.new' % locals() 93 | 94 | suffix = '_dbg' if debug else '' 95 | prebuilts = [] 96 | 97 | andMk = open(andMkTmpName, 'w') 98 | andMk.write('LOCAL_PATH := $(call my-dir)\n') 99 | andMk.write('\n') 100 | # Write prebuilt deps (use shared) 101 | lib.runOnAllDeps(target, Android_AppendDepsPrebuiltAndroidMk, mkfile=andMk, array=prebuilts, suffix=suffix, rootDir=installRoot) 102 | # Write prebuilt self (use shared) 103 | libUpper = lib.name.upper() 104 | libLower = lib.name.lower() 105 | if hasNative: 106 | andMk.write('# lib%(lib)s\n' % locals()) 107 | andMk.write('include $(CLEAR_VARS)\n') 108 | andMk.write('\n') 109 | andMk.write('LOCAL_MODULE := LIB%(libUpper)s-prebuilt\n' % locals()) 110 | andMk.write('LOCAL_SRC_FILES := %(installRoot)s/$(TARGET_ARCH_ABI)/lib/lib%(libLower)s%(suffix)s.' % locals() + target.soext + '\n') 111 | andMk.write('\n') 112 | andMk.write('include $(PREBUILT_SHARED_LIBRARY)\n') 113 | andMk.write('\n') 114 | # Write JNI Compiler wrapper 115 | andMk.write('# JNI Wrapper\n') 116 | andMk.write('include $(CLEAR_VARS)\n') 117 | andMk.write('\n') 118 | # TEMP ALWAYS USE -g !!! 119 | #andMk.write('LOCAL_CFLAGS := \n') 120 | andMk.write('LOCAL_CFLAGS := -g\n') 121 | # END OF TEMP ALWAYS USE -g !!! 122 | if inhouse: 123 | andMk.write('LOCAL_CFLAGS += -D_IN_HOUSE\n') 124 | andMk.write('ifeq ($(TARGET_ARCH_ABI), armeabi-v7a)\n') 125 | andMk.write(' LOCAL_CFLAGS += -mfloat-abi=softfp -mfpu=neon\n') 126 | andMk.write('endif\n') 127 | andMk.write('LOCAL_C_INCLUDES:= %(installRoot)s/$(TARGET_ARCH_ABI)/include\n' % locals()) 128 | andMk.write('LOCAL_MODULE := lib%(libLower)s_android%(suffix)s\n' % locals()) 129 | JniCFiles = [] 130 | for Dir, directories, files in os.walk(JniRootDir): 131 | for _file in files: 132 | if _file.endswith('.c'): 133 | JniCFiles.append (os.path.join(Dir, _file).replace(JniRootDir, '')) 134 | if JniCFiles: 135 | andMk.write('LOCAL_SRC_FILES :=') 136 | for _file in JniCFiles: 137 | andMk.write(' %(_file)s' % locals()) 138 | andMk.write('\n') 139 | andMk.write('LOCAL_LDLIBS := -llog -lz\n') 140 | if hasNative or prebuilts: 141 | andMk.write('LOCAL_SHARED_LIBRARIES :=') 142 | if hasNative: 143 | andMk.write(' LIB%(libUpper)s-prebuilt' % locals()) 144 | for dep in prebuilts: 145 | andMk.write(' %(dep)s' % locals()) 146 | andMk.write('\n') 147 | andMk.write('include $(BUILD_SHARED_LIBRARY)\n') 148 | andMk.close() 149 | ARReplaceFileIfDifferent(andMkName, andMkTmpName) 150 | -------------------------------------------------------------------------------- /Utils/Python/Android_GenLibraryDoc.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Copyright (C) 2014 Parrot SA 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in 11 | the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Parrot nor the names 14 | of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written 16 | permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 28 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | SUCH DAMAGE. 30 | ''' 31 | from ARFuncs import * 32 | from Java_GenLibraryDoc import * 33 | 34 | def Android_GenLibraryDoc(target, lib, clean=False): 35 | args = dict(locals()) 36 | StartDumpArgs(**args) 37 | 38 | ANDROID_SDK_VERSION = os.environ.get('AR_ANDROID_API_VERSION') 39 | 40 | if not os.environ.get('ANDROID_SDK_PATH'): 41 | ARLog ('You need to export ANDROID_SDK_PATH to generate android documentation') 42 | return EndDumpArgs(res=True, **args) 43 | 44 | extraJavadocArgs = ['-linkoffline http://developer.android.com/reference ' + os.environ.get('ANDROID_SDK_PATH') + '/docs/reference'] 45 | extraClasspath = [os.environ.get('ANDROID_SDK_PATH')+'/platforms/android-' + ANDROID_SDK_VERSION + '/android.jar'] 46 | 47 | res = Java_GenLibraryDoc(target, lib, clean, extraSrcDirs=['Android/src'], extraJavadocArgs=extraJavadocArgs, extraClasspath=extraClasspath) 48 | 49 | return EndDumpArgs(res, **args) 50 | -------------------------------------------------------------------------------- /Utils/Python/Common_BuildConfigureLibrary.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Copyright (C) 2014 Parrot SA 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in 11 | the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Parrot nor the names 14 | of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written 16 | permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 28 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | SUCH DAMAGE. 30 | ''' 31 | from ARFuncs import * 32 | from Common_CheckBootstrap import * 33 | from Common_CheckConfigure import * 34 | from Common_RemoveVersionsFromSo import * 35 | from multiprocessing import Lock 36 | 37 | def Common_GetConfigureDir(lib): 38 | # Find library configure dir 39 | if Common_ValidAutotoolsDirectory(lib.path + '/Build'): 40 | LibConfigureDir = lib.path + '/Build' 41 | elif Common_ValidAutotoolsDirectory(lib.path): 42 | LibConfigureDir = lib.path 43 | elif lib.customBuild is not None: 44 | LibConfigureDir = lib.path 45 | else: 46 | LibConfigureDir = None 47 | return LibConfigureDir 48 | 49 | def Common_IsConfigureLibrary(lib): 50 | return Common_GetConfigureDir(lib) is not None 51 | 52 | def Common_MergeConfigureArgs(args): 53 | variables = {} 54 | newArgs = [] 55 | for arg in args: 56 | match = re.match(r'[A-Z]+=', arg) 57 | if match is not None: 58 | var = match.group(0).strip('=') 59 | val = arg.strip(var).strip('=').strip('"') 60 | 61 | if var in variables: 62 | gval = variables[var] + ' ' + val 63 | variables[var] = gval 64 | else: 65 | variables[var] = val 66 | else: 67 | newArgs.append(arg) 68 | for var in variables: 69 | newArg = var + '="' + variables[var] + '"' 70 | newArgs.append(newArg) 71 | return newArgs 72 | 73 | 74 | 75 | def Common_BuildConfigureLibrary(target, lib, extraArgs=[], clean=False, debug=False, inhouse=False, confdirSuffix='', installSubDir='', isLib=True, stripVersionNumber=False, noSharedObjects=False, bootstrapLock=None, configureLock=None, makeLock=None, isMp=False): 76 | args = dict(locals()) 77 | 78 | prefix = 'lib' if (isLib and (not lib.name.startswith('lib')) ) else '' 79 | suffix = '_dbg' if debug else '' 80 | 81 | if not target.needsToBuild(lib): 82 | ARLog('Skipping %(prefix)s%(lib)s build : already built for target %(target)s' % locals()) 83 | return (True, lib) if isMp else True 84 | 85 | StartDumpArgs(**args) 86 | 87 | # Build actual library 88 | 89 | # Sanity checks 90 | if not os.path.exists(lib.path): 91 | ARLog('Unable to build ' + lib.name + ' : directory ' + lib.path + ' does not exists') 92 | ret = EndDumpArgs(res=False, **args) 93 | return (ret, lib) if isMp else ret 94 | 95 | # Generate directory names 96 | TargetDir = ARPathFromHere('Targets/%(target)s' % locals()) 97 | ConfigureDir = '%(TargetDir)s/Build/%(prefix)s%(lib)s' % locals() 98 | if confdirSuffix: 99 | ConfigureDir += '_%(confdirSuffix)s' % locals() 100 | ConfigureDirDbg = '%(ConfigureDir)s_dbg' % locals() 101 | InstallDir = '%(TargetDir)s/Install' % locals() 102 | if installSubDir: 103 | InstallDir += '/%(installSubDir)s' % locals() 104 | 105 | # Generate configure args 106 | ConfigureArgs = ['--prefix=%(InstallDir)s' % locals()] 107 | ConfigureArgs.extend(extraArgs) 108 | ConfigureArgs.extend(lib.extraConfFlags) 109 | 110 | # TEMP ALWAYS USE -g !!! 111 | if not lib.ext: 112 | ConfigureArgs.extend([ 'CFLAGS=" -g"' ]) 113 | else: 114 | # CFLAGS must be set to something else build will fail 115 | ConfigureArgs.extend([ 'CFLAGS=" "' ]) 116 | # END OF TEMP ALWAYS USE -g !!! 117 | 118 | if inhouse: 119 | InHouseFlags = [ 'CFLAGS=" -D_IN_HOUSE"', 'CPPFLAGS=" -D_IN_HOUSE"', 'OBJCFLAGS=" -D_IN_HOUSE"' ] 120 | ConfigureArgs.extend(InHouseFlags) 121 | 122 | ConfigureArgs = Common_MergeConfigureArgs(ConfigureArgs) 123 | 124 | ConfigureArgsDbg = ConfigureArgs + ['--enable-debug'] 125 | 126 | 127 | # Get path for install program 128 | InstallBinPath = os.popen('which install').read().strip() 129 | if InstallBinPath is not None: 130 | ConfigureArgs.append('INSTALL="%(InstallBinPath)s -C"' % locals()) 131 | ConfigureArgsDbg.append('INSTALL="%(InstallBinPath)s -C"' % locals()) 132 | 133 | # Find library configure dir 134 | LibConfigureDir = Common_GetConfigureDir(lib) 135 | if LibConfigureDir is None: 136 | ARLog('Don\'t know how to build %(prefix)s%(lib)s for %(target)s' % locals()) 137 | ret = EndDumpArgs(res=False, **args) 138 | return (ret, lib) if isMp else ret 139 | 140 | # Find library custom script 141 | if lib.customBuild is not None: 142 | CustomBuildPath = lib.customBuild 143 | CustomBuildScript = '%(LibConfigureDir)s/../%(CustomBuildPath)s' % locals() 144 | ARLog('Custom build %(CustomBuildScript)s' % locals()) 145 | if not os.path.exists(CustomBuildScript): 146 | ARLog('Failed to customBuild check %(prefix)s%(lib)s' % locals()) 147 | ret = EndDumpArgs(res=False, **args) 148 | return (ret, lib) if isMp else ret 149 | 150 | # Check bootstrap status of the directory 151 | if lib.customBuild is None: 152 | if bootstrapLock is not None: 153 | bootstrapLock.acquire() 154 | res = Common_CheckBootstrap(LibConfigureDir) or not os.path.exists('%(LibConfigureDir)s/configure' % locals()) 155 | if bootstrapLock is not None: 156 | bootstrapLock.release() 157 | if not res: 158 | ARLog('Failed to bootstrap %(prefix)s%(lib)s' % locals()) 159 | ret = EndDumpArgs(res=False, **args) 160 | return (ret, lib) if isMp else ret 161 | 162 | # Replace %{ARSDK_INSTALL_DIR}% 163 | Argn = len(ConfigureArgs) 164 | index = 0 165 | while index < Argn: 166 | arg = ConfigureArgs[index] 167 | match = re.search('%\{[a-zA-Z_]*\}%', arg) 168 | if match is not None: 169 | ConfigureArgs[index] = re.sub('%\{[a-zA-Z_]*\}%', InstallDir, arg) 170 | index = index + 1 171 | Argn = len(ConfigureArgsDbg) 172 | index = 0 173 | while index < Argn: 174 | arg = ConfigureArgsDbg[index] 175 | match = re.search('%\{[a-zA-Z_]*\}%', arg) 176 | if match is not None: 177 | ConfigureArgsDbg[index] = re.sub('%\{[a-zA-Z_]*\}%', InstallDir, arg) 178 | index = index + 1 179 | 180 | if not clean: 181 | mdir = None 182 | #Custom Build 183 | if lib.customBuild is not None: 184 | CustomBuildArg = ConfigureArgs 185 | if debug: 186 | CustomBuildArg = ConfigureArgsDbg 187 | if makeLock is not None: 188 | makeLock.acquire() 189 | res = ARExecute(CustomBuildScript + ' ' + ARListAsBashArg(CustomBuildArg), failOnError=False) 190 | if makeLock is not None: 191 | makeLock.release() 192 | if not res: 193 | ARLog('Failed to build %(prefix)s%(lib)s' % locals()) 194 | ret = EndDumpArgs(res=False, **args) 195 | return (ret, lib) if isMp else ret 196 | else: 197 | ret = EndDumpArgs(res=True, **args) 198 | return (ret, lib) if isMp else ret 199 | 200 | if not debug: 201 | # Check configure(release) 202 | if configureLock is not None: 203 | configureLock.acquire() 204 | res = Common_CheckConfigure(lib, LibConfigureDir, ConfigureDir, ConfigureArgs, lib.confdeps) 205 | if configureLock is not None: 206 | configureLock.release() 207 | if not res: 208 | ret = EndDumpArgs(res=False, **args) 209 | return (ret, lib) if isMp else ret 210 | mdir = Chdir(ConfigureDir) 211 | else: 212 | if configureLock is not None: 213 | configureLock.acquire() 214 | res = Common_CheckConfigure(lib, LibConfigureDir, ConfigureDirDbg, ConfigureArgsDbg, lib.confdeps) 215 | if configureLock is not None: 216 | configureLock.release() 217 | if not res: 218 | ret = EndDumpArgs(res=False, **args) 219 | return (ret, lib) if isMp else ret 220 | mdir = Chdir(ConfigureDirDbg) 221 | # Make 222 | if makeLock is not None: 223 | makeLock.acquire() 224 | res = ARExecute(os.environ.get('ARMAKE') + ' install', failOnError=False) 225 | if not res: 226 | if makeLock is not None: 227 | makeLock.release() 228 | ARLog('Failed to build %(prefix)s%(lib)s' % locals()) 229 | mdir.exit() 230 | ret = EndDumpArgs(res=False, **args) 231 | return (ret, lib) if isMp else ret 232 | 233 | # Strip version number if requested 234 | if not noSharedObjects: 235 | # Get all .so name 236 | InstallOut = ARExecuteGetStdout(['make', 'install']).replace('\n', ' ') 237 | soregex = r'lib[a-z]*' + suffix + '\.' + target.soext + r'\ ' 238 | 239 | for somatch in re.finditer(soregex, InstallOut): 240 | soname = somatch.group().strip() 241 | if soname not in lib.soLibs: 242 | lib.soLibs.append(soname) 243 | 244 | if stripVersionNumber: 245 | extLibDir='%(InstallDir)s/lib' % locals() 246 | for soname in lib.soLibs: 247 | sopath = '%(extLibDir)s/%(soname)s' % locals() 248 | if not Common_RemoveVersionsFromSo(sopath, target.soext, lib.soLibs): 249 | ARLog('Error while removing versioning informations of %(sopath)s' % locals()) 250 | ret = EndDumpArgs(res=False, **args) 251 | return (ret, lib) if isMp else ret 252 | # Rename lib to _dbg if not already done (ext libraries in debug mode) 253 | if lib.ext and debug: 254 | extLibDir='%(InstallDir)s/lib' % locals() 255 | for soname in lib.soLibs: 256 | if not soname.endswith('_dbg.' + target.soext): 257 | soname_dbg = re.sub('\.' + target.soext + '$', '_dbg.' + target.soext, soname) 258 | extLibDbg='%(extLibDir)s/%(soname_dbg)s' % locals() 259 | extLibNDbg='%(extLibDir)s/%(soname)s' % locals() 260 | ARCopyAndReplaceFile(extLibNDbg, extLibDbg) 261 | mdir.exit() 262 | if makeLock is not None: 263 | makeLock.release() 264 | 265 | else: 266 | if makeLock is not None: 267 | makeLock.acquire() 268 | if os.path.exists ('%(ConfigureDirDbg)s/Makefile' % locals()): 269 | cdir = Chdir(ConfigureDirDbg) 270 | ARExecute(os.environ.get('ARMAKE') + ' uninstall') 271 | ARExecute(os.environ.get('ARMAKE') + ' clean') 272 | cdir.exit () 273 | if os.path.exists ('%(ConfigureDir)s/Makefile' % locals()): 274 | cdir = Chdir(ConfigureDir) 275 | ARExecute(os.environ.get('ARMAKE') + ' uninstall') 276 | ARExecute(os.environ.get('ARMAKE') + ' clean') 277 | cdir.exit () 278 | if makeLock is not None: 279 | makeLock.release() 280 | 281 | 282 | ret = EndDumpArgs(res=True, **args) 283 | return (ret, lib) if isMp else ret 284 | -------------------------------------------------------------------------------- /Utils/Python/Common_CheckBootstrap.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Copyright (C) 2014 Parrot SA 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in 11 | the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Parrot nor the names 14 | of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written 16 | permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 28 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | SUCH DAMAGE. 30 | ''' 31 | from ARFuncs import * 32 | 33 | VALID_BSTRAP_SCRIPTS = [ 'bootstrap', 'buildconf' ] 34 | 35 | def Common_ValidAutotoolsDirectory(path): 36 | if os.path.exists('%(path)s/configure' % locals()): 37 | return True 38 | for tst in VALID_BSTRAP_SCRIPTS: 39 | if os.path.exists('%(path)s/%(tst)s' % locals()): 40 | return True 41 | return False 42 | 43 | def Common_CheckBootstrap(path): 44 | args = dict(locals()) 45 | 46 | StartDumpArgs(**args) 47 | 48 | CONFIGURE = '%(path)s/configure' % locals() 49 | MAKEFILE_AM = '%(path)s/Makefile.am' % locals() 50 | CONFIGURE_AC = '%(path)s/configure.ac' % locals() 51 | CONFIGURE_IN = '%(path)s/configure.in' % locals() 52 | ARSDK_M4 = ARPathFromHere('Utils/m4/ARSDK.m4') 53 | 54 | BSTRAP = '' 55 | 56 | 57 | # Search either a configure script, or a valid bootstrap script 58 | found = False 59 | for bstrap in VALID_BSTRAP_SCRIPTS: 60 | if os.path.exists('%(path)s/%(bstrap)s' % locals()): 61 | found = True 62 | BSTRAP = './%(bstrap)s' % locals() 63 | break 64 | 65 | # Check for needed files for bootstrapping 66 | if (not os.path.exists(MAKEFILE_AM) or not os.path.exists(CONFIGURE_AC)) and not os.path.exists(CONFIGURE): 67 | ARLog('Given directory must contains Makefile.am and configure.ac') 68 | return EndDumpArgs(res=False, **args) 69 | 70 | # Check if we need to rerun the bootstrapping script 71 | # + rerun if needed 72 | mustRerun = False 73 | if not os.path.exists(CONFIGURE): 74 | ARLog('No configure script : must run %(BSTRAP)s' % locals()) 75 | mustRerun = True 76 | elif ARFileIsNewerThan(MAKEFILE_AM, CONFIGURE): 77 | ARLog('%(MAKEFILE_AM)s is newer than %(CONFIGURE)s : rerun %(BSTRAP)s' % locals()) 78 | mustRerun = True 79 | elif ARFileIsNewerThan(CONFIGURE_AC, CONFIGURE): 80 | ARLog('%(CONFIGURE_AC)s is newer than %(CONFIGURE)s : rerun %(BSTRAP)s' % locals()) 81 | mustRerun = True 82 | elif ARFileIsNewerThan(CONFIGURE_IN, CONFIGURE): 83 | ARLog('%(CONFIGURE_IN)s is newer than %(CONFIGURE)s : rerun %(BSTRAP)s' % locals()) 84 | mustRerun = True 85 | elif ARFileIsNewerThan(ARSDK_M4, CONFIGURE): 86 | ARLog('%(ARSDK_M4)s is newer than %(CONFIGURE)s : rerun %(BSTRAP)s' % locals()) 87 | mustRerun = True 88 | 89 | 90 | res = True 91 | if mustRerun: 92 | cdir = Chdir(path) 93 | if found: 94 | res = ARExecute(BSTRAP) 95 | elif os.path.exists(CONFIGURE_AC) or os.path.exists(CONFIGURE_IN) or os.path.exists(MAKEFILE_AM): 96 | res = ARExecute('autoreconf -fiv') 97 | else: 98 | res = True 99 | cdir.exit() 100 | 101 | return EndDumpArgs(res, **args) 102 | -------------------------------------------------------------------------------- /Utils/Python/Common_CheckConfigure.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Copyright (C) 2014 Parrot SA 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in 11 | the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Parrot nor the names 14 | of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written 16 | permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 28 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | SUCH DAMAGE. 30 | ''' 31 | from ARFuncs import * 32 | import re 33 | 34 | def Common_CheckConfigure(lib, confdir, makedir, ConfigureArgs, extraConfigureFiles): 35 | args = dict(locals()) 36 | 37 | StartDumpArgs(**args) 38 | 39 | # Files used in this part 40 | CONFIGURE = '%(confdir)s/configure' % locals() 41 | FAILFILE = '%(makedir)s/.configure.failed' % locals() 42 | CONFIG_LOG = '%(makedir)s/config.log' % locals() 43 | MAKEFILE = '%(makedir)s/Makefile' % locals() 44 | 45 | # Sanity check 46 | if not os.path.exists(CONFIGURE): 47 | ARLog('No configure script in %(confdir)s' % locals()) 48 | return EndDumpArgs(res=False, **args) 49 | 50 | mustRunConfigure = False 51 | 52 | # Check if a previous configure run failed 53 | if os.path.exists(FAILFILE): 54 | ARLog('Previous configure run failed, rerun it') 55 | mustRunConfigure = True 56 | # Check if config.log does exist 57 | elif not os.path.exists(CONFIG_LOG): 58 | ARLog('Config.log does not exists, run configure') 59 | mustRunConfigure = True 60 | # Check if Makefile does exist 61 | elif not os.path.exists(MAKEFILE): 62 | ARLog('Makefile does not exists, run configure') 63 | mustRunConfigure = True 64 | 65 | confCheckFiles = [ CONFIGURE, ARPathFromHere('Utils/Python/ARSDK_PrebuildActions.py') ] 66 | 67 | # For non external lib, add all public headers as deps for configure run 68 | # This allow proper update of enum tostrings and java enum files 69 | # -- > Library which generates code should be avoided in this list. 70 | # Otherwise, the configure will be run each time the target is changed, 71 | # regardless of real changes. 72 | # To find these libraries, we check for deps on xml files. 73 | HeadersDir = lib.path + '/Includes/lib' + lib.name + '/*.h' 74 | if not lib.ext: 75 | hasXmlDeps = False 76 | for ecf in extraConfigureFiles: 77 | if ecf.endswith('xml'): 78 | hasXmlDeps = True 79 | break 80 | if not hasXmlDeps: 81 | if extraConfigureFiles is not None: 82 | extraConfigureFiles.append(HeadersDir) 83 | else: 84 | extraConfigureFiles = [HeadersDir] 85 | 86 | for extraFile in extraConfigureFiles: 87 | if '*' in extraFile: 88 | extraBasedir = os.path.dirname(extraFile) 89 | pattern = os.path.basename(extraFile).replace('*', '.*') 90 | for basedir, directories, files in os.walk(extraBasedir): 91 | for _file in files: 92 | match = re.search(pattern, _file) 93 | if match is not None: 94 | confCheckFiles.append(os.path.join(basedir, _file)) 95 | else: 96 | confCheckFiles.append(extraFile) 97 | 98 | if not mustRunConfigure: 99 | for _file in confCheckFiles: 100 | if ARFileIsNewerThan(_file, CONFIG_LOG): 101 | ARLog(os.path.basename(_file) + ' is newer than config.log, rerun configure') 102 | mustRunConfigure = True 103 | break 104 | 105 | 106 | # Check config.log args against our args 107 | if not mustRunConfigure: 108 | # Write current args as a string (same format as in config.log) 109 | STR_ARGS = ARListAsBashArg(ConfigureArgs).replace('\'','').replace('"','') 110 | # Retrieve config.log args list 111 | LOG_ARGS = None 112 | clogfile = open(CONFIG_LOG, 'r') 113 | for line in clogfile.readlines(): 114 | match = re.search(r'^[\ \t]*\$.*configure.*', line) 115 | if match: 116 | LOG_ARGS = re.sub(r'.*configure\ ', '', line).strip() 117 | break 118 | clogfile.close() 119 | if LOG_ARGS != STR_ARGS: 120 | ARLog('Rerun configure because ConfigureArgs are differents :') 121 | ARLog(' OLD args -> %(LOG_ARGS)s' % locals()) 122 | ARLog(' NEW args -> %(STR_ARGS)s' % locals()) 123 | mustRunConfigure = True 124 | 125 | res = True 126 | if mustRunConfigure: 127 | # Remove fail info file if it exists 128 | ARDeleteIfExists(FAILFILE) 129 | 130 | # Go to makedir 131 | mdir = Chdir(makedir) 132 | 133 | # Run configure 134 | if not ARExecute(CONFIGURE + ' ' + ARListAsBashArg(ConfigureArgs), failOnError=False): 135 | # Error 136 | # Create FAILFILE 137 | open(FAILFILE, 'a').close() 138 | res = False 139 | 140 | if res: 141 | ARExecute(os.environ.get('ARMAKE') + ' clean') 142 | 143 | # Return to previous directory 144 | mdir.exit() 145 | 146 | return EndDumpArgs(res, **args) 147 | -------------------------------------------------------------------------------- /Utils/Python/Common_GenAutotoolsLibraryDoc.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Copyright (C) 2014 Parrot SA 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in 11 | the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Parrot nor the names 14 | of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written 16 | permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 28 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | SUCH DAMAGE. 30 | ''' 31 | from ARFuncs import * 32 | import re 33 | import tempfile 34 | import os 35 | 36 | def Common_WriteValuesToDoxyCfgFile(DFile, **kwargs): 37 | for key, value in kwargs.items(): 38 | os.write(DFile, '%(key)s = %(value)s\n' % locals()) 39 | 40 | def Common_GenAutotoolsLibraryDoc(target, lib, clean=False, subdirsToInclude=[], onlyC=True): 41 | args = dict(locals()) 42 | StartDumpArgs(**args) 43 | 44 | res = False 45 | 46 | # Do not generate doc for external lib 47 | if lib.ext: 48 | ARLog('Documentation will not be generated for external libraries') 49 | return EndDumpArgs(res=True, **args) 50 | OutputDir = ARPathFromHere('Targets/%(target)s/Build/Doc/lib%(lib)s' % locals()) 51 | 52 | # Clean handle 53 | if clean: 54 | ARDeleteIfExists(OutputDir) 55 | return EndDumpArgs(res=True, **args) 56 | 57 | # Create output directory 58 | if not os.path.exists(OutputDir): 59 | os.makedirs(OutputDir) 60 | 61 | # If the directory (release) is configured, just call "make doxygen-doc" 62 | BuildDir = ARPathFromHere('Targets/%(target)s/Build/lib%(lib)s' % locals()) 63 | Makefile = '%(BuildDir)s/Makefile' % locals() 64 | if os.path.exists(Makefile): 65 | bdir = Chdir(BuildDir) 66 | res = ARExecute(os.environ.get('ARMAKE') + ' doxygen-doc') 67 | bdir.exit() 68 | # If make doxygen-doc failed, or if the Makefile does not exists, run doxygen manually 69 | if not res: 70 | DummyDirForRelativePath = ARPathFromHere('Targets/%(target)s/Build/Dummy' % locals()) 71 | if not os.path.exists(DummyDirForRelativePath): 72 | os.makedirs(DummyDirForRelativePath) 73 | ConfigureAc = lib.path + '/Build/configure.ac' 74 | DoxyCfg = lib.path + '/Build/doxygen.cfg' 75 | if not os.path.exists(ConfigureAc): 76 | ARLog('Unable to generate lib%(lib)s documentation') 77 | ARLog('lib%(lib)s does not contains a configure.ac file, and was not previously built') 78 | return EndDumpArgs(res=False, **args) 79 | # Create Doxygen Extra Args 80 | SRCDIR = lib.path + '/Build' 81 | PROJECT = 'lib%(lib)s' % locals() 82 | # -- Search version in configure.ac file 83 | confacfile = open(ConfigureAc) 84 | VERSION = '' 85 | for line in confacfile.readlines(): 86 | match = re.search(r'AC_INIT', line) 87 | if match: 88 | Version = re.sub(r'[A-Z_]*\(\[[^]]*\], \[([^]]*)\].*', r'\1', line).strip() 89 | break 90 | confacfile.close() 91 | if not Version: 92 | ARLog('Unable to read version from configure.ac file') 93 | return EndDumpArgs(res=False, **args) 94 | PERL_PATH = os.popen('which perl').read().strip() 95 | HAVE_DOT = 'NO' 96 | if ARExistsInPath('dot'): 97 | HAVE_DOT = 'YES' 98 | 99 | # Create temporary configuration file 100 | DoxyCfgFinalFile, DoxyCfgFinalName = tempfile.mkstemp() 101 | # -- Copy original file in the temporary one 102 | DoxyCfgFile = open(DoxyCfg) 103 | for line in DoxyCfgFile.readlines(): 104 | os.write(DoxyCfgFinalFile, line) 105 | DoxyCfgFile.close() 106 | 107 | # -- Export needed values 108 | ARSetEnv ('PROJECT', PROJECT) 109 | ARSetEnv ('VERSION', VERSION) 110 | ARSetEnv ('SRCDIR', SRCDIR) 111 | # -- Append needed values 112 | Common_WriteValuesToDoxyCfgFile(DoxyCfgFinalFile, 113 | PERL_PATH=PERL_PATH, 114 | HAVE_DOT=HAVE_DOT, 115 | GENERATE_MAN='NO', 116 | GENERATE_RTF='NO', 117 | GENERATE_XML='NO', 118 | GENERATE_HTMLHELP='NO', 119 | GENERATE_CHI='NO', 120 | GENERATE_HTML='YES', 121 | GENERATE_LATEX='NO',) 122 | 123 | # -- Append subdirs 124 | for extraDir in subdirsToInclude: 125 | if os.path.exists(lib.path + '/../' + extraDir): 126 | os.write(DoxyCfgFinalFile, 'INPUT += $(SRCDIR)/../%(extraDir)s\n' % locals()) 127 | 128 | # -- Append Non-C mode 129 | if not onlyC: 130 | Common_WriteValuesToDoxyCfgFile(DoxyCfgFinalFile, OPTIMIZE_OUTPUT_FOR_C='NO') 131 | 132 | # -- Close temporary file 133 | os.close(DoxyCfgFinalFile) 134 | 135 | # Call doxygen 136 | bdir = Chdir (DummyDirForRelativePath) 137 | res = ARExecute ('doxygen %(DoxyCfgFinalName)s' % locals()) 138 | bdir.exit() 139 | 140 | ARDeleteIfExists(DummyDirForRelativePath) 141 | 142 | os.remove (DoxyCfgFinalName) 143 | 144 | return EndDumpArgs(res, **args) 145 | -------------------------------------------------------------------------------- /Utils/Python/Common_GitUtils.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Copyright (C) 2014 Parrot SA 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in 11 | the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Parrot nor the names 14 | of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written 16 | permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 28 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | SUCH DAMAGE. 30 | ''' 31 | from ARFuncs import * 32 | import os 33 | 34 | def checkAllReposUpToDate(repos, MYDIR, baseRepoUrl, defaultBaseRepoUrl, nonInteractive=False, extraScripts=[]): 35 | for repo in repos.list: 36 | if not repo.ext: 37 | if not repo.forceBaseUrl: 38 | repoURL = baseRepoUrl + repo.name + '.git' 39 | else: 40 | repoURL = defaultBaseRepoUrl + repo.name + '.git' 41 | else: 42 | repoURL = repo.name 43 | repoURL = ARReplaceEnvVars(repoURL) 44 | if repoURL is None: 45 | EXIT(1) 46 | # Clone non existant repositories 47 | if not os.path.exists(repo.getDir()): 48 | ARLog('Cloning %(repo)s git repository' % locals()) 49 | rDir = repo.getDir() 50 | newDir = Chdir(ARPathFromHere('..')) 51 | ARExecute('git clone %(repoURL)s' % locals() + ' ' + rDir, failOnError=(not repo.ext)) 52 | newDir.exit() 53 | # Check for local changes + checkout + pull if needed 54 | gitscript = '%(MYDIR)s/Utils/updateGitStatus.bash' % locals() 55 | for patch in reversed(repo.patches): 56 | patchPath = ARPathFromHere(patch) 57 | repoDir = Chdir(repo.getDir()) 58 | ARExecute('patch -tsNR -p0 < %(patchPath)s' % locals(), failOnError=False) 59 | repoDir.exit() 60 | failOnError = (not repo.ext) or repo.extra 61 | failArg = ' exitOnFailed' if nonInteractive else '' 62 | if not repo.ext or repo.extra: 63 | for scr in extraScripts: 64 | ARExecute(scr + ' ' + repo.getDir(), failOnError=False) 65 | ARExecute(gitscript + ' ' + repo.getDir() + ' ' + repoURL + ' ' + repo.rev + failArg, failOnError=failOnError) 66 | for patch in repo.patches: 67 | patchPath = ARPathFromHere(patch) 68 | repoDir = Chdir(repo.getDir()) 69 | ARExecute('patch -tsN -p0 < %(patchPath)s' % locals(), failOnError=False) 70 | repoDir.exit() 71 | for cmd in repo.additionnalCommands: 72 | ARExecute(cmd) 73 | for webfile in repos.webfilesList: 74 | if not os.path.exists(webfile.storePath): 75 | os.makedirs(webfile.storePath) 76 | Url = webfile.url 77 | Dst = os.path.join(webfile.storePath, webfile.name) 78 | if not os.path.exists(Dst): 79 | downloadOk = False 80 | if ARExistsInPath('wget'): 81 | downloadOk = ARExecute('wget %(Url)s -O %(Dst)s' % locals(), failOnError=True) 82 | elif ARExistsInPath('curl'): 83 | downloadOk = ARExecute('curl -L %(Url)s -o %(Dst)s' % locals(), failOnError=True) 84 | if downloadOk: 85 | root, Ext = os.path.splitext(webfile.name) 86 | spath = Chdir(webfile.storePath) 87 | if Ext in ['.gz', '.tgz']: 88 | ARExecute('tar xzf ' + webfile.name, failOnError=True) 89 | elif Ext in ['.bz2', '.tbz2']: 90 | ARExecute('tar xjf ' + webfile.name, failOnError=True) 91 | elif Ext in ['.zip']: 92 | ARExecute('unzip ' + webfile.name, failOnError=True) 93 | for cmd in webfile.additionnalCommands: 94 | ARExecute(cmd, failOnError=True) 95 | spath.exit() 96 | for patch in webfile.patches: 97 | patchPath = ARPathFromHere(patch) 98 | repoDir = Chdir(webfile.storePath) 99 | ARExecute('patch -tsN -p0 < %(patchPath)s' % locals(), failOnError=False) 100 | repoDir.exit() 101 | 102 | -------------------------------------------------------------------------------- /Utils/Python/Common_HandlePrebuiltDep.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Copyright (C) 2014 Parrot SA 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in 11 | the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Parrot nor the names 14 | of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written 16 | permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 28 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | SUCH DAMAGE. 30 | ''' 31 | import os 32 | import shutil 33 | import re 34 | from ARFuncs import * 35 | 36 | 37 | def Common_HandlePrebuiltDep(target, pb, forcedOutputDir=None, outputSuffixes=None): 38 | args = dict(locals()) 39 | StartDumpArgs(**args) 40 | 41 | res = True 42 | 43 | if not pb.isAvailableForTarget(target): 44 | ARLog('Prebuilt library %(pb)s does not exists for target %(target)s' % locals()) 45 | else: 46 | Type = pb.type 47 | if Type == 'jar': 48 | if not forcedOutputDir: 49 | OutputDirs = [ARPathFromHere('Targets/%(target)s/Install/jars/release/' % locals()), 50 | ARPathFromHere('Targets/%(target)s/Install/jars/debug/' % locals())] 51 | else: 52 | OutputDirs = [forcedOutputDir] 53 | for OutputDir in OutputDirs: 54 | if not os.path.exists(OutputDir): 55 | os.makedirs(OutputDir) 56 | Path = pb.path 57 | Path = ARReplaceEnvVars(Path) 58 | if Path is None: 59 | return EndDumpArgs(res=False, **args) 60 | OutputFile = os.path.join(OutputDir, os.path.basename(Path)) 61 | if not os.path.exists(OutputFile): 62 | shutil.copy2(Path, OutputFile) 63 | elif Type == 'header_only': 64 | Name = pb.name 65 | if not forcedOutputDir: 66 | rootOutputDir = ARPathFromHere('Targets/%(target)s/Install/' % locals()) 67 | OutputDirs = [] 68 | if outputSuffixes: 69 | for d in outputSuffixes: 70 | OutputDirs.append('%(rootOutputDir)s/%(d)s/include/%(Name)s/' % locals()) 71 | else: 72 | OutputDirs.append('%(rootOutputDir)s/include/%(Name)s/' % locals()) 73 | else: 74 | OutputDirs = [forcedOutputDir] 75 | for OutputDir in OutputDirs: 76 | Path = pb.path 77 | Path = ARReplaceEnvVars(Path) 78 | if Path is None: 79 | return EndDumpArgs(res=False, **args) 80 | ARCopyAndReplace(Path, OutputDir, deletePrevious=True) 81 | elif Type == 'external_project': 82 | if not forcedOutputDir: 83 | OutputDirs = [ ARPathFromHere('../' + pb.name) ] 84 | else: 85 | OutputDirs = [ forcedOutputDir ] 86 | for OutputDir in OutputDirs: 87 | Path = pb.path 88 | Path = ARReplaceEnvVars(Path) 89 | if Path is None: 90 | return EndDumpArgs(res=False, **args) 91 | if not os.path.islink(OutputDir): 92 | os.symlink(Path,OutputDir) 93 | else: 94 | ARLog('Do not know how to handle prebuilts of type %(Type)s' % locals()) 95 | res = False 96 | 97 | return EndDumpArgs(res, **args) 98 | -------------------------------------------------------------------------------- /Utils/Python/Common_RemoveVersionsFromSo.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Copyright (C) 2014 Parrot SA 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in 11 | the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Parrot nor the names 14 | of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written 16 | permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 28 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | SUCH DAMAGE. 30 | ''' 31 | from ARFuncs import * 32 | import os 33 | import shutil 34 | import re 35 | 36 | if sys.version_info < (3,): 37 | range = xrange 38 | 39 | def Common_RemoveVersionsFromSo(rootSo, soext, depLibs): 40 | # This script needs rpl to be in the path 41 | if not ARExistsInPath('rpl'): 42 | ARLog('rpl is needed to strip versioning informations from shared object files') 43 | return False 44 | 45 | outputName = rootSo 46 | inputName = rootSo 47 | # Can't work on a lib if it does not exists 48 | if not os.path.exists(inputName): 49 | ARLog('%(inputName)s does not exists' % locals()) 50 | return False 51 | # If the lib is not a symlink to the main library, assume it was already stripped of versioning symbols 52 | # and remove input if different from output 53 | if os.path.exists(outputName) and not os.path.islink(outputName): 54 | if inputName is not outputName: 55 | ARDeleteIfExists(inputName) 56 | return True 57 | 58 | DirName = os.path.dirname(inputName) 59 | # Remove symlink and copy acutal lib 60 | ActualName = os.readlink(inputName) 61 | ARDeleteIfExists(outputName) 62 | ARDeleteIfExists(inputName) 63 | shutil.copy2(os.path.join(DirName, ActualName), outputName) 64 | 65 | for BaseName in os.path.basename(inputName) and depLibs: 66 | # Find other names 67 | OtherNames = [ f for f in os.listdir(DirName) if BaseName in f and not f.endswith('.' + soext) ] 68 | 69 | # Iterate over other names 70 | for name in OtherNames: 71 | # Compute new string to replace 72 | lenDiff = len(name) - len(BaseName) 73 | newString = BaseName 74 | for i in range(lenDiff): 75 | newString = newString + r'\0' 76 | # Call rpl 77 | if not ARExecute('rpl -e %(name)s "%(newString)s" %(outputName)s >/dev/null 2>&1' % locals(), printErrorMessage=False): 78 | ARLog('Error while running rpl') 79 | return False 80 | return True 81 | -------------------------------------------------------------------------------- /Utils/Python/Common_RunAntScript.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Copyright (C) 2014 Parrot SA 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in 11 | the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Parrot nor the names 14 | of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written 16 | permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 28 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | SUCH DAMAGE. 30 | ''' 31 | from ARFuncs import * 32 | 33 | def Common_RunAntScript(RootDir, SrcDir, Script, depLibs=[], debug=False, clean=False): 34 | args = dict(locals()) 35 | StartDumpArgs(**args) 36 | return EndDumpArgs(res=True, **args) 37 | -------------------------------------------------------------------------------- /Utils/Python/Darwin_RunXcodeBuild.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Copyright (C) 2014 Parrot SA 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in 11 | the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Parrot nor the names 14 | of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written 16 | permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 28 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | SUCH DAMAGE. 30 | ''' 31 | from ARFuncs import * 32 | import shutil 33 | 34 | def Darwin_RunXcodeBuild(target, lib, xcprojPath, archs, debug=False, clean=False): 35 | args = dict(locals()) 36 | StartDumpArgs(**args) 37 | 38 | res = True 39 | 40 | if not os.path.exists(xcprojPath): 41 | ARLog('%(xcprojPath)s does not exists' % locals()) 42 | return EndDumpArgs(res=False, **args) 43 | 44 | FrameworksDir = ARPathFromHere('Targets/%(target)s/Install/Frameworks' % locals()) 45 | 46 | libLower = lib.name.lower() 47 | libPrefix = 'lib' if ((not libLower.startswith('lib')) and (not lib.ext)) else '' 48 | 49 | Framework = '%(FrameworksDir)s/%(libPrefix)s%(lib)s.framework' % locals() 50 | FrameworkDbg = '%(FrameworksDir)s/%(libPrefix)s%(lib)s_dbg.framework' % locals() 51 | 52 | BuiltLibs = [] 53 | xcprojDir = os.path.realpath('%(xcprojPath)s/..' % locals()) 54 | 55 | if debug: 56 | ARDeleteIfExists(FrameworkDbg) 57 | else: 58 | ARDeleteIfExists(Framework) 59 | 60 | for dictionnary in archs: 61 | arch = dictionnary['arch'] 62 | platform = dictionnary['platform'] 63 | minos = dictionnary['minos'] 64 | #for arch, platform in archs.items(): 65 | SDK = platform.lower() 66 | if clean: 67 | if not ARExecute('xcodebuild -project %(xcprojPath)s -configuration Release -sdk %(SDK)s -arch %(arch)s clean' % locals()): 68 | ARLog('Unable to clean Release project') 69 | return EndDumpArgs(res=False, **args) 70 | if not ARExecute('xcodebuild -project %(xcprojPath)s -configuration Debug -sdk %(SDK)s -arch %(arch)s clean' % locals()): 71 | ARLog('Unable to clean Debug project') 72 | return EndDumpArgs(res=False, **args) 73 | else: 74 | CONFIGURATION = 'Release' 75 | if debug: 76 | CONFIGURATION = 'Debug' 77 | if not ARExecute('xcodebuild -project %(xcprojPath)s -configuration %(CONFIGURATION)s -sdk %(SDK)s -arch %(arch)s' % locals()): 78 | ARLog('Unable to build %(CONFIGURATION)s project' % locals()) 79 | return EndDumpArgs(res=False, **args) 80 | 81 | BuildFramework = '%(xcprojDir)s/Products/%(arch)s/%(libPrefix)s%(lib)s.framework' % locals() 82 | BuildFrameworkDbg = '%(xcprojDir)s/Products/%(arch)s/%(libPrefix)s%(lib)s_dbg.framework' % locals() 83 | 84 | if debug: 85 | if not os.path.exists(FrameworkDbg): 86 | shutil.copytree(BuildFrameworkDbg, FrameworkDbg) 87 | BuiltLibs.extend([ os.path.join(BuildFrameworkDbg, l) for l in os.listdir(BuildFrameworkDbg) if 'lib' in l]) 88 | else: 89 | if not os.path.exists(Framework): 90 | shutil.copytree(BuildFramework, Framework) 91 | BuiltLibs.extend([ os.path.join(BuildFramework, l) for l in os.listdir(BuildFramework) if 'lib' in l]) 92 | 93 | # Create(or delete) universal framework 94 | if clean: 95 | ARDeleteIfExists(Framework) 96 | ARDeleteIfExists(FrameworkDbg) 97 | else: 98 | FrameworkLib = '%(Framework)s/%(libPrefix)s%(lib)s' % locals() 99 | if debug: 100 | FrameworkLib = '%(FrameworkDbg)s/%(libPrefix)s%(lib)s_dbg' % locals() 101 | 102 | if not ARExecute('lipo ' + ARListAsBashArg(BuiltLibs) + ' -create -output ' + FrameworkLib): 103 | ARLog('Error while creating universal library') 104 | return EndDumpArgs(res=False, **args) 105 | 106 | return EndDumpArgs(res=True, **args) 107 | -------------------------------------------------------------------------------- /Utils/Python/Java_GenLibraryDoc.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Copyright (C) 2014 Parrot SA 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in 11 | the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Parrot nor the names 14 | of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written 16 | permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 28 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | SUCH DAMAGE. 30 | ''' 31 | from ARFuncs import * 32 | from Common_HandlePrebuiltDep import * 33 | import os 34 | import shutil 35 | 36 | def Java_GenLibraryDoc(target, lib, clean=False, extraSrcDirs=[], extraJavadocArgs=[], extraClasspath=[]): 37 | args = dict(locals()) 38 | StartDumpArgs(**args) 39 | 40 | OutputDir = ARPathFromHere('Targets/%(target)s/Build/Doc' % locals()) 41 | JavadocRootDir = ARPathFromHere('Targets/%(target)s/Build/.srcdir' % locals()) 42 | JavadocSrcDir = '%(JavadocRootDir)s/sources' % locals() 43 | JavadocPrebuiltDir = '%(JavadocRootDir)s/prebuilts' % locals() 44 | 45 | # Clean : remove ALL docs (not just the one of the library) 46 | if clean: 47 | ARDeleteIfExists (OutputDir, JavadocSrcDir) 48 | return EndDumpArgs(res=True, **args) 49 | 50 | # Create a directory to hold all java sources to generate doc 51 | if not os.path.exists(JavadocSrcDir): 52 | os.makedirs(JavadocSrcDir) 53 | if not os.path.exists(JavadocPrebuiltDir): 54 | os.makedirs(JavadocPrebuiltDir) 55 | 56 | # Copy sources to the folder 57 | srcDirs = ['JNI/java'] 58 | srcDirs.extend(extraSrcDirs) 59 | 60 | for _dir in srcDirs: 61 | SrcDir = lib.path + '/%(_dir)s' % locals() 62 | DstDir = '%(JavadocSrcDir)s/' % locals() 63 | if os.path.exists(SrcDir): 64 | ARCopyAndReplace(SrcDir, DstDir) 65 | 66 | # Copy prebuilts 67 | classpath = [] 68 | for prebuilt in lib.pbdeps: 69 | if not Common_HandlePrebuiltDep(target, prebuilt, forcedOutputDir=JavadocPrebuiltDir): 70 | ARLog('Error while handling prebuilt library %(prebuilt)s' % locals()) 71 | return EndDumpArgs(res=False, **args) 72 | 73 | # Run javadoc 74 | # -- Find list of .java / .jar (prebuilts) files 75 | JavaFiles = [] 76 | for baseDir, directories, files in os.walk(JavadocSrcDir): 77 | for f in files: 78 | if f.endswith('.java'): 79 | JavaFiles.append(os.path.join(os.path.join(JavadocSrcDir, baseDir), f)) 80 | for baseDir, directories, files in os.walk(JavadocPrebuiltDir): 81 | for f in files: 82 | if f.endswith('.jar'): 83 | classpath.append(os.path.join(os.path.join(JavadocPrebuiltDir, baseDir), f)) 84 | classpath.extend(extraClasspath) 85 | 86 | # -- Do nothing if no input files are found 87 | if not JavaFiles: 88 | return EndDumpArgs(res=True, **args) 89 | 90 | # -- Convert list as strings 91 | ExtraArgsString = ARListAsBashArg(extraJavadocArgs) 92 | JavaFilesString = ARListAsBashArg(JavaFiles) 93 | classPathString = '' 94 | if classpath: 95 | classPathString = '-classpath "' 96 | for c in classpath: 97 | classPathString = classPathString + c + ':' 98 | classPathString = classPathString[:-1] + '"' 99 | 100 | # -- Actual run 101 | res = ARExecute('javadoc -d %(OutputDir)s %(JavaFilesString)s %(ExtraArgsString)s %(classPathString)s' % locals()) 102 | 103 | return EndDumpArgs(res, **args) 104 | -------------------------------------------------------------------------------- /Utils/Python/Unix_BuildBinary.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Copyright (C) 2014 Parrot SA 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in 11 | the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Parrot nor the names 14 | of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written 16 | permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 28 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | SUCH DAMAGE. 30 | ''' 31 | from ARFuncs import * 32 | from Unix_BuildLibrary import * 33 | 34 | def Unix_BuildBinary(target, bin, clean=False, debug=False, nodeps=False, inhouse=False, requestedArchs=None): 35 | args = dict(locals()) 36 | StartDumpArgs(**args) 37 | 38 | # Sanity check : is library valid for this target 39 | if not bin.isAvailableForTarget(target): 40 | ARLog('%(bin)s does not need to be built for %(target)s' % locals()) 41 | return EndDumpArgs(res=True, **args) 42 | 43 | # First thing : build deps 44 | if not nodeps: 45 | for dep in bin.deps: 46 | ARLog('Building lib%(dep)s (dependancy of %(bin)s)' % locals()) 47 | if target.hasAlreadyBuilt(dep): 48 | ARLog('Dependancy lib%(dep)s already built for %(target)s' % locals()) 49 | elif not dep.isAvailableForTarget(target): 50 | ARLog('Dependancy lib%(dep)s does not need to be built for %(target)s' % locals()) 51 | elif Unix_BuildLibrary(target, dep, clean, debug): 52 | ARLog('Dependancy lib%(dep)s built' % locals()) 53 | else: 54 | ARLog('Error while building dependancy lib%(dep)s' %locals()) 55 | return EndDumpArgs(res=False, **args) 56 | else: 57 | ARLog('Skipping deps building for %(bin)s' % locals()) 58 | 59 | target.addTriedBinary(bin) 60 | 61 | # Next : build binary as if it was a library 62 | res = Common_BuildConfigureLibrary(target, bin, clean=clean, debug=debug, isLib=False, inhouse=inhouse) 63 | 64 | if res: 65 | target.addBuiltBinary(bin) 66 | 67 | return EndDumpArgs(res=res, **args) 68 | -------------------------------------------------------------------------------- /Utils/Python/Unix_BuildLibrary.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Copyright (C) 2014 Parrot SA 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in 11 | the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Parrot nor the names 14 | of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written 16 | permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 28 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | SUCH DAMAGE. 30 | ''' 31 | from ARFuncs import * 32 | from Common_BuildConfigureLibrary import * 33 | from Common_HandlePrebuiltDep import * 34 | 35 | def Unix_BuildLibrary(target, lib, clean=False, debug=False, nodeps=False, inhouse=False, requestedArchs=None, isMp=False): 36 | # Unix libraries are only configure libraries, with no extra args 37 | args = dict(locals()) 38 | StartDumpArgs(**args) 39 | 40 | # Sanity check : is library valid for this target 41 | if not lib.isAvailableForTarget(target): 42 | ARLog('lib%(lib)s does not need to be built for %(target)s' % locals()) 43 | return EndDumpArgs(res=True, **args) 44 | 45 | # First thing : build deps 46 | if not nodeps: 47 | for pb in lib.pbdeps: 48 | if not Common_HandlePrebuiltDep(target, pb): 49 | ARLog('Error while handling prebuilt library %(pb)s' % locals()) 50 | return EndDumpArgs(res=False, **args) 51 | for dep in lib.deps: 52 | ARLog('Building lib%(dep)s (dependancy of lib%(lib)s)' % locals()) 53 | if target.hasAlreadyBuilt(dep): 54 | ARLog('Dependancy lib%(dep)s already built for %(target)s' % locals()) 55 | elif not dep.isAvailableForTarget(target): 56 | ARLog('Dependancy lib%(dep)s does not need to be built for %(target)s' % locals()) 57 | elif Unix_BuildLibrary(target, dep, clean, debug): 58 | ARLog('Dependancy lib%(dep)s built' % locals()) 59 | else: 60 | ARLog('Error while building dependancy lib%(dep)s' %locals()) 61 | return EndDumpArgs(res=False, **args) 62 | else: 63 | ARLog('Skipping deps building for %(lib)s' % locals()) 64 | 65 | target.addTriedLibrary(lib) 66 | 67 | # Then : build this library 68 | ExtraConfFlags = [ 'CFLAGS="-fPIC"'] 69 | res = Common_BuildConfigureLibrary(target, lib, extraArgs=ExtraConfFlags, clean=clean, debug=debug, inhouse=inhouse, isMp=False) 70 | 71 | # If all went well, mark the library as built for current target 72 | if res: 73 | target.addBuiltLibrary(lib) 74 | 75 | return EndDumpArgs(res, **args) 76 | -------------------------------------------------------------------------------- /Utils/Python/Unix_GenLibraryDoc.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Copyright (C) 2014 Parrot SA 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in 11 | the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Parrot nor the names 14 | of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written 16 | permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 28 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | SUCH DAMAGE. 30 | ''' 31 | from ARFuncs import * 32 | from Common_GenAutotoolsLibraryDoc import * 33 | 34 | def Unix_GenLibraryDoc(target, lib, clean=False): 35 | args = dict(locals()) 36 | StartDumpArgs(**args) 37 | 38 | res = Common_GenAutotoolsLibraryDoc(target, lib, clean) 39 | 40 | return EndDumpArgs(res, **args) 41 | -------------------------------------------------------------------------------- /Utils/Python/commandLine.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Copyright (C) 2014 Parrot SA 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in 11 | the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Parrot nor the names 14 | of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written 16 | permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 28 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | SUCH DAMAGE. 30 | ''' 31 | import os 32 | import argparse 33 | from ARFuncs import * 34 | 35 | defaultBaseRepoUrl = 'https://github.com/Parrot-Developers/' 36 | 37 | class CommandLineParser: 38 | "Command line options parser for ARSDK 3 build script" 39 | def __init__(self, targets, libraries, binaries): 40 | self.availableTargets = targets 41 | self.availableLibraries = libraries 42 | self.availableBinaries = binaries 43 | self.activeTargets = [] 44 | self.activeLibs = [] 45 | self.activeBins = [] 46 | self.isClean = False 47 | self.isDebug = False 48 | self.isInHouse = False 49 | self.isForceClean = False 50 | self.isForceCleanup = False 51 | self.genDoc = False 52 | self.installDoc = False 53 | self.doNothing = False 54 | self.noGit = False 55 | self.noDeps = False 56 | self.multiProcess = False 57 | self.threads = -1 58 | self.defaultBaseRepoUrl = defaultBaseRepoUrl 59 | self.repoBaseUrl = defaultBaseRepoUrl 60 | self.extraGitScripts = [] 61 | self.archs = [] 62 | self.parser = argparse.ArgumentParser() 63 | self.init_parser() 64 | 65 | def init_parser(self): 66 | targetsNames = [ t.name for t in self.availableTargets.list ] 67 | librariesNames = [ l.name for l in self.availableLibraries.list ] 68 | binariesNames = [ b.name for b in self.availableBinaries.list ] 69 | self.parser.add_argument('-t', '--target', action="append", choices=targetsNames, help="Target name (cumulative)") 70 | self.parser.add_argument('-l', '--library', action="append", choices=librariesNames, help="Library name (cumulative)") 71 | self.parser.add_argument('-b', '--binary', action="append", choices=binariesNames, help="Binary name (cumulative)") 72 | self.parser.add_argument('-c', '--clean', action="store_true", help="Clean all selected lib/bin") 73 | self.parser.add_argument('-d', '--debug', action="store_true", help="Build selected lib/bin in debug mode") 74 | self.parser.add_argument('--inhouse', action="store_true", help="Build the SDK for inhouse distribution") 75 | self.parser.add_argument('--force-clean', action="store_true", help="Wipe all targets (overrides any other setting)") 76 | self.parser.add_argument('--all-cleanup', action="store_true", help="Implies `--force-clean` and run all cleanup scripts in internal repositories") 77 | self.parser.add_argument('--doc', action="store_true", help="Generate documentation after building") 78 | self.parser.add_argument('--install-doc', action="store_true", help="Implies `--doc` and copy the generated documentation to Docs repository") 79 | self.parser.add_argument('--none', action="store_true", help="Do only GIT Checks, do not build / clean anything") 80 | self.parser.add_argument('--nogit', action="store_true", help="Do not run GIT checks") 81 | self.parser.add_argument('-j', type=int, help="The number of threads to use. Automatically set to the number of CPUs if not set") 82 | self.parser.add_argument('--nodep', action="store_true", help="Do not build deps. Use at your own risks.") 83 | self.parser.add_argument('--repo-base-url', action="store", help=("Use the following base URL instead of " + defaultBaseRepoUrl)) 84 | self.parser.add_argument('--extra-git-script', action="append", help="Path (relative to ARSDKBuildUtils directory) to an extra script which will be run before updating git repo (with path as its first argument)") 85 | self.parser.add_argument('--arch', action="append", help="Architectures to be built. May be ignored depending of the target. May fail if an invalid arch name is provided. (Use only if you know what you're doing !)") 86 | self.parser.add_argument('--mp', action="store_true", help="Run in multiprocess mode (experimental !)") 87 | 88 | 89 | def parse(self, argv): 90 | 91 | AL_FILE=ARPathFromHere('.alreadyLaunched') 92 | if len(argv) == 1 and not os.path.exists(AL_FILE): 93 | ARPrint('This is the first time you run this script without arguments.') 94 | ARPrint('Running without arguments will build all available libraries/binaries for all available targets.') 95 | ARPrint('If you want to select which targets/libraries/binaries you want to build, use the command line options.') 96 | ARPrint('') 97 | ARPrint('If you rerun this command again, this message will not be displayed again and the build will be done.') 98 | ARPrint('') 99 | ARPrint(' --> Running with --help to show the possible options') 100 | tmp = open(AL_FILE, 'w') 101 | tmp.close() 102 | argv.append('--help') 103 | 104 | args=self.parser.parse_args(argv[1:]) 105 | 106 | ARLog ('Args = ' + str(args)) 107 | 108 | 109 | # Parse OPTs 110 | if args.force_clean: 111 | self.isForceClean = True 112 | if args.all_cleanup: 113 | self.isForceClean = True 114 | self.isForceCleanup = True 115 | if args.doc: 116 | self.genDoc = True 117 | if args.install_doc: 118 | self.genDoc = True 119 | self.installDoc = True 120 | if args.none: 121 | self.doNothing = True 122 | if args.nogit: 123 | self.noGit = True 124 | if args.nodep: 125 | self.noDeps = True 126 | if args.target: 127 | for arg in args.target: 128 | self.activeTargets.append(self.availableTargets.getTarget(arg)) 129 | if args.binary: 130 | for arg in args.binary: 131 | t_bin = self.availableBinaries.getBin(arg) 132 | self.activeBins.append(t_bin) 133 | if args.library: 134 | for arg in args.library: 135 | t_lib = self.availableLibraries.getLib(arg) 136 | self.activeLibs.append(t_lib) 137 | if args.inhouse: 138 | self.isInHouse = True 139 | if args.clean: 140 | self.isClean = True 141 | if args.debug: 142 | self.isDebug = True 143 | if args.j and int(args.j) >= 0: 144 | self.threads = int(args.j) 145 | if args.repo_base_url: 146 | self.repoBaseUrl = args.repo_base_url 147 | if args.extra_git_script: 148 | self.extraGitScripts = args.extra_git_script[:] 149 | if args.arch: 150 | self.archs = args.arch[:] 151 | if args.mp: 152 | self.multiProcess = True 153 | 154 | # Fill default values if needed 155 | if not self.activeTargets: 156 | for tar in self.availableTargets.list: 157 | self.activeTargets.append(tar) 158 | if not self.activeBins and not self.activeLibs: 159 | for bin in self.availableBinaries.list: 160 | self.activeBins.append(bin) 161 | for lib in self.availableLibraries.list: 162 | self.activeLibs.append(lib) 163 | if self.threads == 0: 164 | self.threads = 1 165 | elif self.threads < 0: 166 | self.threads = ARGetNumberOfCpus() 167 | ARLog('Using automatic -j --> -j ' + str(self.threads)) 168 | 169 | # If in clean mode, reverse build order(clean deps after) 170 | if self.isClean: 171 | newLibs = [] 172 | for lib in reversed(self.activeLibs): 173 | newLibs.append(lib) 174 | self.activeLibs = newLibs 175 | newBins = [] 176 | for bin in reversed(self.activeBins): 177 | newBins.append(bin) 178 | self.activeBins = newBins 179 | 180 | def dump(self): 181 | ARLog('Build script called with the following configuration:') 182 | ARLog(' - FORCE CLEANUP = ' + str(self.isForceCleanup)) 183 | ARLog(' - FORCE CLEAN = ' + str(self.isForceClean)) 184 | ARLog(' - DEBUG = ' + str(self.isDebug)) 185 | ARLog(' - CLEAN = ' + str(self.isClean)) 186 | ARLog(' - GENERATE DOC = ' + str(self.genDoc)) 187 | ARLog(' - INSTALL DOC = ' + str(self.installDoc)) 188 | ARLog(' - DO NOTHING = ' + str(self.doNothing)) 189 | ARLog(' - NO GIT = ' + str(self.noGit)) 190 | ARLog(' - NO DEPS = ' + str(self.noDeps)) 191 | ARLog(' - NB THREADS = ' + str(self.threads)) 192 | ARLog(' - MULTIPROCESS = ' + str(self.multiProcess)) 193 | ARLog('Active targets : {') 194 | for tar in self.activeTargets: 195 | ARLog(' - %(tar)s' % locals()) 196 | ARLog('}') 197 | ARLog('Active libraries : {') 198 | for lib in self.activeLibs: 199 | ARLog(' - %(lib)s' % locals()) 200 | ARLog('}') 201 | ARLog('Active binaries : {') 202 | for bin in self.activeBins: 203 | ARLog(' - %(bin)s' % locals()) 204 | ARLog('}') 205 | ARLog('') 206 | -------------------------------------------------------------------------------- /Utils/Python/iOS_BuildLibrary.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Copyright (C) 2014 Parrot SA 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in 11 | the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Parrot nor the names 14 | of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written 16 | permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 28 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | SUCH DAMAGE. 30 | ''' 31 | from ARFuncs import * 32 | from Common_BuildConfigureLibrary import * 33 | from Darwin_RunXcodeBuild import * 34 | from iOS_HandlePrebuiltDep import * 35 | import shutil 36 | import re 37 | from multiprocessing import Lock, Pool, Manager 38 | 39 | XCRunCache = {} 40 | 41 | def iOS_getXCRunExec(program, sdk, failOnError=True): 42 | if XCRunCache.get(sdk): 43 | if XCRunCache[sdk].get(program): 44 | val = XCRunCache[sdk][program] 45 | return val 46 | val = ARExecuteGetStdout(["xcrun", "--sdk", sdk, "--find", program], failOnError=failOnError) 47 | if not XCRunCache.get(sdk): 48 | cacheDict = { program: val } 49 | XCRunCache[sdk] = cacheDict 50 | else: 51 | XCRunCache[sdk][program] = val 52 | return val 53 | 54 | def iOS_GetXcodeProject(lib): 55 | # 1st check : the iOS dir must exist 56 | iOSPath = lib.path + '/iOS' 57 | if not os.path.exists(iOSPath): 58 | return None 59 | # 2nd check, the iOS dir must contain a .xcodeproj directory 60 | directories = [ d for d in os.listdir(iOSPath) if os.path.isdir(os.path.join(iOSPath, d))] 61 | for d in directories: 62 | if '.xcodeproj' in d: 63 | return os.path.join(iOSPath, d) 64 | return None 65 | 66 | def iOS_HasXcodeProject(lib): 67 | return iOS_GetXcodeProject(lib) is not None 68 | 69 | def iOS_MakePostProcessCb(lib, BuiltLibs, sslLibs, cryptoLibs, Strip, ArchLibDir): 70 | def iOS_PostProcessCb(arg): 71 | p_res = arg[0] 72 | p_updatedlib = arg[1] 73 | 74 | # Get the static libs installed 75 | if p_res: 76 | liblower = lib.name.lower() 77 | newLibs = [ os.path.join(ArchLibDir, l) for l in os.listdir(ArchLibDir) if '.a' in l] 78 | if lib.ext: 79 | for libToStrip in newLibs: 80 | ARExecute(Strip + ' -S ' + libToStrip, failOnError=False) 81 | if (lib.name == 'libressl'): 82 | sslLibs.extend([os.path.join(ArchLibDir, 'libssl.a')]) 83 | cryptoLibs.extend([os.path.join(ArchLibDir, 'libcrypto.a')]) 84 | ARExecute('libtool -static -o ' + os.path.join(ArchLibDir, 'libressl.a') + ' ' + os.path.join(ArchLibDir, 'libssl.a') + ' ' + os.path.join(ArchLibDir, 'libcrypto.a'), failOnError=False) 85 | BuiltLibs.extend([os.path.join(ArchLibDir, 'libressl.a')]) 86 | else: 87 | BuiltLibs.extend(newLibs) 88 | 89 | return iOS_PostProcessCb 90 | 91 | def iOS_BuildLibrary(target, lib, clean=False, debug=False, nodeps=False, inhouse=False, requestedArchs=None, isMp=False): 92 | args = dict(locals()) 93 | 94 | StartDumpArgs(**args) 95 | 96 | # Sanity check : is library valid for this target 97 | if not lib.isAvailableForTarget(target): 98 | ARLog('lib%(lib)s does not need to be built for %(target)s' % locals()) 99 | return EndDumpArgs(res=True, **args) 100 | 101 | # First thing : build deps 102 | if not nodeps: 103 | for pb in lib.pbdeps: 104 | if not iOS_HandlePrebuiltDep(target, pb, clean=clean, debug=debug): 105 | ARLog('Error while handling prebuilt library %(pb)s' % locals()) 106 | return EndDumpArgs(res=False, **args) 107 | for dep in lib.deps: 108 | ARLog('Building lib%(dep)s (dependancy of lib%(lib)s)' % locals()) 109 | if target.hasAlreadyBuilt(dep): 110 | ARLog('Dependancy lib%(dep)s already built for %(target)s' % locals()) 111 | elif not dep.isAvailableForTarget(target): 112 | ARLog('Dependancy lib%(dep)s does not need to be built for %(target)s' % locals()) 113 | elif iOS_BuildLibrary(target, dep, clean, debug, nodeps, inhouse, requestedArchs): 114 | ARLog('Dependancy lib%(dep)s built' % locals()) 115 | else: 116 | ARLog('Error while building dependancy lib%(dep)s' %locals()) 117 | return EndDumpArgs(res=False, **args) 118 | else: 119 | ARLog('Skipping deps building for %(lib)s' % locals()) 120 | 121 | target.addTriedLibrary(lib) 122 | 123 | # Check that we're building on Mac OSX 124 | if not ARExecute('test $(uname) = Darwin', 125 | failOnError=False, 126 | printErrorMessage=False): 127 | ARLog('Can\'t build an iOS library while not on Mac OSX (Darwin)') 128 | return EndDumpArgs(res=True, **args) 129 | 130 | # iOS libraries consists of two exclusive parts 131 | # 1> An autotools library 132 | # 2> An Xcode project 133 | 134 | KnownArchs = [ { 'arch':'armv7', 'platform':'iPhoneOS', 'minos':'iphoneos' }, 135 | { 'arch':'armv7s', 'platform':'iPhoneOS', 'minos':'iphoneos' }, 136 | { 'arch':'arm64', 'platform':'iPhoneOS', 'minos':'iphoneos' }, 137 | # { 'arch':'i386', 'platform':'iPhoneSimulator', 'minos':'ios-simulator' }, 138 | { 'arch':'x86_64', 'platform':'iPhoneSimulator', 'minos':'ios-simulator' }] 139 | 140 | KnownEabis = [ arch['arch'] for arch in KnownArchs ] 141 | ValidArchs = [] 142 | 143 | if requestedArchs: 144 | ValidArchs = [ arch for arch in KnownArchs if arch['arch'] in requestedArchs ] 145 | for ra in requestedArchs: 146 | if ra not in KnownEabis: 147 | ARLog('Error : requested arch %(ra)s is not available for target iOS' % locals()) 148 | ARLog(' Avaiable archs : %(KnownEabis)s' % locals()) 149 | return EndDumpArgs(res=False, **args) 150 | if not ValidArchs: 151 | ValidArchs = KnownArchs 152 | 153 | 154 | InstallDir = ARPathFromHere('Targets/%(target)s/Install/' % locals()) 155 | FrameworksDir = '%(InstallDir)s/Frameworks/' % locals() 156 | 157 | libLower = lib.name.lower() 158 | libPrefix = 'lib' if ((not libLower.startswith('lib')) and (not lib.ext)) else '' 159 | 160 | Framework = '%(FrameworksDir)s/%(libPrefix)s%(lib)s.framework' % locals() 161 | FrameworkDbg = '%(FrameworksDir)s/%(libPrefix)s%(lib)s_dbg.framework' % locals() 162 | 163 | # Build the autotools part 164 | BuiltLibs = [] 165 | sslLibs = [] 166 | cryptoLibs = [] 167 | if Common_IsConfigureLibrary(lib): 168 | # Add extra exports to force configure to assume that we have a working malloc 169 | # If not set, configure will fail the malloc test and will use 'rpl_malloc' and 'rpl_realloc' 170 | # for libraries which defines the AC_FUNC_MALLOC in their configure.ac 171 | # This leads to link issues for programs. 172 | forcedMalloc = ARSetEnvIfEmpty('ac_cv_func_malloc_0_nonnull', 'yes') 173 | forcedRealloc = ARSetEnvIfEmpty('ac_cv_func_realloc_0_nonnull', 'yes') 174 | pool = Pool(processes=len(ValidArchs)) 175 | poolResults = [] 176 | retStatus = True 177 | bLock = Manager().Lock() 178 | cLock = Manager().Lock() 179 | mLock = None 180 | 181 | for dictionnary in ValidArchs: 182 | arch = dictionnary['arch'] 183 | platform = dictionnary['platform'] 184 | minos = dictionnary['minos'] 185 | # Find latest iOS platform 186 | iOSSDKRoot = '/Applications/Xcode.app/Contents/Developer/Platforms/%(platform)s.platform/Developer/SDKs/' % locals() 187 | Subdirs = os.walk(iOSSDKRoot).next()[1] 188 | Subdirs.sort() 189 | if len(Subdirs) > 0: 190 | Sysroot = iOSSDKRoot + Subdirs[-1] 191 | else: 192 | ARLog('Unable to find a suitable iOS SDK for %(platform)s' % locals()) 193 | return EndDumpArgs(res=False, **args) 194 | SdkVersionMatch = re.search(r'[0-9]*\.[0-9]*', Subdirs[-1]) 195 | if SdkVersionMatch: 196 | SdkVersion = SdkVersionMatch.group(0) 197 | else: 198 | ARLog('Unable to find a suitable iOS SDK for %(platform)s' % locals()) 199 | return EndDumpArgs(res=False, **args) 200 | SdkLower = platform.lower() 201 | Compiler = iOS_getXCRunExec('clang', SdkLower) 202 | Ar = iOS_getXCRunExec('ar', SdkLower) 203 | Ranlib = iOS_getXCRunExec('ranlib', SdkLower) 204 | Strip = iOS_getXCRunExec('strip', SdkLower) 205 | 206 | # Generate unique alternate install dir for libs 207 | ArchLibDir = ARPathFromHere('Targets/%(target)s/Build/.install_%(lib)s_%(arch)s_%(debug)s' % locals()) 208 | # Add extra configure flags 209 | ExtraCommonFlags = [ "-arch %(arch)s" % locals(), 210 | "-isysroot %(Sysroot)s" % locals() ] 211 | ExtraCommonClangFlags = [ "-std=gnu99" ] 212 | ExtraCommonNonLlvmFlags = [ "-m%(minos)s-version-min=%(SdkVersion)s" % locals() ] 213 | ExtraCFlags = [] 214 | ExtraCClangFlags = [ "-x c" ] 215 | ExtraASFlags = [] 216 | ExtraASClangFlags = [ "-x assembler-with-cpp" ] 217 | ExtraOBJCFlags = [] 218 | ExtraOBJCClangFlags = [ "-x objective-c", 219 | "-fobjc-arc" ] 220 | 221 | CFLAGSString = 'CFLAGS="' 222 | OBJCFLAGSString = 'OBJCFLAGS="' 223 | CPPFLAGSString = 'CPPFLAGS="' 224 | ASFLAGSString = 'CCASFLAGS="' 225 | 226 | if not lib.ext: 227 | for flag in ExtraCClangFlags: 228 | CFLAGSString = '%(CFLAGSString)s %(flag)s' % locals() 229 | for flag in ExtraOBJCClangFlags: 230 | OBJCFLAGSString = '%(OBJCFLAGSString)s %(flag)s' % locals() 231 | for flag in ExtraASClangFlags: 232 | ASFLAGSString = '%(ASFLAGSString)s %(flag)s' % locals() 233 | for flag in ExtraCommonClangFlags: 234 | CFLAGSString = '%(CFLAGSString)s %(flag)s' % locals() 235 | OBJCFLAGSString = '%(OBJCFLAGSString)s %(flag)s' % locals() 236 | CPPFLAGSString = '%(CPPFLAGSString)s %(flag)s' % locals() 237 | ASFLAGSString = '%(ASFLAGSString)s %(flag)s' % locals() 238 | 239 | for flag in ExtraCommonNonLlvmFlags: 240 | CFLAGSString = '%(CFLAGSString)s %(flag)s' % locals() 241 | OBJCFLAGSString = '%(OBJCFLAGSString)s %(flag)s' % locals() 242 | CPPFLAGSString = '%(CPPFLAGSString)s %(flag)s' % locals() 243 | ASFLAGSString = '%(ASFLAGSString)s %(flag)s' % locals() 244 | for flag in ExtraCFlags: 245 | CFLAGSString = '%(CFLAGSString)s %(flag)s' % locals() 246 | for flag in ExtraOBJCFlags: 247 | OBJCFLAGSString = '%(OBJCFLAGSString)s %(flag)s' % locals() 248 | for flag in ExtraASFlags: 249 | ASFLAGSString = '%(ASFLAGSString)s %(flag)s' % locals() 250 | for flag in ExtraCommonFlags: 251 | CFLAGSString = '%(CFLAGSString)s %(flag)s' % locals() 252 | OBJCFLAGSString = '%(OBJCFLAGSString)s %(flag)s' % locals() 253 | CPPFLAGSString = '%(CPPFLAGSString)s %(flag)s' % locals() 254 | ASFLAGSString = '%(ASFLAGSString)s %(flag)s' % locals() 255 | CFLAGSString = CFLAGSString + '"' 256 | OBJCFLAGSString = OBJCFLAGSString + '"' 257 | CPPFLAGSString = CPPFLAGSString + '"' 258 | ASFLAGSString = ASFLAGSString + '"' 259 | ExtraConfFlags = ['--host=arm-apple', 260 | '--disable-shared', 261 | '--libdir=%(ArchLibDir)s' % locals(), 262 | 'CC=%(Compiler)s' % locals(), 263 | 'OBJC=%(Compiler)s' % locals(), 264 | 'CCAS=%(Compiler)s' % locals(), 265 | 'AR=%(Ar)s' % locals(), 266 | 'RANLIB=%(Ranlib)s' % locals(), 267 | CFLAGSString, 268 | OBJCFLAGSString, 269 | CPPFLAGSString, 270 | ASFLAGSString] 271 | 272 | block_MakePostProcess = iOS_MakePostProcessCb(lib, BuiltLibs, sslLibs, cryptoLibs, Strip, ArchLibDir) 273 | 274 | if isMp: 275 | poolRes = pool.apply_async(Common_BuildConfigureLibrary, 276 | args=(target, lib,), 277 | kwds={'extraArgs':ExtraConfFlags, 278 | 'clean':clean, 279 | 'debug':debug, 280 | 'confdirSuffix':arch, 281 | 'noSharedObjects':True, 282 | 'inhouse':inhouse, 283 | 'bootstrapLock':bLock, 284 | 'configureLock':cLock, 285 | 'makeLock':mLock, 286 | 'isMp':isMp,}, 287 | callback=block_MakePostProcess) 288 | poolResults.append(poolRes) 289 | else: 290 | retStatus = Common_BuildConfigureLibrary(target, lib, extraArgs=ExtraConfFlags, clean=clean, debug=debug, confdirSuffix=arch, noSharedObjects=True, inhouse=inhouse, bootstrapLock=bLock, configureLock=cLock, makeLock=mLock, isMp=False) 291 | block_MakePostProcess((retStatus, lib)) 292 | 293 | if isMp: 294 | for p in poolResults: 295 | (p_res, p_updatedlib) = p.get() 296 | if not p_res: 297 | retStatus = False 298 | 299 | # Remove any added export 300 | if forcedMalloc: 301 | ARUnsetEnv('ac_cv_func_malloc_0_nonnull') 302 | if forcedRealloc: 303 | ARUnsetEnv('ac_cv_func_realloc_0_nonnull') 304 | if not retStatus: 305 | return EndDumpArgs(res=False, **args) 306 | 307 | res = True 308 | if not clean: 309 | # Make fat library 310 | OutputDir = '%(InstallDir)s/lib/' % locals() 311 | 312 | libPrefix = 'lib' if not lib.ext else '' 313 | 314 | if (lib.name == 'libressl'): 315 | lipoSsl = '%(OutputDir)s/libssl.a' % locals() 316 | cryptoSsl = '%(OutputDir)s/libcrypto.a' % locals() 317 | ARExecute('lipo ' + ARListAsBashArg(sslLibs) + ' -create -output ' + lipoSsl) 318 | ARExecute('lipo ' + ARListAsBashArg(cryptoLibs) + ' -create -output ' + cryptoSsl) 319 | 320 | OutputLibrary = '%(OutputDir)s/%(libPrefix)s%(lib)s.a' % locals() 321 | if debug: 322 | OutputLibrary = '%(OutputDir)s/%(libPrefix)s%(lib)s_dbg.a' % locals() 323 | if not os.path.exists(OutputDir): 324 | os.makedirs(OutputDir) 325 | res = ARExecute('lipo ' + ARListAsBashArg(BuiltLibs) + ' -create -output ' + OutputLibrary) 326 | # Create framework 327 | FinalFramework = Framework 328 | if debug: 329 | FinalFramework = FrameworkDbg 330 | suffix = '_dbg' if debug else '' 331 | FrameworkLib = '%(FinalFramework)s/%(libPrefix)s%(lib)s%(suffix)s' % locals() 332 | FrameworkHeaders = '%(FinalFramework)s/Headers/' % locals() 333 | ARDeleteIfExists(FinalFramework) 334 | os.makedirs(FinalFramework) 335 | libIncDirPrefix = 'lib' if not lib.ext else '' 336 | if (lib.name == 'libressl'): 337 | shutil.copytree('%(InstallDir)s/include/openssl' % locals(), FrameworkHeaders) 338 | else: 339 | shutil.copytree('%(InstallDir)s/include/%(libIncDirPrefix)s%(lib)s' % locals(), FrameworkHeaders) 340 | shutil.copyfile(OutputLibrary, FrameworkLib) 341 | 342 | elif iOS_HasXcodeProject(lib): 343 | res = Darwin_RunXcodeBuild(target, lib, iOS_GetXcodeProject(lib), ValidArchs, debug, clean) 344 | 345 | else: 346 | ARLog('The library lib%(lib)s does not contains either an autotools or an Xcode project' % locals()) 347 | res = False 348 | 349 | if res: 350 | target.addBuiltLibrary(lib) 351 | 352 | return EndDumpArgs(res, **args) 353 | -------------------------------------------------------------------------------- /Utils/Python/iOS_GenLibraryDoc.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Copyright (C) 2014 Parrot SA 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in 11 | the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Parrot nor the names 14 | of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written 16 | permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 28 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | SUCH DAMAGE. 30 | ''' 31 | from ARFuncs import * 32 | from Common_GenAutotoolsLibraryDoc import * 33 | 34 | def iOS_GenLibraryDoc(target, lib, clean=False): 35 | args = dict(locals()) 36 | StartDumpArgs(**args) 37 | 38 | onlyC = True 39 | 40 | subdirs = ['iOS', 'Darwin'] 41 | 42 | for subdir in subdirs: 43 | if os.path.exists(lib.path + '/' + subdir): 44 | onlyC = False 45 | break 46 | 47 | res = Common_GenAutotoolsLibraryDoc(target, lib, clean, subdirsToInclude=subdirs, onlyC=onlyC) 48 | 49 | return EndDumpArgs(res, **args) 50 | 51 | -------------------------------------------------------------------------------- /Utils/Python/iOS_HandlePrebuiltDep.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Copyright (C) 2014 Parrot SA 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in 11 | the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Parrot nor the names 14 | of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written 16 | permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 28 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | SUCH DAMAGE. 30 | ''' 31 | import os 32 | import shutil 33 | import re 34 | from Common_HandlePrebuiltDep import * 35 | from ARFuncs import * 36 | 37 | 38 | def iOS_HandlePrebuiltDep(target, pb, forcedOutputDir=None, outputSuffixes=None, clean=False, debug=False): 39 | args = dict(locals()) 40 | StartDumpArgs(**args) 41 | 42 | Common_HandlePrebuiltDep(target, pb, forcedOutputDir=forcedOutputDir, outputSuffixes=outputSuffixes) 43 | 44 | res = True 45 | 46 | if not pb.isAvailableForTarget(target): 47 | ARLog('Prebuilt library %(pb)s does not exists for target %(target)s' % locals()) 48 | else: 49 | Type = pb.type 50 | if Type == 'header_only': 51 | if not clean: 52 | # Make fat library 53 | lib = pb 54 | InstallDir = ARPathFromHere('Targets/%(target)s/Install/' % locals()) 55 | FrameworksDir = '%(InstallDir)s/Frameworks/' % locals() 56 | Framework = '%(FrameworksDir)s/%(lib)s.framework' % locals() 57 | FrameworkDbg = '%(FrameworksDir)s/%(lib)s_dbg.framework' % locals() 58 | OutputDir = '%(InstallDir)s/lib/' % locals() 59 | 60 | if not os.path.exists(OutputDir): 61 | os.makedirs(OutputDir) 62 | # Create framework 63 | FinalFramework = Framework 64 | if debug: 65 | FinalFramework = FrameworkDbg 66 | suffix = '_dbg' if debug else '' 67 | FrameworkLib = '%(FinalFramework)s/%(lib)s%(suffix)s' % locals() 68 | FrameworkHeaders = '%(FinalFramework)s/Headers/' % locals() 69 | ARDeleteIfExists(FinalFramework) 70 | os.makedirs(FinalFramework) 71 | shutil.copytree('%(InstallDir)s/include/%(lib)s' % locals(), FrameworkHeaders) 72 | elif Type == 'framework': 73 | lib = pb 74 | InstallDir = ARPathFromHere('Targets/%(target)s/Install/' % locals()) 75 | FrameworksDir = '%(InstallDir)s/Frameworks/' % locals() 76 | Framework = '%(FrameworksDir)s/%(lib)s.framework' % locals() 77 | FrameworkDbg = '%(FrameworksDir)s/%(lib)s_dbg.framework' % locals() 78 | if not os.path.exists(FrameworksDir): 79 | os.makedirs(FrameworksDir) 80 | # Copy framework 81 | FinalFramework = Framework if not debug else FrameworkDbg 82 | suffix = '_dbg' if debug else '' 83 | prefix = 'lib' if not lib.name.startswith('lib') else '' 84 | ARLog(str(locals())) 85 | ARCopyAndReplace(pb.path,FinalFramework, deletePrevious=True) 86 | else: 87 | ARLog('Do not know how to handle prebuilts of type %(Type)s in iOS' % locals()) 88 | res = False 89 | 90 | return EndDumpArgs(res, **args) 91 | -------------------------------------------------------------------------------- /Utils/cleanupSDKRepo.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | : <<'END' 3 | Copyright (C) 2014 Parrot SA 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 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Parrot nor the names 15 | of its contributors may be used to endorse or promote products 16 | derived from this software without specific prior written 17 | permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 22 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 26 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 27 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | SUCH DAMAGE. 31 | END 32 | 33 | # 34 | # This script is not designed to be directly called ! 35 | # 36 | 37 | RETCODE=0 38 | 39 | function ARHello 40 | { 41 | echo "Start cleanup for repos $ALL_REPOS" | tee -a $ARLOGF 42 | } 43 | 44 | function ARQuit 45 | { 46 | if [ $RETCODE -eq 0 ]; then 47 | echo "Finished cleanup for repos $ALL_REPOS" | tee -a $ARLOGF 48 | 49 | else 50 | echo "Error during cleanup for repos $ALL_REPOS" | tee -a $ARLOGF 51 | fi 52 | exit $RETCODE 53 | } 54 | 55 | ALL_REPOS=$* 56 | 57 | ARHello 58 | 59 | if [ -z $2 ]; then 60 | echo "Must specify at least one directory !" | tee -a $ARLOGF 61 | RETCODE=1 62 | ARQuit 63 | fi 64 | 65 | for repo in $ALL_REPOS; do 66 | if [ ! -d $repo ]; then 67 | echo "$repo is not a directory !" | tee -a $ARLOGF 68 | RETCODE=1 69 | ARQuit 70 | fi 71 | cleanupFiles=$(find $repo -name 'cleanup') 72 | for cfile in $cleanupFiles; do 73 | cdir=$(dirname $cfile) 74 | here=$(pwd) 75 | cd $cdir 76 | echo "Running cleanup in $cdir" 77 | ./cleanup 78 | cd $here 79 | done 80 | done 81 | -------------------------------------------------------------------------------- /Utils/copyDoc.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | : <<'END' 3 | Copyright (C) 2014 Parrot SA 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 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Parrot nor the names 15 | of its contributors may be used to endorse or promote products 16 | derived from this software without specific prior written 17 | permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 22 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 26 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 27 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | SUCH DAMAGE. 31 | END 32 | 33 | RETCODE=0 34 | 35 | function ARHello 36 | { 37 | echo "Start copying documentation for target $TARGET, from directory $DOCDIR, to directory $OUTPUT" | tee -a $ARLOGF 38 | } 39 | 40 | function ARQuit 41 | { 42 | if [ $RETCODE -eq 0 ]; then 43 | echo "Finished copying documentation for target $TARGET, from directory $DOCDIR, to directory $OUTPUT" | tee -a $ARLOGF 44 | else 45 | echo "Error while copying documentation for target $TARGET, from directory $DOCDIR, to directory $OUTPUT" | tee -a $ARLOGF 46 | fi 47 | exit $RETCODE 48 | } 49 | 50 | # Help function 51 | function usage 52 | { 53 | echo "Usage:" 54 | echo $0 "TARGET" 55 | echo " - TARGET is the name of the target used to generate the documentation" 56 | exit 1 57 | } 58 | 59 | # Generic directories 60 | HERE=$(pwd) 61 | ME=$(which $0) 62 | MYDIR=$(echo $ME | sed 's:\(.*\)/.*:\1:') 63 | 64 | # Check for missing args 65 | if [ -z $1 ]; then 66 | echo "Missing args to copy documentation" | tee -a $ARLOGF 67 | usage 68 | fi 69 | 70 | # Assign args to better names 71 | TARGET=$1 72 | DOCDIR=$MYDIR/../Targets/$TARGET/Build/Doc/ 73 | 74 | # Output directory 75 | ROOT_OUTPUT=$MYDIR/../../Docs/SDK/ 76 | OUTPUT=$ROOT_OUTPUT/$TARGET 77 | 78 | ARHello 79 | 80 | # 1> Check if the new doc is here 81 | if [ ! -d $DOCDIR ]; then 82 | echo "$DOCDIR does not exist" | tee -a $ARLOGF 83 | echo "No documentation to copy for target $TARGET" | tee -a $ARLOGF 84 | ARQuit 85 | fi 86 | 87 | # 2> Remove old doc 88 | rm -rf $OUTPUT 89 | 90 | # 3> Copy new doc 91 | mkdir -p $ROOT_OUTPUT 92 | cp -r $DOCDIR $OUTPUT 93 | 94 | # 4> Remove tag files 95 | find $OUTPUT -name '*.tag' -delete 96 | 97 | # 5> Generate root index.html 98 | ROOT_INDEX=$MYDIR/../../Docs/SDK/index.html 99 | 100 | echo "" > $ROOT_INDEX 101 | echo "" >> $ROOT_INDEX 102 | echo "" >> $ROOT_INDEX 122 | echo "" >> $ROOT_INDEX 123 | echo "" >> $ROOT_INDEX 124 | echo "

" >> $ROOT_INDEX 125 | echo "" >> $ROOT_INDEX 126 | echo "
" >> $ROOT_INDEX 127 | echo "ARSDK 3.0 Documentation" >> $ROOT_INDEX 128 | echo "
" >> $ROOT_INDEX 129 | echo "" >> $ROOT_INDEX 130 | echo "
" >> $ROOT_INDEX 131 | echo "Click on a platform below to open its documentation" >> $ROOT_INDEX 132 | echo "
" >> $ROOT_INDEX 133 | echo "" >> $ROOT_INDEX 134 | 135 | cd $ROOT_OUTPUT 136 | ALL_TARGETS=$(ls -d -- */ | sed 's:/::') 137 | cd $HERE 138 | for TAR in $ALL_TARGETS; do 139 | echo "
" >> $ROOT_INDEX 140 | echo "" >> $ROOT_INDEX 141 | echo "$TAR" >> $ROOT_INDEX 142 | echo "" >> $ROOT_INDEX 143 | echo "
" >> $ROOT_INDEX 144 | done 145 | 146 | echo "
" >> $ROOT_INDEX 147 | echo "Documentation may be similar across different platforms" >> $ROOT_INDEX 148 | echo "
" >> $ROOT_INDEX 149 | 150 | echo "" >> $ROOT_INDEX 151 | echo "" >> $ROOT_INDEX 152 | echo "" >> $ROOT_INDEX 153 | 154 | ARQuit -------------------------------------------------------------------------------- /Utils/generateDocIndex.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | : <<'END' 3 | Copyright (C) 2014 Parrot SA 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 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Parrot nor the names 15 | of its contributors may be used to endorse or promote products 16 | derived from this software without specific prior written 17 | permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 22 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 26 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 27 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | SUCH DAMAGE. 31 | END 32 | 33 | RETCODE=0 34 | 35 | function ARHello 36 | { 37 | echo "Start generating $OUTPUT_FILE for target $TARGET" | tee -a $ARLOGF 38 | } 39 | 40 | function ARQuit 41 | { 42 | if [ $RETCODE -eq 0 ]; then 43 | echo "Finished generating $OUTPUT_FILE for target $TARGET" | tee -a $ARLOGF 44 | else 45 | echo "Error while generating $OUTPUT_FILE for target $TARGET" | tee -a $ARLOGF 46 | fi 47 | exit $RETCODE 48 | } 49 | 50 | # Help function 51 | function usage 52 | { 53 | echo "Usage:" 54 | echo $0 "DOCDIR TARGET" 55 | echo " - DOCDIR is the root directory of the library documentations" 56 | echo " - TARGET is the name of the target for which the doc was generated" 57 | exit 1 58 | } 59 | 60 | # Generic directories 61 | HERE=$(pwd) 62 | ME=$(which $0) 63 | MYDIR=$(echo $ME | sed 's:\(.*\)/.*:\1:') 64 | 65 | # Check for missing args 66 | if [ -z $1 ] || [ -z $2 ]; then 67 | echo "Missing args to generate doc index" | tee -a $ARLOGF 68 | usage 69 | fi 70 | 71 | # Assign args to better names 72 | DOCDIR=$1 73 | TARGET=$2 74 | 75 | # Create index.html 76 | OUTPUT_FILE=$DOCDIR/index.html 77 | 78 | # Test file for Javadoc dirs 79 | JAVADOC_TEST_FILE=$DOCDIR/index-all.html 80 | 81 | ARHello 82 | 83 | if [ -f $JAVADOC_TEST_FILE ]; then 84 | echo "Operating on a javadoc directory : do not modify index.html" | tee -a $ARLOGF 85 | ARQuit 86 | fi 87 | 88 | echo "" > $OUTPUT_FILE 89 | echo "" >> $OUTPUT_FILE 90 | echo "" >> $OUTPUT_FILE 110 | echo "" >> $OUTPUT_FILE 111 | echo "" >> $OUTPUT_FILE 112 | echo "

" >> $OUTPUT_FILE 113 | echo "" >> $OUTPUT_FILE 114 | echo "
" >> $OUTPUT_FILE 115 | echo "ARSDK 3.0 Documentation for $TARGET" >> $OUTPUT_FILE 116 | echo "
" >> $OUTPUT_FILE 117 | echo "" >> $OUTPUT_FILE 118 | echo "
" >> $OUTPUT_FILE 119 | echo "Click on a library below to open its documentation" >> $OUTPUT_FILE 120 | echo "
" >> $OUTPUT_FILE 121 | echo "" >> $OUTPUT_FILE 122 | 123 | cd $DOCDIR 124 | LIBRARIES=$(ls -d -- */ | sed 's:/::') 125 | cd $HERE 126 | for LIB in $LIBRARIES; do 127 | LINK=./$LIB/index.html 128 | if [ ! -f $DOCDIR/$LINK ]; then 129 | LINK=./$LIB/html/index.html 130 | fi 131 | if [ -f $DOCDIR/$LINK ]; then 132 | echo "
" >> $OUTPUT_FILE 133 | echo "" >> $OUTPUT_FILE 134 | echo "$LIB" >> $OUTPUT_FILE 135 | echo "" >> $OUTPUT_FILE 136 | echo "
" >> $OUTPUT_FILE 137 | fi 138 | done 139 | 140 | echo "" >> $OUTPUT_FILE 141 | echo "" >> $OUTPUT_FILE 142 | echo "" >> $OUTPUT_FILE 143 | 144 | echo "Generated $OUTPUT_FILE for target $TARGET" | tee -a $ARLOGF 145 | 146 | ARQuit 147 | -------------------------------------------------------------------------------- /Utils/m4/ARSDK.m4: -------------------------------------------------------------------------------- 1 | # AR_DEPENDS([libNAME], [REQUIRED], [HEADERS], [HAS_DEBUG], [HEADER_ONLY]) 2 | # Y or N list of headers to check Y or N, assumed to be Y if not passed Y or N, assumed to be N if not passed 3 | AC_DEFUN([AR_DEPENDS], [ 4 | # Add with args 5 | # - Install dir 6 | AC_ARG_WITH([$1InstallDir], 7 | AS_HELP_STRING([--with-$1InstallDir=DIR],[directory of the $1 installation @<:@default=PREFIX@:>@]), 8 | [if test x$withval = xno; then 9 | $1InstallDir="" 10 | else 11 | $1InstallDir="$withval" 12 | fi], 13 | [if test x$prefix = xNONE; then 14 | $1InstallDir="" 15 | else 16 | $1InstallDir="$prefix" 17 | fi]) 18 | # - Include dir 19 | AC_ARG_WITH([$1IncludeDir], 20 | AS_HELP_STRING([--with-$1IncludeDir=DIR],[directory of the $1 headers @<:@default=$1InstallDir/include@:>@]), 21 | [if test x$withval = xno; then 22 | $1IncludeDir="" 23 | else 24 | $1IncludeDir="$withval" 25 | fi], 26 | [if test ! -z $$1InstallDir; then 27 | $1IncludeDir="$$1InstallDir/include" 28 | else 29 | $1IncludeDir="" 30 | fi]) 31 | # - Lib dir 32 | AC_ARG_WITH([$1LibDir], 33 | AS_HELP_STRING([--with-$1LibDir=DIR],[directory of the $1 libraries @<:@default=$1InstallDir/lib@:>@]), 34 | [if test x$withval = xno; then 35 | $1LibDir="" 36 | else 37 | $1LibDir="$withval" 38 | fi], 39 | [if test ! -z $$1InstallDir; then 40 | $1LibDir="$$1InstallDir/lib" 41 | else 42 | $1LibDir="" 43 | fi]) 44 | # Add include dir to -I path 45 | if test ! -z $$1IncludeDir; then 46 | CFLAGS+=" -I$$1IncludeDir" 47 | CPPFLAGS+=" -I$$1IncludeDir" 48 | OBJCFLAGS+=" -I$$1IncludeDir" 49 | fi 50 | if test x$5 != xY; then 51 | # Add lib dir to -L path 52 | if test ! -z $$1LibDir; then 53 | LDFLAGS+=" -L$$1LibDir" 54 | fi 55 | fi 56 | # Check given headers 57 | ar_$1_support="no" 58 | if test x$2 = xY; then 59 | AC_CHECK_HEADERS([$3],ar_$1_support="yes",AC_MSG_ERROR(The $1 headers are required in order to build the library! 60 | - Use --with-$1InstallDir or --with-$1IncludeDir to incidate a specific include path.)) 61 | else 62 | AC_CHECK_HEADERS([$3],ar_$1_support="yes",AC_MSG_WARN(The $1 headers were not found: compiling without $1 support.)) 63 | fi 64 | # Define HAVE name 65 | define([AR_HAVE_NAME], [HAVE_]translit($1, "a-z", "A-Z")) 66 | # Define AM variable HAVE_Name for Makefile.am tests 67 | AM_CONDITIONAL(AR_HAVE_NAME, [test x$ar_$1_support = xyes]) 68 | # Define AC preprocessor variable HAVE_Name for Source tests 69 | if test x$ar_$1_support = xyes; then 70 | AC_DEFINE_UNQUOTED(AR_HAVE_NAME, [1], [$1 presence]) 71 | fi 72 | # Add -l directives 73 | if test x$5 != xY; then 74 | if test x$ar_$1_support = xyes; then 75 | LNAME=$(echo $1 | sed 's:^lib::' | tr @<:@:upper:@:>@ @<:@:lower:@:>@) 76 | if test x$debugit = xyes && test x$4 != xN; then 77 | LNAME+="_dbg" 78 | fi 79 | LDFLAGS+=" -l$LNAME" 80 | fi 81 | fi 82 | ]) -------------------------------------------------------------------------------- /Utils/updateGitStatus.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | : <<'END' 3 | Copyright (C) 2014 Parrot SA 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 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Parrot nor the names 15 | of its contributors may be used to endorse or promote products 16 | derived from this software without specific prior written 17 | permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 22 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 26 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 27 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | SUCH DAMAGE. 31 | END 32 | 33 | RETCODE=0 34 | EXIT_ON_FAILED='' 35 | REPO_REVISION='' 36 | 37 | function ARHello 38 | { 39 | echo "Start updating status for repo $REPODIR" | tee -a $ARLOGF 40 | } 41 | 42 | function ARQuit 43 | { 44 | if [ $RETCODE -eq 0 ]; then 45 | echo "Finished updating status for repo $REPODIR" | tee -a $ARLOGF 46 | elif [[ $EXIT_ON_FAILED = "exitOnFailed" ]]; then 47 | echo "===============================================================================================" 48 | echo "Error while updating for repo $REPODIR, is not sync to remote ($REPO_REVISION)" | tee -a $ARLOGF 49 | echo "===============================================================================================" 50 | echo "$RETCODE" 51 | exit $RETCODE 52 | else 53 | echo "Do you want to skip $REPODIR ?" 54 | select yn in "Yes" "No" "Retry" "Stash/Stash-Pop" "Show-Diff" "Reset"; do 55 | case $yn in 56 | Yes ) 57 | echo "Skipping $REPODIR" | tee -a $ARLOGF 58 | RETCODE=0 59 | break 60 | ;; 61 | Retry ) 62 | echo "Trying again" | tee -a $ARLOGF 63 | $ME $REPODIR $REPO_URL $REPO_REVISION $EXIT_ON_FAILED 64 | RETCODE=$? 65 | break 66 | ;; 67 | Stash/Stash-Pop ) 68 | echo "Stashing your changes" | tee -a $ARLOGF 69 | if ! git stash; then 70 | echo "Error while stashing !" | tee -a $ARLOGF 71 | RETCODE=1 72 | break 73 | fi 74 | $ME $REPODIR $REPO_URL $REPO_REVISION $EXIT_ON_FAILED 75 | RETCODE=$? 76 | if [ $RETCODE -ne 0 ]; then 77 | break 78 | fi 79 | if ! git stash pop; then 80 | echo "Stash pop failed ... Go fix it manually !" | tee -a $ARLOGF 81 | RETCODE=1 82 | fi 83 | break 84 | ;; 85 | Show-Diff ) 86 | echo "Showing diff in the repo" | tee -a $ARLOGF 87 | if ! git diff; then 88 | echo "Error while showing diff !" | tee -a $ARLOGF 89 | RETCODE=1 90 | break 91 | fi 92 | $ME $REPODIR $REPO_URL $REPO_REVISION $EXIT_ON_FAILED 93 | RETCODE=$? 94 | break 95 | ;; 96 | Reset ) 97 | RETCODE=0 98 | echo "Are you sure you want to reset $REPODIR ???" | tee -a $ARLOGF 99 | select ryn in "Yes" "No"; do 100 | case $ryn in 101 | Yes ) 102 | if ! git reset --hard; then 103 | echo "Error while resetting !" | tee -a $ARLOGF 104 | RETCODE=1 105 | fi 106 | break 107 | ;; 108 | esac 109 | done 110 | if [ $RETCODE -eq 0 ]; then 111 | $ME $REPODIR $REPO_URL $REPO_REVISION $EXIT_ON_FAILED 112 | RETCODE=$? 113 | fi 114 | break 115 | ;; 116 | 117 | esac 118 | echo "Error while updating status for repo $REPODIR" | tee -a $ARLOGF 119 | break 120 | done 121 | fi 122 | exit $RETCODE 123 | } 124 | 125 | function usage 126 | { 127 | echo "Usage:" 128 | echo $0 "REPODIR REMOTE_URL REPO_REVISION" 129 | echo " - REPODIR is the path to the repository root directory" 130 | echo " - REMOTE_URL is the requested remote URL" 131 | echo " - REPO_REVISION is the revision to checkout." 132 | echo " It can be a branch name, a tag name, a commit sha1" 133 | echo " or 'DEV' (i.e. don't touch the repo)" 134 | echo " or 'CURR_BRANCH' (i.e. just check and pull, do not checkout anything)" 135 | echo " If it's a branch name, the branch will be pulled" 136 | echo " - EXIT_ON_FAILED (optionnal). Put 'exitOnFailed' to force" 137 | echo " the script to stop on any error, without prompt" 138 | exit 1 139 | } 140 | 141 | HERE=$(pwd) 142 | ME=$(which $0) 143 | MYDIR=$(echo $ME | sed 's:\(.*\)/.*:\1:') 144 | 145 | # Test if the parameters are correct 146 | if [ -z $1 ] || [ -z $2 ] || [ -z $3 ]; then 147 | echo "Missing args to check git repository status" | tee -a $ARLOGF 148 | usage 149 | fi 150 | 151 | REPODIR=$1 152 | REPO_URL=$2 153 | REPO_REVISION=$3 154 | if [ -n $4 ]; then 155 | EXIT_ON_FAILED=$4 156 | echo "==$EXIT_ON_FAILED ==" 157 | fi 158 | 159 | ARHello 160 | 161 | if [ ! -d $REPODIR ]; then 162 | echo "Repository $REPODIR does not exists" | tee -a $ARLOGF 163 | RETCODE=1 164 | ARQuit 165 | fi 166 | 167 | NEEDS_CHECKOUT="YES" 168 | NEEDS_PULL="YES" 169 | 170 | if [ x$REPO_REVISION = xDEV ]; then 171 | echo "Don't touch repo $REPODIR (revision = DEV)" | tee -a $ARLOGF 172 | ARQuit 173 | elif [ x$REPO_REVISION = xCURR_BRANCH ]; then 174 | echo "Using current branch/tag as target reivision" | tee -a $ARLOGF 175 | NEEDS_CHECKOUT="NO" 176 | fi 177 | 178 | cd $REPODIR 179 | 180 | NEED_ADD_REMOTE=NO 181 | SKIP_REMOTE_TEST=NO 182 | NEED_SET_REMOTE=NO 183 | 184 | if ! git remote -v 2>&1 | grep origin >/dev/null 2>&1; then 185 | echo "Missing remote origin" 186 | echo "Do you want to add origin remote ($REPO_URL) ?" 187 | select yn in "Yes" "No"; do 188 | case $yn in 189 | Yes ) 190 | NEED_ADD_REMOTE=YES 191 | break 192 | ;; 193 | No ) 194 | SKIP_REMOTE_TEST=YES 195 | break 196 | ;; 197 | esac 198 | done 199 | fi 200 | 201 | if [ x$NEED_ADD_REMOTE = xYES ]; then 202 | if ! git remote add origin $REPO_URL 2>&1 >/dev/null; then 203 | echo "Error while adding remote origin" 204 | RETCODE=1 205 | ARQuit 206 | fi 207 | fi 208 | 209 | if [ x$SKIP_REMOTE_TEST = xNO ]; then 210 | CURRENT_REMOTE=$(git remote -v | grep origin | grep fetch | sed 's:[^[:blank:]]*[[:blank:]]*\([^[:blank:]]*\)[[:blank:]]*.*:\1:') 211 | 212 | if [ ! x"$CURRENT_REMOTE" = x"$REPO_URL" ]; then 213 | echo "Origin does not point to $REPO_URL, but instead to $CURRENT_REMOTE" 214 | echo "Do you want to change it to $REPO_URL ?" 215 | select yn in "Yes" "No"; do 216 | case $yn in 217 | Yes ) 218 | NEED_SET_REMOTE=YES 219 | break 220 | ;; 221 | No ) 222 | break 223 | ;; 224 | esac 225 | done 226 | fi 227 | 228 | if [ x$NEED_SET_REMOTE = xYES ]; then 229 | if ! git remote set-url origin $REPO_URL 2>&1 >/dev/null; then 230 | echo "Error while setting origin URL to $REPO_URL" 231 | RETCODE=1 232 | ARQuit 233 | fi 234 | fi 235 | fi 236 | 237 | if ! git status 2>&1 >/dev/null; then 238 | echo "Error while updating repo status" | tee -a $ARLOGF 239 | RETCODE=1 240 | ARQuit 241 | fi 242 | 243 | if ! git diff-files --quiet; then 244 | echo "The repo $REPODIR has local changes" | tee -a $ARLOGF 245 | RETCODE=1 246 | ARQuit 247 | fi 248 | 249 | if ! git diff-index --cached --quiet HEAD; then 250 | echo "The repo $REPODIR has local changes" | tee -a $ARLOGF 251 | RETCODE=1 252 | ARQuit 253 | fi 254 | 255 | if [ x$NEEDS_CHECKOUT = xYES ]; then 256 | CURR_SHA1=$(git rev-parse HEAD) 257 | if [ $CURR_SHA1 = $REPO_REVISION ]; then 258 | echo "Already on good sha1" | tee -a $ARLOGF 259 | NEEDS_CHECKOUT="NO" 260 | NEEDS_PULL="NO" 261 | else 262 | TAGS_HERE=$(git tag --points-at HEAD) 263 | for TAG in $TAGS_HERE; do 264 | if [ "$TAG" = "$REPO_REVISION" ]; then 265 | echo "Already on good tag (or at least on the sha1 pointed by the tag)" | tee -a $ARLOGF 266 | NEEDS_CHECKOUT="NO" 267 | NEEDS_PULL="NO" 268 | fi 269 | done 270 | fi 271 | fi 272 | 273 | if [ x$NEEDS_CHECKOUT = xYES ]; then 274 | if ! git fetch; then 275 | echo "Unable to fetch $REPODIR" | tee -a $ARLOGF 276 | RETCODE=1 277 | ARQuit 278 | fi 279 | if ! git fetch --tags; then 280 | echo "Unable to fetch --tags $REPODIR" | tee -a $ARLOGF 281 | RETCODE=1 282 | ARQuit 283 | fi 284 | if ! git checkout $REPO_REVISION; then 285 | echo "Unable to checkout $REPO_REVISION for $REPODIR" | tee -a $ARLOGF 286 | echo " --> Working tree might have changed !" | tee -a $ARLOGF 287 | RETCODE=1 288 | ARQuit 289 | fi 290 | fi 291 | 292 | if [ x$NEEDS_PULL = xYES ]; then 293 | if git symbolic-ref -q HEAD; then 294 | REMOTE=$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null) 295 | if [ x$REMOTE != x'@{u}' ]; then 296 | # On a branch, with a tracking remote one 297 | CNT=$(git rev-list $REMOTE..HEAD -n 1 | wc -l) 298 | if [ $CNT -ne 0 ]; then 299 | echo "Local commits found on a remote tracking branch" | tee -a $ARLOGF 300 | echo " --> Don't pull because a merge conflict could happen" | tee -a $ARLOGF 301 | RETCODE=1 302 | ARQuit 303 | fi 304 | fi 305 | echo "On a branch, pulling" | tee -a $ARLOGF 306 | if ! git pull; then 307 | echo "Unable to pull the branch" | tee -a $ARLOGF 308 | RETCODE=1 309 | ARQuit 310 | fi 311 | fi 312 | fi 313 | 314 | cd $HERE 315 | ARQuit 316 | -------------------------------------------------------------------------------- /atom.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_CATEGORY_PATH := dragon/libs 6 | LOCAL_MODULE := ARSDKBuildUtils 7 | LOCAL_DESCRIPTION := ARSDK Build Utils 8 | 9 | LOCAL_COPY_TO_BUILD_DIR := 1 10 | 11 | include $(BUILD_CUSTOM) 12 | 13 | -------------------------------------------------------------------------------- /binaries.xml: -------------------------------------------------------------------------------- 1 | 31 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /libraries.xml: -------------------------------------------------------------------------------- 1 | 31 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | -------------------------------------------------------------------------------- /prebuilt.xml: -------------------------------------------------------------------------------- 1 | 31 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /repos.xml: -------------------------------------------------------------------------------- 1 | 31 | 67 | 68 | 69 | 70 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /targets.xml: -------------------------------------------------------------------------------- 1 | 31 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | --------------------------------------------------------------------------------