diff options
| author | ruki <[email protected]> | 2019-01-29 22:43:59 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-01-29 10:23:56 +0800 |
| commit | 0bfe3e42e041fb23bf15669c4c88931a4bc65c48 (patch) | |
| tree | e827004c80e81fe725d331d79467e71152311d64 /xmake/modules | |
| parent | f0efa9f471824ead88a98ca8cf3387c88606e051 (diff) | |
rename conan functions
Diffstat (limited to 'xmake/modules')
| -rw-r--r-- | xmake/modules/package/manager/conan/find_package.lua | 34 | ||||
| -rw-r--r-- | xmake/modules/package/manager/conan/install_package.lua | 13 |
2 files changed, 38 insertions, 9 deletions
diff --git a/xmake/modules/package/manager/conan/find_package.lua b/xmake/modules/package/manager/conan/find_package.lua index ca39a2f12..8c3541866 100644 --- a/xmake/modules/package/manager/conan/find_package.lua +++ b/xmake/modules/package/manager/conan/find_package.lua @@ -27,10 +27,30 @@ import("core.base.option") import("core.project.config") -- get build info file -function _get_buildinfo_file(name) +function _conan_get_buildinfo_file(name) return path.absolute(path.join(config.buildir() or os.tmpdir(), ".conan", name, "conanbuildinfo.xmake.lua")) end +-- get conan platform +function _conan_get_plat(opt) + local plats = {macosx = "Macos", windows = "Windows", linux = "Linux"} + return plats[opt.plat] +end + +-- get conan architecture +function _conan_get_arch(opt) + if opt.plat == "windows" then + return opt.arch == "x64" and "x86_64" or "x86" + else + return opt.arch == "i386" and "x86" or opt.arch + end +end + +-- get conan mode +function _conan_get_mode(opt) + return opt.mode == "debug" and "Debug" or "Release" +end + -- find package using the conan package manager -- -- @param name the package name @@ -39,7 +59,7 @@ end function main(name, opt) -- get the build info - local buildinfo_file = _get_buildinfo_file(name) + local buildinfo_file = _conan_get_buildinfo_file(name) if not os.isfile(buildinfo_file) then return end @@ -47,10 +67,18 @@ function main(name, opt) -- load build info local buildinfo = io.load(buildinfo_file) + -- get platform, architecture and mode + local plat = _conan_get_plat(opt) + local arch = _conan_get_arch(opt) + local mode = _conan_get_mode(opt) + if not plat and not arch and not mode then + return + end + -- get the package info of the given platform, architecture and mode local found = false local result = {} - for k, v in pairs(buildinfo[opt.plat .. "_" .. opt.arch .. "_" .. opt.mode]) do + for k, v in pairs(buildinfo[plat .. "_" .. arch .. "_" .. mode]) do if #table.wrap(v) > 0 then result[k] = v found = true diff --git a/xmake/modules/package/manager/conan/install_package.lua b/xmake/modules/package/manager/conan/install_package.lua index 3d7af9078..62ab744ef 100644 --- a/xmake/modules/package/manager/conan/install_package.lua +++ b/xmake/modules/package/manager/conan/install_package.lua @@ -28,17 +28,17 @@ import("core.project.config") import("lib.detect.find_tool") -- get build directory -function _get_build_directory(name) +function _conan_get_build_directory(name) return path.absolute(path.join(config.buildir() or os.tmpdir(), ".conan", name)) end -- generate conanfile.txt -function _generate_conanfile(name, opt) +function _conan_generate_conanfile(name, opt) -- trace - dprint("generate %s ..", path.join(_get_build_directory(name), "conanfile.txt")) + dprint("generate %s ..", path.join(_conan_get_build_directory(name), "conanfile.txt")) - -- get conan options and imports + -- get conan options, imports and build_requires local options = table.wrap(opt.options) local imports = table.wrap(opt.imports) local build_requires = table.wrap(opt.build_requires) @@ -74,7 +74,7 @@ function main(name, opt) end -- get build directory - local buildir = _get_build_directory(name) + local buildir = _conan_get_build_directory(name) -- clean the build directory os.tryrm(buildir) @@ -86,8 +86,9 @@ function main(name, opt) local oldir = os.cd(buildir) -- generate conanfile.txt - _generate_conanfile(name, opt) + _conan_generate_conanfile(name, opt) + -- TODO opt.mode, --remote=, --compiler=, .. -- install package local argv = {"install", "."} if opt.build then |
