From e296548d91b462114eff7393234409de6f9f9836 Mon Sep 17 00:00:00 2001 From: "Charles K. Neimog" Date: Mon, 25 Nov 2024 15:23:17 -0300 Subject: [PATCH] fix pd4web to handle spaces --- Resources/Pd/pd4web.cpp | 16 ++++++++++------ Sources/pd4web/Builder.py | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Resources/Pd/pd4web.cpp b/Resources/Pd/pd4web.cpp index bfd8c135..a29d7812 100644 --- a/Resources/Pd/pd4web.cpp +++ b/Resources/Pd/pd4web.cpp @@ -334,15 +334,19 @@ static void pd4web_set(Pd4Web *x, t_symbol *s, int argc, t_atom *argv) { } else if ("patch" == config) { std::string newpatch; for (int i = 1; i < argc; i++) { - if (argv[i].a_type != A_SYMBOL) { - pd_error(x, "[pd4web] Invalid argument, use [set patch ]"); - return; + if (i > 1) { + newpatch += " "; + } + if (argv[i].a_type == A_SYMBOL) { + newpatch += atom_getsymbolarg(i, argc, argv)->s_name; + } else if (argv[i].a_type == A_FLOAT) { + newpatch += std::to_string(atom_getfloatarg(i, argc, argv)); + } else { + pd_error(x, "[pd4web] Invalid argument, use [set patch ]"); } - newpatch += atom_getsymbolarg(i, argc, argv)->s_name; - newpatch += " "; } x->projectRoot = std::filesystem::path(newpatch).parent_path().string(); - x->patch = newpatch; + x->patch = "\"" + newpatch + "\""; } else if ("template" == config) { int tpl = atom_getintarg(1, argc, argv); if (x->tpl == tpl) { diff --git a/Sources/pd4web/Builder.py b/Sources/pd4web/Builder.py index 777fb03b..ed9c1d7f 100644 --- a/Sources/pd4web/Builder.py +++ b/Sources/pd4web/Builder.py @@ -60,18 +60,18 @@ def InitCMakeLists(self): else: self.ProjectName = os.path.basename(self.Pd4Web.PROJECT_ROOT) self.cmakeFile.append("cmake_minimum_required(VERSION 3.25)") - self.cmakeFile.append(f"project({self.ProjectName})\n") + self.cmakeFile.append(f'project("{self.ProjectName}")\n') # Pd Sources self.cmakeFile.append("# Pd sources") self.cmakeFile.append('set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -matomics -mbulk-memory")') - self.cmakeFile.append("include(${CMAKE_CURRENT_SOURCE_DIR}/Pd4Web/libpd.cmake)") - self.cmakeFile.append("include(${CMAKE_CURRENT_SOURCE_DIR}/Pd4Web/Externals/pd.cmake)") + self.cmakeFile.append('include("${CMAKE_CURRENT_SOURCE_DIR}/Pd4Web/libpd.cmake")') + self.cmakeFile.append('include("${CMAKE_CURRENT_SOURCE_DIR}/Pd4Web/Externals/pd.cmake")') self.cmakeFile.append('set(PDCMAKE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Pd4Web/Externals/" CACHE STRING "" FORCE)') self.cmakeFile.append( 'set(PD4WEB_EXTERNAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Pd4Web/Externals/" CACHE STRING "" FORCE)' ) - self.cmakeFile.append("include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Pd4Web/pure-data/src)") + self.cmakeFile.append('include_directories("${CMAKE_CURRENT_SOURCE_DIR}/Pd4Web/pure-data/src")') self.cmakeFile.append("add_definitions(-DPDTHREADS)") self.cmakeFile.append("") @@ -106,7 +106,7 @@ def InitCMakeLists(self): targetProperties = [ "set_target_properties(pd4web PROPERTIES", - " RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/WebPatch", + ' RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/WebPatch"', ")", ] linkOptions = [ @@ -268,23 +268,23 @@ def buildExternalsObjects(self): def AddFilesToWebPatch(self): self.cmakeFile.append("\n# FileSystem for the Patch") - string = 'set_target_properties(pd4web PROPERTIES LINK_FLAGS "--preload-file ${CMAKE_CURRENT_SOURCE_DIR}/WebPatch/index.pd@/index.pd")' + #string = 'set_target_properties(pd4web PROPERTIES LINK_FLAGS "--preload-file \"${CMAKE_CURRENT_SOURCE_DIR}/WebPatch/index.pd@/index.pd\"")' + string = 'set_target_properties(pd4web PROPERTIES LINK_FLAGS "--preload-file \\"${CMAKE_CURRENT_SOURCE_DIR}/WebPatch/index.pd@/index.pd\\"")' self.cmakeFile.append(string) - if os.path.exists(self.Pd4Web.PROJECT_ROOT + "/Audios"): self.cmakeFile.append("get_target_property(EMCC_LINK_FLAGS pd4web LINK_FLAGS)") self.cmakeFile.append( - 'set_target_properties(pd4web PROPERTIES LINK_FLAGS "${EMCC_LINK_FLAGS} --preload-file ${CMAKE_CURRENT_SOURCE_DIR}/Audios@/Audios/")' + 'set_target_properties(pd4web PROPERTIES LINK_FLAGS "${EMCC_LINK_FLAGS} --preload-file \\"${CMAKE_CURRENT_SOURCE_DIR}/Audios@/Audios/\\"")' ) if os.path.exists(self.Pd4Web.PROJECT_ROOT + "/.tmp"): self.cmakeFile.append("get_target_property(EMCC_LINK_FLAGS pd4web LINK_FLAGS)") self.cmakeFile.append( - 'set_target_properties(pd4web PROPERTIES LINK_FLAGS "${EMCC_LINK_FLAGS} --preload-file ${CMAKE_CURRENT_SOURCE_DIR}/.tmp@/Libs/")' + 'set_target_properties(pd4web PROPERTIES LINK_FLAGS "${EMCC_LINK_FLAGS} --preload-file \\"${CMAKE_CURRENT_SOURCE_DIR}/.tmp@/Libs/\\"")' ) if os.path.exists(self.Pd4Web.PROJECT_ROOT + "/Extras"): self.cmakeFile.append("get_target_property(EMCC_LINK_FLAGS pd4web LINK_FLAGS)") self.cmakeFile.append( - 'set_target_properties(pd4web PROPERTIES LINK_FLAGS "${EMCC_LINK_FLAGS} --preload-file ${CMAKE_CURRENT_SOURCE_DIR}/Extras@/Extras/")' + 'set_target_properties(pd4web PROPERTIES LINK_FLAGS "${EMCC_LINK_FLAGS} --preload-file \\"${CMAKE_CURRENT_SOURCE_DIR}/Extras@/Extras/\\"")' ) def CreateCppCallsExternalFile(self):