Commits

Dimitar Trendafilov committed eeaee7a Merge

Merge

Comments (0)

Files changed (9)

src/actions/make/make_cpp.lua

 		_p('  CPPFLAGS  += %s $(DEFINES) $(INCLUDES)', table.concat(toolset.getcppflags(cfg), " "))
 		_p('  CFLAGS    += $(CPPFLAGS) $(ARCH) %s', table.concat(table.join(toolset.getcflags(cfg), cfg.buildoptions), " "))
 		_p('  CXXFLAGS  += $(CFLAGS) %s', table.concat(toolset.getcxxflags(cfg), " "))
-		_p('  LDFLAGS   += %s', table.concat(table.join(toolset.getldflags(cfg), cfg.linkoptions), " "))
+
+		local ldflags = {}
+		for _, ldflag in ipairs(table.join(toolset.getldflags(cfg), cfg.linkoptions)) do
+			table.insert(ldflags, make.esc(ldflag))
+		end
+		_p('  LDFLAGS   += %s', table.concat(ldflags, " "))
 	
 		local resflags = table.join(toolset.getdefines(cfg.resdefines), toolset.getincludedirs(cfg, cfg.resincludedirs), cfg.resoptions)
 		_p('  RESFLAGS  += $(DEFINES) $(INCLUDES) %s', table.concat(resflags, " "))
 --
 
 	function cpp.linkconfig(cfg, toolset)
-		local flags = toolset.getlinks(cfg)
+		local flags = {}
+		for _, flag in ipairs(toolset.getlinks(cfg)) do
+			table.insert(flags, make.esc(flag))
+		end
+		
 		_p('  LIBS      += %s', table.concat(flags, " "))
 		
 		local deps = config.getlinks(cfg, "siblings", "fullpath")
 
 	function cpp.buildcommand_old(iscfile)
 		local flags = iif(iscfile, '$(CC) $(CFLAGS)', '$(CXX) $(CXXFLAGS)')
-		_p('\t$(SILENT) %s -o "$@" -MF $(@:%%.o=%%.d) -c "$<"', flags)
+		_p('\t$(SILENT) %s -o "$@" -MF "$(@:%%.o=%%.d)" -c "$<"', flags)
 	end
 
 

src/actions/make/make_solution.lua

 			for prj in solution.eachproject_ng(sln) do
 				local prjcfg = project.getconfig(prj, cfg.buildcfg, cfg.platform)
 				if prjcfg then
-					_p('  %s_config = %s', make.tovar(prj.name), prjcfg.shortname)
+					local cfgname = prjcfg.shortname
+					if prj.external then
+						cfgname = prjcfg.buildcfg
+					end
+					_p('  %s_config = %s', make.tovar(prj.name), make.esc(cfgname))
 				end
 			end
 			_p('endif')
 		for prj in solution.eachproject_ng(sln) do
 			local slnpath = solution.getlocation(sln)
 			local prjpath = path.getrelative(slnpath, project.getlocation(prj))
-			_p(1,'@${MAKE} --no-print-directory -C %s -f %s clean', make.esc(prjpath), make.esc(make.getmakefilename(prj, true)))
+			if prj.external then
+				_p(1, string.format(prj.cleancmd, prj.name, prj.externalname))
+			else
+				_p(1,'@${MAKE} --no-print-directory -C %s -f %s clean', make.esc(prjpath), make.esc(make.getmakefilename(prj, true)))
+			end
 		end
 		_p('')
 	end
 			local slnpath = solution.getlocation(sln)
 			local prjpath = path.getrelative(slnpath, project.getlocation(prj))
 			local filename = make.getmakefilename(prj, true)
-			_p(1,'@${MAKE} --no-print-directory -C %s -f %s config=$(%s_config)', make.esc(prjpath), make.esc(filename), cfgvar)
+			if prj.external then
+				_p(1, string.format(prj.buildcmd, cfgvar, prj.externalname))
+			else
+				_p(1,'@${MAKE} --no-print-directory -C %s -f %s config=$(%s_config)', make.esc(prjpath), make.esc(filename), cfgvar)
+			end
 			
 			_p('endif')
 			_p('')

