diff options
| author | ruki <[email protected]> | 2017-06-15 09:12:10 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-06-15 09:12:10 +0800 |
| commit | a9ed35ab83f46ba4117292a6b94a7264351f4c22 (patch) | |
| tree | 95b97fd49668ba0cf688669e593d050fcda8af9c | |
| parent | b4874e068e076cd2b643273baf3bc6012c8591b9 (diff) | |
add find_[some compilers]
| -rw-r--r-- | xmake/modules/detect/tool/find_ar.lua | 70 | ||||
| -rw-r--r-- | xmake/modules/detect/tool/find_ccache.lua | 5 | ||||
| -rw-r--r-- | xmake/modules/detect/tool/find_dmd.lua | 57 | ||||
| -rw-r--r-- | xmake/modules/detect/tool/find_go.lua | 57 | ||||
| -rw-r--r-- | xmake/modules/detect/tool/find_gxx.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/detect/tool/find_ldc2.lua | 57 | ||||
| -rw-r--r-- | xmake/modules/detect/tool/find_lipo.lua | 5 | ||||
| -rw-r--r-- | xmake/modules/detect/tool/find_rustc.lua | 57 | ||||
| -rw-r--r-- | xmake/modules/detect/tool/find_swiftc.lua | 58 |
9 files changed, 365 insertions, 3 deletions
diff --git a/xmake/modules/detect/tool/find_ar.lua b/xmake/modules/detect/tool/find_ar.lua new file mode 100644 index 000000000..2cb78ddff --- /dev/null +++ b/xmake/modules/detect/tool/find_ar.lua @@ -0,0 +1,70 @@ +--!The Make-like Build Utility based on Lua +-- +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you 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 - 2017, TBOOX Open Source Group. +-- +-- @author ruki +-- @file find_ar.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_ar() +-- local ar, version = find_ar({program = "xcrun -sdk macosx g++", version = true}) +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- find program + return find_program(opt.program or "ar", {}, _check) +end diff --git a/xmake/modules/detect/tool/find_ccache.lua b/xmake/modules/detect/tool/find_ccache.lua index faf45da53..c32bbc4b6 100644 --- a/xmake/modules/detect/tool/find_ccache.lua +++ b/xmake/modules/detect/tool/find_ccache.lua @@ -40,9 +40,12 @@ import("lib.detect.find_programver") -- @endcode -- function main(opt) + + -- init options + opt = opt or {} -- find program - local program = find_program("ccache") + local program = find_program(opt.program or "ccache") -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_dmd.lua b/xmake/modules/detect/tool/find_dmd.lua new file mode 100644 index 000000000..fe47fc618 --- /dev/null +++ b/xmake/modules/detect/tool/find_dmd.lua @@ -0,0 +1,57 @@ +--!The Make-like Build Utility based on Lua +-- +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you 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 - 2017, TBOOX Open Source Group. +-- +-- @author ruki +-- @file find_dmd.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find dmd +-- +-- @param opt the argument options, .e.g {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local dmd = find_dmd() +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- find program + local program = find_program(opt.program or "dmd") + + -- find program version + local version = nil + if program and opt and opt.version then + version = find_programver(program, "--version", function (output) return output:match("v(%d+%.?%d*%.?%d*.-)%s") end) + end + + -- ok? + return program, version +end diff --git a/xmake/modules/detect/tool/find_go.lua b/xmake/modules/detect/tool/find_go.lua new file mode 100644 index 000000000..9932f73ba --- /dev/null +++ b/xmake/modules/detect/tool/find_go.lua @@ -0,0 +1,57 @@ +--!The Make-like Build Utility based on Lua +-- +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you 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 - 2017, TBOOX Open Source Group. +-- +-- @author ruki +-- @file find_go.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find go +-- +-- @param opt the argument options, .e.g {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local go = find_go() +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- find program + local program = find_program(opt.program or "go", {}, "version") + + -- find program version + local version = nil + if program and opt and opt.version then + version = find_programver(program, "version") + end + + -- ok? + return program, version +end diff --git a/xmake/modules/detect/tool/find_gxx.lua b/xmake/modules/detect/tool/find_gxx.lua index 8f2a0e08a..a58cfe75f 100644 --- a/xmake/modules/detect/tool/find_gxx.lua +++ b/xmake/modules/detect/tool/find_gxx.lua @@ -26,7 +26,7 @@ import("lib.detect.find_program") import("lib.detect.find_programver") --- find clang++ +-- find g++ -- -- @param opt the argument options, .e.g {version = true} -- diff --git a/xmake/modules/detect/tool/find_ldc2.lua b/xmake/modules/detect/tool/find_ldc2.lua new file mode 100644 index 000000000..77df85852 --- /dev/null +++ b/xmake/modules/detect/tool/find_ldc2.lua @@ -0,0 +1,57 @@ +--!The Make-like Build Utility based on Lua +-- +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you 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 - 2017, TBOOX Open Source Group. +-- +-- @author ruki +-- @file find_ldc2.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find ldc2 +-- +-- @param opt the argument options, .e.g {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local ldc2 = find_ldc2() +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- find program + local program = find_program(opt.program or "ldc2") + + -- find program version + local version = nil + if program and opt and opt.version then + version = find_programver(program, "--version", function (output) return output:match("%((%d+%.?%d*%.?%d*.-)%)") end) + end + + -- ok? + return program, version +end diff --git a/xmake/modules/detect/tool/find_lipo.lua b/xmake/modules/detect/tool/find_lipo.lua index 621bb80d5..85d1fba76 100644 --- a/xmake/modules/detect/tool/find_lipo.lua +++ b/xmake/modules/detect/tool/find_lipo.lua @@ -40,6 +40,9 @@ import("lib.detect.find_programver") -- function main(opt) + -- init options + opt = opt or {} + -- find program - return find_program("lipo", {}, function (program) os.run("%s -info %s", program, os.programfile()) end) + return find_program(opt.program or "lipo", {}, function (program) os.run("%s -info %s", program, os.programfile()) end) end diff --git a/xmake/modules/detect/tool/find_rustc.lua b/xmake/modules/detect/tool/find_rustc.lua new file mode 100644 index 000000000..9f3c992ef --- /dev/null +++ b/xmake/modules/detect/tool/find_rustc.lua @@ -0,0 +1,57 @@ +--!The Make-like Build Utility based on Lua +-- +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you 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 - 2017, TBOOX Open Source Group. +-- +-- @author ruki +-- @file find_gorustc.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find rustc +-- +-- @param opt the argument options, .e.g {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local rustc = find_rustc() +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- find program + local program = find_program(opt.program or "rustc") + + -- find program version + local version = nil + if program and opt and opt.version then + version = find_programver(program) + end + + -- ok? + return program, version +end diff --git a/xmake/modules/detect/tool/find_swiftc.lua b/xmake/modules/detect/tool/find_swiftc.lua new file mode 100644 index 000000000..cc9bdf4d6 --- /dev/null +++ b/xmake/modules/detect/tool/find_swiftc.lua @@ -0,0 +1,58 @@ +--!The Make-like Build Utility based on Lua +-- +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you 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 - 2017, TBOOX Open Source Group. +-- +-- @author ruki +-- @file find_swiftc.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find swiftc +-- +-- @param opt the argument options, .e.g {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local swiftc = find_swiftc() +-- local swiftc, version = find_swiftc({program = "xcrun -sdk macosx swiftc", version = true}) +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- find program + local program = find_program(opt.program or "swiftc") + + -- find program version + local version = nil + if program and opt and opt.version then + version = find_programver(program) + end + + -- ok? + return program, version +end |
