Skip to content

Commit e09ca0b

Browse files
committed
[[ CmdLineBuilder ]] Installers can now be built from the command-line.
This patch contains minor changes to the engine to allow the community IDE engine to run in -ui along with various changes to the builder system to enable installers to be built from the command line. Specifically, there is a new stack 'builder_tool.livecodescript' which gives a command-line interface to the installer builder system: <ide-engine> -ui builder/builder_tool.livecodescript This takes the following arguments: . --platform <plat> : <plat> is one of win, mac, linux (multiple --platform arguments are allowed) . --stage <stage> : <stage> is one of environment, tools, server, notes, docs . --edition <edition> : <edition> is one of community, commercial . --build <build> : <build> is one of stable, maintenance, development, beta . --engine-dir <dir> : <dir> is a folder containing zipped binary components . --output-dir <dir> : <dir> is the folder where the final built installers should be placed . --work-dir <dir> : <dir> is the folder where intermediate files should be placed . --warn-as-error : if specified, the build will stop at the first warning The environment stage will generate a suitable public/private key. The docs stage will generate the documentation. The notes stage will generate the release notes. The tools stage will generate the installers themselves.
1 parent 2648907 commit e09ca0b

10 files changed

Lines changed: 696 additions & 219 deletions
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
script "Command Line Builder"
2+
local sWarnAsError
3+
4+
on startup
5+
set the itemdelimiter to slash
6+
start using stack (item 1 to -2 of the filename of me & slash & "builder_utilities.livecodescript")
7+
set the itemDelimiter to comma
8+
9+
__loadExternal "revzip"
10+
__loadExternal "revxml"
11+
12+
put false into sWarnAsError
13+
14+
local tArgs, tArgIndex
15+
repeat with tArgIndex = 1 to $# - 1
16+
put value("$" & tArgIndex) into tArgs[tArgIndex]
17+
end repeat
18+
19+
local tPlatforms, tStage, tEdition, tBuild
20+
put empty into tPlatforms
21+
put "tools" into tStage
22+
put "community" into tEdition
23+
put "stable" into tBuild
24+
25+
local tEngineDir, tOutputDir, tWorkDir
26+
27+
put 1 into tArgIndex
28+
repeat while tArgIndex is among the keys of tArgs
29+
if tArgs[tArgIndex] is "--platform" then
30+
get tArgs[tArgIndex + 1]
31+
if it is not among the items of "windows,win,macosx,mac,linux" then
32+
__builderLog "error", "Unknown platform '" & tArgs[tArgIndex + 1] & "'"
33+
end if
34+
if it is "win" then get "windows"
35+
if it is "mac" then get "macosx"
36+
put true into tPlatforms[it]
37+
add 1 to tArgIndex
38+
else if tArgs[tArgIndex] is "--stage" then
39+
if tArgs[tArgIndex + 1] is not among the items of "environment,tools,server,notes,docs" then
40+
__builderLog "error", "Unknown stage '" & tArgs[tArgIndex + 1] & "'"
41+
end if
42+
put tArgs[tArgIndex + 1] into tStage
43+
add 1 to tArgIndex
44+
else if tArgs[tArgIndex] is "--edition" then
45+
if tArgs[tArgIndex + 1] is not among the items of "community,commercial" then
46+
__builderLog "error", "Unknown edition '" & tArgs[tArgIndex + 1] & "'"
47+
end if
48+
put tArgs[tArgIndex + 1] into tEdition
49+
add 1 to tArgIndex
50+
else if tArgs[tArgIndex] is "--build" then
51+
if tArgs[tArgIndex + 1] is not among the items of "stable,maintenance,development,beta" then
52+
__builderLog "error", "Unknown build '" & tArgs[tArgIndex + 1] & "'"
53+
end if
54+
put tArgs[tArgIndex + 1] into tBuild
55+
add 1 to tArgIndex
56+
else if tArgs[tArgIndex] is "--engine-dir" then
57+
if tArgs[tArgIndex + 1] is empty then
58+
__builderLog "error", "No path specified for --engine-dir argument"
59+
end if
60+
put tArgs[tArgIndex + 1] into tEngineDir
61+
add 1 to tArgIndex
62+
else if tArgs[tArgIndex] is "--output-dir" then
63+
if tArgs[tArgIndex + 1] is empty then
64+
__builderLog "error", "No path specified for --output-dir argument"
65+
end if
66+
put tArgs[tArgIndex + 1] into tOutputDir
67+
add 1 to tArgIndex
68+
else if tArgs[tArgIndex] is "--work-dir" then
69+
if tArgs[tArgIndex + 1] is empty then
70+
__builderLog "error", "No path specified for --work-dir argument"
71+
end if
72+
put tArgs[tArgIndex + 1] into tWorkDir
73+
add 1 to tArgIndex
74+
else if tArgs[tArgIndex] is "--warn-as-error" then
75+
put true into sWarnAsError
76+
end if
77+
add 1 to tArgIndex
78+
end repeat
79+
80+
if the keys of tPlatforms is empty and tStage is "tools" then
81+
__builderLog "error", "No platforms specified"
82+
end if
83+
84+
if tStage is "environment" then
85+
put empty into tPlatforms
86+
put true into tPlatforms["environment"]
87+
put "engine" into tStage
88+
end if
89+
90+
set the name of this stack to "Builder"
91+
92+
if tEngineDir is not empty then
93+
builderSetEngineDir tEngineDir
94+
end if
95+
96+
builderBuild tStage, the keys of tPlatforms, tEdition, tBuild
97+
98+
quit 0
99+
end startup
100+
101+
command __loadExternal pExternal
102+
set the itemdelimiter to slash
103+
104+
set the externals of the templateStack to item 1 to -4 of specialFolderPath("engine") & slash & pExternal & ".bundle"
105+
create stack pExternal && "External"
106+
start using it
107+
if the externalCommands of it is empty then
108+
__builderLog "error", "Cannot load external" && pExternal
109+
end if
110+
end __loadExternal
111+
112+
command __builderLog pType, pMessage
113+
local tLine
114+
115+
put toUpper(char 1 of pType) into char 1 of pType
116+
117+
repeat for each line tLine in pMessage
118+
write ("[" && the internet date && "]" && ":" && pType && ":" && tLine & return) to stderr
119+
end repeat
120+
if pType is "warning" and sWarnAsError or \
121+
pType is "error" then
122+
quit 1
123+
end if
124+
end __builderLog
125+
126+
on errorDialog pBacktrace
127+
write pBacktrace & return to stderr
128+
quit 1
129+
end errorDialog

