Rakefile 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  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. require 'json'
  24. if ENV['XCODE']
  25. require 'xcodeproj'
  26. end
  27. # Usage: rake sync (only intended to be used in a fork with remote 'upstream' set to urho3d/Urho3D)
  28. desc 'Fetch and merge upstream urho3d/Urho3D to a Urho3D fork'
  29. task :sync do
  30. 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"
  31. end
  32. # Usage: rake scaffolding dir=/path/to/new/project/root [project=your-project-name] [target=your-target-name]
  33. desc 'Create a new project using Urho3D as external library'
  34. task :scaffolding do
  35. abort 'Usage: rake scaffolding dir=/path/to/new/project/root [project=your-project-name] [target=your-target-name]' unless ENV['dir']
  36. abs_path = ENV['dir'][0, 1] == '/' ? ENV['dir'] : "#{Dir.pwd}/#{ENV['dir']}"
  37. project = ENV['project'] || 'Scaffolding'
  38. target = ENV['target'] || 'Main'
  39. scaffolding(abs_path, project, target)
  40. abs_path = Pathname.new(abs_path).realpath
  41. puts "\nNew project created in #{abs_path}\n\n"
  42. puts "To build the new project, you may need to first define and export either 'URHO3D_HOME' or 'CMAKE_PREFIX_PATH' environment variable"
  43. puts "Please see http://urho3d.github.io/documentation/_using_library.html for more detail. For example:\n\n"
  44. 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"
  45. end
  46. # Usage: NOT intended to be used manually (if you insist then try: rake travis_ci)
  47. desc 'Configure, build, and test Urho3D project'
  48. task :travis_ci do
  49. if ENV['PACKAGE_UPLOAD']
  50. $configuration = 'Release'
  51. $testing = 0
  52. else
  53. $configuration = 'Debug'
  54. $testing = 1
  55. end
  56. if ENV['XCODE']
  57. # xctool or xcodebuild
  58. xcode_travis_ci
  59. else
  60. # GCC or Clang
  61. makefile_travis_ci
  62. end
  63. end
  64. # Usage: NOT intended to be used manually (if you insist then try: GIT_NAME=... GIT_EMAIL=... GH_TOKEN=... rake travis_ci_site_update)
  65. desc 'Update site documentation to GitHub Pages'
  66. task :travis_ci_site_update do
  67. # Pull or clone
  68. 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'
  69. # Update credits from Readme.txt to about.md
  70. 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'
  71. # Setup doxygen to use minimal theme
  72. 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'
  73. system 'cp doc-Build/_includes/Doxygen/minimal-* Docs' or abort 'Failed to copy minimal-themed template'
  74. release = ENV['RELEASE_TAG'].empty? ? 'HEAD' : ENV['RELEASE_TAG'];
  75. unless release == 'HEAD'
  76. system "mkdir -p doc-Build/documentation/#{release}" or 'Failed to create directory for new document version'
  77. system "ruby -i -pe 'gsub(/HEAD/, %q{#{release}})' Docs/minimal-header.html" or 'Failed to update document version in YAML Front Matter block'
  78. append_new_release release, 'doc-Build/_data/urho3d.json' or abort 'Failed to add new release to document data file'
  79. end
  80. # Generate and sync doxygen pages
  81. system "cd Build && make -j$NUMJOBS doc >/dev/null 2>&1 && ruby -i -pe 'gsub(/(<\\/?h)2([^>]*?>)/, %q{\\13\\2}); gsub(/(<\\/?h)1([^>]*?>)/, %q{\\12\\2})' ../Docs/html/_*.html && rsync -a --delete ../Docs/html/ ../doc-Build/documentation/#{release}" or abort 'Failed to generate/rsync doxygen pages'
  82. # Supply GIT credentials and push site documentation to urho3d/urho3d.github.io.git
  83. 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'
  84. # Automatically give instruction to do packaging when API has changed, unless the instruction is already given in this commit
  85. if ENV['PACKAGE_UPLOAD']
  86. instruction = 'skip'
  87. else
  88. instruction = 'package'
  89. end
  90. # 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)
  91. 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*'
  92. if system("git commit -q -m 'Travis CI: API documentation update at #{Time.now.utc}.\n[ci #{instruction}]'") && !ENV['PACKAGE_UPLOAD']
  93. bump_soversion 'Source/Engine/.soversion' or abort 'Failed to bump soversion'
  94. 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'
  95. end
  96. 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'
  97. end
  98. # Usage: NOT intended to be used manually (if you insist then try: GIT_NAME=... GIT_EMAIL=... GH_TOKEN=... rake travis_ci_rebase)
  99. desc 'Rebase OSX-CI mirror branch'
  100. task :travis_ci_rebase do
  101. 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'
  102. end
  103. # Usage: NOT intended to be used manually (if you insist then try: rake travis_ci_package_upload)
  104. desc 'Make binary package and upload it to a designated central hosting server'
  105. task :travis_ci_package_upload do
  106. if ENV['XCODE']
  107. $configuration = 'Release'
  108. $testing = 0
  109. end
  110. if ENV['ANDROID']
  111. platform_prefix = 'android-'
  112. elsif ENV['WINDOWS']
  113. platform_prefix = 'mingw-'
  114. elsif ENV['IOS']
  115. platform_prefix = 'ios-'
  116. elsif ENV['RPI']
  117. platform_prefix = 'raspi-'
  118. else
  119. platform_prefix = ''
  120. end
  121. # Generate the documentation if necessary
  122. unless ENV['SITE_UPDATE']
  123. system 'echo Generate documentation'
  124. if ENV['XCODE']
  125. xcode_build(ENV['IOS'], "#{platform_prefix}Build/Urho3D.xcodeproj", 'doc', false, '>/dev/null') or abort 'Failed to generate documentation'
  126. else
  127. system "cd #{platform_prefix}Build && make -j$NUMJOBS doc >/dev/null" or abort 'Failed to generate documentation'
  128. end
  129. end
  130. # Make the package
  131. if ENV['IOS']
  132. unless ENV['URHO3D_64BIT'] # Skip Mach-O universal binary build for the time being as otherwise overall build time exceeds 50 minutes time limit
  133. # 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)
  134. system 'echo Rebuild Urho3D library as Mach-O universal binary'
  135. xcode_build(0, "#{platform_prefix}Build/Urho3D.xcodeproj", 'Urho3D_universal', false) or abort 'Failed to build Mach-O universal binary'
  136. end
  137. # There is a bug in CMake/CPack that causes the 'package' scheme failed to build for IOS platform, workaround by calling cpack directly
  138. system "cd #{platform_prefix}Build && cpack -G TGZ 2>/dev/null" or abort 'Failed to make binary package'
  139. elsif ENV['XCODE']
  140. xcode_build(ENV['IOS'], "#{platform_prefix}Build/Urho3D.xcodeproj", 'package', false) or abort 'Failed to make binary package'
  141. else
  142. if ENV['ANDROID']
  143. # Build Android package consisting of both armeabi-v7a and armeabi ABIs
  144. system 'echo Reconfigure and rebuild Urho3D project using armeabi ABI'
  145. 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'
  146. 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)'
  147. end
  148. system "cd #{platform_prefix}Build && make package" or abort 'Failed to make binary package'
  149. end
  150. # Determine the upload location
  151. setup_digital_keys
  152. if ENV['RELEASE_TAG'].empty?
  153. upload_dir = "/home/frs/project/#{ENV['TRAVIS_REPO_SLUG']}/Snapshots"
  154. if ENV['SITE_UPDATE']
  155. # Download source packages from GitHub
  156. system 'SNAPSHOP_VER=`git describe $TRAVIS_COMMIT`; 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'
  157. # Only keep the snapshots from the last +/- 50 revisions
  158. # 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
  159. system "for v in $(sftp [email protected] <<EOF |tr ' ' '\n' |grep Urho3D- |cut -d '-' -f1,2 |uniq |tail -n +51 |sort |uniq
  160. cd #{upload_dir}
  161. ls -1t
  162. bye
  163. EOF
  164. ); do echo rm #{upload_dir}/${v}*; done |sftp -b - [email protected]" or abort 'Failed to housekeep snapshots'
  165. end
  166. else
  167. upload_dir = "/home/frs/project/#{ENV['TRAVIS_REPO_SLUG']}/#{ENV['RELEASE_TAG']}"
  168. if ENV['SITE_UPDATE']
  169. # Download source packages from GitHub
  170. 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'
  171. end
  172. # 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
  173. system "sftp [email protected] <<EOF >/dev/null 2>&1
  174. mkdir #{upload_dir}
  175. bye
  176. EOF" or abort 'Failed to create release directory remotely'
  177. end
  178. # Upload the package
  179. system "scp #{platform_prefix}Build/Urho3D-* [email protected]:#{upload_dir}" or abort 'Failed to upload binary package'
  180. if ENV['SITE_UPDATE']
  181. # Upload the source package
  182. system "scp Urho3D-* [email protected]:#{upload_dir}" or abort 'Failed to upload source package'
  183. # Sync readme and license files, just in case they are updated in the repo
  184. 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'
  185. 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'
  186. end
  187. end
  188. def scaffolding(dir, project = 'Scaffolding', target = 'Main')
  189. 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
  190. # Set project name
  191. project (#{project})
  192. # Set minimum version
  193. cmake_minimum_required (VERSION 2.8.6)
  194. if (COMMAND cmake_policy)
  195. cmake_policy (SET CMP0003 NEW)
  196. if (CMAKE_VERSION VERSION_GREATER 2.8.12 OR CMAKE_VERSION VERSION_EQUAL 2.8.12)
  197. cmake_policy (SET CMP0022 NEW) # INTERFACE_LINK_LIBRARIES defines the link interface
  198. endif ()
  199. if (CMAKE_VERSION VERSION_GREATER 3.0.0 OR CMAKE_VERSION VERSION_EQUAL 3.0.0)
  200. cmake_policy (SET CMP0026 OLD) # Disallow use of the LOCATION target property - therefore we set to OLD as we still need it
  201. cmake_policy (SET CMP0042 NEW) # MACOSX_RPATH is enabled by default
  202. endif ()
  203. endif ()
  204. # Set CMake modules search path
  205. set (CMAKE_MODULE_PATH
  206. \\$ENV{URHO3D_HOME}/Source/CMake/Modules
  207. \\$ENV{CMAKE_PREFIX_PATH}/share/Urho3D/CMake/Modules
  208. CACHE PATH \"Path to Urho3D-specific CMake modules\")
  209. # Include Urho3D CMake common module
  210. include (Urho3D-CMake-common)
  211. # Find Urho3D library
  212. find_package (Urho3D REQUIRED)
  213. include_directories (\\${URHO3D_INCLUDE_DIRS})
  214. # Define target name
  215. set (TARGET_NAME #{target})
  216. # Define source files
  217. define_source_files ()
  218. # Setup target with resource copying
  219. setup_main_executable ()
  220. # Setup test cases
  221. add_test (NAME ExternalLibAS COMMAND \\${TARGET_NAME} Data/Scripts/12_PhysicsStressTest.as -w -timeout \\${URHO3D_TEST_TIME_OUT})
  222. add_test (NAME ExternalLibLua COMMAND \\${TARGET_NAME} Data/LuaScripts/12_PhysicsStressTest.lua -w -timeout \\${URHO3D_TEST_TIME_OUT})
  223. EOF" or abort 'Failed to create new project using Urho3D as external library'
  224. end
  225. def makefile_travis_ci
  226. if ENV['WINDOWS']
  227. # 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.
  228. jit = ''
  229. amalg = ''
  230. # Lua on MinGW build requires tolua++ tool to be built natively first
  231. 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'
  232. system "cd Build/ThirdParty/toluapp/src/bin && make -j$NUMJOBS" or abort 'Failed to build tolua++ tool'
  233. ENV['SKIP_NATIVE'] = '1'
  234. else
  235. jit = 'JIT'
  236. amalg = '-DURHO3D_LUAJIT_AMALG=1'
  237. end
  238. 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'
  239. if ENV['ANDROID']
  240. # LuaJIT on Android build requires tolua++ and buildvm-android tools to be built natively first
  241. system "cd Build/ThirdParty/toluapp/src/bin && make -j$NUMJOBS" or abort 'Failed to build tolua++ tool'
  242. system "cd Build/ThirdParty/LuaJIT/generated/buildvm-android && make -j$NUMJOBS" or abort 'Failed to build buildvm-android tool'
  243. # Reconfigure Android build one more time now that we have the tools built
  244. ENV['SKIP_NATIVE'] = '1'
  245. system './cmake_gcc.sh' or abort 'Failed to reconfigure Urho3D library for Android build'
  246. platform_prefix = 'android-'
  247. elsif ENV['RPI']
  248. # LuaJIT on Raspberry Pi build requires tolua++ and buildvm-raspi tools to be built natively first
  249. system "cd Build/ThirdParty/toluapp/src/bin && make -j$NUMJOBS" or abort 'Failed to build tolua++ tool'
  250. system "cd Build/ThirdParty/LuaJIT/generated/buildvm-raspi && make -j$NUMJOBS" or abort 'Failed to build buildvm-raspi tool'
  251. # Reconfigure Raspberry Pi build one more time now that we have the tools built
  252. ENV['SKIP_NATIVE'] = '1'
  253. system './cmake_gcc.sh' or abort 'Failed to reconfigure Urho3D library for Raspberry Pi build'
  254. platform_prefix = 'raspi-'
  255. elsif ENV['WINDOWS']
  256. platform_prefix = 'mingw-'
  257. else
  258. platform_prefix = ''
  259. end
  260. # Temporary workaround due to Travis-CI insufficient memory in 64-bit/MinGW/STATIC build configuration, build samples separately using single worker process
  261. if ENV['CI'] and ENV['WINDOWS'] and ENV['URHO3D_64BIT'] and ENV['URHO3D_LIB_TYPE'] == 'STATIC'
  262. system "cd #{platform_prefix}Build/Tools && make -j$NUMJOBS && cd .. && make" or abort 'Failed to build or test Urho3D library'
  263. else
  264. # Only 64-bit Linux environment with virtual framebuffer X server support and not MinGW build; or OSX build environment are capable to run tests
  265. if $testing == 1 and (ENV['URHO3D_64BIT'] and ENV['WINDOWS'].to_i != 1 or ENV['OSX'])
  266. test = '&& make test'
  267. else
  268. test = ''
  269. end
  270. system "cd #{platform_prefix}Build && make -j$NUMJOBS #{test}" or abort 'Failed to build or test Urho3D library'
  271. end
  272. # Create a new project on the fly that uses newly built Urho3D library
  273. scaffolding "#{platform_prefix}Build/generated/externallib"
  274. 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'
  275. end
  276. def xcode_travis_ci
  277. if ENV['IOS']
  278. # IOS platform does not support LuaJIT
  279. jit = ''
  280. amalg = ''
  281. platform_prefix = 'ios-'
  282. # Lua on IOS build requires tolua++ tool to be built natively first
  283. 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'
  284. xcode_build(0, 'Build/Urho3D.xcodeproj', 'tolua++') or abort 'Failed to build tolua++ tool'
  285. else
  286. jit = 'JIT'
  287. amalg = '-DURHO3D_LUAJIT_AMALG=1'
  288. platform_prefix = ''
  289. end
  290. 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'
  291. xcode_build(ENV['IOS'], "#{platform_prefix}Build/Urho3D.xcodeproj") or abort 'Failed to build or test Urho3D library'
  292. # Create a new project on the fly that uses newly built Urho3D library
  293. scaffolding "#{platform_prefix}Build/generated/externallib"
  294. 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'
  295. 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'
  296. end
  297. def xcode_build(ios, project, scheme = 'ALL_BUILD', autosave = true, extras = '')
  298. if autosave
  299. # Save auto-created schemes from Xcode project file
  300. system "ruby -i -pe 'gsub(/refType = 0; /, %q{})' #{project}/project.pbxproj" or 'Failed to remove legacy refType attributes from the generated Xcode project file'
  301. 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'
  302. xcproj = Xcodeproj::Project.open(project)
  303. xcproj.recreate_user_schemes
  304. xcproj.save # There is a bug in this gem, it does not appear to exit with proper exit status (assume always success for now)
  305. end
  306. sdk = ios.to_i == 1 ? '-sdk iphonesimulator' : ''
  307. # Use xctool when building as its output is nicer
  308. system "xctool -project #{project} -scheme #{scheme} -configuration #{$configuration} #{sdk} #{extras}" or return 1
  309. 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
  310. # Use xcodebuild when testing as its output is instantaneous (ensure Travis-CI does not kill the process during testing)
  311. system "xcodebuild -project #{project} -scheme RUN_TESTS -configuration #{$configuration} #{sdk} #{extras}" or return 1
  312. end
  313. return 0
  314. end
  315. def append_new_release release, filename
  316. begin
  317. urho3d_hash = JSON.parse File.read filename
  318. unless urho3d_hash['releases'].last == release
  319. urho3d_hash['releases'] << release
  320. end
  321. File.open filename, 'w' do |file|
  322. file.puts urho3d_hash.to_json
  323. end
  324. return 0
  325. rescue
  326. nil
  327. end
  328. end
  329. def bump_soversion filename
  330. begin
  331. version = File.read(filename).split '.'
  332. bump_version version, 2
  333. File.open filename, 'w' do |file|
  334. file.puts version.join '.'
  335. end
  336. return 0
  337. rescue
  338. nil
  339. end
  340. end
  341. def bump_version version, index
  342. if index > 0 && version[index].to_i == 255
  343. version[index] = 0
  344. bump_version version, index - 1
  345. else
  346. version[index] = version[index].to_i + 1
  347. end
  348. end
  349. def setup_digital_keys
  350. system 'mkdir -p ~/.ssh && chmod 700 ~/.ssh' or abort 'Failed to create ~/.ssh directory'
  351. system "cat <<EOF >>~/.ssh/known_hosts
  352. frs.sourceforge.net,216.34.181.57 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA2uifHZbNexw6cXbyg1JnzDitL5VhYs0E65Hk/tLAPmcmm5GuiGeUoI/B0eUSNFsbqzwgwrttjnzKMKiGLN5CWVmlN1IXGGAfLYsQwK6wAu7kYFzkqP4jcwc5Jr9UPRpJdYIK733tSEmzab4qc5Oq8izKQKIaxXNe7FgmL15HjSpatFt9w/ot/CHS78FUAr3j3RwekHCm/jhPeqhlMAgC+jUgNJbFt3DlhDaRMa0NYamVzmX8D47rtmBbEDU3ld6AezWBPUR5Lh7ODOwlfVI58NAf/aYNlmvl2TZiauBCTa7OPYSyXJnIPbQXg6YQlDknNCr0K769EjeIlAfY87Z4tw==
  353. EOF" or abort 'Failed to append frs.sourceforge.net server public key to known_hosts'
  354. # 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.
  355. system "cat <<EOF >~/.ssh/id_rsa
  356. -----BEGIN RSA PRIVATE KEY-----
  357. MIIEpQIBAAKCAQEAnZGzFEypdXKY3KDT0Q3NLY4Bv74yKgJ4LIgbXothx8w4CfM0
  358. VeWBL/AE2iRISEWGB07LruM9y+U/wt58WlCVu001GuJuvXwWenlljsvH8qQlErYi
  359. oXlCwAeVVeanILGL8CPS7QlyzOwwnVF6NdcmfDJjTthBVFbvHrWGo5if86zcZyMR
  360. 2BB5QVEr5fU0yOPFp0+2p7J3cA6HQSKwjUiDtJ+lM62UQp7InCCT3qeh5KYHQcYb
  361. KVJTyj5iycVuBujHDwNAivLq82ojG7LcKjP+Ia8fblardCOQyFk6pSDM79NJJ2Dg
  362. 3ZbYIJeUmqSqFhRW/13Bro7Z1aNGrdh/XZkkHwIDAQABAoIBACHcBFJxYtzVIloO
  363. yVWcFKIcaO3OLjNu0monWVJIu1tW3BfvRijLJ6aoejJyJ4I4RmPdn9FWDZp6CeiT
  364. LL+vn21fWvELBWb8ekwZOCSmT7IpaboKn4h5aUmgl4udA/73iC2zVQkQxbWZb5zu
  365. vEdDk4aOwV5ZBDjecYX01hjjnEOdZHGJlF/H/Xs0hYX6WDG3/r9QCJJ0nfd1/Fk2
  366. zdbZRtAbyRz6ZHiYKnFQ441qRRaEbzunkvTBEwu9iqzlE0s/g49LJL0mKEp7rt/J
  367. 4iS3LZTQbJNx5J0ti8ZJKHhvoWb5RJxNimwKvVHC0XBZKTiLMrhnADmcpjLz53F8
  368. $SF_KEY
  369. sx27yCaeBeKXV0tFOeZmgK664VM9EgesjIX4sVOJ5mA3xBJBOtz9n66LjoIlIM58
  370. dvsAnJt7MUBdclL/RBHEjbUxgGBDcazfWSuJe0sGczhnXMN94ox4MSECgYEAx5cv
  371. cs/2KurjtWPanDGSz71LyGNdL/xQrAud0gi49H0tyYr0XmzNoe2CbZ/T5xGSZB92
  372. PBcz4rnHQ/oujo/qwjNpDD0xVLEU70Uy/XiY5/v2111TFC4clfE/syZPywKAztt3
  373. y2l5z+QdsNigRPDhKw+7CFYaAnYBEISxR6nabT8CgYEAqHrM8fdn2wsCNE6XvkZQ
  374. O7ZANHNIKVnaRqW/8HW7EFAWQrlQTgzFbtR4uNBIqAtPsvwSx8Pk652+OR1VKfSv
  375. ya3dtqY3rY/ErXWyX0nfPQEbYj/oh8LbS6zPw75yIorP3ACIwMw3GRNWIvkdAGTn
  376. BMUgpWHUDLWWpWRrSzNi90ECgYEAkxxzQ6vW5OFGv17/NdswO+BpqCTc/c5646SY
  377. ScRWFxbhFclOvv5xPqYiWYzRkmIYRaYO7tGnU7jdD9SqVjfrsAJWrke4QZVYOdgG
  378. cl9eTLchxLGr15b5SOeNrQ1TCO4qZM3M6Wgv+bRI0h2JW+c0ABpTIBzehOvXcwZq
  379. 6MhgD98CgYEAtOPqc4aoIRUy+1oijpWs+wU7vAc8fe4sBHv5fsv7naHuPqZgyQYY
  380. 32a54xZxlsBw8T5P4BDy40OR7fu+6miUfL+WxUdII4fD3grlIPw6bpNE0bCDykv5
  381. RLq28S11hDrKf/ZetXNuIprfTlhl6ISBy+oWQibhXmFZSxEiXNV6hCQ=
  382. -----END RSA PRIVATE KEY-----
  383. EOF" or abort 'Failed to create user private key to id_rsa'
  384. system 'chmod 600 ~/.ssh/id_rsa' or abort 'Failed to change id_rsa file permission'
  385. end
  386. # vi: set ts=2 sw=2 expandtab: