Skip to content

Commit

Permalink
Add. rockspec and appveyor.yml files.
Browse files Browse the repository at this point in the history
  • Loading branch information
moteus committed Nov 5, 2016
1 parent 3a1c8ab commit 07221a6
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 59 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ All Rights Deserved. Use at your own risk!. Shake well before using.

#Introduction

winreg is a Lua binary module to Access Microsoft(R) Windows(R) Registry. The registry is a system-defined database that applications and Microsoft(R) Windows(R) system components use to store and retrieve configuration data.
winreg is a Lua binary module to Access Microsoft(R) Windows(R) Registry. The registry is a
system-defined database that applications and Microsoft(R) Windows(R) system components use to
store and retrieve configuration data.
Load the module via the require function (make sure Lua can find the module), for example:

```lua
Expand All @@ -21,8 +23,8 @@ hkey = winreg.openkey[[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVers

skey = hkey:openkey([[Explorer\Shell Folders]])
for name in skey:enumvalue() do
print("\nname: " .. name
.. "\npath: " .. skey:getvalue(name))
print("\nname: " .. name
.. "\npath: " .. skey:getvalue(name))
end
```

32 changes: 32 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: 0.1.0.{build}

environment:
matrix:
- LUA: "lua 5.1"
- LUA: "lua 5.2"
- LUA: "lua 5.3"

platform:
- x64
- x86

before_build:
- set PATH=C:\Python27\Scripts;%PATH%
- pip install hererocks
- if /I "%platform%"=="x86" set HR_TARGET=vs_32
- if /I "%platform%"=="x64" set HR_TARGET=vs_64
- hererocks env --%LUA% --target %HR_TARGET% -rlatest
- call env\bin\activate

build_script:
- luarocks make rockspecs\winreg-scm-0.rockspec

test_script:
- cd test
- lua test_1.lua
- lua test_5_1_5.lua
- lua test_5_1_6.lua
- lua test_5_1_8.lua
- lua test_5_1_9.lua
- lua test_5_1_10.lua
- lua test_5_1_13.lua
81 changes: 25 additions & 56 deletions lakeconfig.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
J = J or path.join
J = IF or choose

function vc_version()
local VER = lake.compiler_version()
MSVC_VER = ({
Expand All @@ -7,64 +10,12 @@ function vc_version()
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)
function run_lua(file, cwd)
print()
print("run " .. file)
if not TESTING then
Expand All @@ -78,14 +29,16 @@ function run(file, cwd)
end

function run_test(name, params)
local test_dir = J(ROOT, 'test')
local test_dir = TEST_DIR or J(ROOT, 'test')
local cmd = J(test_dir, name)
if params then cmd = cmd .. ' ' .. params end
local ok = run(cmd, test_dir)
local ok = run_lua(cmd, test_dir)
print("TEST " .. cmd .. (ok and ' - pass!' or ' - fail!'))
end

function spawn(file, cwd)
do -- spawn

local function spawn_win(file, cwd)
local winapi = prequire "winapi"
if not winapi then
print(file, ' error: Test needs winapi!')
Expand All @@ -101,6 +54,22 @@ function spawn(file, cwd)
return true
end

local function spawn_nix(file, cwd)
print("spawn " .. file)
if not TESTING then
if cwd then lake.chdir(cwd) end
local status, code = utils.execute( LUA_RUNNER .. file .. ' &', true )
if cwd then lake.chdir("<") end
print()
return status, code
end
return true
end

spawn = WINDOWS and spawn_win or spawn_nix

end

function as_bool(v,d)
if v == nil then return not not d end
local n = tonumber(v)
Expand Down
47 changes: 47 additions & 0 deletions rockspecs/winreg-scm-0.rockspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package = "winreg"
version = "scm-0"
source = {
url = "https://github.com/moteus/lua-winreg/archive/master.zip",
dir = "lua-winreg-master",
}

description = {
summary = "Lua module to Access Microsoft(R) Windows(R) Registry",
homepage = "http://github.com/moteus/lua-winreg",
license = "MIT/X11",
detailed = [[
]],
}

supported_platforms = {
"windows"
}

dependencies = {
"lua >= 5.1, < 5.4",
}

build = {
type = "builtin",

copy_directories = {'doc', 'examples', 'test'},

modules = {
winreg = {
sources = {
"src/l52util.c", "src/lua_int64.c", "src/lua_mtutil.c", "src/lua_tstring.c",
"src/luawin_dllerror.c", "src/win_privileges.c", "src/win_registry.c",
"src/win_trace.c", "src/winreg.c",
},
defines = {
"WIN32"; "_WIN32"; "_WINDOWS",
"WIN32_LEAN_AND_MEAN"; "WINDLL"; "USRDLL",
"NDEBUG", "_CRT_SECURE_NO_WARNINGS",
"CRTAPI1=_cdecl", "CRTAPI2=_cdecl",
"WINREG_EXPORTS", "WINREG_API=__declspec(dllexport)"
},
libraries = {"advapi32", "kernel32", "user32"},
}
}
}

0 comments on commit 07221a6

Please sign in to comment.