summaryrefslogtreecommitdiff
path: root/xmake/scripts
diff options
context:
space:
mode:
authorruki <[email protected]>2015-06-15 14:41:00 +0800
committerruki <[email protected]>2015-06-15 14:41:00 +0800
commit351b402b8d0f5ee48097742c7b59a53054dd10ef (patch)
treeedf2696bd2a1035eaa113f124344ca0e6d5a9a65 /xmake/scripts
parent2ff2b14ec02d4d2ec77d26213412c1b82473bf8d (diff)
add os name
Diffstat (limited to 'xmake/scripts')
-rw-r--r--xmake/scripts/base/project.lua40
-rw-r--r--xmake/scripts/platform/android/android.lua7
-rw-r--r--xmake/scripts/platform/iphoneos/iphoneos.lua3
-rw-r--r--xmake/scripts/platform/iphonesimulator/iphonesimulator.lua3
-rw-r--r--xmake/scripts/platform/linux/linux.lua3
-rw-r--r--xmake/scripts/platform/macosx/macosx.lua3
-rw-r--r--xmake/scripts/platform/mingw/mingw.lua3
-rw-r--r--xmake/scripts/platform/platform.lua7
-rw-r--r--xmake/scripts/platform/windows/windows.lua3
9 files changed, 63 insertions, 9 deletions
diff --git a/xmake/scripts/base/project.lua b/xmake/scripts/base/project.lua
index 2cf101f79..af37ef50f 100644
--- a/xmake/scripts/base/project.lua
+++ b/xmake/scripts/base/project.lua
@@ -33,6 +33,7 @@ local table = require("base/table")
local config = require("base/config")
local linker = require("base/linker")
local compiler = require("base/compiler")
+local platform = require("platform/platform")
-- the current mode is belong to the given modes?
function project._api_modes(env, ...)
@@ -232,10 +233,35 @@ function project._filter(values)
for _, v in ipairs(utils.wrap(values)) do
if type(v) == "string" then
v = v:gsub("%$%((.-)%)", function (w)
+
+ -- is upper?
+ local isupper = false
+ local c = string.char(w:byte())
+ if c >= 'A' and c <= 'Z' then isupper = true end
+
+ -- attempt to get it directly from the configure
local r = config.get(w)
- if r and type(r) == "string" then return r
- elseif w == "projectdir" then return xmake._PROJECT_DIR
- end
+ if not r or type(r) ~= "string" then
+
+ -- attempt to get it from the configure and the lower key
+ w = w:lower()
+ r = config.get(w)
+ if not r or type(r) ~= "string" then
+
+ -- get the other keys
+ if w == "projectdir" then r = xmake._PROJECT_DIR
+ elseif w == "os" then r = platform.os()
+ end
+ end
+ end
+
+ -- upper?
+ if r and type(r) == "string" and isupper then
+ r = r:upper()
+ end
+
+ -- ok?
+ return r
end)
end
table.insert(newvals, v)
@@ -294,11 +320,11 @@ function project._makeconf_for_target(target_name, target)
-- make the defines
local defines = {}
- if target.defines_h_if_ok then table.join2(defines, target.defines_h_if_ok) end
+ if target.defines_h then table.join2(defines, target.defines_h) end
-- make the undefines
local undefines = {}
- if target.undefines_h_if_ok then table.join2(undefines, target.undefines_h_if_ok) end
+ if target.undefines_h then table.join2(undefines, target.undefines_h) end
-- the options
if target.options then
@@ -811,8 +837,8 @@ function project._load_targets(file)
, "options"
, "defines"
, "undefines"
- , "defines_h_if_ok"
- , "undefines_h_if_ok"
+ , "defines_h"
+ , "undefines_h"
, "languages"
, "vectorexts"}
for _, interface in ipairs(interfaces) do
diff --git a/xmake/scripts/platform/android/android.lua b/xmake/scripts/platform/android/android.lua
index 4774b79b5..62c862970 100644
--- a/xmake/scripts/platform/android/android.lua
+++ b/xmake/scripts/platform/android/android.lua
@@ -27,10 +27,13 @@ local android = android or {}
local config = require("base/config")
-- init host
-android._HOST = xmake._HOST
+android._HOST = xmake._HOST
+
+-- init os
+android._OS = "android"
-- init architectures
-android._ARCHS = {"armv5te", "armv6", "armv7-a"}
+android._ARCHS = {"armv5te", "armv6", "armv7-a"}
-- make configure
function android.make(configs)
diff --git a/xmake/scripts/platform/iphoneos/iphoneos.lua b/xmake/scripts/platform/iphoneos/iphoneos.lua
index c66119e15..9b9b4dd50 100644
--- a/xmake/scripts/platform/iphoneos/iphoneos.lua
+++ b/xmake/scripts/platform/iphoneos/iphoneos.lua
@@ -29,6 +29,9 @@ local config = require("base/config")
-- init host
iphoneos._HOST = "macosx"
+-- init os
+iphoneos._OS = "ios"
+
-- init architectures
iphoneos._ARCHS = {"armv7", "armv7s", "arm64"}
diff --git a/xmake/scripts/platform/iphonesimulator/iphonesimulator.lua b/xmake/scripts/platform/iphonesimulator/iphonesimulator.lua
index db3f1c8c7..6b059caaa 100644
--- a/xmake/scripts/platform/iphonesimulator/iphonesimulator.lua
+++ b/xmake/scripts/platform/iphonesimulator/iphonesimulator.lua
@@ -29,6 +29,9 @@ local config = require("base/config")
-- init host
iphonesimulator._HOST = "macosx"
+-- init os
+iphonesimulator._OS = "ios"
+
-- init architectures
iphonesimulator._ARCHS = {"i386", "x86_64"}
diff --git a/xmake/scripts/platform/linux/linux.lua b/xmake/scripts/platform/linux/linux.lua
index 9ce5f447e..82b934ee4 100644
--- a/xmake/scripts/platform/linux/linux.lua
+++ b/xmake/scripts/platform/linux/linux.lua
@@ -29,6 +29,9 @@ local config = require("base/config")
-- init host
linux._HOST = "linux"
+-- init os
+linux._OS = "linux"
+
-- init architectures
linux._ARCHS = {"i386", "x86_64"}
diff --git a/xmake/scripts/platform/macosx/macosx.lua b/xmake/scripts/platform/macosx/macosx.lua
index f413fd759..9866209e2 100644
--- a/xmake/scripts/platform/macosx/macosx.lua
+++ b/xmake/scripts/platform/macosx/macosx.lua
@@ -29,6 +29,9 @@ local config = require("base/config")
-- init host
macosx._HOST = "macosx"
+-- init os
+macosx._OS = "macosx"
+
-- init architectures
macosx._ARCHS = {"i386", "x86_64"}
diff --git a/xmake/scripts/platform/mingw/mingw.lua b/xmake/scripts/platform/mingw/mingw.lua
index 466305753..430d3519a 100644
--- a/xmake/scripts/platform/mingw/mingw.lua
+++ b/xmake/scripts/platform/mingw/mingw.lua
@@ -29,6 +29,9 @@ local config = require("base/config")
-- init host
mingw._HOST = xmake._HOST
+-- init os
+mingw._OS = "windows"
+
-- init architectures
mingw._ARCHS = {"i386", "x86_64"}
diff --git a/xmake/scripts/platform/platform.lua b/xmake/scripts/platform/platform.lua
index 07981c40a..a84f80187 100644
--- a/xmake/scripts/platform/platform.lua
+++ b/xmake/scripts/platform/platform.lua
@@ -161,6 +161,13 @@ function platform.make()
return platform._configs(config.get("plat"))
end
+-- get the platform os
+function platform.os()
+
+ -- ok?
+ return platform.module()._OS
+end
+
-- get the given configure
function platform.get(name)
diff --git a/xmake/scripts/platform/windows/windows.lua b/xmake/scripts/platform/windows/windows.lua
index 4c9d11e8f..2203b57e4 100644
--- a/xmake/scripts/platform/windows/windows.lua
+++ b/xmake/scripts/platform/windows/windows.lua
@@ -30,6 +30,9 @@ local config = require("base/config")
-- init host
windows._HOST = "windows"
+-- init os
+windows._OS = "windows"
+
-- init architectures
windows._ARCHS = {"i386", "x86_64"}