summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-04-03 00:45:33 +0800
committerruki <[email protected]>2021-04-03 00:45:33 +0800
commite11df3dc74e9cd0c840b3474ee3b85092a094732 (patch)
tree27706eff0412b0093ffbc092ba38291c3753a0c6
parent9762bed68e2143e9c088813018c525f734cd8110 (diff)
add longpaths
-rw-r--r--xmake/core/package/package.lua23
-rw-r--r--xmake/core/project/policy.lua4
-rw-r--r--xmake/modules/devel/git/submodule/update.lua22
-rw-r--r--xmake/modules/private/action/require/impl/actions/download.lua9
4 files changed, 52 insertions, 6 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index fd9ef0d6c..dbe2da3c5 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -38,6 +38,7 @@ local memcache = require("cache/memcache")
local toolchain = require("tool/toolchain")
local sandbox = require("sandbox/sandbox")
local config = require("project/config")
+local policy = require("project/policy")
local platform = require("platform/platform")
local platform_menu = require("platform/menu")
local language = require("language/language")
@@ -299,6 +300,24 @@ function _instance:revision(url_alias)
end
end
+-- get the package policy
+function _instance:policy(name)
+ local policies = self._POLICIES
+ if not policies then
+ policies = self:get("policy")
+ self._POLICIES = policies
+ if policies then
+ local defined_policies = policy.policies()
+ for name, _ in pairs(policies) do
+ if not defined_policies[name] then
+ utils.warning("unknown policy(%s), please run `xmake l core.project.policy.policies` if you want to all policies", name)
+ end
+ end
+ end
+ end
+ return policy.check(name, policies and policies[name])
+end
+
-- get the package kind
--
-- - binary
@@ -1617,8 +1636,10 @@ function package.apis()
}
, keyvalues =
{
+ -- package.set_xxx
+ "package.set_policy"
-- package.add_xxx
- "package.add_patches"
+ , "package.add_patches"
, "package.add_resources"
}
, dictionary =
diff --git a/xmake/core/project/policy.lua b/xmake/core/project/policy.lua
index 7a9d3a03d..7040182a2 100644
--- a/xmake/core/project/policy.lua
+++ b/xmake/core/project/policy.lua
@@ -42,7 +42,9 @@ function policy.policies()
-- we will check the compatibility of target and package licenses
["check.target_package_licenses"] = {description = "Enable check the compatibility of target and package licenses.", default = true, type = "boolean"},
-- we can compile the source files for each target in parallel
- ["build.across_targets_in_parallel"] = {description = "Enable compile the source files for each target in parallel.", default = true, type = "boolean"}
+ ["build.across_targets_in_parallel"] = {description = "Enable compile the source files for each target in parallel.", default = true, type = "boolean"},
+ -- we need enable longpaths when building target or installing package
+ ["platform.longpaths"] = {description = "Enable long paths when building target or installing package on windows.", default = false, type = "boolean"}
}
policy._POLICIES = policies
end
diff --git a/xmake/modules/devel/git/submodule/update.lua b/xmake/modules/devel/git/submodule/update.lua
index b75e391ca..5d9323a02 100644
--- a/xmake/modules/devel/git/submodule/update.lua
+++ b/xmake/modules/devel/git/submodule/update.lua
@@ -31,7 +31,7 @@ import("lib.detect.find_tool")
-- import("devel.git.submodule")
--
-- submodule.update({repodir = "/tmp/xmake", init = true, remote = true})
--- submodule.update({repodir = "/tmp/xmake", recursive = true, reference = "xxx", paths = "xxx"})
+-- submodule.update({repodir = "/tmp/xmake", recursive = true, longpaths = true, reference = "xxx", paths = "xxx"})
--
-- @endcode
--
@@ -64,9 +64,29 @@ function main(opt)
oldir = os.cd(opt.repodir)
end
+ -- enable long paths
+ local longpaths_old
+ local longpaths_changed = false
+ if opt.longpaths then
+ local longpaths_old = try {function () return os.iorunv(git.program, {"config", "--get", "--global", "core.longpaths"}) end}
+ if not longpaths_old or not longpaths_old:find("true") then
+ os.vrunv(git.program, {"config", "--global", "core.longpaths", "true"})
+ longpaths_changed = true
+ end
+ end
+
-- submodule it
os.vrunv(git.program, argv)
+ -- restore old long paths configuration
+ if longpaths_changed then
+ if longpaths_old and longpaths_old:find("false") then
+ os.vrunv(git.program, {"config", "--global", "core.longpaths", "false"})
+ else
+ os.vrunv(git.program, {"config", "--global", "--unset", "core.longpaths"})
+ end
+ end
+
-- leave repository directory
if oldir then
os.cd(oldir)
diff --git a/xmake/modules/private/action/require/impl/actions/download.lua b/xmake/modules/private/action/require/impl/actions/download.lua
index ac90a752f..01d75025c 100644
--- a/xmake/modules/private/action/require/impl/actions/download.lua
+++ b/xmake/modules/private/action/require/impl/actions/download.lua
@@ -59,25 +59,28 @@ function _checkout(package, url, sourcedir, url_alias)
-- remove temporary directory
os.rm(sourcedir .. ".tmp")
+ -- we need enable longpaths on windows
+ local longpaths = package:policy("platform.longpaths")
+
-- download package from branches?
packagedir = path.join(sourcedir .. ".tmp", package:name())
if package:branch() then
-- only shadow clone this branch
- git.clone(url, {depth = 1, recursive = true, longpaths = true, branch = package:branch(), outputdir = packagedir})
+ git.clone(url, {depth = 1, recursive = true, longpaths = longpaths, branch = package:branch(), outputdir = packagedir})
-- download package from revision or tag?
else
-- clone whole history and tags
- git.clone(url, {longpaths = true, outputdir = packagedir})
+ git.clone(url, {longpaths = longpaths, outputdir = packagedir})
-- attempt to checkout the given version
local revision = package:revision(url_alias) or package:tag() or package:version_str()
git.checkout(revision, {repodir = packagedir})
-- update all submodules
- git.submodule.update({init = true, recursive = true, repodir = packagedir})
+ git.submodule.update({init = true, recursive = true, longpaths = longpaths, repodir = packagedir})
end
-- move to source directory