builder/builder_utilities.livecodescript

Lines changed: 62 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
script "BuilderUtilities"
2+
local sEngineDir
3+
24
////////////////////////////////////////////////////////////////////////////////
35

46
command builderLog pType, pMessage
57
if there is a stack "Builder" then
6-
send "__builderLog pType, pMessage" to stack "Builder"
8+
dispatch "__builderLog" to stack "Builder" with pType, pMessage
79
end if
810
end builderLog
911

@@ -17,6 +19,10 @@ command builderFinalize
1719
stop using stack (builderSystemFolder() & slash & "package_compiler.livecodescript")
1820
end builderFinalize
1921

22+
command builderSetEngineDir pDir
23+
put pDir into sEngineDir
24+
end builderSetEngineDir
25+
2026
////////////////////////////////////////////////////////////////////////////////
2127

2228
on builderBuild pWhich, pPlatforms, pEdition, pType
@@ -65,6 +71,28 @@ on builderBuild pWhich, pPlatforms, pEdition, pType
6571
end builderBuild
6672

6773
command builderFetchEngine pVersion, pPlatform
74+
if sEngineDir is not empty then
75+
switch pPlatform
76+
case "windows"
77+
return sEngineDir & slash & "build-win-x86.zip/build-win-x86/Release"
78+
case "linux"
79+
return sEngineDir & slash & "build-linux-x86.zip/build-linux-x86/out/Release"
80+
case "linux-x64"
81+
return sEngineDir & slash & "build-linux-x64.zip/build-linux-x64/out/Release"
82+
case "linux-armv6hf"
83+
return sEngineDir & slash & "build-linux-armv6hf.zip/build-linux-armv6hf/out/Release"
84+
case "macosx"
85+
return sEngineDir & slash & "build-mac-all.zip/build-mac-all/_build/mac/Release"
86+
case "ios"
87+
return sEngineDir & slash & "build-ios-all.zip/build-ios-all/_build/ios"
88+
case "android"
89+
return sEngineDir & slash & "build-android-armv6.zip/build-android-armv6/out/Release"
90+
default
91+
write the executionContexts to stderr
92+
builderLog "error", "Unknown platform '" & pPlatform & "'"
93+
end switch
94+
return empty
95+
end if
6896
local tPlatform
6997
switch pPlatform
7098
case "windows"
@@ -137,25 +165,39 @@ function builderRepoFolder
137165
return item 1 to -3 of the filename of me
138166
end builderRepoFolder
139167

140-
function builderIDEFolder
141-
set the itemDelimiter to slash
142-
return (item 1 to -3 of the filename of me & slash & "ide")
143-
end builderIDEFolder
168+
-- Returns the folder of the private repository
169+
function builderPrivateRepoFolder
170+
return builderRepoFolder() & slash & ".." & slash & "livecode-commercial"
171+
end builderPrivateRepoFolder
172+
173+
-- Returns the folder of the IDE repository
174+
function builderIdeRepoFolder
175+
return builderRepoFolder() & slash & "ide"
176+
end builderIdeRepoFolder
144177

145178
-- Returns the folder of the builder system
146179
function builderSystemFolder
147180
set the itemDelimiter to slash
148181
return item 1 to -2 of the filename of me
149182
end builderSystemFolder
150183

184+
-- Returns the folder where intermediate products should be placed
185+
function builderWorkFolder
186+
return builderRepoFolder() & slash & "_build/final/work"
187+
end builderWorkFolder
188+
189+
-- Returns the folder where output products should be placed
190+
function builderOutputFolder
191+
return builderRepoFolder() & slash & "_build/final/output"
192+
end builderOutputFolder
193+
151194
-- Returns the folder where all the work should be done
152195
function builderWorkspaceFolder
153196
return builderRepoFolder() & slash & "_build/final"
154-
--return specialFolderPath("Desktop") & slash & "BuilderWorkspace"
155197
end builderWorkspaceFolder
156198

