summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2016-04-26 13:30:43 +0800
committerruki <[email protected]>2016-04-26 13:30:43 +0800
commitbf7678ececf50ef69f81d4801a43ef572fcc2933 (patch)
tree16b10773fc50d0dd6fd7de6e2e8e5794fa3e292a
parentc172d1cda21f5ece12301bbc22d2eacf67c068d5 (diff)
add linux platform
-rw-r--r--xmake/platforms/linux/checker.lua82
-rwxr-xr-xxmake/platforms/linux/xmake.lua88
2 files changed, 170 insertions, 0 deletions
diff --git a/xmake/platforms/linux/checker.lua b/xmake/platforms/linux/checker.lua
new file mode 100644
index 000000000..ee3345bb7
--- /dev/null
+++ b/xmake/platforms/linux/checker.lua
@@ -0,0 +1,82 @@
+--!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) 2015 - 2016, ruki All rights reserved.
+--
+-- @author ruki
+-- @file checker.lua
+--
+
+-- imports
+import("core.tool.tool")
+import("platforms.checker", {rootdir = os.programdir()})
+
+-- check the architecture
+function __check_arch(config)
+
+ -- get the architecture
+ local arch = config.get("arch")
+ if not arch then
+
+ -- init the default architecture
+ config.set("arch", ifelse(config.get("cross"), "none", os.arch()))
+
+ -- trace
+ print("checking for the architecture ... %s", config.get("arch"))
+ end
+end
+
+-- check the toolchains
+function _check_toolchains(config)
+
+ -- done
+ checker.check_toolchain(config, "cc", "", "gcc", "the c compiler")
+ checker.check_toolchain(config, "cxx", "", "g++", "the c++ compiler")
+ checker.check_toolchain(config, "as", "", "gcc", "the assember")
+ checker.check_toolchain(config, "ld", "", "g++", "the linker")
+ checker.check_toolchain(config, "ar", "", "ar", "the static library linker")
+ checker.check_toolchain(config, "sh", "", "g++", "the shared library linker")
+end
+
+-- init it
+function init()
+
+ -- init the check list of config
+ _g.config =
+ {
+ __check_arch
+ , checker.check_make
+ , checker.check_ccache
+ , _check_toolchains
+ }
+
+ -- init the check list of global
+ _g.global =
+ {
+ checker.check_make
+ , checker.check_ccache
+ , _check_ndk_sdkver
+ }
+
+end
+
+-- get the property
+function get(name)
+
+ -- get it
+ return _g[name]
+end
+
diff --git a/xmake/platforms/linux/xmake.lua b/xmake/platforms/linux/xmake.lua
new file mode 100755
index 000000000..408c07b8d
--- /dev/null
+++ b/xmake/platforms/linux/xmake.lua
@@ -0,0 +1,88 @@
+--!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) 2015 - 2016, ruki All rights reserved.
+--
+-- @author ruki
+-- @file xmake.lua
+--
+
+-- define platform
+platform("linux")
+
+ -- set os
+ set_platform_os("linux")
+
+ -- set hosts
+ set_platform_hosts("macosx", "linux", "windows")
+
+ -- set archs
+ set_platform_archs("i386", "x86_64")
+
+ -- set checker
+ set_platform_checker("checker")
+
+ -- on load
+ on_platform_load(function ()
+
+ -- imports
+ import("core.project.config")
+
+ -- init the file formats
+ _g.formats = {}
+ _g.formats.static = {"lib", ".a"}
+ _g.formats.object = {"", ".o"}
+ _g.formats.shared = {"lib", ".so"}
+
+ -- init the toolchains
+ _g.tools = {}
+ _g.tools.make = config.get("make")
+ _g.tools.ccache = config.get("__ccache")
+ _g.tools.cc = config.get("cc")
+ _g.tools.cxx = config.get("cxx")
+ _g.tools.as = config.get("as")
+ _g.tools.ld = config.get("ld")
+ _g.tools.ar = config.get("ar")
+ _g.tools.sh = config.get("sh")
+ _g.tools.ex = config.get("ar")
+ _g.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
+ _g.cxflags = { archflags }
+ _g.mxflags = { archflags }
+ _g.asflags = { archflags }
+ _g.ldflags = { archflags }
+ _g.shflags = { archflags }
+
+ -- init linkdirs and includedirs
+ _g.linkdirs = {"/usr/lib", "/usr/local/lib"}
+ _g.includedirs = {"/usr/include", "/usr/local/include"}
+
+ end)
+
+
+