summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-08-14 22:41:08 +0800
committerruki <[email protected]>2018-08-14 10:06:49 +0800
commit6b471f65f4536d07150b89504bf52753461064a5 (patch)
tree51b7264dac2baa7d5b6559cea50badaeac3fb1bc
parente5011cbbe2717c0fd07c4da2394f6ced07a3f6cc (diff)
detect case-sensitive filesystem
-rw-r--r--CHANGELOG.md2
-rw-r--r--xmake/core/base/os.lua24
-rw-r--r--xmake/core/base/path.lua4
-rw-r--r--xmake/core/sandbox/modules/os.lua1
4 files changed, 29 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 01651d54e..39d94235a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,7 @@
* Improve to detect Qt envirnoment and support mingw
* Add debug and release rules to the auto-generated xmake.lua
* [#178](https://github.com/tboox/xmake/issues/178): Modify the shared library name for mingw.
+* Support case-insensitive path pattern-matching for `add_files()` on windows
### Bug fixed
@@ -482,6 +483,7 @@
* 改进Qt编译编译环境探测,增加对mingw sdk的支持
* 在自动扫描生成的xmake.lua中增加默认debug/release规则
* [#178](https://github.com/tboox/xmake/issues/178): 修改mingw平台下的目标名
+* 对于`add_files()`在windows上支持大小写不敏感路径模式匹配
### Bugs修复
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua
index 4820fa3a1..c0f86c805 100644
--- a/xmake/core/base/os.lua
+++ b/xmake/core/base/os.lua
@@ -851,6 +851,30 @@ function os.isroot()
return os.uid().euid == 0
end
+-- is case-insensitive filesystem?
+function os.fscase()
+ if os._FSCASE == nil then
+ if os.host() == "windows" then
+ os._FSCASE = false
+ else
+
+ -- get temporary directory
+ local tmpdir = os.tmpdir()
+
+ -- attempt to detect it
+ local file = os.filedirs(path.join(tmpdir, "**"), function (file, isdir) return false end)
+ if file and #file > 0 then
+ local file1 = file[1]
+ local file2 = file1:gsub(".", function (ch) return (ch >= 'a' and ch <= 'z') and ch:upper() or ch:lower() end)
+ os._FSCASE = not (os.exists(file1) and os.exists(file2))
+ else
+ os._FSCASE = true
+ end
+ end
+ end
+ return os._FSCASE
+end
+
-- set values to environment variable
function os.setenv(name, ...)
diff --git a/xmake/core/base/path.lua b/xmake/core/base/path.lua
index 19189ee90..61fd2acda 100644
--- a/xmake/core/base/path.lua
+++ b/xmake/core/base/path.lua
@@ -119,8 +119,8 @@ function path.pattern(pattern)
pattern = pattern:gsub("\001", ".*")
pattern = pattern:gsub("\002", "[^/]*")
- -- case-insensitive for windows path
- if os.host() == "windows" then
+ -- case-insensitive filesystem?
+ if not os.fscase() then
pattern = string.ipattern(pattern, true)
end
return pattern
diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua
index e029588d5..ddf5105cd 100644
--- a/xmake/core/sandbox/modules/os.lua
+++ b/xmake/core/sandbox/modules/os.lua
@@ -45,6 +45,7 @@ sandbox_os.argw = os.argw
sandbox_os.mtime = os.mtime
sandbox_os.sleep = os.sleep
sandbox_os.raise = os.raise
+sandbox_os.fscase = os.fscase
sandbox_os.isroot = os.isroot
sandbox_os.mclock = os.mclock
sandbox_os.nuldev = os.nuldev