mirror of
https://github.com/reactos/CMake.git
synced 2024-11-23 11:39:48 +00:00
Merge topic 'UseJava-clean-stale'
4559eb490a
UseJava: clean class files from previous builds
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Leonid Pospelov <pospelovlm@yandex.ru>
Merge-request: !4381
This commit is contained in:
commit
a4c873fc5d
@ -597,7 +597,10 @@ function(add_jar _TARGET_NAME)
|
||||
# Create the list of files to compile.
|
||||
set(_JAVA_SOURCES_FILE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_sources)
|
||||
string(REPLACE ";" "\"\n\"" _JAVA_COMPILE_STRING "\"${_JAVA_COMPILE_FILES}\"")
|
||||
file(WRITE ${_JAVA_SOURCES_FILE} ${_JAVA_COMPILE_STRING})
|
||||
set(CMAKE_CONFIGURABLE_FILE_CONTENT "${_JAVA_COMPILE_STRING}")
|
||||
configure_file("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in"
|
||||
"${_JAVA_SOURCES_FILE}" @ONLY)
|
||||
unset(CMAKE_CONFIGURABLE_FILE_CONTENT)
|
||||
list (APPEND _JAVA_SOURCES_FILELISTS "@${_JAVA_SOURCES_FILE}")
|
||||
endif()
|
||||
if (_JAVA_COMPILE_FILELISTS)
|
||||
@ -610,6 +613,10 @@ function(add_jar _TARGET_NAME)
|
||||
add_custom_command(
|
||||
# NOTE: this command generates an artificial dependency file
|
||||
OUTPUT ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DCMAKE_JAVA_CLASS_OUTPUT_PATH=${CMAKE_JAVA_CLASS_OUTPUT_PATH}
|
||||
-DCMAKE_JAR_CLASSES_PREFIX="${CMAKE_JAR_CLASSES_PREFIX}"
|
||||
-P ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/UseJava/ClearClassFiles.cmake
|
||||
COMMAND ${Java_JAVAC_EXECUTABLE}
|
||||
${CMAKE_JAVA_COMPILE_FLAGS}
|
||||
-classpath "${CMAKE_JAVA_INCLUDE_PATH_FINAL}"
|
||||
@ -617,7 +624,7 @@ function(add_jar _TARGET_NAME)
|
||||
${_GENERATE_NATIVE_HEADERS}
|
||||
${_JAVA_SOURCES_FILELISTS}
|
||||
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME}
|
||||
DEPENDS ${_JAVA_COMPILE_FILES} ${_JAVA_COMPILE_FILELISTS} ${_JAVA_COMPILE_DEPENDS}
|
||||
DEPENDS ${_JAVA_COMPILE_FILES} ${_JAVA_COMPILE_FILELISTS} ${_JAVA_COMPILE_DEPENDS} ${_JAVA_SOURCES_FILE}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMENT "Building Java objects for ${_TARGET_NAME}.jar"
|
||||
)
|
||||
|
17
Modules/UseJava/ClearClassFiles.cmake
Normal file
17
Modules/UseJava/ClearClassFiles.cmake
Normal file
@ -0,0 +1,17 @@
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
# This script deletes compiled Java class files.
|
||||
|
||||
if(CMAKE_JAVA_CLASS_OUTPUT_PATH)
|
||||
if(EXISTS "${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist")
|
||||
file(STRINGS "${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist" classes)
|
||||
list(TRANSFORM classes PREPEND "${CMAKE_JAVA_CLASS_OUTPUT_PATH}/")
|
||||
if(classes)
|
||||
file(REMOVE ${classes})
|
||||
message(STATUS "Clean class files from previous build")
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "Can't find CMAKE_JAVA_CLASS_OUTPUT_PATH")
|
||||
endif()
|
Loading…
Reference in New Issue
Block a user