diff options
author | Endi Sukma Dewata <edewata@redhat.com> | 2012-07-18 13:13:34 -0500 |
---|---|---|
committer | Endi Sukma Dewata <edewata@redhat.com> | 2012-07-19 22:41:13 -0500 |
commit | 4f7af51285d9b8991929d7e01b3ae6a980e53eb5 (patch) | |
tree | 3dfaf346751928c6066ffaf2c9ad4c4c73627818 | |
parent | aa8a82d5d09ec621f2b100ccdd27ffdc6df541d0 (diff) | |
download | pki-4f7af51285d9b8991929d7e01b3ae6a980e53eb5.tar.gz pki-4f7af51285d9b8991929d7e01b3ae6a980e53eb5.tar.xz pki-4f7af51285d9b8991929d7e01b3ae6a980e53eb5.zip |
Added support for exclusion in Java CMake script.
The Java CMake scripts has been modified to support excluding some
files from compilation or JAR packaging.
Ticket #62
-rw-r--r-- | cmake/Modules/Java.cmake | 28 | ||||
-rw-r--r-- | cmake/Modules/JavaFileList.cmake | 22 |
2 files changed, 38 insertions, 12 deletions
diff --git a/cmake/Modules/Java.cmake b/cmake/Modules/Java.cmake index bab17f541..62f26f9fc 100644 --- a/cmake/Modules/Java.cmake +++ b/cmake/Modules/Java.cmake @@ -24,10 +24,10 @@ function(javac target) foreach (arg ${ARGN}) - if (arg MATCHES "(SOURCE_DIR|SOURCES|CLASSPATH|OUTPUT_DIR|DEPENDS)") + if (arg MATCHES "(SOURCE_DIR|SOURCES|EXCLUDE|CLASSPATH|OUTPUT_DIR|DEPENDS)") set(param ${arg}) - else (arg MATCHES "(SOURCE_DIR|SOURCES|CLASSPATH|OUTPUT_DIR|DEPENDS)") + else (arg MATCHES "(SOURCE_DIR|SOURCES|EXCLUDE|CLASSPATH|OUTPUT_DIR|DEPENDS)") if (param MATCHES "SOURCE_DIR") set(source_dir ${arg}) @@ -35,6 +35,9 @@ function(javac target) elseif (param MATCHES "SOURCES") list(APPEND sources ${arg}) + elseif (param MATCHES "EXCLUDE") + list(APPEND exclude ${arg}) + elseif (param MATCHES "CLASSPATH") list(APPEND classpath ${arg}) @@ -46,7 +49,7 @@ function(javac target) endif(param MATCHES "SOURCE_DIR") - endif(arg MATCHES "(SOURCE_DIR|SOURCES|CLASSPATH|OUTPUT_DIR|DEPENDS)") + endif(arg MATCHES "(SOURCE_DIR|SOURCES|EXCLUDE|CLASSPATH|OUTPUT_DIR|DEPENDS)") endforeach(arg) @@ -60,22 +63,23 @@ function(javac target) set(native_classpath "${native_classpath}${separator}${path}") endforeach(path) - set(filelist "${CMAKE_CURRENT_BINARY_DIR}/${target}.files") + set(file_list "${CMAKE_CURRENT_BINARY_DIR}/${target}.files") add_custom_target(${target} ALL DEPENDS ${depends}) add_custom_command( TARGET ${target} COMMAND ${CMAKE_COMMAND} - -Doutput=${filelist} + -Doutput=${file_list} -Dinput_dir=${source_dir} -Dfiles="${sources}" + -Dexclude="${exclude}" -P ${CMAKE_MODULE_PATH}/JavaFileList.cmake COMMAND ${CMAKE_Java_COMPILER} ${CMAKE_JAVA_COMPILE_FLAGS} -cp ${native_classpath} -d ${output_dir} - @${filelist} + @${file_list} WORKING_DIRECTORY ${source_dir} ) @@ -96,7 +100,7 @@ function(jar target) set(param ${arg}) set(operation "u") - elseif (arg MATCHES "(INPUT_DIR|FILES|DEPENDS)") + elseif (arg MATCHES "(INPUT_DIR|FILES|EXCLUDE|DEPENDS)") set(param ${arg}) else () @@ -110,6 +114,9 @@ function(jar target) elseif (param MATCHES "FILES") list(APPEND files ${arg}) + elseif (param MATCHES "EXCLUDE") + list(APPEND exclude ${arg}) + elseif (param MATCHES "DEPENDS") list(APPEND depends ${arg}) @@ -119,20 +126,21 @@ function(jar target) endforeach(arg) - set(filelist "${CMAKE_CURRENT_BINARY_DIR}/${target}.files") + set(file_list "${CMAKE_CURRENT_BINARY_DIR}/${target}.files") add_custom_target(${target} ALL DEPENDS ${depends}) add_custom_command( TARGET ${target} COMMAND ${CMAKE_COMMAND} - -Doutput=${filelist} + -Doutput=${file_list} -Dinput_dir=${input_dir} -Dfiles="${files}" + -Dexclude="${exclude}" -P ${CMAKE_MODULE_PATH}/JavaFileList.cmake COMMAND ${CMAKE_Java_ARCHIVE} -${operation}f ${output} - @${filelist} + -C ${input_dir} @${file_list} WORKING_DIRECTORY ${input_dir} ) diff --git a/cmake/Modules/JavaFileList.cmake b/cmake/Modules/JavaFileList.cmake index 6ebdaea12..ef6f99f2d 100644 --- a/cmake/Modules/JavaFileList.cmake +++ b/cmake/Modules/JavaFileList.cmake @@ -21,6 +21,18 @@ file(WRITE ${output} "") separate_arguments(file_list UNIX_COMMAND ${files}) +separate_arguments(exclude_list UNIX_COMMAND ${exclude}) + +foreach(file ${exclude_list}) + + file(GLOB_RECURSE absolute_files "${input_dir}/${file}") + + foreach(absolute_file ${absolute_files}) + file(RELATIVE_PATH relative_file ${input_dir} ${absolute_file}) + list(APPEND excluded_files ${relative_file}) + endforeach(absolute_file ${absolute_files}) + +endforeach(file ${exclude_list}) foreach(file ${file_list}) @@ -28,7 +40,13 @@ foreach(file ${file_list}) foreach(absolute_file ${absolute_files}) file(RELATIVE_PATH relative_file ${input_dir} ${absolute_file}) - file(APPEND ${output} "${relative_file}\n") + + list(FIND excluded_files ${relative_file} index) + + if (${index} EQUAL -1) + file(APPEND ${output} "${relative_file}\n") + endif(${index} EQUAL -1) + endforeach(absolute_file ${absolute_files}) -endforeach(file ${files}) +endforeach(file ${file_list}) |