From 2f1fe980efa1e5511bbc6fcf952cc58aed96dcb0 Mon Sep 17 00:00:00 2001 From: Jason Perkins Date: Fri, 21 Jun 2013 17:32:33 -0400 Subject: [PATCH] Duplicate object file names are now ordered the same across all toolsets --- src/actions/make/make_cpp.lua | 9 +++------ src/actions/vstudio/vs200x_vcproj.lua | 5 ++--- src/actions/vstudio/vs2010_vcxproj.lua | 5 ++--- src/project/project.lua | 18 +++++++++++++++--- tests/actions/make/cpp/test_objects.lua | 2 +- 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/actions/make/make_cpp.lua b/src/actions/make/make_cpp.lua index ea72395e..a7efdc8e 100644 --- a/src/actions/make/make_cpp.lua +++ b/src/actions/make/make_cpp.lua @@ -182,15 +182,13 @@ function cpp.standardfilerules(prj, node) -- C/C++ file if path.iscppfile(node.abspath) then - local objectname = project.getfileobject(prj, node.abspath) - _x('$(OBJDIR)/%s.o: %s', objectname, node.relpath) + _x('$(OBJDIR)/%s.o: %s', node.objname, node.relpath) _p('\t@echo $(notdir $<)') cpp.buildcommand(prj, "o", node) -- resource file elseif path.isresourcefile(node.abspath) then - local objectname = project.getfileobject(prj, node.abspath) - _x('$(OBJDIR)/%s.res: %s', objectname, node.relpath) + _x('$(OBJDIR)/%s.res: %s', node.objname, node.relpath) _p('\t@echo $(notdir $<)') _p('\t$(SILENT) $(RESCOMP) $< -O coff -o "$@" $(ALL_RESFLAGS)') end @@ -309,8 +307,7 @@ end -- assign a unique object file name to avoid collisions - local objectname = project.getfileobject(prj, node.abspath) - objectname = "$(OBJDIR)/" .. objectname .. iif(kind == "objects", ".o", ".res") + objectname = "$(OBJDIR)/" .. node.objname .. iif(kind == "objects", ".o", ".res") -- if this file exists in all configurations, write it to -- the project's list of files, else add to specific cfgs diff --git a/src/actions/vstudio/vs200x_vcproj.lua b/src/actions/vstudio/vs200x_vcproj.lua index 469aadfc..2a26d1a7 100644 --- a/src/actions/vstudio/vs200x_vcproj.lua +++ b/src/actions/vstudio/vs200x_vcproj.lua @@ -1072,9 +1072,8 @@ function vc200x.objectFile(filecfg, depth) if path.iscppfile(filecfg.name) then - local objectName = project.getfileobject(filecfg.project, filecfg.abspath) - if objectName ~= path.getbasename(filecfg.abspath) then - _x(depth, 'ObjectFile="$(IntDir)\\%s.obj"', objectName) + if filecfg.objname ~= path.getbasename(filecfg.abspath) then + _x(depth, 'ObjectFile="$(IntDir)\\%s.obj"', filecfg.objname) end end end diff --git a/src/actions/vstudio/vs2010_vcxproj.lua b/src/actions/vstudio/vs2010_vcxproj.lua index 5c72deb5..68da7621 100644 --- a/src/actions/vstudio/vs2010_vcxproj.lua +++ b/src/actions/vstudio/vs2010_vcxproj.lua @@ -893,9 +893,8 @@ function vc2010.objectFileName(filecfg) - local objectname = project.getfileobject(filecfg.project, filecfg.abspath) - if objectname ~= path.getbasename(filecfg.abspath) then - _p(3,'$(IntDir)\\%s.obj', vc2010.condition(filecfg.config), objectname) + if filecfg.objname ~= path.getbasename(filecfg.abspath) then + _p(3,'$(IntDir)\\%s.obj', vc2010.condition(filecfg.config), filecfg.objname) end end diff --git a/src/project/project.lua b/src/project/project.lua index 09174799..7f418905 100755 --- a/src/project/project.lua +++ b/src/project/project.lua @@ -92,7 +92,7 @@ ctx.language = premake.CPP end - -- The kind is a configuration level value, but it has been set at the + -- The kind is a configuration level value, but if it has been set at the -- project level allow that to influence the other project-level results. context.addterms(ctx, ctx.kind) @@ -103,8 +103,8 @@ ctx.baked = true -- Fill in some additional state. Copying the keys over from the - -- scripted project object allows custom values to passed through to - -- extension scripts. + -- scripted project object allows custom values set in the project + -- script to be passed through to extension scripts. for key, value in pairs(prj) do ctx[key] = value @@ -465,6 +465,8 @@ fcfg.basename = path.getbasename(filename) fcfg.path = fcfg.relpath + fcfg.objname = project.getfileobject(prj, filename) + return fcfg end @@ -508,6 +510,16 @@ -- make sure I have the project, and not it's root configuration prj = prj.project or prj + -- Only C/C++ projects need object files + if not project.iscpp(prj) then + return nil + end + + -- Only C/C++ source code files need objects + if not path.iscppfile(filename) and not path.isresourcefile(filename) then + return nil + end + -- create a list of objects if necessary prj.fileobjects = prj.fileobjects or {} diff --git a/tests/actions/make/cpp/test_objects.lua b/tests/actions/make/cpp/test_objects.lua index f9de575f..72530b50 100644 --- a/tests/actions/make/cpp/test_objects.lua +++ b/tests/actions/make/cpp/test_objects.lua @@ -114,8 +114,8 @@ OBJECTS := \ OBJECTS := \ RESOURCES := \ - $(OBJDIR)/hello.res \ $(OBJDIR)/hello1.res \ + $(OBJDIR)/hello.res \ ]] end