diff options
| author | ruki <[email protected]> | 2017-03-01 17:35:30 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-03-01 17:35:30 +0800 |
| commit | 2db00e130e92302f04eaba6e4c2936fe0879b5fc (patch) | |
| tree | 5426c16d495416d66a11c9eb7f95195a9510d872 | |
| parent | 1ab4daf4fbdd148dc5b3ee879d36e9829e4753d7 (diff) | |
fix buildir bug
| -rwxr-xr-x | tests/console_c/xmake.lua | 9 | ||||
| -rw-r--r-- | xmake/core/project/config.lua | 20 | ||||
| -rw-r--r-- | xmake/core/project/project.lua | 5 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/project/config.lua | 2 |
4 files changed, 26 insertions, 10 deletions
diff --git a/tests/console_c/xmake.lua b/tests/console_c/xmake.lua index 4156f32fc..5bb1a2510 100755 --- a/tests/console_c/xmake.lua +++ b/tests/console_c/xmake.lua @@ -30,12 +30,3 @@ target("console_c") -- add files add_files("src/*.c") - after_build(function(target) - import("core.project.config") - os.cd("src") - print(config.buildir()) - print(vformat("$(scriptdir)")) - print(path.absolute(vformat("$(buildir)"))) - os.cp("main.c", "$(buildir)/aaa") - end) - diff --git a/xmake/core/project/config.lua b/xmake/core/project/config.lua index 8765b535d..2f3ce1a96 100644 --- a/xmake/core/project/config.lua +++ b/xmake/core/project/config.lua @@ -116,6 +116,26 @@ function config.options() return configs end +-- get the buildir +function config.buildir() + + -- get it + local buildir = config.get("buildir") + if buildir then + + -- get the absolute path first + if not path.is_absolute(buildir) then + buildir = path.absolute(buildir, xmake._PROJECT_DIR) + end + + -- adjust path for the current directory + buildir = path.relative(buildir, os.curdir()) + end + + -- ok? + return buildir +end + -- get the configure directory function config.directory() diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua index 40bee0a5e..b11fc9154 100644 --- a/xmake/core/project/project.lua +++ b/xmake/core/project/project.lua @@ -277,6 +277,11 @@ function project._interpreter() -- check assert(variable) + -- hack buildir first + if variable == "buildir" then + return config.buildir() + end + -- attempt to get it directly from the configure local result = config.get(variable) if not result or type(result) ~= "string" then diff --git a/xmake/core/sandbox/modules/import/core/project/config.lua b/xmake/core/sandbox/modules/import/core/project/config.lua index caf8be7e1..ba027f80b 100644 --- a/xmake/core/sandbox/modules/import/core/project/config.lua +++ b/xmake/core/sandbox/modules/import/core/project/config.lua @@ -34,7 +34,7 @@ local raise = require("sandbox/modules/raise") function sandbox_core_project_config.buildir() -- get it - return config.get("buildir") + return config.buildir() end -- get the current platform |