157199
function builderIDEFolder
158-
return builderRepoFolder() & slash & "ide"
200+
return builderIdeRepoFolder()
159201
end builderIDEFolder
160202

161203
function builderIDEDocsFolder
@@ -230,24 +272,33 @@ end builderModuleInterfaceFolder
230272
-- Returns the engine that should be used to build the installer
231273
function builderInstallerEngine pPlatform
232274
local tEngineFolder
233-
--put builderWorkspaceFolder() & slash & "engine" & slash & pPlatform & "-" & item 1 of field "Version" of card 1 of me into tEngineFolder
234275
builderFetchEngine empty, pPlatform
235276
put the result into tEngineFolder
236277

237278
switch pPlatform
238279
case "windows"
239280
return tEngineFolder & slash & "installer.exe"
240281
case "linux"
241-
return tEngineFolder & slash & "i386/release/installer"
282+
return tEngineFolder & slash & "installer"
242283
case "linux-x64"
243-
return tEngineFolder & slash & "x86_64/release/installer"
284+
return tEngineFolder & slash & "installer"
244285
case "linux-armv6hf"
245-
return tEngineFolder & slash & "armv6-hf/release/installer"
286+
return tEngineFolder & slash & "installer"
246287
case "macosx"
247288
return tEngineFolder & slash & "installer.app"
248289
end switch
249290
end builderInstallerEngine
250291

292+
function builderMakeTemporaryFile pTempFolder, pTag
293+
local tIndex
294+
put 1 into tIndex
295+
repeat while there is a file (pTempFolder & slash & pTag & "-" & tIndex)
296+
add 1 to tIndex
297+
end repeat
298+
299+
return pTempFolder & slash & pTag & "-" & tIndex
300+
end builderMakeTemporaryFile
301+
251302
////////////////////////////////////////////////////////////////////////////////
252303

253304
command builderEnsureFolder pFolder

builder/docs_builder.livecodescript

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ command docsBuilderRun pEdition, pVersion
3333
put docsBuilderGetSourceDirectory() into tSourceDir
3434
put docsBuilderGetOutputDirectory() & "/packaged_xml" into tOutputDir
3535

36+
start using stack (builderIdeRepoFolder() & slash & "Toolset/palettes/revdocumentationlibrary.rev")
37+
3638
builderLog "report", "Building docs into" && tOutputDir
3739
buildDocumentation tSourceDir & "/dictionary", tSourceDir & "/glossary", tOutputDir & "/dictionary", tOutputDir & "/glossary", tOutputDir, "docsBuilderProgressUpdate", the long id of me
3840
builderLog "report", "Building docs into" && tOutputDir && "complete"
@@ -2058,3 +2060,45 @@ command docsBuilderGenerateDistributedAPI
20582060

20592061
put textEncode(tJSON, "utf-8") into url ("binfile:" & builderAPIFolder() & slash & "distributed_api.js")
20602062
end docsBuilderGenerateDistributedAPI
2063+
2064+
--- LEGACY
2065+
2066+
function revDocumentationRetrieve pType, pTag, pFolder
2067+
-- We know how many files per clump cuz of kFilesPerClump
2068+
-- pType is either "dictionary/" or "glossary/"
2069+
local tClumpNumber, tFileNumber, tPropNumber, tPropName
2070+
local tClumpName, tDocData, tClumpPath, tType, tOpenClumps
2071+
---------
2072+
2073+
put pType into tType
2074+
if the last char of tType is not slash then put slash after tType
2075+
2076+
if pFolder is empty then
2077+
put revEnvironmentDocumentationPath() & slash & "packaged_xml/" & tType into tClumpPath
2078+
else
2079+
put pFolder & slash & "packaged_xml/" & tType into tClumpPath
2080+
end if
2081+
2082+
set the itemDelimiter to "."
2083+
put item 1 of pTag into tFileNumber
2084+
if tFileNumber is not a number then
2085+
return empty
2086+
end if
2087+
put ((tFileNumber - 1) div kFilesPerClump) + 1 into tClumpNumber
2088+
put ((tFileNumber - 1) mod kFilesPerClump) + 1 into tPropNumber
2089+
2090+
put "c" & tPropNumber into tPropName
2091+
put the mainStacks into tOpenClumps
2092+
filter tOpenClumps with kClumpNamePrefix & "*"
2093+
2094+
put kClumpNamePrefix & tClumpNumber into tClumpName
2095+
2096+
put the tPropName of stack (tClumpPath & tClumpName & ".rev") into tDocData
2097+
if tDocData is empty then
2098+
return empty
2099+
end if
2100+
2101+
-- We've got the doc's compressed data, uncompress and return
2102+
return the decompress of tDocData
2103+
end revDocumentationRetrieve
2104+

0 commit comments

Comments
 (0)