diff --git a/cmake/Modules/BuildPython.cmake b/cmake/Modules/BuildPython.cmake index 6cd9168a8..795303c4c 100644 --- a/cmake/Modules/BuildPython.cmake +++ b/cmake/Modules/BuildPython.cmake @@ -52,13 +52,20 @@ else() set( platform Win32 ) endif() - # @bug: This creates another .bat file and makes the original .bat file fail - # set( Python_ENV ${CMAKE_COMMAND} -E env "PATH=${Python_PATH}" -- ) - string(CONCAT Python_ENV "cmd /c \"set PATH=\"${Python_PATH}\"") - string(CONCAT Python_BUILD ${Python_ENV} && PCbuild/build.bat -e -q -p ${platform} ) - + # @bug: + # This creates another .bat file and makes the original .bat file fail + # set( Python_ENV ${CMAKE_COMMAND} -E env "PATH=${Python_PATH}" --) + + list(JOIN Python_PATH "|" Python_PATH_STR) + set(Python_SCRIPT "-DPATH=${Python_PATH_STR}" -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -P ${PROJECT_SOURCE_DIR}/cmake/build_python_windows.cmake + ) + + set(Python_BUILD ${CMAKE_COMMAND} -D Python_COMMAND=build + -D Python_PLATFORM=${platform}) + set(Python_BUILD ${Python_BUILD} ${Python_SCRIPT}) - set( Python_INSTALL ${Python_ENV} && python.bat PC/layout --precompile --preset-default --copy "${CMAKE_INSTALL_PREFIX}/bin/" ) + set(Python_INSTALL ${CMAKE_COMMAND} -D Python_COMMAND=install) + set(Python_INSTALL ${Python_INSTALL} ${Python_SCRIPT}) endif() ExternalProject_Add( diff --git a/cmake/Modules/BuildpyFLTK.cmake b/cmake/Modules/BuildpyFLTK.cmake index a0f0f7fab..92fbb5f5b 100644 --- a/cmake/Modules/BuildpyFLTK.cmake +++ b/cmake/Modules/BuildpyFLTK.cmake @@ -30,6 +30,9 @@ set(pyFLTK_LD_LIBRARY_PATH $ENV{LD_LIBRARY_PATH}) set(pyFLTK_DYLD_LIBRARY_PATH $ENV{DYLD_LIBRARY_PATH}) set(pyFLTK_PATH $ENV{PATH}) +if(WIN32) + string(REPLACE ";" "|" pyFLTK_PATH "$ENV{PATH}") +endif() # # Handle macOS min version. @@ -68,16 +71,20 @@ set(pyFLTK_PATCH COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/cmake/patches/pyFLTK-patch/swig/WindowShowTypemap.i" - "${CMAKE_BINARY_DIR}/pyFLTK-prefix/src/pyFLTK/swig/") + "${CMAKE_BINARY_DIR}/pyFLTK-prefix/src/pyFLTK/swig/" + COMMAND + ${CMAKE_COMMAND} -E copy_if_different + "${PROJECT_SOURCE_DIR}/cmake/patches/pyFLTK-patch/fltk14/test/exceptions.py" + "${CMAKE_BINARY_DIR}/pyFLTK-prefix/src/pyFLTK/fltk14/test") # Environment setup for configure, building and installing set(pyFLTK_ENV ${CMAKE_COMMAND} -E env CXXFLAGS=${pyFLTK_CXX_FLAGS} ) if(WIN32) - set(pyFLTK_ENV ${pyFLTK_ENV} PATH=${pyFLTK_PATH} FLTK_HOME=${CMAKE_INSTALL_PREFIX} --) + set(pyFLTK_ENV ${pyFLTK_ENV} "PATH=${pyFLTK_PATH}" FLTK_HOME=${CMAKE_INSTALL_PREFIX} --) elseif(APPLE) - set(pyFLTK_ENV ${pyFLTK_ENV} PATH=${pyFLTK_PATH} DYLD_LIBRARY_PATH=${pyFLTK_DYLD_LIBRARY_PATH} -- ) + set(pyFLTK_ENV ${pyFLTK_ENV} "PATH=${pyFLTK_PATH}" DYLD_LIBRARY_PATH=${pyFLTK_DYLD_LIBRARY_PATH} -- ) else() - set(pyFLTK_ENV ${pyFLTK_ENV} PATH=${pyFLTK_PATH} LD_LIBRARY_PATH=${pyFLTK_LD_LIBRARY_PATH} -- ) + set(pyFLTK_ENV ${pyFLTK_ENV} "PATH=${pyFLTK_PATH}" LD_LIBRARY_PATH=${pyFLTK_LD_LIBRARY_PATH} -- ) endif() @@ -86,7 +93,12 @@ set(pyFLTK_CONFIGURE ${pyFLTK_ENV} ${PYTHON_EXECUTABLE} setup.py swig --enable-s set(pyFLTK_BUILD ${pyFLTK_ENV} ${PYTHON_EXECUTABLE} setup.py build --enable-shared) set(pyFLTK_INSTALL ${pyFLTK_ENV} ${PYTHON_EXECUTABLE} setup.py install --enable-shared) - +# +# Output the commands +# +message(STATUS "pyFLTK_CONFIGURE=${pyFLTK_CONFIGURE}") +message(STATUS "pyFLTK_BUIILD=${pyFLTK_BUILD}") +message(STATUS "pyFLTK_INSTALL=${pyFLTK_INSTALL}") ExternalProject_Add( @@ -101,6 +113,7 @@ ExternalProject_Add( CONFIGURE_COMMAND "${pyFLTK_CONFIGURE}" BUILD_COMMAND "${pyFLTK_BUILD}" INSTALL_COMMAND "${pyFLTK_INSTALL}" + LIST_SEPARATOR | BUILD_IN_SOURCE 1 ) diff --git a/cmake/build_python_windows.cmake b/cmake/build_python_windows.cmake new file mode 100644 index 000000000..25cf0a452 --- /dev/null +++ b/cmake/build_python_windows.cmake @@ -0,0 +1,30 @@ + + +message(STATUS "Python_COMMAND=${Python_COMMAND}") +message(STATUS "CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}") +message(STATUS "PATH ENV 1=$ENV{PATH}") +message(STATUS "PATH 1=${PATH}") +string(REPLACE "|" ";" $ENV{PATH} "${PATH}") +message(STATUS "PATH ENV 2=$ENV{PATH}") + +set(ROOT_DIR ${CMAKE_INSTALL_PREFIX}/../Python-prefix/src/Python) + +if (Python_COMMAND STREQUAL "build") + set(CMD cmd /C PCbuild\\build.bat -e -q -p ${Python_PLATFORM}) +elseif(Python_COMMAND STREQUAL "install") + set(CMD cmd /C python.bat PC\\layout --precompile --preset-default --copy "${CMAKE_INSTALL_PREFIX}/bin/") +else() + message(FATAL_ERROR "Unknown Python_COMMAND ${Python_COMMAND}!") +endif() + +message(STATUS "Running: ${CMD} in ${ROOT_DIR}...") + +execute_process( + COMMAND ${CMD} + WORKING_DIRECTORY ${ROOT_DIR} + ERROR_VARIABLE BAT_CMD_ERROR + OUTPUT_VARIABLE BAT_CMD_OUTPUT + ECHO_ERROR_VARIABLE + ECHO_OUTPUT_VARIABLE + COMMAND_ERROR_IS_FATAL ANY +) diff --git a/cmake/patches/pyFLTK-patch/fltk14/test/exceptions.py b/cmake/patches/pyFLTK-patch/fltk14/test/exceptions.py new file mode 100644 index 000000000..b48b7cdd8 --- /dev/null +++ b/cmake/patches/pyFLTK-patch/fltk14/test/exceptions.py @@ -0,0 +1,67 @@ +# "$Id: demos.py 531 2019-12-27 12:15:45Z andreasheld $" +# +# Test program for pyFLTK the Python bindings +# for the Fast Light Tool Kit (FLTK). +# +# FLTK copyright 1998-1999 by Bill Spitzak and others. +# pyFLTK copyright 2003 by Andreas Held and others. +# +# This library is free software you can redistribute it and/or +# modify it under the terms of the GNU Library General Public +# License, version 2.0 as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public +# License along with this library if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# Please report all bugs and problems to "pyfltk-user@lists.sourceforge.net". +# + + +from fltk14 import * + +class subwindow(Fl_Gl_Window): + + def __init__(self, x,y,w,h): + super().__init__(x,y,w,h, "") + + def handle(self, event): + if event == FL_PUSH: + raise Exception("exception in handle") + return super().handle(event) + + def draw(self): + pass + + + +class MyButton(Fl_Button): + def __init__(self, x,y,w,h, l): + super().__init__(x,y,w,h, l) + self.callback(self.b_cb) + + def b_cb(self, wid): + raise Exception("exception in callback") + +if __name__=='__main__': + window = Fl_Double_Window(0, 0, 500, 500, "tst") + + widget = subwindow(0,0,500,400) + window.resizable(widget) + + mb = MyButton(200,420,100,60, "Exit") + + + try: + window.end() + window.show() + Fl.run() + except Exception as e: + print("Exception: ", e) + diff --git a/tlRender b/tlRender index 072c0012c..7a076e6af 160000 --- a/tlRender +++ b/tlRender @@ -1 +1 @@ -Subproject commit 072c0012c73f50377508d0ce81624a8edbf6494a +Subproject commit 7a076e6af6910e15ee76228c07bd40aa9ff10dd1