Skip to content

Commit 977f2ab

Browse files
committed
Merge remote-tracking branch 'origin/bugfix-20603' into bugfix-20603_develop
2 parents 67814e8 + 117f6f2 commit 977f2ab

File tree

8 files changed

+168
-116
lines changed

8 files changed

+168
-116
lines changed

docs/notes/bugfix-20603.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Ensure extensions' resource folders are available in standalones

docs/notes/platforms.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ The Mac engine supports:
5050
* 10.10.x (Yosemite) on Intel
5151
* 10.11.x (El Capitan) on Intel
5252
* 10.12.x (Sierra) on Intel
53+
* 10.13.x (High Sierra) on Intel
5354

5455
## iOS
5556
iOS deployment is possible when running LiveCode IDE on a Mac, and provided Xcode is installed and has been set in LiveCode *Preferences* (in the *Mobile Support* pane).
@@ -88,6 +89,7 @@ It will run on the following versions of Android:
8889
* 5.0-5.1 (Lollipop)
8990
* 6.0 (Marshmallow)
9091
* 7.0 (Nougat)
92+
* 8.0 (Oreo)
9193

9294
To enable deployment to Android devices, you need to download the
9395
[Android SDK](https://developer.android.com/sdk/index.html#Other), and

engine/src/deploy.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,17 @@ bool MCDeployWriteCapsule(const MCDeployParameters& p_params, MCDeployFileRef p_
540540
/* UNCHECKED */ MCArrayFetchValueAtIndex(p_params.redirects, i + 1, t_val);
541541
t_success = MCDeployCapsuleDefineString(t_capsule, kMCCapsuleSectionTypeRedirect, (MCStringRef)t_val);
542542
}
543+
544+
////////
545+
546+
// AL-2015-02-10: [[ Standalone Inclusions ]] Add the resource mappings, if any.
547+
if (t_success)
548+
for(uindex_t i = 0; i < MCArrayGetCount(p_params.library) && t_success; i++)
549+
{
550+
MCValueRef t_val;
551+
/* UNCHECKED */ MCArrayFetchValueAtIndex(p_params.library, i + 1, t_val);
552+
t_success = MCDeployCapsuleDefineString(t_capsule, kMCCapsuleSectionTypeLibrary, (MCStringRef)t_val);
553+
}
543554

544555
////////
545556

@@ -589,16 +600,7 @@ bool MCDeployWriteCapsule(const MCDeployParameters& p_params, MCDeployFileRef p_
589600
if (t_success)
590601
t_success = MCDeployCapsuleDefineFromStackFile(t_capsule, (MCStringRef)t_val, t_aux_stackfiles[i], false);
591602
}
592-
593-
// AL-2015-02-10: [[ Standalone Inclusions ]] Add the resource mappings, if any.
594-
if (t_success)
595-
for(uindex_t i = 0; i < MCArrayGetCount(p_params.library) && t_success; i++)
596-
{
597-
MCValueRef t_val;
598-
/* UNCHECKED */ MCArrayFetchValueAtIndex(p_params.library, i + 1, t_val);
599-
t_success = MCDeployCapsuleDefineString(t_capsule, kMCCapsuleSectionTypeLibrary, (MCStringRef)t_val);
600-
}
601-
603+
602604
// Now add the externals, if any
603605
if (t_success)
604606
for(uindex_t i = 0; i < MCArrayGetCount(p_params.externals) && t_success; i++)

engine/src/mode_standalone.cpp

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -387,32 +387,59 @@ bool MCStandaloneCapsuleCallback(void *p_self, const uint8_t *p_digest, MCCapsul
387387
MCresult -> sets("failed to read module");
388388
return false;
389389
}
390-
391-
bool t_success;
392-
t_success = true;
393390

394-
MCStreamRef t_stream;
395-
t_stream = nil;
396-
if (t_success)
397-
t_success = MCMemoryInputStreamCreate(t_module_data.Bytes(), p_length, t_stream);
391+
MCAutoValueRefBase<MCStreamRef> t_stream;
392+
bool t_success = MCMemoryInputStreamCreate(t_module_data.Bytes(),
393+
p_length, &t_stream);
398394

399-
MCScriptModuleRef t_module;
395+
MCScriptModuleRef t_module = nullptr;
400396
if (t_success)
401-
t_success = MCScriptCreateModuleFromStream(t_stream, t_module);
397+
t_success = MCScriptCreateModuleFromStream(*t_stream, t_module);
402398

403-
if (t_stream != nil)
404-
MCValueRelease(t_stream);
399+
if (t_success)
400+
{
401+
extern bool MCEngineAddExtensionFromModule(MCScriptModuleRef module);
402+
t_success = MCEngineAddExtensionFromModule(t_module);
403+
}
405404

406-
if (!t_success)
405+
MCAutoStringRef t_module_resources;
406+
if (t_success)
407+
t_success = MCStringFormat(&t_module_resources, "%@/resources",
408+
MCScriptGetNameOfModule(t_module));
409+
410+
MCAutoStringRef t_resources_path;
411+
if (t_success && MCdispatcher -> fetchlibrarymapping(*t_module_resources,
412+
&t_resources_path))
407413
{
408-
MCresult -> sets("failed to load module");
409-
return false;
414+
// Resolve the relative path
415+
MCAutoStringRef t_path;
416+
if (MCStringBeginsWith(*t_resources_path, MCSTR("./"),
417+
kMCStringOptionCompareExact) && MCcmd)
418+
{
419+
uindex_t t_last_slash_index;
420+
// On Android, we need to substitute in the whole of MCcmd so
421+
// that the apk path resolution works
422+
#ifndef TARGET_SUBPLATFORM_ANDROID
423+
if (!MCStringLastIndexOfChar(MCcmd, '/', UINDEX_MAX, kMCStringOptionCompareExact, t_last_slash_index))
424+
#endif
425+
t_last_slash_index = MCStringGetLength(MCcmd);
426+
427+
MCRange t_range;
428+
t_range = MCRangeMake(0, t_last_slash_index);
429+
t_success = MCStringFormat(&t_path, "%*@/%@", &t_range, MCcmd, *t_resources_path);
430+
}
431+
else
432+
t_path = *t_resources_path;
433+
434+
extern bool MCEngineAddResourcePathForModule(MCScriptModuleRef module, MCStringRef path);
435+
if (t_success)
436+
t_success = MCEngineAddResourcePathForModule(t_module, *t_path);
410437
}
411438

412-
extern bool MCEngineAddExtensionFromModule(MCScriptModuleRef module);
413-
if (!MCEngineAddExtensionFromModule(t_module))
439+
if (!t_success)
414440
{
415441
MCScriptReleaseModule(t_module);
442+
MCresult -> sets("failed to load module");
416443
return false;
417444
}
418445
}

