Add more scaffolding logic in build system for AutoBinder invocation.

[ci only: Annotate]
This commit is contained in:
Yao Wei Tjong 姚伟忠 2015-09-25 16:58:13 +08:00
parent b6abf67ca1
commit a25f982043
3 changed files with 66 additions and 51 deletions

View File

@ -198,11 +198,11 @@ end
desc 'Build and run the Annotate tool (temporary)'
task :ci_annotate do
system 'rake cmake URHO3D_CLANG_TOOLS=1 && rake make annotate' or abort 'Failed to annotate'
system "git config user.name $GIT_NAME && git config user.email $GIT_EMAIL && git remote set-url --push origin https://$GH_TOKEN@github.com/$TRAVIS_REPO_SLUG.git && if git fetch origin annotated:annotated 2>/dev/null; then git push -qf origin --delete annotated; fi && git checkout -B annotated && git stash -q && git reset --hard HEAD~ && git stash pop -q && sed -i \"s/COVERITY_SCAN_THRESHOLD/URHO3D_BINDINGS=1 COVERITY_SCAN_THRESHOLD/g\" .travis.yml && git add -A .travis.yml Source/Urho3D && if git commit -qm 'Result of Annotator tool. [ci only: annotated]'; then git push -q -u origin annotated >/dev/null 2>&1; fi" or abort 'Failed to push annotated branch'
system "git config user.name $GIT_NAME && git config user.email $GIT_EMAIL && git remote set-url --push origin https://$GH_TOKEN@github.com/$TRAVIS_REPO_SLUG.git && if git fetch origin clang-tools:clang-tools 2>/dev/null; then git push -qf origin --delete clang-tools; fi && git checkout -B clang-tools && git stash -q && git reset --hard HEAD~ && git stash pop -q && sed -i \"s/COVERITY_SCAN_THRESHOLD/URHO3D_BINDINGS=1 COVERITY_SCAN_THRESHOLD/g\" .travis.yml && git add -A .travis.yml Source/Urho3D && if git commit -qm 'Result of Annotator tool. [ci only: clang-tools]'; then git push -q -u origin clang-tools >/dev/null 2>&1; fi" or abort 'Failed to push clang-tools branch'
end
# Usage: NOT intended to be used manually
desc 'Push the generated binding source files to annotated branch (temporary)'
desc 'Push the generated binding source files to clang-tools branch (temporary)'
task :ci_push_bindings do
abort "Skipped pushing to #{ENV['TRAVIS_BRANCH']} branch due to moving HEAD" unless `git fetch -qf origin #{ENV['TRAVIS_PULL_REQUEST'] == 'false' ? ENV['TRAVIS_BRANCH'] : %Q{+refs/pull/#{ENV['TRAVIS_PULL_REQUEST']}/head'}}; git log -1 --pretty=format:'%H' FETCH_HEAD` == ENV['TRAVIS_COMMIT']
system "git config user.name $GIT_NAME && git config user.email $GIT_EMAIL && git remote set-url --push origin https://$GH_TOKEN@github.com/$TRAVIS_REPO_SLUG.git && git add -A Source/Urho3D && if git commit -qm 'Result of AutoBinder tool. [ci skip]'; then git push -q origin HEAD:#{ENV['TRAVIS_BRANCH']} >/dev/null 2>&1; fi" or abort "Failed to push #{ENV['TRAVIS_BRANCH']} branch"

View File

