Browse Source

Differentiate between SOVERSION and git revision number.
Closes #419. Test [ci package]

Yao Wei Tjong 姚伟忠 11 years ago
parent
commit
eb8157c3eb
3 changed files with 37 additions and 9 deletions
  1. 30 3
      Rakefile
  2. 1 0
      Source/Engine/.soversion
  3. 6 6
      Source/Engine/CMakeLists.txt

+ 30 - 3
Rakefile

@@ -78,7 +78,7 @@ task :travis_ci_site_update do
   # Generate and sync doxygen pages
   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'
   # Supply GIT credentials and push site documentation to urho3d/urho3d.github.io.git
-  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'
+  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'
   # Automatically give instruction to do packaging when API has changed, unless the instruction is already given in this commit
   if ENV['PACKAGE_UPLOAD']
     instruction = 'skip'
@@ -86,13 +86,18 @@ task :travis_ci_site_update do
     instruction = 'package'
   end
   # 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)
-  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* && ( git commit -q -m 'Travis CI: API documentation update at #{Time.now.utc}.\n[ci #{instruction}]' || true ) && 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'
+  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*'
+  if system("git commit -q -m 'Travis CI: API documentation update at #{Time.now.utc}.\n[ci #{instruction}]'") && !ENV['PACKAGE_UPLOAD']
+    bump_soversion 'Source/Engine/.soversion' or abort 'Failed to bump soversion'
+    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'
+  end
+  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'
 end
 
 # Usage: NOT intended to be used manually (if you insist then try: GIT_NAME=... GIT_EMAIL=... GH_TOKEN=... rake travis_ci_rebase)
 desc 'Rebase OSX-CI mirror branch'
 task :travis_ci_rebase do
-  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'
+  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'
 end
 
 # Usage: NOT intended to be used manually (if you insist then try: rake travis_ci_package_upload)
@@ -320,6 +325,28 @@ def xcode_build(ios, project, scheme = 'ALL_BUILD', autosave = true, extras = ''
   return 0
 end
 
+def bump_soversion filename
+  begin
+    version = File.read(filename).split '.'
+    bump_version version, 2
+    File.open filename, 'w' do |file|
+      file.puts version.join '.'
+    end
+    return 0
+  rescue
+    nil
+  end
+end
+
+def bump_version version, index
+  if index > 0 && version[index].to_i == 255
+    version[index] = 0
+    bump_version version, index - 1
+  else
+    version[index] = version[index].to_i + 1
+  end
+end
+
 def setup_digital_keys
   system 'mkdir -p ~/.ssh && chmod 700 ~/.ssh' or abort 'Failed to create ~/.ssh directory'
   system "cat <<EOF >>~/.ssh/known_hosts

+ 1 - 0
Source/Engine/.soversion

@@ -0,0 +1 @@
+0.0.0

+ 6 - 6
Source/Engine/CMakeLists.txt

@@ -96,14 +96,14 @@ set_output_directories (${OUTPUT_PATH} ARCHIVE LIBRARY)
  
 # Setup target
 setup_library (${URHO3D_LIB_TYPE})
-if (APPLE)
-    # Apple linker only accepts 32-bit x.y.z version number in this format 0xffff.0xff.0xff so it does not accept our version number because our patch number is quite high
-    # Workaround by masking the high order byte
-    math (EXPR VERSION_PATCH "${CPACK_PACKAGE_VERSION_PATCH} & 255")
+file (READ .soversion SOVERSION)
+string (STRIP ${SOVERSION} SOVERSION)
+string (REGEX MATCH "([^.]+)\\.([^.]+)\\.(.+)" MATCHED ${SOVERSION})
+if (MATCHED)
+    set_target_properties (${TARGET_NAME} PROPERTIES VERSION ${MATCHED} SOVERSION ${CMAKE_MATCH_1})
 else ()
-    set (VERSION_PATCH ${CPACK_PACKAGE_VERSION_PATCH})
+    message (FATAL_ERROR "The .soversion file is corrupted. It should contain a version number with this format major(0xFFFF).minor(0xFF).patch-level(0xFF). e.g.: 0.1.2")
 endif ()
-set_target_properties (${TARGET_NAME} PROPERTIES VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${VERSION_PATCH} SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${VERSION_PATCH})
 install (TARGETS ${TARGET_NAME} RUNTIME DESTINATION ${DEST_RUNTIME_DIR} LIBRARY DESTINATION ${DEST_LIBRARY_DIR} ARCHIVE DESTINATION ${DEST_LIBRARY_DIR})
 if (NOT GIT_EXIT_CODE EQUAL 0)
     add_dependencies (${TARGET_NAME} ${STATIC_LIBRARY_TARGETS})