ide-support/revsaveasandroidstandalone.livecodescript

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,8 @@ private command revSaveAsMobileStandaloneMain pStack, pApkFile, pTarget, pSettin
122122
set the itemDelimiter to comma
123123

124124
-- Fetch the various options we need to initially build the app-bundle
125-
local tName, tFiles, tVersionName, tVersionCode, tExternals, tIcon, tSplash, tKey, tUnsigned, tStatusBarIcon
125+
local tName, tVersionName, tVersionCode, tExternals, tIcon, tSplash, tKey, tUnsigned, tStatusBarIcon
126126
put pSettings["name"] into tName
127-
put pSettings["files"] into tFiles
128127
put pSettings["android,icon"] into tIcon
129128
put pSettings["android,key"] into tKey
130129

@@ -288,7 +287,8 @@ private command revSaveAsMobileStandaloneMain pStack, pApkFile, pTarget, pSettin
288287
set the itemDelimiter to "."
289288

290289
local tResolvedFileData
291-
revSBResolveCopyFilesList tBaseFolder, "android", tFiles, tResolvedFileData
290+
revSBUpdateSettingsForExtensions "android", pSettings
291+
revSBResolveCopyFilesList tBaseFolder, "android", pSettings, tResolvedFileData
292292

293293
repeat for each element tFile in tResolvedFileData
294294
-- Look for manifest template
@@ -699,6 +699,13 @@ private command revSaveAsMobileStandaloneMain pStack, pApkFile, pTarget, pSettin
699699
------- Compile the Standalone
700700
revStandaloneProgress "Building executable..."
701701

