diff options
| author | ruki <[email protected]> | 2017-09-26 23:15:11 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-09-26 13:31:08 +0800 |
| commit | 516eef07b377f938772a8047e122e8d0287e55ad (patch) | |
| tree | 365a2b4e36a4931ce82116e144810a9957a535c1 /xmake/core/base | |
| parent | a158b677a28eab3f06c7798b8af9b1ef6523221c (diff) | |
add user-agent
Diffstat (limited to 'xmake/core/base')
| -rw-r--r-- | xmake/core/base/os.lua | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 6d4c4a96e..cef1af966 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -689,6 +689,32 @@ function os.nuldev() return xmake._NULDEV end +-- get user agent +function os.user_agent() + + -- init user agent + if os._USER_AGENT == nil then + + -- init systems + local systems = {macosx = "Macintosh", linux = "Linux", windows = "Windows"} + + -- os user agent + local os_user_agent = "" + if os.host() == "macosx" then + local ok, osver = os.iorun("/usr/bin/sw_vers -productVersion") + if ok then + os_user_agent = "Intel Mac OS X " .. (osver or ""):trim() + end + end + + -- make user agent + os._USER_AGENT = string.format("Xmake/%s (%s;%s)", xmake._VERSION_SHORT, systems[os.host()] or os.host(), os_user_agent) + end + + -- ok? + return os._USER_AGENT +end + -- get uid function os.uid(...) -- get uid |
