diff options
| author | ruki <[email protected]> | 2015-05-19 13:55:47 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-05-19 13:55:47 +0800 |
| commit | f9214c5e20b64d662af20b83da5889e6675dea95 (patch) | |
| tree | 7683e43755a87f624f2c972dec511d83e5191b26 /xmake/scripts | |
| parent | 050d1882cf578ca81f92666d42bc005b7c0eb914 (diff) | |
add platform for macosx
Diffstat (limited to 'xmake/scripts')
| -rw-r--r-- | xmake/scripts/base/main.lua | 11 | ||||
| -rw-r--r-- | xmake/scripts/base/makefile.lua | 7 | ||||
| -rw-r--r-- | xmake/scripts/base/os.lua | 1 | ||||
| -rw-r--r-- | xmake/scripts/platform/_macosx.lua | 48 | ||||
| -rw-r--r-- | xmake/scripts/platform/platform.lua | 69 |
5 files changed, 136 insertions, 0 deletions
diff --git a/xmake/scripts/base/main.lua b/xmake/scripts/base/main.lua index e746e5f01..e09613254 100644 --- a/xmake/scripts/base/main.lua +++ b/xmake/scripts/base/main.lua @@ -32,6 +32,7 @@ local config = require("base/config") local project = require("base/project") local preprocessor = require("base/preprocessor") local action = require("action/action") +local platform = require("platform/platform") -- init the option menu local menu = @@ -325,12 +326,22 @@ function main._done_option() return false end + -- init platform + if not platform.init() then + -- error + utils.error("init platform: %s failed!", config.target().plat) + return false + end + -- dump project project.dump() -- dump config config.dump() + -- dump platform + platform.dump() + -- enter the project directory if not os.cd(xmake._PROJECT_DIR) then -- error diff --git a/xmake/scripts/base/makefile.lua b/xmake/scripts/base/makefile.lua index b7d8813ee..80ef7aa45 100644 --- a/xmake/scripts/base/makefile.lua +++ b/xmake/scripts/base/makefile.lua @@ -29,6 +29,7 @@ local os = require("base/os") local utils = require("base/utils") local config = require("base/config") local project = require("base/project") +local platform = require("platform/platform") -- make the given target to the makefile function makefile._make_target(file, name, target) @@ -47,6 +48,12 @@ function makefile._make_target(file, name, target) end end + -- make dependence for object + local srcfiles = os.match(target.files) + for _, srcfile in ipairs(srcfiles) do + file:write(" " .. srcfile) + end + -- make dependence end file:write("\n") diff --git a/xmake/scripts/base/os.lua b/xmake/scripts/base/os.lua index 31434f37c..31ff7957f 100644 --- a/xmake/scripts/base/os.lua +++ b/xmake/scripts/base/os.lua @@ -155,6 +155,7 @@ end -- @code -- local dirs, count = os.match("./src/*", true) -- local files, count = os.match("./src/**.c") +-- local file = os.match("./src/test.c") -- @endcode -- function os.match(pattern, findir) diff --git a/xmake/scripts/platform/_macosx.lua b/xmake/scripts/platform/_macosx.lua new file mode 100644 index 000000000..428d2ae02 --- /dev/null +++ b/xmake/scripts/platform/_macosx.lua @@ -0,0 +1,48 @@ +--!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 {} + +-- init _macosx +function _macosx.init() + + -- init configs + local configs = {} + + -- init the target file suffix name + configs.suffix = {} + configs.suffix.static = ".a" + configs.suffix.object = ".o" + configs.suffix.shared = ".dylib" + + -- init the target file prefix name + configs.prefix = {} + configs.prefix.static = "lib" + + -- ok + return configs +end + + +-- return module: _macosx +return _macosx diff --git a/xmake/scripts/platform/platform.lua b/xmake/scripts/platform/platform.lua new file mode 100644 index 000000000..47ccb4914 --- /dev/null +++ b/xmake/scripts/platform/platform.lua @@ -0,0 +1,69 @@ +--!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 utils = require("base/utils") +local config = require("base/config") + +-- init platform +function platform.init() + + -- have been existed? + if platform._CONFIGS then + return platform._CONFIGS + end + + -- get target + local target = config.target() + assert(target) + + -- load platform + local p = require("platform/_" .. target.plat) + if not p then + return nil + end + + -- init platform + platform._CONFIGS = p.init() + + -- ok? + return platform._CONFIGS +end + +-- dump configs +function platform.dump() + + -- check + assert(platform._CONFIGS) + + -- dump + if xmake._OPTIONS.verbose then + utils.dump(platform._CONFIGS) + end + +end + +-- return module: platform +return platform |
