diff options
| author | ruki <[email protected]> | 2018-10-04 00:37:36 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-10-03 21:45:37 +0800 |
| commit | 9b4d2611b05065bfc0c9ac8a7b3c1e80cedb7e82 (patch) | |
| tree | bcd2ae00dc772589cd5ee852f761796dd0ad1efc | |
| parent | 7ab9409d3cedff94974cfa65fc9be31e54733062 (diff) | |
improve to link and find_package
| -rw-r--r-- | xmake/actions/require/impl/action/prefix/install.lua | 69 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/lib/detect/find_package.lua | 4 |
2 files changed, 56 insertions, 17 deletions
diff --git a/xmake/actions/require/impl/action/prefix/install.lua b/xmake/actions/require/impl/action/prefix/install.lua index d1464b0e5..e6487c14a 100644 --- a/xmake/actions/require/impl/action/prefix/install.lua +++ b/xmake/actions/require/impl/action/prefix/install.lua @@ -63,6 +63,56 @@ function _copy_filedirs(pattern) _copy('a', pattern) end +-- do link +function _do_link(sourcepath, destpath) + + -- link conflicts? + if os.islink(destpath) then + + -- get the original path of destpath + local originpath = os.readlink(destpath) + if os.isdir(sourcepath) and os.isdir(originpath) then + + -- trace + vprint("unlinking %s ..", destpath) + + -- remove the previous link + os.rm(destpath) + + -- expand and relink the previous directories + for _, filedir in ipairs(os.filedirs(path.join(originpath, "*"))) do + + -- trace + vprint("relinking %s ..", path.join(destpath, path.filename(filedir))) + + -- do link + os.ln(filedir, path.join(destpath, path.filename(filedir))) + end + + -- link the child pathes + for _, filedir in ipairs(os.filedirs(path.join(sourcepath, "*"))) do + _do_link(filedir, path.join(destpath, path.filename(filedir))) + end + else + -- link conflicts + os.raise("cannot link %s => %s", sourcepath, destpath) + end + elseif os.isdir(destpath) then + + -- link the child pathes + for _, filedir in ipairs(os.filedirs(path.join(sourcepath, "*"))) do + _do_link(filedir, path.join(destpath, path.filename(filedir))) + end + else + + -- trace + vprint("linking %s ..", destpath) + + -- do link + os.ln(sourcepath, destpath) + end +end + -- link files to the prefix directory function _link(mode, pattern) @@ -75,11 +125,8 @@ function _link(mode, pattern) -- get relative path local relative_path = path.relative(sourcepath, installdir) - -- trace - vprint("linking %s ..", relative_path) - -- link file to the prefix directory - os.ln(sourcepath, path.absolute(relative_path, prefixdir)) + _do_link(sourcepath, path.absolute(relative_path, prefixdir)) -- save this relative path table.insert(relative_pathes, relative_path) @@ -106,17 +153,9 @@ function _install_with_link(package) _link_files("bin/*") _link_files("sbin/*") _link_filedirs("include/*") - _link_filedirs("lib/*|pkgconfig|cmake|lua") - _link_filedirs("lib/pkgconfig/*") - _link_filedirs("lib/cmake/*") - _link_filedirs("lib/lua/*") - _link_filedirs("share/*|aclocal|doc|info|man|icons|locale") - _link_filedirs("share/aclocal/*") - _link_filedirs("share/doc/*") - _link_filedirs("share/info/*") - _link_filedirs("share/man/*") - _link_filedirs("share/icons/*") - _link_filedirs("share/locale/*") + _link_filedirs("lib/*") + _link_filedirs("share/*|info") + _link_filedirs("share/info/*|dir") end -- install package without link (windows) diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_package.lua b/xmake/core/sandbox/modules/import/lib/detect/find_package.lua index 81f608885..9f458a808 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_package.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_package.lua @@ -139,8 +139,8 @@ function sandbox_lib_detect_find_package._find_from_prefixdirs(name, opt) -- get prefix directories local prefixdirs = table.wrap(opt.prefixdirs) if #prefixdirs == 0 then - table.insert(prefixdirs, path.join(config.directory(), "prefix", "release", config.get("plat") or os.host(), config.get("arch") or os.arch())) - table.insert(prefixdirs, path.join(global.directory(), "prefix", "release", config.get("plat") or os.host(), config.get("arch") or os.arch())) + table.insert(prefixdirs, path.join(config.directory(), "prefix", config.get("plat") or os.host(), config.get("arch") or os.arch(), "release")) + table.insert(prefixdirs, path.join(global.directory(), "prefix", config.get("plat") or os.host(), config.get("arch") or os.arch(), "release")) end -- find the package list file, .e.g zlib-1.2.11.txt |
