]> SALOME platform Git repositories - modules/med.git/commitdiff
Salome HOME
0022778: [CEA 1298] Python file compilation should be done at build time, not install...
authorabn <adrien.bruneton@cea.fr>
Mon, 18 May 2015 14:31:31 +0000 (16:31 +0200)
committervsr <vsr@opencascade.com>
Tue, 9 Jun 2015 11:31:42 +0000 (14:31 +0300)
- Synchronisation of adm file with KERNEL (see log there) + removal of obsolete INSTALL_AND_COMPILE... CMake macro.

adm_local_without_kernel/cmake_files/SalomeMacros.cmake
src/MEDCalculator/Swig/CMakeLists.txt
src/MEDCouplingCorba_Swig/CMakeLists.txt
src/MEDCouplingCorba_Swig/Client/CMakeLists.txt
src/MEDCoupling_Swig/CMakeLists.txt
src/MEDLoader/Swig/CMakeLists.txt
src/MEDOP/tui/xmedpy/CMakeLists.txt
src/MEDPartitioner_Swig/CMakeLists.txt
src/ParaMEDMEM_Swig/CMakeLists.txt
src/RENUMBER_Swig/CMakeLists.txt

index a7cf6304ccb905fe350200ac7a14a478b4e1893a..557a5a548d5f38e489ddac782562d87986e9922d 100755 (executable)
@@ -109,59 +109,59 @@ MACRO(SALOME_INSTALL_SCRIPTS file_list path)
   IF(NOT SALOME_INSTALL_SCRIPTS_DEF_PERMS)
     SET(PERMS ${PERMS} OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE)
   ENDIF(NOT SALOME_INSTALL_SCRIPTS_DEF_PERMS)
+  SET(_all_pyc)
+  SET(_all_pyo)
+  SET(_all_subdirs)
   FOREACH(file ${file_list})
     SET(PREFIX "")
+    SET(_source_prefix "")
     GET_FILENAME_COMPONENT(file_name ${file} NAME)
     IF(NOT IS_ABSOLUTE ${file})
       IF(SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY)
            SET(PREFIX "${SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY}/")
       ENDIF(SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY)
+      SET(_source_prefix "${CMAKE_CURRENT_SOURCE_DIR}/")
     ENDIF(NOT IS_ABSOLUTE ${file})
     INSTALL(FILES ${PREFIX}${file} DESTINATION ${path} PERMISSIONS ${PERMS})
     GET_FILENAME_COMPONENT(ext ${file} EXT)
-    IF(ext STREQUAL .py)
-      # FILE TIMESTAMP command appears in cmake-2.8.11
-      IF(${CMAKE_VERSION} VERSION_LESS "2.8.11")
-        INSTALL(CODE "MESSAGE(STATUS \"py compiling ${CMAKE_INSTALL_PREFIX}/${path}/${file_name}\")")
-        INSTALL(CODE "SET(CMD \"import py_compile ; py_compile.compile('${CMAKE_INSTALL_PREFIX}/${path}/${file_name}')\")")
-        INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c \"\${CMD}\")")
-        INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -O -c \"\${CMD}\")")
-      ELSE(${CMAKE_VERSION} VERSION_LESS "2.8.11")
-        GET_FILENAME_COMPONENT(file_we ${file_name} NAME_WE)
-        INSTALL(CODE "SET(CMD \"import py_compile ; py_compile.compile('${CMAKE_INSTALL_PREFIX}/${path}/${file_name}')\")")
-        INSTALL(CODE "FILE(TIMESTAMP \"${CMAKE_INSTALL_PREFIX}/${path}/${file_name}\"            py_time)")
-        INSTALL(CODE "IF(EXISTS \"${CMAKE_INSTALL_PREFIX}/${path}/${file_we}.pyc\") \n  FILE(TIMESTAMP \"${CMAKE_INSTALL_PREFIX}/${path}/${file_we}.pyc\" pyc_time) \n ELSE()\n  SET(pyc_time 0) \n ENDIF() ")
-        INSTALL(CODE "IF(EXISTS \"${CMAKE_INSTALL_PREFIX}/${path}/${file_we}.pyo\") \n  FILE(TIMESTAMP \"${CMAKE_INSTALL_PREFIX}/${path}/${file_we}.pyo\" pyo_time) \n ELSE()\n  SET(pyo_time 0) \n ENDIF() ")
-        #INSTALL(CODE "MESSAGE(STATUS \"\${py_time} \${pyc_time} \")")
-        INSTALL(CODE "STRING(COMPARE LESS \${pyc_time} \${py_time} to_install_pyc)")
-        INSTALL(CODE "STRING(COMPARE LESS \${pyo_time} \${py_time} to_install_pyo)")
-        INSTALL(CODE "IF (\${to_install_pyc} OR \${to_install_pyo}) \n MESSAGE(STATUS \"py compiling ${CMAKE_INSTALL_PREFIX}/${path}/${file_name}\") \n ENDIF()")
-        INSTALL(CODE "IF (\${to_install_pyc}) \n EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c \"\${CMD}\") \n ENDIF()")
-        INSTALL(CODE "IF (\${to_install_pyo}) \n EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -O -c \"\${CMD}\") \n ENDIF()")
-      ENDIF(${CMAKE_VERSION} VERSION_LESS "2.8.11")
+    GET_FILENAME_COMPONENT(we_ext ${file} NAME_WE)
+    GET_FILENAME_COMPONENT(single_dir ${CMAKE_CURRENT_SOURCE_DIR} NAME_WE) 
+    IF(ext STREQUAL .py)    
+      # Generate and install the pyc and pyo
+      # [ABN] Important: we avoid references or usage of CMAKE_INSTALL_PREFIX which is not correctly set 
+      # when using CPack.       
+      SET(_pyc_file "${CMAKE_CURRENT_BINARY_DIR}/${we_ext}.pyc")
+      SET(_pyo_file "${CMAKE_CURRENT_BINARY_DIR}/${we_ext}.pyo")
+      LIST(APPEND _all_pyc ${_pyc_file})
+      LIST(APPEND _all_pyo ${_pyo_file})
+      ADD_CUSTOM_COMMAND(
+           OUTPUT ${_pyc_file}
+           COMMAND ${PYTHON_EXECUTABLE} -c "import py_compile ; py_compile.compile('${_source_prefix}${file}', '${_pyc_file}' )"
+           DEPENDS ${PREFIX}${file}
+           VERBATIM
+       )
+      ADD_CUSTOM_COMMAND(
+           OUTPUT ${_pyo_file}
+           COMMAND ${PYTHON_EXECUTABLE} -O -c "import py_compile ; py_compile.compile('${_source_prefix}${file}', '${_pyo_file}' )"
+           DEPENDS ${PREFIX}${file}
+           VERBATIM
+       )
+      # Install the .pyo and the .pyc
+      INSTALL(FILES ${_pyc_file} DESTINATION ${path} PERMISSIONS ${PERMS})
+      INSTALL(FILES ${_pyo_file} DESTINATION ${path} PERMISSIONS ${PERMS})
     ENDIF(ext STREQUAL .py)
   ENDFOREACH(file ${file_list})
+  # Generate only one target for all requested Python script compilation.
+  # Make sure that the target name is unique too. 
+  IF(_all_pyc)
+     SET(_cnt 0)
+     WHILE(TARGET "PYCOMPILE_${single_dir}_${_cnt}")
+       MATH(EXPR _cnt ${_cnt}+1)
+     ENDWHILE()
+     ADD_CUSTOM_TARGET("PYCOMPILE_${single_dir}_${_cnt}" ALL DEPENDS ${_all_pyc} ${_all_pyo})
+  ENDIF()
 ENDMACRO(SALOME_INSTALL_SCRIPTS)
 
