bkaradzic / GENie

GENie - Project generator tool
Other
905 stars 168 forks source link

`[string "premake.bake = { }..."]:497: bad argument #1 to 'for iterator' (table expected, got nil)` #231

Open KageKirin opened 8 years ago

KageKirin commented 8 years ago

Hi, I'm getting the following error after upgrading to version 614 when creating projects for Xcode and VS2015. My previous version was 556 and I'm using the mac version.

Building configurations...
[string "premake.bake = { }..."]:497: bad argument #1 to 'for iterator' (table expected, got nil)
stack traceback:
    [C]: in for iterator 'for iterator'
    [string "premake.bake = { }..."]:497: in field 'postprocess'
    [string "premake.bake = { }..."]:443: in field 'buildconfigs'
    [string "_WORKING_DIR        = os.getcwd()..."]:67: in function '_premake_main'

Question: as the error cause might entirely reside in my luafiles, like some genie internals that worked by mistake and now have been fixed, is there a way to figure which setting or which file is causing this?

bkaradzic commented 8 years ago

Not sure. I just tested with bgfx and it works. You can build GENie in debug mode and if you set --scripts to point genie/src directory that call stack will be better.

KageKirin commented 8 years ago

Thanks. I managed to get a more detailed error stack:

genie/src/base/bake.lua:756: bad argument #1 to 'for iterator' (table expected, got nil)
stack traceback:
    [C]: in for iterator 'for iterator'
    ...e/badassX/scaffolding/thirdparty/genie/src/base/bake.lua:756: in field 'postprocess'
    ...e/badassX/scaffolding/thirdparty/genie/src/base/bake.lua:665: in field 'buildconfigs'
    ./thirdparty/genie/src/_premake_main.lua:138: in function '_premake_main'
make: *** [dev-xcode-debug] Error 1

Looking at the code (bake.lua:756), it says:

for _, fname in ipairs(cfg.allfiles) do

and in fact, the error is caused by one project of mine that had no call to files{} list, resulting in cfg.allfiles to be nil.

Following project (basically just a dummy to force recompilation of every project in the solution, pretty useful for rebuilding everything under Xcode):

group "__all"

local sln = solution()
local prjs = sln.projects
for i, prj in ipairs(prjs) do
end

project("__all_targets")
    kind("SharedLib")
    configuration {}
    files {} -- <-- this was missing and caused the error. adding it solved it.
    for _, prj in ipairs(prjs) do
        print("all targets: ", prj.name)        
        links{
            (prj.name)
        }
    end
bkaradzic commented 8 years ago

Probably there could be better error for missing files... :)