Rakefile 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. #
  2. # Copyright (c) 2008-2014 the Urho3D project.
  3. #
  4. # Permission is hereby granted, free of charge, to any person obtaining a copy
  5. # of this software and associated documentation files (the "Software"), to deal
  6. # in the Software without restriction, including without limitation the rights
  7. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. # copies of the Software, and to permit persons to whom the Software is
  9. # furnished to do so, subject to the following conditions:
  10. #
  11. # The above copyright notice and this permission notice shall be included in
  12. # all copies or substantial portions of the Software.
  13. #
  14. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. # THE SOFTWARE.
  21. #
  22. require 'pathname'
  23. if ENV['XCODE']
  24. require 'xcodeproj'
  25. end
  26. # Usage: rake sync (only intended to be used in a fork with remote 'upstream' set to urho3d/Urho3D)
  27. desc 'Fetch and merge upstream urho3d/Urho3D to a Urho3D fork'
  28. task :sync do
  29. system "cwb=`git symbolic-ref -q --short HEAD || git rev-parse --short HEAD`; export cwb && git fetch upstream && git checkout master && git pull && git merge -m 'Sync at #{Time.now.localtime}.' upstream/master && git push && git checkout $cwb"
  30. end
  31. # Usage: rake scaffolding dir=/path/to/new/project/root [project=your-project-name] [target=your-target-name]
  32. desc 'Create a new project using Urho3D as external library'
  33. task :scaffolding do
  34. abort 'Usage: rake scaffolding dir=/path/to/new/project/root [project=your-project-name] [target=your-target-name]' unless ENV['dir']
  35. abs_path = ENV['dir'][0, 1] == '/' ? ENV['dir'] : "#{Dir.pwd}/#{ENV['dir']}"
  36. project = ENV['project'] || 'Scaffolding'
  37. target = ENV['target'] || 'Main'
  38. scaffolding(abs_path, project, target)
  39. abs_path = Pathname.new(abs_path).realpath
  40. puts "\nNew project created in #{abs_path}\n\n"
  41. puts "To build the new project, you may need to first define and export either 'URHO3D_HOME' or 'CMAKE_PREFIX_PATH' environment variable"
  42. puts "Please see http://urho3d.github.io/documentation/_using_library.html for more detail. For example:\n\n"
  43. puts "$ URHO3D_HOME=#{Dir.pwd}; export URHO3D_HOME\n$ cd #{abs_path}\n$ ./cmake_gcc.sh -DURHO3D_64BIT=1 -DURHO3D_LUAJIT=1\n$ cd Build\n$ make\n\n"
  44. end
  45. # Usage: NOT intended to be used manually (if you insist then try: rake travis_ci)
  46. desc 'Configure, build, and test Urho3D project'
  47. task :travis_ci do
  48. if ENV['PACKAGE_UPLOAD']
  49. $configuration = 'Release'
  50. $testing = 0
  51. else
  52. $configuration = 'Debug'
  53. $testing = 1
  54. end
  55. if ENV['XCODE']
  56. # xctool or xcodebuild
  57. xcode_travis_ci
  58. else
  59. # GCC or Clang
  60. makefile_travis_ci
  61. end
  62. end
  63. # Usage: NOT intended to be used manually (if you insist then try: GIT_NAME=... GIT_EMAIL=... GH_TOKEN=... rake travis_ci_site_update)
  64. desc 'Update site documentation to GitHub Pages'
  65. task :travis_ci_site_update do
  66. # Pull or clone
  67. system 'cd doc-Build 2>/dev/null && git pull -q -r || git clone --depth=1 -q https://github.com/urho3d/urho3d.github.io.git doc-Build' or abort 'Failed to pull/clone'
  68. # Update credits from Readme.txt to about.md
  69. system "ruby -lne 'BEGIN { credits = false }; puts $_ if credits; credits = true if /bugfixes by:/; credits = false if /^$/' Readme.txt |ruby -i -le 'credits = STDIN.read; puts ARGF.read.gsub(/(?<=bugfixes by\n).*?(?=##)/m, credits)' doc-Build/about.md" or abort 'Failed to update credits'
  70. # Setup doxygen to use minimal theme
  71. system "ruby -i -pe 'BEGIN { a = {%q{HTML_HEADER} => %q{minimal-header.html}, %q{HTML_FOOTER} => %q{minimal-footer.html}, %q{HTML_STYLESHEET} => %q{minimal-doxygen.css}, %q{HTML_COLORSTYLE_HUE} => 200, %q{HTML_COLORSTYLE_SAT} => 0, %q{HTML_COLORSTYLE_GAMMA} => 20, %q{DOT_IMAGE_FORMAT} => %q{svg}, %q{INTERACTIVE_SVG} => %q{YES}} }; a.each {|k, v| gsub(/\#{k}\s*?=.*?\n/, %Q{\#{k} = \#{v}\n}) }' Docs/Doxyfile" or abort 'Failed to setup doxygen configuration file'
  72. system 'cp doc-Build/_includes/Doxygen/minimal-* Docs' or abort 'Failed to copy minimal-themed template'
  73. # Generate and sync doxygen pages
  74. system "cd Build && make -j$NUMJOBS doc >/dev/null 2>&1 && rsync -a --delete ../Docs/html/ ../doc-Build/documentation" or abort 'Failed to generate/rsync doxygen pages'
  75. # Supply GIT credentials and push site documentation to urho3d/urho3d.github.io.git
  76. system 'cd doc-Build && pwd && git config user.name $GIT_NAME && git config user.email $GIT_EMAIL && git remote set-url --push origin https://[email protected]/urho3d/urho3d.github.io.git && git add -A . && ( git commit -q -m "Travis CI: site documentation update at #{Time.now.utc}.\n\nCommit: https://github.com/$TRAVIS_REPO_SLUG/commit/$TRAVIS_COMMIT\n\nMessage: $COMMIT_MESSAGE" || true) && git push -q >/dev/null 2>&1' or abort 'Failed to update site'
  77. # Automatically give instruction to do packaging when API has changed, unless the instruction is already given in this commit
  78. if ENV['PACKAGE_UPLOAD']
  79. instruction = 'skip'
  80. else
  81. instruction = 'package'
  82. end
  83. # Supply GIT credentials and push API documentation to urho3d/Urho3D.git (the push may not be successful if detached HEAD is not a fast forward of remote master)
  84. system 'pwd && git config user.name $GIT_NAME && git config user.email $GIT_EMAIL && git remote set-url --push origin https://[email protected]/$TRAVIS_REPO_SLUG.git && git add Docs/*API*'
  85. if system("git commit -q -m 'Travis CI: API documentation update at #{Time.now.utc}.\n[ci #{instruction}]'") && !ENV['PACKAGE_UPLOAD']
  86. bump_soversion 'Source/Engine/.soversion' or abort 'Failed to bump soversion'
  87. system "git add Source/Engine/.soversion && git commit --amend -q -m 'Travis CI: API documentation update at #{Time.now.utc}.\n[ci #{instruction}]'" or 'Failed to stage .soversion file'
  88. end
  89. system "git push origin HEAD:master -q >/dev/null 2>&1" or abort 'Failed to update API documentation, most likely due to remote master has diverged, the API documentation update will be performed again in the subsequent CI build'
  90. end
  91. # Usage: NOT intended to be used manually (if you insist then try: GIT_NAME=... GIT_EMAIL=... GH_TOKEN=... rake travis_ci_rebase)
  92. desc 'Rebase OSX-CI mirror branch'
  93. task :travis_ci_rebase do
  94. system 'git config user.name $GIT_NAME && git config user.email $GIT_EMAIL && git remote set-url --push origin https://[email protected]/$TRAVIS_REPO_SLUG.git && git fetch origin OSX-CI:OSX-CI && git rebase origin/master OSX-CI && git push -qf -u origin OSX-CI >/dev/null 2>&1' or abort 'Failed to rebase OSX-CI mirror branch'
  95. end
  96. # Usage: NOT intended to be used manually (if you insist then try: rake travis_ci_package_upload)
  97. desc 'Make binary package and upload it to a designated central hosting server'
  98. task :travis_ci_package_upload do
  99. if ENV['XCODE']
  100. $configuration = 'Release'
  101. $testing = 0
  102. end
  103. if ENV['ANDROID']
  104. platform_prefix = 'android-'
  105. elsif ENV['WINDOWS']
  106. platform_prefix = 'mingw-'
  107. elsif ENV['IOS']
  108. platform_prefix = 'ios-'
  109. elsif ENV['RPI']
  110. platform_prefix = 'raspi-'
  111. else
  112. platform_prefix = ''
  113. end
  114. # Generate the documentation if necessary
  115. unless ENV['SITE_UPDATE']
  116. system 'echo Generate documentation'
  117. if ENV['XCODE']
  118. xcode_build(ENV['IOS'], "#{platform_prefix}Build/Urho3D.xcodeproj", 'doc', false, '>/dev/null') or abort 'Failed to generate documentation'
  119. else
  120. system "cd #{platform_prefix}Build && make -j$NUMJOBS doc >/dev/null" or abort 'Failed to generate documentation'
  121. end
  122. end
  123. # Make the package
  124. if ENV['IOS']
  125. unless ENV['URHO3D_64BIT'] # Skip Mach-O universal binary build for the time being as otherwise overall build time exceeds 50 minutes time limit
  126. # Build Mach-O universal binary consisting of iphoneos (universal ARM archs including 'arm64' if 64-bit is enabled) and iphonesimulator (i386 arch and also x86_64 arch if 64-bit is enabled)
  127. system 'echo Rebuild Urho3D library as Mach-O universal binary'
  128. xcode_build(0, "#{platform_prefix}Build/Urho3D.xcodeproj", 'Urho3D_universal', false) or abort 'Failed to build Mach-O universal binary'
  129. end
  130. # There is a bug in CMake/CPack that causes the 'package' scheme failed to build for IOS platform, workaround by calling cpack directly
  131. system "cd #{platform_prefix}Build && cpack -G TGZ 2>/dev/null" or abort 'Failed to make binary package'
  132. elsif ENV['XCODE']
  133. xcode_build(ENV['IOS'], "#{platform_prefix}Build/Urho3D.xcodeproj", 'package', false) or abort 'Failed to make binary package'
  134. else
  135. if ENV['ANDROID']
  136. # Build Android package consisting of both armeabi-v7a and armeabi ABIs
  137. system 'echo Reconfigure and rebuild Urho3D project using armeabi ABI'
  138. system "SKIP_NATIVE=1 ./cmake_gcc.sh -DANDROID_ABI=armeabi && cd #{platform_prefix}Build && make -j$NUMJOBS" or abort 'Failed to reconfigure and rebuild for armeabi'
  139. system "cd #{platform_prefix}Build && $ANDROID_SDK/tools/android update project -p . -t 1 && ant debug && bash -c 'mv bin/Urho3D{-debug,}.apk'" or abort 'Failed to make Android package (apk)'
  140. end
  141. system "cd #{platform_prefix}Build && make -j$NUMJOBS package" or abort 'Failed to make binary package'
  142. end
  143. # Determine the upload location
  144. setup_digital_keys
  145. if ENV['RELEASE_TAG'].empty?
  146. upload_dir = "/home/frs/project/#{ENV['TRAVIS_REPO_SLUG']}/Snapshots"
  147. if ENV['SITE_UPDATE']
  148. # Download source packages from GitHub
  149. system 'SNAPSHOP_VER=`git describe`; export SNAPSHOP_VER && wget -q https://github.com/$TRAVIS_REPO_SLUG/tarball/$TRAVIS_COMMIT -O Urho3D-$SNAPSHOP_VER-Source-snapshot.tar.gz && wget -q https://github.com/$TRAVIS_REPO_SLUG/zipball/$TRAVIS_COMMIT -O Urho3D-$SNAPSHOP_VER-Source-snapshot.zip' or abort 'Failed to get source packages'
  150. # Only keep the snapshots from the last +/- 50 revisions
  151. # The package revisions and their creation time may not always be in perfect chronological order due to Travis-CI build latency, so sort the final result one more time in order to get a unique revision removal list
  152. system "for v in $(sftp [email protected] <<EOF |tr ' ' '\n' |grep Urho3D- |cut -d '-' -f1,2 |uniq |tail -n +51 |sort |uniq
  153. cd #{upload_dir}
  154. ls -1t
  155. bye
  156. EOF
  157. ); do echo rm #{upload_dir}/${v}*; done |sftp -b - [email protected]" or abort 'Failed to housekeep snapshots'
  158. end
  159. else
  160. upload_dir = "/home/frs/project/#{ENV['TRAVIS_REPO_SLUG']}/#{ENV['RELEASE_TAG']}"
  161. if ENV['SITE_UPDATE']
  162. # Download source packages from GitHub
  163. system 'wget -q https://github.com/$TRAVIS_REPO_SLUG/archive/$RELEASE_TAG.tar.gz -O Urho3D-$RELEASE_TAG-Source.tar.gz && wget -q https://github.com/$TRAVIS_REPO_SLUG/archive/$RELEASE_TAG.zip -O Urho3D-$RELEASE_TAG-Source.zip' or abort 'Failed to get source packages'
  164. end
  165. # Make sure the release directory exists remotely, do this in all the build jobs as we don't know which one would start uploading first
  166. system "sftp [email protected] <<EOF >/dev/null 2>&1
  167. mkdir #{upload_dir}
  168. bye
  169. EOF" or abort 'Failed to create release directory remotely'
  170. end
  171. # Upload the package
  172. system "scp #{platform_prefix}Build/Urho3D-* [email protected]:#{upload_dir}" or abort 'Failed to upload binary package'
  173. if ENV['SITE_UPDATE']
  174. # Upload the source package
  175. system "scp Urho3D-* [email protected]:#{upload_dir}" or abort 'Failed to upload source package'
  176. # Sync readme and license files, just in case they are updated in the repo
  177. system 'for f in Readme.txt License.txt; do mtime=$(git log --format=%ai -n1 $f); touch -d "$mtime" $f; done' or abort 'Failed to acquire file modified time'
  178. system 'rsync -e ssh -az Readme.txt License.txt [email protected]:/home/frs/project/$TRAVIS_REPO_SLUG' or abort 'Failed to sync readme and license files'
  179. end
  180. end
  181. def scaffolding(dir, project = 'Scaffolding', target = 'Main')
  182. system "bash -c \"mkdir -p #{dir}/{Source,Bin} && cp Source/Tools/Urho3DPlayer/Urho3DPlayer.* #{dir}/Source && for f in {.,}*.sh; do ln -sf `pwd`/\\$f #{dir}; done && ln -sf `pwd`/Bin/{Core,}Data #{dir}/Bin\" && cat <<EOF >#{dir}/Source/CMakeLists.txt
  183. # Set project name
  184. project (#{project})
  185. # Set minimum version
  186. cmake_minimum_required (VERSION 2.8.6)
  187. if (COMMAND cmake_policy)
  188. cmake_policy (SET CMP0003 NEW)
  189. if (CMAKE_VERSION VERSION_GREATER 2.8.12 OR CMAKE_VERSION VERSION_EQUAL 2.8.12)
  190. cmake_policy (SET CMP0022 NEW) # INTERFACE_LINK_LIBRARIES defines the link interface
  191. endif ()
  192. if (CMAKE_VERSION VERSION_GREATER 3.0.0 OR CMAKE_VERSION VERSION_EQUAL 3.0.0)
  193. cmake_policy (SET CMP0026 OLD) # Disallow use of the LOCATION target property - therefore we set to OLD as we still need it
  194. cmake_policy (SET CMP0042 NEW) # MACOSX_RPATH is enabled by default
  195. endif ()
  196. endif ()
  197. # Set CMake modules search path
  198. set (CMAKE_MODULE_PATH
  199. \\$ENV{URHO3D_HOME}/Source/CMake/Modules
  200. \\$ENV{CMAKE_PREFIX_PATH}/share/Urho3D/CMake/Modules
  201. CACHE PATH \"Path to Urho3D-specific CMake modules\")
  202. # Include Urho3D CMake common module
  203. include (Urho3D-CMake-common)
  204. # Find Urho3D library
  205. find_package (Urho3D REQUIRED)
  206. include_directories (\\${URHO3D_INCLUDE_DIRS})
  207. # Define target name
  208. set (TARGET_NAME #{target})
  209. # Define source files
  210. define_source_files ()
  211. # Setup target with resource copying
  212. setup_main_executable ()
  213. # Setup test cases
  214. add_test (NAME ExternalLibAS COMMAND \\${TARGET_NAME} Data/Scripts/12_PhysicsStressTest.as -w -timeout \\${URHO3D_TEST_TIME_OUT})
  215. add_test (NAME ExternalLibLua COMMAND \\${TARGET_NAME} Data/LuaScripts/12_PhysicsStressTest.lua -w -timeout \\${URHO3D_TEST_TIME_OUT})
  216. EOF" or abort 'Failed to create new project using Urho3D as external library'
  217. end
  218. def makefile_travis_ci
  219. if ENV['WINDOWS']
  220. # LuaJIT on MinGW build is not possible on Ubuntu 12.04 LTS as its GCC cross-compiler version is too old. Fallback to use Lua library instead.
  221. jit = ''
  222. amalg = ''
  223. # Lua on MinGW build requires tolua++ tool to be built natively first
  224. system 'MINGW_PREFIX= ./cmake_gcc.sh -DURHO3D_LIB_TYPE=$URHO3D_LIB_TYPE -DURHO3D_64BIT=$URHO3D_64BIT -DURHO3D_LUA=1 -DURHO3D_TOOLS=0' or abort 'Failed to configure native build for tolua++ target'
  225. system "cd Build/ThirdParty/toluapp/src/bin && make -j$NUMJOBS" or abort 'Failed to build tolua++ tool'
  226. ENV['SKIP_NATIVE'] = '1'
  227. else
  228. jit = 'JIT'
  229. amalg = '-DURHO3D_LUAJIT_AMALG=1'
  230. end
  231. system "./cmake_gcc.sh -DURHO3D_LIB_TYPE=$URHO3D_LIB_TYPE -DURHO3D_64BIT=$URHO3D_64BIT -DURHO3D_LUA#{jit}=1 #{amalg} -DURHO3D_SAMPLES=1 -DURHO3D_TOOLS=1 -DURHO3D_EXTRAS=1 -DURHO3D_TESTING=#{$testing} -DCMAKE_BUILD_TYPE=#{$configuration}" or abort 'Failed to configure Urho3D library build'
  232. if ENV['ANDROID']
  233. # LuaJIT on Android build requires tolua++ and buildvm-android tools to be built natively first
  234. system "cd Build/ThirdParty/toluapp/src/bin && make -j$NUMJOBS" or abort 'Failed to build tolua++ tool'
  235. system "cd Build/ThirdParty/LuaJIT/generated/buildvm-android && make -j$NUMJOBS" or abort 'Failed to build buildvm-android tool'
  236. # Reconfigure Android build one more time now that we have the tools built
  237. ENV['SKIP_NATIVE'] = '1'
  238. system './cmake_gcc.sh' or abort 'Failed to reconfigure Urho3D library for Android build'
  239. platform_prefix = 'android-'
  240. elsif ENV['RPI']
  241. # LuaJIT on Raspberry Pi build requires tolua++ and buildvm-raspi tools to be built natively first
  242. system "cd Build/ThirdParty/toluapp/src/bin && make -j$NUMJOBS" or abort 'Failed to build tolua++ tool'
  243. system "cd Build/ThirdParty/LuaJIT/generated/buildvm-raspi && make -j$NUMJOBS" or abort 'Failed to build buildvm-raspi tool'
  244. # Reconfigure Raspberry Pi build one more time now that we have the tools built
  245. ENV['SKIP_NATIVE'] = '1'
  246. system './cmake_gcc.sh' or abort 'Failed to reconfigure Urho3D library for Raspberry Pi build'
  247. platform_prefix = 'raspi-'
  248. elsif ENV['WINDOWS']
  249. platform_prefix = 'mingw-'
  250. else
  251. platform_prefix = ''
  252. end
  253. # Temporary workaround due to Travis-CI insufficient memory in 64-bit/MinGW/STATIC build configuration, build 21_AngelScriptIntegration separately
  254. if ENV['CI'] and ENV['WINDOWS'] and ENV['URHO3D_64BIT'] and ENV['URHO3D_LIB_TYPE'] == 'STATIC'
  255. system "cd #{platform_prefix}Build/Samples/21_AngelScriptIntegration && make -j$NUMJOBS" or abort 'Failed to build or test Urho3D library'
  256. end
  257. # Only 64-bit Linux environment with virtual framebuffer X server support and not MinGW build; or OSX build environment are capable to run tests
  258. if $testing == 1 and (ENV['URHO3D_64BIT'] and ENV['WINDOWS'].to_i != 1 or ENV['OSX'])
  259. test = '&& make test'
  260. else
  261. test = ''
  262. end
  263. system "cd #{platform_prefix}Build && make -j$NUMJOBS #{test}" or abort 'Failed to build or test Urho3D library'
  264. # Create a new project on the fly that uses newly built Urho3D library
  265. scaffolding "#{platform_prefix}Build/generated/externallib"
  266. system "URHO3D_HOME=`pwd`; export URHO3D_HOME && cd #{platform_prefix}Build/generated/externallib && echo '\nUsing Urho3D as external library in external project' && ./cmake_gcc.sh -DURHO3D_64BIT=$URHO3D_64BIT -DURHO3D_LUA#{jit}=1 -DURHO3D_TESTING=#{$testing} -DCMAKE_BUILD_TYPE=#{$configuration} && cd #{platform_prefix}Build && make -j$NUMJOBS #{test}" or abort 'Failed to configure/build/test temporary project using Urho3D as external library'
  267. end
  268. def xcode_travis_ci
  269. if ENV['IOS']
  270. # IOS platform does not support LuaJIT
  271. jit = ''
  272. amalg = ''
  273. platform_prefix = 'ios-'
  274. # Lua on IOS build requires tolua++ tool to be built natively first
  275. system "./cmake_macosx.sh -DURHO3D_LIB_TYPE=$URHO3D_LIB_TYPE -DURHO3D_64BIT=$URHO3D_64BIT -DURHO3D_LUA=1 -DURHO3D_TOOLS=0" or abort 'Failed to configure native build for tolua++ target'
  276. xcode_build(0, 'Build/Urho3D.xcodeproj', 'tolua++') or abort 'Failed to build tolua++ tool'
  277. else
  278. jit = 'JIT'
  279. amalg = '-DURHO3D_LUAJIT_AMALG=1'
  280. platform_prefix = ''
  281. end
  282. system "./cmake_macosx.sh -DIOS=$IOS -DURHO3D_LIB_TYPE=$URHO3D_LIB_TYPE -DURHO3D_64BIT=$URHO3D_64BIT -DURHO3D_LUA#{jit}=1 #{amalg} -DURHO3D_SAMPLES=1 -DURHO3D_TOOLS=1 -DURHO3D_EXTRAS=1 -DURHO3D_TESTING=#{$testing}" or abort 'Failed to configure Urho3D library build'
  283. xcode_build(ENV['IOS'], "#{platform_prefix}Build/Urho3D.xcodeproj") or abort 'Failed to build or test Urho3D library'
  284. # Create a new project on the fly that uses newly built Urho3D library
  285. scaffolding "#{platform_prefix}Build/generated/externallib"
  286. system "URHO3D_HOME=`pwd`; export URHO3D_HOME && cd #{platform_prefix}Build/generated/externallib && echo '\nUsing Urho3D as external library in external project' && ./cmake_macosx.sh -DIOS=$IOS -DURHO3D_64BIT=$URHO3D_64BIT -DURHO3D_LUA#{jit}=1 -DURHO3D_TESTING=#{$testing}" or abort 'Failed to configure temporary project using Urho3D as external library'
  287. xcode_build(ENV['IOS'], "#{platform_prefix}Build/generated/externallib/#{platform_prefix}Build/Scaffolding.xcodeproj") or abort 'Failed to configure/build/test temporary project using Urho3D as external library'
  288. end
  289. def xcode_build(ios, project, scheme = 'ALL_BUILD', autosave = true, extras = '')
  290. if autosave
  291. # Save auto-created schemes from Xcode project file
  292. system "ruby -i -pe 'gsub(/refType = 0; /, %q{})' #{project}/project.pbxproj" or 'Failed to remove legacy refType attributes from the generated Xcode project file'
  293. system "ruby -i -e 'puts ARGF.read.gsub(/buildSettings = \\{\n\s*?\\};\n\s*?buildStyles = \(.*?\);/m, %q{})' #{project}/project.pbxproj" or 'Failed to remove unsupported PBXProject attributes from the generated Xcode project file'
  294. xcproj = Xcodeproj::Project.open(project)
  295. xcproj.recreate_user_schemes
  296. xcproj.save # There is a bug in this gem, it does not appear to exit with proper exit status (assume always success for now)
  297. end
  298. sdk = ios.to_i == 1 ? '-sdk iphonesimulator' : ''
  299. # Use xctool when building as its output is nicer
  300. system "xctool -project #{project} -scheme #{scheme} -configuration #{$configuration} #{sdk} #{extras}" or return 1
  301. if $testing == 1 and ios.to_i != 1 and scheme == 'ALL_BUILD' # Disable testing for IOS as we don't have unit tests for IOS platform yet
  302. # Use xcodebuild when testing as its output is instantaneous (ensure Travis-CI does not kill the process during testing)
  303. system "xcodebuild -project #{project} -scheme RUN_TESTS -configuration #{$configuration} #{sdk} #{extras}" or return 1
  304. end
  305. return 0
  306. end
  307. def bump_soversion filename
  308. begin
  309. version = File.read(filename).split '.'
  310. bump_version version, 2
  311. File.open filename, 'w' do |file|
  312. file.puts version.join '.'
  313. end
  314. return 0
  315. rescue
  316. nil
  317. end
  318. end
  319. def bump_version version, index
  320. if index > 0 && version[index].to_i == 255
  321. version[index] = 0
  322. bump_version version, index - 1
  323. else
  324. version[index] = version[index].to_i + 1
  325. end
  326. end
  327. def setup_digital_keys
  328. system 'mkdir -p ~/.ssh && chmod 700 ~/.ssh' or abort 'Failed to create ~/.ssh directory'
  329. system "cat <<EOF >>~/.ssh/known_hosts
  330. frs.sourceforge.net,216.34.181.57 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA2uifHZbNexw6cXbyg1JnzDitL5VhYs0E65Hk/tLAPmcmm5GuiGeUoI/B0eUSNFsbqzwgwrttjnzKMKiGLN5CWVmlN1IXGGAfLYsQwK6wAu7kYFzkqP4jcwc5Jr9UPRpJdYIK733tSEmzab4qc5Oq8izKQKIaxXNe7FgmL15HjSpatFt9w/ot/CHS78FUAr3j3RwekHCm/jhPeqhlMAgC+jUgNJbFt3DlhDaRMa0NYamVzmX8D47rtmBbEDU3ld6AezWBPUR5Lh7ODOwlfVI58NAf/aYNlmvl2TZiauBCTa7OPYSyXJnIPbQXg6YQlDknNCr0K769EjeIlAfY87Z4tw==
  331. EOF" or abort 'Failed to append frs.sourceforge.net server public key to known_hosts'
  332. # Workaround travis encryption key size limitation. Rather than using the solution in their FAQ (using AES to encrypt/decrypt the file and check in the encrypted file into repo), our solution is more pragmatic. The private key below is incomplete. Only the missing portion is encrypted. Much less secure than the original 2048-bit RSA has to offer but good enough for our case.
  333. system "cat <<EOF >~/.ssh/id_rsa
  334. -----BEGIN RSA PRIVATE KEY-----
  335. MIIEpQIBAAKCAQEAnZGzFEypdXKY3KDT0Q3NLY4Bv74yKgJ4LIgbXothx8w4CfM0
  336. VeWBL/AE2iRISEWGB07LruM9y+U/wt58WlCVu001GuJuvXwWenlljsvH8qQlErYi
  337. oXlCwAeVVeanILGL8CPS7QlyzOwwnVF6NdcmfDJjTthBVFbvHrWGo5if86zcZyMR
  338. 2BB5QVEr5fU0yOPFp0+2p7J3cA6HQSKwjUiDtJ+lM62UQp7InCCT3qeh5KYHQcYb
  339. KVJTyj5iycVuBujHDwNAivLq82ojG7LcKjP+Ia8fblardCOQyFk6pSDM79NJJ2Dg
  340. 3ZbYIJeUmqSqFhRW/13Bro7Z1aNGrdh/XZkkHwIDAQABAoIBACHcBFJxYtzVIloO
  341. yVWcFKIcaO3OLjNu0monWVJIu1tW3BfvRijLJ6aoejJyJ4I4RmPdn9FWDZp6CeiT
  342. LL+vn21fWvELBWb8ekwZOCSmT7IpaboKn4h5aUmgl4udA/73iC2zVQkQxbWZb5zu
  343. vEdDk4aOwV5ZBDjecYX01hjjnEOdZHGJlF/H/Xs0hYX6WDG3/r9QCJJ0nfd1/Fk2
  344. zdbZRtAbyRz6ZHiYKnFQ441qRRaEbzunkvTBEwu9iqzlE0s/g49LJL0mKEp7rt/J
  345. 4iS3LZTQbJNx5J0ti8ZJKHhvoWb5RJxNimwKvVHC0XBZKTiLMrhnADmcpjLz53F8
  346. $SF_KEY
  347. sx27yCaeBeKXV0tFOeZmgK664VM9EgesjIX4sVOJ5mA3xBJBOtz9n66LjoIlIM58
  348. dvsAnJt7MUBdclL/RBHEjbUxgGBDcazfWSuJe0sGczhnXMN94ox4MSECgYEAx5cv
  349. cs/2KurjtWPanDGSz71LyGNdL/xQrAud0gi49H0tyYr0XmzNoe2CbZ/T5xGSZB92
  350. PBcz4rnHQ/oujo/qwjNpDD0xVLEU70Uy/XiY5/v2111TFC4clfE/syZPywKAztt3
  351. y2l5z+QdsNigRPDhKw+7CFYaAnYBEISxR6nabT8CgYEAqHrM8fdn2wsCNE6XvkZQ
  352. O7ZANHNIKVnaRqW/8HW7EFAWQrlQTgzFbtR4uNBIqAtPsvwSx8Pk652+OR1VKfSv
  353. ya3dtqY3rY/ErXWyX0nfPQEbYj/oh8LbS6zPw75yIorP3ACIwMw3GRNWIvkdAGTn
  354. BMUgpWHUDLWWpWRrSzNi90ECgYEAkxxzQ6vW5OFGv17/NdswO+BpqCTc/c5646SY
  355. ScRWFxbhFclOvv5xPqYiWYzRkmIYRaYO7tGnU7jdD9SqVjfrsAJWrke4QZVYOdgG
  356. cl9eTLchxLGr15b5SOeNrQ1TCO4qZM3M6Wgv+bRI0h2JW+c0ABpTIBzehOvXcwZq
  357. 6MhgD98CgYEAtOPqc4aoIRUy+1oijpWs+wU7vAc8fe4sBHv5fsv7naHuPqZgyQYY
  358. 32a54xZxlsBw8T5P4BDy40OR7fu+6miUfL+WxUdII4fD3grlIPw6bpNE0bCDykv5
  359. RLq28S11hDrKf/ZetXNuIprfTlhl6ISBy+oWQibhXmFZSxEiXNV6hCQ=
  360. -----END RSA PRIVATE KEY-----
  361. EOF" or abort 'Failed to create user private key to id_rsa'
  362. system 'chmod 600 ~/.ssh/id_rsa' or abort 'Failed to change id_rsa file permission'
  363. end
  364. # vi: set ts=2 sw=2 expandtab: