summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-03-14 23:57:38 +0800
committerruki <[email protected]>2019-03-14 17:45:49 +0800
commit9036abe2d5d282bd19c9f6bdd2acee9ac03051fc (patch)
tree9de2c370b841128b754bd2590e4d0a82173bbe7f
parent1885d14af400ea5658dc89431fc1353184e40643 (diff)
fix uninstall and remove unlink for package
-rw-r--r--xmake/actions/require/impl/action/install.lua24
-rw-r--r--xmake/actions/require/impl/package.lua36
-rw-r--r--xmake/actions/require/main.lua6
-rw-r--r--xmake/actions/require/unlink.lua77
-rw-r--r--xmake/actions/require/xmake.lua1
-rw-r--r--xmake/core/package/package.lua2
-rw-r--r--xmake/core/tool/compiler.lua7
-rw-r--r--xmake/core/tool/linker.lua7
-rw-r--r--xmake/modules/lib/detect/check_cxsnippets.lua2
9 files changed, 25 insertions, 137 deletions
diff --git a/xmake/actions/require/impl/action/install.lua b/xmake/actions/require/impl/action/install.lua
index a032dd7aa..f55d8afd1 100644
--- a/xmake/actions/require/impl/action/install.lua
+++ b/xmake/actions/require/impl/action/install.lua
@@ -79,6 +79,7 @@ function main(package)
local installtask = function ()
-- install the third-party package directly, e.g. brew::pcre2/libpcre2-8, conan::OpenSSL/1.0.2n@conan/stable
+ local need_test = false
if package:is3rd() then
local script = package:script("install")
if script ~= nil then
@@ -102,11 +103,21 @@ function main(package)
-- save the package info to the manifest file
package:manifest_save()
-
- -- test it
- test(package)
+ need_test = true
end
end
+
+ -- fetch package and force to flush the cache
+ local fetchinfo = package:fetch({force = true})
+ if option.get("verbose") or option.get("diagnosis") then
+ print(fetchinfo)
+ end
+ assert(fetchinfo, "fetch %s failed!", tipname)
+
+ -- test it
+ if need_test then
+ test(package)
+ end
end
-- install package
@@ -116,13 +127,6 @@ function main(package)
process.asyncrun(installtask)
end
- -- fetch package and force to flush the cache
- local fetchinfo = package:fetch({force = true})
- if option.get("verbose") or option.get("diagnosis") then
- print(fetchinfo)
- end
- assert(fetchinfo, "fetch %s failed!", tipname)
-
-- trace
cprint("${color.success}${text.success}")
end,
diff --git a/xmake/actions/require/impl/package.lua b/xmake/actions/require/impl/package.lua
index dbed2aee8..06fa89a1e 100644
--- a/xmake/actions/require/impl/package.lua
+++ b/xmake/actions/require/impl/package.lua
@@ -601,48 +601,14 @@ function uninstall_packages(requires, opt)
-- remove all packages
local packages = {}
for _, instance in ipairs(load_packages(requires, opt)) do
- if os.isfile(instance:prefixfile()) then
-
- -- uninstall package from the prefix directory
- action.prefix.uninstall(instance)
-
- -- remove ok
+ if os.isfile(instance:manifest_file()) then
table.insert(packages, instance)
end
-
- -- remove the installed files
os.tryrm(instance:installdir())
end
return packages
end
--- only unlink packages from the prefix directory
-function unlink_packages(requires, opt)
-
- -- init options
- opt = opt or {}
-
- -- do not remove dependent packages
- opt.nodeps = true
-
- -- clear the detect cache
- detectcache.clear()
-
- -- unlink all packages
- local packages = {}
- for _, instance in ipairs(load_packages(requires, opt)) do
- if os.isfile(instance:prefixfile()) then
-
- -- uninstall package from the prefix directory
- action.prefix.uninstall(instance)
-
- -- remove ok
- table.insert(packages, instance)
- end
- end
- return packages
-end
-
-- search packages
function search_packages(names)
diff --git a/xmake/actions/require/main.lua b/xmake/actions/require/main.lua
index 5e5ccd830..ed42efcd5 100644
--- a/xmake/actions/require/main.lua
+++ b/xmake/actions/require/main.lua
@@ -34,7 +34,6 @@ import("clear")
import("search")
import("install")
import("uninstall")
-import("unlink")
--
-- the default repositories:
@@ -89,11 +88,6 @@ function main()
uninstall(option.get("requires"))
- -- unlink the installed packages
- elseif option.get("unlink") then
-
- unlink(option.get("requires"))
-
-- show the given package info
elseif option.get("info") then
diff --git a/xmake/actions/require/unlink.lua b/xmake/actions/require/unlink.lua
deleted file mode 100644
index de1cd5f99..000000000
--- a/xmake/actions/require/unlink.lua
+++ /dev/null
@@ -1,77 +0,0 @@
---!A cross-platform build utility based on Lua
---
--- Licensed to the Apache Software Foundation (ASF) under one
--- or more contributor license agreements. See the NOTICE file
--- distributed with this work for additional information
--- regarding copyright ownership. The ASF licenses this file
--- to you 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 - 2019, TBOOX Open Source Group.
---
--- @author ruki
--- @file unlink.lua
---
-
--- imports
-import("core.base.task")
-import("core.base.option")
-import("core.project.project")
-import("impl.package")
-import("impl.repository")
-import("impl.environment")
-
--- unlink the given packages
-function main(package_names)
-
- -- no package names?
- if not package_names then
- return
- end
-
- -- enter environment
- environment.enter()
-
- -- pull all repositories first if not exists
- if not repository.pulled() then
- task.run("repo", {update = true})
- end
-
- -- get project requires
- local project_requires, requires_extra = project.requires_str()
- if not project_requires then
- raise("requires(%s) not found in project!", table.concat(requires, " "))
- end
-
- -- find required package in project
- local requires = {}
- for _, name in ipairs(package_names) do
- for _, require_str in ipairs(project_requires) do
- if require_str:split(' ')[1]:lower():find(name:lower()) then
- table.insert(requires, require_str)
- end
- end
- end
- if #requires == 0 then
- raise("%s not found in project!", table.concat(package_names, " "))
- end
-
- -- unlink packages
- local packages = package.unlink_packages(requires, {requires_extra = requires_extra})
- for _, instance in ipairs(packages) do
- print("unlink: %s%s ok!", instance:name(), instance:version_str() and ("-" .. instance:version_str()) or "")
- end
-
- -- leave environment
- environment.leave()
-end
-
diff --git a/xmake/actions/require/xmake.lua b/xmake/actions/require/xmake.lua
index 35d6e0853..c9cf9452f 100644
--- a/xmake/actions/require/xmake.lua
+++ b/xmake/actions/require/xmake.lua
@@ -51,7 +51,6 @@ task("require")
, { }
, {nil, "info", "k", nil, "Show the given package info." }
, {'s', "search", "k", nil, "Search for the given packages from repositories." }
- , {nil, "unlink", "k", nil, "Only unlink the installed packages." }
, {nil, "uninstall", "k", nil, "Uninstall the installed packages." }
, {nil, "extra", "kv", nil, "Set the extra info of packages." }
, { }
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index b81536443..89d4d95c5 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -646,7 +646,7 @@ function _instance:fetch(opt)
return fetchinfo
end
--- exists this package in local
+-- exists this package?
function _instance:exists()
return self._FETCHINFO
end
diff --git a/xmake/core/tool/compiler.lua b/xmake/core/tool/compiler.lua
index 781e95e7d..a3715379f 100644
--- a/xmake/core/tool/compiler.lua
+++ b/xmake/core/tool/compiler.lua
@@ -266,7 +266,7 @@ end
--
-- @param opt the argument options (contain all the compiler attributes of target),
-- .e.g
--- {target = ..., targetkind = "static", config = {defines = "", cxflags = "", includedirs = ""}}
+-- {target = ..., targetkind = "static", configs = {defines = "", cxflags = "", includedirs = ""}}
--
-- @return flags string, flags list
--
@@ -300,8 +300,9 @@ function compiler:compflags(opt)
end
-- add flags for the argument
- if opt.config then
- self:_add_flags_from_argument(flags, target, opt.config)
+ local configs = opt.configs or opt.config
+ if configs then
+ self:_add_flags_from_argument(flags, target, configs)
end
-- add flags from the platform
diff --git a/xmake/core/tool/linker.lua b/xmake/core/tool/linker.lua
index f7482888c..6f9d9e6eb 100644
--- a/xmake/core/tool/linker.lua
+++ b/xmake/core/tool/linker.lua
@@ -247,7 +247,7 @@ end
-- get the link flags
--
-- @param opt the argument options (contain all the linker attributes of target),
--- .e.g {target = ..., targetkind = "static", config = {ldflags = "", links = "", linkdirs = "", ...}}
+-- .e.g {target = ..., targetkind = "static", configs = {ldflags = "", links = "", linkdirs = "", ...}}
--
function linker:linkflags(opt)
@@ -271,8 +271,9 @@ function linker:linkflags(opt)
self:_add_flags_from_target(flags, target)
-- add flags for the argument
- if opt.config then
- self:_add_flags_from_argument(flags, target, opt.config)
+ local configs = opt.configs or opt.config
+ if configs then
+ self:_add_flags_from_argument(flags, target, configs)
end
-- add flags from the platform
diff --git a/xmake/modules/lib/detect/check_cxsnippets.lua b/xmake/modules/lib/detect/check_cxsnippets.lua
index e44043b99..5ef642f09 100644
--- a/xmake/modules/lib/detect/check_cxsnippets.lua
+++ b/xmake/modules/lib/detect/check_cxsnippets.lua
@@ -120,7 +120,7 @@ end
-- .e.g
-- { verbose = false, target = [target|option], sourcekind = "[cc|cxx]"
-- , types = {"wchar_t", "char*"}, includes = "stdio.h", funcs = {"sigsetjmp", "sigsetjmp((void*)0, 0)"}
--- , config = {defines = "xx", cxflags = ""}}
+-- , configs = {defines = "xx", cxflags = ""}}
--
-- funcs:
-- sigsetjmp