diff options
| author | ruki <[email protected]> | 2015-12-09 09:38:13 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-12-09 09:38:13 +0800 |
| commit | 5023cb209d1d9104b1a4ad4e99836a3c24b5302c (patch) | |
| tree | 508eaffeb9bd84aa928a486d54c2f558dd945f3f | |
| parent | f86dc16b057cab514cefb72103e7791bf9c57c23 (diff) | |
add templates for objc/objc++/swift
| -rw-r--r-- | xmake/scripts/platform/macosx/macosx.lua | 4 | ||||
| -rw-r--r-- | xmake/templates/objc++/console/_template.lua | 49 | ||||
| -rw-r--r-- | xmake/templates/objc++/console/project/src/main.mm | 10 | ||||
| -rw-r--r-- | xmake/templates/objc++/console/project/xmake.lua | 43 | ||||
| -rw-r--r-- | xmake/templates/objc/console/_template.lua | 49 | ||||
| -rw-r--r-- | xmake/templates/objc/console/project/src/main.m | 10 | ||||
| -rw-r--r-- | xmake/templates/objc/console/project/xmake.lua | 43 | ||||
| -rw-r--r-- | xmake/templates/swift/console/_template.lua | 49 | ||||
| -rw-r--r-- | xmake/templates/swift/console/project/src/main.swift | 3 | ||||
| -rw-r--r-- | xmake/templates/swift/console/project/xmake.lua | 32 |
10 files changed, 289 insertions, 3 deletions
diff --git a/xmake/scripts/platform/macosx/macosx.lua b/xmake/scripts/platform/macosx/macosx.lua index fd96d323b..f270e0305 100644 --- a/xmake/scripts/platform/macosx/macosx.lua +++ b/xmake/scripts/platform/macosx/macosx.lua @@ -99,11 +99,9 @@ function macosx.make(configs) -- init includedirs -- -- @note - -- cannot use configs.includedirs because the swift compiler will compile code failed + -- 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") - table.insert(configs.mxflags, "-I/usr/include") - table.insert(configs.mxflags, "-I/usr/local/include") end diff --git a/xmake/templates/objc++/console/_template.lua b/xmake/templates/objc++/console/_template.lua new file mode 100644 index 000000000..312273a46 --- /dev/null +++ b/xmake/templates/objc++/console/_template.lua @@ -0,0 +1,49 @@ +--!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 _template.lua +-- + +-- define module: _template +local _template = _template or {} + +-- load modules +local io = require("base/io") +local os = require("base/os") +local path = require("base/path") +local utils = require("base/utils") + +-- init the template description +_template.description = "The Console Program" + +-- done the template file +function _template.done(targetname, projectdir) + + -- check + assert(targetname and projectdir) + + -- replace the target name + io.gsub(projectdir .. "/xmake.lua", "%[targetname%]", targetname) + + -- ok + return true +end + +-- return module: _template +return _template diff --git a/xmake/templates/objc++/console/project/src/main.mm b/xmake/templates/objc++/console/project/src/main.mm new file mode 100644 index 000000000..61a3f5875 --- /dev/null +++ b/xmake/templates/objc++/console/project/src/main.mm @@ -0,0 +1,10 @@ +#import <Foundation/Foundation.h> + +int main(int argc, char** argv) +{ + @autoreleasepool + { + NSLog(@"hello world!"); + } + return 0; +} diff --git a/xmake/templates/objc++/console/project/xmake.lua b/xmake/templates/objc++/console/project/xmake.lua new file mode 100644 index 000000000..b051ac9df --- /dev/null +++ b/xmake/templates/objc++/console/project/xmake.lua @@ -0,0 +1,43 @@ +-- the debug mode +if modes("debug") then + + -- enable the debug symbols + set_symbols("debug") + + -- disable optimization + set_optimize("none") +end + +-- the release mode +if modes("release") then + + -- set the symbols visibility: hidden + set_symbols("hidden") + + -- enable fastest optimization + set_optimize("fastest") + + -- strip all symbols + set_strip("all") +end + +-- for macosx or ios +if os("macosx", "ios") then + + -- add framework + add_mxflags("-framework Foundation", "-framework CoreFoundation") + add_ldflags("-framework Foundation", "-framework CoreFoundation") + + -- enable arc? + add_mxflags("-fobjc-arc") +end + +-- add target +add_target("[targetname]") + + -- set kind + set_kind("binary") + + -- add files + add_files("src/*.mm") + diff --git a/xmake/templates/objc/console/_template.lua b/xmake/templates/objc/console/_template.lua new file mode 100644 index 000000000..312273a46 --- /dev/null +++ b/xmake/templates/objc/console/_template.lua @@ -0,0 +1,49 @@ +--!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 _template.lua +-- + +-- define module: _template +local _template = _template or {} + +-- load modules +local io = require("base/io") +local os = require("base/os") +local path = require("base/path") +local utils = require("base/utils") + +-- init the template description +_template.description = "The Console Program" + +-- done the template file +function _template.done(targetname, projectdir) + + -- check + assert(targetname and projectdir) + + -- replace the target name + io.gsub(projectdir .. "/xmake.lua", "%[targetname%]", targetname) + + -- ok + return true +end + +-- return module: _template +return _template diff --git a/xmake/templates/objc/console/project/src/main.m b/xmake/templates/objc/console/project/src/main.m new file mode 100644 index 000000000..61a3f5875 --- /dev/null +++ b/xmake/templates/objc/console/project/src/main.m @@ -0,0 +1,10 @@ +#import <Foundation/Foundation.h> + +int main(int argc, char** argv) +{ + @autoreleasepool + { + NSLog(@"hello world!"); + } + return 0; +} diff --git a/xmake/templates/objc/console/project/xmake.lua b/xmake/templates/objc/console/project/xmake.lua new file mode 100644 index 000000000..5e08682d5 --- /dev/null +++ b/xmake/templates/objc/console/project/xmake.lua @@ -0,0 +1,43 @@ +-- the debug mode +if modes("debug") then + + -- enable the debug symbols + set_symbols("debug") + + -- disable optimization + set_optimize("none") +end + +-- the release mode +if modes("release") then + + -- set the symbols visibility: hidden + set_symbols("hidden") + + -- enable fastest optimization + set_optimize("fastest") + + -- strip all symbols + set_strip("all") +end + +-- for macosx or ios +if os("macosx", "ios") then + + -- add framework + add_mxflags("-framework Foundation", "-framework CoreFoundation") + add_ldflags("-framework Foundation", "-framework CoreFoundation") + + -- enable arc? + add_mxflags("-fobjc-arc") +end + +-- add target +add_target("[targetname]") + + -- set kind + set_kind("binary") + + -- add files + add_files("src/*.m") + diff --git a/xmake/templates/swift/console/_template.lua b/xmake/templates/swift/console/_template.lua new file mode 100644 index 000000000..312273a46 --- /dev/null +++ b/xmake/templates/swift/console/_template.lua @@ -0,0 +1,49 @@ +--!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 _template.lua +-- + +-- define module: _template +local _template = _template or {} + +-- load modules +local io = require("base/io") +local os = require("base/os") +local path = require("base/path") +local utils = require("base/utils") + +-- init the template description +_template.description = "The Console Program" + +-- done the template file +function _template.done(targetname, projectdir) + + -- check + assert(targetname and projectdir) + + -- replace the target name + io.gsub(projectdir .. "/xmake.lua", "%[targetname%]", targetname) + + -- ok + return true +end + +-- return module: _template +return _template diff --git a/xmake/templates/swift/console/project/src/main.swift b/xmake/templates/swift/console/project/src/main.swift new file mode 100644 index 000000000..ee21045f4 --- /dev/null +++ b/xmake/templates/swift/console/project/src/main.swift @@ -0,0 +1,3 @@ +import Foundation + +print("hello world!") diff --git a/xmake/templates/swift/console/project/xmake.lua b/xmake/templates/swift/console/project/xmake.lua new file mode 100644 index 000000000..f4aef294d --- /dev/null +++ b/xmake/templates/swift/console/project/xmake.lua @@ -0,0 +1,32 @@ +-- the debug mode +if modes("debug") then + + -- enable the debug symbols + set_symbols("debug") + + -- disable optimization + set_optimize("none") +end + +-- the release mode +if modes("release") then + + -- set the symbols visibility: hidden + set_symbols("hidden") + + -- enable fastest optimization + set_optimize("fastest") + + -- strip all symbols + set_strip("all") +end + +-- add target +add_target("[targetname]") + + -- set kind + set_kind("binary") + + -- add files + add_files("src/*.swift") + |
