diff options
Diffstat (limited to 'xmake/rules')
| -rw-r--r-- | xmake/rules/xmake_cli/xmake.lua | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/xmake/rules/xmake_cli/xmake.lua b/xmake/rules/xmake_cli/xmake.lua index a8d891ab1..455a67365 100644 --- a/xmake/rules/xmake_cli/xmake.lua +++ b/xmake/rules/xmake_cli/xmake.lua @@ -24,10 +24,48 @@ rule("xmake.cli") target:set("kind", "binary") assert(target:pkg("libxmake"), 'please add_packages("libxmake") to target(%s) first!', target:name()) end) + after_install(function (target) + -- install xmake/cli program + -- + -- - bin + -- - hello + -- - share + -- - hello + -- - lua + -- - main.lua + -- - core + -- - .. + -- + local scriptdir = path.join(target:scriptdir(), "src") + if not os.isfile(path.join(scriptdir, "lua", "main.lua")) then + import("lib.detect.find_path") + scriptdir = assert(find_path("lua/main.lua", path.join(target:scriptdir(), "**")), "lua/main.lua not found!") + end + local installdir = path.join(target:installdir(), "share", target:name()) + if not os.isdir(installdir) then + os.mkdir(installdir) + end + os.vcp(path.join(scriptdir, "lua"), installdir) + + -- install xmake-core lua scripts + local libxmake = target:pkg("libxmake") + local programdir = path.join(path.directory(libxmake:get("linkdirs")), "share", "xmake") + assert(os.isdir(programdir), "%s not found!", programdir) + local coredir = path.join(installdir, "core") + if not os.isdir(coredir) then + os.mkdir(coredir) + end + os.vcp(path.join(programdir, "*"), coredir) + end) before_run(function (target) + local scriptdir = path.join(target:scriptdir(), "src") + if not os.isfile(path.join(scriptdir, "lua", "main.lua")) then + import("lib.detect.find_path") + scriptdir = assert(find_path("lua/main.lua", path.join(target:scriptdir(), "**")), "lua/main.lua not found!") + end local libxmake = target:pkg("libxmake") local programdir = path.join(path.directory(libxmake:get("linkdirs")), "share", "xmake") assert(os.isdir(programdir), "%s not found!", programdir) os.setenv("XMAKE_PROGRAM_DIR", programdir) - os.setenv("XMAKE_MODULES_DIR", path.join(target:scriptdir(), "src")) + os.setenv("XMAKE_MODULES_DIR", scriptdir) end) |
