diff options
| author | ruki <[email protected]> | 2023-11-23 22:38:03 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-11-23 22:10:50 +0800 |
| commit | 95195e3199a3e03e66e6be94bf14c83c694cc8ff (patch) | |
| tree | 0bdba24bf316824906ef4497eee26ece9f44f09c | |
| parent | 6b400aa1f7a578694079ccb84813a02192cb28e6 (diff) | |
add runself stub
| -rw-r--r-- | xmake/plugins/pack/runself/main.lua | 76 | ||||
| -rw-r--r-- | xmake/plugins/pack/xpack.lua | 6 |
2 files changed, 80 insertions, 2 deletions
diff --git a/xmake/plugins/pack/runself/main.lua b/xmake/plugins/pack/runself/main.lua new file mode 100644 index 000000000..aaf267454 --- /dev/null +++ b/xmake/plugins/pack/runself/main.lua @@ -0,0 +1,76 @@ +--!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-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file main.lua +-- + +-- imports +import("core.base.option") +import("core.base.semver") +import("lib.detect.find_tool") +import("private.action.require.impl.packagenv") +import("private.action.require.impl.install_packages") +import(".batchcmds") + +-- get the makeself +function _get_makeself() + + -- enter the environments of makeself + local oldenvs = packagenv.enter("makeself") + + -- find makeself + local packages = {} + local makeself = find_tool("makeself") + if not makeself then + table.join2(packages, install_packages("makeself")) + end + + -- enter the environments of installed packages + for _, instance in ipairs(packages) do + instance:envs_enter() + end + + -- we need to force detect and flush detect cache after loading all environments + if not makeself then + makeself = find_tool("makeself", {force = true}) + end + assert(makeself, "makeself not found!") + return makeself, oldenvs +end + +-- pack runself package +function _pack_runself(makeself, package) +end + +function main(package) + + -- only for windows + if not is_subhost("windows") then + return + end + + cprint("packing %s", package:outputfile()) + + -- get makeself + local makeself, oldenvs = _get_makeself() + + -- pack runself package + _pack_runself(makeself.program, package) + + -- done + os.setenvs(oldenvs) +end diff --git a/xmake/plugins/pack/xpack.lua b/xmake/plugins/pack/xpack.lua index e5829fd45..6715fb178 100644 --- a/xmake/plugins/pack/xpack.lua +++ b/xmake/plugins/pack/xpack.lua @@ -325,7 +325,8 @@ end -- get the specfile path function xpack:specfile() local extensions = { - nsis = ".nsi" + nsis = ".nsi", + runself = ".sh" } local extension = extensions[self:format()] or ".spec" return self:get("specfile") or path.join(self:buildir(), self:basename() .. extension) @@ -338,7 +339,8 @@ function xpack:extension() local extensions = { nsis = ".exe", zip = ".zip", - targz = ".tar.gz" + targz = ".tar.gz", + runself = ".sh" } extension = extensions[self:format()] or "" end |
