Skip to content

Commit

Permalink
switching between 5.2 and 5.3: updates to soar and driver scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
stevedonovan committed Dec 20, 2014
1 parent ef375f0 commit 322dba7
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 19 deletions.
7 changes: 3 additions & 4 deletions build
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#!/bin/bash
#!/bin/sh
LUA="lua"
CC="gcc"

while [ $# -gt 0 ]
do
case "$1" in
(5.3) LUA53=1;;
(*=*) eval $1;;
-h|--help) echo "optionally LUA=lua, PLAT=plat, CC=cc"; exit;;
-h|--help) echo "optionally LUA=lua, PLAT=plat, CC=cc, LUA53=1"; exit;;
esac
shift
done
Expand Down Expand Up @@ -74,7 +73,7 @@ CMD="env $LUA lake $CC $LUAVS"
echo $CMD
if $CMD
then
env $LUA lake install.lua
env $LUA lake install.lua $LUA53
fi


Expand Down
18 changes: 15 additions & 3 deletions install.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
--- Lake script to install script wrappers in bin
local exec, join = utils.execute, path.join

print(#arg)

if arg[1] then
lua = 'lua53'
soar = 'soar53'
print 'installing Lua 5.3'
else
lua = 'lua52'
soar = 'soar52'
end

-- some platform-dependent swearing...
if WINDOWS then
bat_ext, all_args, shebang = '.bat',' %*', '@echo off\n'
else
Expand All @@ -16,7 +29,7 @@ local function make_wrapper(target,exe,name)
end
target = path.abs(target)
if not exe then
exe = path.abs(bin_dir'lua52')
exe = path.abs(bin_dir(lua))
end
local wrap = bin_dir (name)..bat_ext
file.write(wrap,shebang..exe..' '..target..all_args..'\n')
Expand All @@ -25,8 +38,7 @@ local function make_wrapper(target,exe,name)
end
end

make_wrapper ('tools/soar.lua',nil,'soar52')
make_wrapper ('tools/soar.lua','lua')
make_wrapper ('tools/soar.lua')
make_wrapper ('tools/srlua.lua','lake')
make_wrapper 'lake'

3 changes: 1 addition & 2 deletions lakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
-- you may exclude standard Lua modules as well.
-- For instance, a static.modules file like this
-- include = 'lfs'
-- exclude = 'debug
-- exclude = 'debug'
-- will statically link in LuaFileSystem and exclude the standard debug module.
local lfs = require 'lfs'
local append,join,exists = table.insert,path.join,path.exists
-- for our purposes, the distinction is between Lua 5.1 and 5.2, 5.3
local lua52 = not _VERSION:match '5.1'
local quote = path.quote
local build53 = LUA53 ~= nil
print ('LUA53',LUA53)

if not build53 then
SRC_DIR = "lua-5.2.2"
Expand Down
6 changes: 4 additions & 2 deletions test.lake
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

local name = NAME or 'lua52'
local name = NAME
if not name then
name = LUA53 and 'lua53' or 'lua52'
end
local testfile = name..'.tests'
local f,err = io.open(testfile)
if not f then quit(err) end
Expand Down
25 changes: 22 additions & 3 deletions tests
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
#!/bin/bash

. setpath

while [ $# -gt 0 ]
do
case "$1" in
(*=*) eval $1;;
-h|--help) echo "optionally LUA53=1, STATIC=1"; exit;;
esac
shift
done

if [ -z LUA53 ]
then
L53=''
L='lua52'
else
L53='L53=1'
L='lua53'
fi

# see if we can build luaish properly!
pushd luaish
soar52 -o luaish lua.lua -lconfig -lluaish.lua < t.lua
srlua -o ../bin/luaish luaish
soar -o luaish lua.lua -lconfig -lluaish.lua < t.lua
srlua -o ../bin/luaish -l $L luaish
popd
if ! luaish < luaish/t.lua
then
echo "luaish test borked"
exit
fi

lake -f test.lake
lake -f test.lake $L53
10 changes: 8 additions & 2 deletions tools/soar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,15 @@ end
-- Instead, just list things we do know about as of 2012.
local standalone_package_loaded = set{"string", "debug", "package", "_G",
"io", "os", "table", "math", "coroutine"}
if table.pack then

-- modules added subsequently by Lua 5.2 and 5.3...
if _G.bit32 then
standalone_package_loaded.bit32 = true
end
if _G.utf8 then
standalone_package_loaded.utf8 = true
end

package.standalone_package_loaded = standalone_package_loaded

-- If you're targeting another lua executable, add bit32 or whatever.
Expand Down Expand Up @@ -298,7 +304,7 @@ local function find_requires(sourcepath)
local requires = {}
local state = "none"
local candidate_module
local lua52 = _VERSION:match '5%.2$'
local lua52 = not _VERSION:match '5%.1$'

for line in f:lines() do
if line:match("^%s*$") then
Expand Down
17 changes: 14 additions & 3 deletions tools/srlua.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ srlua: [options] scriptname
-o outputname (an .exe will be appended for Windows)
--modules,-m modlist
Explicit list of modules; otherwise we read soar.out
--lua, -l Lua executable (e.g. -l lua53)
]]

local loadstring, append = loadstring or load, table.insert
Expand Down Expand Up @@ -41,7 +42,8 @@ local function execute(cmd)
return utils.execute(cmd)
end

local scriptname, outfile, binmods
local scriptname, outfile, binmods,L53
local lua = os.getenv 'LUA53' and 'lua53' or 'lua52'
local i = 1
while i <= #arg do
local a = arg[i]
Expand All @@ -51,12 +53,21 @@ while i <= #arg do
elseif a == '-m' or a == '--modules' then
i = i + 1
binmods = utils.split(arg[i])
elseif a == '-l' or a == '--lua' then
i = i + 1
lua = arg[i]
else
scriptname = a
end
i = i + 1
end

if lua == 'lua53' then
L53 = 'LUA53=1'
else
L53 = ''
end

if not scriptname then quit(usage) end
if not outfile then
local _,file = path.splitpath(scriptname)
Expand Down Expand Up @@ -84,7 +95,7 @@ table.sort(binmods)
-- this defines the canonical name for srlua executables
-- if there were no bin modules, then we'll just use the static executable
local were_mods = #binmods > 0
local canon = 'lua-'..table.concat(were_mods and binmods or {'static'},'-')
local canon = lua..'-'..table.concat(were_mods and binmods or {'static'},'-')

local uses_linenoise = list.index(binmods,'linenoise')

Expand All @@ -102,7 +113,7 @@ if not path.exists(fullpath) then
end
f:write('srlua = "',canon,'"\n')
f:close()
local cmd = 'lua '..lb_path'lake'..' -d '..lb_dir..' CONFIG='..canon..'.config'
local cmd = lua..' '..lb_path'lake'..' -d '..lb_dir..' CONFIG='..canon..'.config '..L53
if not execute(cmd) then quit '----we had a problem----' end
end

Expand Down

0 comments on commit 322dba7

Please sign in to comment.