diff --git a/README.md b/README.md index fd9f8cc6..05932d6a 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Download (stable) [![Build Status](https://travis-ci.org/bkaradzic/GENie.svg?branch=master)](https://travis-ci.org/bkaradzic/GENie) - version 1104 (commit 9bded4c5ef2cf2641c61d5e7b0ddf7ec41afddd7) + version 1111 (commit dda72349cd2cf1a741c5490e06dc87d457d7f22b) Linux: https://github.com/bkaradzic/bx/raw/master/tools/bin/linux/genie diff --git a/scripts/embed.lua b/scripts/embed.lua index 05165923..39703b1d 100644 --- a/scripts/embed.lua +++ b/scripts/embed.lua @@ -5,6 +5,8 @@ -- issues in Mac OS X Universal builds. -- + local scriptdir = path.getdirectory(_SCRIPT) + local function stripfile(fname) local f = io.open(fname) local s = assert(f:read("*a")) @@ -73,13 +75,13 @@ function doembed() -- load the manifest of script files - scripts = dofile("../src/_manifest.lua") + scripts = dofile(path.join(scriptdir, "../src/_manifest.lua")) -- main script always goes at the end table.insert(scripts, "_premake_main.lua") -- open scripts.c and write the file header - local out = io.open("../src/host/scripts.c", "w+b") + local out = io.open(path.join(scriptdir, "../src/host/scripts.c"), "w+b") out:write("/* Premake's Lua scripts, as static data buffers for release mode builds */\n") out:write("/* DO NOT EDIT - this file is autogenerated - see BUILD.txt */\n") out:write("/* To regenerate this file, run: premake4 embed */ \n\n") @@ -87,7 +89,7 @@ for i,fn in ipairs(scripts) do print(fn) - local s = stripfile("../src/" .. fn) + local s = stripfile(path.join(scriptdir,"../src/" .. fn)) writefile(out, fn, s) end diff --git a/src/_premake_main.lua b/src/_premake_main.lua index b92e4fa6..7872331b 100644 --- a/src/_premake_main.lua +++ b/src/_premake_main.lua @@ -84,8 +84,10 @@ else local dir, name = premake.findDefaultScript(path.getabsolute("./")) if dir ~= nil then + local cwd = os.getcwd() os.chdir(dir) dofile(name) + os.chdir(cwd) end end diff --git a/src/base/premake.lua b/src/base/premake.lua index c96ef0f2..a4051427 100644 --- a/src/base/premake.lua +++ b/src/base/premake.lua @@ -52,7 +52,7 @@ end if delta then - printf("Generating %s...", filename) + printf("Generating %q", filename) local f, err = io.open(filename, "wb") if (not f) then error(err, 0) @@ -67,7 +67,7 @@ premake.stats.num_skipped = premake.stats.num_skipped + 1 end else - printf("Generating %s...", filename) + printf("Generating %q", filename) local f, err = io.open(filename, "wb") if (not f) then diff --git a/src/host/scripts.c b/src/host/scripts.c index f9e264f3..7edda214 100644 --- a/src/host/scripts.c +++ b/src/host/scripts.c @@ -190,8 +190,8 @@ const char* builtin_scripts[] = { "function premake.showhelp()\nprintf(\"\")\nprintf(\"Usage: genie [options] action [arguments]\")\nprintf(\"\")\nprintf(\"OPTIONS\")\nprintf(\"\")\nfor option in premake.option.each() do\nlocal trigger = option.trigger\nlocal description = option.description\nif (option.value) then trigger = trigger .. \"=\" .. option.value end\nif (option.allowed) then description = description .. \"; one of:\" end\nprintf(\" --%-15s %s\", trigger, description)\nif (option.allowed) then\nfor _, value in ipairs(option.allowed) do\nprintf(\" %-14s %s\", value[1], value[2])\nend\nend\nprintf(\"\")\nend\nprintf(\"ACTIONS\")\nprintf(\"\")\nfor action in premake.action.each() do\nprintf(\" %-17s %s\", action.trigger, action.description)\nend\nprintf(\"\")\nprintf(\"For additional information, see https://github.com/bkaradzic/genie\")\nend\n", /* base/premake.lua */ - "premake._filelevelconfig = false\npremake._checkgenerate = true\nfunction premake.generate(obj, filename, callback)\nlocal prev = io.capture()\nlocal abort = (callback(obj) == false)\nlocal new = io.endcapture(prev)\nif abort then\npremake.stats.num_skipped = premake.stats.num_skipped + 1\nreturn\nend\nfilename = premake.project.getfilename(obj, filename)\nif (premake._checkgenerate) then\nlocal delta = false\nlocal f, err = io.open(filename, \"rb\")\nif (not f) then\nif string.find(err, \"No such file or directory\") then\ndelta = true\nelse\nerror(err, 0)\nend\nelse\nlocal existing = f:read(\"*all\")\nif existing ~= new then\ndelta = true\nend\nf:close()\nend\nif delta then\nprintf(\"Generating %s...\", filename)\nlocal f, err = io.open(filename, \"wb\")\nif (not f) then\nerror(err, 0)\nend\nf:write(new)\nf:close()\npremake.stats.num_generated = premake.stats.num_generated + 1\nelse\npremake.stats.num_skipped = premake.stats.num_skipped + 1\nend\nelse\nprintf(\"Generating %s...\", filename)\nlocal f, err " - "= io.open(filename, \"wb\")\nif (not f) then\nerror(err, 0)\nend\nf:write(new)\nf:close()\npremake.stats.num_generated = premake.stats.num_generated + 1\nend\nend\nfunction premake.findDefaultScript(dir, search_upwards)\nsearch_upwards = search_upwards or true\nlocal last = \"\"\nwhile dir ~= last do\nfor _, name in ipairs({ \"genie.lua\", \"solution.lua\", \"premake4.lua\" }) do\nlocal script0 = dir .. \"/\" .. name\nif (os.isfile(script0)) then\nreturn dir, name\nend\nlocal script1 = dir .. \"/scripts/\" .. name\nif (os.isfile(script1)) then\nreturn dir .. \"/scripts/\", name\nend\nend\nlast = dir\ndir = path.getabsolute(dir .. \"/..\")\nif dir == \".\" or not search_upwards then break end\nend\nreturn nil, nil\nend\n", + "premake._filelevelconfig = false\npremake._checkgenerate = true\nfunction premake.generate(obj, filename, callback)\nlocal prev = io.capture()\nlocal abort = (callback(obj) == false)\nlocal new = io.endcapture(prev)\nif abort then\npremake.stats.num_skipped = premake.stats.num_skipped + 1\nreturn\nend\nfilename = premake.project.getfilename(obj, filename)\nif (premake._checkgenerate) then\nlocal delta = false\nlocal f, err = io.open(filename, \"rb\")\nif (not f) then\nif string.find(err, \"No such file or directory\") then\ndelta = true\nelse\nerror(err, 0)\nend\nelse\nlocal existing = f:read(\"*all\")\nif existing ~= new then\ndelta = true\nend\nf:close()\nend\nif delta then\nprintf(\"Generating %q\", filename)\nlocal f, err = io.open(filename, \"wb\")\nif (not f) then\nerror(err, 0)\nend\nf:write(new)\nf:close()\npremake.stats.num_generated = premake.stats.num_generated + 1\nelse\npremake.stats.num_skipped = premake.stats.num_skipped + 1\nend\nelse\nprintf(\"Generating %q\", filename)\nlocal f, err = io.o" + "pen(filename, \"wb\")\nif (not f) then\nerror(err, 0)\nend\nf:write(new)\nf:close()\npremake.stats.num_generated = premake.stats.num_generated + 1\nend\nend\nfunction premake.findDefaultScript(dir, search_upwards)\nsearch_upwards = search_upwards or true\nlocal last = \"\"\nwhile dir ~= last do\nfor _, name in ipairs({ \"genie.lua\", \"solution.lua\", \"premake4.lua\" }) do\nlocal script0 = dir .. \"/\" .. name\nif (os.isfile(script0)) then\nreturn dir, name\nend\nlocal script1 = dir .. \"/scripts/\" .. name\nif (os.isfile(script1)) then\nreturn dir .. \"/scripts/\", name\nend\nend\nlast = dir\ndir = path.getabsolute(dir .. \"/..\")\nif dir == \".\" or not search_upwards then break end\nend\nreturn nil, nil\nend\n", /* base/iter.lua */ "iter = {}\nfunction iter.sortByKeys(arr, f)\nlocal a = table.keys(arr)\ntable.sort(a, f)\nlocal i = 0\nreturn function()\ni = i + 1\nif a[i] ~= nil then \nreturn a[i], arr[a[i]]\nend\nend\nend\n", @@ -538,8 +538,8 @@ const char* builtin_scripts[] = { /* _premake_main.lua */ "_WORKING_DIR = os.getcwd()\nlocal function injectplatform(platform)\nif not platform then return true end\nplatform = premake.checkvalue(platform, premake.fields.platforms.allowed)\nfor sln in premake.solution.each() do\nlocal platforms = sln.platforms or { }\nif #platforms == 0 then\ntable.insert(platforms, \"Native\")\nend\nif not table.contains(platforms, \"Native\") then\nreturn false, sln.name .. \" does not target native platform\\nNative platform settings are required for the --platform feature.\"\nend\nif not table.contains(platforms, platform) then\ntable.insert(platforms, platform)\nend\nsln.platforms = platforms\nend\nreturn true\nend\nfunction _premake_main(scriptpath)\nif (scriptpath) then\nlocal scripts = dofile(scriptpath .. \"/_manifest.lua\")\nfor _,v in ipairs(scripts) do\ndofile(scriptpath .. \"/\" .. v)\nend\nend\nlocal profiler = newProfiler()\nif (nil ~= _OPTIONS[\"debug-profiler\"]) then\nprofiler:start()\nend\n_PREMAKE_COMMAND = path.getabsolute(_PREMAKE_COMMAND)\npremake.action" - ".set(_ACTION)\nmath.randomseed(os.time())\nif (nil ~= _OPTIONS[\"file\"]) then\nlocal fname = _OPTIONS[\"file\"]\nif (os.isfile(fname)) then\ndofile(fname)\nelse\nerror(\"No genie script '\" .. fname .. \"' found!\", 2)\nend\nelse\nlocal dir, name = premake.findDefaultScript(path.getabsolute(\"./\"))\nif dir ~= nil then\nos.chdir(dir)\ndofile(name)\nend\nend\nif (_OPTIONS[\"version\"] or _OPTIONS[\"help\"] or not _ACTION) then\nprintf(\"GENie - Project generator tool %s\", _GENIE_VERSION_STR)\nprintf(\"https://github.com/bkaradzic/GENie\")\nif (not _OPTIONS[\"version\"]) then\npremake.showhelp()\nend\nreturn 1\nend\naction = premake.action.current()\nif (not action) then\nerror(\"Error: no such action '\" .. _ACTION .. \"'\", 0)\nend\nok, err = premake.option.validate(_OPTIONS)\nif (not ok) then error(\"Error: \" .. err, 0) end\nok, err = premake.checktools()\nif (not ok) then error(\"Error: \" .. err, 0) end\nok, err = injectplatform(_OPTIONS[\"platform\"])\nif (not ok) then error(\"Error: \" .. err, 0) end\n" - "print(\"Building configurations...\")\npremake.bake.buildconfigs()\nok, err = premake.checkprojects()\nif (not ok) then error(\"Error: \" .. err, 0) end\npremake.stats = { }\npremake.stats.num_generated = 0\npremake.stats.num_skipped = 0\nprintf(\"Running action '%s'...\", action.trigger)\npremake.action.call(action.trigger)\nif (nil ~= _OPTIONS[\"debug-profiler\"]) then\nprofiler:stop()\nlocal filePath = path.getabsolute(\"GENie-profile.txt\")\nprint(\"Writing debug-profile report to ''\" .. filePath .. \"'.\")\nlocal outfile = io.open(filePath, \"w+\")\nprofiler:report(outfile, true)\noutfile:close()\nend\nprintf(\"Done. Generated %d/%d projects.\"\n, premake.stats.num_generated\n, premake.stats.num_generated+premake.stats.num_skipped\n)\nreturn 0\nend\n", + ".set(_ACTION)\nmath.randomseed(os.time())\nif (nil ~= _OPTIONS[\"file\"]) then\nlocal fname = _OPTIONS[\"file\"]\nif (os.isfile(fname)) then\ndofile(fname)\nelse\nerror(\"No genie script '\" .. fname .. \"' found!\", 2)\nend\nelse\nlocal dir, name = premake.findDefaultScript(path.getabsolute(\"./\"))\nif dir ~= nil then\nlocal cwd = os.getcwd()\nos.chdir(dir)\ndofile(name)\nos.chdir(cwd)\nend\nend\nif (_OPTIONS[\"version\"] or _OPTIONS[\"help\"] or not _ACTION) then\nprintf(\"GENie - Project generator tool %s\", _GENIE_VERSION_STR)\nprintf(\"https://github.com/bkaradzic/GENie\")\nif (not _OPTIONS[\"version\"]) then\npremake.showhelp()\nend\nreturn 1\nend\naction = premake.action.current()\nif (not action) then\nerror(\"Error: no such action '\" .. _ACTION .. \"'\", 0)\nend\nok, err = premake.option.validate(_OPTIONS)\nif (not ok) then error(\"Error: \" .. err, 0) end\nok, err = premake.checktools()\nif (not ok) then error(\"Error: \" .. err, 0) end\nok, err = injectplatform(_OPTIONS[\"platform\"])\nif (not ok)" + " then error(\"Error: \" .. err, 0) end\nprint(\"Building configurations...\")\npremake.bake.buildconfigs()\nok, err = premake.checkprojects()\nif (not ok) then error(\"Error: \" .. err, 0) end\npremake.stats = { }\npremake.stats.num_generated = 0\npremake.stats.num_skipped = 0\nprintf(\"Running action '%s'...\", action.trigger)\npremake.action.call(action.trigger)\nif (nil ~= _OPTIONS[\"debug-profiler\"]) then\nprofiler:stop()\nlocal filePath = path.getabsolute(\"GENie-profile.txt\")\nprint(\"Writing debug-profile report to ''\" .. filePath .. \"'.\")\nlocal outfile = io.open(filePath, \"w+\")\nprofiler:report(outfile, true)\noutfile:close()\nend\nprintf(\"Done. Generated %d/%d projects.\"\n, premake.stats.num_generated\n, premake.stats.num_generated+premake.stats.num_skipped\n)\nreturn 0\nend\n", 0 };