diff options
| author | ruki <[email protected]> | 2016-01-14 09:19:14 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-01-14 09:19:14 +0800 |
| commit | cdcf953259aee5e7e1a06855ddbedbaabf585bc9 (patch) | |
| tree | 47b8e5de10522cca3b67354fa527b3525193e880 /xmake/scripts/platform | |
| parent | 8c50566e7ab2139b9f6c2976b9ce875b7ad11b7a (diff) | |
rename script directory to core
Diffstat (limited to 'xmake/scripts/platform')
30 files changed, 0 insertions, 5455 deletions
diff --git a/xmake/scripts/platform/android/android.lua b/xmake/scripts/platform/android/android.lua deleted file mode 100644 index 15e3c33a2..000000000 --- a/xmake/scripts/platform/android/android.lua +++ /dev/null @@ -1,120 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- 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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file android.lua --- - --- define module: android -local android = android or {} - --- load modules -local config = require("base/config") - --- init host -android._HOST = xmake._HOST - --- init os -android._OS = "android" - --- init architectures -android._ARCHS = {"armv5te", "armv6", "armv7-a", "armv8-a", "arm64-v8a"} - --- make configure -function android.make(configs) - - -- init the file formats - configs.formats = {} - configs.formats.static = {"lib", ".a"} - configs.formats.object = {"", ".o"} - configs.formats.shared = {"lib", ".so"} - - -- init the toolchains - configs.tools = {} - configs.tools.make = config.get("make") - configs.tools.ccache = config.get("__ccache") - configs.tools.cc = config.get("cc") - configs.tools.cxx = config.get("cxx") - configs.tools.as = config.get("as") - configs.tools.ld = config.get("ld") - configs.tools.ar = config.get("ar") - configs.tools.sh = config.get("sh") - configs.tools.ex = config.get("ar") - configs.tools.sc = config.get("sc") - - -- init flags - local arch = config.get("arch") - if arch:startswith("arm64") then - configs.cxflags = {} - configs.asflags = {} - configs.ldflags = {"-llog"} - configs.shflags = {"-llog"} - else - configs.cxflags = { "-march=" .. arch, "-mthumb"} - configs.asflags = { "-march=" .. arch, "-mthumb"} - configs.ldflags = { "-march=" .. arch, "-llog", "-mthumb"} - configs.shflags = { "-march=" .. arch, "-llog", "-mthumb"} - 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 - local ndk_sdkdir = path.translate(string.format("%s/platforms/android-%d", ndk, ndk_sdkver)) - if arch:startswith("arm64") then - table.insert(configs.cxflags, string.format("--sysroot=%s/arch-arm64", ndk_sdkdir)) - table.insert(configs.asflags, string.format("--sysroot=%s/arch-arm64", ndk_sdkdir)) - table.insert(configs.ldflags, string.format("--sysroot=%s/arch-arm64", ndk_sdkdir)) - table.insert(configs.shflags, string.format("--sysroot=%s/arch-arm64", ndk_sdkdir)) - else - table.insert(configs.cxflags, string.format("--sysroot=%s/arch-arm", ndk_sdkdir)) - table.insert(configs.asflags, string.format("--sysroot=%s/arch-arm", ndk_sdkdir)) - table.insert(configs.ldflags, string.format("--sysroot=%s/arch-arm", ndk_sdkdir)) - table.insert(configs.shflags, string.format("--sysroot=%s/arch-arm", ndk_sdkdir)) - end - end - -end - --- get the option menu for action: xmake config or global -function android.menu(action) - - -- init config option menu - android._MENU_CONFIG = android._MENU_CONFIG or - { {} - , {nil, "ndk", "kv", nil, "The NDK Directory" } - , {nil, "ndk_sdkver", "kv", "auto", "The SDK Version for NDK" } - , } - - -- init global option menu - android._MENU_GLOBAL = android._MENU_GLOBAL or - { {} - , {nil, "ndk", "kv", nil, "The NDK Directory" } - , {nil, "ndk_sdkver", "kv", "auto", "The SDK Version for NDK" } - , } - - -- get the option menu - if action == "config" then - return android._MENU_CONFIG - elseif action == "global" then - return android._MENU_GLOBAL - end -end - --- return module: android -return android diff --git a/xmake/scripts/platform/android/prober.lua b/xmake/scripts/platform/android/prober.lua deleted file mode 100644 index a6446e0e1..000000000 --- a/xmake/scripts/platform/android/prober.lua +++ /dev/null @@ -1,269 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- 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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file prober.lua --- - --- load modules -local os = require("base/os") -local path = require("base/path") -local utils = require("base/utils") -local string = require("base/string") -local tools = require("tools/tools") -local config = require("base/config") -local global = require("base/global") - --- define module: prober -local prober = prober or {} - --- probe the architecture -function prober._probe_arch(configs) - - -- get the architecture - local arch = configs.get("arch") - - -- ok? - if arch then return true end - - -- init the default architecture - configs.set("arch", "armv7-a") - - -- trace - utils.printf("checking for the architecture ... %s", configs.get("arch")) - - -- ok - return true -end - --- probe the sdk version for ndk -function prober._probe_ndk_sdkver(configs) - - -- ok? - local ndk_sdkver = configs.get("ndk_sdkver") - if ndk_sdkver then return true end - - -- get the ndk - local ndk = configs.get("ndk") - if ndk then - - -- match all sdk directories - local sdkdirs = os.match(ndk .. "/platforms/android-*", true) - if sdkdirs then - - -- get the max version - local version_maxn = 0 - for _, sdkdir in ipairs(sdkdirs) do - local filename = path.filename(sdkdir) - local version, count = filename:gsub("android%-", "") - if count > 0 then - version = tonumber(version) - if version > version_maxn then version_maxn = version end - end - end - - -- save the version - if version_maxn > 0 then ndk_sdkver = version_maxn end - end - end - - -- probe ok? update it - if type(ndk_sdkver) == "number" and ndk_sdkver > 0 then - - -- save it - configs.set("ndk_sdkver", ndk_sdkver) - - -- trace - utils.printf("checking for the SDK version of NDK ... %s", string.format("android-%d", ndk_sdkver)) - else - - -- trace - utils.printf("checking for the SDK version of NDK ... no") - end - - -- ok - return true -end - --- probe the make -function prober._probe_make(configs) - - -- ok? - local make = configs.get("make") - if make then return true end - - -- probe the make path - make = tools.probe("make", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"}) - - -- probe ok? update it - if make then configs.set("make", make) end - - -- trace - utils.printf("checking for the make ... %s", utils.ifelse(make, make, "no")) - - -- ok - return true -end - --- probe the ccache -function prober._probe_ccache(configs) - - -- ok? - local ccache_enable = configs.get("ccache") - if ccache_enable and configs.get("__ccache") then return true end - - -- disable? - if type(ccache_enable) == "boolean" and not ccache_enable then - configs.set("__ccache", nil) - return true - end - - -- probe the ccache path - local ccache_path = tools.probe("ccache", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"}) - - -- probe ok? update it - if ccache_path then - configs.set("ccache", true) - configs.set("__ccache", ccache_path) - else - configs.set("ccache", false) - end - - -- trace - utils.printf("checking for the ccache ... %s", utils.ifelse(ccache_path, ccache_path, "no")) - - -- ok - return true -end - --- probe the toolchains -function prober._probe_toolpath(configs, kind, cross, name, description) - - -- check - assert(kind) - - -- get the cross - cross = configs.get("cross") or cross - - -- attempt to get it from the given cross toolchains - local toolpath = nil - local toolchains = configs.get("toolchains") - if toolchains then - toolpath = tools.probe(cross .. (configs.get(kind) or name), toolchains) - end - - -- attempt to get it directly from the configure - if not toolpath then - toolpath = configs.get(kind) - end - - -- attempt to get it from the ndk - if not toolpath then - local ndk = configs.get("ndk") - if ndk then - - -- match all toolchains - local arch = configs.get("arch") - if arch and arch:startswith("arm64") then - toolchains = os.match(string.format("%s/toolchains/aarch64-linux-android-**/prebuilt/*/bin/%s%s", ndk, cross, name)) - else - toolchains = os.match(string.format("%s/toolchains/arm-linux-androideabi-**/prebuilt/*/bin/%s%s", ndk, cross, name)) - end - - -- probe the tool path - if toolchains then - for _, filepath in ipairs(toolchains) do - toolpath = tools.probe(cross .. name, path.directory(filepath)) - if toolpath then break end - end - end - end - end - - -- probe ok? update it - if toolpath then configs.set(kind, toolpath) end - - -- trace - if toolpath then - utils.printf("checking for %s (%s) ... %s", description, kind, path.filename(toolpath)) - else - utils.printf("checking for %s (%s) ... no", description, kind) - end - - -- failed? - if not toolpath and not configs.get("ndk") then - utils.error("checking for the NDK directory ... no") - utils.error(" - xmake config --ndk=xxx") - utils.error("or - xmake global --ndk=xxx") - return false - end - - -- ok - return true -end - --- probe the toolchains -function prober._probe_toolchains(configs) - - -- init prefix - local prefix = "arm-linux-androideabi-" - local arch = configs.get("arch") - if arch and arch:startswith("arm64") then - prefix = "aarch64-linux-android-" - end - - -- done - if not prober._probe_toolpath(configs, "cc", prefix, "gcc", "the c compiler") then return false end - if not prober._probe_toolpath(configs, "cxx", prefix, "g++", "the c++ compiler") then return false end - if not prober._probe_toolpath(configs, "as", prefix, "gcc", "the assember") then return false end - if not prober._probe_toolpath(configs, "ld", prefix, "g++", "the linker") then return false end - if not prober._probe_toolpath(configs, "ar", prefix, "ar", "the static library linker") then return false end - if not prober._probe_toolpath(configs, "sh", prefix, "g++", "the shared library linker") then return false end - if not prober._probe_toolpath(configs, "sc", prefix, "swiftc", "the swift compiler") then return false end - - -- ok - return true -end - --- probe the project configure -function prober.config() - - -- call all probe functions - return utils.call( { prober._probe_arch - , prober._probe_make - , prober._probe_ccache - , prober._probe_ndk_sdkver - , prober._probe_toolchains} - , nil - , config) - -end - --- probe the global configure -function prober.global() - - -- call all probe functions - return utils.call( { prober._probe_make - , prober._probe_ccache - , prober._probe_ndk_sdkver} - , nil - , global) -end - --- return module: prober -return prober diff --git a/xmake/scripts/platform/iphoneos/iphoneos.lua b/xmake/scripts/platform/iphoneos/iphoneos.lua deleted file mode 100644 index f9147945c..000000000 --- a/xmake/scripts/platform/iphoneos/iphoneos.lua +++ /dev/null @@ -1,141 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- 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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file iphoneos.lua --- - --- define module: iphoneos -local iphoneos = iphoneos or {} - --- load modules -local config = require("base/config") - --- init host -iphoneos._HOST = "macosx" - --- init os -iphoneos._OS = "ios" - --- init architectures -iphoneos._ARCHS = {"armv7", "armv7s", "arm64"} - --- make configure -function iphoneos.make(configs) - - -- init the file formats - configs.formats = {} - configs.formats.static = {"lib", ".a"} - configs.formats.object = {"", ".o"} - configs.formats.shared = {"lib", ".dylib"} - - -- init the toolchains - configs.tools = {} - configs.tools.make = config.get("make") - configs.tools.ccache = config.get("__ccache") - configs.tools.cc = config.get("cc") - configs.tools.cxx = config.get("cxx") - configs.tools.mm = config.get("mm") - configs.tools.mxx = config.get("mxx") - configs.tools.as = config.get("as") - configs.tools.ld = config.get("ld") - configs.tools.ar = config.get("ar") - configs.tools.sh = config.get("sh") - configs.tools.ex = config.get("ar") - configs.tools.sc = config.get("sc") - configs.tools.lipo = config.get("lipo") - - -- init target minimal version - local target_minver = config.get("target_minver") - assert(target_minver) - - -- init flags for architecture - local archflags = nil - local arch = config.get("arch") - if arch then archflags = "-arch " .. arch end - configs.cxflags = { archflags, "-miphoneos-version-min=" .. target_minver } - configs.mxflags = { archflags, "-miphoneos-version-min=" .. target_minver } - configs.asflags = { archflags, "-miphoneos-version-min=" .. target_minver } - configs.ldflags = { archflags, "-ObjC", "-lstdc++", "-fobjc-link-runtime", "-miphoneos-version-min=" .. target_minver } - configs.shflags = { archflags, "-ObjC", "-lstdc++", "-fobjc-link-runtime", "-miphoneos-version-min=" .. target_minver } - if arch then - configs.scflags = { string.format("-target %s-apple-ios%s", arch, target_minver) } - end - - -- init flags for the xcode sdk directory - local xcode_dir = config.get("xcode_dir") - local xcode_sdkver = config.get("xcode_sdkver") - if xcode_dir and xcode_sdkver then - - -- init flags - local xcode_sdkdir = xcode_dir .. "/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" .. xcode_sdkver .. ".sdk" - table.insert(configs.cxflags, "-isysroot " .. xcode_sdkdir) - table.insert(configs.asflags, "-isysroot " .. xcode_sdkdir) - table.insert(configs.mxflags, "-isysroot " .. xcode_sdkdir) - table.insert(configs.ldflags, "-isysroot " .. xcode_sdkdir) - table.insert(configs.shflags, "-isysroot " .. xcode_sdkdir) - table.insert(configs.scflags, "-sdk " .. xcode_sdkdir) - - -- save swift link directory - config.set("__swift_linkdirs", xcode_dir .. "/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos") - end - -end - --- get the option menu for action: xmake config or global -function iphoneos.menu(action) - - -- init config option menu - iphoneos._MENU_CONFIG = iphoneos._MENU_CONFIG or - { {} - , {nil, "mm", "kv", nil, "The Objc Compiler" } - , {nil, "mxx", "kv", nil, "The Objc++ Compiler" } - , {nil, "mflags", "kv", nil, "The Objc Compiler Flags" } - , {nil, "mxflags", "kv", nil, "The Objc/c++ Compiler Flags" } - , {nil, "mxxflags", "kv", nil, "The Objc++ Compiler Flags" } - , {} - , {nil, "xcode_dir", "kv", "auto", "The Xcode Application Directory" } - , {nil, "xcode_sdkver", "kv", "auto", "The SDK Version for Xcode" } - , {nil, "target_minver", "kv", "auto", "The Target Minimal Version" } - , {} - , {nil, "mobileprovision","kv", "auto", "The Provisioning Profile File" } - , {nil, "codesign", "kv", "auto", "The Code Signing Indentity" } - , {nil, "entitlements", "kv", "auto", "The Code Signing Entitlements" } - , } - - -- init global option menu - iphoneos._MENU_GLOBAL = iphoneos._MENU_GLOBAL or - { {} - , {nil, "xcode_dir", "kv", "auto", "The Xcode Application Directory" } - , {} - , {nil, "mobileprovision","kv", "auto", "The Provisioning Profile File" } - , {nil, "codesign", "kv", "auto", "The Code Signing Indentity" } - , {nil, "entitlements", "kv", "auto", "The Code Signing Entitlements" } - , } - - -- get the option menu - if action == "config" then - return iphoneos._MENU_CONFIG - elseif action == "global" then - return iphoneos._MENU_GLOBAL - end -end - - --- return module: iphoneos -return iphoneos diff --git a/xmake/scripts/platform/iphoneos/package.lua b/xmake/scripts/platform/iphoneos/package.lua deleted file mode 100644 index 1e46ddadc..000000000 --- a/xmake/scripts/platform/iphoneos/package.lua +++ /dev/null @@ -1,76 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- 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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file package.lua --- - --- define module: package -local package = package or {} - --- load modules -local os = require("base/os") -local path = require("base/path") -local rule = require("base/rule") -local utils = require("base/utils") -local string = require("base/string") -local platform = require("platform/platform") - --- package target -function package.main(target) - - -- check - assert(target and target.name) - - -- the count of architectures - local count = 0 - for _, _ in pairs(target.archs) do count = count + 1 end - if count < 2 then return 0 end - - -- get the lipo tool - local lipo = platform.tool("lipo") - if not lipo then return 0 end - - -- make universal info - local universal = {} - universal.targetdir = rule.backupdir(target.name, "universal") - universal.targetfile = rule.targetfile(target.name, target) - if not universal.targetdir or not universal.targetfile then return 0 end - - -- make the universal directory - os.mkdir(path.directory(string.format("%s/%s", universal.targetdir, universal.targetfile))) - - -- make the lipo command - local cmd = lipo .. " -create" - for arch, info in pairs(target.archs) do - cmd = string.format("%s -arch %s %s/%s", cmd, arch, info.targetdir, info.targetfile) - end - cmd = string.format("%s -output %s/%s", cmd, universal.targetdir, universal.targetfile) - - -- make the universal target - if 0 ~= os.execute(cmd) then return 0 end - - -- ok - target.archs.universal = universal - - -- continue - return 0 -end - --- return module: package -return package diff --git a/xmake/scripts/platform/iphoneos/prober.lua b/xmake/scripts/platform/iphoneos/prober.lua deleted file mode 100644 index 0b4d10dc8..000000000 --- a/xmake/scripts/platform/iphoneos/prober.lua +++ /dev/null @@ -1,310 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- 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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file prober.lua --- - --- load modules -local os = require("base/os") -local path = require("base/path") -local utils = require("base/utils") -local string = require("base/string") -local tools = require("tools/tools") -local config = require("base/config") -local global = require("base/global") - --- define module: prober -local prober = prober or {} - --- probe the architecture -function prober._probe_arch(configs) - - -- get the architecture - local arch = configs.get("arch") - - -- ok? - if arch then return true end - - -- init the default architecture - configs.set("arch", "armv7") - - -- trace - utils.printf("checking for the architecture ... %s", configs.get("arch")) - - -- ok - return true -end - --- probe the xcode application directory -function prober._probe_xcode(configs) - - -- get the xcode directory - local xcode_dir = configs.get("xcode_dir") - - -- ok? - if xcode_dir then return true end - - -- clear it first - xcode_dir = nil - - -- attempt to get the default directory - if not xcode_dir then - if os.isdir("/Applications/Xcode.app") then - xcode_dir = "/Applications/Xcode.app" - end - end - - -- attempt to match the other directories - if not xcode_dir then - local dirs = os.match("/Applications/Xcode*.app", true) - if dirs and table.getn(dirs) ~= 0 then - xcode_dir = dirs[1] - end - end - - -- probe ok? update it - if xcode_dir then - -- save it - configs.set("xcode_dir", xcode_dir) - - -- trace - utils.printf("checking for the Xcode application directory ... %s", xcode_dir) - else - -- failed - utils.error("checking for the Xcode application directory ... no") - utils.error(" - xmake config --xcode_dir=xxx") - utils.error("or - xmake global --xcode_dir=xxx") - return false - end - - -- ok - return true -end - --- probe the xcode sdk version -function prober._probe_xcode_sdkver(configs) - - -- get the xcode sdk version - local xcode_sdkver = configs.get("xcode_sdkver") - - -- ok? - if xcode_sdkver then return true end - - -- clear it first - xcode_sdkver = nil - - -- attempt to match the directory - if not xcode_sdkver then - local dirs = os.match(configs.get("xcode_dir") .. "/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk", true) - if dirs then - for _, dir in ipairs(dirs) do - xcode_sdkver = string.match(dir, "%d+%.%d+") - if xcode_sdkver then break end - end - end - end - - -- probe ok? update it - if xcode_sdkver then - - -- save it - configs.set("xcode_sdkver", xcode_sdkver) - - -- trace - utils.printf("checking for the Xcode SDK version for %s ... %s", configs.get("plat"), xcode_sdkver) - else - -- failed - utils.error("checking for the Xcode SDK version for %s ... no", configs.get("plat")) - utils.error(" - xmake config --xcode_sdkver=xxx") - utils.error("or - xmake global --xcode_sdkver=xxx") - return false - end - - -- ok - return true -end - --- probe the target minimal version -function prober._probe_target_minver(configs) - - -- get the target minimal version - local target_minver = configs.get("target_minver") - - -- ok? - if target_minver then return true end - - -- init the default target minimal version - configs.set("target_minver", "7.0") - - -- trace - utils.printf("checking for the target minimal version ... %s", configs.get("target_minver")) - - -- ok - return true -end - --- probe the make -function prober._probe_make(configs) - - -- ok? - local make = configs.get("make") - if make then return true end - - -- probe the make path - make = tools.probe("make", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"}) - - -- probe ok? update it - if make then configs.set("make", make) end - - -- trace - utils.printf("checking for the make ... %s", utils.ifelse(make, make, "no")) - - -- ok - return true -end - --- probe the ccache -function prober._probe_ccache(configs) - - -- ok? - local ccache_enable = configs.get("ccache") - if ccache_enable and configs.get("__ccache") then return true end - - -- disable? - if type(ccache_enable) == "boolean" and not ccache_enable then - configs.set("__ccache", nil) - return true - end - - -- probe the ccache path - local ccache_path = tools.probe("ccache", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"}) - - -- probe ok? update it - if ccache_path then - configs.set("ccache", true) - configs.set("__ccache", ccache_path) - else - configs.set("ccache", false) - end - - -- trace - utils.printf("checking for the ccache ... %s", utils.ifelse(ccache_path, ccache_path, "no")) - - -- ok - return true -end - --- probe the tool path -function prober._probe_toolpath(configs, kind, cross, names, description) - - -- check - assert(kind) - - -- get the cross - cross = configs.get("cross") or cross - - -- done - local toolpath = nil - local toolchains = configs.get("toolchains") - for _, name in ipairs(utils.wrap(names)) do - - -- attempt to get it from the given cross toolchains - if toolchains then - toolpath = tools.probe(cross .. (configs.get(kind) or name), toolchains) - end - - -- attempt to get it directly from the configure - if not toolpath then - toolpath = configs.get(kind) - end - - -- attempt to run it directly - if not toolpath then - toolpath = tools.probe(cross .. name) - end - - -- probe ok? - if toolpath then - - -- update config - configs.set(kind, toolpath) - - -- end - break - end - - end - - -- trace - if toolpath then - utils.printf("checking for %s (%s) ... %s", description, kind, path.filename(toolpath)) - else - utils.printf("checking for %s (%s) ... no", description, kind) - end - - -- ok - return true -end - --- probe the toolchains -function prober._probe_toolchains(configs) - - -- done - if not prober._probe_toolpath(configs, "cc", "xcrun -sdk iphoneos ", "clang", "the c compiler") then return false end - if not prober._probe_toolpath(configs, "cxx", "xcrun -sdk iphoneos ", {"clang++", "clang"}, "the c++ compiler") then return false end - if not prober._probe_toolpath(configs, "mm", "xcrun -sdk iphoneos ", "clang", "the objc compiler") then return false end - if not prober._probe_toolpath(configs, "mxx", "xcrun -sdk iphoneos ", {"clang++", "clang"}, "the objc++ compiler") then return false end - if not prober._probe_toolpath(configs, "as", xmake._SCRIPTS_DIR .. "/tools/gas-preprocessor.pl xcrun -sdk iphoneos ", "clang", "the assember") then return false end - if not prober._probe_toolpath(configs, "ld", "xcrun -sdk iphoneos ", {"clang++", "clang"}, "the linker") then return false end - if not prober._probe_toolpath(configs, "ar", "xcrun -sdk iphoneos ", "ar", "the static library linker") then return false end - if not prober._probe_toolpath(configs, "sh", "xcrun -sdk iphoneos ", {"clang++", "clang"}, "the shared library linker") then return false end - if not prober._probe_toolpath(configs, "sc", "xcrun -sdk iphoneos ", "swiftc", "the swift compiler") then return false end - if not prober._probe_toolpath(configs, "lipo", "xcrun -sdk iphoneos ", "lipo", "the universal files creater") then return false end - return true -end - --- probe the project configure -function prober.config() - - -- call all probe functions - return utils.call( { prober._probe_arch - , prober._probe_xcode - , prober._probe_xcode_sdkver - , prober._probe_target_minver - , prober._probe_make - , prober._probe_ccache - , prober._probe_toolchains} - , nil - , config) - -end - --- probe the global configure -function prober.global() - - -- call all probe functions - return utils.call( { prober._probe_xcode - , prober._probe_make - , prober._probe_ccache} - , nil - , global) -end - --- return module: prober -return prober diff --git a/xmake/scripts/platform/iphonesimulator/iphonesimulator.lua b/xmake/scripts/platform/iphonesimulator/iphonesimulator.lua deleted file mode 100644 index 4ceeb3eca..000000000 --- a/xmake/scripts/platform/iphonesimulator/iphonesimulator.lua +++ /dev/null @@ -1,138 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- 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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file iphonesimulator.lua --- - --- define module: iphonesimulator -local iphonesimulator = iphonesimulator or {} - --- load modules -local config = require("base/config") - --- init host -iphonesimulator._HOST = "macosx" - --- init os -iphonesimulator._OS = "ios" - --- init architectures -iphonesimulator._ARCHS = {"i386", "x86_64"} - --- make configure -function iphonesimulator.make(configs) - - -- init the file formats - configs.formats = {} - configs.formats.static = {"lib", ".a"} - configs.formats.object = {"", ".o"} - configs.formats.shared = {"lib", ".dylib"} - - -- init the toolchains - configs.tools = {} - configs.tools.make = config.get("make") - configs.tools.ccache = config.get("__ccache") - configs.tools.cc = config.get("cc") - configs.tools.cxx = config.get("cxx") - configs.tools.mm = config.get("mm") - configs.tools.mxx = config.get("mxx") - configs.tools.ld = config.get("ld") - configs.tools.ar = config.get("ar") - configs.tools.sh = config.get("sh") - configs.tools.ex = config.get("ar") - configs.tools.sc = config.get("sc") - - -- init target minimal version - local target_minver = config.get("target_minver") - assert(target_minver) - - -- init flags for architecture - local archflags = nil - local arch = config.get("arch") - if arch then archflags = "-arch " .. arch end - configs.cxflags = { archflags, "-mios-simulator-version-min=" .. target_minver } - configs.mxflags = { archflags, "-mios-simulator-version-min=" .. target_minver } - configs.asflags = { archflags, "-mios-simulator-version-min=" .. target_minver } - configs.ldflags = { archflags, "-Xlinker -objc_abi_version", "-Xlinker 2 -stdlib=libc++", "-Xlinker -no_implicit_dylibs", "-fobjc-link-runtime", "-mios-simulator-version-min=" .. target_minver } - configs.shflags = { archflags, "-Xlinker -objc_abi_version", "-Xlinker 2 -stdlib=libc++", "-Xlinker -no_implicit_dylibs", "-fobjc-link-runtime", "-mios-simulator-version-min=" .. target_minver } - if arch then - configs.scflags = { string.format("-target %s-apple-ios%s", arch, target_minver) } - end - - -- init flags for the xcode sdk directory - local xcode_dir = config.get("xcode_dir") - local xcode_sdkver = config.get("xcode_sdkver") - if xcode_dir and xcode_sdkver then - - -- init flags - local xcode_sdkdir = xcode_dir .. "/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" .. xcode_sdkver .. ".sdk" - table.insert(configs.cxflags, "-isysroot " .. xcode_sdkdir) - table.insert(configs.asflags, "-isysroot " .. xcode_sdkdir) - table.insert(configs.mxflags, "-isysroot " .. xcode_sdkdir) - table.insert(configs.ldflags, "-isysroot " .. xcode_sdkdir) - table.insert(configs.shflags, "-isysroot " .. xcode_sdkdir) - table.insert(configs.scflags, "-sdk " .. xcode_sdkdir) - - -- save swift link directory - config.set("__swift_linkdirs", xcode_dir .. "/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator") - end -end - --- get the option menu for action: xmake config or global -function iphonesimulator.menu(action) - - -- init config option menu - iphonesimulator._MENU_CONFIG = iphonesimulator._MENU_CONFIG or - { {} - , {nil, "mm", "kv", nil, "The Objc Compiler" } - , {nil, "mxx", "kv", nil, "The Objc++ Compiler" } - , {nil, "mflags", "kv", nil, "The Objc Compiler Flags" } - , {nil, "mxflags", "kv", nil, "The Objc/c++ Compiler Flags" } - , {nil, "mxxflags", "kv", nil, "The Objc++ Compiler Flags" } - , {} - , {nil, "xcode_dir", "kv", "auto", "The Xcode Application Directory" } - , {nil, "xcode_sdkver", "kv", "auto", "The SDK Version for Xcode" } - , {nil, "target_minver", "kv", "auto", "The Target Minimal Version" } - , {} - , {nil, "mobileprovision","kv", "auto", "The Provisioning Profile File" } - , {nil, "codesign", "kv", "auto", "The Code Signing Indentity" } - , {nil, "entitlements", "kv", "auto", "The Code Signing Entitlements" } - , } - - -- init global option menu - iphonesimulator._MENU_GLOBAL = iphonesimulator._MENU_GLOBAL or - { {} - , {nil, "xcode_dir", "kv", "auto", "The Xcode Application Directory" } - , {} - , {nil, "mobileprovision","kv", "auto", "The Provisioning Profile File" } - , {nil, "codesign", "kv", "auto", "The Code Signing Indentity" } - , {nil, "entitlements", "kv", "auto", "The Code Signing Entitlements" } - , } - - -- get the option menu - if action == "config" then - return iphonesimulator._MENU_CONFIG - elseif action == "global" then - return iphonesimulator._MENU_GLOBAL - end -end - - --- return module: iphonesimulator -return iphonesimulator diff --git a/xmake/scripts/platform/iphonesimulator/prober.lua b/xmake/scripts/platform/iphonesimulator/prober.lua deleted file mode 100644 index a4c69c72a..000000000 --- a/xmake/scripts/platform/iphonesimulator/prober.lua +++ /dev/null @@ -1,308 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- 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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file prober.lua --- - --- load modules -local os = require("base/os") -local path = require("base/path") -local utils = require("base/utils") -local string = require("base/string") -local tools = require("tools/tools") -local config = require("base/config") -local global = require("base/global") - --- define module: prober -local prober = prober or {} - --- probe the architecture -function prober._probe_arch(configs) - - -- get the architecture - local arch = configs.get("arch") - - -- ok? - if arch then return true end - - -- init the default architecture - configs.set("arch", "x86_64") - - -- trace - utils.printf("checking for the architecture ... %s", configs.get("arch")) - - -- ok - return true -end - --- probe the xcode application directory -function prober._probe_xcode(configs) - - -- get the xcode directory - local xcode_dir = configs.get("xcode_dir") - - -- ok? - if xcode_dir then return true end - - -- clear it first - xcode_dir = nil - - -- attempt to get the default directory - if not xcode_dir then - if os.isdir("/Applications/Xcode.app") then - xcode_dir = "/Applications/Xcode.app" - end - end - - -- attempt to match the other directories - if not xcode_dir then - local dirs = os.match("/Applications/Xcode*.app", true) - if dirs and table.getn(dirs) ~= 0 then - xcode_dir = dirs[1] - end - end - - -- probe ok? update it - if xcode_dir then - -- save it - configs.set("xcode_dir", xcode_dir) - - -- trace - utils.printf("checking for the Xcode application directory ... %s", xcode_dir) - else - -- failed - utils.error("checking for the Xcode application directory ... no") - utils.error(" - xmake config --xcode_dir=xxx") - utils.error("or - xmake global --xcode_dir=xxx") - return false - end - - -- ok - return true -end - --- probe the xcode sdk version -function prober._probe_xcode_sdkver(configs) - - -- get the xcode sdk version - local xcode_sdkver = configs.get("xcode_sdkver") - - -- ok? - if xcode_sdkver then return true end - - -- clear it first - xcode_sdkver = nil - - -- attempt to match the directory - if not xcode_sdkver then - local dirs = os.match(configs.get("xcode_dir") .. "/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator*.sdk", true) - if dirs then - for _, dir in ipairs(dirs) do - xcode_sdkver = string.match(dir, "%d+%.%d+") - if xcode_sdkver then break end - end - end - end - - -- probe ok? update it - if xcode_sdkver then - - -- save it - configs.set("xcode_sdkver", xcode_sdkver) - - -- trace - utils.printf("checking for the Xcode SDK version for %s ... %s", configs.get("plat"), xcode_sdkver) - else - -- failed - utils.error("checking for the Xcode SDK version for %s ... no", configs.get("plat")) - utils.error(" - xmake config --xcode_sdkver=xxx") - utils.error("or - xmake global --xcode_sdkver=xxx") - return false - end - - -- ok - return true -end - --- probe the target minimal version -function prober._probe_target_minver(configs) - - -- get the target minimal version - local target_minver = configs.get("target_minver") - - -- ok? - if target_minver then return true end - - -- init the default target minimal version - configs.set("target_minver", "7.0") - - -- trace - utils.printf("checking for the target minimal version ... %s", configs.get("target_minver")) - - -- ok - return true -end - --- probe the make -function prober._probe_make(configs) - - -- ok? - local make = configs.get("make") - if make then return true end - - -- probe the make path - make = tools.probe("make", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"}) - - -- probe ok? update it - if make then configs.set("make", make) end - - -- trace - utils.printf("checking for the make ... %s", utils.ifelse(make, make, "no")) - - -- ok - return true -end - --- probe the ccache -function prober._probe_ccache(configs) - - -- ok? - local ccache_enable = configs.get("ccache") - if ccache_enable and configs.get("__ccache") then return true end - - -- disable? - if type(ccache_enable) == "boolean" and not ccache_enable then - configs.set("__ccache", nil) - return true - end - - -- probe the ccache path - local ccache_path = tools.probe("ccache", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"}) - - -- probe ok? update it - if ccache_path then - configs.set("ccache", true) - configs.set("__ccache", ccache_path) - else - configs.set("ccache", false) - end - - -- trace - utils.printf("checking for the ccache ... %s", utils.ifelse(ccache_path, ccache_path, "no")) - - -- ok - return true -end - --- probe the tool path -function prober._probe_toolpath(configs, kind, cross, names, description) - - -- check - assert(kind) - - -- get the cross - cross = configs.get("cross") or cross - - -- done - local toolpath = nil - local toolchains = configs.get("toolchains") - for _, name in ipairs(utils.wrap(names)) do - - -- attempt to get it from the given cross toolchains - if toolchains then - toolpath = tools.probe(cross .. (configs.get(kind) or name), toolchains) - end - - -- attempt to get it directly from the configure - if not toolpath then - toolpath = configs.get(kind) - end - - -- attempt to run it directly - if not toolpath then - toolpath = tools.probe(cross .. name) - end - - -- probe ok? - if toolpath then - - -- update config - configs.set(kind, toolpath) - - -- end - break - end - - end - - -- trace - if toolpath then - utils.printf("checking for %s (%s) ... %s", description, kind, path.filename(toolpath)) - else - utils.printf("checking for %s (%s) ... no", description, kind) - end - - -- ok - return true -end - --- probe the toolchains -function prober._probe_toolchains(configs) - - -- done - if not prober._probe_toolpath(configs, "cc", "xcrun -sdk iphonesimulator ", "clang", "the c compiler") then return false end - if not prober._probe_toolpath(configs, "cxx", "xcrun -sdk iphonesimulator ", {"clang++", "clang"}, "the c++ compiler") then return false end - if not prober._probe_toolpath(configs, "mm", "xcrun -sdk iphonesimulator ", "clang", "the objc compiler") then return false end - if not prober._probe_toolpath(configs, "mxx", "xcrun -sdk iphonesimulator ", {"clang++", "clang"}, "the objc++ compiler") then return false end - if not prober._probe_toolpath(configs, "as", "xcrun -sdk iphonesimulator ", "clang", "the assember") then return false end - if not prober._probe_toolpath(configs, "ld", "xcrun -sdk iphonesimulator ", {"clang++", "clang"}, "the linker") then return false end - if not prober._probe_toolpath(configs, "ar", "xcrun -sdk iphonesimulator ", "ar", "the static library linker") then return false end - if not prober._probe_toolpath(configs, "sh", "xcrun -sdk iphonesimulator ", {"clang++", "clang"}, "the shared library linker") then return false end - if not prober._probe_toolpath(configs, "sc", "xcrun -sdk iphonesimulator ", "swiftc", "the swift compiler") then return false end - return true -end - --- probe the project configure -function prober.config() - - -- call all probe functions - return utils.call( { prober._probe_arch - , prober._probe_xcode - , prober._probe_xcode_sdkver - , prober._probe_target_minver - , prober._probe_make - , prober._probe_ccache - , prober._probe_toolchains} - , nil - , config) -end - --- probe the global configure -function prober.global() - - -- call all probe functions - return utils.call( { prober._probe_xcode - , prober._probe_make - , prober._probe_ccache} - , nil - , global) -end - --- return module: prober -return prober diff --git a/xmake/scripts/platform/linux/install.lua b/xmake/scripts/platform/linux/install.lua deleted file mode 100644 index 870cf5040..000000000 --- a/xmake/scripts/platform/linux/install.lua +++ /dev/null @@ -1,182 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- 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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file install.lua --- - --- define module: install -local install = install or {} - --- load modules -local os = require("base/os") -local path = require("base/path") -local rule = require("base/rule") -local utils = require("base/utils") -local string = require("base/string") -local platform = require("platform/platform") - --- install target for the library file -function install._done_library(target) - - -- check - assert(target and target.name and target.archs) - - -- the output directory - local outputdir = target.outputdir or "/usr/local" - assert(outputdir) - - -- get target info - local info = target.archs[xmake._ARCH] or target.archs["x86_64"] or target.archs["i386"] - if not info then return -1 end - - -- check - assert(info.targetdir and info.targetfile) - - -- make the library directory - local librarydir = outputdir .. "/lib" - if not os.isdir(librarydir) then - if not os.mkdir(librarydir) then - utils.error("create directory %s failed", librarydir) - return -1 - end - end - - -- copy the library file to the library directory - local ok, errors = os.cp(string.format("%s/%s", info.targetdir, info.targetfile), string.format("%s/%s", librarydir, path.filename(info.targetfile))) - if not ok then - utils.error(errors) - return -1 - end - - -- make the include directory - local includedir = outputdir .. "/include" - if not os.isdir(includedir) then - if not os.mkdir(includedir) then - utils.error("create directory %s failed", includedir) - return -1 - end - end - - -- copy the config.h to the output directory - if info.config_h then - local ok, errors = os.cp(string.format("%s/%s", info.targetdir, info.config_h), string.format("%s/%s/%s", includedir, target.name, path.filename(info.config_h))) - if not ok then - utils.error(errors) - return -1 - end - - -- update the config.h - info.config_h = string.format("%s/%s/%s", includedir, target.name, path.filename(info.config_h)) - end - - -- copy headers - if target.headers then - local srcheaders, dstheaders = rule.headerfiles(target, includedir) - if srcheaders and dstheaders then - local i = 1 - for _, srcheader in ipairs(srcheaders) do - local dstheader = dstheaders[i] - if dstheader then - local ok, errors = os.cp(srcheader, dstheader) - if not ok then - utils.error(errors) - return -1 - end - end - i = i + 1 - end - end - - -- update the headers - target.headers = dstheaders - end - - -- update the target directory and file - info.targetdir = librarydir - info.targetfile = path.filename(info.targetfile) - - -- ok - return 1 -end - --- install target for the binary file -function install._done_binary(target) - - -- check - assert(target and target.archs) - - -- the output directory - local outputdir = target.outputdir or "/usr/local" - assert(outputdir) - - -- make the binary directory - local binarydir = outputdir .. "/bin" - if not os.isdir(binarydir) then - if not os.mkdir(binarydir) then - utils.error("create directory %s failed", binarydir) - return -1 - end - end - - -- get target info - local info = target.archs[xmake._ARCH] or target.archs["x86_64"] or target.archs["i386"] - if not info then return -1 end - - -- check - assert(info.targetdir and info.targetfile) - - -- copy the binary file to the binary directory - local ok, errors = os.cp(string.format("%s/%s", info.targetdir, info.targetfile), binarydir) - if not ok then - utils.error(errors) - return -1 - end - - -- update the target directory and file - info.targetdir = binarydir - info.targetfile = path.filename(info.targetfile) - - -- ok - return 1 -end - --- install target -function install.main(target) - - -- check - assert(target and target.kind) - - -- the install scripts - local installscripts = - { - static = install._done_library - , shared = install._done_library - , binary = install._done_binary - } - - -- install it - local installscript = installscripts[target.kind] - if installscript then return installscript(target) end - - -- continue - return 0 -end - --- return module: install -return install diff --git a/xmake/scripts/platform/linux/linux.lua b/xmake/scripts/platform/linux/linux.lua deleted file mode 100644 index 406dc5c58..000000000 --- a/xmake/scripts/platform/linux/linux.lua +++ /dev/null @@ -1,103 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- 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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file linux.lua --- - --- define module: linux -local linux = linux or {} - --- load modules -local config = require("base/config") - --- init host -linux._HOST = "linux" - --- init os -linux._OS = "linux" - --- init architectures -linux._ARCHS = {"i386", "x86_64"} - --- make configure -function linux.make(configs) - - -- init the file formats - configs.formats = {} - configs.formats.static = {"lib", ".a"} - configs.formats.object = {"", ".o"} - configs.formats.shared = {"lib", ".so"} - - -- init the toolchains - configs.tools = {} - configs.tools.make = config.get("make") - configs.tools.ccache = config.get("__ccache") - configs.tools.cc = config.get("cc") - configs.tools.cxx = config.get("cxx") - configs.tools.mm = config.get("mm") - configs.tools.mxx = config.get("mxx") - configs.tools.ld = config.get("ld") - configs.tools.ar = config.get("ar") - configs.tools.sh = config.get("sh") - configs.tools.ex = config.get("ar") - configs.tools.sc = config.get("sc") - - -- cross toolchains? - if config.get("cross") then return 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 - configs.cxflags = { archflags } - configs.mxflags = { archflags } - configs.asflags = { archflags } - configs.ldflags = { archflags } - configs.shflags = { archflags } - - -- init linkdirs and includedirs - configs.linkdirs = {"/usr/lib", "/usr/local/lib"} - configs.includedirs = {"/usr/include", "/usr/local/include"} - -end - --- get the option menu for action: xmake config or global -function linux.menu(action) - - -- init config option menu - linux._MENU_CONFIG = linux._MENU_CONFIG or {} - - -- init global option menu - linux._MENU_GLOBAL = linux._MENU_GLOBAL or {} - - -- get the option menu - if action == "config" then - return linux._MENU_CONFIG - elseif action == "global" then - return linux._MENU_GLOBAL - end -end - --- return module: linux -return linux diff --git a/xmake/scripts/platform/linux/prober.lua b/xmake/scripts/platform/linux/prober.lua deleted file mode 100644 index 4e50b13cf..000000000 --- a/xmake/scripts/platform/linux/prober.lua +++ /dev/null @@ -1,198 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- 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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file prober.lua --- - --- load modules -local os = require("base/os") -local path = require("base/path") -local utils = require("base/utils") -local string = require("base/string") -local tools = require("tools/tools") -local config = require("base/config") -local global = require("base/global") - --- define module: prober -local prober = prober or {} - --- probe the architecture -function prober._probe_arch(configs) - - -- get the architecture - local arch = configs.get("arch") - - -- ok? - if arch then return true end - - -- init the default architecture - if configs.get("cross") then - configs.set("arch", "none") - else - configs.set("arch", xmake._ARCH) - end - - -- trace - utils.printf("checking for the architecture ... %s", configs.get("arch")) - - -- ok - return true -end - --- probe the make -function prober._probe_make(configs) - - -- ok? - local make = configs.get("make") - if make then return true end - - -- probe the make path - make = tools.probe("make", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"}) - - -- probe ok? update it - if make then configs.set("make", make) end - - -- trace - utils.printf("checking for the make ... %s", utils.ifelse(make, make, "no")) - - -- ok - return true -end - --- probe the ccache -function prober._probe_ccache(configs) - - -- ok? - local ccache_enable = configs.get("ccache") - if ccache_enable and configs.get("__ccache") then return true end - - -- disable? - if type(ccache_enable) == "boolean" and not ccache_enable then - configs.set("__ccache", nil) - return true - end - - -- probe the ccache path - local ccache_path = tools.probe("ccache", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"}) - - -- probe ok? update it - if ccache_path then - configs.set("ccache", true) - configs.set("__ccache", ccache_path) - else - configs.set("ccache", false) - end - - -- trace - utils.printf("checking for the ccache ... %s", utils.ifelse(ccache_path, ccache_path, "no")) - - -- ok - return true -end - --- probe the tool path -function prober._probe_toolpath(configs, kind, cross, names, description) - - -- check - assert(kind) - - -- get the cross - cross = configs.get("cross") or cross - - -- done - local toolpath = nil - local toolchains = configs.get("toolchains") - for _, name in ipairs(utils.wrap(names)) do - - -- attempt to get it from the given cross toolchains - if toolchains then - toolpath = tools.probe(cross .. (configs.get(kind) or name), toolchains) - end - - -- attempt to get it directly from the configure - if not toolpath then - toolpath = configs.get(kind) - end - - -- attempt to run it directly - if not toolpath then - toolpath = tools.probe(cross .. name) - end - - -- probe ok? - if toolpath then - - -- update config - configs.set(kind, toolpath) - - -- end - break - end - - end - - -- trace - if toolpath then - utils.printf("checking for %s (%s) ... %s", description, kind, path.filename(toolpath)) - else - utils.printf("checking for %s (%s) ... no", description, kind) - end - - -- ok - return true -end - --- probe the toolchains -function prober._probe_toolchains(configs) - - -- done - if not prober._probe_toolpath(configs, "cc", "", "gcc", "the c compiler") then return false end - if not prober._probe_toolpath(configs, "cxx", "", {"g++", "gcc"}, "the c++ compiler") then return false end - if not prober._probe_toolpath(configs, "as", "", "gcc", "the assember") then return false end - if not prober._probe_toolpath(configs, "ld", "", {"g++", "gcc"}, "the linker") then return false end - if not prober._probe_toolpath(configs, "ar", "", "ar", "the static library linker") then return false end - if not prober._probe_toolpath(configs, "sh", "", {"g++", "gcc"}, "the shared library linker") then return false end - if not prober._probe_toolpath(configs, "sc", "", "swiftc", "the swift compiler") then return false end - return true -end - --- probe the project configure -function prober.config() - - -- call all probe functions - return utils.call( { prober._probe_arch - , prober._probe_make - , prober._probe_ccache - , prober._probe_toolchains} - , nil - , config) -end - --- probe the global configure -function prober.global() - - -- call all probe functions - return utils.call( { prober._probe_make - , prober._probe_ccache} - , nil - , global) -end - --- return module: prober -return prober diff --git a/xmake/scripts/platform/linux/uninstall.lua b/xmake/scripts/platform/linux/uninstall.lua deleted file mode 100644 index 468692620..000000000 --- a/xmake/scripts/platform/linux/uninstall.lua +++ /dev/null @@ -1,134 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- 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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file uninstall.lua --- - --- define module: uninstall -local uninstall = uninstall or {} - --- load modules -local os = require("base/os") -local path = require("base/path") -local rule = require("base/rule") -local utils = require("base/utils") -local string = require("base/string") -local platform = require("platform/platform") - --- uninstall target for the library file -function uninstall._done_library(target) - - -- check - assert(target and target.name and target.archs) - - -- get target info - local info = target.archs[xmake._ARCH] or target.archs["x86_64"] or target.archs["i386"] - if not info then return -1 end - - -- check - assert(info.targetdir and info.targetfile) - - -- remove the target file - local targetfile = info.targetdir .. "/" .. info.targetfile - if os.isfile(targetfile) then - local ok, errors = os.rm(targetfile) - if not ok then - utils.error(errors) - return -1 - end - end - - -- remove config.h - if info.config_h and os.isfile(info.config_h) then - local ok, errors = os.rm(info.config_h) - if not ok then - utils.error(errors) - return -1 - end - end - - -- remove headers - if target.headers then - for _, header in ipairs(target.headers) do - if os.isfile(header) then - local ok, errors = os.rm(header) - if not ok then - utils.error(errors) - return -1 - end - end - end - end - - -- ok - return 1 -end - --- uninstall target for the binary file -function uninstall._done_binary(target) - - -- check - assert(target and target.archs) - - -- get target info - local info = target.archs[xmake._ARCH] or target.archs["x86_64"] or target.archs["i386"] - if not info then return -1 end - - -- check - assert(info.targetdir and info.targetfile) - - -- the target file - local targetfile = info.targetdir .. "/" .. info.targetfile - if not os.isfile(targetfile) then return 1 end - - -- remove the target file - local ok, errors = os.rm(targetfile) - if not ok then - utils.error(errors) - return -1 - end - - -- ok - return 1 -end - --- uninstall target -function uninstall.main(target) - - -- check - assert(target and target.kind) - - -- the uninstall scripts - local uninstallscripts = - { - static = uninstall._done_library - , shared = uninstall._done_library - , binary = uninstall._done_binary - } - - -- uninstall it - local uninstallscript = uninstallscripts[target.kind] - if uninstallscript then return uninstallscript(target) end - - -- continue - return 0 -end - --- return module: uninstall -return uninstall diff --git a/xmake/scripts/platform/macosx/install.lua b/xmake/scripts/platform/macosx/install.lua deleted file mode 100644 index 870cf5040..000000000 --- a/xmake/scripts/platform/macosx/install.lua +++ /dev/null @@ -1,182 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- 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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file install.lua --- - --- define module: install -local install = install or {} - --- load modules -local os = require("base/os") -local path = require("base/path") -local rule = require("base/rule") -local utils = require("base/utils") -local string = require("base/string") -local platform = require("platform/platform") - --- install target for the library file -function install._done_library(target) - - -- check - assert(target and target.name and target.archs) - - -- the output directory - local outputdir = target.outputdir or "/usr/local" - assert(outputdir) - - -- get target info - local info = target.archs[xmake._ARCH] or target.archs["x86_64"] or target.archs["i386"] - if not info then return -1 end - - -- check - assert(info.targetdir and info.targetfile) - - -- make the library directory - local librarydir = outputdir .. "/lib" - if not os.isdir(librarydir) then - if not os.mkdir(librarydir) then - utils.error("create directory %s failed", librarydir) - return -1 - end - end - - -- copy the library file to the library directory - local ok, errors = os.cp(string.format("%s/%s", info.targetdir, info.targetfile), string.format("%s/%s", librarydir, path.filename(info.targetfile))) - if not ok then - utils.error(errors) - return -1 - end - - -- make the include directory - local includedir = outputdir .. "/include" - if not os.isdir(includedir) then - if not os.mkdir(includedir) then - utils.error("create directory %s failed", includedir) - return -1 - end - end - - -- copy the config.h to the output directory - if info.config_h then - local ok, errors = os.cp(string.format("%s/%s", info.targetdir, info.config_h), string.format("%s/%s/%s", includedir, target.name, path.filename(info.config_h))) - if not ok then - utils.error(errors) - return -1 - end - - -- update the config.h - info.config_h = string.format("%s/%s/%s", includedir, target.name, path.filename(info.config_h)) - end - - -- copy headers - if target.headers then - local srcheaders, dstheaders = rule.headerfiles(target, includedir) - if srcheaders and dstheaders then - local i = 1 - for _, srcheader in ipairs(srcheaders) do - local dstheader = dstheaders[i] - if dstheader then - local ok, errors = os.cp(srcheader, dstheader) - if not ok then - utils.error(errors) - return -1 - end - end - i = i + 1 - end - end - - -- update the headers - target.headers = dstheaders - end - - -- update the target directory and file - info.targetdir = librarydir - info.targetfile = path.filename(info.targetfile) - - -- ok - return 1 -end - --- install target for the binary file -function install._done_binary(target) - - -- check - assert(target and target.archs) - - -- the output directory - local outputdir = target.outputdir or "/usr/local" - assert(outputdir) - - -- make the binary directory - local binarydir = outputdir .. "/bin" - if not os.isdir(binarydir) then - if not os.mkdir(binarydir) then - utils.error("create directory %s failed", binarydir) - return -1 - end - end - - -- get target info - local info = target.archs[xmake._ARCH] or target.archs["x86_64"] or target.archs["i386"] - if not info then return -1 end - - -- check - assert(info.targetdir and info.targetfile) - - -- copy the binary file to the binary directory - local ok, errors = os.cp(string.format("%s/%s", info.targetdir, info.targetfile), binarydir) - if not ok then - utils.error(errors) - return -1 - end - - -- update the target directory and file - info.targetdir = binarydir - info.targetfile = path.filename(info.targetfile) - - -- ok - return 1 -end - --- install target -function install.main(target) - - -- check - assert(target and target.kind) - - -- the install scripts - local installscripts = - { - static = install._done_library - , shared = install._done_library - , binary = install._done_binary - } - - -- install it - local installscript = installscripts[target.kind] - if installscript then return installscript(target) end - - -- continue - return 0 -end - --- return module: install -return install diff --git a/xmake/scripts/platform/macosx/macosx.lua b/xmake/scripts/platform/macosx/macosx.lua deleted file mode 100644 index 088a01c18..000000000 --- a/xmake/scripts/platform/macosx/macosx.lua +++ /dev/null @@ -1,140 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- 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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file macosx.lua --- - --- define module: macosx -local macosx = macosx or {} - --- load modules -local config = require("base/config") - --- init host -macosx._HOST = "macosx" - --- init os -macosx._OS = "macosx" - --- init architectures -macosx._ARCHS = {"i386", "x86_64"} - --- make configure -function macosx.make(configs) - - -- init the file formats - configs.formats = {} - configs.formats.static = {"lib", ".a"} - configs.formats.object = {"", ".o"} - configs.formats.shared = {"lib", ".dylib"} - - -- init the toolchains - configs.tools = {} - configs.tools.make = config.get("make") - configs.tools.ccache = config.get("__ccache") - configs.tools.cc = config.get("cc") - configs.tools.cxx = config.get("cxx") - configs.tools.mm = config.get("mm") - configs.tools.mxx = config.get("mxx") - configs.tools.ld = config.get("ld") - configs.tools.ar = config.get("ar") - configs.tools.sh = config.get("sh") - configs.tools.ex = config.get("ar") - configs.tools.sc = config.get("sc") - - -- init target minimal version - local target_minver = config.get("target_minver") - assert(target_minver) - - -- init flags for architecture - local archflags = nil - local arch = config.get("arch") - if arch then archflags = "-arch " .. arch end - configs.cxflags = { archflags, "-fpascal-strings", "-fmessage-length=0" } - configs.mxflags = { archflags, "-fpascal-strings", "-fmessage-length=0" } - configs.asflags = { archflags } - configs.ldflags = { archflags, "-mmacosx-version-min=" .. target_minver, "-stdlib=libc++", "-lz" } - configs.shflags = { archflags, "-mmacosx-version-min=" .. target_minver, "-stdlib=libc++", "-lz" } - if arch then - configs.scflags = { string.format("-target %s-apple-macosx%s", arch, target_minver) } - end - - -- init flags for the xcode sdk directory - local xcode_dir = config.get("xcode_dir") - local xcode_sdkver = config.get("xcode_sdkver") - if xcode_dir and xcode_sdkver then - - -- init flags - local xcode_sdkdir = xcode_dir .. "/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX" .. xcode_sdkver .. ".sdk" - table.insert(configs.cxflags, "-isysroot " .. xcode_sdkdir) - table.insert(configs.asflags, "-isysroot " .. xcode_sdkdir) - table.insert(configs.mxflags, "-isysroot " .. xcode_sdkdir) - table.insert(configs.ldflags, "-isysroot " .. xcode_sdkdir) - table.insert(configs.shflags, "-isysroot " .. xcode_sdkdir) - table.insert(configs.scflags, "-sdk " .. xcode_sdkdir) - - -- save swift link directory - config.set("__swift_linkdirs", xcode_dir .. "/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx") - end - - -- init linkdirs - configs.linkdirs = {"/usr/lib", "/usr/local/lib"} - - -- init includedirs - -- - -- @note - -- cannot use configs.includedirs because the swift/objc compiler will compile code failed - table.insert(configs.cxflags, "-I/usr/include") - table.insert(configs.cxflags, "-I/usr/local/include") - -end - --- get the option menu for action: xmake config or global -function macosx.menu(action) - - -- init config option menu - macosx._MENU_CONFIG = macosx._MENU_CONFIG or - { {} - , {nil, "mm", "kv", nil, "The Objc Compiler" } - , {nil, "mxx", "kv", nil, "The Objc++ Compiler" } - , {nil, "mflags", "kv", nil, "The Objc Compiler Flags" } - , {nil, "mxflags", "kv", nil, "The Objc/c++ Compiler Flags" } - , {nil, "mxxflags", "kv", nil, "The Objc++ Compiler Flags" } - , {} - , {nil, "xcode_dir", "kv", "auto", "The Xcode Application Directory" } - , {nil, "xcode_sdkver", "kv", "auto", "The SDK Version for Xcode" } - , {nil, "target_minver", "kv", "auto", "The Target Minimal Version" } - , } - - -- init global option menu - macosx._MENU_GLOBAL = macosx._MENU_GLOBAL or - { {} - , {nil, "xcode_dir", "kv", "auto", "The Xcode Application Directory" } - , } - - -- get the option menu - if action == "config" then - return macosx._MENU_CONFIG - elseif action == "global" then - return macosx._MENU_GLOBAL - end -end - --- return module: macosx -return macosx diff --git a/xmake/scripts/platform/macosx/prober.lua b/xmake/scripts/platform/macosx/prober.lua deleted file mode 100644 index e2571fdd9..000000000 --- a/xmake/scripts/platform/macosx/prober.lua +++ /dev/null @@ -1,307 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- 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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file prober.lua --- - --- load modules -local os = require("base/os") -local path = require("base/path") -local utils = require("base/utils") -local string = require("base/string") -local tools = require("tools/tools") -local config = require("base/config") -local global = require("base/global") - --- define module: prober -local prober = prober or {} - --- probe the architecture -function prober._probe_arch(configs) - - -- get the architecture - local arch = configs.get("arch") - - -- ok? - if arch then return true end - - -- init the default architecture - configs.set("arch", xmake._ARCH) - - -- trace - utils.printf("checking for the architecture ... %s", configs.get("arch")) - - -- ok - return true -end - --- probe the xcode application directory -function prober._probe_xcode(configs) - - -- get the xcode directory - local xcode_dir = configs.get("xcode_dir") - - -- ok? - if xcode_dir then return true end - - -- clear it first - xcode_dir = nil - - -- attempt to get the default directory - if not xcode_dir then - if os.isdir("/Applications/Xcode.app") then - xcode_dir = "/Applications/Xcode.app" - end - end - - -- attempt to match the other directories - if not xcode_dir then - local dirs = os.match("/Applications/Xcode*.app", true) - if dirs and table.getn(dirs) ~= 0 then - xcode_dir = dirs[1] - end - end - - -- probe ok? update it - if xcode_dir then - -- save it - configs.set("xcode_dir", xcode_dir) - - -- trace - utils.printf("checking for the Xcode application directory ... %s", xcode_dir) - else - -- failed - utils.error("checking for the Xcode application directory ... no") - utils.error(" - xmake config --xcode_dir=xxx") - utils.error("or - xmake global --xcode_dir=xxx") - return false - end - - -- ok - return true -end - --- probe the xcode sdk version -function prober._probe_xcode_sdkver(configs) - - -- get the xcode sdk version - local xcode_sdkver = configs.get("xcode_sdkver") - - -- ok? - if xcode_sdkver then return true end - - -- clear it first - xcode_sdkver = nil - - -- attempt to match the directory - if not xcode_sdkver then - local dirs = os.match(configs.get("xcode_dir") .. "/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX*.sdk", true) - if dirs then - for _, dir in ipairs(dirs) do - xcode_sdkver = string.match(dir, "%d+%.%d+") - if xcode_sdkver then break end - end - end - end - - -- probe ok? update it - if xcode_sdkver then - - -- save it - configs.set("xcode_sdkver", xcode_sdkver) - - -- trace - utils.printf("checking for the Xcode SDK version for %s ... %s", configs.get("plat"), xcode_sdkver) - else - -- failed - utils.error("checking for the Xcode SDK version for %s ... no", configs.get("plat")) - utils.error(" - xmake config --xcode_sdkver=xxx") - utils.error("or - xmake global --xcode_sdkver=xxx") - return false - end - - -- ok - return true -end - --- probe the target minimal version -function prober._probe_target_minver(configs) - - -- get the target minimal version - local target_minver = configs.get("target_minver") - - -- ok? - if target_minver then return true end - - -- init the default target minimal version - configs.set("target_minver", "10.9") - - -- trace - utils.printf("checking for the target minimal version ... %s", configs.get("target_minver")) - - -- ok - return true -end - --- probe the make -function prober._probe_make(configs) - - -- ok? - local make = configs.get("make") - if make then return true end - - -- probe the make path - make = tools.probe("make", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"}) - - -- probe ok? update it - if make then configs.set("make", make) end - - -- trace - utils.printf("checking for the make ... %s", utils.ifelse(make, make, "no")) - - -- ok - return true -end - --- probe the ccache -function prober._probe_ccache(configs) - - -- ok? - local ccache_enable = configs.get("ccache") - if ccache_enable and configs.get("__ccache") then return true end - - -- disable? - if type(ccache_enable) == "boolean" and not ccache_enable then - configs.set("__ccache", nil) - return true - end - - -- probe the ccache path - local ccache_path = tools.probe("ccache", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"}) - - -- probe ok? update it - if ccache_path then - configs.set("ccache", true) - configs.set("__ccache", ccache_path) - else - configs.set("ccache", false) - end - - -- trace - utils.printf("checking for the ccache ... %s", utils.ifelse(ccache_path, ccache_path, "no")) - - -- ok - return true -end - --- probe the tool path -function prober._probe_toolpath(configs, kind, cross, names, description) - - -- check - assert(kind) - - -- get the cross - cross = configs.get("cross") or cross - - -- done - local toolpath = nil - local toolchains = configs.get("toolchains") - for _, name in ipairs(utils.wrap(names)) do - - -- attempt to get it from the given cross toolchains - if toolchains then - toolpath = tools.probe(cross .. (configs.get(kind) or name), toolchains) - end - - -- attempt to get it directly from the configure - if not toolpath then - toolpath = configs.get(kind) - end - - -- attempt to run it directly - if not toolpath then - toolpath = tools.probe(cross .. name) - end - - -- probe ok? - if toolpath then - - -- update config - configs.set(kind, toolpath) - - -- end - break - end - - end - - -- trace - if toolpath then - utils.printf("checking for %s (%s) ... %s", description, kind, path.filename(toolpath)) - else - utils.printf("checking for %s (%s) ... no", description, kind) - end - - -- ok - return true -end - --- probe the toolchains -function prober._probe_toolchains(configs) - - -- done - if not prober._probe_toolpath(configs, "cc", "xcrun -sdk macosx ", "clang", "the c compiler") then return false end - if not prober._probe_toolpath(configs, "cxx", "xcrun -sdk macosx ", {"clang++", "clang"}, "the c++ compiler") then return false end - if not prober._probe_toolpath(configs, "mm", "xcrun -sdk macosx ", "clang", "the objc compiler") then return false end - if not prober._probe_toolpath(configs, "mxx", "xcrun -sdk macosx ", {"clang++", "clang"}, "the objc++ compiler") then return false end - if not prober._probe_toolpath(configs, "as", "xcrun -sdk macosx ", "clang", "the assember") then return false end - if not prober._probe_toolpath(configs, "ld", "xcrun -sdk macosx ", {"clang++", "clang"}, "the linker") then return false end - if not prober._probe_toolpath(configs, "ar", "xcrun -sdk macosx ", "ar", "the static library linker") then return false end - if not prober._probe_toolpath(configs, "sh", "xcrun -sdk macosx ", {"clang++", "clang"}, "the shared library linker") then return false end - if not prober._probe_toolpath(configs, "sc", "xcrun -sdk macosx ", "swiftc", "the swift compiler") then return false end - return true -end - --- probe the project configure -function prober.config() - - -- call all probe functions - return utils.call( { prober._probe_arch - , prober._probe_xcode - , prober._probe_xcode_sdkver - , prober._probe_target_minver - , prober._probe_make - , prober._probe_ccache - , prober._probe_toolchains} - , nil - , config) -end - --- probe the global configure -function prober.global() - - -- call all probe functions - return utils.call( { prober._probe_xcode - , prober._probe_ccache} - , nil - , global) -end - --- return module: prober -return prober diff --git a/xmake/scripts/platform/macosx/uninstall.lua b/xmake/scripts/platform/macosx/uninstall.lua deleted file mode 100644 index 468692620..000000000 --- a/xmake/scripts/platform/macosx/uninstall.lua +++ /dev/null @@ -1,134 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- 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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file uninstall.lua --- - --- define module: uninstall -local uninstall = uninstall or {} - --- load modules -local os = require("base/os") -local path = require("base/path") -local rule = require("base/rule") -local utils = require("base/utils") -local string = require("base/string") -local platform = require("platform/platform") - --- uninstall target for the library file -function uninstall._done_library(target) - - -- check - assert(target and target.name and target.archs) - - -- get target info - local info = target.archs[xmake._ARCH] or target.archs["x86_64"] or target.archs["i386"] - if not info then return -1 end - - -- check - assert(info.targetdir and info.targetfile) - - -- remove the target file - local targetfile = info.targetdir .. "/" .. info.targetfile - if os.isfile(targetfile) then - local ok, errors = os.rm(targetfile) - if not ok then - utils.error(errors) - return -1 - end - end - - -- remove config.h - if info.config_h and os.isfile(info.config_h) then - local ok, errors = os.rm(info.config_h) - if not ok then - utils.error(errors) - return -1 - end - end - - -- remove headers - if target.headers then - for _, header in ipairs(target.headers) do - if os.isfile(header) then - local ok, errors = os.rm(header) - if not ok then - utils.error(errors) - return -1 - end - end - end - end - - -- ok - return 1 -end - --- uninstall target for the binary file -function uninstall._done_binary(target) - - -- check - assert(target and target.archs) - - -- get target info - local info = target.archs[xmake._ARCH] or target.archs["x86_64"] or target.archs["i386"] - if not info then return -1 end - - -- check - assert(info.targetdir and info.targetfile) - - -- the target file - local targetfile = info.targetdir .. "/" .. info.targetfile - if not os.isfile(targetfile) then return 1 end - - -- remove the target file - local ok, errors = os.rm(targetfile) - if not ok then - utils.error(errors) - return -1 - end - - -- ok - return 1 -end - --- uninstall target -function uninstall.main(target) - - -- check - assert(target and target.kind) - - -- the uninstall scripts - local uninstallscripts = - { - static = uninstall._done_library - , shared = uninstall._done_library - , binary = uninstall._done_binary - } - - -- uninstall it - local uninstallscript = uninstallscripts[target.kind] - if uninstallscript then return uninstallscript(target) end - - -- continue - return 0 -end - --- return module: uninstall -return uninstall diff --git a/xmake/scripts/platform/mingw/mingw.lua b/xmake/scripts/platform/mingw/mingw.lua deleted file mode 100644 index 7264489b2..000000000 --- a/xmake/scripts/platform/mingw/mingw.lua +++ /dev/null @@ -1,93 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- 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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file mingw.lua --- - --- define module: mingw -local mingw = mingw or {} - --- load modules -local config = require("base/config") - --- init host -mingw._HOST = xmake._HOST - --- init os -mingw._OS = "windows" - --- init architectures -mingw._ARCHS = {"i386", "x86_64"} - --- make configure -function mingw.make(configs) - - -- init the file formats - configs.formats = {} - configs.formats.static = {"lib", ".a"} - configs.formats.object = {"", ".o"} - configs.formats.shared = {"lib", ".so"} - - -- init the toolchains - configs.tools = {} - configs.tools.make = config.get("make") - configs.tools.ccache = config.get("__ccache") - configs.tools.cc = config.get("cc") - configs.tools.cxx = config.get("cxx") - configs.tools.ld = config.get("ld") - configs.tools.ar = config.get("ar") - configs.tools.sh = config.get("sh") - configs.tools.ex = config.get("ar") - configs.tools.sc = config.get("sc") - - -- 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 - configs.cxflags = { archflags } - configs.asflags = { archflags } - configs.ldflags = { archflags } - configs.shflags = { archflags } - -end - --- get the option menu for action: xmake config or global -function mingw.menu(action) - - -- init config option menu - mingw._MENU_CONFIG = mingw._MENU_CONFIG or {} - - -- init global option menu - mingw._MENU_GLOBAL = mingw._MENU_GLOBAL or {} - - -- get the option menu - if action == "config" then - return mingw._MENU_CONFIG - elseif action == "global" then - return mingw._MENU_GLOBAL - end -end - --- return module: mingw -return mingw diff --git a/xmake/scripts/platform/mingw/prober.lua b/xmake/scripts/platform/mingw/prober.lua deleted file mode 100644 index 575e3a7ba..000000000 --- a/xmake/scripts/platform/mingw/prober.lua +++ /dev/null @@ -1,207 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- 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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file prober.lua --- - --- load modules -local os = require("base/os") -local path = require("base/path") -local utils = require("base/utils") -local string = require("base/string") -local tools = require("tools/tools") -local config = require("base/config") -local global = require("base/global") - --- define module: prober -local prober = prober or {} - --- probe the architecture -function prober._probe_arch(configs) - - -- get the architecture - local arch = configs.get("arch") - - -- ok? - if arch then return true end - - -- init the default architecture - configs.set("arch", "i386") - - -- trace - utils.printf("checking for the architecture ... %s", configs.get("arch")) - - -- ok - return true -end - --- probe the make -function prober._probe_make(configs) - - -- ok? - local make = configs.get("make") - if make then return true end - - -- probe the make path - make = tools.probe("make", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"}) - - -- probe ok? update it - if make then configs.set("make", make) end - - -- trace - utils.printf("checking for the make ... %s", utils.ifelse(make, make, "no")) - - -- ok - return true -end - --- probe the ccache -function prober._probe_ccache(configs) - - -- ok? - local ccache_enable = configs.get("ccache") - if ccache_enable and configs.get("__ccache") then return true end - - -- disable? - if type(ccache_enable) == "boolean" and not ccache_enable then - configs.set("__ccache", nil) - return true - end - - -- probe the ccache path - local ccache_path = tools.probe("ccache", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"}) - - -- probe ok? update it - if ccache_path then - configs.set("ccache", true) - configs.set("__ccache", ccache_path) - else - configs.set("ccache", false) - end - - -- trace - utils.printf("checking for the ccache ... %s", utils.ifelse(ccache_path, ccache_path, "no")) - - -- ok - return true -end - --- probe the tool path -function prober._probe_toolpath(configs, kind, cross, names, description) - - -- check - assert(kind) - - -- get the cross - cross = configs.get("cross") or cross - - -- done - local toolpath = nil - local toolchains = configs.get("toolchains") - for _, name in ipairs(utils.wrap(names)) do - - -- attempt to get it from the given cross toolchains - if toolchains then - toolpath = tools.probe(cross .. (configs.get(kind) or name), toolchains) - end - - -- attempt to get it directly from the configure - if not toolpath then - toolpath = configs.get(kind) - end - - -- attempt to run it directly - if not toolpath then - toolpath = tools.probe(cross .. name) - end - - -- probe ok? - if toolpath then - - -- update config - configs.set(kind, toolpath) - - -- end - break - end - - end - - -- trace - if toolpath then - utils.printf("checking for %s (%s) ... %s", description, kind, path.filename(toolpath)) - else - utils.printf("checking for %s (%s) ... no", description, kind) - end - - -- ok - return true -end - --- probe the toolchains -function prober._probe_toolchains(configs) - - -- init the default cross from the current host and architecture - local cross = "" - local arch = configs.get("arch") - if arch then - if xmake._HOST == "macosx" and arch == "i386" then - cross = "i386-mingw32-" - elseif arch == "i386" then - cross = "i686-w64-mingw32-" - elseif arch == "x86_64" then - cross = "x86_64-w64-mingw32-" - end - end - - -- done - if not prober._probe_toolpath(configs, "cc", cross, "gcc", "the c compiler") then return false end - if not prober._probe_toolpath(configs, "cxx", cross, {"g++", "gcc"}, "the c++ compiler") then return false end - if not prober._probe_toolpath(configs, "as", cross, "gcc", "the assember") then return false end - if not prober._probe_toolpath(configs, "ld", cross, {"g++", "gcc"}, "the linker") then return false end - if not prober._probe_toolpath(configs, "ar", cross, "ar", "the static library linker") then return false end - if not prober._probe_toolpath(configs, "sh", cross, {"g++", "gcc"}, "the shared library linker") then return false end - if not prober._probe_toolpath(configs, "sc", cross, "swiftc", "the swift compiler") then return false end - return true -end - --- probe the project configure -function prober.config() - - -- call all probe functions - return utils.call( { prober._probe_arch - , prober._probe_make - , prober._probe_ccache - , prober._probe_toolchains} - , nil - , config) -end - --- probe the global configure -function prober.global() - - -- call all probe functions - return utils.call( { prober._probe_make - , prober._probe_ccache} - , nil - , global) -end - --- return module: prober -return prober diff --git a/xmake/scripts/platform/platform.lua b/xmake/scripts/platform/platform.lua deleted file mode 100644 index 38d482f44..000000000 --- a/xmake/scripts/platform/platform.lua +++ /dev/null @@ -1,385 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- 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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file platform.lua --- - --- define module: platform -local platform = platform or {} - --- load modules -local os = require("base/os") -local path = require("base/path") -local utils = require("base/utils") -local config = require("base/config") -local global = require("base/global") - --- load prober the given platform directory -function platform._load_prober(root) - - -- the platform file path - local filepath = string.format("%s/prober.lua", root) - if os.isfile(filepath) then - - -- load script - local script = loadfile(filepath) - if script then - - -- load prober - local prober = script() - if prober then - - -- ok - return prober - end - end - end -end - --- load the given platform from the given root directory -function platform._load_from(root, plat) - - -- the platform file path - local filepath = string.format("%s/platform/%s/%s.lua", root, plat, plat) - if os.isfile(filepath) then - - -- load script - local script = loadfile(filepath) - if script then - - -- load module - local module = script() - if module then - - -- save directory - module._DIRECTORY = path.directory(filepath) - assert(module._DIRECTORY) - - -- attempt to load prober - module._PROBER = platform._load_prober(module._DIRECTORY) - - -- ok - return module - end - end - end -end - --- load the given platform -function platform._load(plat) - - -- the module - platform._MODULES = platform._MODULES or {} - local module = platform._MODULES[plat] - - -- return it directory if ok - if module then return module end - - -- attempt to load it from the project configure directory - if not module then module = platform._load_from(config.directory(), plat) end - - -- attempt to load it from the global configure directory - if not module then module = platform._load_from(global.directory(), plat) end - - -- attempt to load it from the script directory - if not module then module = platform._load_from(xmake._SCRIPTS_DIR, plat) end - - -- cache it if ok - if module then - platform._MODULES[plat] = module - end - - -- ok? - return module -end - --- get the configure of the given platform -function platform._configs(plat) - - -- the configure - platform._CONFIGS = platform._CONFIGS or {} - local configs = platform._CONFIGS[plat] - - -- return it directly if exists - if configs then - return configs - end - - -- load platform - local module = platform._load(plat) - if module then - - -- init configure - platform._CONFIGS[plat]= {} - configs = platform._CONFIGS[plat] - - -- make configure - module.make(configs) - end - - -- ok? - return configs -end - --- get the current platform module -function platform.module() - - -- load it - return platform._load(config.get("plat")) -end - --- get the current platform module directory -function platform.directory() - - -- load it - local module = platform.module() - if module then - return module._DIRECTORY - end -end - --- make the current platform configure -function platform.make() - - -- get the platform - local plat = config.get("plat") - assert(plat) - - -- make and get the current platform configure - return platform._configs(plat) -end - --- get the platform os -function platform.os() - - -- get module - local module = platform.module() - if not module then return end - - -- ok? - return module._OS -end - --- get the given configure -function platform.get(name) - - -- check - assert(platform._CONFIGS) - - -- get the current platform configure - local configs = platform._configs(config.get("plat")) - if configs then - -- get it - return configs[name] - end -end - --- get the given tool -function platform.tool(name) - - -- check - assert(name) - - -- get tools - local tools = platform.get("tools") - if tools then - return tools[name] - end - -end - --- get the given format -function platform.format(kind) - - -- check - assert(kind) - - -- get formats - local formats = platform.get("formats") - if formats then - return formats[kind] - end - -end - --- dump the platform configure -function platform.dump() - - -- check - assert(platform._CONFIGS) - - -- dump - if xmake._OPTIONS.verbose then - utils.dump(platform._configs(config.get("plat"))) - end - -end - --- list all platforms -function platform.plats() - - -- return it directly if exists - if platform._PLATS then - return platform._PLATS - end - - -- make list - local list = {} - - -- get the platform list from the project configure directory - local plats = os.match(config.directory() .. "/platform/*", true) - if plats then - for _, v in ipairs(plats) do - table.insert(list, path.basename(v)) - end - end - - -- get the platform list from the global configure directory - plats = os.match(global.directory() .. "/platform/*", true) - if plats then - for _, v in ipairs(plats) do - table.insert(list, path.basename(v)) - end - end - - -- get the platform list from the script directory - plats = os.match(xmake._SCRIPTS_DIR .. "/platform/*", true) - if plats then - for _, v in ipairs(plats) do - table.insert(list, path.basename(v)) - end - end - - -- save it - platform._PLATS = list - - -- ok - return list -end - --- list all architectures -function platform.archs(plat) - - -- check - assert(plat) - - -- load all platform configs - local archs = {} - local module = platform._load(plat) - if module and module._ARCHS then - for _, arch in ipairs(module._ARCHS) do - table.insert(archs, arch) - end - end - - -- ok - return archs -end - --- get the option menu for action: xmake config or global -function platform.menu(action) - - -- check - assert(action) - - -- get all platforms - local plats = platform.plats() - assert(plats) - - -- load and merge all platform menus - local menus = {} - local exist = {} - for _, plat in ipairs(plats) do - - -- load platform - local module = platform._load(plat) - if module and module.menu then - - -- get the platform menu - local menu = module.menu(action) - if menu then - - -- exists options? - local exists = false - for _, option in ipairs(menu) do - local name = option[2] - if name and not exist[name] then - exists = true - break - end - end - - -- merge it and remove repeat if exists options - if exists then - -- get the platform menu option - for _, option in ipairs(menu) do - - -- merge it and remove repeat - local name = option[2] - if name then - if not exist[name] then - table.insert(menus, option) - exist[name] = true - end - else - table.insert(menus, option) - end - end - end - end - end - end - - -- get all platform menus - return menus -end - --- probe the platform configure -function platform.probe(is_global) - - -- probe global - if is_global then - - -- get all platforms - local plats = platform.plats() - assert(plats) - - -- probe all platforms with the current host - for _, plat in ipairs(plats) do - local module = platform._load(plat) - if module and module._PROBER and module._PROBER.global and module._HOST and module._HOST == xmake._HOST then - if not module._PROBER.global() then return false end - end - end - - -- probe config - else - -- probe it - local module = platform.module() - if module and module._PROBER and module._PROBER.config then - if not module._PROBER.config() then return false end - end - end - - -- ok - return true -end - --- return module: platform -return platform diff --git a/xmake/scripts/platform/watchos/package.lua b/xmake/scripts/platform/watchos/package.lua deleted file mode 100644 index 1e46ddadc..000000000 --- a/xmake/scripts/platform/watchos/package.lua +++ /dev/null @@ -1,76 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- 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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file package.lua --- - --- define module: package -local package = package or {} - --- load modules -local os = require("base/os") -local path = require("base/path") -local rule = require("base/rule") -local utils = require("base/utils") -local string = require("base/string") -local platform = require("platform/platform") - --- package target -function package.main(target) - - -- check - assert(target and target.name) - - -- the count of architectures - local count = 0 - for _, _ in pairs(target.archs) do count = count + 1 end - if count < 2 then return 0 end - - -- get the lipo tool - local lipo = platform.tool("lipo") - if not lipo then return 0 end - - -- make universal info - local universal = {} - universal.targetdir = rule.backupdir(target.name, "universal") - universal.targetfile = rule.targetfile(target.name, target) - if not universal.targetdir or not universal.targetfile then return 0 end - - -- make the universal directory - os.mkdir(path.directory(string.format("%s/%s", universal.targetdir, universal.targetfile))) - - -- make the lipo command - local cmd = lipo .. " -create" - for arch, info in pairs(target.archs) do - cmd = string.format("%s -arch %s %s/%s", cmd, arch, info.targetdir, info.targetfile) - end - cmd = string.format("%s -output %s/%s", cmd, universal.targetdir, universal.targetfile) - - -- make the universal target - if 0 ~= os.execute(cmd) then return 0 end - - -- ok - target.archs.universal = universal - - -- continue - return 0 -end - --- return module: package -return package diff --git a/xmake/scripts/platform/watchos/prober.lua b/xmake/scripts/platform/watchos/prober.lua deleted file mode 100644 index 7b393f925..000000000 --- a/xmake/scripts/platform/watchos/prober.lua +++ /dev/null @@ -1,310 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- 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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file prober.lua --- - --- load modules -local os = require("base/os") -local path = require("base/path") -local utils = require("base/utils") -local string = require("base/string") -local tools = require("tools/tools") -local config = require("base/config") -local global = require("base/global") - --- define module: prober -local prober = prober or {} - --- probe the architecture -function prober._probe_arch(configs) - - -- get the architecture - local arch = configs.get("arch") - - -- ok? - if arch then return true end - - -- init the default architecture - configs.set("arch", "armv7") - - -- trace - utils.printf("checking for the architecture ... %s", configs.get("arch")) - - -- ok - return true -end - --- probe the xcode application directory -function prober._probe_xcode(configs) - - -- get the xcode directory - local xcode_dir = configs.get("xcode_dir") - - -- ok? - if xcode_dir then return true end - - -- clear it first - xcode_dir = nil - - -- attempt to get the default directory - if not xcode_dir then - if os.isdir("/Applications/Xcode.app") then - xcode_dir = "/Applications/Xcode.app" - end - end - - -- attempt to match the other directories - if not xcode_dir then - local dirs = os.match("/Applications/Xcode*.app", true) - if dirs and table.getn(dirs) ~= 0 then - xcode_dir = dirs[1] - end - end - - -- probe ok? update it - if xcode_dir then - -- save it - configs.set("xcode_dir", xcode_dir) - - -- trace - utils.printf("checking for the Xcode application directory ... %s", xcode_dir) - else - -- failed - utils.error("checking for the Xcode application directory ... no") - utils.error(" - xmake config --xcode_dir=xxx") - utils.error("or - xmake global --xcode_dir=xxx") - return false - end - - -- ok - return true -end - --- probe the xcode sdk version -function prober._probe_xcode_sdkver(configs) - - -- get the xcode sdk version - local xcode_sdkver = configs.get("xcode_sdkver") - - -- ok? - if xcode_sdkver then return true end - - -- clear it first - xcode_sdkver = nil - - -- attempt to match the directory - if not xcode_sdkver then - local dirs = os.match(configs.get("xcode_dir") .. "/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS*.sdk", true) - if dirs then - for _, dir in ipairs(dirs) do - xcode_sdkver = string.match(dir, "%d+%.%d+") - if xcode_sdkver then break end - end - end - end - - -- probe ok? update it - if xcode_sdkver then - - -- save it - configs.set("xcode_sdkver", xcode_sdkver) - - -- trace - utils.printf("checking for the Xcode SDK version for %s ... %s", configs.get("plat"), xcode_sdkver) - else - -- failed - utils.error("checking for the Xcode SDK version for %s ... no", configs.get("plat")) - utils.error(" - xmake config --xcode_sdkver=xxx") - utils.error("or - xmake global --xcode_sdkver=xxx") - return false - end - - -- ok - return true -end - --- probe the target minimal version -function prober._probe_target_minver(configs) - - -- get the target minimal version - local target_minver = configs.get("target_minver") - - -- ok? - if target_minver then return true end - - -- init the default target minimal version - configs.set("target_minver", "7.0") - - -- trace - utils.printf("checking for the target minimal version ... %s", configs.get("target_minver")) - - -- ok - return true -end - --- probe the make -function prober._probe_make(configs) - - -- ok? - local make = configs.get("make") - if make then return true end - - -- probe the make path - make = tools.probe("make", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"}) - - -- probe ok? update it - if make then configs.set("make", make) end - - -- trace - utils.printf("checking for the make ... %s", utils.ifelse(make, make, "no")) - - -- ok - return true -end - --- probe the ccache -function prober._probe_ccache(configs) - - -- ok? - local ccache_enable = configs.get("ccache") - if ccache_enable and configs.get("__ccache") then return true end - - -- disable? - if type(ccache_enable) == "boolean" and not ccache_enable then - configs.set("__ccache", nil) - return true - end - - -- probe the ccache path - local ccache_path = tools.probe("ccache", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"}) - - -- probe ok? update it - if ccache_path then - configs.set("ccache", true) - configs.set("__ccache", ccache_path) - else - configs.set("ccache", false) - end - - -- trace - utils.printf("checking for the ccache ... %s", utils.ifelse(ccache_path, ccache_path, "no")) - - -- ok - return true -end - --- probe the tool path -function prober._probe_toolpath(configs, kind, cross, names, description) - - -- check - assert(kind) - - -- get the cross - cross = configs.get("cross") or cross - - -- done - local toolpath = nil - local toolchains = configs.get("toolchains") - for _, name in ipairs(utils.wrap(names)) do - - -- attempt to get it from the given cross toolchains - if toolchains then - toolpath = tools.probe(cross .. (configs.get(kind) or name), toolchains) - end - - -- attempt to get it directly from the configure - if not toolpath then - toolpath = configs.get(kind) - end - - -- attempt to run it directly - if not toolpath then - toolpath = tools.probe(cross .. name) - end - - -- probe ok? - if toolpath then - - -- update config - configs.set(kind, toolpath) - - -- end - break - end - - end - - -- trace - if toolpath then - utils.printf("checking for %s (%s) ... %s", description, kind, path.filename(toolpath)) - else - utils.printf("checking for %s (%s) ... no", description, kind) - end - - -- ok - return true -end - --- probe the toolchains -function prober._probe_toolchains(configs) - - -- done - if not prober._probe_toolpath(configs, "cc", "xcrun -sdk watchos ", "clang", "the c compiler") then return false end - if not prober._probe_toolpath(configs, "cxx", "xcrun -sdk watchos ", {"clang++", "clang"}, "the c++ compiler") then return false end - if not prober._probe_toolpath(configs, "mm", "xcrun -sdk watchos ", "clang", "the objc compiler") then return false end - if not prober._probe_toolpath(configs, "mxx", "xcrun -sdk watchos ", {"clang++", "clang"}, "the objc++ compiler") then return false end - if not prober._probe_toolpath(configs, "as", xmake._SCRIPTS_DIR .. "/tools/gas-preprocessor.pl xcrun -sdk watchos ", "clang", "the assember") then return false end - if not prober._probe_toolpath(configs, "ld", "xcrun -sdk watchos ", {"clang++", "clang"}, "the linker") then return false end - if not prober._probe_toolpath(configs, "ar", "xcrun -sdk watchos ", "ar", "the static library linker") then return false end - if not prober._probe_toolpath(configs, "sh", "xcrun -sdk watchos ", {"clang++", "clang"}, "the shared library linker") then return false end - if not prober._probe_toolpath(configs, "sc", "xcrun -sdk watchos ", "swiftc", "the swift compiler") then return false end - if not prober._probe_toolpath(configs, "lipo", "xcrun -sdk watchos ", "lipo", "the universal files creater") then return false end - return true -end - --- probe the project configure -function prober.config() - - -- call all probe functions - return utils.call( { prober._probe_arch - , prober._probe_xcode - , prober._probe_xcode_sdkver - , prober._probe_target_minver - , prober._probe_make - , prober._probe_ccache - , prober._probe_toolchains} - , nil - , config) - -end - --- probe the global configure -function prober.global() - - -- call all probe functions - return utils.call( { prober._probe_xcode - , prober._probe_make - , prober._probe_ccache} - , nil - , global) -end - --- return module: prober -return prober diff --git a/xmake/scripts/platform/watchos/watchos.lua b/xmake/scripts/platform/watchos/watchos.lua deleted file mode 100644 index 9551084f8..000000000 --- a/xmake/scripts/platform/watchos/watchos.lua +++ /dev/null @@ -1,141 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- 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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file watchos.lua --- - --- define module: watchos -local watchos = watchos or {} - --- load modules -local config = require("base/config") - --- init host -watchos._HOST = "macosx" - --- init os -watchos._OS = "ios" - --- init architectures -watchos._ARCHS = {"armv7", "armv7s", "arm64"} - --- make configure -function watchos.make(configs) - - -- init the file formats - configs.formats = {} - configs.formats.static = {"lib", ".a"} - configs.formats.object = {"", ".o"} - configs.formats.shared = {"lib", ".dylib"} - - -- init the toolchains - configs.tools = {} - configs.tools.make = config.get("make") - configs.tools.ccache = config.get("__ccache") - configs.tools.cc = config.get("cc") - configs.tools.cxx = config.get("cxx") - configs.tools.mm = config.get("mm") - configs.tools.mxx = config.get("mxx") - configs.tools.as = config.get("as") - configs.tools.ld = config.get("ld") - configs.tools.ar = config.get("ar") - configs.tools.sh = config.get("sh") - configs.tools.ex = config.get("ar") - configs.tools.sc = config.get("sc") - configs.tools.lipo = config.get("lipo") - - -- init target minimal version - local target_minver = config.get("target_minver") - assert(target_minver) - - -- init flags for architecture - local archflags = nil - local arch = config.get("arch") - if arch then archflags = "-arch " .. arch end - configs.cxflags = { archflags, "-mwatchos-version-min=" .. target_minver } - configs.mxflags = { archflags, "-mwatchos-version-min=" .. target_minver } - configs.asflags = { archflags, "-mwatchos-version-min=" .. target_minver } - configs.ldflags = { archflags, "-ObjC", "-lstdc++", "-fobjc-link-runtime", "-mwatchos-version-min=" .. target_minver } - configs.shflags = { archflags, "-ObjC", "-lstdc++", "-fobjc-link-runtime", "-mwatchos-version-min=" .. target_minver } - if arch then - configs.scflags = { string.format("-target %s-apple-ios%s", arch, target_minver) } - end - - -- init flags for the xcode sdk directory - local xcode_dir = config.get("xcode_dir") - local xcode_sdkver = config.get("xcode_sdkver") - if xcode_dir and xcode_sdkver then - - -- init flags - local xcode_sdkdir = xcode_dir .. "/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS" .. xcode_sdkver .. ".sdk" - table.insert(configs.cxflags, "-isysroot " .. xcode_sdkdir) - table.insert(configs.asflags, "-isysroot " .. xcode_sdkdir) - table.insert(configs.mxflags, "-isysroot " .. xcode_sdkdir) - table.insert(configs.ldflags, "-isysroot " .. xcode_sdkdir) - table.insert(configs.shflags, "-isysroot " .. xcode_sdkdir) - table.insert(configs.scflags, "-sdk " .. xcode_sdkdir) - - -- save swift link directory - config.set("__swift_linkdirs", xcode_dir .. "/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/watchos") - end - -end - --- get the option menu for action: xmake config or global -function watchos.menu(action) - - -- init config option menu - watchos._MENU_CONFIG = watchos._MENU_CONFIG or - { {} - , {nil, "mm", "kv", nil, "The Objc Compiler" } - , {nil, "mxx", "kv", nil, "The Objc++ Compiler" } - , {nil, "mflags", "kv", nil, "The Objc Compiler Flags" } - , {nil, "mxflags", "kv", nil, "The Objc/c++ Compiler Flags" } - , {nil, "mxxflags", "kv", nil, "The Objc++ Compiler Flags" } - , {} - , {nil, "xcode_dir", "kv", "auto", "The Xcode Application Directory" } - , {nil, "xcode_sdkver", "kv", "auto", "The SDK Version for Xcode" } - , {nil, "target_minver", "kv", "auto", "The Target Minimal Version" } - , {} - , {nil, "mobileprovision","kv", "auto", "The Provisioning Profile File" } - , {nil, "codesign", "kv", "auto", "The Code Signing Indentity" } - , {nil, "entitlements", "kv", "auto", "The Code Signing Entitlements" } - , } - - -- init global option menu - watchos._MENU_GLOBAL = watchos._MENU_GLOBAL or - { {} - , {nil, "xcode_dir", "kv", "auto", "The Xcode Application Directory" } - , {} - , {nil, "mobileprovision","kv", "auto", "The Provisioning Profile File" } - , {nil, "codesign", "kv", "auto", "The Code Signing Indentity" } - , {nil, "entitlements", "kv", "auto", "The Code Signing Entitlements" } - , } - - -- get the option menu - if action == "config" then - return watchos._MENU_CONFIG - elseif action == "global" then - return watchos._MENU_GLOBAL - end -end - - --- return module: watchos -return watchos diff --git a/xmake/scripts/platform/watchsimulator/prober.lua b/xmake/scripts/platform/watchsimulator/prober.lua deleted file mode 100644 index d33059c36..000000000 --- a/xmake/scripts/platform/watchsimulator/prober.lua +++ /dev/null @@ -1,308 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- 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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file prober.lua --- - --- load modules -local os = require("base/os") -local path = require("base/path") -local utils = require("base/utils") -local string = require("base/string") -local tools = require("tools/tools") -local config = require("base/config") -local global = require("base/global") - --- define module: prober -local prober = prober or {} - --- probe the architecture -function prober._probe_arch(configs) - - -- get the architecture - local arch = configs.get("arch") - - -- ok? - if arch then return true end - - -- init the default architecture - configs.set("arch", "x86_64") - - -- trace - utils.printf("checking for the architecture ... %s", configs.get("arch")) - - -- ok - return true -end - --- probe the xcode application directory -function prober._probe_xcode(configs) - - -- get the xcode directory - local xcode_dir = configs.get("xcode_dir") - - -- ok? - if xcode_dir then return true end - - -- clear it first - xcode_dir = nil - - -- attempt to get the default directory - if not xcode_dir then - if os.isdir("/Applications/Xcode.app") then - xcode_dir = "/Applications/Xcode.app" - end - end - - -- attempt to match the other directories - if not xcode_dir then - local dirs = os.match("/Applications/Xcode*.app", true) - if dirs and table.getn(dirs) ~= 0 then - xcode_dir = dirs[1] - end - end - - -- probe ok? update it - if xcode_dir then - -- save it - configs.set("xcode_dir", xcode_dir) - - -- trace - utils.printf("checking for the Xcode application directory ... %s", xcode_dir) - else - -- failed - utils.error("checking for the Xcode application directory ... no") - utils.error(" - xmake config --xcode_dir=xxx") - utils.error("or - xmake global --xcode_dir=xxx") - return false - end - - -- ok - return true -end - --- probe the xcode sdk version -function prober._probe_xcode_sdkver(configs) - - -- get the xcode sdk version - local xcode_sdkver = configs.get("xcode_sdkver") - - -- ok? - if xcode_sdkver then return true end - - -- clear it first - xcode_sdkver = nil - - -- attempt to match the directory - if not xcode_sdkver then - local dirs = os.match(configs.get("xcode_dir") .. "/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator*.sdk", true) - if dirs then - for _, dir in ipairs(dirs) do - xcode_sdkver = string.match(dir, "%d+%.%d+") - if xcode_sdkver then break end - end - end - end - - -- probe ok? update it - if xcode_sdkver then - - -- save it - configs.set("xcode_sdkver", xcode_sdkver) - - -- trace - utils.printf("checking for the Xcode SDK version for %s ... %s", configs.get("plat"), xcode_sdkver) - else - -- failed - utils.error("checking for the Xcode SDK version for %s ... no", configs.get("plat")) - utils.error(" - xmake config --xcode_sdkver=xxx") - utils.error("or - xmake global --xcode_sdkver=xxx") - return false - end - - -- ok - return true -end - --- probe the target minimal version -function prober._probe_target_minver(configs) - - -- get the target minimal version - local target_minver = configs.get("target_minver") - - -- ok? - if target_minver then return true end - - -- init the default target minimal version - configs.set("target_minver", "7.0") - - -- trace - utils.printf("checking for the target minimal version ... %s", configs.get("target_minver")) - - -- ok - return true -end - --- probe the make -function prober._probe_make(configs) - - -- ok? - local make = configs.get("make") - if make then return true end - - -- probe the make path - make = tools.probe("make", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"}) - - -- probe ok? update it - if make then configs.set("make", make) end - - -- trace - utils.printf("checking for the make ... %s", utils.ifelse(make, make, "no")) - - -- ok - return true -end - --- probe the ccache -function prober._probe_ccache(configs) - - -- ok? - local ccache_enable = configs.get("ccache") - if ccache_enable and configs.get("__ccache") then return true end - - -- disable? - if type(ccache_enable) == "boolean" and not ccache_enable then - configs.set("__ccache", nil) - return true - end - - -- probe the ccache path - local ccache_path = tools.probe("ccache", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"}) - - -- probe ok? update it - if ccache_path then - configs.set("ccache", true) - configs.set("__ccache", ccache_path) - else - configs.set("ccache", false) - end - - -- trace - utils.printf("checking for the ccache ... %s", utils.ifelse(ccache_path, ccache_path, "no")) - - -- ok - return true -end - --- probe the tool path -function prober._probe_toolpath(configs, kind, cross, names, description) - - -- check - assert(kind) - - -- get the cross - cross = configs.get("cross") or cross - - -- done - local toolpath = nil - local toolchains = configs.get("toolchains") - for _, name in ipairs(utils.wrap(names)) do - - -- attempt to get it from the given cross toolchains - if toolchains then - toolpath = tools.probe(cross .. (configs.get(kind) or name), toolchains) - end - - -- attempt to get it directly from the configure - if not toolpath then - toolpath = configs.get(kind) - end - - -- attempt to run it directly - if not toolpath then - toolpath = tools.probe(cross .. name) - end - - -- probe ok? - if toolpath then - - -- update config - configs.set(kind, toolpath) - - -- end - break - end - - end - - -- trace - if toolpath then - utils.printf("checking for %s (%s) ... %s", description, kind, path.filename(toolpath)) - else - utils.printf("checking for %s (%s) ... no", description, kind) - end - - -- ok - return true -end - --- probe the toolchains -function prober._probe_toolchains(configs) - - -- done - if not prober._probe_toolpath(configs, "cc", "xcrun -sdk watchsimulator ", "clang", "the c compiler") then return false end - if not prober._probe_toolpath(configs, "cxx", "xcrun -sdk watchsimulator ", {"clang++", "clang"}, "the c++ compiler") then return false end - if not prober._probe_toolpath(configs, "mm", "xcrun -sdk watchsimulator ", "clang", "the objc compiler") then return false end - if not prober._probe_toolpath(configs, "mxx", "xcrun -sdk watchsimulator ", {"clang++", "clang"}, "the objc++ compiler") then return false end - if not prober._probe_toolpath(configs, "as", "xcrun -sdk watchsimulator ", "clang", "the assember") then return false end - if not prober._probe_toolpath(configs, "ld", "xcrun -sdk watchsimulator ", {"clang++", "clang"}, "the linker") then return false end - if not prober._probe_toolpath(configs, "ar", "xcrun -sdk watchsimulator ", "ar", "the static library linker") then return false end - if not prober._probe_toolpath(configs, "sh", "xcrun -sdk watchsimulator ", {"clang++", "clang"}, "the shared library linker") then return false end - if not prober._probe_toolpath(configs, "sc", "xcrun -sdk watchsimulator ", "swiftc", "the swift compiler") then return false end - return true -end - --- probe the project configure -function prober.config() - - -- call all probe functions - return utils.call( { prober._probe_arch - , prober._probe_xcode - , prober._probe_xcode_sdkver - , prober._probe_target_minver - , prober._probe_make - , prober._probe_ccache - , prober._probe_toolchains} - , nil - , config) -end - --- probe the global configure -function prober.global() - - -- call all probe functions - return utils.call( { prober._probe_xcode - , prober._probe_make - , prober._probe_ccache} - , nil - , global) -end - --- return module: prober -return prober diff --git a/xmake/scripts/platform/watchsimulator/watchsimulator.lua b/xmake/scripts/platform/watchsimulator/watchsimulator.lua deleted file mode 100644 index a13bfde1e..000000000 --- a/xmake/scripts/platform/watchsimulator/watchsimulator.lua +++ /dev/null @@ -1,138 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- 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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file watchsimulator.lua --- - --- define module: watchsimulator -local watchsimulator = watchsimulator or {} - --- load modules -local config = require("base/config") - --- init host -watchsimulator._HOST = "macosx" - --- init os -watchsimulator._OS = "ios" - --- init architectures -watchsimulator._ARCHS = {"i386", "x86_64"} - --- make configure -function watchsimulator.make(configs) - - -- init the file formats - configs.formats = {} - configs.formats.static = {"lib", ".a"} - configs.formats.object = {"", ".o"} - configs.formats.shared = {"lib", ".dylib"} - - -- init the toolchains - configs.tools = {} - configs.tools.make = config.get("make") - configs.tools.ccache = config.get("__ccache") - configs.tools.cc = config.get("cc") - configs.tools.cxx = config.get("cxx") - configs.tools.mm = config.get("mm") - configs.tools.mxx = config.get("mxx") - configs.tools.ld = config.get("ld") - configs.tools.ar = config.get("ar") - configs.tools.sh = config.get("sh") - configs.tools.ex = config.get("ar") - configs.tools.sc = config.get("sc") - - -- init target minimal version - local target_minver = config.get("target_minver") - assert(target_minver) - - -- init flags for architecture - local archflags = nil - local arch = config.get("arch") - if arch then archflags = "-arch " .. arch end - configs.cxflags = { archflags, "-mios-simulator-version-min=" .. target_minver } - configs.mxflags = { archflags, "-mios-simulator-version-min=" .. target_minver } - configs.asflags = { archflags, "-mios-simulator-version-min=" .. target_minver } - configs.ldflags = { archflags, "-Xlinker -objc_abi_version", "-Xlinker 2 -stdlib=libc++", "-Xlinker -no_implicit_dylibs", "-fobjc-link-runtime", "-mios-simulator-version-min=" .. target_minver } - configs.shflags = { archflags, "-Xlinker -objc_abi_version", "-Xlinker 2 -stdlib=libc++", "-Xlinker -no_implicit_dylibs", "-fobjc-link-runtime", "-mios-simulator-version-min=" .. target_minver } - if arch then - configs.scflags = { string.format("-target %s-apple-ios%s", arch, target_minver) } - end - - -- init flags for the xcode sdk directory - local xcode_dir = config.get("xcode_dir") - local xcode_sdkver = config.get("xcode_sdkver") - if xcode_dir and xcode_sdkver then - - -- init flags - local xcode_sdkdir = xcode_dir .. "/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator" .. xcode_sdkver .. ".sdk" - table.insert(configs.cxflags, "-isysroot " .. xcode_sdkdir) - table.insert(configs.asflags, "-isysroot " .. xcode_sdkdir) - table.insert(configs.mxflags, "-isysroot " .. xcode_sdkdir) - table.insert(configs.ldflags, "-isysroot " .. xcode_sdkdir) - table.insert(configs.shflags, "-isysroot " .. xcode_sdkdir) - table.insert(configs.scflags, "-sdk " .. xcode_sdkdir) - - -- save swift link directory - config.set("__swift_linkdirs", xcode_dir .. "/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/watchsimulator") - end -end - --- get the option menu for action: xmake config or global -function watchsimulator.menu(action) - - -- init config option menu - watchsimulator._MENU_CONFIG = watchsimulator._MENU_CONFIG or - { {} - , {nil, "mm", "kv", nil, "The Objc Compiler" } - , {nil, "mxx", "kv", nil, "The Objc++ Compiler" } - , {nil, "mflags", "kv", nil, "The Objc Compiler Flags" } - , {nil, "mxflags", "kv", nil, "The Objc/c++ Compiler Flags" } - , {nil, "mxxflags", "kv", nil, "The Objc++ Compiler Flags" } - , {} - , {nil, "xcode_dir", "kv", "auto", "The Xcode Application Directory" } - , {nil, "xcode_sdkver", "kv", "auto", "The SDK Version for Xcode" } - , {nil, "target_minver", "kv", "auto", "The Target Minimal Version" } - , {} - , {nil, "mobileprovision","kv", "auto", "The Provisioning Profile File" } - , {nil, "codesign", "kv", "auto", "The Code Signing Indentity" } - , {nil, "entitlements", "kv", "auto", "The Code Signing Entitlements" } - , } - - -- init global option menu - watchsimulator._MENU_GLOBAL = watchsimulator._MENU_GLOBAL or - { {} - , {nil, "xcode_dir", "kv", "auto", "The Xcode Application Directory" } - , {} - , {nil, "mobileprovision","kv", "auto", "The Provisioning Profile File" } - , {nil, "codesign", "kv", "auto", "The Code Signing Indentity" } - , {nil, "entitlements", "kv", "auto", "The Code Signing Entitlements" } - , } - - -- get the option menu - if action == "config" then - return watchsimulator._MENU_CONFIG - elseif action == "global" then - return watchsimulator._MENU_GLOBAL - end -end - - --- return module: watchsimulator -return watchsimulator diff --git a/xmake/scripts/platform/windows/prober.lua b/xmake/scripts/platform/windows/prober.lua deleted file mode 100644 index 40d214efd..000000000 --- a/xmake/scripts/platform/windows/prober.lua +++ /dev/null @@ -1,300 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- 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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file prober.lua --- - --- load modules -local io = require("base/io") -local os = require("base/os") -local path = require("base/path") -local utils = require("base/utils") -local string = require("base/string") -local config = require("base/config") -local global = require("base/global") -local tools = require("tools/tools") -local platform = require("platform/platform") - --- define module: prober -local prober = prober or {} - --- probe the architecture -function prober._probe_arch(configs) - - -- get the architecture - local arch = configs.get("arch") - - -- ok? - if arch then return true end - - -- init the default architecture - configs.set("arch", "x86") - - -- trace - utils.printf("checking for the architecture ... %s", configs.get("arch")) - - -- ok - return true -end - --- probe the vs version -function prober._probe_vs_version(configs) - - -- get the vs version - local vs = configs.get("vs") - - -- ok? - if vs then return true end - - -- clear it first - vs = nil - - -- make the map table - local map = - { - VS140COMNTOOLS = "2015" - , VS120COMNTOOLS = "2013" - , VS110COMNTOOLS = "2012" - , VS100COMNTOOLS = "2010" - , VS90COMNTOOLS = "2008" - , VS80COMNTOOLS = "2005" - , VS71COMNTOOLS = "2003" - , VS70COMNTOOLS = "7.0" - , VS60COMNTOOLS = "6.0" - , VS50COMNTOOLS = "5.0" - , VS42COMNTOOLS = "4.2" - } - - -- attempt to get it from the envirnoment variable - if not vs then - for k, v in pairs(map) do - if os.getenv(k) then - vs = v - break - end - end - end - - -- probe ok? update it - if vs then - -- save it - configs.set("vs", vs) - - -- trace - utils.printf("checking for the Microsoft Visual Studio version ... %s", vs) - else - -- failed - utils.error("checking for the Microsoft Visual Studio version ... no") - utils.error(" - xmake config --vs=xxx") - utils.error("or - xmake global --vs=xxx") - return false - end - - -- ok - return true -end - --- probe the vs path -function prober._probe_vs_path(configs) - - -- ok? - if configs.get("__vsenv_path") then return true end - - -- get the vs version - local vs = configs.get("vs") - assert(vs) - - -- make the map table - local map = - { - ["2015"] = "VS140COMNTOOLS" - , ["2013"] = "VS120COMNTOOLS" - , ["2012"] = "VS110COMNTOOLS" - , ["2010"] = "VS100COMNTOOLS" - , ["2008"] = "VS90COMNTOOLS" - , ["2005"] = "VS80COMNTOOLS" - , ["2003"] = "VS71COMNTOOLS" - , ["7.0"] = "VS70COMNTOOLS" - , ["6.0"] = "VS60COMNTOOLS" - , ["5.0"] = "VS50COMNTOOLS" - , ["4.2"] = "VS42COMNTOOLS" - } - - -- attempt to get the vs directory from the envirnoment variable - local vsdir = map[vs] - if vsdir then - vsdir = os.getenv(vsdir) - end - if vsdir then - vsdir = vsdir .. "\\..\\.." - end - if not os.isdir(vsdir) then - -- error - utils.error("not found %s", vsdir) - return false - end - - -- the vcvarsall.bat path - local vcvarsall = vsdir .. "\\VC\\vcvarsall.bat" - if not os.isfile(vcvarsall) then - -- error - utils.error("not found %s", vcvarsall) - return false - end - - -- get the temporary directory - local tmpdir = os.tmpdir() - assert(tmpdir) - - -- make the call(vcvarsall.bat) file - local callpath = tmpdir .. "\\call_vcvarsall.bat" - local callfile = io.openmk(callpath) - assert(callfile) - - -- make call scripts - callfile:write("@echo off\n") - callfile:write(string.format("call \"%s\" %s > nul\n", vcvarsall, configs.get("arch"))) - callfile:write("echo return \n") - callfile:write("echo { \n") - callfile:write("echo path = \"%path%\"\n") - callfile:write("echo , lib = \"%lib%\"\n") - callfile:write("echo , libpath = \"%libpath%\"\n") - callfile:write("echo , include = \"%include%\"\n") - callfile:write("echo , devenvdir = \"%devenvdir%\"\n") - callfile:write("echo , vsinstalldir = \"%vsinstalldir%\"\n") - callfile:write("echo , vcinstalldir = \"%vcinstalldir%\"\n") - callfile:write("echo } \n") - - -- close the file - callfile:close() - - -- execute the call(vsvars32.bat) file and get all envirnoment variables - local cmd = io.popen(callpath) - local results = cmd:read("*all") - cmd:close() - - -- translate '\' => '\\' - results = results:gsub("\\", "\\\\") - - -- get all envirnoment variables - local variables = assert(loadstring(results))() - if not variables or not variables.path then - return false - end - - -- save the variables - for k, v in pairs(variables) do - configs.set("__vsenv_" .. k, v) - end - - -- ok - return true -end - --- probe the tool path -function prober._probe_toolpath(configs, kind, name, description) - - -- check - assert(kind) - - -- attempt to get it directly from the configure - local toolpath = configs.get(kind) - if toolpath then return true end - - -- make cmd - local cmd = string.format("%s > %s 2>&1", name, xmake._NULDEV) - if kind == "ld" then - cmd = string.format("%s nul > %s 2>&1", name, xmake._NULDEV) - end - - -- attempt to run it directly first - if not toolpath and os.execute(cmd) ~= 1 then - toolpath = name - end - - -- probe ok? update it - if toolpath then configs.set(kind, toolpath) end - - -- trace - if toolpath then - utils.printf("checking for %s (%s) ... %s", description, kind, path.filename(toolpath)) - else - utils.printf("checking for %s (%s) ... no", description, kind) - end - - -- failed? - if not toolpath and (kind == "cc" or kind == "ld" or kind == "make") then - return false - end - - -- ok - return true -end - --- probe the toolchains -function prober._probe_toolchains(configs) - - -- the windows module - local windows = platform.module() - assert(windows) - - -- enter envirnoment - windows.enter() - - -- done - if not prober._probe_toolpath(configs, "cc", "cl.exe", "the c compiler") then return false end - if not prober._probe_toolpath(configs, "cxx", "cl.exe", "the c++ compiler") then return false end - if not prober._probe_toolpath(configs, "as", "ml.exe", "the assember") then return false end - if not prober._probe_toolpath(configs, "ld", "link.exe", "the linker") then return false end - if not prober._probe_toolpath(configs, "ar", "link.exe -lib", "the static library linker") then return false end - if not prober._probe_toolpath(configs, "sh", "link.exe -dll", "the shared library linker") then return false end - if not prober._probe_toolpath(configs, "ex", "lib.exe", "the library extractor") then return false end - if not prober._probe_toolpath(configs, "make", "nmake.exe", "the make") then return false end - - -- leave envirnoment - windows.leave() - - -- ok - return true -end - --- probe the project configure -function prober.config() - - -- call all probe functions - return utils.call( { prober._probe_arch - , prober._probe_vs_version - , prober._probe_vs_path - , prober._probe_toolchains} - , nil - , config) -end - --- probe the global configure -function prober.global() - - -- call all probe functions - return utils.call( { prober._probe_vs_version - , prober._probe_vs_path} - , nil - , global) -end - --- return module: prober -return prober diff --git a/xmake/scripts/platform/windows/tools/cl.lua b/xmake/scripts/platform/windows/tools/cl.lua deleted file mode 100644 index 299960bb8..000000000 --- a/xmake/scripts/platform/windows/tools/cl.lua +++ /dev/null @@ -1,139 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- 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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file cl.lua --- - --- define module: cl -local cl = cl or {} - --- load modules -local utils = require("base/utils") -local string = require("base/string") -local config = require("base/config") -local platform = require("platform/platform") - --- init the compiler -function cl.init(self, name) - - -- save name - self.name = name or "cl.exe" - - -- init cxflags - self.cxflags = { "-nologo", "-Gd", "-MP4", "-D_MBCS", "-D_CRT_SECURE_NO_WARNINGS"} - - -- init flags map - self.mapflags = - { - -- optimize - ["-O0"] = "-Od" - , ["-O3"] = "-Ot" - , ["-Ofast"] = "-Ox" - , ["-fomit-frame-pointer"] = "-Oy" - - -- symbols - , ["-g"] = "-Z7" - , ["-fvisibility=.*"] = "" - - -- warnings - , ["-Wall"] = "-W3" -- = "-Wall" will enable too more warnings - , ["-W1"] = "-W1" - , ["-W2"] = "-W2" - , ["-W3"] = "-W3" - , ["-Werror"] = "-WX" - , ["%-Wno%-error=.*"] = "" - , ["%-fno%-.*"] = "" - - -- vectorexts - , ["-mmmx"] = "-arch:MMX" - , ["-msse"] = "-arch:SSE" - , ["-msse2"] = "-arch:SSE2" - , ["-msse3"] = "-arch:SSE3" - , ["-mssse3"] = "-arch:SSSE3" - , ["-mavx"] = "-arch:AVX" - , ["-mavx2"] = "-arch:AVX2" - , ["-mfpu=.*"] = "" - - -- language - , ["-ansi"] = "" - , ["-std=c99"] = "-TP" -- compile as c++ files because msvc only support c89 - , ["-std=gnu99"] = "-TP" -- compile as c++ files because msvc only support c89 - , ["-std=.*"] = "" - - -- others - , ["-ftrapv"] = "" - , ["-fsanitize=address"] = "" - } - -end - --- make the compiler command -function cl.command_compile(self, srcfile, objfile, flags, logfile) - - -- redirect - local redirect = "" - if logfile then redirect = string.format(" > %s 2>&1", logfile) end - - -- make it - return string.format("%s -c %s -Fo%s %s%s", self.name, flags, objfile, srcfile, redirect) -end - --- make the define flag -function cl.flag_define(self, define) - - -- make it - return "-D" .. define:gsub("\"", "\\\"") -end - --- make the undefine flag -function cl.flag_undefine(self, undefine) - - -- make it - return "-U" .. undefine -end - --- make the includedir flag -function cl.flag_includedir(self, includedir) - - -- make it - return "-I" .. includedir -end - --- the main function -function cl.main(self, cmd) - - -- the windows module - local windows = platform.module() - assert(windows) - - -- enter envirnoment - windows.enter() - - -- execute it - local ok = os.execute(cmd) - - -- leave envirnoment - windows.leave() - - -- ok? - return utils.ifelse(ok == 0, true, false) -end - --- return module: cl -return cl diff --git a/xmake/scripts/platform/windows/tools/lib.lua b/xmake/scripts/platform/windows/tools/lib.lua deleted file mode 100644 index 1d94152cc..000000000 --- a/xmake/scripts/platform/windows/tools/lib.lua +++ /dev/null @@ -1,138 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- 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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file lib.lua --- - --- define module: lib -local lib = lib or {} - --- load modules -local io = require("base/io") -local os = require("base/os") -local path = require("base/path") -local utils = require("base/utils") -local string = require("base/string") -local config = require("base/config") -local platform = require("platform/platform") - --- init the compiler -function lib.init(self, name) - - -- save name - self.name = name or "lib.exe" - -end - --- extract the static library to object files -function lib.extract(self, ...) - - -- check - local args = ... - assert(#args == 2 and self.name) - - -- get library and object file path - local libfile = args[1] - local objfile = args[2] - assert(libfile and objfile) - - -- get object directory - local objdir = path.directory(objfile) - if not os.isdir(objdir) then os.mkdir(objdir) end - if not os.isdir(objdir) then - utils.error("%s not found!", objdir) - return false - end - - -- the windows module - local windows = platform.module() - assert(windows) - - -- enter envirnoment - windows.enter() - - -- list object files - local file = io.popen(string.format("%s -nologo -list %s", self.name, libfile)) - if not file then - utils.error("extract %s to %s failed!", libfile, objdir) - windows.leave() - return false - end - - -- extrace all object files - for line in file:lines() do - - -- is object file? - if line:find("%.obj") then - - -- init command - local out = path.translate(string.format("%s\\%s", objdir, path.filename(line))) - - -- repeat? rename it - if os.isfile(out) then - for i = 0, 10 do - out = path.translate(string.format("%s\\%d_%s", objdir, i, path.filename(line))) - if not os.isfile(out) then break end - end - end - - -- init command - local cmd = string.format("%s -nologo -extract:%s -out:%s %s", self.name, line, out, libfile) - - -- extract it - if 0 ~= os.execute(cmd) then - utils.error("extract %s to %s failed!", libfile, objdir) - windows.leave() - return false - end - end - end - - -- exit file - file:close() - - -- leave envirnoment - windows.leave() - - -- ok - return true -end - --- the main function -function lib.main(self, cmd) - - -- the windows module - local windows = platform.module() - assert(windows) - - -- enter envirnoment - windows.enter() - - -- execute it - local ok = os.execute(cmd) - - -- leave envirnoment - windows.leave() - - -- ok? - return utils.ifelse(ok == 0, true, false) -end - --- return module: lib -return lib diff --git a/xmake/scripts/platform/windows/tools/link.lua b/xmake/scripts/platform/windows/tools/link.lua deleted file mode 100644 index 66476fa41..000000000 --- a/xmake/scripts/platform/windows/tools/link.lua +++ /dev/null @@ -1,128 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- 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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file link.lua --- - --- define module: link -local link = link or {} - --- load modules -local utils = require("base/utils") -local string = require("base/string") -local config = require("base/config") -local platform = require("platform/platform") - --- init the compiler -function link.init(self, name) - - -- save name - self.name = name or "link.exe" - - -- the architecture - local arch = config.get("arch") - assert(arch) - - -- init flags for architecture - local flags_arch = "" - if arch == "x86" then flags_arch = "-machine:x86" - elseif arch == "x64" or arch == "amd64" or arch == "x86_amd64" then flags_arch = "-machine:x64" - end - - -- init ldflags - self.ldflags = { "-nologo" - , "-dynamicbase" - , "-nxcompat" - , flags_arch} - - -- init arflags - self.arflags = {"-nologo", flags_arch} - - -- init shflags - self.shflags = {"-nologo", flags_arch} - - -- init flags map - self.mapflags = - { - -- strip - ["-s"] = "" - , ["-S"] = "" - - -- others - , ["-ftrapv"] = "" - , ["-fsanitize=address"] = "" - } - -end - --- make the linker command -function link.command_link(self, objfiles, targetfile, flags, logfile) - - -- redirect - local redirect = "" - if logfile then redirect = string.format(" > %s 2>&1", logfile) end - - -- make it - local cmd = string.format("%s %s -out:%s %s%s", self.name, flags, targetfile, objfiles, redirect) - - -- too long? - if #cmd > 256 then - cmd = string.format("%s%s @<<\n%s -out:%s %s\n<<", self.name, redirect, flags, targetfile, objfiles) - end - - -- ok? - return cmd -end - --- make the link flag -function link.flag_link(self, link) - - -- make it - return link .. ".lib" -end - --- make the linkdir flag -function link.flag_linkdir(self, linkdir) - - -- make it - return "-libpath:" .. linkdir -end - --- the main function -function link.main(self, cmd) - - -- the windows module - local windows = platform.module() - assert(windows) - - -- enter envirnoment - windows.enter() - - -- execute it - local ok = os.execute(cmd) - - -- leave envirnoment - windows.leave() - - -- ok? - return utils.ifelse(ok == 0, true, false) -end - --- return module: link -return link diff --git a/xmake/scripts/platform/windows/tools/ml.lua b/xmake/scripts/platform/windows/tools/ml.lua deleted file mode 100644 index 5a6034320..000000000 --- a/xmake/scripts/platform/windows/tools/ml.lua +++ /dev/null @@ -1,132 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- 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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file ml.lua --- - --- define module: ml -local ml = ml or {} - --- load modules -local utils = require("base/utils") -local string = require("base/string") -local config = require("base/config") -local platform = require("platform/platform") - --- init the compiler -function ml.init(self, name) - - -- save name - self.name = name or "ml.exe" - - -- init asflags - self.asflags = { "-nologo", "-Gd", "-MP4", "-D_MBCS", "-D_CRT_SECURE_NO_WARNINGS"} - - -- init flags map - self.mapflags = - { - -- optimize - ["-O0"] = "-Od" - , ["-O3"] = "-Ot" - , ["-Ofast"] = "-Ox" - , ["-fomit-frame-pointer"] = "-Oy" - - -- symbols - , ["-g"] = "-Z7" - , ["-fvisibility=.*"] = "" - - -- warnings - , ["-Wall"] = "-W3" -- = "-Wall" will enable too more warnings - , ["-W1"] = "-W1" - , ["-W2"] = "-W2" - , ["-W3"] = "-W3" - , ["-Werror"] = "-WX" - , ["%-Wno%-error=.*"] = "" - - -- vectorexts - , ["-mmmx"] = "-arch:MMX" - , ["-msse"] = "-arch:SSE" - , ["-msse2"] = "-arch:SSE2" - , ["-msse3"] = "-arch:SSE3" - , ["-mssse3"] = "-arch:SSSE3" - , ["-mavx"] = "-arch:AVX" - , ["-mavx2"] = "-arch:AVX2" - , ["-mfpu=.*"] = "" - - -- others - , ["-ftrapv"] = "" - , ["-fsanitize=address"] = "" - } - -end - --- make the compiler command -function ml.command_compile(self, srcfile, objfile, flags, logfile) - - -- redirect - local redirect = "" - if logfile then redirect = string.format(" > %s 2>&1", logfile) end - - -- make it - return string.format("%s -c %s -Fo%s %s%s", self.name, flags, objfile, srcfile, redirect) -end - --- make the define flag -function ml.flag_define(self, define) - - -- make it - return "-D" .. define:gsub("\"", "\\\"") -end - --- make the undefine flag -function ml.flag_undefine(self, undefine) - - -- make it - return "-U" .. undefine -end - --- make the includedir flag -function ml.flag_includedir(self, includedir) - - -- make it - return "-I" .. includedir -end - --- the main function -function ml.main(self, cmd) - - -- the windows module - local windows = platform.module() - assert(windows) - - -- enter envirnoment - windows.enter() - - -- execute it - local ok = os.execute(cmd) - - -- leave envirnoment - windows.leave() - - -- ok? - return utils.ifelse(ok == 0, true, false) -end - --- return module: ml -return ml diff --git a/xmake/scripts/platform/windows/tools/nmake.lua b/xmake/scripts/platform/windows/tools/nmake.lua deleted file mode 100644 index 3dddc7cf2..000000000 --- a/xmake/scripts/platform/windows/tools/nmake.lua +++ /dev/null @@ -1,74 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- 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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file nmake.lua --- - --- load modules -local os = require("base/os") -local path = require("base/path") -local utils = require("base/utils") -local string = require("base/string") -local config = require("base/config") -local platform = require("platform/platform") - --- define module: nmake -local nmake = nmake or {} - --- the init function -function nmake.init(self, name) - - -- save name - self.name = name or "nmake.exe" - - -- is verbose? - self._VERBOSE = utils.ifelse(xmake._OPTIONS.verbose, "-v", "") - -end - --- the main function -function nmake.main(self, mkfile, target) - - -- the windows module - local windows = platform.module() - assert(windows) - - -- enter envirnoment - windows.enter() - - -- make command - local cmd = nil - if mkfile and os.isfile(mkfile) then - cmd = string.format("%s /nologo /f %s %s VERBOSE=%s", self.name, mkfile, target or "", self._VERBOSE) - else - cmd = string.format("%s /nologo %s VERBOSE=%s", self.name, target or "", self._VERBOSE) - end - - -- done - local ok = os.execute(cmd) - - -- leave envirnoment - windows.leave() - - -- ok? - return utils.ifelse(ok == 0, true, false) -end - --- return module: nmake -return nmake diff --git a/xmake/scripts/platform/windows/windows.lua b/xmake/scripts/platform/windows/windows.lua deleted file mode 100644 index 794358dc1..000000000 --- a/xmake/scripts/platform/windows/windows.lua +++ /dev/null @@ -1,144 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- 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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file windows.lua --- - --- define module: windows -local windows = windows or {} - --- load modules -local os = require("base/os") -local config = require("base/config") - --- init host -windows._HOST = "windows" - --- init os -windows._OS = "windows" - --- init architectures -windows._ARCHS = {"x86", "x64", "amd64", "x86_amd64"} - --- enter the given environment -function windows._enter(name) - - -- check - assert(name) - - -- get the pathes for the vs environment - local old = nil - local new = config.get("__vsenv_" .. name) - if new then - - -- get the current pathes - old = os.getenv(name) or "" - - -- append the current pathes - new = new .. ";" .. old - - -- update the pathes for the environment - os.setenv(name, new) - end - - -- return the previous environment - return old; -end - --- leave the given environment -function windows._leave(name, old) - - -- check - assert(name) - - -- restore the previous environment - if old then - os.setenv(name, old) - end -end - --- enter environment -function windows.enter() - - -- enter the vs environment - windows._pathes = windows._enter("path") - windows._libs = windows._enter("lib") - windows._includes = windows._enter("include") - windows._libpathes = windows._enter("libpath") - -end - --- leave environment -function windows.leave() - - -- leave the vs environment - windows._leave("path", windows._pathes) - windows._leave("lib", windows._libs) - windows._leave("include", windows._includes) - windows._leave("libpath", windows._libpathes) - -end --- make configure -function windows.make(configs) - - -- init the file formats - configs.formats = {} - configs.formats.static = {"", ".lib"} - configs.formats.object = {"", ".obj"} - configs.formats.shared = {"", ".dll"} - configs.formats.binary = {"", ".exe"} - - -- init the toolchains - configs.tools = {} - configs.tools.make = config.get("make") - configs.tools.cc = config.get("cc") - configs.tools.cxx = config.get("cxx") - configs.tools.ld = config.get("ld") - configs.tools.ar = config.get("ar") - configs.tools.sh = config.get("sh") - configs.tools.as = config.get("as") - configs.tools.ex = config.get("ex") -end - --- get the option menu for action: xmake config or global -function windows.menu(action) - - -- init config option menu - windows._MENU_CONFIG = windows._MENU_CONFIG or - { {} - , {nil, "vs", "kv", "auto", "The Microsoft Visual Studio" } - , } - - -- init global option menu - windows._MENU_GLOBAL = windows._MENU_GLOBAL or - { {} - , {nil, "vs", "kv", "auto", "The Microsoft Visual Studio" } - , } - - -- get the option menu - if action == "config" then - return windows._MENU_CONFIG - elseif action == "global" then - return windows._MENU_GLOBAL - end -end - - --- return module: windows -return windows |
