diff options
| author | ruki <[email protected]> | 2020-07-31 00:34:18 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-07-31 00:34:18 +0800 |
| commit | 7cc471182dc9e137c2d5ff8d7731157bf227d819 (patch) | |
| tree | eb0b5178658b3ce6bf74188ce4422bf1ca2337e7 | |
| parent | ec97f73a2a0f954ab15647036360f307f4e7f3e4 (diff) | |
improve ldc2/gdc toolchain
| -rw-r--r-- | xmake/toolchains/dlang/check.lua | 46 | ||||
| -rw-r--r-- | xmake/toolchains/dlang/xmake.lua | 23 |
2 files changed, 63 insertions, 6 deletions
diff --git a/xmake/toolchains/dlang/check.lua b/xmake/toolchains/dlang/check.lua new file mode 100644 index 000000000..cd40b0d15 --- /dev/null +++ b/xmake/toolchains/dlang/check.lua @@ -0,0 +1,46 @@ +--!A cross-toolchain build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-2020, TBOOX Open Source Group. +-- +-- @author ruki +-- @file check.lua +-- + +-- imports +import("core.project.config") +import("detect.sdks.find_cross_toolchain") + +-- check the cross toolchain, for ldc2/gdc toolchain +function main(toolchain) + + -- is cross? + local sdkdir = config.get("sdk") + local bindir = config.get("bin") + local cross = config.get("cross") + if not sdkdir and not bindir and not cross then + return + end + + -- find cross toolchain + local cross_toolchain = find_cross_toolchain(sdkdir, {bindir = bindir, cross = cross}) + if cross_toolchain then + config.set("cross", cross_toolchain.cross, {readonly = true, force = true}) + config.set("bin", cross_toolchain.bindir, {readonly = true, force = true}) + config.set("sdkdir", cross_toolchain.sdkdir, {readonly = true, force = true}) + else + raise("cross toolchain not found!") + end + return cross_toolchain +end diff --git a/xmake/toolchains/dlang/xmake.lua b/xmake/toolchains/dlang/xmake.lua index 23e8871d0..bfe9c20b8 100644 --- a/xmake/toolchains/dlang/xmake.lua +++ b/xmake/toolchains/dlang/xmake.lua @@ -24,15 +24,26 @@ toolchain("dlang") -- set homepage set_homepage("https://dlang.org/") set_description("D Programming Language Compiler") - - -- set toolset - set_toolset("dc", "$(env DC)", "dmd", "ldc2", "gdc") - set_toolset("dcld", "$(env DC)", "dmd", "ldc2", "gdc") - set_toolset("dcsh", "$(env DC)", "dmd", "ldc2", "gdc") - set_toolset("dcar", "$(env DC)", "dmd", "ldc2", "gcc-ar") + + -- check toolchain + on_check("check") -- on load on_load(function (toolchain) + + -- imports + import("core.project.config") + + -- get cross prefix + local cross = config.get("cross") or "" + + -- set toolset + toolchain:set("toolset", "dc", "$(env DC)", "dmd", "ldc2", cross .. "gdc") + toolchain:set("toolset", "dcld", "$(env DC)", "dmd", "ldc2", cross .. "gdc") + toolchain:set("toolset", "dcsh", "$(env DC)", "dmd", "ldc2", cross .. "gdc") + toolchain:set("toolset", "dcar", "$(env DC)", "dmd", "ldc2", cross .. "gcc-ar") + + -- init flags local march = toolchain:is_arch("x86_64", "x64") and "-m64" or "-m32" toolchain:add("dcflags", march) toolchain:add("dcshflags", march) |
