summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-01-05 14:22:40 +0800
committerruki <[email protected]>2017-01-06 17:20:09 +0800
commit61465cbf8df493c13c0adf2adfc985b679933bdd (patch)
tree0a0bc75d249b59cfac6e095d5b323c46c62c988c
parenta79375f2e32977068e783ac4edf881bd6ccfaaaa (diff)
move load script for platform
-rw-r--r--xmake/platforms/android/load.lua106
-rwxr-xr-xxmake/platforms/android/xmake.lua82
-rw-r--r--xmake/platforms/iphoneos/load.lua94
-rwxr-xr-xxmake/platforms/iphoneos/xmake.lua70
-rw-r--r--xmake/platforms/linux/load.lua73
-rwxr-xr-xxmake/platforms/linux/xmake.lua49
-rw-r--r--xmake/platforms/macosx/load.lua74
-rwxr-xr-xxmake/platforms/macosx/xmake.lua50
-rw-r--r--xmake/platforms/mingw/load.lua62
-rwxr-xr-xxmake/platforms/mingw/xmake.lua38
-rw-r--r--xmake/platforms/watchos/load.lua94
-rwxr-xr-xxmake/platforms/watchos/xmake.lua70
-rwxr-xr-xxmake/platforms/windows/xmake.lua3
13 files changed, 509 insertions, 356 deletions
diff --git a/xmake/platforms/android/load.lua b/xmake/platforms/android/load.lua
new file mode 100644
index 000000000..7263a0b75
--- /dev/null
+++ b/xmake/platforms/android/load.lua
@@ -0,0 +1,106 @@
+--!The Make-like Build Utility based on Lua
+--
+-- XMake is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU Lesser General Public License as published by
+-- the Free Software Foundation; either version 2.1 of the License, or
+-- (at your option) any later version.
+--
+-- XMake is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public License
+-- along with XMake;
+-- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a>
+--
+-- Copyright (C) 2015 - 2016, ruki All rights reserved.
+--
+-- @author ruki
+-- @file load.lua
+--
+
+-- imports
+import("core.project.config")
+
+-- load it
+function main()
+
+ -- init the file formats
+ _g.formats = {}
+ _g.formats.static = {"lib", ".a"}
+ _g.formats.object = {"", ".o"}
+ _g.formats.shared = {"lib", ".so"}
+ _g.formats.symbol = {"", ".sym"}
+
+ -- init flags
+ local arch = config.get("arch")
+ if arch:startswith("arm64") then
+ _g.cxflags = {}
+ _g.asflags = {}
+ _g.ldflags = {"-llog"}
+ _g.shflags = {"-llog"}
+ _g.cxxflags = {}
+ else
+ _g.cxflags = { "-march=" .. arch, "-mthumb"}
+ _g.asflags = { "-march=" .. arch, "-mthumb"}
+ _g.ldflags = { "-march=" .. arch, "-llog", "-mthumb"}
+ _g.shflags = { "-march=" .. arch, "-llog", "-mthumb"}
+ _g.cxxflags = {}
+ end
+
+ -- add flags for the sdk directory of ndk
+ local ndk = config.get("ndk")
+ local ndk_sdkver = config.get("ndk_sdkver")
+ if ndk and ndk_sdkver then
+
+ -- get ndk sdk directory
+ local ndk_sdkdir = path.translate(format("%s/platforms/android-%d", ndk, ndk_sdkver))
+
+ -- add sysroot
+ if arch:startswith("arm64") then
+ insert(_g.cxflags, format("--sysroot=%s/arch-arm64", ndk_sdkdir))
+ insert(_g.asflags, format("--sysroot=%s/arch-arm64", ndk_sdkdir))
+ insert(_g.ldflags, format("--sysroot=%s/arch-arm64", ndk_sdkdir))
+ insert(_g.shflags, format("--sysroot=%s/arch-arm64", ndk_sdkdir))
+ else
+ insert(_g.cxflags, format("--sysroot=%s/arch-arm", ndk_sdkdir))
+ insert(_g.asflags, format("--sysroot=%s/arch-arm", ndk_sdkdir))
+ insert(_g.ldflags, format("--sysroot=%s/arch-arm", ndk_sdkdir))
+ insert(_g.shflags, format("--sysroot=%s/arch-arm", ndk_sdkdir))
+ end
+
+ -- only for c++ stl
+ local toolchains_ver = config.get("toolchains_ver")
+ if toolchains_ver then
+
+ -- get c++ stl sdk directory
+ local cxxstl_sdkdir = path.translate(format("%s/sources/cxx-stl/gnu-libstdc++/%s", ndk, toolchains_ver))
+
+ -- the toolchains archs
+ local toolchains_archs =
+ {
+ ["armv5te"] = "armeabi"
+ , ["armv6"] = "armeabi"
+ , ["armv7-a"] = "armeabi-v7a"
+ , ["armv8-a"] = "armeabi-v8a"
+ , ["arm64-v8a"] = "arm64-v8a"
+ }
+
+ -- add search directories for c++ stl
+ insert(_g.cxxflags, format("-I%s/include", cxxstl_sdkdir))
+ if toolchains_archs[arch] then
+ insert(_g.cxxflags, format("-I%s/libs/%s/include", cxxstl_sdkdir, toolchains_archs[arch]))
+ insert(_g.ldflags, format("-L%s/libs/%s", cxxstl_sdkdir, toolchains_archs[arch]))
+ insert(_g.shflags, format("-L%s/libs/%s", cxxstl_sdkdir, toolchains_archs[arch]))
+ insert(_g.ldflags, format("-lgnustl_static"))
+ insert(_g.shflags, format("-lgnustl_static"))
+ end
+ end
+ end
+
+ -- ok
+ return _g
+end
+
+
diff --git a/xmake/platforms/android/xmake.lua b/xmake/platforms/android/xmake.lua
index 9f8b44bd1..4f8bc0642 100755
--- a/xmake/platforms/android/xmake.lua
+++ b/xmake/platforms/android/xmake.lua
@@ -39,87 +39,7 @@ platform("android")
on_check("check")
-- on load
- on_load(function ()
-
- -- imports
- import("core.project.config")
-
- -- init the file formats
- _g.formats = {}
- _g.formats.static = {"lib", ".a"}
- _g.formats.object = {"", ".o"}
- _g.formats.shared = {"lib", ".so"}
- _g.formats.symbol = {"", ".sym"}
-
- -- init flags
- local arch = config.get("arch")
- if arch:startswith("arm64") then
- _g.cxflags = {}
- _g.asflags = {}
- _g.ldflags = {"-llog"}
- _g.shflags = {"-llog"}
- _g.cxxflags = {}
- else
- _g.cxflags = { "-march=" .. arch, "-mthumb"}
- _g.asflags = { "-march=" .. arch, "-mthumb"}
- _g.ldflags = { "-march=" .. arch, "-llog", "-mthumb"}
- _g.shflags = { "-march=" .. arch, "-llog", "-mthumb"}
- _g.cxxflags = {}
- end
-
- -- add flags for the sdk directory of ndk
- local ndk = config.get("ndk")
- local ndk_sdkver = config.get("ndk_sdkver")
- if ndk and ndk_sdkver then
-
- -- get ndk sdk directory
- local ndk_sdkdir = path.translate(format("%s/platforms/android-%d", ndk, ndk_sdkver))
-
- -- add sysroot
- if arch:startswith("arm64") then
- insert(_g.cxflags, format("--sysroot=%s/arch-arm64", ndk_sdkdir))
- insert(_g.asflags, format("--sysroot=%s/arch-arm64", ndk_sdkdir))
- insert(_g.ldflags, format("--sysroot=%s/arch-arm64", ndk_sdkdir))
- insert(_g.shflags, format("--sysroot=%s/arch-arm64", ndk_sdkdir))
- else
- insert(_g.cxflags, format("--sysroot=%s/arch-arm", ndk_sdkdir))
- insert(_g.asflags, format("--sysroot=%s/arch-arm", ndk_sdkdir))
- insert(_g.ldflags, format("--sysroot=%s/arch-arm", ndk_sdkdir))
- insert(_g.shflags, format("--sysroot=%s/arch-arm", ndk_sdkdir))
- end
-
- -- only for c++ stl
- local toolchains_ver = config.get("toolchains_ver")
- if toolchains_ver then
-
- -- get c++ stl sdk directory
- local cxxstl_sdkdir = path.translate(format("%s/sources/cxx-stl/gnu-libstdc++/%s", ndk, toolchains_ver))
-
- -- the toolchains archs
- local toolchains_archs =
- {
- ["armv5te"] = "armeabi"
- , ["armv6"] = "armeabi"
- , ["armv7-a"] = "armeabi-v7a"
- , ["armv8-a"] = "armeabi-v8a"
- , ["arm64-v8a"] = "arm64-v8a"
- }
-
- -- add search directories for c++ stl
- insert(_g.cxxflags, format("-I%s/include", cxxstl_sdkdir))
- if toolchains_archs[arch] then
- insert(_g.cxxflags, format("-I%s/libs/%s/include", cxxstl_sdkdir, toolchains_archs[arch]))
- insert(_g.ldflags, format("-L%s/libs/%s", cxxstl_sdkdir, toolchains_archs[arch]))
- insert(_g.shflags, format("-L%s/libs/%s", cxxstl_sdkdir, toolchains_archs[arch]))
- insert(_g.ldflags, format("-lgnustl_static"))
- insert(_g.shflags, format("-lgnustl_static"))
- end
- end
- end
-
- -- ok
- return _g
- end)
+ on_load("load")
-- set menu
set_menu({
diff --git a/xmake/platforms/iphoneos/load.lua b/xmake/platforms/iphoneos/load.lua
new file mode 100644
index 000000000..21c98f093
--- /dev/null
+++ b/xmake/platforms/iphoneos/load.lua
@@ -0,0 +1,94 @@
+--!The Make-like Build Utility based on Lua
+--
+-- XMake is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU Lesser General Public License as published by
+-- the Free Software Foundation; either version 2.1 of the License, or
+-- (at your option) any later version.
+--
+-- XMake is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public License
+-- along with XMake;
+-- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a>
+--
+-- Copyright (C) 2015 - 2016, ruki All rights reserved.
+--
+-- @author ruki
+-- @file load.lua
+--
+
+-- imports
+import("core.project.config")
+
+-- load it
+function main()
+
+ -- init the file formats
+ _g.formats = {}
+ _g.formats.static = {"lib", ".a"}
+ _g.formats.object = {"", ".o"}
+ _g.formats.shared = {"lib", ".dylib"}
+ _g.formats.symbol = {"", ".sym"}
+
+ -- iphoneos or iphonesimulator?
+ local arch = config.get("arch")
+ if arch == "i386" or arch == "x86_64" then
+
+ -- init flags for architecture
+ local target_minver = config.get("target_minver")
+ _g.cxflags = { "-arch " .. arch, "-mios-simulator-version-min=" .. target_minver }
+ _g.mxflags = { "-arch " .. arch, "-mios-simulator-version-min=" .. target_minver }
+ _g.asflags = { "-arch " .. arch, "-mios-simulator-version-min=" .. target_minver }
+ _g.ldflags = { "-arch " .. arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", "-mios-simulator-version-min=" .. target_minver }
+ _g.shflags = { "-arch " .. arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", "-mios-simulator-version-min=" .. target_minver }
+ _g.ldflags = { "-arch " .. arch, "-Xlinker -objc_abi_version", "-Xlinker 2 -stdlib=libc++", "-Xlinker -no_implicit_dylibs", "-fobjc-link-runtime", "-mios-simulator-version-min=" .. target_minver }
+ _g.shflags = { "-arch " .. arch, "-Xlinker -objc_abi_version", "-Xlinker 2 -stdlib=libc++", "-Xlinker -no_implicit_dylibs", "-fobjc-link-runtime", "-mios-simulator-version-min=" .. target_minver }
+ _g.scflags = { format("-target %s-apple-ios%s", arch, target_minver) }
+
+ -- init flags for the xcode sdk directory
+ local xcode_dir = config.get("xcode_dir")
+ local xcode_sdkver = config.get("xcode_sdkver")
+ local xcode_sdkdir = xcode_dir .. "/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" .. xcode_sdkver .. ".sdk"
+ insert(_g.cxflags, "-isysroot " .. xcode_sdkdir)
+ insert(_g.asflags, "-isysroot " .. xcode_sdkdir)
+ insert(_g.mxflags, "-isysroot " .. xcode_sdkdir)
+ insert(_g.ldflags, "-isysroot " .. xcode_sdkdir)
+ insert(_g.shflags, "-isysroot " .. xcode_sdkdir)
+ insert(_g.scflags, "-sdk " .. xcode_sdkdir)
+
+ -- save swift link directory for tools
+ config.set("__swift_linkdirs", xcode_dir .. "/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator")
+ else
+
+ -- init flags for architecture
+ local target_minver = config.get("target_minver")
+ _g.cxflags = { "-arch " .. arch, "-miphoneos-version-min=" .. target_minver }
+ _g.mxflags = { "-arch " .. arch, "-miphoneos-version-min=" .. target_minver }
+ _g.asflags = { "-arch " .. arch, "-miphoneos-version-min=" .. target_minver }
+ _g.ldflags = { "-arch " .. arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", "-miphoneos-version-min=" .. target_minver }
+ _g.shflags = { "-arch " .. arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", "-miphoneos-version-min=" .. target_minver }
+ _g.scflags = { format("-target %s-apple-ios%s", arch, target_minver) }
+
+ -- init flags for the xcode sdk directory
+ local xcode_dir = config.get("xcode_dir")
+ local xcode_sdkver = config.get("xcode_sdkver")
+ local xcode_sdkdir = xcode_dir .. "/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" .. xcode_sdkver .. ".sdk"
+ insert(_g.cxflags, "-isysroot " .. xcode_sdkdir)
+ insert(_g.asflags, "-isysroot " .. xcode_sdkdir)
+ insert(_g.mxflags, "-isysroot " .. xcode_sdkdir)
+ insert(_g.ldflags, "-isysroot " .. xcode_sdkdir)
+ insert(_g.shflags, "-isysroot " .. xcode_sdkdir)
+ insert(_g.scflags, "-sdk " .. xcode_sdkdir)
+
+ -- save swift link directory for tools
+ config.set("__swift_linkdirs", xcode_dir .. "/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos")
+ end
+
+ -- ok
+ return _g
+end
+
+
diff --git a/xmake/platforms/iphoneos/xmake.lua b/xmake/platforms/iphoneos/xmake.lua
index 446e1a910..384a09e8a 100755
--- a/xmake/platforms/iphoneos/xmake.lua
+++ b/xmake/platforms/iphoneos/xmake.lua
@@ -39,75 +39,7 @@ platform("iphoneos")
on_check("check")
-- on load
- on_load(function ()
-
- -- imports
- import("core.project.config")
-
- -- init the file formats
- _g.formats = {}
- _g.formats.static = {"lib", ".a"}
- _g.formats.object = {"", ".o"}
- _g.formats.shared = {"lib", ".dylib"}
- _g.formats.symbol = {"", ".sym"}
-
- -- iphoneos or iphonesimulator?
- local arch = config.get("arch")
- if arch == "i386" or arch == "x86_64" then
-
- -- init flags for architecture
- local target_minver = config.get("target_minver")
- _g.cxflags = { "-arch " .. arch, "-mios-simulator-version-min=" .. target_minver }
- _g.mxflags = { "-arch " .. arch, "-mios-simulator-version-min=" .. target_minver }
- _g.asflags = { "-arch " .. arch, "-mios-simulator-version-min=" .. target_minver }
- _g.ldflags = { "-arch " .. arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", "-mios-simulator-version-min=" .. target_minver }
- _g.shflags = { "-arch " .. arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", "-mios-simulator-version-min=" .. target_minver }
- _g.ldflags = { "-arch " .. arch, "-Xlinker -objc_abi_version", "-Xlinker 2 -stdlib=libc++", "-Xlinker -no_implicit_dylibs", "-fobjc-link-runtime", "-mios-simulator-version-min=" .. target_minver }
- _g.shflags = { "-arch " .. arch, "-Xlinker -objc_abi_version", "-Xlinker 2 -stdlib=libc++", "-Xlinker -no_implicit_dylibs", "-fobjc-link-runtime", "-mios-simulator-version-min=" .. target_minver }
- _g.scflags = { format("-target %s-apple-ios%s", arch, target_minver) }
-
- -- init flags for the xcode sdk directory
- local xcode_dir = config.get("xcode_dir")
- local xcode_sdkver = config.get("xcode_sdkver")
- local xcode_sdkdir = xcode_dir .. "/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" .. xcode_sdkver .. ".sdk"
- insert(_g.cxflags, "-isysroot " .. xcode_sdkdir)
- insert(_g.asflags, "-isysroot " .. xcode_sdkdir)
- insert(_g.mxflags, "-isysroot " .. xcode_sdkdir)
- insert(_g.ldflags, "-isysroot " .. xcode_sdkdir)
- insert(_g.shflags, "-isysroot " .. xcode_sdkdir)
- insert(_g.scflags, "-sdk " .. xcode_sdkdir)
-
- -- save swift link directory for tools
- config.set("__swift_linkdirs", xcode_dir .. "/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator")
- else
-
- -- init flags for architecture
- local target_minver = config.get("target_minver")
- _g.cxflags = { "-arch " .. arch, "-miphoneos-version-min=" .. target_minver }
- _g.mxflags = { "-arch " .. arch, "-miphoneos-version-min=" .. target_minver }
- _g.asflags = { "-arch " .. arch, "-miphoneos-version-min=" .. target_minver }
- _g.ldflags = { "-arch " .. arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", "-miphoneos-version-min=" .. target_minver }
- _g.shflags = { "-arch " .. arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", "-miphoneos-version-min=" .. target_minver }
- _g.scflags = { format("-target %s-apple-ios%s", arch, target_minver) }
-
- -- init flags for the xcode sdk directory
- local xcode_dir = config.get("xcode_dir")
- local xcode_sdkver = config.get("xcode_sdkver")
- local xcode_sdkdir = xcode_dir .. "/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" .. xcode_sdkver .. ".sdk"
- insert(_g.cxflags, "-isysroot " .. xcode_sdkdir)
- insert(_g.asflags, "-isysroot " .. xcode_sdkdir)
- insert(_g.mxflags, "-isysroot " .. xcode_sdkdir)
- insert(_g.ldflags, "-isysroot " .. xcode_sdkdir)
- insert(_g.shflags, "-isysroot " .. xcode_sdkdir)
- insert(_g.scflags, "-sdk " .. xcode_sdkdir)
-
- -- save swift link directory for tools
- config.set("__swift_linkdirs", xcode_dir .. "/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos")
- end
-
- -- ok
- return _g
- end)
+ on_load("load")
-- set menu
set_menu({
diff --git a/xmake/platforms/linux/load.lua b/xmake/platforms/linux/load.lua
new file mode 100644
index 000000000..7ae004ac5
--- /dev/null
+++ b/xmake/platforms/linux/load.lua
@@ -0,0 +1,73 @@
+--!The Make-like Build Utility based on Lua
+--
+-- XMake is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU Lesser General Public License as published by
+-- the Free Software Foundation; either version 2.1 of the License, or
+-- (at your option) any later version.
+--
+-- XMake is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public License
+-- along with XMake;
+-- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a>
+--
+-- Copyright (C) 2015 - 2016, ruki All rights reserved.
+--
+-- @author ruki
+-- @file load.lua
+--
+
+-- imports
+import("core.project.config")
+
+-- load it
+function main()
+
+ -- init the file formats
+ _g.formats = {}
+ _g.formats.static = {"lib", ".a"}
+ _g.formats.object = {"", ".o"}
+ _g.formats.shared = {"lib", ".so"}
+ _g.formats.symbol = {"", ".sym"}
+
+ -- cross toolchains?
+ if config.get("cross") or config.get("toolchains") or config.get("sdk") then
+
+ -- init linkdirs and includedirs
+ local sdkdir = config.get("sdk")
+ if sdkdir then
+ _g.includedirs = {path.join(sdkdir, "include")}
+ _g.linkdirs = {path.join(sdkdir, "lib")}
+ end
+
+ -- ok
+ return _g
+ end
+
+ -- init flags for architecture
+ local archflags = nil
+ local arch = config.get("arch")
+ if arch then
+ if arch == "x86_64" then archflags = "-m64"
+ elseif arch == "i386" then archflags = "-m32"
+ else archflags = "-arch " .. arch
+ end
+ end
+ _g.cxflags = { archflags }
+ _g.mxflags = { archflags }
+ _g.asflags = { archflags }
+ _g.ldflags = { archflags }
+ _g.shflags = { archflags }
+
+ -- init linkdirs and includedirs
+ _g.linkdirs = {"/usr/lib", "/usr/local/lib"}
+ _g.includedirs = {"/usr/include", "/usr/local/include"}
+
+ -- ok
+ return _g
+end
+
+
diff --git a/xmake/platforms/linux/xmake.lua b/xmake/platforms/linux/xmake.lua
index b546fbbd8..8e6dc4315 100755
--- a/xmake/platforms/linux/xmake.lua
+++ b/xmake/platforms/linux/xmake.lua
@@ -45,54 +45,7 @@ platform("linux")
on_check("check")
-- on load
- on_load(function ()
-
- -- imports
- import("core.project.config")
-
- -- init the file formats
- _g.formats = {}
- _g.formats.static = {"lib", ".a"}
- _g.formats.object = {"", ".o"}
- _g.formats.shared = {"lib", ".so"}
- _g.formats.symbol = {"", ".sym"}
-
- -- cross toolchains?
- if config.get("cross") or config.get("toolchains") or config.get("sdk") then
-
- -- init linkdirs and includedirs
- local sdkdir = config.get("sdk")
- if sdkdir then
- _g.includedirs = {path.join(sdkdir, "include")}
- _g.linkdirs = {path.join(sdkdir, "lib")}
- end
-
- -- ok
- return _g
- end
-
- -- init flags for architecture
- local archflags = nil
- local arch = config.get("arch")
- if arch then
- if arch == "x86_64" then archflags = "-m64"
- elseif arch == "i386" then archflags = "-m32"
- else archflags = "-arch " .. arch
- end
- end
- _g.cxflags = { archflags }
- _g.mxflags = { archflags }
- _g.asflags = { archflags }
- _g.ldflags = { archflags }
- _g.shflags = { archflags }
-
- -- init linkdirs and includedirs
- _g.linkdirs = {"/usr/lib", "/usr/local/lib"}
- _g.includedirs = {"/usr/include", "/usr/local/include"}
-
- -- ok
- return _g
- end)
+ on_load("load")
diff --git a/xmake/platforms/macosx/load.lua b/xmake/platforms/macosx/load.lua
new file mode 100644
index 000000000..94f89ce91
--- /dev/null
+++ b/xmake/platforms/macosx/load.lua
@@ -0,0 +1,74 @@
+--!The Make-like Build Utility based on Lua
+--
+-- XMake is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU Lesser General Public License as published by
+-- the Free Software Foundation; either version 2.1 of the License, or
+-- (at your option) any later version.
+--
+-- XMake is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public License
+-- along with XMake;
+-- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a>
+--
+-- Copyright (C) 2015 - 2016, ruki All rights reserved.
+--
+-- @author ruki
+-- @file load.lua
+--
+
+-- imports
+import("core.project.config")
+
+-- load it
+function main()
+
+ -- init the file formats
+ _g.formats = {}
+ _g.formats.static = {"lib", ".a"}
+ _g.formats.object = {"", ".o"}
+ _g.formats.shared = {"lib", ".dylib"}
+ _g.formats.symbol = {"", ".sym"}
+
+ -- init flags for architecture
+ local arch = config.get("arch")
+ local target_minver = config.get("target_minver")
+ _g.cxflags = { "-arch " .. arch, "-fpascal-strings", "-fmessage-length=0" }
+ _g.mxflags = { "-arch " .. arch, "-fpascal-strings", "-fmessage-length=0" }
+ _g.asflags = { "-arch " .. arch }
+ _g.ldflags = { "-arch " .. arch, "-mmacosx-version-min=" .. target_minver, "-stdlib=libc++", "-lz" }
+ _g.shflags = { "-arch " .. arch, "-mmacosx-version-min=" .. target_minver, "-stdlib=libc++", "-lz" }
+ _g.scflags = { format("-target %s-apple-macosx%s", arch, target_minver) }
+
+ -- init flags for the xcode sdk directory
+ local xcode_dir = config.get("xcode_dir")
+ local xcode_sdkver = config.get("xcode_sdkver")
+ local xcode_sdkdir = xcode_dir .. "/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX" .. xcode_sdkver .. ".sdk"
+ insert(_g.cxflags, "-isysroot " .. xcode_sdkdir)
+ insert(_g.asflags, "-isysroot " .. xcode_sdkdir)
+ insert(_g.mxflags, "-isysroot " .. xcode_sdkdir)
+ insert(_g.ldflags, "-isysroot " .. xcode_sdkdir)
+ insert(_g.shflags, "-isysroot " .. xcode_sdkdir)
+ insert(_g.scflags, "-sdk " .. xcode_sdkdir)
+
+ -- init includedirs
+ --
+ -- @note
+ -- cannot use _g.includedirs because the swift/objc compiler will compile code failed
+ insert(_g.cxflags, "-I/usr/include")
+ insert(_g.cxflags, "-I/usr/local/include")
+
+ -- init linkdirs
+ _g.linkdirs = {"/usr/lib", "/usr/local/lib"}
+
+ -- save swift link directory for tools
+ config.set("__swift_linkdirs", xcode_dir .. "/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx")
+
+ -- ok
+ return _g
+end
+
+
diff --git a/xmake/platforms/macosx/xmake.lua b/xmake/platforms/macosx/xmake.lua
index c4c428afd..30a092aa0 100755
--- a/xmake/platforms/macosx/xmake.lua
+++ b/xmake/platforms/macosx/xmake.lua
@@ -45,55 +45,7 @@ platform("macosx")
on_uninstall("uninstall")
-- on load
- on_load(function ()
-
- -- imports
- import("core.project.config")
-
- -- init the file formats
- _g.formats = {}
- _g.formats.static = {"lib", ".a"}
- _g.formats.object = {"", ".o"}
- _g.formats.shared = {"lib", ".dylib"}
- _g.formats.symbol = {"", ".sym"}
-
- -- init flags for architecture
- local arch = config.get("arch")
- local target_minver = config.get("target_minver")
- _g.cxflags = { "-arch " .. arch, "-fpascal-strings", "-fmessage-length=0" }
- _g.mxflags = { "-arch " .. arch, "-fpascal-strings", "-fmessage-length=0" }
- _g.asflags = { "-arch " .. arch }
- _g.ldflags = { "-arch " .. arch, "-mmacosx-version-min=" .. target_minver, "-stdlib=libc++", "-lz" }
- _g.shflags = { "-arch " .. arch, "-mmacosx-version-min=" .. target_minver, "-stdlib=libc++", "-lz" }
- _g.scflags = { format("-target %s-apple-macosx%s", arch, target_minver) }
-
- -- init flags for the xcode sdk directory
- local xcode_dir = config.get("xcode_dir")
- local xcode_sdkver = config.get("xcode_sdkver")
- local xcode_sdkdir = xcode_dir .. "/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX" .. xcode_sdkver .. ".sdk"
- insert(_g.cxflags, "-isysroot " .. xcode_sdkdir)
- insert(_g.asflags, "-isysroot " .. xcode_sdkdir)
- insert(_g.mxflags, "-isysroot " .. xcode_sdkdir)
- insert(_g.ldflags, "-isysroot " .. xcode_sdkdir)
- insert(_g.shflags, "-isysroot " .. xcode_sdkdir)
- insert(_g.scflags, "-sdk " .. xcode_sdkdir)
-
- -- init includedirs
- --
- -- @note
- -- cannot use _g.includedirs because the swift/objc compiler will compile code failed
- insert(_g.cxflags, "-I/usr/include")
- insert(_g.cxflags, "-I/usr/local/include")
-
- -- init linkdirs
- _g.linkdirs = {"/usr/lib", "/usr/local/lib"}
-
- -- save swift link directory for tools
- config.set("__swift_linkdirs", xcode_dir .. "/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx")
-
- -- ok
- return _g
- end)
+ on_load("load")
-- set menu
set_menu({
diff --git a/xmake/platforms/mingw/load.lua b/xmake/platforms/mingw/load.lua
new file mode 100644
index 000000000..339939427
--- /dev/null
+++ b/xmake/platforms/mingw/load.lua
@@ -0,0 +1,62 @@
+--!The Make-like Build Utility based on Lua
+--
+-- XMake is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU Lesser General Public License as published by
+-- the Free Software Foundation; either version 2.1 of the License, or
+-- (at your option) any later version.
+--
+-- XMake is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public License
+-- along with XMake;
+-- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a>
+--
+-- Copyright (C) 2015 - 2016, ruki All rights reserved.
+--
+-- @author ruki
+-- @file load.lua
+--
+
+-- imports
+import("core.project.config")
+
+-- load it
+function main()
+
+ -- init the file formats
+ _g.formats = {}
+ _g.formats.static = {"", ".lib"}
+ _g.formats.object = {"", ".obj"}
+ _g.formats.shared = {"", ".dll"}
+ _g.formats.binary = {"", ".exe"}
+ _g.formats.symbol = {"", ".pdb"}
+
+ -- init flags for architecture
+ local archflags = nil
+ local arch = config.get("arch")
+ if arch then
+ if arch == "x86_64" then archflags = "-m64"
+ elseif arch == "i386" then archflags = "-m32"
+ else archflags = "-arch " .. arch
+ end
+ end
+ _g.cxflags = { archflags }
+ _g.asflags = { archflags }
+ _g.ldflags = { archflags }
+ _g.shflags = { archflags }
+
+ -- init linkdirs and includedirs
+ local sdkdir = config.get("sdk")
+ if sdkdir then
+ _g.includedirs = {path.join(sdkdir, "include")}
+ _g.linkdirs = {path.join(sdkdir, "lib")}
+ end
+
+ -- ok
+ return _g
+end
+
+
diff --git a/xmake/platforms/mingw/xmake.lua b/xmake/platforms/mingw/xmake.lua
index e46e5c5cc..66144b3df 100755
--- a/xmake/platforms/mingw/xmake.lua
+++ b/xmake/platforms/mingw/xmake.lua
@@ -36,41 +36,5 @@ platform("mingw")
on_check("check")
-- on load
- on_load(function ()
-
- -- imports
- import("core.project.config")
-
- -- init the file formats
- _g.formats = {}
- _g.formats.static = {"", ".lib"}
- _g.formats.object = {"", ".obj"}
- _g.formats.shared = {"", ".dll"}
- _g.formats.binary = {"", ".exe"}
- _g.formats.symbol = {"", ".pdb"}
-
- -- init flags for architecture
- local archflags = nil
- local arch = config.get("arch")
- if arch then
- if arch == "x86_64" then archflags = "-m64"
- elseif arch == "i386" then archflags = "-m32"
- else archflags = "-arch " .. arch
- end
- end
- _g.cxflags = { archflags }
- _g.asflags = { archflags }
- _g.ldflags = { archflags }
- _g.shflags = { archflags }
-
- -- init linkdirs and includedirs
- local sdkdir = config.get("sdk")
- if sdkdir then
- _g.includedirs = {path.join(sdkdir, "include")}
- _g.linkdirs = {path.join(sdkdir, "lib")}
- end
-
- -- ok
- return _g
- end)
+ on_load("load")
diff --git a/xmake/platforms/watchos/load.lua b/xmake/platforms/watchos/load.lua
new file mode 100644
index 000000000..803b3ec27
--- /dev/null
+++ b/xmake/platforms/watchos/load.lua
@@ -0,0 +1,94 @@
+--!The Make-like Build Utility based on Lua
+--
+-- XMake is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU Lesser General Public License as published by
+-- the Free Software Foundation; either version 2.1 of the License, or
+-- (at your option) any later version.
+--
+-- XMake is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public License
+-- along with XMake;
+-- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a>
+--
+-- Copyright (C) 2015 - 2016, ruki All rights reserved.
+--
+-- @author ruki
+-- @file load.lua
+--
+
+-- imports
+import("core.project.config")
+
+-- load it
+function main()
+
+ -- init the file formats
+ _g.formats = {}
+ _g.formats.static = {"lib", ".a"}
+ _g.formats.object = {"", ".o"}
+ _g.formats.shared = {"lib", ".dylib"}
+ _g.formats.symbol = {"", ".sym"}
+
+ -- watchos or watchsimulator?
+ local arch = config.get("arch")
+ if arch == "i386" then
+
+ -- init flags for architecture
+ local target_minver = config.get("target_minver")
+ _g.cxflags = { "-arch " .. arch, "-mwatchos-simulator-version-min=" .. target_minver }
+ _g.mxflags = { "-arch " .. arch, "-mwatchos-simulator-version-min=" .. target_minver }
+ _g.asflags = { "-arch " .. arch, "-mwatchos-simulator-version-min=" .. target_minver }
+ _g.ldflags = { "-arch " .. arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", "-mwatchos-simulator-version-min=" .. target_minver }
+ _g.shflags = { "-arch " .. arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", "-mwatchos-simulator-version-min=" .. target_minver }
+ _g.ldflags = { "-arch " .. arch, "-Xlinker -objc_abi_version", "-Xlinker 2 -stdlib=libc++", "-Xlinker -no_implicit_dylibs", "-fobjc-link-runtime", "-mwatchos-simulator-version-min=" .. target_minver }
+ _g.shflags = { "-arch " .. arch, "-Xlinker -objc_abi_version", "-Xlinker 2 -stdlib=libc++", "-Xlinker -no_implicit_dylibs", "-fobjc-link-runtime", "-mwatchos-simulator-version-min=" .. target_minver }
+ _g.scflags = { format("-target %s-apple-ios%s", arch, target_minver) }
+
+ -- init flags for the xcode sdk directory
+ local xcode_dir = config.get("xcode_dir")
+ local xcode_sdkver = config.get("xcode_sdkver")
+ local xcode_sdkdir = xcode_dir .. "/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator" .. xcode_sdkver .. ".sdk"
+ insert(_g.cxflags, "-isysroot " .. xcode_sdkdir)
+ insert(_g.asflags, "-isysroot " .. xcode_sdkdir)
+ insert(_g.mxflags, "-isysroot " .. xcode_sdkdir)
+ insert(_g.ldflags, "-isysroot " .. xcode_sdkdir)
+ insert(_g.shflags, "-isysroot " .. xcode_sdkdir)
+ insert(_g.scflags, "-sdk " .. xcode_sdkdir)
+
+ -- save swift link directory for tools
+ config.set("__swift_linkdirs", xcode_dir .. "/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/watchsimulator")
+ else
+
+ -- init flags for architecture
+ local target_minver = config.get("target_minver")
+ _g.cxflags = { "-arch " .. arch, "-mwatchos-version-min=" .. target_minver }
+ _g.mxflags = { "-arch " .. arch, "-mwatchos-version-min=" .. target_minver }
+ _g.asflags = { "-arch " .. arch, "-mwatchos-version-min=" .. target_minver }
+ _g.ldflags = { "-arch " .. arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", "-mwatchos-version-min=" .. target_minver }
+ _g.shflags = { "-arch " .. arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", "-mwatchos-version-min=" .. target_minver }
+ _g.scflags = { format("-target %s-apple-ios%s", arch, target_minver) }
+
+ -- init flags for the xcode sdk directory
+ local xcode_dir = config.get("xcode_dir")
+ local xcode_sdkver = config.get("xcode_sdkver")
+ local xcode_sdkdir = xcode_dir .. "/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS" .. xcode_sdkver .. ".sdk"
+ insert(_g.cxflags, "-isysroot " .. xcode_sdkdir)
+ insert(_g.asflags, "-isysroot " .. xcode_sdkdir)
+ insert(_g.mxflags, "-isysroot " .. xcode_sdkdir)
+ insert(_g.ldflags, "-isysroot " .. xcode_sdkdir)
+ insert(_g.shflags, "-isysroot " .. xcode_sdkdir)
+ insert(_g.scflags, "-sdk " .. xcode_sdkdir)
+
+ -- save swift link directory for tools
+ config.set("__swift_linkdirs", xcode_dir .. "/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/watchos")
+ end
+
+ -- ok
+ return _g
+end
+
+
diff --git a/xmake/platforms/watchos/xmake.lua b/xmake/platforms/watchos/xmake.lua
index a48e50073..81bde1a4d 100755
--- a/xmake/platforms/watchos/xmake.lua
+++ b/xmake/platforms/watchos/xmake.lua
@@ -39,75 +39,7 @@ platform("watchos")
on_check("check")
-- on load
- on_load(function ()
-
- -- imports
- import("core.project.config")
-
- -- init the file formats
- _g.formats = {}
- _g.formats.static = {"lib", ".a"}
- _g.formats.object = {"", ".o"}
- _g.formats.shared = {"lib", ".dylib"}
- _g.formats.symbol = {"", ".sym"}
-
- -- watchos or watchsimulator?
- local arch = config.get("arch")
- if arch == "i386" then
-
- -- init flags for architecture
- local target_minver = config.get("target_minver")
- _g.cxflags = { "-arch " .. arch, "-mwatchos-simulator-version-min=" .. target_minver }
- _g.mxflags = { "-arch " .. arch, "-mwatchos-simulator-version-min=" .. target_minver }
- _g.asflags = { "-arch " .. arch, "-mwatchos-simulator-version-min=" .. target_minver }
- _g.ldflags = { "-arch " .. arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", "-mwatchos-simulator-version-min=" .. target_minver }
- _g.shflags = { "-arch " .. arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", "-mwatchos-simulator-version-min=" .. target_minver }
- _g.ldflags = { "-arch " .. arch, "-Xlinker -objc_abi_version", "-Xlinker 2 -stdlib=libc++", "-Xlinker -no_implicit_dylibs", "-fobjc-link-runtime", "-mwatchos-simulator-version-min=" .. target_minver }
- _g.shflags = { "-arch " .. arch, "-Xlinker -objc_abi_version", "-Xlinker 2 -stdlib=libc++", "-Xlinker -no_implicit_dylibs", "-fobjc-link-runtime", "-mwatchos-simulator-version-min=" .. target_minver }
- _g.scflags = { format("-target %s-apple-ios%s", arch, target_minver) }
-
- -- init flags for the xcode sdk directory
- local xcode_dir = config.get("xcode_dir")
- local xcode_sdkver = config.get("xcode_sdkver")
- local xcode_sdkdir = xcode_dir .. "/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator" .. xcode_sdkver .. ".sdk"
- insert(_g.cxflags, "-isysroot " .. xcode_sdkdir)
- insert(_g.asflags, "-isysroot " .. xcode_sdkdir)
- insert(_g.mxflags, "-isysroot " .. xcode_sdkdir)
- insert(_g.ldflags, "-isysroot " .. xcode_sdkdir)
- insert(_g.shflags, "-isysroot " .. xcode_sdkdir)
- insert(_g.scflags, "-sdk " .. xcode_sdkdir)
-
- -- save swift link directory for tools
- config.set("__swift_linkdirs", xcode_dir .. "/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/watchsimulator")
- else
-
- -- init flags for architecture
- local target_minver = config.get("target_minver")
- _g.cxflags = { "-arch " .. arch, "-mwatchos-version-min=" .. target_minver }
- _g.mxflags = { "-arch " .. arch, "-mwatchos-version-min=" .. target_minver }
- _g.asflags = { "-arch " .. arch, "-mwatchos-version-min=" .. target_minver }
- _g.ldflags = { "-arch " .. arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", "-mwatchos-version-min=" .. target_minver }
- _g.shflags = { "-arch " .. arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", "-mwatchos-version-min=" .. target_minver }
- _g.scflags = { format("-target %s-apple-ios%s", arch, target_minver) }
-
- -- init flags for the xcode sdk directory
- local xcode_dir = config.get("xcode_dir")
- local xcode_sdkver = config.get("xcode_sdkver")
- local xcode_sdkdir = xcode_dir .. "/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS" .. xcode_sdkver .. ".sdk"
- insert(_g.cxflags, "-isysroot " .. xcode_sdkdir)
- insert(_g.asflags, "-isysroot " .. xcode_sdkdir)
- insert(_g.mxflags, "-isysroot " .. xcode_sdkdir)
- insert(_g.ldflags, "-isysroot " .. xcode_sdkdir)
- insert(_g.shflags, "-isysroot " .. xcode_sdkdir)
- insert(_g.scflags, "-sdk " .. xcode_sdkdir)
-
- -- save swift link directory for tools
- config.set("__swift_linkdirs", xcode_dir .. "/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/watchos")
- end
-
- -- ok
- return _g
- end)
+ on_load("load")
-- set menu
set_menu({
diff --git a/xmake/platforms/windows/xmake.lua b/xmake/platforms/windows/xmake.lua
index ab54b0f2e..04db739c5 100755
--- a/xmake/platforms/windows/xmake.lua
+++ b/xmake/platforms/windows/xmake.lua
@@ -41,9 +41,6 @@ platform("windows")
-- on load
on_load(function ()
- -- imports
- import("core.project.config")
-
-- init the file formats
_g.formats = {}
_g.formats.static = {"", ".lib"}