diff options
Diffstat (limited to 'xmake/plugins')
| -rw-r--r-- | xmake/plugins/doxygen/main.lua | 3 | ||||
| -rw-r--r-- | xmake/plugins/macro/macros/package.lua | 3 | ||||
| -rw-r--r-- | xmake/plugins/project/vstudio/impl/vs200x_solution.lua | 8 | ||||
| -rw-r--r-- | xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua | 2 | ||||
| -rw-r--r-- | xmake/plugins/project/vstudio/impl/vs201x_solution.lua | 8 | ||||
| -rw-r--r-- | xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua | 2 | ||||
| -rw-r--r-- | xmake/plugins/project/vstudio/impl/vs201x_vcxproj_filters.lua | 2 | ||||
| -rw-r--r-- | xmake/plugins/repo/main.lua | 158 | ||||
| -rw-r--r-- | xmake/plugins/repo/xmake.lua | 54 |
9 files changed, 223 insertions, 17 deletions
diff --git a/xmake/plugins/doxygen/main.lua b/xmake/plugins/doxygen/main.lua index c13327959..fe9c0df4d 100644 --- a/xmake/plugins/doxygen/main.lua +++ b/xmake/plugins/doxygen/main.lua @@ -44,9 +44,6 @@ function main() -- load configure config.load() - -- load project - project.load() - -- enable recursive -- -- RECURSIVE = YES diff --git a/xmake/plugins/macro/macros/package.lua b/xmake/plugins/macro/macros/package.lua index 27f15969c..c9fef7977 100644 --- a/xmake/plugins/macro/macros/package.lua +++ b/xmake/plugins/macro/macros/package.lua @@ -73,9 +73,6 @@ function main(argv) -- load configure config.load() - -- load project - project.load() - -- enter the project directory os.cd(project.directory()) diff --git a/xmake/plugins/project/vstudio/impl/vs200x_solution.lua b/xmake/plugins/project/vstudio/impl/vs200x_solution.lua index b076d35bd..26117a557 100644 --- a/xmake/plugins/project/vstudio/impl/vs200x_solution.lua +++ b/xmake/plugins/project/vstudio/impl/vs200x_solution.lua @@ -43,12 +43,12 @@ function _make_projects(slnfile, vsinfo) if not target:isphony() then -- enter project - slnfile:enter("Project(\"{%s}\") = \"%s\", \"%s\\%s.vcproj\", \"{%s}\"", vctool, targetname, targetname, targetname, os.uuid(targetname)) + slnfile:enter("Project(\"{%s}\") = \"%s\", \"%s\\%s.vcproj\", \"{%s}\"", vctool, targetname, targetname, targetname, hash.uuid(targetname)) -- add dependences for _, dep in ipairs(target:get("deps")) do slnfile:enter("ProjectSection(ProjectDependencies) = postProject") - slnfile:print("{%s} = {%s}", os.uuid(dep), os.uuid(dep)) + slnfile:print("{%s} = {%s}", hash.uuid(dep), hash.uuid(dep)) slnfile:leave("EndProjectSection") end @@ -73,8 +73,8 @@ function _make_global(slnfile, vsinfo) slnfile:enter("GlobalSection(ProjectConfigurationPlatforms) = postSolution") for targetname, target in pairs(project.targets()) do if not target:isphony() then - slnfile:print("{%s}.$(mode)|Win32.ActiveCfg = $(mode)|Win32", os.uuid(targetname)) - slnfile:print("{%s}.$(mode)|Win32.Build.0 = $(mode)|Win32", os.uuid(targetname)) + slnfile:print("{%s}.$(mode)|Win32.ActiveCfg = $(mode)|Win32", hash.uuid(targetname)) + slnfile:print("{%s}.$(mode)|Win32.Build.0 = $(mode)|Win32", hash.uuid(targetname)) end end slnfile:leave("EndGlobalSection") diff --git a/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua b/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua index 102ab8399..eb0706cf8 100644 --- a/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua +++ b/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua @@ -133,7 +133,7 @@ function _make_header(vcprojfile, vsinfo, target) vcprojfile:print("ProjectType=\"Visual C++\"") vcprojfile:print("Version=\"%s0\"", assert(versions["vs" .. vsinfo.vstudio_version])) vcprojfile:print("Name=\"%s\"", targetname) - vcprojfile:print("ProjectGUID=\"{%s}\"", os.uuid(targetname)) + vcprojfile:print("ProjectGUID=\"{%s}\"", hash.uuid(targetname)) vcprojfile:print("RootNamespace=\"%s\"", targetname) vcprojfile:print("TargetFrameworkVersion=\"196613\"") vcprojfile:print(">") diff --git a/xmake/plugins/project/vstudio/impl/vs201x_solution.lua b/xmake/plugins/project/vstudio/impl/vs201x_solution.lua index 40ac3e0f5..73bc1655d 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x_solution.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x_solution.lua @@ -43,12 +43,12 @@ function _make_projects(slnfile, vsinfo) if not target:isphony() then -- enter project - slnfile:enter("Project(\"{%s}\") = \"%s\", \"%s\\%s.vcxproj\", \"{%s}\"", vctool, targetname, targetname, targetname, os.uuid(targetname)) + slnfile:enter("Project(\"{%s}\") = \"%s\", \"%s\\%s.vcxproj\", \"{%s}\"", vctool, targetname, targetname, targetname, hash.uuid(targetname)) -- add dependences for _, dep in ipairs(target:get("deps")) do slnfile:enter("ProjectSection(ProjectDependencies) = postProject") - slnfile:print("{%s} = {%s}", os.uuid(dep), os.uuid(dep)) + slnfile:print("{%s} = {%s}", hash.uuid(dep), hash.uuid(dep)) slnfile:leave("EndProjectSection") end @@ -79,8 +79,8 @@ function _make_global(slnfile, vsinfo) if not target:isphony() then for _, mode in ipairs(vsinfo.modes) do for _, arch in ipairs({"x86", "x64"}) do - slnfile:print("{%s}.%s|%s.ActiveCfg = %s|%s", os.uuid(targetname), mode, arch, mode, arch) - slnfile:print("{%s}.%s|%s.Build.0 = %s|%s", os.uuid(targetname), mode, arch, mode, arch) + slnfile:print("{%s}.%s|%s.ActiveCfg = %s|%s", hash.uuid(targetname), mode, arch, mode, arch) + slnfile:print("{%s}.%s|%s.Build.0 = %s|%s", hash.uuid(targetname), mode, arch, mode, arch) end end end diff --git a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua index 7abe20a54..fbff38a72 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua @@ -157,7 +157,7 @@ function _make_configurations(vcxprojfile, vsinfo, target, vcxprojdir) -- make Globals vcxprojfile:enter("<PropertyGroup Label=\"Globals\">") - vcxprojfile:print("<ProjectGuid>{%s}</ProjectGuid>", os.uuid(targetname)) + vcxprojfile:print("<ProjectGuid>{%s}</ProjectGuid>", hash.uuid(targetname)) vcxprojfile:print("<RootNamespace>%s</RootNamespace>", targetname) if vsinfo.vstudio_version >= "2015" then vcxprojfile:print("<WindowsTargetPlatformVersion>%s</WindowsTargetPlatformVersion>", sdkver or sdk_versions["vs" .. vsinfo.vstudio_version]) diff --git a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj_filters.lua b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj_filters.lua index f15fa9c5f..7361611e2 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj_filters.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj_filters.lua @@ -75,7 +75,7 @@ function _make_filters(filtersfile, vsinfo, target, vcxprojdir) while filter and filter ~= '.' do
if not exists[filter] then
filtersfile:enter("<Filter Include=\"%s\">", filter)
- filtersfile:print("<UniqueIdentifier>{%s}</UniqueIdentifier>", os.uuid(filter))
+ filtersfile:print("<UniqueIdentifier>{%s}</UniqueIdentifier>", hash.uuid(filter))
filtersfile:leave("</Filter>")
exists[filter] = true
end
diff --git a/xmake/plugins/repo/main.lua b/xmake/plugins/repo/main.lua new file mode 100644 index 000000000..58d9b2090 --- /dev/null +++ b/xmake/plugins/repo/main.lua @@ -0,0 +1,158 @@ +--!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 main.lua +-- + +-- imports +import("core.base.option") +import("core.project.config") +import("core.project.project") +import("core.platform.platform") +import("core.package.repository") +import("devel.git") + +-- add repository url +function _add(name, url, is_global) + + -- add url + repository.add(name, url, is_global) + + -- remove previous repository if exists + local repodir = path.join(repository.directory(is_global), name) + if os.isdir(repodir) then + os.rmdir(repodir) + end + + -- clone repository + git.clone(url, {verbose = option.get("verbose"), branch = "master", outputdir = repodir}) + + -- trace + cprint("${bright}add %s repository(%s): %s ok!", ifelse(is_global, "global", "local"), name, url) +end + +-- remove repository url +function _remove(name, is_global) + + -- remove url + repository.remove(name, is_global) + + -- remove repository + local repodir = path.join(repository.directory(is_global), name) + if os.isdir(repodir) then + os.rmdir(repodir) + end + + -- trace + cprint("${bright}remove %s repository(%s): %s ok!", ifelse(is_global, "global", "local"), name, url) +end + +-- clear all repositories +function _clear(is_global) + + -- clear all urls + repository.clear(is_global) + + -- remove all repositories + local repodir = repository.directory(is_global) + if os.isdir(repodir) then + os.rmdir(repodir) + end + + -- trace + cprint("${bright}clear %s repositories: ok!", ifelse(is_global, "global", "local")) +end + +-- list all repositories +function _list(is_global) + + -- list all repositories + local count = 0 + for _, position in ipairs({"local", "global"}) do + + -- trace + print("%s repositories:", position) + + -- list all + for _, repo in pairs(repository.repositories(position == "global")) do + + -- trace + print(" %s %s", repo.name, repo.url) + + -- update count + count = count + 1 + end + + -- trace + print("") + end + + -- trace + print("%d repositories were found!", count) +end + +-- load project +function _load_project() + + -- enter project directory + os.cd(project.directory()) + + -- load config + config.load() + + -- load platform + platform.load(config.plat()) +end + +-- main +function main() + + -- load project if operate local repositories + if not option.get("global") then + _load_project() + end + + -- add repository url + if option.get("add") then + + _add(option.get("name"), option.get("url"), option.get("global")) + + -- remove repository url + elseif option.get("remove") then + + _remove(option.get("name"), option.get("global")) + + -- clear all repositories + elseif option.get("clear") then + + _clear(option.get("global")) + + -- list all repositories + elseif option.get("list") then + + _list(option.get("global")) + + -- show help + else + option.show_help() + end +end + diff --git a/xmake/plugins/repo/xmake.lua b/xmake/plugins/repo/xmake.lua new file mode 100644 index 000000000..6f38fdc12 --- /dev/null +++ b/xmake/plugins/repo/xmake.lua @@ -0,0 +1,54 @@ +--!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 repo.lua +-- + +-- define task +task("repo") + + -- set category + set_category("plugin") + + -- on run + on_run("main") + + -- set menu + set_menu { + -- usage + usage = "xmake repo [options] [name] [url]" + + -- description + , description = "Manage package repositories." + + -- options + , options = + { + {'a', "add", "k", nil, "Add the given remote repository url." } + , {'r', "remove", "k", nil, "Remove the given remote repository url." } + , {'l', "list", "k", nil, "List all added repositories." } + , {'g', "global", "k", nil, "Save repository to global. (default: local)" } + , {'c', "clear", "k", nil, "Clear all added repositories." } + , { } + , {nil, "name", "v", nil, "The repository name." } + , {nil, "url", "v", nil, "The repository url" } + } + } |
