Skip to content

Commit de4b196

Browse files
Merge pull request livecode#2785 from peter-b/js/cleanups
[emscripten] Miscellaneous cleanups.
2 parents 45b41ad + 8bdeab5 commit de4b196

2 files changed

Lines changed: 32 additions & 17 deletions

File tree

engine/src/mode_standalone.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,6 @@ IO_stat MCDispatch::startup(void)
449449
MCdispatcher -> loadexternal(MCSTR("revxml"));
450450
MCdispatcher -> loadexternal(MCSTR("dbsqlite"));
451451
MCdispatcher -> loadexternal(MCSTR("dbmysql"));
452-
#elif defined(__EMSCRIPTEN__)
453-
/* Don't load any externals */
454452
#else
455453
MCdispatcher -> loadexternal(MCSTR("revzip.dylib"));
456454
MCdispatcher -> loadexternal(MCSTR("revdb.dylib"));

ide-support/revsaveasemscriptenstandalone.livecodescript

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ command revSaveAsEmscriptenStandalone pStack, pOutputFolder
132132
put tBuildFolder & slash & tName & ".html" into tHtmlFile
133133
logDebug "html", "Creating" && tHtmlFile
134134
logDebug "html", "Copying" && getHtmlTemplateFile()
135-
revSBCopyFileToFile mapPath(getHtmlTemplateFile()), tHtmlFile, \
135+
revSBCopyFileToFile mapBinPath(getHtmlTemplateFile()), tHtmlFile, \
136136
"revStandaloneProgressCallback", the long id of me
137137

138138
catch tError
@@ -161,9 +161,9 @@ end revSaveAsEmscriptenStandalone
161161
-- File & path helper functions
162162
----------------------------------------------------------------
163163

164-
-- Map a file path into an absolute filesystem path. This is used to
165-
-- cope with running from a git repository working tree.
166-
private function mapPath pPath
164+
-- Map a compiled file's path into an absolute filesystem path. This
165+
-- is used to cope with running from a git repository working tree.
166+
private function mapBinPath pPath
167167
if there is a file pPath then
168168
return pPath
169169
end if
@@ -175,18 +175,32 @@ private function mapPath pPath
175175
-- We're running from a git checkout
176176
return getRepoBinariesFolder() & slash & pPath
177177
end if
178-
end mapPath
178+
end mapBinPath
179+
180+
-- Map a resource file's path into an absolute filesystem path. This
181+
-- is used to cope with running from a git repository working tree.
182+
private function mapResPath pPath
183+
if there is a file pPath then
184+
return pPath
185+
end if
186+
187+
if revEnvironmentIsInstalled() then
188+
return getRuntimeFolder() & slash & pPath
189+
else
190+
return getRepoResourceFolder() & slash & pPath
191+
end if
192+
end mapResPath
179193

180194
-- Return a number-indexed array of engine files that need to be
181195
-- copied into the standalone output folder.
182196
private function getEngineFiles
183197
local tFiles
184198

185199
-- Engine JavaScript
186-
put mapPath("standalone-" & revLicenseType() & "-" & the version & ".js") into tFiles[1]
200+
put mapBinPath("standalone-" & revLicenseType() & "-" & the version & ".js") into tFiles[1]
187201

188202
-- Memory initialisation file
189-
put mapPath("standalone-" & revLicenseType() & "-" & the version & ".html.mem") into tFiles[2]
203+
put mapBinPath("standalone-" & revLicenseType() & "-" & the version & ".html.mem") into tFiles[2]
190204

191205
return tFiles
192206
end getEngineFiles
@@ -196,7 +210,7 @@ end getEngineFiles
196210
-- initialisation data that's automatically included in all
197211
-- standalones (especially fonts).
198212
private function getStandaloneTemplateFolder
199-
return mapPath("emscripten-standalone-template")
213+
return mapResPath("emscripten-standalone-template")
200214
end getStandaloneTemplateFolder
201215

202216
-- Return a number-indexed array of files in the Emscripten standalone
@@ -230,6 +244,11 @@ private command getStandaloneTemplateFiles_Impl @xCount, @xFiles, pRelPath
230244

231245
-- List files
232246
repeat for each line tFile in the files
247+
-- Skip dotfiles
248+
if tFile begins with "." then
249+
next repeat
250+
end if
251+
233252
add 1 to xCount
234253
put pRelPath & slash & tFile into tFilePath
235254
put tFilePath into xFiles[xCount]
@@ -256,7 +275,7 @@ end getStandaloneTemplateFiles_Impl
256275
-- This has some standalone-dependent JavaScript substituted into it
257276
-- to instantiate the engine.
258277
private function getHtmlTemplateFile
259-
return mapPath("standalone-" & revLicenseType() & "-" & the version & ".html")
278+
return mapBinPath("standalone-" & revLicenseType() & "-" & the version & ".html")
260279
end getHtmlTemplateFile
261280

262281
-- Get the directory containing the Emscripten runtime
@@ -291,9 +310,7 @@ private function getRepoBinariesFolder
291310
return revEnvironmentRepositoryPath() & slash & "emscripten-bin"
292311
end getRepoBinariesFolder
293312

294-
---------------------------------------
295-
-- FIXME REMOVE THESE
296-
297-
function revEmscriptenGetRepoBinariesFolder
298-
return getRepoBinariesFolder()
299-
end revEmscriptenGetRepoBinariesFolder
313+
-- Get the directory where Emscripten resources are kept
314+
private function getRepoResourceFolder
315+
return revEnvironmentRepositoryPath() & slash & "engine" & slash & "rsrc"
316+
end getRepoResourceFolder

0 commit comments

Comments
 (0)