diff options
| author | ruki <[email protected]> | 2017-09-30 10:34:42 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-09-30 10:34:42 +0800 |
| commit | b77dcc4cea91854766a718b5d03d49a25de6a180 (patch) | |
| tree | 77fb384d36e12eb4ad5a81e9851e67e11e82ed18 | |
| parent | c1881132bf73e9914a244896506e9bc3954de301 (diff) | |
inherit some configs
| -rw-r--r-- | xmake/actions/require/action/build.lua | 26 | ||||
| -rw-r--r-- | xmake/core/tool/builder.lua | 23 | ||||
| -rw-r--r-- | xmake/core/tool/compiler.lua | 20 | ||||
| -rw-r--r-- | xmake/core/tool/linker.lua | 20 |
4 files changed, 52 insertions, 37 deletions
diff --git a/xmake/actions/require/action/build.lua b/xmake/actions/require/action/build.lua index 78501b7dc..d49f6274f 100644 --- a/xmake/actions/require/action/build.lua +++ b/xmake/actions/require/action/build.lua @@ -31,8 +31,32 @@ import("filter") -- build for xmake file function _build_for_xmakefile(package, buildfile) + -- init argv + local plat = config.plat() + local argv = {"f", "-c", "-p", plat, "-a", config.arch(), "-m", config.mode()} + + -- init config keys + local keys = + { + android = {"ndk", "ndk_sdkver"}, + linux = {"sdk", "cross", "toolchains"}, + cross = {"sdk", "cross", "toolchains"}, + mingw = {"sdk", "cross", "toolchains"}, + macosx = {"xcode_dir", "xcode_sdkver"}, + iphoneos = {"xcode_dir", "xcode_sdkver"}, + windows = {"vs"} + } + + -- inherit some configs + for _, key in ipairs(keys[plat]) do + local val = config.get(key) + if val ~= nil then + table.insert(argv, "--" .. key .. "=" .. tostring(val)) + end + end + -- configure it first - os.vrun("xmake f -p $(plat) -a $(arch) -m $(mode) -c") + os.vrunv("xmake", argv) -- build it os.vrun("xmake") diff --git a/xmake/core/tool/builder.lua b/xmake/core/tool/builder.lua index 4270a16f0..01e779fda 100644 --- a/xmake/core/tool/builder.lua +++ b/xmake/core/tool/builder.lua @@ -345,6 +345,29 @@ function builder:_addflags_from_language(flags, target, getters) end end +-- preprocess flags +function builder:_preprocess_flags(flags) + + -- remove repeat + flags = table.unique(flags) + + -- split flag group, .e.g "-I /xxx" => {"-I", "/xxx"} + local results = {} + for _, flag in ipairs(flags) do + flag = flag:trim() + if #flag > 0 then + if flag:find(" ", 1, true) then + table.join2(results, os.argv(flag)) + else + table.insert(results, flag) + end + end + end + + -- get it + return results +end + -- get tool name function builder:name() return self:_tool():name() diff --git a/xmake/core/tool/compiler.lua b/xmake/core/tool/compiler.lua index a6afc1a22..c3b8782a7 100644 --- a/xmake/core/tool/compiler.lua +++ b/xmake/core/tool/compiler.lua @@ -284,24 +284,8 @@ function compiler:compflags(opt) -- add flags from the compiler self:_addflags_from_compiler(flags, targetkind) - -- remove repeat - flags = table.unique(flags) - - -- split flag group, .e.g "-I /xxx" => {"-I", "/xxx"} - local results = {} - for _, flag in ipairs(flags) do - flag = flag:trim() - if #flag > 0 then - if flag:find(" ", 1, true) then - table.join2(results, os.argv(flag)) - else - table.insert(results, flag) - end - end - end - - -- get it - return results + -- preprocess flags + return self:_preprocess_flags(flags) end -- return module diff --git a/xmake/core/tool/linker.lua b/xmake/core/tool/linker.lua index 1ce6d80e4..496efc2c7 100644 --- a/xmake/core/tool/linker.lua +++ b/xmake/core/tool/linker.lua @@ -237,24 +237,8 @@ function linker:linkflags(opt) -- add flags from the linker self:_addflags_from_linker(flags) - -- remove repeat - flags = table.unique(flags) - - -- split flag group, .e.g "-I /xxx" => {"-I", "/xxx"} - local results = {} - for _, flag in ipairs(flags) do - flag = flag:trim() - if #flag > 0 then - if flag:find(" ", 1, true) then - table.join2(results, os.argv(flag)) - else - table.insert(results, flag) - end - end - end - - -- get it - return results + -- preprocess flags + return self:_preprocess_flags(flags) end -- return module |
