diff options
| author | ruki <[email protected]> | 2018-09-14 00:41:45 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-09-13 22:10:31 +0800 |
| commit | d07c0752aea017f1d0f26b1c95d4e4971dfce486 (patch) | |
| tree | 1ddb957da400f4af7eaff6d9a5587176a94aa52c | |
| parent | 9b9f4ca9fe943bbc9e32aa5d6eb1ffb5f87841df (diff) | |
improve the package install directory
| -rw-r--r-- | xmake/actions/require/action/install.lua | 31 | ||||
| -rw-r--r-- | xmake/core/package/package.lua | 12 |
2 files changed, 18 insertions, 25 deletions
diff --git a/xmake/actions/require/action/install.lua b/xmake/actions/require/action/install.lua index 278e7c0b4..9d6386a15 100644 --- a/xmake/actions/require/action/install.lua +++ b/xmake/actions/require/action/install.lua @@ -42,16 +42,14 @@ function _make_package(package) local linkdir = path.join(packagedir, "lib/$(mode)/$(plat)/$(arch)") -- the includedir - local includedir = path.join(packagedir, "inc") - - -- the installdir - local installdir = package:installdir() + local includedir = path.join(packagedir, "include/$(mode)/$(plat)/$(arch)") -- install the library files and ignore hidden files (.xxx) - os.cp(path.join(installdir, "lib"), linkdir) + os.tryrm(linkdir) + os.cp(package:installdir("lib"), linkdir) -- install the header files - os.cp(path.join(installdir, "include"), includedir) + os.cp(package:installdir("include"), includedir) -- get links local links = {} @@ -99,7 +97,7 @@ option("%s") add_linkdirs("lib/$(mode)/$(plat)/$(arch)") -- add include directories - add_includedirs("inc") + add_includedirs("include/$(mode)/$(plat)/$(arch)") ]] -- save file @@ -110,16 +108,6 @@ option("%s") end end --- prepare directories -function _prepare_directories(...) - for _, dir in ipairs({...}) do - os.tryrm(dir) - if not os.isdir(dir) then - os.mkdir(dir) - end - end -end - -- install the given package function main(package) @@ -167,8 +155,8 @@ function main(package) -- create the install task local installtask = function () - -- prepare the install and package directories - _prepare_directories(package:directory(), package:installdir()) + -- clean the install directory first + os.tryrm(package:installdir()) -- build it build(package) @@ -183,10 +171,7 @@ function main(package) -- add search path for program if package:kind() == "binary" then - local bindir = path.join(package:installdir(), "bin") - if os.isdir(bindir) then - os.addenv("PATH", bindir) - end + os.addenv("PATH", package:installdir("bin")) else -- make package from the install directory _make_package(package) diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index 8a286b2cc..cdd853257 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -168,8 +168,16 @@ function _instance:cachedir() end -- get the installed directory of this package -function _instance:installdir() - return path.join(self:directory(), "install") +function _instance:installdir(...) + + -- make the given install directory + local dir = path.join(self:directory(), "install", ...) + + -- ensure the install directory + if not os.isdir(dir) then + os.mkdir(dir) + end + return dir end -- get the downloaded original file |
