summaryrefslogtreecommitdiff
path: root/xmake/core/main.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2017-04-01 14:20:37 +0800
committerruki <[email protected]>2017-04-01 14:20:37 +0800
commitc5c844960ffc68bf7b701b0fbb1577b79fd2b15c (patch)
tree68310f4924823417189e49ec97bd09a5aa563977 /xmake/core/main.lua
parent9ddb1d298ddaf90c0f2d759c93f02890d1128fb4 (diff)
fix find xmake.lua in subdirs
Diffstat (limited to 'xmake/core/main.lua')
-rw-r--r--xmake/core/main.lua44
1 files changed, 20 insertions, 24 deletions
diff --git a/xmake/core/main.lua b/xmake/core/main.lua
index 8f0f2d1e6..6b95b0a75 100644
--- a/xmake/core/main.lua
+++ b/xmake/core/main.lua
@@ -100,33 +100,29 @@ function main._init()
xmake._PROJECT_FILE = projectfile
assert(projectfile)
- -- xmake.lua not found? attempt to find it from the parent directory
- if not os.isfile(projectfile) then
-
- -- make all parent directories
- local dirs = {}
- local dir = path.directory(projectfile)
- while os.isdir(dir) do
- table.insert(dirs, 1, dir)
- local parentdir = path.directory(dir)
- if parentdir ~= dir then
- dir = parentdir
- else
- break
- end
+ -- make all parent directories
+ local dirs = {}
+ local dir = path.directory(projectfile)
+ while os.isdir(dir) do
+ table.insert(dirs, 1, dir)
+ local parentdir = path.directory(dir)
+ if parentdir ~= dir then
+ dir = parentdir
+ else
+ break
end
+ end
- -- find the first `xmake.lua`
- for _, dir in ipairs(dirs) do
- local file = path.join(dir, "xmake.lua")
- if os.isfile(file) then
+ -- find the first `xmake.lua` from it's parent directory
+ for _, dir in ipairs(dirs) do
+ local file = path.join(dir, "xmake.lua")
+ if os.isfile(file) then
- -- switch to the project directory
- xmake._PROJECT_DIR = dir
- xmake._PROJECT_FILE = file
- os.cd(dir)
- break
- end
+ -- switch to the project directory
+ xmake._PROJECT_DIR = dir
+ xmake._PROJECT_FILE = file
+ os.cd(dir)
+ break
end
end
end