Changeset View
Changeset View
Standalone View
Standalone View
build/premake/pkgconfig/pkgconfig.lua
local m = {} | local m = {} | ||||
m._VERSION = "1.1.0-dev" | m._VERSION = "1.1.0-dev" | ||||
local function os_capture(cmd) | local function os_capture(cmd) | ||||
return io.popen(cmd, 'r'):read('*a'):gsub("\n", " ") | return io.popen(cmd, 'r'):read('*a'):gsub("\n", " ") | ||||
end | end | ||||
function m.add_includes(lib, alternative_cmd, alternative_flags) | function m.add_includes(lib, alternative_cmd, alternative_flags, after_system_includes) | ||||
local result | local result | ||||
if not alternative_cmd then | if not alternative_cmd then | ||||
result = os_capture("pkg-config --cflags "..lib) | result = os_capture("pkg-config --cflags "..lib) | ||||
else | else | ||||
if not alternative_flags then | if not alternative_flags then | ||||
result = os_capture(alternative_cmd.." --cflags") | result = os_capture(alternative_cmd.." --cflags") | ||||
else | else | ||||
result = os_capture(alternative_cmd.." "..alternative_flags) | result = os_capture(alternative_cmd.." "..alternative_flags) | ||||
Show All 12 Lines | if string.sub(w,1,2) == "-I" then | ||||
table.insert(dirs, string.sub(w,3)) | table.insert(dirs, string.sub(w,3)) | ||||
elseif string.sub(w,1,8) == "-include" then | elseif string.sub(w,1,8) == "-include" then | ||||
table.insert(files, string.sub(w,9)) | table.insert(files, string.sub(w,9)) | ||||
else | else | ||||
table.insert(options, w) | table.insert(options, w) | ||||
end | end | ||||
end | end | ||||
if not after_system_includes then | |||||
sysincludedirs(dirs) | sysincludedirs(dirs) | ||||
else | |||||
aftersysincludedirs(dirs) | |||||
end | |||||
forceincludes(files) | forceincludes(files) | ||||
buildoptions(options) | buildoptions(options) | ||||
end | end | ||||
function m.add_links(lib, alternative_cmd, alternative_flags) | function m.add_links(lib, alternative_cmd, alternative_flags) | ||||
local result | local result | ||||
if not alternative_cmd then | if not alternative_cmd then | ||||
result = os_capture("pkg-config --libs "..lib) | result = os_capture("pkg-config --libs "..lib) | ||||
Show All 23 Lines | for w in string.gmatch(result, "[^' ']+") do | ||||
end | end | ||||
end | end | ||||
links(libs) | links(libs) | ||||
libdirs(dirs) | libdirs(dirs) | ||||
linkoptions(options) | linkoptions(options) | ||||
end | end | ||||
return m | return m | ||||
wraitii: I like this approach, I think you ought to add an explicit failure message and rename "load" to… | |||||
Done Inline ActionsI disagree with adding a failure state - it is possible that a dependency might not need any additional include paths on certain systems. For instance, x11 on my machine doesn't need additional include paths beyond the standard system paths. But if one considers the hard-coded paths that were removed in rP22302 (the sysincludedirs), this is clearly not true for everyone. s0600204: I disagree with adding a failure state - it is possible that a dependency might not need any… | |||||
Not Done Inline ActionsIt fails regardless in your code because there are calls with 'nil' then, which should be fixed regardless wraitii: It fails regardless in your code because there are calls with 'nil' then, which should be fixed… | |||||
Not Done Inline ActionsYou mean you're getting error messages and/or the build's failing at this point? s0600204: You mean you're getting error messages and/or the build's failing at this point? | |||||
Not Done Inline ActionsYes, aftersysincludedirs(nil) fails. I added the "fail" because at least it's an explicit failure. If that's not what you want, it ought to be changed. wraitii: Yes, `aftersysincludedirs(nil)` fails. I added the "fail" because at least it's an explicit… | |||||
Not Done Inline ActionsHmm.
Am I missing something? s0600204: Hmm.
1. Replacing `aftersysincludedirs(dirs)` with `aftersysincludedirs(nil)` does not cause… |
Wildfire Games · Phabricator
I like this approach, I think you ought to add an explicit failure message and rename "load" to "find_system" or something, like so: