summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-10-05 00:46:43 +0800
committerruki <[email protected]>2018-10-04 22:40:21 +0800
commit2795b39f0b54d16c44ebee788a609108685c2e81 (patch)
treebcfadb0810311dc185f806852f7777dc3ec2064f
parentf1edfe402c882ad01e471dbdfbf019533414ee49 (diff)
add pkgconfig search pathes
-rw-r--r--xmake/actions/require/impl/action/install.lua4
-rw-r--r--xmake/actions/require/impl/action/prefix/install.lua3
-rw-r--r--xmake/actions/require/impl/action/prefix/uninstall.lua3
-rw-r--r--xmake/actions/require/impl/environment.lua26
-rw-r--r--xmake/core/package/package.lua15
-rw-r--r--xmake/core/sandbox/modules/import/core/package/package.lua10
6 files changed, 53 insertions, 8 deletions
diff --git a/xmake/actions/require/impl/action/install.lua b/xmake/actions/require/impl/action/install.lua
index 8885889fa..b720d7bc8 100644
--- a/xmake/actions/require/impl/action/install.lua
+++ b/xmake/actions/require/impl/action/install.lua
@@ -79,8 +79,8 @@ function main(package)
-- create the install task
local installtask = function ()
- -- clean the install directory first
- os.tryrm(package:installdir())
+ -- uninstall the install directory first
+ prefix.uninstall(package)
-- install it
for i = 1, 3 do
diff --git a/xmake/actions/require/impl/action/prefix/install.lua b/xmake/actions/require/impl/action/prefix/install.lua
index 78c6f1ed0..4e0d507a0 100644
--- a/xmake/actions/require/impl/action/prefix/install.lua
+++ b/xmake/actions/require/impl/action/prefix/install.lua
@@ -198,9 +198,6 @@ end
-- install package to the prefix directory
function main(package)
- -- uninstall the prefix package files first
- uninstall(package)
-
-- init some pathes
_g.prefixdir = package:prefixdir()
_g.installdir = package:installdir()
diff --git a/xmake/actions/require/impl/action/prefix/uninstall.lua b/xmake/actions/require/impl/action/prefix/uninstall.lua
index 420524fd2..9c77cbb96 100644
--- a/xmake/actions/require/impl/action/prefix/uninstall.lua
+++ b/xmake/actions/require/impl/action/prefix/uninstall.lua
@@ -49,5 +49,8 @@ function main(package)
-- remove the prefix file
os.tryrm(package:prefixfile())
+
+ -- remove the install directory
+ os.tryrm(package:installdir())
end
diff --git a/xmake/actions/require/impl/environment.lua b/xmake/actions/require/impl/environment.lua
index f340ab7eb..e67427b77 100644
--- a/xmake/actions/require/impl/environment.lua
+++ b/xmake/actions/require/impl/environment.lua
@@ -25,6 +25,7 @@
-- imports
import("core.project.config")
import("core.platform.environment")
+import("core.package.package", {alias = "core_package"})
import("lib.detect.find_tool")
import("package")
@@ -43,11 +44,36 @@ function enter()
if not find_tool("git") then
package.install_packages("git")
end
+
+ -- get prefix directories
+ local plat = get_config("plat")
+ local arch = get_config("arch")
+ _g.prefixdirs = _g.prefixdirs or
+ {
+ core_package.prefixdir(false, false, plat, arch),
+ core_package.prefixdir(false, true, plat, arch),
+ core_package.prefixdir(true, false, plat, arch),
+ core_package.prefixdir(true, true, plat, arch)
+ }
+
+ -- add search directories of pkgconfig, aclocal
+ _g._ACLOCAL_PATH = os.getenv("ACLOCAL_PATH")
+ _g._PKG_CONFIG_PATH = os.getenv("PKG_CONFIG_PATH")
+ if not is_plat("windows") then
+ for _, prefixdir in ipairs(_g.prefixdirs) do
+ os.addenv("ACLOCAL_PATH", path.join(prefixdir, "share", "aclocal"))
+ os.addenv("PKG_CONFIG_PATH", path.join(prefixdir, "lib", "pkgconfig"))
+ end
+ end
end
-- leave environment
function leave()
+ -- restore search directories of pkgconfig, aclocal
+ os.setenv("ACLOCAL_PATH", _g._ACLOCAL_PATH)
+ os.setenv("PKG_CONFIG_PATH", _g._PKG_CONFIG_PATH)
+
-- restore search pathes of toolchains
environment.leave("toolchains")
end
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index 43c7971df..0f1a32b8b 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -369,11 +369,20 @@ function _instance:requireinfo_set(requireinfo)
-- save require info
self._REQUIREINFO = requireinfo
- -- switch to local package if exists package configuration or debug package or limit version
+ -- get version
local version = requireinfo and requireinfo.version or nil
local limitversion = version and version ~= "master" and version ~= "lastest"
- if requireinfo and (requireinfo.config or requireinfo.debug or limitversion) then
- self._FROMKIND = "local"
+ if requireinfo then
+
+ -- switch to local package if exists package configuration or debug package or limit version
+ if requireinfo.config or requireinfo.debug or limitversion then
+ self._FROMKIND = "local"
+ end
+
+ -- disable the system package if limit version
+ if limitversion then
+ requireinfo.system = false
+ end
end
end
diff --git a/xmake/core/sandbox/modules/import/core/package/package.lua b/xmake/core/sandbox/modules/import/core/package/package.lua
index bbcad0ec3..178467208 100644
--- a/xmake/core/sandbox/modules/import/core/package/package.lua
+++ b/xmake/core/sandbox/modules/import/core/package/package.lua
@@ -35,6 +35,16 @@ function sandbox_core_package_package.cachedir()
return package.cachedir()
end
+-- the install directory
+function sandbox_core_package_package.installdir(is_global, is_debug, plat, arch)
+ return package.installdir(is_global, is_debug, plat, arch)
+end
+
+-- get the prefix directory
+function sandbox_core_package_package.prefixdir(is_global, is_debug, plat, arch)
+ return package.prefixdir(is_global, is_debug, plat, arch)
+end
+
-- load the package from the project file
function sandbox_core_package_package.load_from_project(packagename)