Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boost: Improve option for i18n backend #5553

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions recipes/boost/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ patches:
base_path: "source_subfolder"
- patch_file: "patches/support_msvc_2019.patch"
base_path: "source_subfolder"
- patch_file: "patches/boost_locale_fail_on_missing_backend.patch"
base_path: "source_subfolder"
1.70.0:
- patch_file: "patches/0001-beast-fix-moved-from-executor.patch"
base_path: "source_subfolder"
Expand All @@ -69,6 +71,8 @@ patches:
base_path: "source_subfolder"
- patch_file: "patches/solaris_pthread_data.patch"
base_path: "source_subfolder"
- patch_file: "patches/boost_locale_fail_on_missing_backend.patch"
base_path: "source_subfolder"
1.71.0:
- patch_file: "patches/bcp_namespace_issues_1_71.patch"
base_path: "source_subfolder"
Expand All @@ -80,6 +84,8 @@ patches:
base_path: "source_subfolder"
- patch_file: "patches/solaris_pthread_data.patch"
base_path: "source_subfolder"
- patch_file: "patches/boost_locale_fail_on_missing_backend.patch"
base_path: "source_subfolder"
1.72.0:
- patch_file: "patches/bcp_namespace_issues_1_72.patch"
base_path: "source_subfolder"
Expand All @@ -95,18 +101,29 @@ patches:
base_path: "source_subfolder"
- patch_file: "patches/boost_log_filesystem_no_deprecated_1_72.patch"
base_path: "source_subfolder"
- patch_file: "patches/boost_locale_fail_on_missing_backend.patch"
base_path: "source_subfolder"
1.73.0:
- patch_file: "patches/boost_build_qcc_fix_debug_build_parameter.patch"
base_path: "source_subfolder"
- patch_file: "patches/python_base_prefix.patch"
base_path: "source_subfolder"
- patch_file: "patches/boost_locale_fail_on_missing_backend.patch"
base_path: "source_subfolder"
1.74.0:
- patch_file: "patches/boost_build_qcc_fix_debug_build_parameter_since_1_74.patch"
base_path: "source_subfolder"
- patch_file: "patches/python_base_prefix_since_1_74.patch"
base_path: "source_subfolder"
- patch_file: "patches/boost_locale_fail_on_missing_backend.patch"
base_path: "source_subfolder"
1.75.0:
- patch_file: "patches/boost_build_qcc_fix_debug_build_parameter_since_1_74.patch"
base_path: "source_subfolder"
- patch_file: "patches/python_base_prefix_since_1_74.patch"
base_path: "source_subfolder"
- patch_file: "patches/boost_locale_fail_on_missing_backend.patch"
base_path: "source_subfolder"
1.76.0:
- patch_file: "patches/boost_locale_fail_on_missing_backend.patch"
base_path: "source_subfolder"
66 changes: 50 additions & 16 deletions recipes/boost/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ class BoostConan(ConanFile):
"debug_level": [i for i in range(0, 14)],
"pch": [True, False],
"extra_b2_flags": "ANY", # custom b2 flags
"i18n_backend": ["iconv", "icu", None],
"i18n_backend": ["iconv", "icu", None, "deprecated"],
"i18n_backend_iconv": ["libc", "libiconv", "off"],
"i18n_backend_icu": [True, False],
"visibility": ["global", "protected", "hidden"],
}
options.update({"without_{}".format(_name): [True, False] for _name in CONFIGURE_OPTIONS})
Expand Down Expand Up @@ -122,7 +124,9 @@ class BoostConan(ConanFile):
"debug_level": 0,
"pch": True,
"extra_b2_flags": "None",
"i18n_backend": "iconv",
"i18n_backend": "deprecated",
"i18n_backend_iconv": "libc",
"i18n_backend_icu": False,
"visibility": "hidden",
}
default_options.update({"without_{}".format(_name): False for _name in CONFIGURE_OPTIONS})
Expand Down Expand Up @@ -225,6 +229,10 @@ def _python_executable(self):
exe = self.options.python_executable if self.options.python_executable else sys.executable
return str(exe).replace('\\', '/')

@property
def _is_windows_platform(self):
return self.settings.os in ["Windows", "WindowsStore", "WindowsCE"]

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
Expand Down Expand Up @@ -253,6 +261,11 @@ def config_options(self):
self.options.without_json = True
self.options.without_nowide = True

# iconv is off by default on Windows and Solaris
if self._is_windows_platform or self.settings.os == "SunOS":
self.options.i18n_backend_iconv = "off"
elif self.settings.os == "Macos":
self.options.i18n_backend_iconv = "libiconv"

# Remove options not supported by this version of boost
for dep_name in CONFIGURE_OPTIONS:
Expand Down Expand Up @@ -304,11 +317,23 @@ def configure(self):
elif self.options.shared:
del self.options.fPIC

if self.options.i18n_backend != "deprecated":
self.output.warn("i18n_backend option is deprecated, do not use anymore.")
if self.options.i18n_backend == "iconv":
self.options.i18n_backend_iconv = "libiconv"
self.options.i18n_backend_icu = False
if self.options.i18n_backend == "icu":
self.options.i18n_backend_iconv = "off"
self.options.i18n_backend_icu = True
if self.options.i18n_backend == "None":
self.options.i18n_backend_iconv = "off"
self.options.i18n_backend_icu = False
if self.options.without_locale:
self.options.i18n_backend = None
del self.options.i18n_backend_iconv
del self.options.i18n_backend_icu
else:
if not self.options.i18n_backend:
raise ConanInvalidConfiguration("Boost.locale library requires a i18n_backend (either 'icu' or 'iconv')")
if self.options.i18n_backend_iconv == "off" and not self.options.i18n_backend_icu and not self._is_windows_platform:
raise ConanInvalidConfiguration("Boost.Locale library needs either iconv or ICU library to be built on non windows platforms")

if not self.options.without_python:
if not self.options.python_version:
Expand Down Expand Up @@ -418,11 +443,11 @@ def _with_zstd(self):

@property
def _with_icu(self):
return not self.options.header_only and self._with_dependency("icu") and self.options.i18n_backend == "icu"
return not self.options.header_only and self._with_dependency("icu") and self.options.get_safe("i18n_backend_icu")

@property
def _with_iconv(self):
return not self.options.header_only and self._with_dependency("iconv") and self.options.i18n_backend == "iconv"
return not self.options.header_only and self._with_dependency("iconv") and self.options.get_safe("i18n_backend_iconv") == "libiconv"

def requirements(self):
if self._with_zlib:
Expand All @@ -436,10 +461,12 @@ def requirements(self):

if self._with_icu:
self.requires("icu/68.2")
elif self._with_iconv:
if self._with_iconv:
self.requires("libiconv/1.16")

def package_id(self):
del self.info.options.i18n_backend

if self.options.header_only:
self.info.header_only()
self.info.options.header_only = True
Expand Down Expand Up @@ -837,15 +864,20 @@ def _build_flags(self):
flags.append("-sNO_LZMA=%s" % ("0" if self._with_lzma else "1"))
flags.append("-sNO_ZSTD=%s" % ("0" if self._with_zstd else "1"))

if self.options.i18n_backend == 'icu':
flags.append("-sICU_PATH={}".format(self.deps_cpp_info["icu"].rootpath))
flags.append("boost.locale.iconv=off boost.locale.icu=on")
elif self.options.i18n_backend == 'iconv':
flags.append("boost.locale.iconv=on boost.locale.icu=off")
if self.options.get_safe("i18n_backend_icu"):
flags.append("boost.locale.icu=on")
else:
flags.append("boost.locale.icu=off")
flags.append("--disable-icu")
if self.options.get_safe("i18n_backend_iconv") in ["libc", "libiconv"]:
flags.append("boost.locale.iconv=on")
if self.options.get_safe("i18n_backend_iconv") == "libc":
flags.append("boost.locale.iconv.lib=libc")
else:
flags.append("boost.locale.iconv.lib=libiconv")
else:
flags.append("boost.locale.iconv=off boost.locale.icu=off")
flags.append("--disable-icu --disable-iconv")
flags.append("boost.locale.iconv=off")
flags.append("--disable-iconv")

def add_defines(library):
for define in self.deps_cpp_info[library].defines:
Expand Down Expand Up @@ -1389,7 +1421,9 @@ def filter_transform_module_libraries(names):
if conan_requirement not in self.requires:
continue
if module == "locale" and requirement in ("icu", "iconv"):
if requirement != self.options.i18n_backend:
if requirement == "icu" and not self._with_icu:
continue
if requirement == "iconv" and not self._with_iconv:
continue
self.cpp_info.components[module].requires.append("{0}::{0}".format(conan_requirement))
for incomplete_component in incomplete_components:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
diff --git a/libs/locale/build/Jamfile.v2 b/libs/locale/build/Jamfile.v2
index 578e722..b715f59 100644
--- a/libs/locale/build/Jamfile.v2
+++ b/libs/locale/build/Jamfile.v2
@@ -17,6 +17,7 @@ import feature ;
# Features

feature.feature boost.locale.iconv : on off : optional propagated ;
+feature.feature boost.locale.iconv.lib : libc libiconv : optional propagated ;
feature.feature boost.locale.icu : on off : optional propagated ;
feature.feature boost.locale.posix : on off : optional propagated ;
feature.feature boost.locale.std : on off : optional propagated ;
@@ -217,6 +218,14 @@ rule configure-full ( properties * : flags-only )
if [ configure.builds has_iconv : $(properties) : "iconv (libc)" ]
{
found-iconv = true ;
+ if <boost.locale.iconv.lib>libiconv in $(properties)
+ {
+ EXIT "- Boost.Locale found iconv (libc) instead of iconv (separate) library to be built." ;
+ }
+ }
+ else if <boost.locale.iconv.lib>libc in $(properties)
+ {
+ EXIT "- Boost.Locale failed to find iconv (libc) library to be built." ;
}
else
{
@@ -225,6 +234,14 @@ rule configure-full ( properties * : flags-only )
found-iconv = true ;
result += <library>iconv ;
}
+ else if <boost.locale.iconv.lib>libiconv in $(properties)
+ {
+ EXIT "- Boost.Locale failed to find iconv (separate) library to be built." ;
+ }
+ }
+ if ! $(found-iconv)
+ {
+ EXIT "- Boost.Locale failed to find iconv library to be built." ;
}
}
if $(found-iconv)
@@ -265,6 +282,10 @@ rule configure-full ( properties * : flags-only )
<library>../../thread/build//boost_thread
;
}
+ else
+ {
+ EXIT "- Boost.Locale failed to find ICU library to be built." ;
+ }

}