From 1e907d9090e6e5cbd4013d997f2d14d37e313d2f Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 15 Jun 2017 10:16:11 +0800 Subject: add find_gccgo and find_gdc --- xmake/modules/detect/tool/find_gccgo.lua | 57 ++++++++++++++++++++++++++++++++ xmake/modules/detect/tool/find_gdc.lua | 57 ++++++++++++++++++++++++++++++++ xmake/modules/detect/tool/find_rustc.lua | 2 +- 3 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 xmake/modules/detect/tool/find_gccgo.lua create mode 100644 xmake/modules/detect/tool/find_gdc.lua diff --git a/xmake/modules/detect/tool/find_gccgo.lua b/xmake/modules/detect/tool/find_gccgo.lua new file mode 100644 index 000000000..eaff5e3ea --- /dev/null +++ b/xmake/modules/detect/tool/find_gccgo.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_gogccgo.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find gccgo +-- +-- @param opt the argument options, .e.g {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local gccgo = find_gccgo() +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- find program + local program = find_program(opt.program or "gccgo") + + -- find program version + local version = nil + if program and opt and opt.version then + version = find_programver(program, "--version", function (output) return output:match("%s(%d+%.?%d+%.?%d+)%s") end) + end + + -- ok? + return program, version +end diff --git a/xmake/modules/detect/tool/find_gdc.lua b/xmake/modules/detect/tool/find_gdc.lua new file mode 100644 index 000000000..a094cf7ee --- /dev/null +++ b/xmake/modules/detect/tool/find_gdc.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_gdc.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find gdc +-- +-- @param opt the argument options, .e.g {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local gdc = find_gdc() +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- find program + local program = find_program(opt.program or "gdc") + + -- find program version + local version = nil + if program and opt and opt.version then + version = find_programver(program, "--version", function (output) return output:match("%s(%d+%.?%d+%.?%d+)%s") end) + end + + -- ok? + return program, version +end diff --git a/xmake/modules/detect/tool/find_rustc.lua b/xmake/modules/detect/tool/find_rustc.lua index 9f3c992ef..938c6c180 100644 --- a/xmake/modules/detect/tool/find_rustc.lua +++ b/xmake/modules/detect/tool/find_rustc.lua @@ -19,7 +19,7 @@ -- Copyright (C) 2015 - 2017, TBOOX Open Source Group. -- -- @author ruki --- @file find_gorustc.lua +-- @file find_rustc.lua -- -- imports -- cgit v1.3.1