@ -89,6 +89,7 @@ else ()
string (REGEX REPLACE "[^;]+\\.h" "" SOURCES "${SOURCES}") # Stringify to preserve the semicolons
string (REGEX REPLACE "[^;]+generated[^;]+\\.cpp" "" SOURCES "${SOURCES}")
file (GLOB BINDING_SOURCES RELATIVE ${CMAKE_SOURCE_DIR}/Source/Urho3D ${CMAKE_SOURCE_DIR}/Source/Urho3D/Script/*API.cpp)
string (REGEX REPLACE "[^;]+API[^;]+\\.cpp" "" ANNOTATED_SOURCES "${SOURCES}")
# List of tools
add_subdirectory (Annotator)
@ -119,7 +120,7 @@ else ()
COMMENT "Annotating Urho3D library source files")
add_custom_target (autobinder-as
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/Source/Urho3D/generated
COMMAND ${CMAKE_BINARY_DIR}/bin/tool/clang/AutoBinder -p ${CMAKE_BINARY_DIR} -t AngelScript -o ${CMAKE_BINARY_DIR}/Source/Urho3D/generated ${SOURCES}
COMMAND ${CMAKE_BINARY_DIR}/bin/tool/clang/AutoBinder -p ${CMAKE_BINARY_DIR} -t AngelScript -o ${CMAKE_BINARY_DIR}/Source/Urho3D/generated ${ANNOTATED_SOURCES}
DEPENDS AutoBinder
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/Source/Urho3D
COMMENT "Auto-binding for AngelScript")

View File

@ -62,6 +62,45 @@ if (WIN32)
endif ()
endif ()
# Define source files
foreach (DIR Navigation Network Physics Urho2D)
string (TOUPPER URHO3D_${DIR} OPT)
if (NOT ${OPT})
list (APPEND EXCLUDED_SOURCE_DIRS ${DIR})
endif ()
endforeach ()
if (NOT URHO3D_ANGELSCRIPT)
list (APPEND EXCLUDED_SOURCE_DIRS Script)
endif ()
if (NOT URHO3D_LUA)
list (APPEND EXCLUDED_SOURCE_DIRS LuaScript)
endif ()
if (URHO3D_DATABASE)
if (URHO3D_DATABASE_ODBC)
list (APPEND EXCLUDED_SOURCE_DIRS Database/SQLite)
else ()
list (APPEND EXCLUDED_SOURCE_DIRS Database/ODBC)
endif ()
else ()
list (APPEND EXCLUDED_SOURCE_DIRS Database)
endif ()
if (URHO3D_OPENGL)
# Exclude the opposite source directory
list (APPEND EXCLUDED_SOURCE_DIRS Graphics/Direct3D9 Graphics/Direct3D11)
else ()
list (APPEND EXCLUDED_SOURCE_DIRS Graphics/OpenGL)
if (URHO3D_D3D11)
list (APPEND EXCLUDED_SOURCE_DIRS Graphics/Direct3D9)
else ()
list (APPEND EXCLUDED_SOURCE_DIRS Graphics/Direct3D11)
endif ()
endif ()
if (APPLE AND NOT IOS)
set (GLOB_OBJC_PATTERN *.m) # Should only pick up MacFileWatcher.m for MacOSX platform at the moment
endif ()
string (REPLACE ";" "/[^;]+;" EXCLUDE_PATTERNS "${EXCLUDED_SOURCE_DIRS};")
define_source_files (EXCLUDE_PATTERNS ${EXCLUDE_PATTERNS} GLOB_CPP_PATTERNS *.cpp ${GLOB_OBJC_PATTERN} RECURSE GROUP PCH Precompiled.h)
# Define generated source files
if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/librevision.h)
execute_process (COMMAND ${CMAKE_COMMAND} -DFILENAME=${CMAKE_CURRENT_BINARY_DIR}/librevision.h -P CMake/Modules/GetUrho3DRevision.cmake
@ -73,22 +112,31 @@ add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/librevision.h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Generating GIT revision number (tag + last commit SHA-1)")
if (URHO3D_ANGELSCRIPT)
if (URHO3D_BINDINGS)
# Build the Clang-tools as external project (even when we are not cross-compiling) for auto-binding generation
include (ExternalProject)
if (IOS)
# For iOS target, ensure the host environment is cleared first; Also workaround a known CMake/Xcode generator bug which prevents it from installing binaries correctly
set (IOS_FIX CMAKE_COMMAND /usr/bin/env -i PATH=$ENV{PATH} ${CMAKE_COMMAND} BUILD_COMMAND bash -c "sed -i '' 's/EFFECTIVE_PLATFORM_NAME//g' CMakeScripts/install_postBuildPhase.make*")
endif ()
ExternalProject_Add (AutoBinder
# Use the AutoBinder tool to generate source files for binding script subsystems
if (URHO3D_BINDINGS)
# Build the Clang-tools as external project (even when we are not cross-compiling because it needs C++11 standard on) for auto-binding generation
include (ExternalProject)
if (IOS)
# For iOS target, ensure the host environment is cleared first; Also workaround a known CMake/Xcode generator bug which prevents it from installing binaries correctly
set (IOS_FIX CMAKE_COMMAND /usr/bin/env -i PATH=$ENV{PATH} ${CMAKE_COMMAND} BUILD_COMMAND bash -c "sed -i '' 's/EFFECTIVE_PLATFORM_NAME//g' CMakeScripts/install_postBuildPhase.make*")
endif ()
ExternalProject_Add (AutoBinder
SOURCE_DIR ${CMAKE_SOURCE_DIR}/Source/Clang-Tools
CMAKE_ARGS -DURHO3D_NOABI=1 -DURHO3D_CLANG_TOOLS=AutoBinder -DDEST_RUNTIME_DIR=${CMAKE_BINARY_DIR}/bin/tool/clang -DDEST_INCLUDE_DIR=${DEST_INCLUDE_DIR} -DBAKED_CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR} ${IOS_FIX})
file (MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/generated/generated)
if (URHO3D_ANGELSCRIPT)
list (APPEND TEMPLATES AngelScript)
list (APPEND OUTPUT_FILES ${CMAKE_CURRENT_BINARY_DIR}/generated/AngelScriptAPI.cpp)
endif ()
else ()
list (APPEND EXCLUDED_SOURCE_DIRS Script)
string (REGEX REPLACE "[^;]+API[^;]+\\.cpp" "" ANNOTATED_SOURCES "${CPP_FILES}") # Stringify to preserve the semicolons
add_custom_command (OUTPUT ${OUTPUT_FILES}
COMMAND ${CMAKE_BINARY_DIR}/bin/tool/clang/AutoBinder -p ${CMAKE_BINARY_DIR} -t "${TEMPLATES}" -o ${CMAKE_CURRENT_BINARY_DIR}/generated ${ANNOTATED_SOURCES}
COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT_FILES} # TODO: fake the output - WIP
DEPENDS AutoBinder ${SOURCE_FILES}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating source files for binding script subsystems")
list (APPEND GEN_CPP_FILES ${OUTPUT_FILES})
endif ()
if (URHO3D_LUA)
# The host tool must be built natively
if (CMAKE_CROSSCOMPILING OR IOS)
@ -104,7 +152,6 @@ if (URHO3D_LUA)
# Otherwise, build it internally as per normal
add_subdirectory (../ThirdParty/toluapp/src/bin ../ThirdParty/toluapp/src/bin)
endif ()
# Use the host tool to generate source files for tolua++ API binding
file (MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/LuaScript/generated)
file (GLOB API_PKG_FILES LuaScript/pkgs/*.pkg)
@ -126,8 +173,6 @@ if (URHO3D_LUA)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/LuaScript/pkgs
COMMENT "Generating tolua++ API binding on the fly for ${DIR}")
endforeach ()
else ()
list (APPEND EXCLUDED_SOURCE_DIRS LuaScript)
endif ()
# Generate platform specific export header file
@ -173,39 +218,8 @@ if (MSVC AND URHO3D_LIB_TYPE STREQUAL SHARED) # MSVC linker does not have forc
set_source_files_properties (${ALL_OBJ_FILES} PROPERTIES GENERATED TRUE)
endif ()
# Define source files
foreach (DIR Navigation Network Physics Urho2D)
string (TOUPPER URHO3D_${DIR} OPT)
if (NOT ${OPT})
list (APPEND EXCLUDED_SOURCE_DIRS ${DIR})
endif ()
endforeach ()
if (URHO3D_DATABASE)
if (URHO3D_DATABASE_ODBC)
list (APPEND EXCLUDED_SOURCE_DIRS Database/SQLite)
else ()
list (APPEND EXCLUDED_SOURCE_DIRS Database/ODBC)
endif ()
else ()
list (APPEND EXCLUDED_SOURCE_DIRS Database)
endif ()
if (URHO3D_OPENGL)
# Exclude the opposite source directory
list (APPEND EXCLUDED_SOURCE_DIRS Graphics/Direct3D9 Graphics/Direct3D11)
else ()
list (APPEND EXCLUDED_SOURCE_DIRS Graphics/OpenGL)
if (URHO3D_D3D11)
list (APPEND EXCLUDED_SOURCE_DIRS Graphics/Direct3D9)
else ()
list (APPEND EXCLUDED_SOURCE_DIRS Graphics/Direct3D11)
endif ()
endif ()
if (APPLE AND NOT IOS)
set (GLOB_OBJC_PATTERN *.m) # Should only pick up MacFileWatcher.m for MacOSX platform at the moment
endif ()
string (REPLACE ";" "/[^;]+;" EXCLUDE_PATTERNS "${EXCLUDED_SOURCE_DIRS};")
define_source_files (EXCLUDE_PATTERNS ${EXCLUDE_PATTERNS} GLOB_CPP_PATTERNS *.cpp ${GLOB_OBJC_PATTERN} EXTRA_H_FILES librevision.h Urho3D.h RECURSE GROUP PCH Precompiled.h)
list (APPEND SOURCE_FILES ${GEN_CPP_FILES} ${ALL_OBJ_FILES})
# Aggregate all source files
list (APPEND SOURCE_FILES ${GEN_CPP_FILES} ${ALL_OBJ_FILES} librevision.h Urho3D.h)
# Define dependency libs
# Add include directories to find the precompiled header, export header, and installed headers from thirdparty libs