Repository: conan-io/conan-center-index

Issue:
[question] How to customise icu data?
Hello, 
I'am building icu for **iOS**, arch=**armv8**, data_packaging=**static** and it builds fine but the _libicudata.a_ file is huge.   In the recipe I don't see any support for [ICU_DATA_FILTER_FILE](https://unicode-org.github.io/icu/userguide/icu_data/buildtool.html#icu-data-configuration-file). How can I customise the icu data so I can lower the size of _libicudata.a_ binary?



Discussion:
Hi! Currently the recipes doesn't support anything associated to that, but you can do different things:

 * One option is to populate that environment variable with your desired value and build from sources again
 * Another alternative is to add one option to the recipe (something like `data_filter_file: "ANY"`) and set the value you want for that option.
 
The advantage of the second approach is that the value of the option will also be encoded in the packageID and different paths will result in different packageIDs (and this is good as they are different Conan packages with different content). 

I encourage you to open a PR to improve the recipe in that direction.

Resolving patch:
diff --git a/recipes/icu/all/conanfile.py b/recipes/icu/all/conanfile.py
--- a/recipes/icu/all/conanfile.py
+++ b/recipes/icu/all/conanfile.py
@@ -24,6 +24,8 @@ class ICUBase(ConanFile):
         "with_unit_tests": [True, False],
         "silent": [True, False],
         "with_dyload": [True, False],
+        "dat_package_file": "ANY",
+        "with_icuio": [True, False],
     }
     default_options = {
         "shared": False,
@@ -32,6 +34,8 @@ class ICUBase(ConanFile):
         "with_unit_tests": False,
         "silent": True,
         "with_dyload": True,
+        "dat_package_file": None,
+        "with_icuio": True,
     }
 
     exports_sources = "patches/*.patch"
@@ -96,6 +100,9 @@ def _platform(self):
     def package_id(self):
         del self.info.options.with_unit_tests  # ICU unit testing shouldn't affect the package's ID
         del self.info.options.silent  # Verbosity doesn't affect package's ID
+        if self.info.options.dat_package_file:
+            dat_package_file_sha256 = tools.sha256sum(str(self.info.options.dat_package_file))
+            self.info.options.dat_package_file = dat_package_file_sha256
 
     @property
     def _settings_build(self):
@@ -114,6 +121,12 @@ def source(self):
     def build(self):
         for patch in self.conan_data.get("patches", {}).get(self.version, []):
             tools.patch(**patch)
+        
+        if self.options.dat_package_file:
+            dat_package_file = glob.glob(os.path.join(self.source_folder, self._source_subfolder, "source", "data", "in", "*.dat"))
+            if dat_package_file:
+                shutil.copy(str(self.options.dat_package_file), dat_package_file[0])
+        
         if self._is_msvc:
             run_configure_icu_file = os.path.join(self._source_subfolder, "source", "runConfigureICU")
 
@@ -184,6 +197,9 @@ def _build_config_cmd(self):
 
         if not self._enable_icu_tools:
             args.append("--disable-tools")
+        
+        if not self.options.with_icuio:
+            args.append("--disable-icuio")
 
         env_build = self._configure_autotools()
         if tools.cross_building(self, skip_x64_x86=True):
@@ -329,11 +345,12 @@ def package_info(self):
         self.cpp_info.components["icu-i18n-alias"].requires = ["icu-i18n"]
 
         # icuio
-        self.cpp_info.components["icu-io"].names["cmake_find_package"] = "io"
-        self.cpp_info.components["icu-io"].names["cmake_find_package_multi"] = "io"
-        self.cpp_info.components["icu-io"].names["pkg_config"] = "icu-io"
-        self.cpp_info.components["icu-io"].libs = [self._lib_name("icuio")]
-        self.cpp_info.components["icu-io"].requires = ["icu-i18n", "icu-uc"]
+        if self.options.with_icuio:
+            self.cpp_info.components["icu-io"].names["cmake_find_package"] = "io"
+            self.cpp_info.components["icu-io"].names["cmake_find_package_multi"] = "io"
+            self.cpp_info.components["icu-io"].names["pkg_config"] = "icu-io"
+            self.cpp_info.components["icu-io"].libs = [self._lib_name("icuio")]
+            self.cpp_info.components["icu-io"].requires = ["icu-i18n", "icu-uc"]
 
         if self.settings.os != "Windows" and self.options.data_packaging in ["files", "archive"]:
             data_path = os.path.join(self.package_folder, "res", self._data_filename).replace("\\", "/")


Test patch: