Skip to content

Commit 6cb5f17

Browse files
hishamhmleafo
authored andcommitted
Download LuaJIT rolling release from git
As requested by luajit.org: https://luajit.org/download.html
1 parent b1670dd commit 6cb5f17

File tree

2 files changed

+54
-46
lines changed

2 files changed

+54
-46
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,15 @@ Examples of versions:
6565
* `"5.2.4"`
6666
* `"5.3.5"`
6767
* `"5.4.1"`
68-
* `"luajit-2.0.5"`
69-
* `"luajit-2.1.0-beta3"`
68+
* `"luajit-2.0"`
69+
* `"luajit-2.1"`
70+
* `"luajit-master"`
7071
* `"luajit-openresty"`
7172

7273
The version specifies where the source is downloaded from:
7374

74-
* `luajit-openresty` — will allways pull master from https://github.com/openresty/luajit2
75-
* Anything starting with `luajit-` — from http://luajit.org/download.html
75+
* `luajit-openresty` — will always pull master from https://github.com/openresty/luajit2
76+
* Anything else starting with `luajit-` — pulls a master or version branch from https://github.com/luajit/luajit
7677
* Anything else — from https://www.lua.org/ftp/
7778

7879
**Version aliases**

main.js

Lines changed: 49 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,35 @@ const VERSION_ALIASES = {
1919
"5.2": "5.2.4",
2020
"5.3": "5.3.6",
2121
"5.4": "5.4.4",
22-
"luajit": "luajit-2.1.0-beta3",
22+
"luajit": "luajit-2.1",
23+
}
24+
25+
const LUAJIT_REPOS = {
26+
"luajit-2.0": {
27+
"url": "https://github.com/luajit/luajit.git",
28+
"branch": "v2.0",
29+
"binary": "luajit"
30+
},
31+
"luajit-2.1": {
32+
"url": "https://github.com/luajit/luajit.git",
33+
"branch": "v2.1",
34+
"binary": "luajit"
35+
},
36+
"luajit-2.1.0-beta3": {
37+
"url": "https://github.com/luajit/luajit.git",
38+
"branch": "v2.1.0-beta3",
39+
"binary": "luajit-2.1.0-beta3"
40+
},
41+
"luajit-master": {
42+
"url": "https://github.com/luajit/luajit.git",
43+
"branch": "master",
44+
"binary": "luajit"
45+
},
46+
"luajit-openresty": {
47+
"url": "https://github.com/openresty/luajit2.git",
48+
"branch": "v2.1-agentzh",
49+
"binary": "luajit"
50+
},
2351
}
2452

2553
const isMacOS = () => (process.platform || "").startsWith("darwin")
@@ -49,13 +77,27 @@ async function finish_luajit_install(src, dst, luajit) {
4977
}
5078
}
5179

52-
async function install_luajit_openresty(luaInstallPath) {
80+
async function install_luajit(luaInstallPath, luaVersion) {
81+
const luajitVersion = luaVersion.substr("luajit-".length)
82+
83+
let repo = LUAJIT_REPOS[luaVersion];
84+
if (!repo) {
85+
repo = {
86+
"url": LUAJIT_REPOS["luajit-master"].url,
87+
"branch": "v" + luajitVersion,
88+
"binary": "luajit"
89+
}
90+
}
91+
5392
const buildPath = path.join(process.env["RUNNER_TEMP"], BUILD_PREFIX)
5493
const luaCompileFlags = core.getInput('luaCompileFlags')
5594

95+
// "luajit" or "luajit2"
96+
const baseDir = repo.url.match(/.*\/(.*)\.git/)[1]
97+
5698
await io.mkdirP(buildPath)
5799

58-
await exec.exec("git clone https://github.com/openresty/luajit2.git", undefined, {
100+
await exec.exec(`git clone --branch ${repo.branch} --single-branch ${repo.url}`, undefined, {
59101
cwd: buildPath
60102
})
61103

@@ -70,45 +112,15 @@ async function install_luajit_openresty(luaInstallPath) {
70112
}
71113

72114
await exec.exec(`make ${finalCompileFlags}`, undefined, {
73-
cwd: pathJoin(buildPath, "luajit2"),
115+
cwd: pathJoin(buildPath, baseDir),
74116
...(isWindows() ? { env: { SHELL: 'cmd' }} : {})
75117
})
76118

77119
await exec.exec(`make -j install PREFIX="${luaInstallPath}"`, undefined, {
78-
cwd: pathJoin(buildPath, "luajit2")
120+
cwd: pathJoin(buildPath, baseDir)
79121
})
80122

81-
await finish_luajit_install(pathJoin(buildPath, "luajit2", "src"), luaInstallPath, "luajit")
82-
}
83-
84-
async function install_luajit(luaInstallPath, luajitVersion) {
85-
const luaExtractPath = pathJoin(process.env["RUNNER_TEMP"], BUILD_PREFIX, `LuaJIT-${luajitVersion}`)
86-
87-
const luaCompileFlags = core.getInput('luaCompileFlags')
88-
89-
const luaSourceTar = await tc.downloadTool(`https://luajit.org/download/LuaJIT-${luajitVersion}.tar.gz`)
90-
await io.mkdirP(luaExtractPath)
91-
await tc.extractTar(luaSourceTar, path.join(process.env["RUNNER_TEMP"], BUILD_PREFIX))
92-
93-
let finalCompileFlags = "-j"
94-
95-
if (isMacOS()) {
96-
finalCompileFlags += " MACOSX_DEPLOYMENT_TARGET=10.15"
97-
}
98-
99-
if (luaCompileFlags) {
100-
finalCompileFlags += ` ${luaCompileFlags}`
101-
}
102-
103-
await exec.exec(`make ${finalCompileFlags}`, undefined, {
104-
cwd: luaExtractPath
105-
})
106-
107-
await exec.exec(`make -j install PREFIX="${luaInstallPath}"`, undefined, {
108-
cwd: luaExtractPath
109-
})
110-
111-
await finish_luajit_install(pathJoin(luaExtractPath, "src"), luaInstallPath, `luajit-${luajitVersion}`)
123+
await finish_luajit_install(pathJoin(buildPath, baseDir, "src"), luaInstallPath, repo.binary)
112124
}
113125

114126
async function msvc_link(luaExtractPath, linkCmd, outFile, objs) {
@@ -231,13 +243,8 @@ async function install_plain_lua(luaInstallPath, luaVersion) {
231243
}
232244

233245
async function install(luaInstallPath, luaVersion) {
234-
if (luaVersion == "luajit-openresty") {
235-
return await install_luajit_openresty(luaInstallPath)
236-
}
237-
238246
if (luaVersion.startsWith("luajit-")) {
239-
const luajitVersion = luaVersion.substr("luajit-".length)
240-
return await install_luajit(luaInstallPath, luajitVersion)
247+
return await install_luajit(luaInstallPath, luaVersion)
241248
}
242249

243250
return await install_plain_lua(luaInstallPath, luaVersion)

0 commit comments

Comments
 (0)