diff options
| author | ruki <[email protected]> | 2017-01-11 09:20:37 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-01-11 09:20:37 +0800 |
| commit | 1be86fced4accecba8f00b903610a42dbd32f33a (patch) | |
| tree | 8937a8407b1b4106aadff5bc441ac97a9e6a3e4e | |
| parent | 6ee204e38815d742b5594c22f2646647d7658a48 (diff) | |
add language menu
| -rwxr-xr-x | xmake/actions/config/xmake.lua | 37 | ||||
| -rw-r--r-- | xmake/core/language/language.lua | 10 | ||||
| -rw-r--r-- | xmake/core/language/menu.lua | 97 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/language/menu.lua | 47 | ||||
| -rwxr-xr-x | xmake/languages/asm/xmake.lua | 28 | ||||
| -rwxr-xr-x | xmake/languages/c++/xmake.lua | 28 | ||||
| -rwxr-xr-x | xmake/languages/golang/xmake.lua | 18 | ||||
| -rwxr-xr-x | xmake/languages/objc++/xmake.lua | 28 | ||||
| -rwxr-xr-x | xmake/languages/swift/xmake.lua | 26 | ||||
| -rwxr-xr-x | xmake/platforms/iphoneos/xmake.lua | 6 | ||||
| -rwxr-xr-x | xmake/platforms/macosx/xmake.lua | 6 | ||||
| -rwxr-xr-x | xmake/platforms/watchos/xmake.lua | 6 |
12 files changed, 289 insertions, 48 deletions
diff --git a/xmake/actions/config/xmake.lua b/xmake/actions/config/xmake.lua index bfa27f88b..8d9cdefee 100755 --- a/xmake/actions/config/xmake.lua +++ b/xmake/actions/config/xmake.lua @@ -121,40 +121,19 @@ task("config") , " - sdk/bin (toolchains)" , " - sdk/lib" , " - sdk/include" } - , {} - , {nil, "cc", "kv", nil, "The C Compiler" } - , {nil, "cxx", "kv", nil, "The C++ Compiler" } - , {nil, "cflags", "kv", nil, "The C Compiler Flags" } - , {nil, "cxflags", "kv", nil, "The C/C++ compiler Flags" } - , {nil, "cxxflags", "kv", nil, "The C++ Compiler Flags" } - - , {} - , {nil, "as", "kv", nil, "The Assembler" } - , {nil, "asflags", "kv", nil, "The Assembler Flags" } - - , {} - , {nil, "sc", "kv", nil, "The Swift Compiler" } - , {nil, "scflags", "kv", nil, "The Swift Compiler Flags" } , {} - , {nil, "ld", "kv", nil, "The Linker" } - , {nil, "ldflags", "kv", nil, "The Binary Linker Flags" } + , {nil, "dd", "kv", "auto", "The Debugger" } - , {} - , {nil, "ar", "kv", nil, "The Static Library Linker" } - , {nil, "arflags", "kv", nil, "The Static Library Linker Flags" } + -- show language menu options + , function () - , {} - , {nil, "sh", "kv", nil, "The Shared Library Linker" } - , {nil, "shflags", "kv", nil, "The Shared Library Linker Flags" } - - , {} - , {nil, "links", "kv", nil, "The Link Libraries" } - , {nil, "linkdirs", "kv", nil, "The Link Search Directories" } - , {nil, "includedirs","kv", nil, "The Include Search Directories" } + -- import language menu + import("core.language.menu") - , {} - , {nil, "dd", "kv", "auto", "The Debugger" } + -- get config menu options + return menu.options("config") + end -- show platform menu options , function () diff --git a/xmake/core/language/language.lua b/xmake/core/language/language.lua index 2801e9bd2..5168b29ae 100644 --- a/xmake/core/language/language.lua +++ b/xmake/core/language/language.lua @@ -80,6 +80,13 @@ function _instance:get(name) return self._g[name] end +-- get the language menu +function _instance:menu() + + -- get it + return self._INFO.menu +end + -- get the language sourcekinds function _instance:sourcekinds() @@ -119,7 +126,8 @@ function language._interpreter() values = { -- language.set_xxx - "language.set_sourcekinds" + "language.set_menu" + , "language.set_sourcekinds" , "language.set_targetkinds" } , script = diff --git a/xmake/core/language/menu.lua b/xmake/core/language/menu.lua new file mode 100644 index 000000000..965d7b101 --- /dev/null +++ b/xmake/core/language/menu.lua @@ -0,0 +1,97 @@ +--!The Make-like Build Utility based on Lua +-- +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015 - 2017, TBOOX Open Source Group. +-- +-- @author ruki +-- @file menu.lua +-- + +-- define module +local menu = menu or {} + +-- load modules +local os = require("base/os") +local path = require("base/path") +local utils = require("base/utils") +local table = require("base/table") +local language = require("language/language") + +-- get the option menu for action: xmake config or global +function menu.options(action) + + -- check + assert(action) + + -- load all languages + local languages, errors = language.load() + if not languages then + os.raise(errors) + end + + -- load and merge all language options + local exist = {} + local results = {} + for _, instance in pairs(languages) do + + -- get menu + local menu = instance:menu() + if menu then + + -- get the options for this action + local options = menu[action] + if options then + + -- exists options? + local exists = false + for _, option in ipairs(options) 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 language option + for _, option in ipairs(options) do + + -- merge it and remove repeat + local name = option[2] + if name then + if not exist[name] then + table.insert(results, option) + exist[name] = true + end + else + table.insert(results, option) + end + end + end + end + end + end + + -- ok? + return results +end + +-- return module +return menu diff --git a/xmake/core/sandbox/modules/import/core/language/menu.lua b/xmake/core/sandbox/modules/import/core/language/menu.lua new file mode 100644 index 000000000..b21f6bb73 --- /dev/null +++ b/xmake/core/sandbox/modules/import/core/language/menu.lua @@ -0,0 +1,47 @@ +--!The Make-like Build Utility based on Lua +-- +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015 - 2017, TBOOX Open Source Group. +-- +-- @author ruki +-- @file menu.lua +-- + +-- define module +local sandbox_core_language_menu = sandbox_core_language_menu or {} + +-- load modules +local menu = require("language/menu") +local raise = require("sandbox/modules/raise") + +-- get the language menu options for the given action: config or global +function sandbox_core_language_menu.options(action) + + -- get it + local options, errors = menu.options(action) + if not options then + raise(errors) + end + + -- ok? + return options +end + + +-- return module +return sandbox_core_language_menu diff --git a/xmake/languages/asm/xmake.lua b/xmake/languages/asm/xmake.lua index 6a641c5e3..7eee220a4 100755 --- a/xmake/languages/asm/xmake.lua +++ b/xmake/languages/asm/xmake.lua @@ -34,5 +34,33 @@ language("asm") -- on load on_load("load") + -- set menu + set_menu({ + config = + { + {} + , {nil, "as", "kv", nil, "The Assembler" } + , {nil, "asflags", "kv", nil, "The Assembler Flags" } + + , {} + , {nil, "ar", "kv", nil, "The Static Library Linker" } + , {nil, "arflags", "kv", nil, "The Static Library Linker Flags" } + + , {} + , {nil, "sh", "kv", nil, "The Shared Library Linker" } + , {nil, "shflags", "kv", nil, "The Shared Library Linker Flags" } + + , {} + , {nil, "links", "kv", nil, "The Link Libraries" } + , {nil, "linkdirs", "kv", nil, "The Link Search Directories" } + , {nil, "includedirs","kv", nil, "The Include Search Directories" } + } + }) + + + + + + diff --git a/xmake/languages/c++/xmake.lua b/xmake/languages/c++/xmake.lua index 594dcb2c9..1a19aa3be 100755 --- a/xmake/languages/c++/xmake.lua +++ b/xmake/languages/c++/xmake.lua @@ -37,6 +37,34 @@ language("c++") -- on check_main on_check_main("check_main") + -- set menu + set_menu({ + config = + { + {} + , {nil, "cc", "kv", nil, "The C Compiler" } + , {nil, "cxx", "kv", nil, "The C++ Compiler" } + , {nil, "cflags", "kv", nil, "The C Compiler Flags" } + , {nil, "cxflags", "kv", nil, "The C/C++ compiler Flags" } + , {nil, "cxxflags", "kv", nil, "The C++ Compiler Flags" } + + , {} + , {nil, "ar", "kv", nil, "The Static Library Linker" } + , {nil, "arflags", "kv", nil, "The Static Library Linker Flags" } + + , {} + , {nil, "sh", "kv", nil, "The Shared Library Linker" } + , {nil, "shflags", "kv", nil, "The Shared Library Linker Flags" } + + , {} + , {nil, "links", "kv", nil, "The Link Libraries" } + , {nil, "linkdirs", "kv", nil, "The Link Search Directories" } + , {nil, "includedirs","kv", nil, "The Include Search Directories" } + } + }) + + + diff --git a/xmake/languages/golang/xmake.lua b/xmake/languages/golang/xmake.lua index b368ae7e4..0e2ffe570 100755 --- a/xmake/languages/golang/xmake.lua +++ b/xmake/languages/golang/xmake.lua @@ -37,4 +37,22 @@ language("golang") -- on check_main on_check_main("check_main") + -- set menu + set_menu({ + config = + { + {} + , {nil, "ar", "kv", nil, "The Static Library Linker" } + , {nil, "arflags", "kv", nil, "The Static Library Linker Flags" } + + , {} + , {nil, "sh", "kv", nil, "The Shared Library Linker" } + , {nil, "shflags", "kv", nil, "The Shared Library Linker Flags" } + + , {} + , {nil, "links", "kv", nil, "The Link Libraries" } + , {nil, "linkdirs", "kv", nil, "The Link Search Directories" } + , {nil, "includedirs","kv", nil, "The Include Search Directories" } + } + }) diff --git a/xmake/languages/objc++/xmake.lua b/xmake/languages/objc++/xmake.lua index 7abddf70a..c8a166bb5 100755 --- a/xmake/languages/objc++/xmake.lua +++ b/xmake/languages/objc++/xmake.lua @@ -37,5 +37,33 @@ language("objc++") -- on check_main on_check_main("check_main") + -- set menu + set_menu({ + config = + { + {} + , {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, "ar", "kv", nil, "The Static Library Linker" } + , {nil, "arflags", "kv", nil, "The Static Library Linker Flags" } + + , {} + , {nil, "sh", "kv", nil, "The Shared Library Linker" } + , {nil, "shflags", "kv", nil, "The Shared Library Linker Flags" } + + , {} + , {nil, "links", "kv", nil, "The Link Libraries" } + , {nil, "linkdirs", "kv", nil, "The Link Search Directories" } + , {nil, "includedirs","kv", nil, "The Include Search Directories" } + + } + }) + + diff --git a/xmake/languages/swift/xmake.lua b/xmake/languages/swift/xmake.lua index 14c6c3912..cf47a5113 100755 --- a/xmake/languages/swift/xmake.lua +++ b/xmake/languages/swift/xmake.lua @@ -34,6 +34,32 @@ language("swift") -- on load on_load("load") + -- set menu + set_menu({ + config = + { + {} + , {nil, "sc", "kv", nil, "The Swift Compiler" } + , {nil, "scflags", "kv", nil, "The Swift Compiler Flags" } + + , {} + , {nil, "ld", "kv", nil, "The Linker" } + , {nil, "ldflags", "kv", nil, "The Binary Linker Flags" } + + , {} + , {nil, "ar", "kv", nil, "The Static Library Linker" } + , {nil, "arflags", "kv", nil, "The Static Library Linker Flags" } + + , {} + , {nil, "sh", "kv", nil, "The Shared Library Linker" } + , {nil, "shflags", "kv", nil, "The Shared Library Linker Flags" } + + , {} + , {nil, "links", "kv", nil, "The Link Libraries" } + , {nil, "linkdirs", "kv", nil, "The Link Search Directories" } + , {nil, "includedirs","kv", nil, "The Include Search Directories" } + } + }) diff --git a/xmake/platforms/iphoneos/xmake.lua b/xmake/platforms/iphoneos/xmake.lua index 4ca95fd9e..3016cdfc8 100755 --- a/xmake/platforms/iphoneos/xmake.lua +++ b/xmake/platforms/iphoneos/xmake.lua @@ -48,12 +48,6 @@ platform("iphoneos") config = { {} - , {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" } diff --git a/xmake/platforms/macosx/xmake.lua b/xmake/platforms/macosx/xmake.lua index 2ae330824..3fafb372b 100755 --- a/xmake/platforms/macosx/xmake.lua +++ b/xmake/platforms/macosx/xmake.lua @@ -54,12 +54,6 @@ platform("macosx") config = { {} - , {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" } diff --git a/xmake/platforms/watchos/xmake.lua b/xmake/platforms/watchos/xmake.lua index 5617ece43..b612d81db 100755 --- a/xmake/platforms/watchos/xmake.lua +++ b/xmake/platforms/watchos/xmake.lua @@ -48,12 +48,6 @@ platform("watchos") config = { {} - , {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" } |
