1. Andrew Gough
  2. premake-dev-d

Commits

Jason Perkins  committed a99436e

Exclude external project references from dependency path lists since actual target isn't known

  • Participants
  • Parent commits c6ec080
  • Branches default

Comments (0)

Files changed (4)

File src/project/config.lua

View file
 
 				local prjcfg = project.getconfig(prj, cfg.buildcfg, cfg.platform)
 				if kind == "dependencies" or canlink(cfg, prjcfg) then
+					-- if the caller wants the whole project object, then okay
 					if part == "object" then
 						item = prjcfg
-					elseif part == "basename" then
-						item = config.getlinkinfo(prjcfg).basename
-					else
-						item = path.rebase(config.getlinkinfo(prjcfg).fullpath, 
-						                   project.getlocation(prjcfg.project), 
-						                   project.getlocation(cfg.project))
-						if part == "directory" then
-							item = path.getdirectory(item)
+					
+					-- if this is an external project reference, I can't return
+					-- any kind of path info, because I don't know the target name
+					elseif not prj.externalname then
+						if part == "basename" then
+							item = config.getlinkinfo(prjcfg).basename
+						else
+							item = path.rebase(config.getlinkinfo(prjcfg).fullpath, 
+											   project.getlocation(prjcfg.project), 
+											   project.getlocation(cfg.project))
+							if part == "directory" then
+								item = path.getdirectory(item)
+							end
 						end
 					end
 				end

File src/tools/gcc.lua

View file
 		if not systemonly then
 			links = config.getlinks(cfg, "siblings", "object")
 			for _, link in ipairs(links) do
-				local linkinfo = config.getlinkinfo(link)
-				if link.kind == premake.STATICLIB then
-					-- Don't use "-l" flag when linking static libraries; instead use 
-					-- path/libname.a to avoid linking a shared library of the same
-					-- name if one is present
-					table.insert(result, project.getrelative(cfg.project, linkinfo.abspath))
-				else
-					table.insert(result, "-l" .. linkinfo.basename)
+				-- skip external project references, since I have no way
+				-- to know the actual output target path
+				if not link.project.externalname then
+					local linkinfo = config.getlinkinfo(link)
+					if link.kind == premake.STATICLIB then
+						-- Don't use "-l" flag when linking static libraries; instead use 
+						-- path/libname.a to avoid linking a shared library of the same
+						-- name if one is present
+						table.insert(result, project.getrelative(cfg.project, linkinfo.abspath))
+					else
+						table.insert(result, "-l" .. linkinfo.basename)
+					end
 				end
 			end
 		end

File tests/config/test_links.lua

View file
 		local r = prepare("all", "directory")
 		test.isequal({ "../libs" }, r)
 	end
+
+
+--
+-- References to external projects should not appear in any results that
+-- use file paths, since there is no way to know what the actual library
+-- path might be. It is okay to return project objects though (right?)
+--
+
+	function suite.skipsExternalProjectRefs()
+		links { "MyProject2" }
+		
+		external "MyProject2"
+		kind "StaticLib"
+		language "C++"
+		
+		local r = prepare("all", "fullpath")
+		test.isequal({}, r)
+	end
+

File tests/tools/test_gcc.lua

View file
 		test.isequal({ "-I../include", "-Isrc/include" }, gcc.getincludedirs(cfg, cfg.includedirs))
 	end
 
+
+--
+-- Skip external projects when building the list of linked
+-- libraries, since I don't know the actual output target.
+--
+
+
+	function suite.skipsExternalProjectRefs()
+		links { "MyProject2" }
+		
+		external "MyProject2"
+		kind "StaticLib"
+		language "C++"
+		
+		prepare()
+		test.isequal({}, gcc.getlinks(cfg, false))
+	end