diff options
Diffstat (limited to 'xmake/toolchains/gcc/xmake.lua')
| -rw-r--r-- | xmake/toolchains/gcc/xmake.lua | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/xmake/toolchains/gcc/xmake.lua b/xmake/toolchains/gcc/xmake.lua new file mode 100644 index 000000000..17270aedb --- /dev/null +++ b/xmake/toolchains/gcc/xmake.lua @@ -0,0 +1,72 @@ +--!A cross-platform 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 xmake.lua +-- + +-- define toolchain +toolchain("gcc") + + -- mark as standalone toolchain + set_kind("standalone") + + -- set toolsets + set_toolsets("cc", "gcc") + set_toolsets("cxx", "gcc", "g++") + set_toolsets("ld", "g++", "gcc") + set_toolsets("sh", "g++", "gcc") + set_toolsets("ar", "ar") + set_toolsets("ex", "ar") + set_toolsets("strip", "strip") + set_toolsets("mm", "gcc") + set_toolsets("mxx", "gcc", "g++") + set_toolsets("as", "gcc") + + -- check toolchain + on_check(function (toolchain) + return import("lib.detect.find_tool")("gcc") + end) + + -- on load + on_load(function (toolchain) + + -- get march + local march = is_arch("x86_64", "x64") and "-m64" or "-m32" + + -- init flags for c/c++ + toolchain:add("cxflags", march) + toolchain:add("ldflags", march) + toolchain:add("shflags", march) + if not is_plat("windows") and os.isdir("/usr") then + for _, includedir in ipairs({"/usr/local/include", "/usr/include"}) do + if os.isdir(includedir) then + toolchain:add("includedirs", includedir) + end + end + for _, linkdir in ipairs({"/usr/local/lib", "/usr/lib"}) do + if os.isdir(linkdir) then + toolchain:add("linkdirs", linkdir) + end + end + end + + -- init flags for objc/c++ (with ldflags and shflags) + toolchain:add("mxflags", march) + + -- init flags for asm + toolchain:add("asflags", march) + end) |