702+
put tExternals into pSettings["externals"]
703+
704+
put "revsecurity:./librevsecurity" into pSettings["android,library"]
705+
repeat for each line tEntry in tExternals
706+
put return & tEntry & ":" & "./lib" & tEntry after pSettings["android,library"]
707+
end repeat
708+
702709
local tDeploy
703710
-- Update the deploy params with script library and extension inclusions
704711
revSBUpdateDeployParams pStack, "android", pSettings, tDeploy
@@ -712,16 +719,6 @@ private command revSaveAsMobileStandaloneMain pStack, pApkFile, pTarget, pSettin
712719
-- Stackfile to use
713720
put the effective filename of stack pStack into tDeploy["stackfile"]
714721

715-
-- Externals to reference (on Android we include drivers in this list)
716-
put "revsecurity:./librevsecurity" into tDeploy["library"]
717-
repeat for each line tEntry in tExternals
718-
if not (tEntry begins with "db") then
719-
put tEntry & return after tDeploy["externals"]
720-
end if
721-
put return & tEntry & ":" & "./lib" & tEntry after tDeploy["library"]
722-
end repeat
723-
delete the last char of tDeploy["externals"]
724-
725722
-- Output file to create
726723
put tArmLibsBuildFolder & slash & "librevandroid.so" into tDeploy["output"]
727724

ide-support/revsaveasiosstandalone.livecodescript

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,8 @@ private command revSaveAsMobileStandaloneMain pStack, pAppBundle, pTarget, pSett
160160
set the itemDelimiter to comma
161161

162162
-- Fetch the various options we need to initially build the app-bundle
163-
local tName, tFiles, tExternals, tDrivers
163+
local tName, tExternals, tDrivers
164164
put pSettings["name"] into tName
165-
put pSettings["files"] into tFiles
166165

167166
if pSettings["ios,display name"] is empty then
168167
put tName into pSettings["ios,display name"]
@@ -255,7 +254,8 @@ private command revSaveAsMobileStandaloneMain pStack, pAppBundle, pTarget, pSett
255254
end if
256255

257256
local tPlist, tCustomEntitlements
258-
revCopyMobileFiles tFiles, tBaseFolder, pAppBundle, pTarget, tSDKs, tRedirects, tCopiedExternals, tCopiedFonts, tPlist, tCustomEntitlements
257+
revSBUpdateSettingsForExtensions "ios", pSettings
258+
revCopyMobileFiles pSettings, tBaseFolder, pAppBundle, pTarget, tSDKs, tRedirects, tCopiedExternals, tCopiedFonts, tPlist, tCustomEntitlements
259259
revCopyMobileStackFiles tStackFiles, tBaseFolder, pAppBundle
260260

261261
-- Copy in the appropriate externals and drivers
@@ -280,6 +280,23 @@ private command revSaveAsMobileStandaloneMain pStack, pAppBundle, pTarget, pSett
280280
end if
281281
end if
282282

283+
-- Externals to reference
284+
-- MM-2012-09-18: Use the new copied externals array instead of the copy files.
285+
--
286+
local tDeployExternals, tLibraryMappings
287+
repeat for each key tExternalName in tCopiedExternals
288+
local tExternalRec
289+
put tCopiedExternals[tExternalName] into tExternalRec
290+
if tExternalRec["type"] is among the words of "external external-tmp" then
291+
put tExternalName & return after tDeployExternals
292+
end if
293+
put tExternalName & ":" & "./" & tExternalRec["location"] & return after tLibraryMappings
294+
end repeat
295+
delete the last char of tDeployExternals
296+
put tDeployExternals into pSettings["externals"]
297+
delete the last char of tLibraryMappings
298+
put tLibraryMappings into pSettings["ios,library"]
299+
283300
local tDeploy
284301
-- Update the deploy params with script library and extension inclusions
285302
revSBUpdateDeployParams pStack, "ios", pSettings, tDeploy
@@ -469,20 +486,6 @@ private command revSaveAsMobileStandaloneMain pStack, pAppBundle, pTarget, pSett
469486
-- Stackfile to use
470487
put the effective filename of stack pStack into tDeploy["stackfile"]
471488

