diff options
| author | ruki <[email protected]> | 2020-09-03 23:29:54 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-09-03 23:29:54 +0800 |
| commit | 304cd31298a66501aecec161c31f5e94aa5ac142 (patch) | |
| tree | 450b0d979f3690b1b1e6d61c63af4980c97b6023 /xmake/modules/detect | |
| parent | 30e13046db1c1e72c78731d184eb491f2e0f4e3b (diff) | |
add emcc/emscripten toolchain
Diffstat (limited to 'xmake/modules/detect')
| -rw-r--r-- | xmake/modules/detect/tools/emcc/has_flags.lua | 23 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/emxx/has_flags.lua | 23 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/find_emar.lua | 67 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/find_emcc.lua | 52 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/find_emxx.lua | 52 |
5 files changed, 217 insertions, 0 deletions
diff --git a/xmake/modules/detect/tools/emcc/has_flags.lua b/xmake/modules/detect/tools/emcc/has_flags.lua new file mode 100644 index 000000000..12c042355 --- /dev/null +++ b/xmake/modules/detect/tools/emcc/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/emxx/has_flags.lua b/xmake/modules/detect/tools/emxx/has_flags.lua new file mode 100644 index 000000000..7abf3872f --- /dev/null +++ b/xmake/modules/detect/tools/emxx/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.emcc.has_flags") + diff --git a/xmake/modules/detect/tools/find_emar.lua b/xmake/modules/detect/tools/find_emar.lua new file mode 100644 index 000000000..ef4ce81b5 --- /dev/null +++ b/xmake/modules/detect/tools/find_emar.lua @@ -0,0 +1,67 @@ +--!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_emar.lua +-- + +-- imports +import("core.tool.compiler") +import("lib.detect.find_program") + +-- check +function _check(program) + + -- make an stub source file + local libraryfile = os.tmpfile() .. ".a" + local objectfile = os.tmpfile() .. ".o" + local sourcefile = os.tmpfile() .. ".c" + io.writefile(sourcefile, "int test(void)\n{return 0;}") + + -- compile it + compiler.compile(sourcefile, objectfile) + + -- archive it + os.runv(program, {"-cr", libraryfile, objectfile}) + + -- remove files + os.rm(objectfile) + os.rm(sourcefile) + os.rm(libraryfile) +end + +-- find ar +-- +-- @param opt the argument options, e.g. {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local ar = find_emar() +-- local ar, version = find_emar({program = "xcrun -sdk macosx g++", version = true}) +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + opt.check = opt.check or _check + + -- find program + return find_program(opt.program or "emar", opt) +end diff --git a/xmake/modules/detect/tools/find_emcc.lua b/xmake/modules/detect/tools/find_emcc.lua new file mode 100644 index 000000000..2eda7543c --- /dev/null +++ b/xmake/modules/detect/tools/find_emcc.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_emcc.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find emcc +-- +-- @param opt the argument options, e.g. {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local emcc = find_emcc() +-- local emcc, version = find_emcc({version = true}) +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- find program + local program = find_program(opt.program or "emcc", opt) + + -- find program version + local version = nil + if program and opt and opt.version then + version = find_programver(program, opt) + end + return program, version +end diff --git a/xmake/modules/detect/tools/find_emxx.lua b/xmake/modules/detect/tools/find_emxx.lua new file mode 100644 index 000000000..6adaea5c9 --- /dev/null +++ b/xmake/modules/detect/tools/find_emxx.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_emxx.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find emxx +-- +-- @param opt the argument options, e.g. {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local emxx = find_emxx() +-- local emxx, version = find_emxx({version = true}) +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- find program + local program = find_program(opt.program or "em++", opt) + + -- find program version + local version = nil + if program and opt and opt.version then + version = find_programver(program, opt) + end + return program, version +end |