-#----------------------------------------------------------------------------
-# SALOME_INSTALL_SCRIPTS is a macro useful for installing executable scripts.
-# ARGUMENTS:
-# PYFILE2COMPINST: IN : list of python files to be installed.
-# PYFILELOC: IN : full pathname for installing.
-# Permissions of installed files: OWNER_WRITE, OWNER_READ, GROUP_READ, and WORLD_READ
-#----------------------------------------------------------------------------
-MACRO(INSTALL_AND_COMPILE_PYTHON_FILE PYFILE2COMPINST PYFILELOC)
-  INSTALL(CODE "SET(PYTHON_FILE ${f})")
-  FOREACH(input ${PYFILE2COMPINST})
-    GET_FILENAME_COMPONENT(inputname ${input} NAME)
-    INSTALL(FILES ${input} DESTINATION ${CMAKE_INSTALL_PREFIX}/${PYFILELOC})
-    INSTALL(CODE "MESSAGE(STATUS \"py compiling ${CMAKE_INSTALL_PREFIX}/${PYFILELOC}/${inputname}\")")
-    INSTALL(CODE "SET(CMD \"import py_compile ; py_compile.compile('${CMAKE_INSTALL_PREFIX}/${PYFILELOC}/${inputname}')\")")
-    INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c \"\${CMD}\")")
-    INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -O -c \"\${CMD}\")")
-  ENDFOREACH(input ${PYFILE2COMPINST})
-ENDMACRO(INSTALL_AND_COMPILE_PYTHON_FILE PYFILE2COMPINST PYFILELOC)
-
 #----------------------------------------------------------------------------
 # SALOME_CONFIGURE_FILE is a macro useful for copying a file to another location 
 # and modify its contents.
index b0c7c23535e090f2a692fa4fba698ec1261e8983..8178393137a06a12e3e57a7149d49cfd1a9a2ff4 100644 (file)
@@ -60,4 +60,4 @@ FILE(GLOB medcalculatorspython_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx")
 INSTALL(FILES ${medcalculatorspython_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS})
 INSTALL(TARGETS _MEDCalculator DESTINATION ${SALOME_INSTALL_PYTHON})
 INSTALL(FILES MEDCalculator.i MEDCalculatorTypemaps.i DESTINATION ${SALOME_INSTALL_HEADERS})
-INSTALL_AND_COMPILE_PYTHON_FILE(${CMAKE_CURRENT_BINARY_DIR}/MEDCalculator.py ${SALOME_INSTALL_PYTHON})
+SALOME_INSTALL_SCRIPTS(${CMAKE_CURRENT_BINARY_DIR}/MEDCalculator.py ${SALOME_INSTALL_PYTHON})
index b5d7f1e9af4d397250a943085277c60f857ba735..7bac79b2ad9a79fa17eee06419e9dcd996b6296a 100644 (file)
@@ -59,4 +59,4 @@ ENDIF(WIN32)
 INSTALL(TARGETS _MEDCouplingCorba DESTINATION ${SALOME_INSTALL_PYTHON})
 INSTALL(FILES MEDCouplingCorba.i MEDCouplingCorbaTypemaps.i DESTINATION ${SALOME_INSTALL_HEADERS})
 SET(PYFILES_TO_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/MEDCouplingCorba.py)
-INSTALL_AND_COMPILE_PYTHON_FILE("${PYFILES_TO_INSTALL}" ${SALOME_INSTALL_PYTHON})
+SALOME_INSTALL_SCRIPTS("${PYFILES_TO_INSTALL}" ${SALOME_INSTALL_PYTHON})
index 526d240e1c69535a6bfa912ae38f466b141ba58d..8e346651632c66f52782fe8895ffe24a5668efaf 100644 (file)
@@ -48,4 +48,4 @@ ENDIF(WIN32)
 INSTALL(TARGETS _MEDCouplingClient DESTINATION ${SALOME_INSTALL_PYTHON})
 INSTALL(FILES MEDCouplingClient.i DESTINATION ${SALOME_INSTALL_HEADERS})
 SET(PYFILES_TO_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/MEDCouplingClient.py)
-INSTALL_AND_COMPILE_PYTHON_FILE("${PYFILES_TO_INSTALL}" ${SALOME_INSTALL_PYTHON})
+SALOME_INSTALL_SCRIPTS("${PYFILES_TO_INSTALL}" ${SALOME_INSTALL_PYTHON})
index edb7d4a002d8b56b83317de27e6c272db53d88b2..4d218def54503e5e2b0f6f443dca94ca176e8094 100644 (file)
@@ -72,7 +72,7 @@ ENDIF(WIN32)
 INSTALL(TARGETS ${SWIG_MODULE_MEDCoupling_REAL_NAME} ${SWIG_MODULE_MEDCouplingRemapper_REAL_NAME} DESTINATION ${SALOME_INSTALL_PYTHON})
 
 SET(PYFILES_TO_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/MEDCoupling.py ${CMAKE_CURRENT_BINARY_DIR}/MEDCouplingRemapper.py)
-INSTALL_AND_COMPILE_PYTHON_FILE("${PYFILES_TO_INSTALL}" ${SALOME_INSTALL_PYTHON})
+SALOME_INSTALL_SCRIPTS("${PYFILES_TO_INSTALL}" ${SALOME_INSTALL_PYTHON})
 
 INSTALL(FILES MEDCoupling.i MEDCouplingCommon.i MEDCouplingRefCountObject.i MEDCouplingMemArray.i MEDCouplingFieldDiscretization.i MEDCouplingTimeDiscretization.i MEDCouplingFinalize.i MEDCouplingRemapper.i MEDCouplingTypemaps.i MEDCouplingDataArrayTypemaps.i DESTINATION ${SALOME_INSTALL_HEADERS})
 INSTALL(FILES MEDCouplingBasicsTest.py MEDCouplingRemapperTest.py MEDCouplingDataForTest.py MEDCouplingNumPyTest.py MEDCouplingPickleTest.py DESTINATION ${SALOME_INSTALL_SCRIPT_PYTHON})
index c6673cdd1542b93402dfd4ee382cdfbe8c0d1e7d..4fcecf52dc5cae092297c791b2547c7f65d80b81 100644 (file)
@@ -61,7 +61,7 @@ INSTALL(TARGETS _MEDLoader DESTINATION ${SALOME_INSTALL_PYTHON})
 INSTALL(FILES MEDLoader.i MEDLoaderTypemaps.i MEDLoaderCommon.i DESTINATION ${SALOME_INSTALL_HEADERS})
 
 SET(PYFILES_TO_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/MEDLoader.py)
-INSTALL_AND_COMPILE_PYTHON_FILE("${PYFILES_TO_INSTALL}" ${SALOME_INSTALL_PYTHON})
+SALOME_INSTALL_SCRIPTS("${PYFILES_TO_INSTALL}" ${SALOME_INSTALL_PYTHON})
 
 INSTALL(FILES MEDLoaderDataForTest.py MEDLoaderTest.py MEDLoaderTest2.py MEDLoaderTest3.py MEDLoaderTest4.py SauvLoaderTest.py MEDLoaderExamplesTest.py MEDLoaderCouplingTrainingSession.py CaseIO.py CaseReader.py CaseWriter.py VTKReader.py MEDLoaderSplitter.py medutilities.py DESTINATION ${SALOME_INSTALL_SCRIPT_SCRIPTS})
 INSTALL(FILES med2sauv PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ DESTINATION ${SALOME_INSTALL_BINS} )
index 667465203197b00c32679766d9cc1dedd3a17ef6..bbc6e70c4d0e4c324784e38d7d758e7d7889b3e6 100644 (file)
@@ -32,7 +32,7 @@ SET(PYFILES_TO_INSTALL
   properties.py
   )
 
-INSTALL_AND_COMPILE_PYTHON_FILE("${PYFILES_TO_INSTALL}" ${SALOME_INSTALL_PYTHON}/xmed)
+SALOME_INSTALL_SCRIPTS("${PYFILES_TO_INSTALL}" ${SALOME_INSTALL_PYTHON}/xmed)
 
 SET(TEST_SCRIPTS_XMED
   tests/test_xmed_fieldOperations.py
index 5245aab2c444391c5cf80f421e85d67018450cb2..f203e72955da76723226f9967256a94d89b66529 100644 (file)
@@ -56,7 +56,7 @@ ENDIF(WIN32)
 INSTALL(TARGETS ${SWIG_MODULE_MEDPartitioner_REAL_NAME} DESTINATION ${SALOME_INSTALL_PYTHON})
 
 SET(PYFILES_TO_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/MEDPartitioner.py)
-INSTALL_AND_COMPILE_PYTHON_FILE("${PYFILES_TO_INSTALL}" ${SALOME_INSTALL_SCRIPT_PYTHON})
+SALOME_INSTALL_SCRIPTS("${PYFILES_TO_INSTALL}" ${SALOME_INSTALL_SCRIPT_PYTHON})
 
 INSTALL(FILES MEDPartitioner.i MEDPartitionerCommon.i DESTINATION ${SALOME_INSTALL_HEADERS})
 INSTALL(FILES MEDPartitionerTest.py DESTINATION ${SALOME_INSTALL_SCRIPT_PYTHON})
index 23b9b5d90453b3beb7f20762bfdd1529a7ef2a16..48266ae3b8e175d025c5875f9d9bfb2b1c46af69 100644 (file)
@@ -58,5 +58,5 @@ SET_SOURCE_FILES_PROPERTIES(ParaMEDMEM.i PROPERTIES SWIG_DEFINITIONS "-shadow")
 
 INSTALL(TARGETS _ParaMEDMEM DESTINATION ${SALOME_INSTALL_PYTHON})
 INSTALL(FILES ParaMEDMEM.i DESTINATION ${SALOME_INSTALL_HEADERS})
-INSTALL_AND_COMPILE_PYTHON_FILE(${CMAKE_CURRENT_BINARY_DIR}/ParaMEDMEM.py ${SALOME_INSTALL_SCRIPT_PYTHON})
+SALOME_INSTALL_SCRIPTS(${CMAKE_CURRENT_BINARY_DIR}/ParaMEDMEM.py ${SALOME_INSTALL_SCRIPT_PYTHON})
 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/ParaMEDMEM.py test_InterpKernelDEC.py test_NonCoincidentDEC.py test_StructuredCoincidentDEC.py DESTINATION ${SALOME_INSTALL_SCRIPT_PYTHON})
\ No newline at end of file
index 98007acb418a9abd113c51fa12c2c9168816db0e..c4c5943d10a73c6c6a0dfcf6deedaf49b87d9222 100644 (file)
@@ -60,7 +60,7 @@ ENDIF(WIN32)
 INSTALL(TARGETS ${SWIG_MODULE_MEDRenumber_REAL_NAME} DESTINATION ${SALOME_INSTALL_PYTHON})
 
 SET(PYFILES_TO_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/MEDRenumber.py)
-INSTALL_AND_COMPILE_PYTHON_FILE("${PYFILES_TO_INSTALL}" ${SALOME_INSTALL_SCRIPT_PYTHON})
+SALOME_INSTALL_SCRIPTS("${PYFILES_TO_INSTALL}" ${SALOME_INSTALL_SCRIPT_PYTHON})
 
 INSTALL(FILES MEDRenumber.i MEDRenumberCommon.i DESTINATION ${SALOME_INSTALL_HEADERS})
 INSTALL(FILES MEDRenumberTest.py DESTINATION ${SALOME_INSTALL_SCRIPT_PYTHON})