Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 5c84e41

Browse files
committed
[[ Extensions ]] Compile downloaded extension with source
This patch ensures that lcb extensions are re-compiled after download so that the module format is always correct for the current IDE instance.
1 parent 276f82a commit 5c84e41

2 files changed

Lines changed: 85 additions & 67 deletions

File tree

Toolset/libraries/revidedeveloperextensionlibrary.livecodescript

Lines changed: 4 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -712,78 +712,15 @@ private function __fetchMetadatum pXmlId, pKey
712712
return textDecode(revXMLNodeContents(pXmlId, tNode), "utf-8")
713713
end __fetchMetadatum
714714

715-
private function shellFormat pArg, pSwitch
716-
local tOutput
717-
718-
if pSwitch is not empty then
719-
put "--" & pSwitch & " " into tOutput
720-
end if
721-
722-
return tOutput & quote & pArg & quote & " "
723-
end shellFormat
724-
725-
private function __revIDEDeveloperExtensionResourcePath
726-
if revEnvironmentIsInstalled() is false then
727-
return revEnvironmentBinariesPath()
728-
else
729-
return revIDESpecialFolderPath("Toolchain")
730-
end if
731-
end __revIDEDeveloperExtensionResourcePath
732-
733-
private function __revIDEDeveloperExtensionCompilerPath
734-
# The actual compile command
735-
if the platform is "win32" then
736-
return __revIDEDeveloperExtensionResourcePath() & slash & "lc-compile.exe"
737-
else
738-
return __revIDEDeveloperExtensionResourcePath() & slash & "lc-compile"
739-
end if
740-
end __revIDEDeveloperExtensionCompilerPath
741-
742715
private command __revIDEDeveloperCompileModule pFile, pTargetFolder
743-
# The manifest is currently always generated from the source
744-
if there is a file (pTargetFolder & slash & "manifest.xml") then
745-
delete file (pTargetFolder & slash & "manifest.xml")
746-
end if
716+
revIDEExtensionCompile pFile, pTargetFolder
747717

748-
# Build the shell command
749-
local tShellCommand
750-
put shellFormat(__revIDEDeveloperExtensionCompilerPath()) into tShellCommand
751-
752-
# The folder to put the .lci file
753-
put shellFormat(pTargetFolder, "modulepath") after tShellCommand
754-
755-
# The built-in module path
756-
put shellFormat(__revIDEDeveloperExtensionResourcePath() & slash & "modules/lci", "modulepath") after tShellCommand
757-
758-
# Installed module path
759-
put shellFormat(revIDESpecialFolderPath("user extensions") & slash & "interface", "modulepath") after tShellCommand
760-
761-
# The manifest target
762-
put shellFormat(pTargetFolder & slash & "manifest.xml", "manifest") after tShellCommand
763-
764-
# The output
765-
put shellFormat(pTargetFolder & slash & "module.lcm", "output") after tShellCommand
766-
767-
# The target .lcb file
768-
put shellFormat(pFile) after tShellCommand
769-
770-
# AL-2015-06-15: [[ Bug 15001 ]] Don't show console window when executing shell command
771-
local tHideConsoleWindows
772-
put the hideConsoleWindows into tHideConsoleWindows
773-
set the hideConsoleWindows to true
774-
775-
local tShellOutput, tShellResult
776-
put shell(tShellCommand) into tShellOutput
777-
put the result into tShellResult
778-
779-
set the hideConsoleWindows to tHideConsoleWindows
780-
781-
if tShellResult is not 0 then
782-
__revIDEDeveloperCompilationError tShellOutput
718+
if the result is not empty then
719+
__revIDEDeveloperCompilationError the result
783720
return "failed to compile module"
784721
end if
785722

786-
__revIDEDeveloperExtensionLog tShellOutput
723+
__revIDEDeveloperExtensionLog it
787724

788725
if there is not a file (pTargetFolder & slash & "module.lcm") then
789726
return "failed to compile module"

