diff options
| author | ruki <[email protected]> | 2020-04-23 22:41:05 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-04-23 10:06:32 +0800 |
| commit | d41e6aeb8aa516742895d64f36025db50e8f857f (patch) | |
| tree | 6e791fa39be295ccfa59503a372a9a7e6f83c5e4 /xmake/rules/xmake_cli/xmake.lua | |
| parent | ceff124c76b8968b0009066c6fcf03a6f31fb180 (diff) | |
improve programdir
Diffstat (limited to 'xmake/rules/xmake_cli/xmake.lua')
| -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) |
