Skip to content

Commit ff60894

Browse files
author
Robert Masen
committed
add debug logging
1 parent 84f642e commit ff60894

File tree

14 files changed

+1748
-1
lines changed

14 files changed

+1748
-1
lines changed

main.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ const exec = require("@actions/exec")
33
const io = require("@actions/io")
44
const tc = require("@actions/tool-cache")
55

6+
process.env["DEBUG"] = process.env["DEBUG"] || "setup-lua"
7+
const debug = require("debug")("setup-lua")
8+
9+
610
const path = require("path")
711
const fs = require("fs")
812
const md5File = require('md5-file')
@@ -93,15 +97,19 @@ function mergeDirectory(source, dest) {
9397
}
9498

9599
function getTarball(version) {
100+
debug("getTarball %s", version)
96101
const v = VERSION_ALIASES[version] || version
102+
debug("maybe aliased version %s", v || "v is undefined...")
97103
if (!TARBALLS[v] || TARBALLS[v].length != 2) {
98104
throw RangeError("Unsupported lua version: " + version)
99105
}
100106
return [TARBALLS[v][1], TARBALLS[v][0]]
101107
}
102108

103109
function getLuaVersion() {
110+
debug("getLuaVersion")
104111
const luaVersion = core.getInput('lua-version', { required: false })
112+
debug("version from input %s", luaVersion)
105113
return VERSION_ALIASES[luaVersion] || luaVersion || "5.1.5"
106114
}
107115

@@ -111,6 +119,7 @@ function getPlatform() {
111119
}
112120

113121
async function download(url, hash) {
122+
debug("download url: %s, hash: %s", url, hash)
114123
const luaSourceTar = await tc.downloadTool(url)
115124
if (hash != md5File.sync(luaSourceTar)) {
116125
throw Error("MD5 mismatch, please check your network.");
@@ -119,30 +128,38 @@ async function download(url, hash) {
119128
}
120129

121130
function tarballContentDirectory(version) {
131+
debug("tarballContentDirectory %s", version)
122132
if (version.startsWith("luajit")) {
123-
const luajitVersion = luaVersion.substr("luajit-".length)
133+
debug("LuaJIT version: %s", luajitVersion)
124134
return `LuaJIT-${luajitVersion}`
125135
}
126136
return `lua-${version}`
127137
}
128138

129139
async function extractTarball(tarball, version) {
140+
debug("extractTarball %s", version)
130141
await io.mkdirP(SOURCE_DIRECTORY)
142+
debug("made source directory")
131143
await exec.exec(`cmake -E tar xzf "${tarball}"`, undefined, {
132144
cwd: SOURCE_DIRECTORY
133145
})
146+
debug("executed cmake -E tar xzf")
134147
showDirectory(SOURCE_DIRECTORY)
135148
const dir = tarballContentDirectory(version)
149+
debug("tarball content directory: %s", dir)
136150
return path.join(SOURCE_DIRECTORY, dir)
137151
}
138152

139153
async function downloadSource(luaVersion) {
154+
debug("downloadSource %s", luaVersion)
140155
const [url, hash] = getTarball(luaVersion)
156+
debug("tarball url: %s, hash: %s", url, hash)
141157
const tarball = await download(url, hash)
142158
return extractTarball(tarball, luaVersion)
143159
}
144160

145161
async function installSystemDependencies() {
162+
debug("installSystemDependencies")
146163
if (process.platform == "linux") {
147164
return await exec.exec("sudo apt-get install -q libreadline-dev libncurses-dev", undefined, {
148165
env: {
@@ -163,15 +180,20 @@ async function installSystemDependencies() {
163180
}
164181

165182
async function addCMakeBuildScripts(sourcePath, luaVersion) {
183+
debug("addCMakeBuildScripts %s, %s", sourcePath, luaVersion)
166184
fs.unlinkSync(path.join(sourcePath, "src", "luaconf.h"))
185+
debug("removed luaconf.h")
167186
mergeDirectory(path.join(__dirname, "patch", "shared"), sourcePath)
187+
debug("merged patch/shared with %s", sourcePath)
168188
const v = luaVersion.replace(/\.\d*$/,'')
189+
debug("v: %s", v)
169190
mergeDirectory(path.join(__dirname, "patch", "lua", v), sourcePath)
170191
console.log("VERSION: " + v)
171192
showDirectory(sourcePath)
172193
}
173194

174195
async function buildAndInstall(sourcePath, platform) {
196+
debug("buildAndInstall %s, %s", sourcePath, platform)
175197

176198
if(platform){
177199
await exec.exec(`cmake -H"${sourcePath}" -Bbuild -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -A${platform}`, undefined, {
@@ -192,12 +214,19 @@ async function buildAndInstall(sourcePath, platform) {
192214
}
193215

194216
async function main() {
217+
debug("main")
195218
await installSystemDependencies()
219+
debug("System dependencies installed")
196220
const luaVersion = getLuaVersion()
221+
debug("Got lua version: %s", luaVersion)
197222
const platform = getPlatform();
223+
debug("Got Platform: %s", platform)
198224
const sourcePath = await downloadSource(luaVersion)
225+
debug("Downloaded to: %s", sourcePath)
199226
await addCMakeBuildScripts(sourcePath, luaVersion)
227+
debug("Added cmake build scripts")
200228
await buildAndInstall(sourcePath, platform)
229+
debug("built and installed")
201230
}
202231

203232
main().catch(err => {

node_modules/debug/LICENSE

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)