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.2.1-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) | local function find_includes(lib, alternative_cmd, alternative_flags) | ||||
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 | ||||
sysincludedirs(dirs) | return dirs, files, options | ||||
forceincludes(files) | |||||
buildoptions(options) | |||||
end | end | ||||
function m.add_links(lib, alternative_cmd, alternative_flags) | local function find_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) | ||||
else | else | ||||
if not alternative_flags then | if not alternative_flags then | ||||
result = os_capture(alternative_cmd.." --libs") | result = os_capture(alternative_cmd.." --libs") | ||||
else | else | ||||
result = os_capture(alternative_cmd.." "..alternative_flags) | result = os_capture(alternative_cmd.." "..alternative_flags) | ||||
Show All 13 Lines | if string.sub(w,1,2) == "-l" then | ||||
table.insert(libs, string.sub(w,3)) | table.insert(libs, string.sub(w,3)) | ||||
elseif string.sub(w,1,2) == "-L" then | elseif string.sub(w,1,2) == "-L" then | ||||
table.insert(dirs, string.sub(w,3)) | table.insert(dirs, string.sub(w,3)) | ||||
else | else | ||||
table.insert(options, w) | table.insert(options, w) | ||||
end | end | ||||
end | end | ||||
return libs, dirs, options | |||||
end | |||||
function m.load(lib, alternative_cmd) | |||||
local meths = {} | |||||
function meths.add_includes(alternative_flags) | |||||
local dirs, files, options = find_includes(lib, alternative_cmd, alternative_flags) | |||||
sysincludedirs(dirs) | |||||
forceincludes(files) | |||||
buildoptions(options) | |||||
end | |||||
function meths.add_includes_after_system(alternative_flags) | |||||
local dirs, files, options = find_includes(lib, alternative_cmd, alternative_flags) | |||||
aftersysincludedirs(dirs) | |||||
forceincludes(files) | |||||
buildoptions(options) | |||||
end | |||||
function meths.add_links(alternative_flags) | |||||
local libs, dirs, options = find_links(lib, alternative_cmd, alternative_flags) | |||||
links(libs) | links(libs) | ||||
libdirs(dirs) | libdirs(dirs) | ||||
linkoptions(options) | linkoptions(options) | ||||
end | end | ||||
return meths | |||||
wraitii: I like this approach, I think you ought to add an explicit failure message and rename "load" to… | |||||
s0600204AuthorUnsubmitted 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… | |||||
wraitiiUnsubmitted 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… | |||||
s0600204AuthorUnsubmitted 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? | |||||
wraitiiUnsubmitted 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… | |||||
s0600204AuthorUnsubmitted Not Done Inline ActionsHmm.
Am I missing something? s0600204: Hmm.
1. Replacing `aftersysincludedirs(dirs)` with `aftersysincludedirs(nil)` does not cause… | |||||
end | |||||
return m | return m |
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: