Commits

Dimitar Trendafilov  committed 19f8d31 Merge

* merge with upstream

  • Participants
  • Parent commits 9fcdc6a, 35636dc

Comments (0)

Files changed (14)

File src/_manifest.lua

File contents unchanged.

File src/actions/make/_make.lua

 --
 
 	function make.getmakefilename(this, searchprjs)
+		if searchprjs then
+			return this.name .. ".make"
+		end
 		local count = 0
 		for sln in premake.solution.each() do
 			if sln.location == this.location then
 				count = count + 1
 			end
-
-			if searchprjs then
-				for _, prj in ipairs(sln.projects) do
-					if prj.location == this.location then
-						count = count + 1
-					end
-				end
-			end
 		end
 
 		if count == 1 then
 			return "Makefile"
 		else
-			return ".make"
+			return this.name .. ".make"
 		end
 	end
 

File src/actions/make/make_cpp.lua

 --
 
 	function cpp.flags(cfg, toolset)
-		_p('  DEFINES   +=%s', make.list(toolset.getdefines(cfg.defines)))
+		local defines = make.esc(toolset.getdefines(cfg.defines))
+		_p('  DEFINES   +=%s', make.list(defines))
 
 		local includes = make.esc(toolset.getincludedirs(cfg, cfg.includedirs))
 		_p('  INCLUDES  +=%s', make.list(includes))
 		_p('  ALL_CFLAGS   += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)%s', make.list(table.join(toolset.getcflags(cfg), cfg.buildoptions)))
 		_p('  ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)%s', make.list(toolset.getcxxflags(cfg)))
 
+
 		local resflags = table.join(toolset.getdefines(cfg.resdefines), toolset.getincludedirs(cfg, cfg.resincludedirs), cfg.resoptions)
 		_p('  ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)%s', make.list(resflags))
 	end
 --
 
 	function cpp.linkconfig(cfg, toolset)
-		_p('  ALL_LDFLAGS  += $(LDFLAGS)%s', make.list(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('  ALL_LDFLAGS  += $(LDFLAGS) %s', table.concat(ldflags, " "))
 
-		local flags = toolset.getlinks(cfg)
+
+		local flags = {}
+		for _, flag in ipairs(toolset.getlinks(cfg)) do
+			if string.match(flag, '^-framework ') then
+				table.insert(flags, flag)
+			else
+				table.insert(flags, make.esc(flag))
+			end
+		end
 		_p('  LIBS      +=%s', make.list(flags))
+		
 
 		local deps = config.getlinks(cfg, "siblings", "fullpath")
 		_p('  LDDEPS    +=%s', make.list(make.esc(deps)))
 			end
 
 			local gch = make.esc(path.getname(pchheader))
+			local pch = make.esc(project.getrelative(cfg.project, pchheader))
 			_p('  PCH        = %s', make.esc(project.getrelative(cfg.project, pchheader)))
 			_p('  GCH        = $(OBJDIR)/%s.gch', gch)
-			_p('  ALL_CPPFLAGS += -I$(OBJDIR) -include $(OBJDIR)/%s', gch)
+			_p('  CPPFLAGS  += -I$(OBJDIR) -include %s', pch)
 		end
 	end
 

File 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')
 			local slnpath = solution.getlocation(sln)
 			local prjpath = project.getfilename(prj, make.getmakefilename(prj, true))
 			local prjdir = path.getdirectory(path.getrelative(slnpath, prjpath))
-			local prjname = path.getname(prjpath)
-			_p(1,'@${MAKE} --no-print-directory -C %s -f %s clean', make.esc(prjdir), make.esc(prjname))
+			if prj.external and prj.cleancmd then
+				_p(1, string.format(prj.cleancmd, prj.name, prj.externalname))
+			else
+				_p(1,'@${MAKE} -C %s -f %s clean', make.esc(prjdir), make.esc(make.getmakefilename(prj, true)))
+			end
 		end
 		_p('')
 	end
 			local slnpath = solution.getlocation(sln)
 			local prjpath = project.getfilename(prj, make.getmakefilename(prj, true))
 			local prjdir = path.getdirectory(path.getrelative(slnpath, prjpath))
-			local prjname = path.getname(prjpath)
+			if prj.external and prj.buildcmd then
+				_p(1, string.format(prj.buildcmd, cfgvar, prj.externalname))
+			else
+				_p(1,'@${MAKE} -C %s -f %s config=$(%s_config)', make.esc(prjdir), make.esc(prjpath), cfgvar)
+			end
 
-			_p(1,'@${MAKE} --no-print-directory -C %s -f %s config=$(%s_config)', make.esc(prjdir), make.esc(prjname), cfgvar)
 
 			_p('endif')
 			_p('')

File src/actions/vstudio/vs2005_solution.lua

 					local prjcfg = project.getconfig(prj, cfg.buildcfg, cfg.platform)
 					if prjcfg then
 						local prjplatform = vstudio.projectPlatform(prjcfg)
-						local architecture = vstudio.archFromConfig(prjcfg, true)
+						--[[
+						if not prjplatfrom then
+							projplatform = prjcfg.buildcfg
+						end
+						--]]
+						local architecture = prjcfg.platform or vstudio.architecture(prjcfg)
 
 						_p(2,'{%s}.%s.ActiveCfg = %s|%s', prj.uuid, slncfg[cfg], prjplatform, architecture)
 						_p(2,'{%s}.%s.Build.0 = %s|%s', prj.uuid, slncfg[cfg], prjplatform, architecture)

File 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>')

File src/base/api.lua

 	}
 
 	api.register {
+		name = "buildcmd",
+		scope = "project",
+		kind = "string"
+	}
+
+	api.register {
+		name = "cleancmd",
+		scope = "project",
+		kind = "string"
+	}
+
+	api.register {
 		name = "configmap",
 		scope = "config",
 		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)
+		prj.name = prj.externalname
+		
 		return prj
 	end
 

File src/base/context.lua

 			local field = premake.fields[key]
 			if field and field.tokens then
 				local kind = field.kind
-				local ispath = kind:startswith("path") or kind:startswith("file") or kind:startswith("mixed")
+				local ispath = kind:startswith("path") or kind:startswith("mixed") or kind:find('directory') or kind:startswith("file")
 				value = premake.detoken.expand(value, ctx.environ, ispath, ctx._basedir)
 			end
 

File src/base/detoken.lua

 			return result
 		end
 
-		function expandvalue(value)
-			local count
-			repeat
-				value, count = value:gsub("%%{(.-)}", function(token)
-					local result, err = expandtoken(token, environ)
-					if not result then
-						error(err, 0)
-					end
-					return result
-				end)
-			until count == 0
-
+		function fixpath(value)
 			-- if a path, look for a split out embedded absolute paths
 			if ispath then
 				local i, j
 			return value
 		end
 
+		function expandvalue(value)
+			local count
+			local result = value
+			repeat
+				value, count = value:gsub("%%{(.-)}", function(token)
+					local err
+					result, err = expandtoken(token, environ)
+					if not result then
+						error(err, 0)
+					end
+
+					return result
+				end)
+			until count == 0
+
+			return fixpath(value)
+		end
+
 		function recurse(value)
 			if type(value) == "table" then
 				for k, v in pairs(value) do

File 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

File 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

File src/project/config.lua

 		-- Iterate all of the links listed in the configuration and boil
 		-- them down to the requested data set
 
-		table.foreachi(cfg.links, function(link)
+		local function find_solution_config(buildcfg, configmap)
+			for slnconfig, map in pairs(configmap or {}) do
+				for _, project_config in ipairs(map) do
+					if project_config == buildcfg then
+						return slnconfig
+					end
+				end
+			end
+		end
+    
+		local function get_general_config(config)
+		  local space = config:find('%s[%p%w]+$')
+		  if space ~= nil then
+			return config:sub(1, space - 1)
+		  end
+		end
+
+		for _, link in ipairs(cfg.links) do
 			local item
 
 			-- Sort the links into "sibling" (is another project in this same
 
 			local prj = premake.solution.findproject(cfg.solution, link)
 			if prj and kind ~= "system" then
-
 				-- Sibling; is there a matching configuration in this project that
 				-- is compatible with linking to me?
 
 				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
+					if not prjcfg then
+						local config = get_general_config(cfg.buildcfg)
+						while config ~= nil and not prjcfg do
+							prjcfg = project.getconfig(prj, config, cfg.platform)
+							config = get_general_config(config)
+						end
+					end
+				end
 				if prjcfg and (kind == "dependencies" or config.canlink(cfg, prjcfg)) then
-
-					-- Yes; does the caller want the whole project config or only part?
-
+					-- if the caller wants the whole project object, then okay
 					if part == "object" then
 						item = prjcfg
 
 				table.insert(result, item)
 			end
 
-		end)
+		end
 
 		return result
 	end

File src/project/project.lua

File contents unchanged.

File src/tools/gcc.lua

File contents unchanged.