Commits

Jason Perkins committed 62c1d83

Duplicate object file names are now ordered the same across all toolsets

  • Participants
  • Parent commits bbac9c6

Comments (0)

Files changed (5)

File src/actions/make/make_cpp.lua

 	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
 					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

File src/actions/vstudio/vs200x_vcproj.lua

 
 	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

File src/actions/vstudio/vs2010_vcxproj.lua

 
 
 	function vc2010.objectFileName(filecfg)
-		local objectname = project.getfileobject(filecfg.project, filecfg.abspath)
-		if objectname ~= path.getbasename(filecfg.abspath) then
-			_p(3,'<ObjectFileName %s>$(IntDir)\\%s.obj</ObjectFileName>', vc2010.condition(filecfg.config), objectname)
+		if filecfg.objname ~= path.getbasename(filecfg.abspath) then
+			_p(3,'<ObjectFileName %s>$(IntDir)\\%s.obj</ObjectFileName>', vc2010.condition(filecfg.config), filecfg.objname)
 		end
 	end
 

File src/project/project.lua

 			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)
 		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
 		fcfg.basename = path.getbasename(filename)
 		fcfg.path = fcfg.relpath
 
+		fcfg.objname = project.getfileobject(prj, filename)
+
 		return fcfg
 	end
 
 		-- 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 {}
 

File tests/actions/make/cpp/test_objects.lua

 OBJECTS := \
 
 RESOURCES := \
+	$(OBJDIR)/hello1.res \
 	$(OBJDIR)/hello.res \
-	$(OBJDIR)/hello1.res \
 
 		]]
 	end