This is an automated email from the ASF dual-hosted git repository.

emmenlau pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git


The following commit(s) were added to refs/heads/master by this push:
     new 037916b  CMake: Added better dependency tracking for external build 
tools
     new 1d905de  Merge pull request #2141 from 
BioDataAnalysis/bda_better_external_source_deps
037916b is described below

commit 037916b45d28fea865ab22e55a23e3702b70da73
Author: Mario Emmenlauer <[email protected]>
AuthorDate: Mon May 11 16:19:44 2020 +0200

    CMake: Added better dependency tracking for external build tools
---
 lib/java/CMakeLists.txt | 22 ++++++++++++++--------
 lib/js/CMakeLists.txt   |  9 +++++++--
 2 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/lib/java/CMakeLists.txt b/lib/java/CMakeLists.txt
index 28158c0..b9bfc81 100644
--- a/lib/java/CMakeLists.txt
+++ b/lib/java/CMakeLists.txt
@@ -48,19 +48,25 @@ else()
         set(PRELEASE "false")
     endif ()
 
-    add_custom_target(ThriftJava ALL
+    file(GLOB_RECURSE THRIFTJAVA_SOURCES LIST_DIRECTORIES false
+        "${CMAKE_CURRENT_SOURCE_DIR}/src/*")
+    add_custom_command(OUTPUT 
"${CMAKE_CURRENT_BINARY_DIR}/build/libs/libthrift.jar"
         COMMENT "Building Java library using Gradle Wrapper"
         COMMAND ${GRADLEW_EXECUTABLE} ${GRADLE_OPTS} assemble
             --console=plain --no-daemon
             -Prelease=${PRELEASE}
             -Pthrift.version=${thrift_VERSION}
             "-Pbuild.dir=${CMAKE_CURRENT_BINARY_DIR}/build"
+        DEPENDS ${THRIFTJAVA_SOURCES}
         WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
     )
+    add_custom_target(ThriftJava ALL
+        DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/build/libs/libthrift.jar")
 
     # Enable publishing from CMake if the publishing information is provided
     add_custom_target(MavenPublish
         COMMENT "Publishing Java Library to Apache Maven staging"
+        DEPENDS ThriftJava
         COMMAND ${GRADLEW_EXECUTABLE} ${GRADLE_OPTS} clean uploadArchives
             --console=plain --no-daemon
             -Prelease=${PRELEASE}
@@ -83,13 +89,13 @@ else()
 
     if(BUILD_TESTING)
         add_test(NAME JavaTest
-                COMMAND ${GRADLEW_EXECUTABLE} ${GRADLE_OPTS} test
-                    --console=plain --no-daemon
-                    -Prelease=${PRELEASE}
-                    -Pthrift.version=${thrift_VERSION}
-                    "-Pbuild.dir=${CMAKE_CURRENT_BINARY_DIR}/build"
-                    "-Pthrift.compiler=${THRIFT_COMPILER}"
-                WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+            COMMAND ${GRADLEW_EXECUTABLE} ${GRADLE_OPTS} test
+                --console=plain --no-daemon
+                -Prelease=${PRELEASE}
+                -Pthrift.version=${thrift_VERSION}
+                "-Pbuild.dir=${CMAKE_CURRENT_BINARY_DIR}/build"
+                "-Pthrift.compiler=${THRIFT_COMPILER}"
+            WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
     endif()
 
 endif()
diff --git a/lib/js/CMakeLists.txt b/lib/js/CMakeLists.txt
index c312a21..115b46e 100644
--- a/lib/js/CMakeLists.txt
+++ b/lib/js/CMakeLists.txt
@@ -38,12 +38,17 @@ add_custom_target(ThriftJavascriptPreDeps ALL
     WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
 )
 
-add_custom_target(ThriftJavascript ALL
+file(GLOB_RECURSE THRIFTJAVASCRIPT_SOURCES LIST_DIRECTORIES false
+    "${CMAKE_CURRENT_SOURCE_DIR}/*")
+list(FILTER THRIFTJAVASCRIPT_SOURCES EXCLUDE REGEX ".*/(dist|doc)/.*")
+add_custom_command(OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/dist/thrift.js"
     COMMENT "Building Javascript library using npx Grunt wrapper"
-    DEPENDS ThriftJavascriptPreDeps
+    DEPENDS ThriftJavascriptPreDeps ${THRIFTJAVASCRIPT_SOURCES}
     COMMAND npx grunt
     WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
 )
+add_custom_target(ThriftJavascript ALL
+    DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/dist/thrift.js")
 
 install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/dist/"
         DESTINATION "${JAVASCRIPT_INSTALL_DIR}"

Reply via email to