472-
-- Externals to reference
473-
-- MM-2012-09-18: Use the new copied externals array instead of the copy files.
474-
--
475-
repeat for each key tExternalName in tCopiedExternals
476-
local tExternalRec
477-
put tCopiedExternals[tExternalName] into tExternalRec
478-
if tExternalRec["type"] is among the words of "external external-tmp" then
479-
put tExternalName & return after tDeploy["externals"]
480-
end if
481-
put tExternalName & ":" & "./" & tExternalRec["location"] & return after tDeploy["library"]
482-
end repeat
483-
delete the last char of tDeploy["externals"]
484-
delete the last char of tDeploy["library"]
485-
486489
-- Put the redirects if any
487490
-- MM-2014-10-06: [[ Bug 13583 ]] Due to issues with the redirects, we use symlinks with the iOS 8 sim.
488491
-- PM-2016-09-16: [[ Bug 18414 ]] iOS 10 - tSDKs["sim"]["suffix"] is x_y on iOS x.y
@@ -938,14 +941,15 @@ end addToManifest
938941
-- foobar/baz -> <base>/foobar/baz
939942
-- C:/foobar/baz -> <base>/baz
940943
--
941-
private command revCopyMobileFiles pFiles, pBaseFolder, pAppBundle, pAppTarget, pSDKs, @rRedirects, @rExternals, @rFonts, @rPlist, @rCustomEntitlements
944+
private command revCopyMobileFiles pSettings, pBaseFolder, pAppBundle, pAppTarget, pSDKs, @rRedirects, @rExternals, @rFonts, @rPlist, @rCustomEntitlements
942945
revStandaloneProgress "Copying files..."
943946

944947
-- Only use redirects in simulator 4.x
945948
-- MM-2012-03-26: revMobileComputeTargetSuffix has changed for 5.1 support. Added device check to make
946949
-- sure that we don't try and use redirects for device builds.
947950
-- MM-2012-09-18: Since we now no longer support sims before 4.3, we always use redirects for sim builds.
948951
--
952+
949953
local tUseRedirects
950954
if pAppTarget is not "Device" then
951955
put true into tUseRedirects
@@ -955,7 +959,7 @@ private command revCopyMobileFiles pFiles, pBaseFolder, pAppBundle, pAppTarget,
955959
put empty into rRedirects
956960

957961
local tFileData
958-
revSBResolveCopyFilesList pBaseFolder, "ios", pFiles, tFileData
962+
revSBResolveCopyFilesList pBaseFolder, "ios", pSettings, tFileData
959963

960964
-- Compute a list of the files we need to copy. This is in the form
961965
-- <target> [tab] <source>

ide-support/revsaveasstandalone.livecodescript

Lines changed: 13 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ private command revStandaloneCopyInclusions pStack, pStackFileList, pStackSource
530530

531531
revCopyScriptLibraries pStack, pTarget
532532

533-
revCopyFiles pDirectory, pStackPath
533+
revCopyFiles pTarget, pDirectory, pStackPath
534534

535535
-- copy database drivers
536536
revCopyDatabaseDrivers pTarget, pStackSourceFile, pStandalonePath, pEngineSourceFile
@@ -564,18 +564,6 @@ private function revStandaloneInitialDeployParams pTarget, pStackSourceFile, pSt
564564
put return & "if there is a stack" && quote & tLine & quote && "then library" && quote & tLine & quote after tDeployInfo["startup_script"]
565565
end repeat
566566

567-
# AL-2015-02-04: [[ Standalone Resources ]] Add (universal) external names and resource mappings to the deploy parameters
568-
if sStandaloneSettingsA["externals"] is not empty then
569-
put sStandaloneSettingsA["externals"] into tDeployInfo["externals"]
570-
end if
571-
572-
local tPlatformDetailsA, tPlatform
573-
put revStandalonePlatformDetails(pTarget) into tPlatformDetailsA
574-
put tPlatformDetailsA["platform"] into tPlatform
575-
if sStandaloneSettingsA[tPlatform & ",library"] is not empty then
576-
put sStandaloneSettingsA[tPlatform & ",library"] into tDeployInfo["library"]
577-
end if
578-
579567
return tDeployInfo
580568
end revStandaloneInitialDeployParams
581569