Toolset/libraries/revideextensionlibrary.livecodescript

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,6 +1078,17 @@ private command __revIDELCBExtensionLoad pID, pFolder, pVersion, pStatus, \
10781078
end if
10791079
if not pIsStartup or tLoadOnStartup is not false then
10801080
__LoadExtension tCacheIndex, "lcb", pSourceFile, pFolder, pStatus, pError
1081+
-- If we have an error loading, try to recompile the extension
1082+
if pError is not empty then
1083+
if not pIsIDEExtension and pSourceFile is not empty then
1084+
revIDEExtensionCompile pFolder & slash & pSourceFile, pFolder
1085+
if the result is empty then
1086+
local tNewError
1087+
__LoadExtension tCacheIndex, "lcb", pSourceFile, pFolder, pStatus, tNewError
1088+
put tNewError into pError
1089+
end if
1090+
end if
1091+
end if
10811092
else
10821093
__extensionPropertySet tCacheIndex, "status", "unloaded"
10831094
end if
@@ -1431,6 +1442,76 @@ on revIDEExtensionUpdateAPI pFolder, pExtensionSource
14311442
end if
14321443
end revIDEExtensionUpdateAPI
14331444

1445+
private function __revIDEExtensionResourcePath
1446+
if revEnvironmentIsInstalled() is false then
1447+
return revEnvironmentBinariesPath()
1448+
else
1449+
return revIDESpecialFolderPath("Toolchain")
1450+
end if
1451+
end __revIDEExtensionResourcePath
1452+
1453+
private function __revIDEExtensionCompilerPath
1454+
# The actual compile command
1455+
if the platform is "win32" then
1456+
return __revIDEExtensionResourcePath() & slash & "lc-compile.exe"
1457+
else
1458+
return __revIDEExtensionResourcePath() & slash & "lc-compile"
1459+
end if
1460+
end __revIDEExtensionCompilerPath
1461+
1462+
private function shellFormat pArg, pSwitch
1463+
local tOutput
1464+
1465+
if pSwitch is not empty then
1466+
put "--" & pSwitch & " " into tOutput
1467+
end if
1468+
1469+
return tOutput & quote & pArg & quote & " "
1470+
end shellFormat
1471+
1472+
command revIDEExtensionCompile pFile, pTargetFolder
1473+
# The manifest is currently always generated from the source
1474+
if there is a file (pTargetFolder & slash & "manifest.xml") then
1475+
delete file (pTargetFolder & slash & "manifest.xml")
1476+
end if
1477+
1478+
# Build the shell command
1479+
local tShellCommand
1480+
put shellFormat(__revIDEExtensionCompilerPath()) into tShellCommand
1481+
1482+
# The folder to put the .lci file
1483+
put shellFormat(pTargetFolder, "modulepath") after tShellCommand
1484+
1485+
# The built-in module path
1486+
put shellFormat(__revIDEExtensionResourcePath() & slash & "modules/lci", "modulepath") after tShellCommand
1487+
1488+
# Installed module path
1489+
put shellFormat(revIDESpecialFolderPath("user extensions") & slash & "interface", "modulepath") after tShellCommand
1490+
1491+
# The manifest target
1492+
put shellFormat(pTargetFolder & slash & "manifest.xml", "manifest") after tShellCommand
1493+
1494+
# The output
1495+
put shellFormat(pTargetFolder & slash & "module.lcm", "output") after tShellCommand
1496+
1497+
# The target .lcb file
1498+
put shellFormat(pFile) after tShellCommand
1499+
1500+
# AL-2015-06-15: [[ Bug 15001 ]] Don't show console window when executing shell command
1501+
local tHideConsoleWindows
1502+
put the hideConsoleWindows into tHideConsoleWindows
1503+
set the hideConsoleWindows to true
1504+
1505+
local tShellOutput, tShellResult
1506+
put shell(tShellCommand) into tShellOutput
1507+
put the result into tShellResult
1508+
set the hideConsoleWindows to tHideConsoleWindows
1509+
if tShellResult is 0 then
1510+
return tShellOutput for value
1511+
end if
1512+
return tShellOutput for error
1513+
end revIDEExtensionCompile
1514+
14341515
command revIDEExtensionMetadata pFolder, pFile, pType, @rDataA
14351516
local tDataA, tResult
14361517
if pType is "lcb" then

0 commit comments

Comments
 (0)