From f55d0e641559051675692bf70831598adf8bd069 Mon Sep 17 00:00:00 2001 From: harry Date: Sun, 1 Jun 2025 22:12:43 +0800 Subject: add [conf] section to conan profile --- xmake/modules/package/manager/conan/configurations.lua | 3 ++- xmake/modules/package/manager/conan/v2/install_package.lua | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/xmake/modules/package/manager/conan/configurations.lua b/xmake/modules/package/manager/conan/configurations.lua index 7b900b983..8742ecb6e 100644 --- a/xmake/modules/package/manager/conan/configurations.lua +++ b/xmake/modules/package/manager/conan/configurations.lua @@ -29,7 +29,8 @@ function main() settings_host = {description = "Set the host settings for conan."}, settings_build = {description = "Set the build settings for conan."}, imports = {description = "Set the imports for conan 1.x, it has been deprecated in conan 2.x."}, - build_requires = {description = "Set the build requires for conan."} + build_requires = {description = "Set the build requires for conan."}, + conf = {description = "Set the conan configuration, e.g. tools.microsoft.bash:subsystem=msys2"} } end diff --git a/xmake/modules/package/manager/conan/v2/install_package.lua b/xmake/modules/package/manager/conan/v2/install_package.lua index d3d109a7e..2d8bcfc86 100644 --- a/xmake/modules/package/manager/conan/v2/install_package.lua +++ b/xmake/modules/package/manager/conan/v2/install_package.lua @@ -248,6 +248,18 @@ function _conan_generate_compiler_profile(profile, configs, opt) end end + if configs.conf then + if not conf then + conf = {} + end + for _, pair in ipairs(configs.conf) do + local key, value = pair:match("([^=]+)=([^=]+)") + if key and value then + conf[key] = value + end + end + end + if conf then profile:print("") profile:print("[conf]") -- cgit v1.3.1 From eb618682cb9c9782285b2b552259473bd472e60a Mon Sep 17 00:00:00 2001 From: harry Date: Mon, 2 Jun 2025 11:35:05 +0800 Subject: pass configuration via command line of conan --- .../package/manager/conan/configurations.lua | 20 ++++++++++-------- .../package/manager/conan/v2/install_package.lua | 24 +++++++++++----------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/xmake/modules/package/manager/conan/configurations.lua b/xmake/modules/package/manager/conan/configurations.lua index 8742ecb6e..fcc9b9c01 100644 --- a/xmake/modules/package/manager/conan/configurations.lua +++ b/xmake/modules/package/manager/conan/configurations.lua @@ -22,15 +22,17 @@ function main() return { - build = {description = "Use it to choose if you want to build from sources.", default = "missing", values = {"all", "never", "missing", "outdated"}}, - remote = {description = "Set the conan remote server."}, - options = {description = "Set the options values, e.g. shared=True"}, - settings = {description = "Set the host settings for conan."}, - settings_host = {description = "Set the host settings for conan."}, - settings_build = {description = "Set the build settings for conan."}, - imports = {description = "Set the imports for conan 1.x, it has been deprecated in conan 2.x."}, - build_requires = {description = "Set the build requires for conan."}, - conf = {description = "Set the conan configuration, e.g. tools.microsoft.bash:subsystem=msys2"} + build = {description = "Use it to choose if you want to build from sources.", default = "missing", values = {"all", "never", "missing", "outdated"}}, + remote = {description = "Set the conan remote server."}, + options = {description = "Set the options values, e.g. shared=True"}, + settings = {description = "Set the host settings for conan."}, + settings_host = {description = "Set the host settings for conan."}, + settings_build = {description = "Set the build settings for conan."}, + imports = {description = "Set the imports for conan 1.x, it has been deprecated in conan 2.x."}, + build_requires = {description = "Set the build requires for conan."}, + configurations = {description = "Set the host configurations for conan, e.g. tools.microsoft.bash:subsystem=msys2"}, + configurations_host = {description = "Set the host configurations for conan, e.g. tools.microsoft.bash:subsystem=msys2"}, + configurations_build = {description = "Set the build configurations for conan, e.g. tools.microsoft.bash:subsystem=msys2"}, } end diff --git a/xmake/modules/package/manager/conan/v2/install_package.lua b/xmake/modules/package/manager/conan/v2/install_package.lua index 2d8bcfc86..b424ee06f 100644 --- a/xmake/modules/package/manager/conan/v2/install_package.lua +++ b/xmake/modules/package/manager/conan/v2/install_package.lua @@ -248,18 +248,6 @@ function _conan_generate_compiler_profile(profile, configs, opt) end end - if configs.conf then - if not conf then - conf = {} - end - for _, pair in ipairs(configs.conf) do - local key, value = pair:match("([^=]+)=([^=]+)") - if key and value then - conf[key] = value - end - end - end - if conf then profile:print("") profile:print("[conf]") @@ -345,6 +333,18 @@ function main(conan, name, opt) table.insert(argv, setting) end + -- set custom host configurations + for _, conf in ipairs(configs.configurations or configs.configurations_host) do + table.insert(argv, "-c") + table.insert(argv, conf) + end + + -- set custom build configurations + for _, conf in ipairs(configs.configurations_build) do + table.insert(argv, "-c:b") + table.insert(argv, conf) + end + -- set remote if configs.remote then table.insert(argv, "-r") -- cgit v1.3.1 From b0abf262b86d9018c954b03dc2970e2191f53b06 Mon Sep 17 00:00:00 2001 From: harry Date: Tue, 3 Jun 2025 10:10:26 +0800 Subject: rename configurations to conf in conan package manager --- .../package/manager/conan/configurations.lua | 22 +++++++++++----------- .../package/manager/conan/v2/install_package.lua | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/xmake/modules/package/manager/conan/configurations.lua b/xmake/modules/package/manager/conan/configurations.lua index fcc9b9c01..01cc8b34c 100644 --- a/xmake/modules/package/manager/conan/configurations.lua +++ b/xmake/modules/package/manager/conan/configurations.lua @@ -22,17 +22,17 @@ function main() return { - build = {description = "Use it to choose if you want to build from sources.", default = "missing", values = {"all", "never", "missing", "outdated"}}, - remote = {description = "Set the conan remote server."}, - options = {description = "Set the options values, e.g. shared=True"}, - settings = {description = "Set the host settings for conan."}, - settings_host = {description = "Set the host settings for conan."}, - settings_build = {description = "Set the build settings for conan."}, - imports = {description = "Set the imports for conan 1.x, it has been deprecated in conan 2.x."}, - build_requires = {description = "Set the build requires for conan."}, - configurations = {description = "Set the host configurations for conan, e.g. tools.microsoft.bash:subsystem=msys2"}, - configurations_host = {description = "Set the host configurations for conan, e.g. tools.microsoft.bash:subsystem=msys2"}, - configurations_build = {description = "Set the build configurations for conan, e.g. tools.microsoft.bash:subsystem=msys2"}, + build = {description = "Use it to choose if you want to build from sources.", default = "missing", values = {"all", "never", "missing", "outdated"}}, + remote = {description = "Set the conan remote server."}, + options = {description = "Set the options values, e.g. shared=True"}, + settings = {description = "Set the host settings for conan."}, + settings_host = {description = "Set the host settings for conan."}, + settings_build = {description = "Set the build settings for conan."}, + imports = {description = "Set the imports for conan 1.x, it has been deprecated in conan 2.x."}, + build_requires = {description = "Set the build requires for conan."}, + conf = {description = "Set the host configurations for conan, e.g. tools.microsoft.bash:subsystem=msys2"}, + conf_host = {description = "Set the host configurations for conan, e.g. tools.microsoft.bash:subsystem=msys2"}, + conf_build = {description = "Set the build configurations for conan, e.g. tools.microsoft.bash:subsystem=msys2"}, } end diff --git a/xmake/modules/package/manager/conan/v2/install_package.lua b/xmake/modules/package/manager/conan/v2/install_package.lua index b424ee06f..f93ebaea7 100644 --- a/xmake/modules/package/manager/conan/v2/install_package.lua +++ b/xmake/modules/package/manager/conan/v2/install_package.lua @@ -334,13 +334,13 @@ function main(conan, name, opt) end -- set custom host configurations - for _, conf in ipairs(configs.configurations or configs.configurations_host) do + for _, conf in ipairs(configs.conf or configs.conf_host) do table.insert(argv, "-c") table.insert(argv, conf) end -- set custom build configurations - for _, conf in ipairs(configs.configurations_build) do + for _, conf in ipairs(configs.conf_build) do table.insert(argv, "-c:b") table.insert(argv, conf) end -- cgit v1.3.1