@@ -1482,44 +1470,19 @@ end revCopyIcons
14821470
#####################################################################
14831471

14841472

1485-
private command revCopyFiles pDirectory, pStackPath
1473+
private command revCopyFiles pTarget, pDirectory, pStackPath
1474+
local tFileData
1475+
revSBUpdateSettingsForExtensions pTarget, sStandaloneSettingsA
1476+
revSBResolveCopyFilesList pStackPath, pTarget, sStandaloneSettingsA, tFileData
1477+
14861478
local tName,tDir
14871479
revStandaloneProgress "Copying files..."
1488-
set the itemDel to "/"
1489-
repeat for each line tFile in sStandaloneSettingsA["files"]
1490-
if the last item of tFile is not "*" then
1491-
if there is not a file tFile then
1492-
put tFile into tName
1493-
put pStackPath & "/" before tFile
1494-
else
1495-
put item -1 of tFile into tName
1496-
end if
1497-
else
1498-
delete the last item of tFile
1499-
--if there is not a folder tFile then
1500-
if there is a folder (pStackpath & slash & tFile) then
1501-
put tFile into tName
1502-
put pStackpath & slash before tFile
1503-
else
1504-
put item -1 of tFile into tName
1505-
end if
1506-
end if
1507-
1508-
put empty into tDir
1509-
repeat for each item tFolder in item 1 to -2 of tName
1510-
put tFolder & "/" after tDir
1511-
if there is not a folder (pDirectory & tDir) then
1512-
create folder pDirectory & tDir
1513-
end if
1514-
end repeat
1515-
if revResourceExists(tFile) then
1516-
## EJB 2014-07-30: [[ Bug 12864 ]] Ensure a relative folder in Copy Files is converted to an absolute path
1517-
--revCopyFile tFile, pDirectory & item 1 to -2 of tName
1518-
if there is a file tFile then
1519-
revSBCopyFileToFolder tFile, pDirectory & item 1 to -2 of tName, "revStandaloneProgressCallback", the long id of me
1520-
else -- it's a folder
1521-
revSBCopyFolderToDestination tFile, pDirectory & item 1 to -2 of tName, "revStandaloneProgressCallback", the long id of me
1522-
end if
1480+
set the itemDelimiter to slash
1481+
repeat for each element tFile in tFileData
1482+
revSBEnsureFolder pDirectory & slash & item 1 to -2 of tFile["name"]
1483+
if revResourceExists(tFile["resolved"]) then
1484+
revSBCopyFileToFile tFile["resolved"], pDirectory & slash & tFile["name"], \
1485+
"revStandaloneProgressCallback", the long id of me
15231486
else
15241487
revStandaloneAddWarning "File to include in standalone not found:" && quote & tFile & quote
15251488
end if
@@ -2150,15 +2113,13 @@ private command revAddExternal pExternalName
21502113
put pExternalName after sStandaloneSettingsA["externals"]
21512114
end revAddExternal
21522115

2153-
constant kSeparator = ":"
21542116
private command revAddMapping pPlatform, pName, pLocation
21552117
-- The name comes in without 'db' in front of it for the existing database
21562118
-- drivers, but it needs to be 'db*'.
21572119
if pName is among the items of "sqlite,postgres,odbc,mysql,oracle" then
21582120
put "db" before pName
21592121
end if
2160-
if sStandaloneSettingsA[pPlatform & ",library"] is not empty then put return after sStandaloneSettingsA[pPlatform & ",library"]
2161-
put pName & kSeparator & "./" & pLocation after sStandaloneSettingsA[pPlatform & ",library"]
2122+
revSBAddLibraryMapping pPlatform, pName, pLocation, sStandaloneSettingsA
21622123
end revAddMapping
21632124

21642125
# AL-2015-01-29: [[ Scriptify IDE ]] Factor out external copy function to ensure external is included in deploy params

0 commit comments

Comments
 (0)