@@ -13,6 +13,52 @@ on extensionFinalize
1313 end if
1414end extensionFinalize
1515
16+ local sModuleVersion
17+ private command __EnsureModuleVersion
18+ if sModuleVersion is not empty then
19+ exit __EnsureModuleVersion
20+ end if
21+ local tTempFile , tModule , tFolder
22+ put the tempname into tTempFile
23+ set the itemdelimiter to slash
24+ put item 1 to - 2 of tTempFile into tFolder
25+ put "module com.livecode.dummy" into tModule
26+ put return & "end module" after tModule
27+ put tModule into url("file:" & tTempFile )
28+ revIDEExtensionCompile tTempFile , "" , tFolder , "module.lcm"
29+ put __CompiledModuleVersion(tFolder & slash & "module.lcm" ) \
30+ into sModuleVersion
31+ end __EnsureModuleVersion
32+
33+ private function __CompiledModuleVersion pModule
34+ local tBytes
35+ put url("binfile:" & pModule ) into tBytes
36+ return byteToNum (byte 4 of tBytes ) * 256 + \
37+ byteToNum (byte 3 of tBytes )
38+ end __CompiledModuleVersion
39+
40+ private function __CheckModuleVersion pModule
41+ return __CompiledModuleVersion(pModule ) is \
42+ __ModuleVersion()
43+ end __CheckModuleVersion
44+
45+ private function __ModuleVersion
46+ __EnsureModuleVersion
47+ return sModuleVersion
48+ end __ModuleVersion
49+
50+ function revIDEExtensionBytecodeFilename pUseVersion
51+ if pUseVersion is empty then
52+ put true into pUseVersion
53+ end if
54+
55+ if pUseVersion then
56+ return "module." & __ModuleVersion() & ".lcm"
57+ else
58+ return "module.lcm"
59+ end if
60+ end revIDEExtensionBytecodeFilename
61+
1662# Called at startup. Loads all the extensions ready for use
1763on revIDEInitialiseExtensions
1864 # Load all the extensions ready for use
@@ -926,8 +972,11 @@ command revIDEExtensionFetchSourceFromFolder pFolder, @rSource, @rSupportFiles,
926972 local tExtFiles , tType
927973 filter tFiles with regex pattern \
928974 __RegexPatternForSource("lcb" ) into tExtFiles
929- if there is a file (pFolder & slash & "module.lcm" ) \
930- or tExtFiles is not empty then
975+ if tExtFiles is not empty \
976+ or there is a file \
977+ (pFolder & slash & revIDEExtensionBytecodeFilename(true )) \
978+ or there is a file \
979+ (pFolder & slash & revIDEExtensionBytecodeFilename(false )) then
931980 put "lcb" into tType
932981 end if
933982
@@ -1188,10 +1237,16 @@ end __MapCodeLibraryForIDE
11881237
11891238private command __LoadExtension pCacheIndex, pSourceType, pSourceFile, pFolder, pStatus, @xError
11901239 if xError is empty then
1240+ local tFileToLoad
11911241 if pSourceType is "lcb" then
11921242 local tResources , tModule , tCode
1243+ put pFolder & slash & revIDEExtensionBytecodeFilename(true ) \
1244+ into tModule
1245+ if there is no file tModule then
1246+ put pFolder & slash & revIDEExtensionBytecodeFilename(false ) \
1247+ into tModule
1248+ end if
11931249 put pFolder & slash & "resources" into tResources
1194- put pFolder & slash & "module.lcm" into tModule
11951250 put pFolder & slash & "code" into tCode
11961251 # map code before loading extension
11971252 if there is a folder tCode then
@@ -1203,9 +1258,11 @@ private command __LoadExtension pCacheIndex, pSourceType, pSourceFile, pFolder,
12031258 else
12041259 load extension from file tModule
12051260 end if
1261+ put tModule into tFileToLoad
12061262 else
12071263 set the itemdelimiter to "."
12081264 revInternal__LoadLibrary item 1 of pSourceFile , pFolder & slash & pSourceFile
1265+ put pSourceFile into tFileToLoad
12091266 end if
12101267 if the result is not empty then
12111268 put toUpper (char 1 of the result ) & \
@@ -1218,6 +1275,7 @@ private command __LoadExtension pCacheIndex, pSourceType, pSourceFile, pFolder,
12181275
12191276 __extensionPropertySet pCacheIndex , "status" , pStatus
12201277 __extensionPropertySet pCacheIndex , "error" , xError
1278+ __extensionPropertySet pCacheIndex , "file" , tFileToLoad
12211279 __extensionsChanged
12221280end __LoadExtension
12231281
@@ -1244,7 +1302,8 @@ private command __revIDELCBExtensionLoad pID, pFolder, pVersion, pStatus, \
12441302 -- If we have an error loading, try to recompile the extension
12451303 if pError is not empty then
12461304 if not pIsIDEExtension and pSourceFile is not empty then
1247- revIDEExtensionCompile pFolder & slash & pSourceFile , tSupportFiles , pFolder
1305+ revIDEExtensionCompile pFolder & slash & pSourceFile , tSupportFiles , pFolder , \
1306+ revIDEExtensionBytecodeFilename(true )
12481307 if the result is empty then
12491308 local tNewError
12501309 __LoadExtension tCacheIndex , "lcb" , pSourceFile , pFolder , pStatus , tNewError
@@ -1636,7 +1695,11 @@ private function shellFormat pArg, pSwitch
16361695 return tOutput & quote & pArg & quote & " "
16371696end shellFormat
16381697
1639- command revIDEExtensionCompile pFile, pSupportFiles, pTargetFolder
1698+ command revIDEExtensionCompile pFile, pSupportFiles, pTargetFolder, pOutputFilename
1699+ if pOutputFilename is empty then
1700+ put revIDEExtensionBytecodeFilename() into pOutputFilename
1701+ end if
1702+
16401703 # The manifest is currently always generated from the source
16411704 if there is a file (pTargetFolder & slash & "manifest.xml" ) then
16421705 delete file (pTargetFolder & slash & "manifest.xml" )
@@ -1659,7 +1722,7 @@ command revIDEExtensionCompile pFile, pSupportFiles, pTargetFolder
16591722 put shellFormat(pTargetFolder & slash & "manifest.xml" , "manifest" ) after tShellCommand
16601723
16611724 # The output
1662- put shellFormat(pTargetFolder & slash & "module.lcm" , "output" ) after tShellCommand
1725+ put shellFormat(pTargetFolder & slash & pOutputFilename , "output" ) after tShellCommand
16631726
16641727 # Support files must be dependency-ordered
16651728 repeat for each line tSupport in revIDEExtensionsOrderByDependency(pSupportFiles )
@@ -1812,18 +1875,14 @@ function revIDEExtensionFileData pID
18121875 local tCacheIndex
18131876 put __extensionCacheID("name" , pID ) into tCacheIndex
18141877
1815- local tSourceType , tFolder , tSourceFile
1878+ local tSourceType , tFolder , tFile
18161879 put __extensionPropertyGet(tCacheIndex , "install_path" ) into tFolder
18171880 put __extensionPropertyGet(tCacheIndex , "source_type" ) into tSourceType
1818- put __extensionPropertyGet(tCacheIndex , "source_file " ) into tSourceFile
1881+ put __extensionPropertyGet(tCacheIndex , "file " ) into tFile
18191882
18201883 local tDataA
18211884 put tSourceType into tDataA ["type" ]
1822- if tSourceType is "lcb" then
1823- put tFolder & slash & "module.lcm" into tDataA ["file" ]
1824- else
1825- put tFolder & slash & tSourceFile into tDataA ["file" ]
1826- end if
1885+ put tFolder & slash & tFile into tDataA ["file" ]
18271886 return tDataA
18281887end revIDEExtensionFileData
18291888
0 commit comments