@@ -3,13 +3,14 @@ const exec = require("@actions/exec")
33const io = require ( "@actions/io" )
44const tc = require ( "@actions/tool-cache" )
55
6- process . env [ "DEBUG" ] = process . env [ "DEBUG" ] || "setup-lua"
7- const debug = require ( "debug" ) ( "setup-lua" )
86
97
8+ process . env [ "DEBUG" ] = process . env [ "DEBUG" ] || "setup-lua"
9+ const debug = require ( "debug" ) ( "setup-lua" )
1010const path = require ( "path" )
1111const fs = require ( "fs" )
1212const md5File = require ( 'md5-file' )
13+ const os = require ( "os" )
1314
1415const SOURCE_DIRECTORY = path . join ( process . cwd ( ) , ".source/" )
1516const INSTALL_PREFIX = path . join ( process . cwd ( ) , ".lua/" )
@@ -181,6 +182,9 @@ async function installSystemDependencies() {
181182}
182183
183184async function addCMakeBuildScripts ( sourcePath , luaVersion ) {
185+ if ( luaVersion . indexOf ( "jit" ) > - 1 ) {
186+ return ;
187+ }
184188 debug ( "addCMakeBuildScripts %s, %s" , sourcePath , luaVersion )
185189 fs . unlinkSync ( path . join ( sourcePath , "src" , "luaconf.h" ) )
186190 debug ( "removed luaconf.h" )
@@ -195,7 +199,29 @@ async function addCMakeBuildScripts(sourcePath, luaVersion) {
195199
196200async function buildAndInstall ( sourcePath , platform ) {
197201 debug ( "buildAndInstall %s, %s" , sourcePath , platform )
202+ if ( / j i t / i. test ( sourcePath ) ) {
203+ await buildAndInstallLuaJIT ( sourcePath , platform )
204+ } else {
205+ await buildAndInstallLua5 ( sourcePath , platform )
206+ }
207+ core . addPath ( path . join ( INSTALL_PREFIX , "bin" ) ) ;
208+ }
198209
210+ async function buildAndInstallLuaJIT ( sourcePath ) {
211+ debug ( "buildAndInstallLuaJIT %s" , sourcePath )
212+ let env
213+ if ( process . platform == "darwin" ) {
214+ env = {
215+ MACOSX_DEPLOYMENT_TARGET : os . release ( ) . split ( '.' ) . slice ( 0 , 2 ) . map ( n => `0${ n } ` . substr ( - 2 ) ) . join ( '.' ) ,
216+ }
217+ }
218+ await exec . exec ( `make PREFIX=${ INSTALL_PREFIX } ` , undefined , { cwd : sourcePath , env } )
219+ await exec . exec ( "sudo make install" , undefined , { cwd : sourcePath , env } )
220+
221+ }
222+
223+ async function buildAndInstallLua5 ( sourcePath , platform ) {
224+ debug ( "buildAndInstallLua5 %s, %s" , sourcePath , platform )
199225 if ( platform ) {
200226 await exec . exec ( `cmake -H"${ sourcePath } " -Bbuild -DCMAKE_INSTALL_PREFIX=${ INSTALL_PREFIX } -A${ platform } ` , undefined , {
201227 cwd : sourcePath
@@ -210,8 +236,6 @@ async function buildAndInstall(sourcePath, platform) {
210236 await exec . exec ( `cmake --build build --config Release --target install` , undefined , {
211237 cwd : sourcePath
212238 } )
213-
214- core . addPath ( path . join ( INSTALL_PREFIX , "bin" ) ) ;
215239}
216240
217241async function main ( ) {
0 commit comments