summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-09-30 22:43:15 +0800
committerruki <[email protected]>2020-09-30 22:43:15 +0800
commit4222cd03180c03accff03b61731dc0be9f4f748b (patch)
tree22d663c72a861b8d59b384af6bfe534c2bdfc49b
parent8190a5609f21bf5ea90bec0a11afb183190a8a50 (diff)
export builtin action/install module
-rw-r--r--xmake/actions/install/install.lua42
-rw-r--r--xmake/actions/uninstall/uninstall.lua34
-rw-r--r--xmake/modules/action/install/main.lua60
-rw-r--r--xmake/modules/action/install/unix.lua (renamed from xmake/actions/install/install/unix.lua)0
-rw-r--r--xmake/modules/action/install/windows.lua (renamed from xmake/actions/install/install/windows.lua)0
-rw-r--r--xmake/modules/action/uninstall/main.lua53
-rw-r--r--xmake/modules/action/uninstall/unix.lua (renamed from xmake/actions/uninstall/uninstall/unix.lua)0
-rw-r--r--xmake/modules/action/uninstall/windows.lua (renamed from xmake/actions/uninstall/uninstall/windows.lua)0
8 files changed, 115 insertions, 74 deletions
diff --git a/xmake/actions/install/install.lua b/xmake/actions/install/install.lua
index cd6b872c6..533bba505 100644
--- a/xmake/actions/install/install.lua
+++ b/xmake/actions/install/install.lua
@@ -22,47 +22,7 @@
import("core.base.task")
import("core.project.rule")
import("core.project.project")
-
--- install files
-function _install_files(target)
-
- local srcfiles, dstfiles = target:installfiles()
- if srcfiles and dstfiles then
- local i = 1
- for _, srcfile in ipairs(srcfiles) do
- local dstfile = dstfiles[i]
- if dstfile then
- os.vcp(srcfile, dstfile)
- end
- i = i + 1
- end
- end
-end
-
--- do install target
-function _do_install_target(target)
-
- -- get install directory
- local installdir = target:installdir()
- if not installdir then
- return
- end
-
- -- trace
- print("installing to %s ..", installdir)
-
- -- call script
- if not target:isphony() then
- local install_style = target:is_plat("windows", "mingw") and "windows" or "unix"
- local script = import("install." .. install_style, {anonymous = true})["install_" .. target:targetkind()]
- if script then
- script(target)
- end
- end
-
- -- install other files
- _install_files(target)
-end
+import("action.install", {alias = "_do_install_target"})
-- on install target
function _on_install_target(target)
diff --git a/xmake/actions/uninstall/uninstall.lua b/xmake/actions/uninstall/uninstall.lua
index e254e3e9a..42b93b57b 100644
--- a/xmake/actions/uninstall/uninstall.lua
+++ b/xmake/actions/uninstall/uninstall.lua
@@ -22,39 +22,7 @@
import("core.base.task")
import("core.project.rule")
import("core.project.project")
-
--- uninstall files
-function _uninstall_files(target)
- local _, dstfiles = target:installfiles()
- for _, dstfile in ipairs(dstfiles) do
- os.vrm(dstfile)
- end
-end
-
--- do uninstall target
-function _do_uninstall_target(target)
-
- -- get install directory
- local installdir = target:installdir()
- if not installdir then
- return
- end
-
- -- trace
- print("uninstalling from %s ..", installdir)
-
- -- call script
- if not target:isphony() then
- local install_style = target:is_plat("windows", "mingw") and "windows" or "unix"
- local script = import("uninstall." .. install_style, {anonymous = true})["uninstall_" .. target:targetkind()]
- if script then
- script(target)
- end
- end
-
- -- uninstall the other files
- _uninstall_files(target)
-end
+import("action.uninstall", {alias = "_do_uninstall_target"})
-- on uninstall target
function _on_uninstall_target(target)
diff --git a/xmake/modules/action/install/main.lua b/xmake/modules/action/install/main.lua
new file mode 100644
index 000000000..51ced360f
--- /dev/null
+++ b/xmake/modules/action/install/main.lua
@@ -0,0 +1,60 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed 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-2020, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file main.lua
+--
+
+-- install files
+function _install_files(target)
+
+ local srcfiles, dstfiles = target:installfiles()
+ if srcfiles and dstfiles then
+ local i = 1
+ for _, srcfile in ipairs(srcfiles) do
+ local dstfile = dstfiles[i]
+ if dstfile then
+ os.vcp(srcfile, dstfile)
+ end
+ i = i + 1
+ end
+ end
+end
+
+-- the builtin install main entry
+function main(target)
+
+ -- get install directory
+ local installdir = target:installdir()
+ if not installdir then
+ return
+ end
+
+ -- trace
+ print("installing to %s ..", installdir)
+
+ -- call script
+ if not target:isphony() then
+ local install_style = target:is_plat("windows", "mingw") and "windows" or "unix"
+ local script = import(install_style, {anonymous = true})["install_" .. target:targetkind()]
+ if script then
+ script(target)
+ end
+ end
+
+ -- install other files
+ _install_files(target)
+end
diff --git a/xmake/actions/install/install/unix.lua b/xmake/modules/action/install/unix.lua
index 75dd750c9..75dd750c9 100644
--- a/xmake/actions/install/install/unix.lua
+++ b/xmake/modules/action/install/unix.lua
diff --git a/xmake/actions/install/install/windows.lua b/xmake/modules/action/install/windows.lua
index 3019152d1..3019152d1 100644
--- a/xmake/actions/install/install/windows.lua
+++ b/xmake/modules/action/install/windows.lua
diff --git a/xmake/modules/action/uninstall/main.lua b/xmake/modules/action/uninstall/main.lua
new file mode 100644
index 000000000..fe9b7e2db
--- /dev/null
+++ b/xmake/modules/action/uninstall/main.lua
@@ -0,0 +1,53 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed 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-2020, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file main.lua
+--
+
+-- uninstall files
+function _uninstall_files(target)
+ local _, dstfiles = target:installfiles()
+ for _, dstfile in ipairs(dstfiles) do
+ os.vrm(dstfile)
+ end
+end
+
+-- the builtin uninstall main entry
+function main(target)
+
+ -- get install directory
+ local installdir = target:installdir()
+ if not installdir then
+ return
+ end
+
+ -- trace
+ print("uninstalling from %s ..", installdir)
+
+ -- call script
+ if not target:isphony() then
+ local install_style = target:is_plat("windows", "mingw") and "windows" or "unix"
+ local script = import(install_style, {anonymous = true})["uninstall_" .. target:targetkind()]
+ if script then
+ script(target)
+ end
+ end
+
+ -- uninstall the other files
+ _uninstall_files(target)
+end
+
diff --git a/xmake/actions/uninstall/uninstall/unix.lua b/xmake/modules/action/uninstall/unix.lua
index 90f07d364..90f07d364 100644
--- a/xmake/actions/uninstall/uninstall/unix.lua
+++ b/xmake/modules/action/uninstall/unix.lua
diff --git a/xmake/actions/uninstall/uninstall/windows.lua b/xmake/modules/action/uninstall/windows.lua
index 865e80c7e..865e80c7e 100644
--- a/xmake/actions/uninstall/uninstall/windows.lua
+++ b/xmake/modules/action/uninstall/windows.lua