From d9c46764bb2e906e7cf8e98ddd70969472ed1c19 Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 5 Oct 2020 23:16:36 +0800 Subject: add initial icc files --- xmake/modules/core/tools/icc.lua | 31 +++++++++++ xmake/modules/core/tools/icl.lua | 31 +++++++++++ xmake/modules/core/tools/icpc.lua | 28 ++++++++++ xmake/modules/detect/tools/find_icc.lua | 52 ++++++++++++++++++ xmake/modules/detect/tools/find_icl.lua | 52 ++++++++++++++++++ xmake/modules/detect/tools/find_icpc.lua | 52 ++++++++++++++++++ xmake/modules/detect/tools/icc/has_flags.lua | 23 ++++++++ xmake/modules/detect/tools/icl/has_flags.lua | 23 ++++++++ xmake/modules/detect/tools/icpc/has_flags.lua | 23 ++++++++ xmake/toolchains/icc/xmake.lua | 77 +++++++++++++++++++++++++++ 10 files changed, 392 insertions(+) create mode 100644 xmake/modules/core/tools/icc.lua create mode 100644 xmake/modules/core/tools/icl.lua create mode 100644 xmake/modules/core/tools/icpc.lua create mode 100644 xmake/modules/detect/tools/find_icc.lua create mode 100644 xmake/modules/detect/tools/find_icl.lua create mode 100644 xmake/modules/detect/tools/find_icpc.lua create mode 100644 xmake/modules/detect/tools/icc/has_flags.lua create mode 100644 xmake/modules/detect/tools/icl/has_flags.lua create mode 100644 xmake/modules/detect/tools/icpc/has_flags.lua create mode 100644 xmake/toolchains/icc/xmake.lua diff --git a/xmake/modules/core/tools/icc.lua b/xmake/modules/core/tools/icc.lua new file mode 100644 index 000000000..9a0eabac1 --- /dev/null +++ b/xmake/modules/core/tools/icc.lua @@ -0,0 +1,31 @@ +--!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 icc.lua +-- + +-- inherit gcc +inherit("gcc") + +-- init it +function init(self) + _super.init(self) +end + +-- TODO +-- inherit gcc.lua and override some interfaces in gcc.lua +-- ... diff --git a/xmake/modules/core/tools/icl.lua b/xmake/modules/core/tools/icl.lua new file mode 100644 index 000000000..bd2bd5e14 --- /dev/null +++ b/xmake/modules/core/tools/icl.lua @@ -0,0 +1,31 @@ +--!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 icl.lua +-- + +-- inherit cl +inherit("cl") + +-- init it +function init(self) + +end + +-- TODO +-- inherit cl.lua and override some interfaces in cl.lua +-- ... diff --git a/xmake/modules/core/tools/icpc.lua b/xmake/modules/core/tools/icpc.lua new file mode 100644 index 000000000..6639bfcfe --- /dev/null +++ b/xmake/modules/core/tools/icpc.lua @@ -0,0 +1,28 @@ +--!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 icpc.lua +-- + +-- inherit gcc +inherit("gcc") + +-- init it +function init(self) + _super.init(self) +end + diff --git a/xmake/modules/detect/tools/find_icc.lua b/xmake/modules/detect/tools/find_icc.lua new file mode 100644 index 000000000..789a16a9e --- /dev/null +++ b/xmake/modules/detect/tools/find_icc.lua @@ -0,0 +1,52 @@ +--!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 find_icc.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find icc +-- +-- @param opt the argument options, e.g. {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local icc = find_icc() +-- local icc, version, hintname = find_icc({program = "icc", version = true}) +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- find program + local program = find_program(opt.program or "icc", opt) + + -- find program version + local version = nil + if program and opt.version then + version = find_programver(program, opt) + end + return program, version +end diff --git a/xmake/modules/detect/tools/find_icl.lua b/xmake/modules/detect/tools/find_icl.lua new file mode 100644 index 000000000..f61f0ce76 --- /dev/null +++ b/xmake/modules/detect/tools/find_icl.lua @@ -0,0 +1,52 @@ +--!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 find_icl.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find icl +-- +-- @param opt the argument options, e.g. {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local icl = find_icl() +-- local icl, version, hintname = find_icl({program = "icl", version = true}) +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- find program + local program = find_program(opt.program or "icl", opt) + + -- find program version + local version = nil + if program and opt.version then + version = find_programver(program, opt) + end + return program, version +end diff --git a/xmake/modules/detect/tools/find_icpc.lua b/xmake/modules/detect/tools/find_icpc.lua new file mode 100644 index 000000000..6c806cad6 --- /dev/null +++ b/xmake/modules/detect/tools/find_icpc.lua @@ -0,0 +1,52 @@ +--!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 find_icpc.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find icpc +-- +-- @param opt the argument options, e.g. {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local icpc = find_icpc() +-- local icpc, version, hintname = find_icpc({program = "icpc", version = true}) +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- find program + local program = find_program(opt.program or "icpc", opt) + + -- find program version + local version = nil + if program and opt.version then + version = find_programver(program, opt) + end + return program, version +end diff --git a/xmake/modules/detect/tools/icc/has_flags.lua b/xmake/modules/detect/tools/icc/has_flags.lua new file mode 100644 index 000000000..6ac2ce551 --- /dev/null +++ b/xmake/modules/detect/tools/icc/has_flags.lua @@ -0,0 +1,23 @@ +--!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 has_flags.lua +-- + +-- imports +inherit("detect.tools.gcc.has_flags") + diff --git a/xmake/modules/detect/tools/icl/has_flags.lua b/xmake/modules/detect/tools/icl/has_flags.lua new file mode 100644 index 000000000..81573039e --- /dev/null +++ b/xmake/modules/detect/tools/icl/has_flags.lua @@ -0,0 +1,23 @@ +--!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 has_flags.lua +-- + +-- imports +inherit("detect.tools.cl.has_flags") + diff --git a/xmake/modules/detect/tools/icpc/has_flags.lua b/xmake/modules/detect/tools/icpc/has_flags.lua new file mode 100644 index 000000000..50d4f59d9 --- /dev/null +++ b/xmake/modules/detect/tools/icpc/has_flags.lua @@ -0,0 +1,23 @@ +--!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 has_flags.lua +-- + +-- imports +inherit("detect.tools.gxx.has_flags") + diff --git a/xmake/toolchains/icc/xmake.lua b/xmake/toolchains/icc/xmake.lua new file mode 100644 index 000000000..2b501c846 --- /dev/null +++ b/xmake/toolchains/icc/xmake.lua @@ -0,0 +1,77 @@ +--!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("icc") + + -- set homepage + set_homepage("https://software.intel.com/content/www/us/en/develop/tools/compilers/c-compilers.html") + set_description("Intel C/C++ Compiler") + + -- mark as standalone toolchain + set_kind("standalone") + + -- check toolchain + on_check(function (toolchain) + return import("lib.detect.find_tool")(toolchain:is_plat("windows") and "icl" or "icc") + end) + + -- on load + on_load(function (toolchain) + + -- set toolset + toolchain:set("toolset", "cc", "icc") + toolchain:set("toolset", "cxx", "icc", "icpc") + toolchain:set("toolset", "ld", "g++", "icc") -- TODO g++/clang++ as linker, i++? icpc? .. + toolchain:set("toolset", "sh", "g++", "icc") + toolchain:set("toolset", "ar", "ar") + toolchain:set("toolset", "ex", "ar") + toolchain:set("toolset", "strip", "strip") + toolchain:set("toolset", "as", "icc") + + -- add march flags + local march + if toolchain:is_arch("x86_64", "x64") then + march = "-m64" + elseif toolchain:is_arch("i386", "x86") then + march = "-m32" + end + if march then + toolchain:add("cxflags", march) + toolchain:add("mxflags", march) + toolchain:add("asflags", march) + toolchain:add("ldflags", march) + toolchain:add("shflags", march) + end + + -- add includedirs and linkdirs + if not toolchain: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 + end) -- cgit v1.3.1