src/actions/vstudio/vs2005_solution.lua

 				local prjcfg = project.getconfig(prj, slncfg.buildcfg, slncfg.platform)
 				if prjcfg then
 					local slnident = vstudio.solutionconfig(slncfg)
-					local prjplatform = vstudio.projectplatform(prjcfg)
-					local architecture = vstudio.architecture(prjcfg)
+					local prjplatform
+					if prj.external then
+						prjplatform = prjcfg.buildcfg
+					else
+						prjplatform = vstudio.projectplatform(prjcfg)
+					end
+					local architecture = prjcfg.platform or vstudio.architecture(prjcfg)
 					
 					_p(2,'{%s}.%s.ActiveCfg = %s|%s', prj.uuid, slnident, prjplatform, architecture)
 					_p(2,'{%s}.%s.Build.0 = %s|%s', prj.uuid, slnident, prjplatform, architecture)

src/actions/vstudio/vs2010_vcxproj.lua

 				local relpath = path.getrelative(prjpath, vstudio.projectfile(dep))
 				_x(2,'<ProjectReference Include=\"%s\">', path.translate(relpath))
 				_p(3,'<Project>{%s}</Project>', dep.uuid)
+				if dep.externalname then
+					_p(3, '<LinkLibraryDependencies>true</LinkLibraryDependencies>')
+				end
 				_p(2,'</ProjectReference>')
 			end
 			_p(1,'</ItemGroup>')
 	}
 
 	api.register {
+		name = "buildcmd",
+		scope = "project",
+		kind = "string"
+	}
+
+	api.register {
+		name = "cleancmd",
+		scope = "project",
+		kind = "string"
+	}
+
+	api.register {
 		name = "configmap",
 		scope = "project",
 		kind = "key-array"
 --
 
 	function external(name)
+		-- define it like a regular project
 		local prj = project(name)
+		
+		-- then mark it as external
 		prj.external = true;
+		prj.externalname = path.getname(name)
+		
 		return prj
 	end
 

src/base/project.lua

 	function premake.findproject(name)
 		for sln in premake.solution.each() do
 			for prj in premake.solution.eachproject(sln) do
-				if (prj.name == name) then
+				local projectname = prj.externalname or prj.name
+				if (projectname == name) then
 					return  prj
 				end
 			end

src/base/solution.lua

 	function solution.findproject(sln, name)
 		name = name:lower()
 		for _, prj in ipairs(sln.projects) do
-			if name == prj.name:lower() then
+			local projectname = prj.externalname or prj.name
+			if name == projectname:lower() then
 				return prj
 			end
 		end

src/project/config.lua

 			elseif premake.isdotnetproject(source.project) then
 				return premake.isdotnetproject(target.project)
 			end
-		end	
+		end
+
+		local function find_solution_config(buildcfg, configmap)
+			for slnconfig, map in pairs(configmap) do
+				for _, project_config in ipairs(map) do
+					if project_config == buildcfg then
+						return slnconfig
+					end
+				end
+			end
+		end
 
 		for _, link in ipairs(cfg.links) do
 			local item
 			-- is this a sibling project?
 			local prj = premake.solution.findproject(cfg.solution, link)
 			if prj and kind ~= "system" then
-
 				local prjcfg = project.getconfig(prj, cfg.buildcfg, cfg.platform)
+				if not prjcfg then
+					local slnconfig = find_solution_config(cfg.buildcfg, cfg.project.configmap)
+					if slnconfig then
+						prjcfg = project.getconfig(prj, slnconfig, cfg.platform)
+					end
+				end
 				if prjcfg and (kind == "dependencies" or canlink(cfg, prjcfg)) then
 					-- if the caller wants the whole project object, then okay
 					if part == "object" then

src/tools/gcc.lua

 					else
 						table.insert(result, "-l" .. link.linktarget.basename)
 					end
+				else
+					table.insert(result, "-l" .. link.project.externalname)	
 				end
 			end
 		end