diff options
| author | ruki <[email protected]> | 2018-10-07 00:05:45 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-10-07 00:05:45 +0800 |
| commit | fbc34dadcfdff7f06a1927fbb593503c5149995b (patch) | |
| tree | c9008e3c62e5f22e5a9e0a261b20d9c6d1b4ce21 | |
| parent | 4307ac5dabce5177d1517b0e043a35b5a7c58512 (diff) | |
add macos and winos version
| -rw-r--r-- | xmake/core/base/macos.lua | 57 | ||||
| -rw-r--r-- | xmake/core/base/winos.lua | 28 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/base/macos.lua | 43 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/base/winos.lua | 12 | ||||
| -rw-r--r-- | xmake/modules/os/winver.lua | 31 | ||||
| -rw-r--r-- | xmake/modules/package/tools/cmake.lua | 17 |
6 files changed, 152 insertions, 36 deletions
diff --git a/xmake/core/base/macos.lua b/xmake/core/base/macos.lua new file mode 100644 index 000000000..d128714d1 --- /dev/null +++ b/xmake/core/base/macos.lua @@ -0,0 +1,57 @@ +--!A cross-platform 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 - 2018, TBOOX Open Source Group. +-- +-- @author ruki +-- @file macos.lua +-- + +-- define module: macos +local macos = macos or {} + +-- load modules +local os = require("base/os") + +-- get system version +function macos.version() + + -- get it from cache first + if macos._VERSION ~= nil then + return macos._VERSION + end + + -- get macver + local macver = nil + local ok, verstr = os.iorun("sw_vers -productVersion") + if ok and verstr then + macver = verstr:match("%d+%.%d+%.%d+") + if macver then + macver = macver:trim() + end + end + + -- save to cache + macos._VERSION = macver or false + + -- done + return macver +end + +-- return module: macos +return macos diff --git a/xmake/core/base/winos.lua b/xmake/core/base/winos.lua index c9ab70be3..c78637b17 100644 --- a/xmake/core/base/winos.lua +++ b/xmake/core/base/winos.lua @@ -25,5 +25,33 @@ -- define module: winos local winos = winos or {} +-- load modules +local os = require("base/os") + +-- get system version +function winos.version() + + -- get it from cache first + if winos._VERSION ~= nil then + return winos._VERSION + end + + -- get winver + local winver = nil + local ok, verstr = os.iorun("cmd /c ver") + if ok and verstr then + winver = verstr:match("%[.-(%d+%.%d+%.%d+)]") + if winver then + winver = winver:trim() + end + end + + -- save to cache + winos._VERSION = winver or false + + -- done + return winver +end + -- return module: winos return winos diff --git a/xmake/core/sandbox/modules/import/core/base/macos.lua b/xmake/core/sandbox/modules/import/core/base/macos.lua new file mode 100644 index 000000000..3acbe9dce --- /dev/null +++ b/xmake/core/sandbox/modules/import/core/base/macos.lua @@ -0,0 +1,43 @@ +--!A cross-platform 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 - 2018, TBOOX Open Source Group. +-- +-- @author ruki +-- @file macos.lua +-- + +-- load modules +local macos = require("base/macos") +local raise = require("sandbox/modules/raise") + +-- define module +local sandbox_core_base_macos = sandbox_core_base_macos or {} + +-- get system version +function sandbox_core_base_macos.version() + local winver = macos.version() + if not winver then + raise("cannot get the version of the current macos!") + end + return winver +end + +-- return module +return sandbox_core_base_macos + diff --git a/xmake/core/sandbox/modules/import/core/base/winos.lua b/xmake/core/sandbox/modules/import/core/base/winos.lua index e581fe177..f1082dc25 100644 --- a/xmake/core/sandbox/modules/import/core/base/winos.lua +++ b/xmake/core/sandbox/modules/import/core/base/winos.lua @@ -23,7 +23,8 @@ -- -- load modules -local winos = require("base/winos") +local winos = require("base/winos") +local raise = require("sandbox/modules/raise") -- define module local sandbox_core_base_winos = sandbox_core_base_winos or {} @@ -32,6 +33,15 @@ local sandbox_core_base_winos = sandbox_core_base_winos or {} sandbox_core_base_winos.registry_query = winos.registry_query sandbox_core_base_winos.logical_drives = winos.logical_drives +-- get windows system version +function sandbox_core_base_winos.version() + local winver = winos.version() + if not winver then + raise("cannot get the version of the current winos!") + end + return winver +end + -- return module return sandbox_core_base_winos diff --git a/xmake/modules/os/winver.lua b/xmake/modules/os/winver.lua index e684ffa02..92b1d6a72 100644 --- a/xmake/modules/os/winver.lua +++ b/xmake/modules/os/winver.lua @@ -119,34 +119,3 @@ function subsystem(name) } return defvals[name] or "10.00" end - --- get windows system version --- --- $ xmake l os.winver --- --- - win10: 10.0.14393 --- - xp: 5.1.2600 --- -function main() - - -- get it from cache first - if _g.winver ~= nil then - return _g.winver - end - - -- get winver - local winver = nil - local verstr = try { function () return os.iorun("cmd /c ver") end } - if verstr then - winver = verstr:match("%[.-(%d+%.%d+%.%d+)]") - if winver then - winver = winver:trim() - end - end - - -- save to cache - _g.winver = winver or false - - -- done - return winver -end diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua index ae1ecee16..a4c94bc33 100644 --- a/xmake/modules/package/tools/cmake.lua +++ b/xmake/modules/package/tools/cmake.lua @@ -29,18 +29,27 @@ import("lib.detect.find_file") -- install package function install(package, configs) os.mkdir("build/install") - os.cd("build") + local oldir = os.cd("build") os.vrun("cmake -a $(arch) -DCMAKE_INSTALL_PREFIX=\"%s\" ..", path.absolute("install")) if is_host("windows") then local slnfile = assert(find_file("*.sln", os.curdir()), "*.sln file not found!") os.vrun("msbuild \"%s\" -nologo -t:Rebuild -p:Configuration=%s -p:Platform=%s", slnfile, package:debug() and "Debug" or "Release", is_arch("x64") and "x64" or "Win32") local projfile = os.isfile("INSTALL.vcxproj") and "INSTALL.vcxproj" or "INSTALL.vcproj" - os.vrun("msbuild \"%s\" /property:configuration=%s", projfile, package:debug() and "Debug" or "Release") + if os.isfile(projfile) then + os.vrun("msbuild \"%s\" /property:configuration=%s", projfile, package:debug() and "Debug" or "Release") + os.cp("install/lib", package:installdir()) + os.cp("install/include", package:installdir()) + else + os.cp("**.lib", package:installdir("lib")) + os.cp("**.dll", package:installdir("lib")) + os.cp("**.exp", package:installdir("lib")) + end else os.vrun("make -j4") os.vrun("make install") + os.cp("install/lib", package:installdir()) + os.cp("install/include", package:installdir()) end - os.cp("install/lib", package:installdir()) - os.cp("install/include", package:installdir()) + os.cd(oldir) end |
