diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2012-08-30 14:11:05 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2012-08-30 14:11:05 +0100 |
commit | a797a8a9d11b0f0ca9bc738192475b06d5aacc9a (patch) | |
tree | 91d4ee70d1842d3487f32712278b7c9c56139005 /utils | |
parent | f853bbf411c5bddfc3c4b46ad1c0593fcf56d93b (diff) | |
download | gitano-a797a8a9d11b0f0ca9bc738192475b06d5aacc9a.tar.gz |
BUILD: Start of a build system and thus installer
Diffstat (limited to 'utils')
-rw-r--r-- | utils/install-lua-bin | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/utils/install-lua-bin b/utils/install-lua-bin new file mode 100644 index 0000000..1e5b105 --- /dev/null +++ b/utils/install-lua-bin @@ -0,0 +1,44 @@ +-- Run this explicitly through -*- Lua -*- + +local lua_bin, inst_mod_path, input_name, output_name = ... + +local input_fh = assert(io.open(input_name, "r")) +local output_fh = assert(io.open(output_name, "w")) + +local line = input_fh:read "*l" + +if not inst_mod_path:match("%?") then + inst_mod_path = inst_mod_path .. "/?.lua" + inst_mod_path = inst_mod_path:gsub("/+", "/") +end + +local mod_path_present = false +for path_elem in package.path:gmatch("([^;]+)") do + if path_elem == inst_mod_path then + mod_path_present = true + break + end +end + +while line do + local token = line:match("^%-%- @@(.+)$") + if token then + if token == "SHEBANG" then + output_fh:write(("#!%s\n"):format(lua_bin)) + elseif token == "GITANO_LUA_PATH" then + if not mod_path_present then + output_fh:write(("package.path = ('%%s;%%s'):" .. + "format(%q, package.path)" .. + "\n"):format(inst_mod_path)) + else + output_fh:write("-- Gitano modules installed into " .. + inst_mod_path .. "\n") + end + else + output_fh:write("-- Unknown token: " .. token .. "\n") + end + else + output_fh:write(line .. "\n") + end + line = input_fh:read "*l" +end |