summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2016-03-06 02:42:09 +0100
committerSuren A. Chilingaryan <csa@suren.me>2016-03-06 02:42:09 +0100
commit0dce5c26ecec594b3f25b9e003c830874a690e1c (patch)
tree9909c8e8674723758d98b98e9b84e9c610562375
parent43029f91d06a76fc38b85e283d368c1d06fcbc61 (diff)
downloadpcitool-0dce5c26ecec594b3f25b9e003c830874a690e1c.tar.gz
pcitool-0dce5c26ecec594b3f25b9e003c830874a690e1c.tar.bz2
pcitool-0dce5c26ecec594b3f25b9e003c830874a690e1c.tar.xz
pcitool-0dce5c26ecec594b3f25b9e003c830874a690e1c.zip
Clean-up python files during the clean and do not delete driver Makefile while packaging
-rw-r--r--CMakeLists.txt11
-rw-r--r--cmake/tools.cmake15
-rw-r--r--pywrap/CMakeLists.txt4
3 files changed, 28 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index aedc6e2..f0edd76 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -72,6 +72,7 @@ set(EXTRA_SYSTEM_LIBS -lrt)
add_definitions("-fPIC --std=c99 -Wall -O2 -gdwarf-2 -g3 -fno-omit-frame-pointer")
#add_definitions("-fPIC --std=c99 -Wall -O2")
+include(cmake/tools.cmake)
include(cmake/version.cmake)
VERSION_TO_VARS(${PCILIB_VERSION} PCILIB_VERSION_MAJOR PCILIB_VERSION_MINOR PCILIB_VERSION_MICRO)
@@ -182,7 +183,7 @@ if (${RELEASE} GREATER 0)
else (${RELEASE} GREATER 0)
set(CPACK_PACKAGE_VERSION "${PACKAGE_VERSION}")
endif (${RELEASE} GREATER 0)
-set(CPACK_SOURCE_IGNORE_FILES "/build/;/.bzr/;CMakeFiles;_CPack_Packages;cmake_install.cmake;CPack.*.cmake;CMakeCache.txt;install_manifest.txt;config.h$;.pc$;Makefile;.tar.bz2$;~$;${CPACK_SOURCE_IGNORE_FILES}")
+set(CPACK_SOURCE_IGNORE_FILES "/build/;/.bzr/;CMakeFiles;_CPack_Packages;cmake_install.cmake;CPack.*.cmake;CMakeCache.txt;install_manifest.txt;common.mk;config.h$;.pc$;/([^d]|d[^r])[^/]*/Makefile;__pycache__;.pyc$;.tar.bz2$;~$;${CPACK_SOURCE_IGNORE_FILES}")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION}")
include(CPack)
@@ -196,7 +197,10 @@ if(EXISTS ${CMAKE_SOURCE_DIR}/.bzr/)
add_dependencies(pci build)
# We need to generate build.h for source releases
- add_custom_target(dist_clean COMMAND ${CMAKE_MAKE_PROGRAM} clean WORKING_DIRECTORY ${CMAKE_CURRENT_DIR})
+ add_custom_target(dist_clean
+ COMMAND make clean WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/driver
+ COMMAND ${CMAKE_MAKE_PROGRAM} clean WORKING_DIRECTORY ${CMAKE_CURRENT_DIR}
+ )
add_custom_target(dist_prepare DEPENDS dist_clean
COMMAND ${CMAKE_COMMAND} -DPCILIB_SOURCE_DIR=${CMAKE_SOURCE_DIR} -DPCILIB_BINARY_DIR=${CMAKE_SOURCE_DIR} -DPCILIB_RELEASE=${CPACK_PACKAGE_VERSION} -P ${CMAKE_SOURCE_DIR}/cmake/build.cmake
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
@@ -232,5 +236,8 @@ if (NOT DISABLE_SERVERS)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/misc/pcilib.sysconfig.in ${CMAKE_CURRENT_BINARY_DIR}/misc/pcilib.sysconfig)
endif (NOT DISABLE_SERVERS)
+PYTHON_CLEAN_LIST("${CMAKE_BINARY_DIR}/xml" XML_PY_FILES)
+PYTHON_CLEAN_LIST("${CMAKE_BINARY_DIR}/pyserver" SERVER_PY_FILES)
+set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${XML_PY_FILES};${SERVER_PY_FILES}")
message("-- Configured pcitool ${PCILIB_VERSION_MAJOR}.${PCILIB_VERSION_MINOR}.${PCILIB_VERSION_MICRO} with public ABI ${PCILIB_ABI_VERSION}")
diff --git a/cmake/tools.cmake b/cmake/tools.cmake
new file mode 100644
index 0000000..3526dba
--- /dev/null
+++ b/cmake/tools.cmake
@@ -0,0 +1,15 @@
+MACRO(PYTHON_CLEAN_LIST PYPATH RESULT)
+ file(GLOB_RECURSE PYTHON_FILES "${PYPATH}/*.py")
+
+ set(CLEAN_LIST "")
+ set(PYTHON_DIRS "")
+ foreach(ITEM ${PYTHON_FILES})
+ get_filename_component(DIR ${ITEM} PATH) # Later version may require to use DIRECTORY instead of PATH
+ list(APPEND PYTHON_DIRS "${DIR}/__pycache__")
+ list(APPEND CLEAN_LIST "${ITEM}c")
+ endforeach(ITEM ${PYTHON_FILES})
+ list(REMOVE_DUPLICATES PYTHON_DIRS)
+ list(APPEND CLEAN_LIST ${PYTHON_DIRS})
+
+ set(${RESULT} ${CLEAN_LIST})
+ENDMACRO(PYTHON_CLEAN_LIST PYPATH CLEAN_LIST)
diff --git a/pywrap/CMakeLists.txt b/pywrap/CMakeLists.txt
index 033298e..f278b86 100644
--- a/pywrap/CMakeLists.txt
+++ b/pywrap/CMakeLists.txt
@@ -24,3 +24,7 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pcilib.py DESTINATION ${PYTHON_INSTALL
if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test_pcilib.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
endif(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
+
+set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "__pycache__;pcilib.pyc;pcipywrap.pyc")
+
+