-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.lua
53 lines (46 loc) · 1.47 KB
/
build.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
-- pcall(os.execute, "git clone [email protected]:kompasim/my-build-tools.git ./my-build-tools")
package.path = package.path .. ";./my-build-tools/?.lua"
local HtmlBuilder = require("html_builder")
local CodeBuilder = require("./code_builder")
-- windows, darwin, linux
-- $Env:GOOS=""
-- $Env:GOARCH="amd64"
-- os.execute("rm -rf ./release/")
local isRun = true
local osName = os.getenv("GOOS")
local versionName = "0.1"
assert(osName, "please set GOOS & GOARCH evn variable")
local function clearAll()
files.delete('./target.html')
files.delete('./target.go')
end
clearAll()
local hBuilder = HtmlBuilder(false)
hBuilder:inputFile("./terminal.html")
hBuilder:containScript()
hBuilder:containStyle()
hBuilder:containImage()
hBuilder:setOutput("./target.html")
hBuilder:start()
local cBuilder = CodeBuilder(false)
cBuilder:setInput("./terminal.go")
cBuilder:handleMacro("//")
cBuilder:setCallback(function(code, firsArg)
if firsArg ~= "VERSION_NAME" then
return string.format(code, "v" .. versionName)
end
end)
cBuilder:setOutput("./target.go")
cBuilder:start()
if isRun then
os.execute("go run target.go")
else
files.mk_folder("./release/")
os.execute("go build target.go")
local fileExt = osName == "windows" and ".exe" or ""
local targetName = "./target" .. fileExt
local releaseName = "./release/simple_web_terminal_" .. versionName .. "_" .. osName .. fileExt
files.copy(targetName, releaseName)
files.delete(targetName)
clearAll()
end