diff --git a/modules/gmake2/gmake2.lua b/modules/gmake2/gmake2.lua index e9d79e95..3267b161 100644 --- a/modules/gmake2/gmake2.lua +++ b/modules/gmake2/gmake2.lua @@ -231,17 +231,31 @@ p.outln('') end + local first = true for cfg in project.eachconfig(prj) do local settings = table.difference(root[cfg], root.settings) if #settings > 0 then - _x('ifeq ($(config),%s)', cfg.shortname) + if first then + _x('ifeq ($(config),%s)', cfg.shortname) + first = false + else + _x('else ifeq ($(config),%s)', cfg.shortname) + end + for k, v in ipairs(settings) do p.outln(v) end - p.outln('endif') - p.outln('') + + _p('') end end + + if not first then + p.outln('else') + p.outln(' $(error "invalid configuration $(config)")') + p.outln('endif') + p.outln('') + end end diff --git a/modules/gmake2/gmake2_makefile.lua b/modules/gmake2/gmake2_makefile.lua index f6f53e9e..cf70535c 100644 --- a/modules/gmake2/gmake2_makefile.lua +++ b/modules/gmake2/gmake2_makefile.lua @@ -47,6 +47,7 @@ end function makefile.configs(prj) + local first = true for cfg in project.eachconfig(prj) do -- identify the toolset used by this configurations (would be nicer if -- this were computed and stored with the configuration up front) @@ -56,8 +57,20 @@ error("Invalid toolset '" .. cfg.toolset .. "'") end - _x('ifeq ($(config),%s)', cfg.shortname) + if first then + _x('ifeq ($(config),%s)', cfg.shortname) + first = false + else + _x('else ifeq ($(config),%s)', cfg.shortname) + end + p.callarray(make, makefile.elements.configuration, cfg, toolset) + _p('') + end + + if not first then + _p('else') + _p(' $(error "invalid configuration $(config)")') _p('endif') _p('') end diff --git a/modules/gmake2/gmake2_workspace.lua b/modules/gmake2/gmake2_workspace.lua index 7b310a09..a8a25920 100644 --- a/modules/gmake2/gmake2_workspace.lua +++ b/modules/gmake2/gmake2_workspace.lua @@ -37,17 +37,31 @@ -- function gmake2.configmap(wks) + local first = true for cfg in p.workspace.eachconfig(wks) do - _p('ifeq ($(config),%s)', cfg.shortname) + if first then + _p('ifeq ($(config),%s)', cfg.shortname) + first = false + else + _p('else ifeq ($(config),%s)', cfg.shortname) + end + for prj in p.workspace.eachproject(wks) do local prjcfg = project.getconfig(prj, cfg.buildcfg, cfg.platform) if prjcfg then _p(' %s_config = %s', gmake2.tovar(prj.name), prjcfg.shortname) end end - _p('endif') + + _p('') + end + + if not first then + _p('else') + _p(' $(error "invalid configuration $(config)")') + _p('endif') + _p('') end - _p('') end diff --git a/modules/gmake2/tests/test_gmake2_file_rules.lua b/modules/gmake2/tests/test_gmake2_file_rules.lua index fb23af32..a6137465 100644 --- a/modules/gmake2/tests/test_gmake2_file_rules.lua +++ b/modules/gmake2/tests/test_gmake2_file_rules.lua @@ -121,13 +121,15 @@ obj/Debug/hello.obj: hello.x @echo Compiling hello.x $(SILENT) cxc -c "hello.x" -o "obj/Debug/hello.xo" $(SILENT) c2o -c "obj/Debug/hello.xo" -o "obj/Debug/hello.obj" -endif -ifeq ($(config),release) +else ifeq ($(config),release) obj/Release/hello.obj: hello.x @echo Compiling hello.x $(SILENT) cxc -c "hello.x" -o "obj/Release/hello.xo" $(SILENT) c2o -c "obj/Release/hello.xo" -o "obj/Release/hello.obj" + +else + $(error "invalid configuration $(config)") endif ]] end @@ -152,13 +154,15 @@ obj/Debug/hello.obj: hello.x hello.x.inc hello.x.inc2 @echo Compiling hello.x $(SILENT) cxc -c "hello.x" -o "obj/Debug/hello.xo" $(SILENT) c2o -c "obj/Debug/hello.xo" -o "obj/Debug/hello.obj" -endif -ifeq ($(config),release) +else ifeq ($(config),release) obj/Release/hello.obj: hello.x hello.x.inc hello.x.inc2 @echo Compiling hello.x $(SILENT) cxc -c "hello.x" -o "obj/Release/hello.xo" $(SILENT) c2o -c "obj/Release/hello.xo" -o "obj/Release/hello.obj" + +else + $(error "invalid configuration $(config)") endif ]] end diff --git a/modules/gmake2/tests/test_gmake2_objects.lua b/modules/gmake2/tests/test_gmake2_objects.lua index 44b2d3b5..73592c47 100644 --- a/modules/gmake2/tests/test_gmake2_objects.lua +++ b/modules/gmake2/tests/test_gmake2_objects.lua @@ -86,10 +86,12 @@ OBJECTS := ifeq ($(config),debug) OBJECTS += $(OBJDIR)/hello_debug.o -endif -ifeq ($(config),release) +else ifeq ($(config),release) OBJECTS += $(OBJDIR)/hello_release.o + +else + $(error "invalid configuration $(config)") endif ]] @@ -138,10 +140,12 @@ CUSTOM := ifeq ($(config),debug) CUSTOM += obj/Debug/hello.luac -endif -ifeq ($(config),release) +else ifeq ($(config),release) CUSTOM += obj/Release/hello.luac + +else + $(error "invalid configuration $(config)") endif ]] end @@ -170,10 +174,12 @@ OBJECTS := ifeq ($(config),debug) OBJECTS += obj/Debug/hello.obj -endif -ifeq ($(config),release) +else ifeq ($(config),release) OBJECTS += obj/Release/hello.obj + +else + $(error "invalid configuration $(config)") endif ]] end @@ -203,10 +209,12 @@ OBJECTS := ifeq ($(config),debug) OBJECTS += obj/Debug/hello.obj -endif -ifeq ($(config),release) +else ifeq ($(config),release) OBJECTS += obj/Release/hello.obj + +else + $(error "invalid configuration $(config)") endif ]] end @@ -236,10 +244,12 @@ CUSTOM := ifeq ($(config),debug) CUSTOM += obj/Debug/hello.obj -endif -ifeq ($(config),release) +else ifeq ($(config),release) CUSTOM += obj/Release/hello.obj + +else + $(error "invalid configuration $(config)") endif ]] end @@ -262,6 +272,9 @@ OBJECTS := ifeq ($(config),release) OBJECTS += $(OBJDIR)/hello.o + +else + $(error "invalid configuration $(config)") endif ]] @@ -280,6 +293,9 @@ OBJECTS := ifeq ($(config),release) OBJECTS += $(OBJDIR)/hello.o + +else + $(error "invalid configuration $(config)") endif ]]