diff options
| author | ruki <[email protected]> | 2017-06-14 23:53:06 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-06-14 23:53:06 +0800 |
| commit | 62fd903400ccd362255ab8314dc7e599587ea521 (patch) | |
| tree | 141ab68b92973774681e2a2c753a712acf5d4f26 | |
| parent | d8f66856927cb9575be311a2102c8a6ad1deea51 (diff) | |
add find clang/gcc
| -rw-r--r-- | xmake/core/sandbox/modules/import/lib/detect/find_programver.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/detect/tool/find_clang.lua | 58 | ||||
| -rw-r--r-- | xmake/modules/detect/tool/find_clangxx.lua | 58 | ||||
| -rw-r--r-- | xmake/modules/detect/tool/find_gcc.lua | 58 | ||||
| -rw-r--r-- | xmake/modules/detect/tool/find_gxx.lua | 58 | ||||
| -rw-r--r-- | xmake/modules/lib/detect/find_tool.lua | 3 |
6 files changed, 236 insertions, 1 deletions
diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_programver.lua b/xmake/core/sandbox/modules/import/lib/detect/find_programver.lua index 50eb72cef..7daec26c8 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_programver.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_programver.lua @@ -93,7 +93,7 @@ function sandbox_lib_detect_find_programver.main(program, command, parse) cacheinfo[program] = utils.ifelse(result, result, false) -- save cache info - detectcache:set("find_program", cacheinfo) + detectcache:set("find_programver", cacheinfo) detectcache:flush() -- ok? diff --git a/xmake/modules/detect/tool/find_clang.lua b/xmake/modules/detect/tool/find_clang.lua new file mode 100644 index 000000000..1de30f6a9 --- /dev/null +++ b/xmake/modules/detect/tool/find_clang.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_clang.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find clang +-- +-- @param opt the argument options, .e.g {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local clang = find_clang() +-- local clang, version = find_clang({program = "xcrun -sdk macosx clang", version = true}) +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- find program + local program = find_program(opt.program or "clang") + + -- 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_clangxx.lua b/xmake/modules/detect/tool/find_clangxx.lua new file mode 100644 index 000000000..c7d9f45d1 --- /dev/null +++ b/xmake/modules/detect/tool/find_clangxx.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_clangxx.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find clang++ +-- +-- @param opt the argument options, .e.g {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local clangxx = find_clangxx() +-- local clangxx, version = find_clangxx({program = "xcrun -sdk macosx clang++", version = true}) +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- find program + local program = find_program(opt.program or "clang++") + + -- 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_gcc.lua b/xmake/modules/detect/tool/find_gcc.lua new file mode 100644 index 000000000..0076d328f --- /dev/null +++ b/xmake/modules/detect/tool/find_gcc.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_gcc.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find gcc +-- +-- @param opt the argument options, .e.g {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local gcc = find_gcc() +-- local gcc, version = find_gcc({program = "xcrun -sdk macosx gcc", version = true}) +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- find program + local program = find_program(opt.program or "gcc") + + -- 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_gxx.lua b/xmake/modules/detect/tool/find_gxx.lua new file mode 100644 index 000000000..8f2a0e08a --- /dev/null +++ b/xmake/modules/detect/tool/find_gxx.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_gxx.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find clang++ +-- +-- @param opt the argument options, .e.g {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local gxx = find_gxx() +-- local gxx, version = find_gxx({program = "xcrun -sdk macosx g++", version = true}) +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- find program + local program = find_program(opt.program or "g++") + + -- 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/lib/detect/find_tool.lua b/xmake/modules/lib/detect/find_tool.lua index f04b06602..74d446bb4 100644 --- a/xmake/modules/lib/detect/find_tool.lua +++ b/xmake/modules/lib/detect/find_tool.lua @@ -29,6 +29,9 @@ import("lib.detect.find_programver") -- find tool from modules function _find_from_modules(name, opt) + -- replace "+" to "x" + name = name:gsub("%+", "x") + -- "detect.tool.find_xxx" exists? if os.isfile(path.join(os.programdir(), "modules", "detect", "tool", "find_" .. name .. ".lua")) then local find_tool = import("detect.tool.find_" .. name) |
