Skip to content

Commit

Permalink
fix pd4web to handle spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesneimog committed Nov 25, 2024
1 parent 1b4835f commit e296548
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
16 changes: 10 additions & 6 deletions Resources/Pd/pd4web.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <patch_name>]");
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 <path>]");
}
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) {
Expand Down
20 changes: 10 additions & 10 deletions Sources/pd4web/Builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("")

Expand Down Expand Up @@ -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 = [
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit e296548

Please sign in to comment.