summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-11-06 21:41:57 +0800
committerruki <[email protected]>2021-11-06 21:41:57 +0800
commit1e4cbd0ad277904bf86366dfba44c965fc640f73 (patch)
tree48e6812fe8a9d2c400b6be480f81f0be2640db57
parent736dc4db6368fa4dd1770e768c5577bc8d55255d (diff)
add pkgconf
-rw-r--r--tests/test_utils/test_build.lua2
-rw-r--r--xmake/modules/detect/tools/find_pkg_config.lua2
-rw-r--r--xmake/modules/detect/tools/find_pkgconf.lua52
-rw-r--r--xmake/modules/lib/detect/pkgconfig.lua16
-rw-r--r--xmake/modules/target/action/install/pkgconfig_importfiles.lua4
5 files changed, 66 insertions, 10 deletions
diff --git a/tests/test_utils/test_build.lua b/tests/test_utils/test_build.lua
index 2a42e67d8..c08e80dc5 100644
--- a/tests/test_utils/test_build.lua
+++ b/tests/test_utils/test_build.lua
@@ -9,7 +9,7 @@ function test_build:build(argv)
os.exec("xmake g -c")
-- generic?
- os.exec("xmake f -c -D -y")
+ os.exec("xmake f -c -vD -y")
os.exec("xmake")
os.exec("xmake p -D")
if not is_host("windows") then
diff --git a/xmake/modules/detect/tools/find_pkg_config.lua b/xmake/modules/detect/tools/find_pkg_config.lua
index 00698d2cc..0dc83454a 100644
--- a/xmake/modules/detect/tools/find_pkg_config.lua
+++ b/xmake/modules/detect/tools/find_pkg_config.lua
@@ -48,7 +48,5 @@ function main(opt)
if program and opt and opt.version then
version = find_programver(program, opt)
end
-
- -- ok?
return program, version
end
diff --git a/xmake/modules/detect/tools/find_pkgconf.lua b/xmake/modules/detect/tools/find_pkgconf.lua
new file mode 100644
index 000000000..563989268
--- /dev/null
+++ b/xmake/modules/detect/tools/find_pkgconf.lua
@@ -0,0 +1,52 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file find_pkgconf.lua
+--
+
+-- imports
+import("lib.detect.find_program")
+import("lib.detect.find_programver")
+
+-- find pkgconf
+--
+-- @param opt the argument options, e.g. {version = true}
+--
+-- @return program, version
+--
+-- @code
+--
+-- local pkgconf = find_pkgconf()
+-- local pkgconf, version = find_pkgconf({version = true})
+--
+-- @endcode
+--
+function main(opt)
+
+ -- init options
+ opt = opt or {}
+
+ -- find program
+ local program = find_program(opt.program or "pkgconf", opt)
+
+ -- find program version
+ local version = nil
+ if program and opt and opt.version then
+ version = find_programver(program, opt)
+ end
+ return program, version
+end
diff --git a/xmake/modules/lib/detect/pkgconfig.lua b/xmake/modules/lib/detect/pkgconfig.lua
index 57726bae0..cf6b6d97d 100644
--- a/xmake/modules/lib/detect/pkgconfig.lua
+++ b/xmake/modules/lib/detect/pkgconfig.lua
@@ -24,7 +24,15 @@ import("core.project.target")
import("core.project.config")
import("lib.detect.find_file")
import("lib.detect.find_library")
-import("detect.tools.find_pkg_config")
+import("lib.detect.find_tool")
+
+-- get pkgconfig
+function _get_pkgconfig()
+ local pkgconfig = find_tool("pkg-config") or find_tool("pkgconf")
+ if pkgconfig then
+ return pkgconfig.program
+ end
+end
-- get version
--
@@ -34,7 +42,7 @@ import("detect.tools.find_pkg_config")
function version(name, opt)
-- attempt to add search paths from pkg-config
- local pkgconfig = find_pkg_config()
+ local pkgconfig = _get_pkgconfig()
if not pkgconfig then
return
end
@@ -73,7 +81,7 @@ end
function variables(name, variables, opt)
-- attempt to add search paths from pkg-config
- local pkgconfig = find_pkg_config()
+ local pkgconfig = _get_pkgconfig()
if not pkgconfig then
return
end
@@ -125,7 +133,7 @@ end
function libinfo(name, opt)
-- attempt to add search paths from pkg-config
- local pkgconfig = find_pkg_config()
+ local pkgconfig = _get_pkgconfig()
if not pkgconfig then
return
end
diff --git a/xmake/modules/target/action/install/pkgconfig_importfiles.lua b/xmake/modules/target/action/install/pkgconfig_importfiles.lua
index 820d7ef54..6954a1bb5 100644
--- a/xmake/modules/target/action/install/pkgconfig_importfiles.lua
+++ b/xmake/modules/target/action/install/pkgconfig_importfiles.lua
@@ -24,10 +24,8 @@ function main(target, opt)
-- check
opt = opt or {}
assert(target:is_library(), 'pkgconfig_importfiles: only support for library target(%s)!', target:name())
-
- -- only for unix platform
local installdir = target:installdir()
- if target:is_plat("windows") or not installdir then
+ if not installdir then
return
end