Pcbnew: Make scripting version compilable under Windows

This commit is contained in:
jean-pierre charras 2012-10-01 08:04:06 +02:00
commit c169de804d
3 changed files with 26 additions and 12 deletions

View File

@ -60,6 +60,12 @@ option(KICAD_SCRIPTING_WXPYTHON
"set this option ON to build wxpython implementation for wx interface building in python and py.shell" "set this option ON to build wxpython implementation for wx interface building in python and py.shell"
) )
# when option KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES is enabled:
# PYTHON_EXECUTABLE can be defined when invoking cmake
# ( use -DPYTHON_EXECUTABLE=<python path>/python.exe or python2 )
# when not defined by user, the default is python.exe under Windows and python2 for others
# python binary filee should be is exec path.
#Set version option (stable or testing) #Set version option (stable or testing)
@ -259,7 +265,15 @@ endif(WIN32 AND USE_WX_GRAPHICS_CONTEXT)
# Find Python and other scripting resources # Find Python and other scripting resources
if (KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES) if (KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES)
execute_process(COMMAND python2 -c "import sys;print\"%s.%s\"%sys.version_info[0:2]" OUTPUT_VARIABLE PYTHON_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) if( "${PYTHON_EXECUTABLE}" STREQUAL "" )
if(WIN32)
SET( PYTHON_EXECUTABLE "python.exe" )
else(WIN32)
SET( PYTHON_EXECUTABLE "python2" )
endif(WIN32)
endif()
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sys;print\"%s.%s\"%sys.version_info[0:2]" OUTPUT_VARIABLE PYTHON_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
set(PYTHON_DEST "lib/python${PYTHON_VERSION}/dist-packages" ) set(PYTHON_DEST "lib/python${PYTHON_VERSION}/dist-packages" )
find_package(PythonLibs) find_package(PythonLibs)
include_directories(${PYTHON_INCLUDE_PATH} include_directories(${PYTHON_INCLUDE_PATH}

View File

@ -301,7 +301,7 @@ if (KICAD_SCRIPTING)
DEPENDS ../scripting/kicadplugins.i DEPENDS ../scripting/kicadplugins.i
COMMAND ${SWIG_EXECUTABLE} ${SWIG_OPTS} -o ${CMAKE_CURRENT_BINARY_DIR}/pcbnew_wrap.cxx scripting/pcbnew.i COMMAND ${SWIG_EXECUTABLE} ${SWIG_OPTS} -o ${CMAKE_CURRENT_BINARY_DIR}/pcbnew_wrap.cxx scripting/pcbnew.i
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../scripting/fixswigimports.py ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../scripting/fixswigimports.py ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
) )
@ -432,9 +432,9 @@ install(TARGETS pcbnew
if(KICAD_SCRIPTING) if(KICAD_SCRIPTING)
add_custom_target(FixSwigImportsScripting ALL add_custom_target(FixSwigImportsScripting ALL
${CMAKE_CURRENT_SOURCE_DIR}/../scripting/fixswigimports.py ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../scripting/fixswigimports.py ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/pcbnew DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/pcbnew
COMMENT "Fixing swig_import_helper" COMMENT "Fixing swig_import_helper in Kicad scripting"
) )
@ -444,9 +444,9 @@ endif(KICAD_SCRIPTING)
if (KICAD_SCRIPTING_MODULES) if (KICAD_SCRIPTING_MODULES)
add_custom_target(FixSwigImportsModuleScripting ALL add_custom_target(FixSwigImportsModuleScripting ALL
${CMAKE_CURRENT_SOURCE_DIR}/../scripting/fixswigimports.py ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../scripting/fixswigimports.py ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/_pcbnew DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/_pcbnew
COMMENT "Fixing swig_import_helper" COMMENT "Fixing swig_import_helper in Kicad scripting modules"
) )

View File

@ -30,12 +30,12 @@ f.close()
doneOk = False doneOk = False
if (len(lines)<4000): if (len(lines)<4000):
print "still building" print "still building"
exit(0) exit(0)
txt = "" txt = ""
for l in lines: for l in lines:
if l.startswith("if version_info >= (2,6,0):"): if l.startswith("if version_info >= (2,6,0):"):
l = l.replace("version_info >= (2,6,0)","False") l = l.replace("version_info >= (2,6,0)","False")
@ -55,8 +55,8 @@ else:
print " and fix this script: fixswigimports.py" print " and fix this script: fixswigimports.py"
exit(2) exit(2)
exit(0) exit(0)