Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/lua-winreg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormoteus <mimir@newmail.ru>2013-04-28 07:19:31 +0400
committermoteus <mimir@newmail.ru>2013-04-28 07:19:31 +0400
commit3a1c8ab327cad1771664cc6e5ddb83706f22d93a (patch)
tree34566b7bb9014b11cab793f8f543a68d1033b831
parent503236b46faf48195a20955fe227f9886506c143 (diff)
Update lakefile. Now work with MinGW.
-rw-r--r--lakeconfig.lua130
-rw-r--r--lakefile46
2 files changed, 148 insertions, 28 deletions
diff --git a/lakeconfig.lua b/lakeconfig.lua
new file mode 100644
index 0000000..33ea7f6
--- /dev/null
+++ b/lakeconfig.lua
@@ -0,0 +1,130 @@
+function vc_version()
+ local VER = lake.compiler_version()
+ MSVC_VER = ({
+ [15] = '9';
+ [16] = '10';
+ })[VER.MAJOR] or ''
+ return MSVC_VER
+end
+
+local function arkey(t)
+ assert(type(t) == 'table')
+ local keys = {}
+ for k in pairs(t) do
+ assert(type(k) == 'number')
+ table.insert(keys, k)
+ end
+ table.sort(keys)
+ return keys
+end
+
+local function ikeys(t)
+ local keys = arkey(t)
+ local i = 0
+ return function()
+ i = i + 1
+ local k = keys[i]
+ if k == nil then return end
+ return k, t[k]
+ end
+end
+
+local function expand(arr, t)
+ if t == nil then return arr end
+
+ if type(t) ~= 'table' then
+ table.insert(arr, t)
+ return arr
+ end
+
+ for _, v in ikeys(t) do
+ expand(arr, v)
+ end
+
+ return arr
+end
+
+function L(...)
+ return expand({}, {...})
+end
+
+J = J or path.join
+
+IF = IF or lake.choose or choose
+
+function prequire(...)
+ local ok, mod = pcall(require, ...)
+ if ok then return mod end
+end
+
+function each_join(dir, list)
+ for i, v in ipairs(list) do
+ list[i] = path.join(dir, v)
+ end
+ return list
+end
+
+function run(file, cwd)
+ print()
+ print("run " .. file)
+ if not TESTING then
+ if cwd then lake.chdir(cwd) end
+ local status, code = utils.execute( LUA_RUNNER .. ' ' .. file )
+ if cwd then lake.chdir("<") end
+ print()
+ return status, code
+ end
+ return true, 0
+end
+
+function run_test(name, params)
+ local test_dir = J(ROOT, 'test')
+ local cmd = J(test_dir, name)
+ if params then cmd = cmd .. ' ' .. params end
+ local ok = run(cmd, test_dir)
+ print("TEST " .. cmd .. (ok and ' - pass!' or ' - fail!'))
+end
+
+function spawn(file, cwd)
+ local winapi = prequire "winapi"
+ if not winapi then
+ print(file, ' error: Test needs winapi!')
+ return false
+ end
+ print("spawn " .. file)
+ if not TESTING then
+ if cwd then lake.chdir(cwd) end
+ assert(winapi.shell_exec(nil, LUA_RUNNER, file, cwd))
+ if cwd then lake.chdir("<") end
+ print()
+ end
+ return true
+end
+
+function as_bool(v,d)
+ if v == nil then return not not d end
+ local n = tonumber(v)
+ if n == 0 then return false end
+ if n then return true end
+ return false
+end
+
+-----------------------
+-- needs --
+-----------------------
+
+lake.define_need('lua52', function()
+ return {
+ incdir = J(ENV.LUA_DIR_5_2, 'include');
+ libdir = J(ENV.LUA_DIR_5_2, 'lib');
+ libs = {'lua52'};
+ }
+end)
+
+lake.define_need('lua51', function()
+ return {
+ incdir = J(ENV.LUA_DIR, 'include');
+ libdir = J(ENV.LUA_DIR, 'lib');
+ libs = {'lua5.1'};
+ }
+end) \ No newline at end of file
diff --git a/lakefile b/lakefile
index b5b38dc..0db0468 100644
--- a/lakefile
+++ b/lakefile
@@ -1,14 +1,22 @@
if not WINDOWS then quit('This is only windows module!') end
+PROJECT = 'winreg'
+
if LUA_VER == '5.2' then
LUA_NEED = 'lua52'
LUA_DIR = ENV.LUA_DIR_5_2 or ENV.LUA_DIR
+ LUA_RUNNER = 'lua52'
else
- LUA_NEED = 'lua'
+ LUA_NEED = 'lua51'
LUA_DIR = ENV.LUA_DIR
+ LUA_RUNNER = 'lua'
end
-DYNAMIC = DYNAMIC or false
+ROOT = ROOT or J(LUA_DIR, 'libs', PROJECT)
+LUADIR = LUADIR or J(ROOT, 'share')
+LIBDIR = LIBDIR or J(ROOT, 'share')
+DYNAMIC = as_bool(DYNAMIC, false)
+WINVER = IF(WINDOWS, WINVER or '501', '')
lake.define_need('unicode',function()return{
defines = {"UNICODE"; "_UNICODE"};
@@ -45,36 +53,18 @@ winreg = c.shared{'winreg',
target('build',{winreg})
install = target('install', {
- file.group{odir=J(INSTALL_DIR, 'test');
- src = J('test','*.*');recurse=true;
- };
- file.group{odir=J(INSTALL_DIR, 'doc');
- src = J('doc','*.*');recurse=true;
- };
- file.group{odir=J(INSTALL_DIR, 'examples');
- src = J('examples','*.*');recurse=true;
- };
- target(J(INSTALL_DIR, 'bin', winreg.name .. DLL_EXT), winreg, CP );
+ file.group{odir=J(ROOT, 'test'); src = J('test','*.*'); recurse=true };
+ file.group{odir=J(ROOT, 'doc'); src = J('doc','*.*'); recurse=true };
+ file.group{odir=J(ROOT, 'examples'); src = J('examples','*.*');recurse=true };
+ file.group{odir = LIBDIR; src = winreg};
})
target('test', install, function()
- if TESTING then
- lake.chdir('test')
- for file in path.mask('*.lua') do
- print("run " .. file)
- end
- lake.chdir('<')
- end
- if not TESTING then
- lake.chdir(J(INSTALL_DIR,'test'))
- for file in path.mask('*.lua') do
- print("run " .. file)
- if not utils.execute( LUA_EXE .. ' ' .. file ) then
- quit("FAIL!")
- end
- end
- lake.chdir('<')
+ lake.chdir('test')
+ for file in path.mask('*.lua') do
+ run_test(file)
end
+ lake.chdir('<')
end)
default('build')