diff options
| author | ruki <[email protected]> | 2020-06-22 23:06:21 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-06-22 12:38:09 +0800 |
| commit | 4e18de04e01386bf7304bbf9d08ec826a1fa6285 (patch) | |
| tree | db7f6563098b8c9fd31bdd75aa1bc0224a7d7c78 /xmake/modules | |
| parent | f78cbc917b997ffaee1f4663472064d5d9515760 (diff) | |
add nmake and msbuild tools
Diffstat (limited to 'xmake/modules')
| -rw-r--r-- | xmake/modules/detect/tools/find_nmake.lua | 55 | ||||
| -rw-r--r-- | xmake/modules/package/tools/msbuild.lua | 49 | ||||
| -rw-r--r-- | xmake/modules/package/tools/nmake.lua | 78 |
3 files changed, 182 insertions, 0 deletions
diff --git a/xmake/modules/detect/tools/find_nmake.lua b/xmake/modules/detect/tools/find_nmake.lua new file mode 100644 index 000000000..dcb65f63c --- /dev/null +++ b/xmake/modules/detect/tools/find_nmake.lua @@ -0,0 +1,55 @@ +--!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_nmake.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find nmake +-- +-- @param opt the argument options, e.g. {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local nmake = find_nmake() +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + opt.check = "/?" + + -- find program + local program = find_program(opt.program or "nmake.exe", opt) + + -- find program version + local version = nil + if program and opt and opt.version then + version = find_programver(program, opt) + end + + -- ok? + return program, version +end + diff --git a/xmake/modules/package/tools/msbuild.lua b/xmake/modules/package/tools/msbuild.lua new file mode 100644 index 000000000..98263d5bf --- /dev/null +++ b/xmake/modules/package/tools/msbuild.lua @@ -0,0 +1,49 @@ +--!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 msbuild.lua +-- + +-- imports +import("core.base.option") +import("core.tool.toolchain") +import("lib.detect.find_tool") + +-- build package +function build(package, configs, opt) + + -- init options + opt = opt or {} + + -- pass configurations + local argv = {} + for name, value in pairs(configs) do + value = tostring(value):trim() + if value ~= "" then + if type(name) == "number" then + table.insert(argv, value) + else + table.insert(argv, name .. "=" .. value) + end + end + end + + -- do build + local runenvs = toolchain.load("msvc"):runenvs() + local msbuild = find_tool("msbuild", {envs = runenvs}) + os.vrunv(msbuild.program, argv, {envs = runenvs}) +end diff --git a/xmake/modules/package/tools/nmake.lua b/xmake/modules/package/tools/nmake.lua new file mode 100644 index 000000000..d948df039 --- /dev/null +++ b/xmake/modules/package/tools/nmake.lua @@ -0,0 +1,78 @@ +--!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 nmake.lua +-- + +-- imports +import("core.base.option") +import("core.project.config") +import("core.tool.toolchain") +import("lib.detect.find_tool") + +-- build package +function build(package, configs, opt) + + -- init options + opt = opt or {} + + -- pass configurations + local argv = {} + if option.get("verbose") then + table.insert(argv, "VERBOSE=1") + end + for name, value in pairs(configs) do + value = tostring(value):trim() + if value ~= "" then + if type(name) == "number" then + table.insert(argv, value) + else + table.insert(argv, name .. "=" .. value) + end + end + end + + -- do build + local runenvs = toolchain.load("msvc"):runenvs() + local nmake = find_tool("nmake", {envs = runenvs}) + os.vrunv(nmake.program, argv, {envs = runenvs}) +end + +-- install package +function install(package, configs) + + -- pass configurations + local argv = {"install"} + if option.get("verbose") then + table.insert(argv, "VERBOSE=1") + end + for name, value in pairs(configs) do + value = tostring(value):trim() + if value ~= "" then + if type(name) == "number" then + table.insert(argv, value) + else + table.insert(argv, name .. "=" .. value) + end + end + end + + -- do install + local runenvs = toolchain.load("msvc"):runenvs() + local nmake = find_tool("nmake", {envs = runenvs}) + os.vrunv(nmake.program, argv, {envs = runenvs}) +end |
