diff --git a/binmodules/example/main.c b/binmodules/example/main.c index 85a2f678..524ab34d 100644 --- a/binmodules/example/main.c +++ b/binmodules/example/main.c @@ -1,4 +1,4 @@ -#include +#include "luashim.h" static int example_test(lua_State* L) diff --git a/contrib/libzip/zip.h b/contrib/libzip/zip.h index 26104bf0..492beaf7 100644 --- a/contrib/libzip/zip.h +++ b/contrib/libzip/zip.h @@ -51,7 +51,7 @@ extern "C" { #endif -#include +#include "zipconf.h" #include #include diff --git a/contrib/luashim/luashim.c b/contrib/luashim/luashim.c index de929fe4..88dbde09 100644 --- a/contrib/luashim/luashim.c +++ b/contrib/luashim/luashim.c @@ -5,7 +5,7 @@ */ #include "luashim.h" #include -#include +#include "lstate.h" static const LuaFunctionTable_t* g_shimTable; @@ -858,4 +858,4 @@ void shimInitialize(lua_State* L) assert(g_shimTable != NULL); lua_unlock(L); -} \ No newline at end of file +} diff --git a/contrib/luashim/luashim.h b/contrib/luashim/luashim.h index 2c28f9e9..18bda586 100644 --- a/contrib/luashim/luashim.h +++ b/contrib/luashim/luashim.h @@ -6,8 +6,8 @@ #ifndef HEADER_luashim_H #define HEADER_luashim_H -#include -#include +#include "lua.h" +#include "lauxlib.h" // premake specific helper methods. void luaL_register(lua_State *L, const char *libname, const luaL_Reg *l); diff --git a/modules/android/vsandroid_androidproj.lua b/modules/android/vsandroid_androidproj.lua index 60920183..3fd3adf0 100644 --- a/modules/android/vsandroid_androidproj.lua +++ b/modules/android/vsandroid_androidproj.lua @@ -152,14 +152,17 @@ end) function android.link(cfg, file) - local fname = path.translate(file.relpath) - + -- default the seperator to '/' as that is what is searched for + -- below. Otherwise the function will use target seperator which + -- could be '\\' and result in failure to create links. + local fname = path.translate(file.relpath, '/') + -- Files that live outside of the project tree need to be "linked" -- and provided with a project relative pseudo-path. Check for any -- leading "../" sequences and, if found, remove them and mark this -- path as external. local link, count = fname:gsub("%.%.%/", "") - local external = (count > 0) or fname:find(':', 1, true) + local external = (count > 0) or fname:find(':', 1, true) or (file.vpath and file.vpath ~= file.relpath) -- Try to provide a little bit of flexibility by allowing virtual -- paths for external files. Would be great to support them for all diff --git a/modules/codelite/codelite_project.lua b/modules/codelite/codelite_project.lua index c2f5f7dc..f52049f5 100755 --- a/modules/codelite/codelite_project.lua +++ b/modules/codelite/codelite_project.lua @@ -274,9 +274,10 @@ end function m.environment(cfg) + local envs = table.concat(cfg.debugenvs, "\n") + _p(3, '') - local variables = "" - _x(4, '', variables) + _x(4, '', envs) _p(3, '') end diff --git a/modules/codelite/codelite_workspace.lua b/modules/codelite/codelite_workspace.lua index dc2f63a4..7ea326c9 100755 --- a/modules/codelite/codelite_workspace.lua +++ b/modules/codelite/codelite_workspace.lua @@ -26,11 +26,11 @@ -- -- Header -- - _p('') + p.w('') local tagsdb = "" -- local tagsdb = "./" .. wks.name .. ".tags" - _p('', wks.name, tagsdb) + p.push('', wks.name, tagsdb) -- -- Project list @@ -45,15 +45,18 @@ prjpath = path.getrelative(prj.workspace.location, prjpath) if (prj.name == wks.startproject) then - _x(1, '', prj.name, prjpath) + p.w('', prj.name, prjpath) else - _x(1, '', prj.name, prjpath) + p.w('', prj.name, prjpath) end end, - onbranch = function(n) - -- TODO: not sure what situation this appears...? - -- premake5.lua emit's one of these for 'contrib', which is a top-level folder with the zip projects + onbranchenter = function(n) + p.push('', n.name) + end, + + onbranchexit = function(n) + p.pop('') end, }) @@ -78,23 +81,23 @@ end -- for each workspace config - _p(1, '') + p.push('') for cfg in workspace.eachconfig(wks) do local cfgname = codelite.cfgname(cfg) - _p(2, '', cfgname) + p.push('', cfgname) local tr = workspace.grouptree(wks) tree.traverse(tr, { onleaf = function(n) local prj = n.project - _p(3, '', prj.name, cfgname) + p.w('', prj.name, cfgname) end }) - _p(2, '') + p.pop('') end - _p(1, '') + p.pop('') - _p('') + p.pop('') end diff --git a/modules/codelite/tests/test_codelite_config.lua b/modules/codelite/tests/test_codelite_config.lua index 69d2e01a..b36c151e 100644 --- a/modules/codelite/tests/test_codelite_config.lua +++ b/modules/codelite/tests/test_codelite_config.lua @@ -142,11 +142,13 @@ end function suite.OnProjectCfg_Environment() + debugenvs { "ENV_ONE=1", "ENV_TWO=2" } prepare() codelite.project.environment(cfg) test.capture( ' \n' .. -' \n' .. +' \n' .. ' ' ) end diff --git a/modules/codelite/tests/test_codelite_workspace.lua b/modules/codelite/tests/test_codelite_workspace.lua index cd56fd07..f36b8508 100644 --- a/modules/codelite/tests/test_codelite_workspace.lua +++ b/modules/codelite/tests/test_codelite_workspace.lua @@ -151,3 +151,42 @@ ]]) end + + + function suite.onGroupedProjects() + wks.projects = {} + project "MyGrouplessProject" + group "MyGroup" + project "MyGroupedProject" + group "My/Nested/Group" + project "MyNestedGroupedProject" + prepare() + test.capture([[ + + + + + + + + + + + + + + + + + + + + + + + + + + + ]]) + end diff --git a/modules/d/actions/gmake.lua b/modules/d/actions/gmake.lua index 9721a84b..75bebc03 100644 --- a/modules/d/actions/gmake.lua +++ b/modules/d/actions/gmake.lua @@ -154,14 +154,24 @@ p.override(cpp, "standardFileRules", function(oldfn, prj, node) -- D file if path.isdfile(node.abspath) then - _x('$(OBJDIR)/%s.o: %s', node.objname, node.relpath) - _p('\t@echo $(notdir $<)') _p('\t$(SILENT) $(DC) $(ALL_DFLAGS) $(OUTPUTFLAG) -c $<') else oldfn(prj, node) end end) +-- +-- Let make know it can compile D source files +-- + + p.override(make, "fileType", function(oldfn, node) + if path.isdfile(node.abspath) then + return "objects" + else + return oldfn(node) + end + end) + -- -- Write out the settings for a particular configuration. diff --git a/modules/d/actions/vcxproj.lua b/modules/d/actions/vcxproj.lua index 4e6ea910..8fba71b6 100644 --- a/modules/d/actions/vcxproj.lua +++ b/modules/d/actions/vcxproj.lua @@ -50,9 +50,11 @@ end function m.dCompile(cfg) - p.push('') - p.callArray(m.elements.dCompile, cfg) - p.pop('') + if config.hasFile(cfg, path.isdfile) then + p.push('') + p.callArray(m.elements.dCompile, cfg) + p.pop('') + end end --- diff --git a/modules/gmake/gmake.lua b/modules/gmake/gmake.lua index 188bb078..4c184d3d 100644 --- a/modules/gmake/gmake.lua +++ b/modules/gmake/gmake.lua @@ -274,12 +274,9 @@ function make.shellType() - _p('SHELLTYPE := msdos') - _p('ifeq (,$(ComSpec)$(COMSPEC))') - _p(' SHELLTYPE := posix') - _p('endif') - _p('ifeq (/bin,$(findstring /bin,$(SHELL)))') - _p(' SHELLTYPE := posix') + _p('SHELLTYPE := posix') + _p('ifeq (.exe,$(findstring .exe,$(ComSpec)))') + _p('\tSHELLTYPE := msdos') _p('endif') _p('') end diff --git a/modules/gmake/gmake_cpp.lua b/modules/gmake/gmake_cpp.lua index cbd0c4f3..ab09397b 100644 --- a/modules/gmake/gmake_cpp.lua +++ b/modules/gmake/gmake_cpp.lua @@ -34,6 +34,9 @@ make.cppObjects, make.shellType, make.cppTargetRules, + make.cppCustomFilesRules, + make.cppTargetDirRules, + make.cppObjDirRules, make.cppCleanRules, make.preBuildRules, make.preLinkRules, @@ -43,18 +46,68 @@ } end + -- should be part of the toolset? + function make.fileTypeExtensions() + return { + ["objects"] = "o", + ["resources"] = "res", + } + end + + -- should be part of the toolset? + function make.fileType(node) + local kind + if path.iscppfile(node.abspath) then + kind = "objects" + elseif path.isresourcefile(node.abspath) then + kind = "resources" + end + + return kind + end + + function make.fileDependency(prj, node) + local filetype = make.fileType(node) + _x('$(OBJDIR)/%s.%s: %s', node.objname, make.fileTypeExtensions()[filetype], node.relpath) + _p('\t@echo $(notdir $<)') + end + function make.cpp.generate(prj) p.eol("\n") p.callArray(cpp.elements.makefile, prj) end +-- +-- Write out the commands for compiling a file +-- + + cpp.elements.standardFileRules = function(prj, node) + return { + make.fileDependency, + cpp.standardFileRules, + } + end + + cpp.elements.customFileRules = function(prj, node) + return { + make.fileDependency, + cpp.customFileRules, + } + end + + cpp.elements.customBuildRules = function(prj, node) + return { + cpp.customFileRules + } + end -- -- Write out the settings for a particular configuration. -- - cpp.elements.configuration = function(cfg) + cpp.elements.configuration = function(cfg, toolset) return { + make.configBegin, make.cppTools, make.target, make.objdir, @@ -76,6 +129,7 @@ make.postBuildCmds, make.cppAllRules, make.settings, + make.configEnd, } end @@ -89,9 +143,7 @@ error("Invalid toolset '" .. cfg.toolset .. "'") end - _x('ifeq ($(config),%s)', cfg.shortname) p.callArray(cpp.elements.configuration, cfg, toolset) - _p('endif') _p('') end end @@ -105,13 +157,33 @@ end end +-- +-- Return the start of the compilation string that corresponds to the 'compileas' enum if set +-- + + function cpp.compileas(prj, node) + local result + if node["compileas"] then + if p.languages.isc(node.compileas) then + result = '$(CC) $(ALL_CFLAGS)' + elseif p.languages.iscpp(node.compileas) then + result = '$(CXX) $(ALL_CXXFLAGS)' + end + end + + return result + end + -- -- Build command for a single file. -- function cpp.buildcommand(prj, objext, node) - local iscfile = node and path.iscfile(node.abspath) or false - local flags = iif(prj.language == "C" or iscfile, '$(CC) $(ALL_CFLAGS)', '$(CXX) $(ALL_CXXFLAGS)') + local flags = cpp.compileas(prj, node) + if not flags then + local iscfile = node and path.iscfile(node.abspath) or false + flags = iif(prj.language == "C" or iscfile, '$(CC) $(ALL_CFLAGS)', '$(CXX) $(ALL_CXXFLAGS)') + end _p('\t$(SILENT) %s $(FORCE_INCLUDE) -o "$@" -MF "$(@:%%.%s=%%.d)" -c "$<"', flags, objext) end @@ -129,17 +201,22 @@ for cfg in project.eachconfig(prj) do local filecfg = fileconfig.getconfig(node, cfg) if fileconfig.hasCustomBuildRule(filecfg) then - rules = true + rules = cpp.elements.customBuildRules(prj, node) + break + end + + if fileconfig.hasFileSettings(filecfg) then + rules = cpp.elements.customFileRules(prj, node) break end end - -- if it has custom rules, need to break them out - -- into individual configurations + if not rules and make.fileType(node) then + rules = cpp.elements.standardFileRules(prj, node) + end + if rules then - cpp.customFileRules(prj, node) - else - cpp.standardFileRules(prj, node) + p.callArray(rules, prj, node) end end }) @@ -147,18 +224,13 @@ end function cpp.standardFileRules(prj, node) - -- C/C++ file - if path.iscppfile(node.abspath) then - _x('$(OBJDIR)/%s.o: %s', node.objname, node.relpath) - _p('\t@echo $(notdir $<)') - make.mkdir('$(OBJDIR)') - cpp.buildcommand(prj, "o", node) + local kind = make.fileType(node) + -- C/C++ file + if kind == "objects" then + cpp.buildcommand(prj, make.fileTypeExtensions()[kind], node) -- resource file - elseif path.isresourcefile(node.abspath) then - _x('$(OBJDIR)/%s.res: %s', node.objname, node.relpath) - _p('\t@echo $(notdir $<)') - make.mkdir('$(OBJDIR)') + elseif kind == "resources" then _p('\t$(SILENT) $(RESCOMP) $< -O coff -o "$@" $(ALL_RESFLAGS)') end end @@ -167,8 +239,9 @@ for cfg in project.eachconfig(prj) do local filecfg = fileconfig.getconfig(node, cfg) if filecfg then - _x('ifeq ($(config),%s)', cfg.shortname) + make.configBegin(cfg) +if fileconfig.hasCustomBuildRule(filecfg) then local output = project.getrelative(prj, filecfg.buildoutputs[1]) local dependencies = filecfg.relpath if filecfg.buildinputs and #filecfg.buildinputs > 0 then @@ -186,7 +259,10 @@ _p('\t$(SILENT) %s', cmd) end end - _p('endif') +else + cpp.standardFileRules(prj, filecfg) +end + make.configEnd(cfg) end end end @@ -287,7 +363,7 @@ for cfg in project.eachconfig(prj) do local files = configs[cfg] if #files.objects > 0 or #files.resources > 0 or #files.customfiles > 0 then - _x('ifeq ($(config),%s)', cfg.shortname) + make.configBegin(cfg, toolset) if #files.objects > 0 then listobjects(' OBJECTS +=', files.objects) end @@ -297,7 +373,7 @@ if #files.customfiles > 0 then listobjects(' CUSTOMFILES +=', files.customfiles) end - _p('endif') + make.configEnd(cfg, toolset) _p('') end end @@ -310,6 +386,18 @@ -- --------------------------------------------------------------------------- + function make.configBegin(cfg, toolset) + if cfg then + _x('ifeq ($(config),%s)', cfg.shortname) + end + end + + function make.configEnd(cfg, toolset) + if cfg then + _p('endif') + end + end + function make.cFlags(cfg, toolset) _p(' ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS)%s', make.list(table.join(toolset.getcflags(cfg), cfg.buildoptions))) end @@ -363,14 +451,31 @@ function make.cppTargetRules(prj) - _p('$(TARGET): $(GCH) ${CUSTOMFILES} $(OBJECTS) $(LDDEPS) $(RESOURCES)') + _p('$(TARGET): $(GCH) ${CUSTOMFILES} $(OBJECTS) $(LDDEPS) $(RESOURCES) | $(TARGETDIR)') _p('\t@echo Linking %s', prj.name) - make.mkdir('$(TARGETDIR)') _p('\t$(SILENT) $(LINKCMD)') _p('\t$(POSTBUILDCMDS)') _p('') end + function make.cppCustomFilesRules(prj) + _p('$(CUSTOMFILES): | $(OBJDIR)') + _p('') + end + + function make.cppTargetDirRules(prj) + _p('$(TARGETDIR):') + _p('\t@echo Creating $(TARGETDIR)') + make.mkdir('$(TARGETDIR)') + _p('') + end + + function make.cppObjDirRules(prj) + _p('$(OBJDIR):') + _p('\t@echo Creating $(OBJDIR)') + make.mkdir('$(OBJDIR)') + _p('') + end function make.cppTools(cfg, toolset) local tool = toolset.gettoolname(cfg, "cc") @@ -509,14 +614,15 @@ function make.pchRules(prj) _p('ifneq (,$(PCH))') - _p('$(OBJECTS): $(GCH) $(PCH)') - _p('$(GCH): $(PCH)') + _p('$(OBJECTS): $(GCH) $(PCH) | $(OBJDIR)') + _p('$(GCH): $(PCH) | $(OBJDIR)') _p('\t@echo $(notdir $<)') - make.mkdir('$(OBJDIR)') local cmd = iif(prj.language == "C", "$(CC) -x c-header $(ALL_CFLAGS)", "$(CXX) -x c++-header $(ALL_CXXFLAGS)") _p('\t$(SILENT) %s -o "$@" -MF "$(@:%%.gch=%%.d)" -c "$<"', cmd) + _p('else') + _p('$(OBJECTS): | $(OBJDIR)') _p('endif') _p('') end diff --git a/modules/gmake/tests/cpp/test_file_rules.lua b/modules/gmake/tests/cpp/test_file_rules.lua index 0462a370..29fc2946 100644 --- a/modules/gmake/tests/cpp/test_file_rules.lua +++ b/modules/gmake/tests/cpp/test_file_rules.lua @@ -37,19 +37,9 @@ test.capture [[ $(OBJDIR)/hello.o: src/greetings/hello.cpp @echo $(notdir $<) -ifeq (posix,$(SHELLTYPE)) - $(SILENT) mkdir -p $(OBJDIR) -else - $(SILENT) mkdir $(subst /,\\,$(OBJDIR)) -endif $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" $(OBJDIR)/hello1.o: src/hello.cpp @echo $(notdir $<) -ifeq (posix,$(SHELLTYPE)) - $(SILENT) mkdir -p $(OBJDIR) -else - $(SILENT) mkdir $(subst /,\\,$(OBJDIR)) -endif $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" ]] @@ -66,24 +56,61 @@ endif test.capture [[ $(OBJDIR)/hello.o: src/hello.c @echo $(notdir $<) -ifeq (posix,$(SHELLTYPE)) - $(SILENT) mkdir -p $(OBJDIR) -else - $(SILENT) mkdir $(subst /,\\,$(OBJDIR)) -endif $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" $(OBJDIR)/test.o: src/test.cpp @echo $(notdir $<) -ifeq (posix,$(SHELLTYPE)) - $(SILENT) mkdir -p $(OBJDIR) -else - $(SILENT) mkdir $(subst /,\\,$(OBJDIR)) -endif $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" ]] end +-- +-- C files in C++ projects can be compiled as C++ with 'compileas' +-- + + function suite.cFilesGetsCompiledWithCXXWithCompileas() + files { "src/hello.c", "src/test.c" } + filter { "files:src/hello.c" } + compileas "C++" + prepare() + test.capture [[ +$(OBJDIR)/hello.o: src/hello.c + @echo $(notdir $<) +ifeq ($(config),debug) + $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" +endif +ifeq ($(config),release) + $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" +endif +$(OBJDIR)/test.o: src/test.c + @echo $(notdir $<) + $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" + ]] + end + +-- +-- C files in C++ projects can be compiled as C++ with 'compileas' on a configuration basis +-- + + function suite.cFilesGetsCompiledWithCXXWithCompileasDebugOnly() + files { "src/test.c", "src/hello.c" } + filter { "configurations:Debug", "files:src/hello.c" } + compileas "C++" + prepare() + test.capture [[ +$(OBJDIR)/hello.o: src/hello.c + @echo $(notdir $<) +ifeq ($(config),debug) + $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" +endif +ifeq ($(config),release) + $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" +endif +$(OBJDIR)/test.o: src/test.c + @echo $(notdir $<) + $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" + ]] + end -- -- If a custom build rule is supplied, it should be used. diff --git a/modules/gmake/tests/cpp/test_make_pch.lua b/modules/gmake/tests/cpp/test_make_pch.lua index bdd13407..b79ab4ee 100644 --- a/modules/gmake/tests/cpp/test_make_pch.lua +++ b/modules/gmake/tests/cpp/test_make_pch.lua @@ -93,15 +93,12 @@ prepareRules() test.capture [[ ifneq (,$(PCH)) -$(OBJECTS): $(GCH) $(PCH) -$(GCH): $(PCH) +$(OBJECTS): $(GCH) $(PCH) | $(OBJDIR) +$(GCH): $(PCH) | $(OBJDIR) @echo $(notdir $<) -ifeq (posix,$(SHELLTYPE)) - $(SILENT) mkdir -p $(OBJDIR) -else - $(SILENT) mkdir $(subst /,\\,$(OBJDIR)) -endif $(SILENT) $(CXX) -x c++-header $(ALL_CXXFLAGS) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<" +else +$(OBJECTS): | $(OBJDIR) endif ]] end @@ -117,15 +114,12 @@ endif prepareRules() test.capture [[ ifneq (,$(PCH)) -$(OBJECTS): $(GCH) $(PCH) -$(GCH): $(PCH) +$(OBJECTS): $(GCH) $(PCH) | $(OBJDIR) +$(GCH): $(PCH) | $(OBJDIR) @echo $(notdir $<) -ifeq (posix,$(SHELLTYPE)) - $(SILENT) mkdir -p $(OBJDIR) -else - $(SILENT) mkdir $(subst /,\\,$(OBJDIR)) -endif $(SILENT) $(CC) -x c-header $(ALL_CFLAGS) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<" +else +$(OBJECTS): | $(OBJDIR) endif ]] end diff --git a/modules/gmake2/gmake2.lua b/modules/gmake2/gmake2.lua index 025ebf50..d6c6ad1f 100644 --- a/modules/gmake2/gmake2.lua +++ b/modules/gmake2/gmake2.lua @@ -273,12 +273,9 @@ function gmake2.shellType() - _p('SHELLTYPE := msdos') - _p('ifeq (,$(ComSpec)$(COMSPEC))') - _p(' SHELLTYPE := posix') - _p('endif') - _p('ifeq (/bin,$(findstring /bin,$(SHELL)))') - _p(' SHELLTYPE := posix') + _p('SHELLTYPE := posix') + _p('ifeq (.exe,$(findstring .exe,$(ComSpec)))') + _p('\tSHELLTYPE := msdos') _p('endif') _p('') end diff --git a/modules/gmake2/gmake2_cpp.lua b/modules/gmake2/gmake2_cpp.lua index dacb2254..6bb0082c 100644 --- a/modules/gmake2/gmake2_cpp.lua +++ b/modules/gmake2/gmake2_cpp.lua @@ -60,13 +60,13 @@ fileExtension { ".cc", ".cpp", ".cxx", ".mm" } buildoutputs { "$(OBJDIR)/%{premake.modules.gmake2.cpp.makeUnique(cfg, file.objname)}.o" } buildmessage '$(notdir $<)' - buildcommands {'$(CXX) $(%{premake.modules.gmake2.cpp.fileFlags(cfg, file)}) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"'} + buildcommands {'$(CXX) %{premake.modules.gmake2.cpp.fileFlags(cfg, file)} $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"'} rule 'cc' fileExtension {".c", ".s", ".m"} buildoutputs { "$(OBJDIR)/%{premake.modules.gmake2.cpp.makeUnique(cfg, file.objname)}.o" } buildmessage '$(notdir $<)' - buildcommands {'$(CC) $(%{premake.modules.gmake2.cpp.fileFlags(cfg, file)}) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"'} + buildcommands {'$(CC) %{premake.modules.gmake2.cpp.fileFlags(cfg, file)} $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"'} rule 'resource' fileExtension ".rc" @@ -198,6 +198,21 @@ end end + function cpp.determineFiletype(cfg, node) + -- determine which filetype to use + local filecfg = fileconfig.getconfig(node, cfg) + local fileext = path.getextension(node.abspath):lower() + if filecfg and filecfg.compileas then + if p.languages.isc(filecfg.compileas) then + fileext = ".c" + elseif p.languages.iscpp(filecfg.compileas) then + fileext = ".cpp" + end + end + + return fileext; + end + function cpp.addGeneratedFile(cfg, source, filename) -- mark that we have generated files. cfg.project.hasGeneratedFiles = true @@ -220,9 +235,11 @@ fileconfig.addconfig(node, cfg) end + -- determine which filetype to use + local fileext = cpp.determineFiletype(cfg, node) -- add file to the fileset. local filesets = cfg.project._gmake.filesets - local kind = filesets[path.getextension(filename):lower()] or "CUSTOM" + local kind = filesets[fileext] or "CUSTOM" -- don't link generated object files automatically if it's explicitly -- disabled. @@ -260,7 +277,8 @@ function cpp.addRuleFile(cfg, node) local rules = cfg.project._gmake.rules - local rule = rules[path.getextension(node.abspath):lower()] + local fileext = cpp.determineFiletype(cfg, node) + local rule = rules[fileext] if rule then local filecfg = fileconfig.getconfig(node, cfg) @@ -425,9 +443,6 @@ function cpp.forceInclude(cfg, toolset) local includes = toolset.getforceincludes(cfg) - if not cfg.flags.NoPCH and cfg.pchheader then - table.insert(includes, 1, "-include $(PCH_PLACEHOLDER)") - end p.outln('FORCE_INCLUDE +=' .. gmake2.list(includes)) end @@ -530,7 +545,7 @@ _p('') end - local function makeVarName(prj, value, saltValue) + function cpp.makeVarName(prj, value, saltValue) prj._gmake = prj._gmake or {} prj._gmake.varlist = prj._gmake.varlist or {} prj._gmake.varlistlength = prj._gmake.varlistlength or 0 @@ -554,7 +569,10 @@ function cpp.perFileFlags(cfg, fcfg) local toolset = gmake2.getToolSet(cfg) - local value = gmake2.list(table.join(toolset.getcflags(fcfg), fcfg.buildoptions)) + local isCFile = path.iscfile(fcfg.name) + + local getflags = iif(isCFile, toolset.getcflags, toolset.getcxxflags) + local value = gmake2.list(table.join(getflags(fcfg), fcfg.buildoptions)) if fcfg.defines or fcfg.undefines then local defs = table.join(toolset.getdefines(fcfg.defines, cfg), toolset.getundefines(fcfg.undefines)) @@ -572,9 +590,9 @@ if #value > 0 then local newPerFileFlag = false - fcfg.flagsVariable, newPerFileFlag = makeVarName(cfg.project, value, iif(path.iscfile(fcfg.name), '_C', '_CPP')) + fcfg.flagsVariable, newPerFileFlag = cpp.makeVarName(cfg.project, value, iif(isCFile, '_C', '_CPP')) if newPerFileFlag then - if path.iscfile(fcfg.name) then + if isCFile then _p('%s = $(ALL_CFLAGS)%s', fcfg.flagsVariable, value) else _p('%s = $(ALL_CXXFLAGS)%s', fcfg.flagsVariable, value) @@ -585,15 +603,25 @@ function cpp.fileFlags(cfg, file) local fcfg = fileconfig.getconfig(file, cfg) - if fcfg and fcfg.flagsVariable then - return fcfg.flagsVariable + local flags = {} + + if cfg.pchheader and not cfg.flags.NoPCH and (not fcfg or not fcfg.flags.NoPCH) then + table.insert(flags, "-include $(PCH_PLACEHOLDER)") end - if path.iscfile(file.name) then - return 'ALL_CFLAGS' + if fcfg and fcfg.flagsVariable then + table.insert(flags, string.format("$(%s)", fcfg.flagsVariable)) else - return 'ALL_CXXFLAGS' + local fileExt = cpp.determineFiletype(cfg, file) + + if path.iscfile(fileExt) then + table.insert(flags, "$(ALL_CFLAGS)") + elseif path.iscppfile(fileExt) then + table.insert(flags, "$(ALL_CXXFLAGS)") + end end + + return table.concat(flags, ' ') end -- @@ -809,9 +837,6 @@ -- include the dependencies, built by GCC (with the -MMD flag) _p('-include $(OBJECTS:%%.o=%%.d)') _p('ifneq (,$(PCH))') - _p(' -include "$(PCH_PLACEHOLDER).d"') + _p(' -include $(PCH_PLACEHOLDER).d') _p('endif') end - - - diff --git a/modules/gmake2/gmake2_utility.lua b/modules/gmake2/gmake2_utility.lua index d6248d6b..ab2a894a 100644 --- a/modules/gmake2/gmake2_utility.lua +++ b/modules/gmake2/gmake2_utility.lua @@ -231,6 +231,8 @@ utility.elements.configuration = function(cfg) return { + utility.bindirs, + utility.exepaths, gmake2.settings, gmake2.preBuildCmds, gmake2.preLinkCmds, @@ -247,6 +249,21 @@ end + function utility.bindirs(cfg, toolset) + local dirs = project.getrelative(cfg.project, cfg.bindirs) + if #dirs > 0 then + p.outln('EXECUTABLE_PATHS = "' .. table.concat(dirs, ":") .. '"') + end + end + + + function utility.exepaths(cfg, toolset) + local dirs = project.getrelative(cfg.project, cfg.bindirs) + if #dirs > 0 then + p.outln('EXE_PATHS = PATH=$(EXECUTABLE_PATHS):$$PATH;') + end + end + -- -- Write out the file sets. @@ -365,7 +382,7 @@ function utility.outputFileRules(cfg, file) local outputs = table.concat(file.buildoutputs, ' ') - local dependencies = file.source + local dependencies = p.esc(file.source) if file.buildinputs and #file.buildinputs > 0 then dependencies = dependencies .. " " .. table.concat(p.esc(file.buildinputs), " ") end @@ -379,7 +396,11 @@ if file.buildcommands then local cmds = os.translateCommandsAndPaths(file.buildcommands, cfg.project.basedir, cfg.project.location) for _, cmd in ipairs(cmds) do - _p('\t$(SILENT) %s', cmd) + if cfg.bindirs and #cfg.bindirs > 0 then + _p('\t$(SILENT) $(EXE_PATHS) %s', cmd) + else + _p('\t$(SILENT) %s', cmd) + end end end end diff --git a/modules/gmake2/tests/test_gmake2_file_rules.lua b/modules/gmake2/tests/test_gmake2_file_rules.lua index a6137465..e8f8657e 100644 --- a/modules/gmake2/tests/test_gmake2_file_rules.lua +++ b/modules/gmake2/tests/test_gmake2_file_rules.lua @@ -97,6 +97,61 @@ $(OBJDIR)/test.o: src/test.cpp ]] end +-- +-- C files in C++ projects can be compiled as C++ with compileas +-- + + function suite.cFilesGetsCompiledWithCXXWithCompileas() + files { "src/hello.c", "src/test.c" } + filter { "files:src/hello.c" } + compileas "C++" + prepare() + test.capture [[ +# File Rules +# ############################################# + +$(OBJDIR)/hello.o: src/hello.c + @echo $(notdir $<) + $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" +$(OBJDIR)/test.o: src/test.c + @echo $(notdir $<) + $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" + ]] + end + +-- +-- C files in C++ projects can be compiled as C++ with 'compileas' on a configuration basis +-- + + function suite.cFilesGetsCompiledWithCXXWithCompileasDebugOnly() + files { "src/hello.c", "src/test.c" } + filter { "configurations:Debug", "files:src/hello.c" } + compileas "C++" + prepare() + test.capture [[ +# File Rules +# ############################################# + +$(OBJDIR)/test.o: src/test.c + @echo $(notdir $<) + $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" + +ifeq ($(config),debug) +$(OBJDIR)/hello.o: src/hello.c + @echo $(notdir $<) + $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" + +else ifeq ($(config),release) +$(OBJDIR)/hello.o: src/hello.c + @echo $(notdir $<) + $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" + +else + $(error "invalid configuration $(config)") +endif + ]] + end + -- -- If a custom build rule is supplied, it should be used. diff --git a/modules/gmake2/tests/test_gmake2_pch.lua b/modules/gmake2/tests/test_gmake2_pch.lua index 94afc439..4394981d 100644 --- a/modules/gmake2/tests/test_gmake2_pch.lua +++ b/modules/gmake2/tests/test_gmake2_pch.lua @@ -21,6 +21,7 @@ local wks, prj function suite.setup() os.chdir(_TESTS_DIR) + gmake2.cpp.initialize() wks, prj = test.createWorkspace() end @@ -34,6 +35,12 @@ gmake2.cpp.pchRules(cfg.project) end + local function prepareFlags() + local project = test.getproject(wks, 1) + gmake2.cpp.createRuleTable(project) + gmake2.cpp.createFileTable(project) + gmake2.cpp.outputFileRuleSection(project) + end -- -- If no header has been set, nothing should be output. @@ -53,8 +60,21 @@ function suite.noConfig_onHeaderAndNoPCHFlag() pchheader "include/myproject.h" flags "NoPCH" - prepareVars() - test.isemptycapture() + + files { 'a.cpp', 'b.cpp' } + + prepareFlags() + test.capture [[ +# File Rules +# ############################################# + +$(OBJDIR)/a.o: a.cpp + @echo $(notdir $<) + $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" +$(OBJDIR)/b.o: b.cpp + @echo $(notdir $<) + $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" +]] end @@ -156,3 +176,49 @@ endif PCH = ../../../../src/host/premake.h ]] end + +-- +-- If the header is located on one of the include file +-- search directories, it should get found automatically. +-- + + function suite.PCHFlag() + pchheader "include/myproject.h" + + files { 'a.cpp', 'b.cpp' } + + prepareFlags() + test.capture [[ +# File Rules +# ############################################# + +$(OBJDIR)/a.o: a.cpp + @echo $(notdir $<) + $(SILENT) $(CXX) -include $(PCH_PLACEHOLDER) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" +$(OBJDIR)/b.o: b.cpp + @echo $(notdir $<) + $(SILENT) $(CXX) -include $(PCH_PLACEHOLDER) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" +]] + end + + function suite.PCHFlag_PerFile() + pchheader "include/myproject.h" + + files { 'a.cpp', 'b.cpp' } + + filter { "files:a.cpp" } + flags "NoPCH" + + prepareFlags() + test.capture [[ +# File Rules +# ############################################# + +$(OBJDIR)/a.o: a.cpp + @echo $(notdir $<) + $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" +$(OBJDIR)/b.o: b.cpp + @echo $(notdir $<) + $(SILENT) $(CXX) -include $(PCH_PLACEHOLDER) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" +]] + end diff --git a/modules/gmake2/tests/test_gmake2_perfile_flags.lua b/modules/gmake2/tests/test_gmake2_perfile_flags.lua index f9843ae9..78d111c2 100644 --- a/modules/gmake2/tests/test_gmake2_perfile_flags.lua +++ b/modules/gmake2/tests/test_gmake2_perfile_flags.lua @@ -73,3 +73,20 @@ PERFILE_FLAGS_1 = $(ALL_CXXFLAGS) -msse -msse2 -mfpmath=sse,387 PERFILE_FLAGS_2 = $(ALL_CFLAGS) -msse -msse2 -mfpmath=sse,387 -msse3 -mssse3 -msse4.1 -maes ]] end + + function suite.perfile_cxxApi() + files { 'a.cpp', 'b.cpp', 'c.cpp' } + + visibility "Hidden" + + filter { 'files:b.cpp' } + visibility "Protected" + + prepare() + test.capture [[ +# Per File Configurations +# ############################################# + +PERFILE_FLAGS_0 = $(ALL_CXXFLAGS) -fvisibility=protected + ]] + end diff --git a/modules/vstudio/tests/_tests.lua b/modules/vstudio/tests/_tests.lua index fad06e65..c5b80af6 100644 --- a/modules/vstudio/tests/_tests.lua +++ b/modules/vstudio/tests/_tests.lua @@ -69,7 +69,6 @@ return { "vc2010/test_files.lua", "vc2010/test_filter_ids.lua", "vc2010/test_filters.lua", - "vc2010/test_imagexex_settings.lua", "vc2010/test_item_def_group.lua", "vc2010/test_link.lua", "vc2010/test_manifest.lua", diff --git a/modules/vstudio/tests/sln2005/test_platforms.lua b/modules/vstudio/tests/sln2005/test_platforms.lua index 5e3d7d21..3cf95ba4 100644 --- a/modules/vstudio/tests/sln2005/test_platforms.lua +++ b/modules/vstudio/tests/sln2005/test_platforms.lua @@ -460,35 +460,6 @@ EndGlobalSection end --- --- If the platform identifier matches a system or architecture, omit it --- from the configuration description. --- - - function suite.onSingleCpp_withPlatformsMatchingArch_noArchs() - platforms { "x86", "Xbox360" } - project "MyProject" - prepare() - test.capture [[ -GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|Xbox 360 = Debug|Xbox 360 - Release|Win32 = Release|Win32 - Release|Xbox 360 = Release|Xbox 360 -EndGlobalSection -GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Win32.ActiveCfg = Debug|Win32 - {C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Win32.Build.0 = Debug|Win32 - {C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Xbox 360.ActiveCfg = Debug|Xbox 360 - {C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Xbox 360.Build.0 = Debug|Xbox 360 - {C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Win32.ActiveCfg = Release|Win32 - {C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Win32.Build.0 = Release|Win32 - {C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Xbox 360.ActiveCfg = Release|Xbox 360 - {C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Xbox 360.Build.0 = Release|Xbox 360 -EndGlobalSection - ]] - end - function suite.onSingleCs_withPlatformsMatchingArch_noArchs() platforms { "x86", "x86_64" } project "MyProject" diff --git a/modules/vstudio/tests/vc200x/test_compiler_block.lua b/modules/vstudio/tests/vc200x/test_compiler_block.lua index c20d67fc..9fd3c56b 100644 --- a/modules/vstudio/tests/vc200x/test_compiler_block.lua +++ b/modules/vstudio/tests/vc200x/test_compiler_block.lua @@ -441,29 +441,6 @@ ]] end - --- --- Xbox 360 uses the same structure, but changes the element name. --- - - function suite.looksGood_onXbox360() - system "Xbox360" - prepare() - test.capture [[ - - ]] - end - - -- -- Check handling of forced includes. -- diff --git a/modules/vstudio/tests/vc200x/test_platforms.lua b/modules/vstudio/tests/vc200x/test_platforms.lua index 3ad18271..3921cfaa 100644 --- a/modules/vstudio/tests/vc200x/test_platforms.lua +++ b/modules/vstudio/tests/vc200x/test_platforms.lua @@ -78,20 +78,3 @@ ]] end - - --- --- Verify the Xbox360 platform. --- - - function suite.platformIsCorrect_onXbox360() - platforms { "Xbox360" } - prepare() - test.capture [[ - - - - ]] - end diff --git a/modules/vstudio/tests/vc2010/test_config_props.lua b/modules/vstudio/tests/vc2010/test_config_props.lua index b4bef03b..9e13f9a9 100644 --- a/modules/vstudio/tests/vc2010/test_config_props.lua +++ b/modules/vstudio/tests/vc2010/test_config_props.lua @@ -292,4 +292,53 @@ v100 true ]] - end \ No newline at end of file + end + + +-- +-- Check the WindowsSDKDesktopARMSupport element +-- + + function suite.WindowsSDKDesktopARMSupport_off() + system "ios" + architecture "ARM" + prepare() + test.capture [[ + + Application + false + Unicode + v100 + + ]] + end + + function suite.WindowsSDKDesktopARMSupport_on() + system "windows" + architecture "ARM" + prepare() + test.capture [[ + + Application + false + Unicode + v100 + true + + ]] + end + + function suite.WindowsSDKDesktopARM64Support() + system "windows" + architecture "ARM64" + prepare() + test.capture [[ + + Application + false + Unicode + v100 + true + + ]] + end diff --git a/modules/vstudio/tests/vc2010/test_files.lua b/modules/vstudio/tests/vc2010/test_files.lua index 8cdc8f54..51019fad 100644 --- a/modules/vstudio/tests/vc2010/test_files.lua +++ b/modules/vstudio/tests/vc2010/test_files.lua @@ -90,6 +90,30 @@ end +-- +-- Check handling of buildaction. +-- + function suite.customBuildTool_onBuildAction() + files { "test.x", "test2.cpp", "test3.cpp" } + filter "files:**.x" + buildaction "FxCompile" + filter "files:test2.cpp" + buildaction "None" + prepare() + test.capture [[ + + + + + + + + + + ]] + end + + -- -- Check handling of files with custom build rules. -- @@ -437,6 +461,33 @@ ]] end +-- +-- Check handling of per-file compileas options. +-- + + function suite.onCompileAs() + files { "hello.c" } + filter "files:hello.c" + compileas "C++" + prepare() + test.capture [[ + + + CompileAsCpp + ]] + end + + function suite.onCompileAsDebug() + files { "hello.c" } + filter { "configurations:Debug", "files:hello.c" } + compileas "C++" + prepare() + test.capture [[ + + + CompileAsCpp + ]] + end -- -- Check handling of per-file optimization levels. diff --git a/modules/vstudio/tests/vc2010/test_imagexex_settings.lua b/modules/vstudio/tests/vc2010/test_imagexex_settings.lua deleted file mode 100644 index f87e6ec9..00000000 --- a/modules/vstudio/tests/vc2010/test_imagexex_settings.lua +++ /dev/null @@ -1,58 +0,0 @@ --- --- tests/actions/vstudio/vc2010/test_compile_settings.lua --- Validate Xbox 360 XEX image settings in Visual Studio 2010 C/C++ projects. --- Copyright (c) 2011-2013 Jason Perkins and the Premake project --- - - local p = premake - local suite = test.declare("vstudio_vs2010_imagexex_settings") - local vc2010 = p.vstudio.vc2010 - local project = p.project - - --- --- Setup --- - - local wks, prj - - function suite.setup() - p.action.set("vs2010") - wks, prj = test.createWorkspace() - platforms "xbox360" - end - - local function prepare(platform) - local cfg = test.getconfig(prj, "Debug", "xbox360") - vc2010.imageXex(cfg) - end - --- --- Test default ImageXex settings --- - function suite.defaultSettings() - prepare() - test.capture [[ - - - - - - - ]] - end - --- --- Ensure configuration file is output in ImageXex block --- - function suite.onConfigfile() - configfile "testconfig.xml" - prepare() - test.capture [[ - - testconfig.xml - - - - ]] - end diff --git a/modules/vstudio/tests/vc2010/test_link.lua b/modules/vstudio/tests/vc2010/test_link.lua index 12d60205..df43572a 100644 --- a/modules/vstudio/tests/vc2010/test_link.lua +++ b/modules/vstudio/tests/vc2010/test_link.lua @@ -621,35 +621,6 @@ ]] end - --- --- Xbox 360 doesn't list a subsystem or entry point. --- - - function suite.onXbox360() - kind "ConsoleApp" - system "Xbox360" - prepare() - test.capture [[ - ]] - end - --- --- Xbox 360 uses .lib for library extensions --- - function suite.libAdded_onXbox360SystemLibs() - kind "ConsoleApp" - system "Xbox360" - links { "user32" } - prepare() - test.capture [[ - - user32.lib;%(AdditionalDependencies) - - ]] - end - - -- -- Check handling of warning flags. -- diff --git a/modules/vstudio/tests/vc2010/test_output_props.lua b/modules/vstudio/tests/vc2010/test_output_props.lua index 5ec306e9..71fb27fa 100644 --- a/modules/vstudio/tests/vc2010/test_output_props.lua +++ b/modules/vstudio/tests/vc2010/test_output_props.lua @@ -60,44 +60,6 @@ test.isemptycapture() end - --- --- Xbox360 adds an extra element to the block. --- - - function suite.structureIsCorrect_onXbox360() - system "Xbox360" - prepare() - test.capture [[ - - true - bin\Debug\ - $(OutDir)MyProject.exe - obj\Debug\ - MyProject - .exe - $(OutDir)$(TargetName).xex - - ]] - end - - function suite.staticLibStructureIsCorrect_onXbox360() - system "Xbox360" - kind "StaticLib" - prepare() - test.capture [[ - - bin\Debug\ - $(OutDir)MyProject.lib - obj\Debug\ - MyProject - .lib - $(OutDir)$(TargetName).xex - - ]] - end - - -- -- Static libraries should omit the link incremental element entirely. -- diff --git a/modules/vstudio/tests/vc2010/test_resource_compile.lua b/modules/vstudio/tests/vc2010/test_resource_compile.lua index 95622840..5532c8ad 100644 --- a/modules/vstudio/tests/vc2010/test_resource_compile.lua +++ b/modules/vstudio/tests/vc2010/test_resource_compile.lua @@ -43,15 +43,6 @@ test.isemptycapture() end - function suite.skips_onXbox360() - files { "hello.rc" } - defines { "DEBUG" } - system "Xbox360" - prepare() - test.isemptycapture() - end - - -- -- If defines are specified, the element should be added. -- diff --git a/modules/vstudio/vs200x_vcproj.lua b/modules/vstudio/vs200x_vcproj.lua index a1fe2276..98d85b2a 100644 --- a/modules/vstudio/vs200x_vcproj.lua +++ b/modules/vstudio/vs200x_vcproj.lua @@ -176,46 +176,26 @@ m.VCNMakeTool } end - if cfg.system == p.XBOX360 then - return { - m.VCPreBuildEventTool, - m.VCCustomBuildTool, - m.VCXMLDataGeneratorTool, - m.VCWebServiceProxyGeneratorTool, - m.VCMIDLTool, - m.VCCLCompilerTool, - m.VCManagedResourceCompilerTool, - m.VCResourceCompilerTool, - m.VCPreLinkEventTool, - m.VCLinkerTool, - m.VCALinkTool, - m.VCX360ImageTool, - m.VCBscMakeTool, - m.VCX360DeploymentTool, - m.VCPostBuildEventTool, - m.DebuggerTool, - } - else - return { - m.VCPreBuildEventTool, - m.VCCustomBuildTool, - m.VCXMLDataGeneratorTool, - m.VCWebServiceProxyGeneratorTool, - m.VCMIDLTool, - m.VCCLCompilerTool, - m.VCManagedResourceCompilerTool, - m.VCResourceCompilerTool, - m.VCPreLinkEventTool, - m.VCLinkerTool, - m.VCALinkTool, - m.VCManifestTool, - m.VCXDCMakeTool, - m.VCBscMakeTool, - m.VCFxCopTool, - m.VCAppVerifierTool, - m.VCPostBuildEventTool, - } - end + + return { + m.VCPreBuildEventTool, + m.VCCustomBuildTool, + m.VCXMLDataGeneratorTool, + m.VCWebServiceProxyGeneratorTool, + m.VCMIDLTool, + m.VCCLCompilerTool, + m.VCManagedResourceCompilerTool, + m.VCResourceCompilerTool, + m.VCPreLinkEventTool, + m.VCLinkerTool, + m.VCALinkTool, + m.VCManifestTool, + m.VCXDCMakeTool, + m.VCBscMakeTool, + m.VCFxCopTool, + m.VCAppVerifierTool, + m.VCPostBuildEventTool, + } end function m.tools(cfg) @@ -504,8 +484,6 @@ local prjcfg, filecfg = config.normalize(cfg) if filecfg and fileconfig.hasCustomBuildRule(filecfg) then return "VCCustomBuildTool" - elseif prjcfg and prjcfg.system == p.XBOX360 then - return "VCCLX360CompilerTool" else return "VCCLCompilerTool" end @@ -572,8 +550,6 @@ function m.VCLinkerToolName(cfg) if cfg.kind == p.STATICLIB then return "VCLibrarianTool" - elseif cfg.system == p.XBOX360 then - return "VCX360LinkerTool" else return "VCLinkerTool" end @@ -692,32 +668,6 @@ ------------ - m.elements.VCX360DeploymentTool = function(cfg) - return { - m.deploymentType, - m.additionalDeploymentOptions, - } - end - - function m.VCX360DeploymentTool(cfg) - m.VCTool("VCX360DeploymentTool", cfg) - end - - ------------ - - m.elements.VCX360ImageTool = function(cfg) - return { - m.additionalImageOptions, - m.outputFileName, - } - end - - function m.VCX360ImageTool(cfg) - m.VCTool("VCX360ImageTool", cfg) - end - - ------------ - m.elements.VCXDCMakeTool = function(cfg) return {} end @@ -813,14 +763,6 @@ - function m.additionalDeploymentOptions(cfg) - if #cfg.deploymentoptions > 0 then - p.x('AdditionalOptions="%s"', table.concat(cfg.deploymentoptions, " ")) - end - end - - - function m.additionalExternalCompilerOptions(cfg, toolset) local buildoptions = table.join(toolset.getcxxflags(cfg), cfg.buildoptions) if not cfg.flags.NoPCH and cfg.pchheader then @@ -1067,13 +1009,7 @@ p.w('DebugInformationFormat="%s"', fmt) end end - - - - function m.deploymentType(cfg) - p.w('DeploymentType="0"') - end - + function m.detect64BitPortabilityProblems(cfg) @@ -1104,7 +1040,7 @@ function m.enableEnhancedInstructionSet(cfg) local map = { SSE = "1", SSE2 = "2" } local value = map[cfg.vectorextensions] - if value and cfg.system ~= "Xbox360" and cfg.architecture ~= "x86_64" then + if value and cfg.architecture ~= "x86_64" then p.w('EnableEnhancedInstructionSet="%d"', value) end end diff --git a/modules/vstudio/vs2010_vcxproj.lua b/modules/vstudio/vs2010_vcxproj.lua index 5117f0a1..4ba96c6d 100644 --- a/modules/vstudio/vs2010_vcxproj.lua +++ b/modules/vstudio/vs2010_vcxproj.lua @@ -225,13 +225,11 @@ m.linkIncremental, m.ignoreImportLibrary, m.outDir, - m.outputFile, m.intDir, m.targetName, m.targetExt, m.includePath, m.libraryPath, - m.imageXexOutput, m.generateManifest, m.extensionsToDeleteOnClean, m.executablePath, @@ -307,8 +305,6 @@ m.linker, m.manifest, m.buildEvents, - m.imageXex, - m.deploy, m.ruleVars, m.buildLog, } @@ -442,7 +438,7 @@ end function m.resourceCompile(cfg) - if cfg.system ~= p.XBOX360 and p.config.hasFile(cfg, path.isresourcefile) then + if p.config.hasFile(cfg, path.isresourcefile) then local contents = p.capture(function () p.push() p.callArray(m.elements.resourceCompile, cfg) @@ -744,6 +740,7 @@ m.basicRuntimeChecks, m.exceptionHandling, m.compileAsManaged, + m.compileAs, m.runtimeTypeInfo, m.warningLevelFile, } @@ -1027,12 +1024,18 @@ function m.categorizeFile(prj, file) - -- If any configuration for this file uses a custom build step, - -- that's the category to use for cfg in project.eachconfig(prj) do local fcfg = fileconfig.getconfig(file, cfg) - if fileconfig.hasCustomBuildRule(fcfg) then - return m.categories.CustomBuild + if fcfg then + -- If any configuration for this file uses a custom build step, that's the category to use + if fileconfig.hasCustomBuildRule(fcfg) then + return m.categories.CustomBuild + end + + -- also check for buildaction + if fcfg.buildaction then + return m.categories[fcfg.buildaction] or m.categories.None + end end end @@ -1545,11 +1548,11 @@ end - function m.compileAs(cfg) + function m.compileAs(cfg, condition) if p.languages.isc(cfg.compileas) then - m.element("CompileAs", nil, "CompileAsC") + m.element("CompileAs", condition, "CompileAsC") elseif p.languages.iscpp(cfg.compileas) then - m.element("CompileAs", nil, "CompileAsCpp") + m.element("CompileAs", condition, "CompileAsCpp") end end @@ -1607,17 +1610,6 @@ end - function m.deploy(cfg) - if cfg.system == p.XBOX360 then - p.push('') - m.element("DeploymentType", nil, "CopyToHardDrive") - m.element("DvdEmulationType", nil, "ZeroSeekTimes") - m.element("DeploymentFiles", nil, "$(RemoteRoot)=$(ImagePath);") - p.pop('') - end - end - - function m.enableDpiAwareness(cfg) local awareness = { None = "false", @@ -1842,29 +1834,6 @@ end - function m.imageXex(cfg) - if cfg.system == p.XBOX360 then - p.push('') - if cfg.configfile then - m.element("ConfigurationFile", nil, "%s", cfg.configfile) - else - p.w('') - p.w('') - end - p.w('') - p.w('') - p.pop('') - end - end - - - function m.imageXexOutput(cfg) - if cfg.system == p.XBOX360 then - m.element("ImageXexOutput", nil, "%s", "$(OutDir)$(TargetName).xex") - end - end - - function m.importLanguageTargets(prj) p.w('') end @@ -2158,11 +2127,13 @@ function m.windowsSDKDesktopARMSupport(cfg) - if cfg.architecture == p.ARM then - p.w('true') - end - if cfg.architecture == p.ARM64 then - p.w('true') + if cfg.system == p.WINDOWS then + if cfg.architecture == p.ARM then + p.w('true') + end + if cfg.architecture == p.ARM64 then + p.w('true') + end end end @@ -2233,13 +2204,6 @@ end - function m.outputFile(cfg) - if cfg.system == p.XBOX360 then - m.element("OutputFile", nil, "$(OutDir)%s", cfg.buildtarget.name) - end - end - - function m.executablePath(cfg) local dirs = vstudio.path(cfg, cfg.bindirs) if #dirs > 0 then @@ -2471,10 +2435,8 @@ function m.subSystem(cfg) - if cfg.system ~= p.XBOX360 then - local subsystem = iif(cfg.kind == p.CONSOLEAPP, "Console", "Windows") - m.element("SubSystem", nil, subsystem) - end + local subsystem = iif(cfg.kind == p.CONSOLEAPP, "Console", "Windows") + m.element("SubSystem", nil, subsystem) end diff --git a/modules/vstudio/vstudio.lua b/modules/vstudio/vstudio.lua index 1a635134..83417c9d 100644 --- a/modules/vstudio/vstudio.lua +++ b/modules/vstudio/vstudio.lua @@ -27,7 +27,6 @@ win32 = "x86", x86 = "x86", x86_64 = "x64", - xbox360 = "Xbox 360", ARM = "ARM", ARM64 = "ARM64", } diff --git a/modules/xcode/tests/test_xcode_project.lua b/modules/xcode/tests/test_xcode_project.lua index 251e6af8..4ab997f2 100644 --- a/modules/xcode/tests/test_xcode_project.lua +++ b/modules/xcode/tests/test_xcode_project.lua @@ -161,6 +161,19 @@ ]] end + function suite.PBXFileReference_ListsSourceFilesCompileAs() + files { "source.c" } + filter { "files:source.c" } + compileas "C++" + prepare() + xcode.PBXFileReference(tr) + test.capture [[ +/* Begin PBXFileReference section */ + [MyProject:product] /* MyProject */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = MyProject; path = MyProject; sourceTree = BUILT_PRODUCTS_DIR; }; + [source.c] /* source.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; name = source.c; path = source.c; sourceTree = ""; }; + ]] + end + function suite.PBXFileReference_ListsXibCorrectly() files { "English.lproj/MainMenu.xib", "French.lproj/MainMenu.xib" } @@ -2367,7 +2380,7 @@ isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(NATIVE_ARCH_ACTUAL)"; - CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LANGUAGE_STANDARD = "c++11"; CONFIGURATION_BUILD_DIR = "$(SYMROOT)"; CONFIGURATION_TEMP_DIR = "$(OBJROOT)"; GCC_OPTIMIZATION_LEVEL = 0; diff --git a/modules/xcode/xcode_common.lua b/modules/xcode/xcode_common.lua index 29d35963..ba1b9d75 100644 --- a/modules/xcode/xcode_common.lua +++ b/modules/xcode/xcode_common.lua @@ -79,6 +79,20 @@ return false end + +-- +-- Return 'explicitFileType' if the given file is being set with 'compileas' +-- + + function xcode.getfiletypekey(node, cfg) + if node.configs then + local filecfg = fileconfig.getconfig(node, cfg) + if filecfg and filecfg["compileas"] then + return "explicitFileType" + end + end + return "lastKnownFileType" + end -- -- Return the Xcode type for a given file, based on the file extension. -- @@ -93,7 +107,11 @@ if node.configs then local filecfg = fileconfig.getconfig(node, cfg) if filecfg then - if filecfg.language == "ObjC" then + if p.languages.isc(filecfg.compileas) then + return "sourcecode.c.c" + elseif p.languages.iscpp(filecfg.compileas) then + return "sourcecode.cpp.cpp" + elseif filecfg.language == "ObjC" then return "sourcecode.c.objc" elseif filecfg.language == "ObjCpp" then return "sourcecode.cpp.objcpp" @@ -495,8 +513,8 @@ end --end end - _p(level,'%s /* %s */ = {isa = PBXFileReference; lastKnownFileType = %s; name = %s; path = %s; sourceTree = %s; };', - node.id, node.name, xcode.getfiletype(node, cfg), stringifySetting(node.name), stringifySetting(pth), stringifySetting(src)) + _p(level,'%s /* %s */ = {isa = PBXFileReference; %s = %s; name = %s; path = %s; sourceTree = %s; };', + node.id, node.name, xcode.getfiletypekey(node, cfg), xcode.getfiletype(node, cfg), stringifySetting(node.name), stringifySetting(pth), stringifySetting(src)) end end end @@ -1014,7 +1032,7 @@ xcode.cppLanguageStandards = { ["Default"] = "compiler-default", -- explicit compiler default ["C++98"] = "c++98", - ["C++11"] = "c++0x", -- Xcode project GUI uses c++0x, but c++11 also works + ["C++11"] = "c++11", ["C++14"] = "c++14", ["C++17"] = "c++1z", ["gnu++98"] = "gnu++98", diff --git a/src/_premake_init.lua b/src/_premake_init.lua index eac9fe1c..54e1113a 100644 --- a/src/_premake_init.lua +++ b/src/_premake_init.lua @@ -58,17 +58,6 @@ name = "buildaction", scope = "config", kind = "string", - allowed = { - "Application", - "Compile", - "Component", - "Copy", - "Embed", - "Form", - "None", - "Resource", - "UserControl", - }, } api.register { @@ -202,13 +191,6 @@ kind = "list:keyed:array:string", } - api.register { - name = "configfile", - scope = "config", - kind = "string", - tokens = true, - } - api.register { name = "configurations", scope = "project", @@ -369,13 +351,6 @@ tokens = true, } - api.register { - name = "deploymentoptions", - scope = "config", - kind = "list:string", - tokens = true, - } - api.register { name = "disablewarnings", scope = "config", @@ -1144,7 +1119,6 @@ "solaris", "wii", "windows", - "xbox360", }, } @@ -1400,7 +1374,6 @@ api.alias("buildmessage", "buildMessage") api.alias("buildoutputs", "buildOutputs") api.alias("cleanextensions", "cleanExtensions") - api.alias("configfile", "configFile") api.alias("dotnetframework", "framework") api.alias("editandcontinue", "editAndContinue") api.alias("fileextension", "fileExtension") @@ -1793,15 +1766,12 @@ filter { "system:Windows or language:C# or language:F#", "kind:ConsoleApp or WindowedApp" } targetextension ".exe" - filter { "system:Xbox360", "kind:ConsoleApp or WindowedApp" } - targetextension ".exe" - - filter { "system:Windows or Xbox360", "kind:SharedLib" } + filter { "system:Windows", "kind:SharedLib" } targetprefix "" targetextension ".dll" implibextension ".lib" - filter { "system:Windows or Xbox360", "kind:StaticLib" } + filter { "system:Windows", "kind:StaticLib" } targetprefix "" targetextension ".lib" diff --git a/src/base/_foundation.lua b/src/base/_foundation.lua index e5d87122..dfec9116 100644 --- a/src/base/_foundation.lua +++ b/src/base/_foundation.lua @@ -56,7 +56,6 @@ premake.X86_64 = "x86_64" premake.ARM = "ARM" premake.ARM64 = "ARM64" - premake.XBOX360 = "xbox360" diff --git a/src/base/fileconfig.lua b/src/base/fileconfig.lua index 43896585..b9826f3f 100644 --- a/src/base/fileconfig.lua +++ b/src/base/fileconfig.lua @@ -100,8 +100,8 @@ local environ = {} local fsub = context.new(prj, environ) - context.copyFilters(fsub, cfg) - context.mergeFilters(fsub, fcfg) + context.copyFilters(fsub, fcfg) + context.mergeFilters(fsub, cfg) fcfg.configs[cfg] = fsub diff --git a/src/host/os_compile.c b/src/host/os_compile.c index ac8c9f58..d35690c8 100644 --- a/src/host/os_compile.c +++ b/src/host/os_compile.c @@ -5,8 +5,8 @@ */ #include "premake.h" -#include -#include +#include "lundump.h" +#include "lstate.h" extern int original_luaL_loadfilex(lua_State* L, const char* filename, const char* mode); diff --git a/src/host/zip_extract.c b/src/host/zip_extract.c index 07eb1cee..96b2d59b 100644 --- a/src/host/zip_extract.c +++ b/src/host/zip_extract.c @@ -8,7 +8,7 @@ #ifdef PREMAKE_COMPRESSION -#include +#include "zip.h" #ifdef WIN32 #include diff --git a/tests/config/test_targetinfo.lua b/tests/config/test_targetinfo.lua index a1d49023..58e2d4d4 100755 --- a/tests/config/test_targetinfo.lua +++ b/tests/config/test_targetinfo.lua @@ -183,25 +183,7 @@ test.isequal("libMyProject.a", i.name) end - --- --- Name should use ".exe" for Xbox360 executables. --- - - function suite.nameUsesExe_onXbox360ConsoleApp() - kind "ConsoleApp" - system "Xbox360" - i = prepare() - test.isequal("MyProject.exe", i.name) - end - - function suite.nameUsesLib_onXbox360StaticLib() - kind "StaticLib" - system "Xbox360" - i = prepare() - test.isequal("MyProject.lib", i.name) - end - + -- -- Name should use a prefix if set. --