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 /xmake/core/base/macos.lua | |
| parent | 4307ac5dabce5177d1517b0e043a35b5a7c58512 (diff) | |
add macos and winos version
Diffstat (limited to 'xmake/core/base/macos.lua')
| -rw-r--r-- | xmake/core/base/macos.lua | 57 |
1 files changed, 57 insertions, 0 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 |
