diff --git a/hecl/.gitignore b/hecl/.gitignore index 95467dc68..3de5fc0e2 100644 --- a/hecl/.gitignore +++ b/hecl/.gitignore @@ -1,3 +1,2 @@ DataSpecRegistry.hpp -blender/hecl.zip diff --git a/hecl/bintoc/CMakeLists.txt b/hecl/bintoc/CMakeLists.txt index 0a26da063..3c478ed23 100644 --- a/hecl/bintoc/CMakeLists.txt +++ b/hecl/bintoc/CMakeLists.txt @@ -1,6 +1,16 @@ add_executable(bintoc bintoc.c) macro(bintoc out in sym) - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${out} - COMMAND $ ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${in} ${CMAKE_CURRENT_BINARY_DIR}/${out} ${sym} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${in}) + if(IS_ABSOLUTE ${out}) + set(theOut ${out}) + else() + set(theOut ${CMAKE_CURRENT_BINARY_DIR}/${out}) + endif() + if(IS_ABSOLUTE ${in}) + set(theIn ${in}) + else() + set(theIn ${CMAKE_CURRENT_SOURCE_DIR}/${in}) + endif() + add_custom_command(OUTPUT ${theOut} + COMMAND $ ARGS ${theIn} ${theOut} ${sym} + DEPENDS ${theIn}) endmacro() diff --git a/hecl/blender/BlenderConnection.cpp b/hecl/blender/BlenderConnection.cpp index 10568c7fa..e0995b4e2 100644 --- a/hecl/blender/BlenderConnection.cpp +++ b/hecl/blender/BlenderConnection.cpp @@ -123,6 +123,8 @@ void BlenderConnection::_closePipe() BlenderConnection::BlenderConnection(bool silenceBlender) { + BlenderLog.report(LogVisor::Info, "Establishing BlenderConnection..."); + /* Put hecl_blendershell.py in temp dir */ #ifdef _WIN32 wchar_t* TMPDIR = _wgetenv(L"TEMP"); @@ -143,6 +145,7 @@ BlenderConnection::BlenderConnection(bool silenceBlender) HECL::SystemString blenderAddonPath(TMPDIR); blenderAddonPath += _S("/hecl_blenderaddon.zip"); + InstallAddon(blenderAddonPath.c_str()); int installAttempt = 0; while (true) @@ -182,12 +185,8 @@ BlenderConnection::BlenderConnection(bool silenceBlender) } wchar_t cmdLine[2048]; - if (installAttempt == 1) - _snwprintf(cmdLine, 2048, L" --background -P \"%s\" -- %" PRIuPTR " %" PRIuPTR " \"%s\"", - blenderShellPath.c_str(), uintptr_t(writehandle), uintptr_t(readhandle), blenderAddonPath.c_str()); - else - _snwprintf(cmdLine, 2048, L" --background -P \"%s\" -- %" PRIuPTR " %" PRIuPTR, - blenderShellPath.c_str(), uintptr_t(writehandle), uintptr_t(readhandle)); + _snwprintf(cmdLine, 2048, L" --background -P \"%s\" -- %" PRIuPTR " %" PRIuPTR " \"%s\"", + blenderShellPath.c_str(), uintptr_t(writehandle), uintptr_t(readhandle), blenderAddonPath.c_str()); STARTUPINFO sinfo = {sizeof(STARTUPINFO)}; HANDLE nulHandle = NULL; @@ -238,14 +237,9 @@ BlenderConnection::BlenderConnection(bool silenceBlender) /* Try user-specified blender first */ if (blenderBin) { - if (installAttempt == 1) - execlp(blenderBin, blenderBin, - "--background", "-P", blenderShellPath.c_str(), - "--", readfds, writefds, blenderAddonPath.c_str(), NULL); - else - execlp(blenderBin, blenderBin, - "--background", "-P", blenderShellPath.c_str(), - "--", readfds, writefds, NULL); + execlp(blenderBin, blenderBin, + "--background", "-P", blenderShellPath.c_str(), + "--", readfds, writefds, blenderAddonPath.c_str(), NULL); if (errno != ENOENT) { snprintf(errbuf, 256, "NOLAUNCH %s\n", strerror(errno)); @@ -255,14 +249,9 @@ BlenderConnection::BlenderConnection(bool silenceBlender) } /* Otherwise default blender */ - if (installAttempt == 1) - execlp(DEFAULT_BLENDER_BIN, DEFAULT_BLENDER_BIN, - "--background", "-P", blenderShellPath.c_str(), - "--", readfds, writefds, blenderAddonPath.c_str(), NULL); - else - execlp(DEFAULT_BLENDER_BIN, DEFAULT_BLENDER_BIN, - "--background", "-P", blenderShellPath.c_str(), - "--", readfds, writefds, NULL); + execlp(DEFAULT_BLENDER_BIN, DEFAULT_BLENDER_BIN, + "--background", "-P", blenderShellPath.c_str(), + "--", readfds, writefds, blenderAddonPath.c_str(), NULL); if (errno != ENOENT) { snprintf(errbuf, 256, "NOLAUNCH %s\n", strerror(errno)); diff --git a/hecl/blender/CMakeLists.txt b/hecl/blender/CMakeLists.txt index ba4292405..bed0eb2e2 100644 --- a/hecl/blender/CMakeLists.txt +++ b/hecl/blender/CMakeLists.txt @@ -13,20 +13,18 @@ list(APPEND PY_SOURCES bintoc(hecl_blendershell.c hecl_blendershell.py HECL_BLENDERSHELL) -if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/hecl.zip) -message("-- Generating addon package") -execute_process(COMMAND python zip_package.py - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) -if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/hecl.zip) -message(FATAL_ERROR "Unable to generate ${CMAKE_CURRENT_SOURCE_DIR}/hecl.zip; is python installed?") -endif() -endif() -bintoc(hecl_addon.c hecl.zip HECL_ADDON) +add_custom_command(OUTPUT hecl.zip DEPENDS ${PY_SOURCES} + COMMAND python ARGS zip_package.py ${CMAKE_CURRENT_BINARY_DIR}/hecl.zip + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMENT "Generating addon package") +bintoc(hecl_addon.c "${CMAKE_CURRENT_BINARY_DIR}/hecl.zip" HECL_ADDON) add_library(HECLBlender BlenderConnection.cpp BlenderConnection.hpp hecl_blendershell.py hecl_blendershell.c + zip_package.py + hecl.zip hecl_addon.c ${PY_SOURCES}) diff --git a/hecl/blender/zip_package.py b/hecl/blender/zip_package.py index c81f193b7..2bcb8703f 100644 --- a/hecl/blender/zip_package.py +++ b/hecl/blender/zip_package.py @@ -8,7 +8,7 @@ def zipdir(path, ziph): ziph.write(os.path.join(root, file)) package_path = 'hecl' -target_zip = 'hecl.zip' +target_zip = sys.argv[1] zf = zipfile.ZipFile(target_zip, mode='w', compression=zipfile.ZIP_DEFLATED) print('GENERATING', target_zip)