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.1-dev" | ||||
m.additional_pc_path = nil | |||||
m.static_link_libs = false | |||||
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.print_version_of(lib) | |||||
local function os_capture_num(cmd) | |||||
return io.popen(cmd, 'r'):read('n') | |||||
end | |||||
print("Reported version(s) of "..lib..":") | |||||
if os_capture_num("pkg-config --exists "..lib.."; echo $?") == 0 then | |||||
print("\ton system: "..os_capture("pkg-config --modversion "..lib)) | |||||
else | |||||
print("\ton system: Not Found") | |||||
end | |||||
if m.additional_pc_path then | |||||
-- There doesn't seem to be a way to check *only* the provided path, so this will display | |||||
-- the system-installed version if there's not a relevant .pc file in the provided path. | |||||
local pc_path = "PKG_CONFIG_PATH="..m.additional_pc_path | |||||
print("\tw. bundled: "..os_capture(pc_path.." pkg-config --modversion "..lib)) | |||||
end | |||||
end | |||||
function m.add_includes(lib, alternative_cmd, alternative_flags) | function m.add_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) | local pc_path = m.additional_pc_path and "PKG_CONFIG_PATH="..m.additional_pc_path or "" | ||||
result = os_capture(pc_path.." 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) | ||||
end | end | ||||
end | end | ||||
Show All 17 Lines | function m.add_includes(lib, alternative_cmd, alternative_flags) | ||||
sysincludedirs(dirs) | sysincludedirs(dirs) | ||||
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) | local pc_path = m.additional_pc_path and "PKG_CONFIG_PATH="..m.additional_pc_path or "" | ||||
local static = m.static_link_libs and " --static " or "" | |||||
result = os_capture(pc_path.." pkg-config --libs "..static..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) | ||||
end | end | ||||
end | end | ||||
-- On OSX, wx-config outputs "-framework foo" instead of "-Wl,-framework,foo" | -- On OSX, wx-config outputs "-framework foo" instead of "-Wl,-framework,foo" | ||||
-- which doesn't fare well with the splitting into libs, libdirs and options | -- which doesn't fare well with the splitting into libs, libdirs and options | ||||
Show All 22 Lines |
Wildfire Games · Phabricator