Repository: conan-io/conan-center-index

Issue:
expat missing option for char_type
<!-- 
  Please don't forget to update the issue title.
  Include all applicable information to help us reproduce your problem.
-->

### Package and Environment Details (include every applicable attribute)
  * Package Name/Version: **expat/2.4.1**
  * Operating System+version: **Linux**
  * Compiler+version: **GCC 8**
  * Conan version: **conan 1.18.0**

### Description
Currently expat recipe accepts the following options
options = {"shared": [True, False], "fPIC": [True, False], "char_type": ["char", "wchar_t"]}

for char_type possible value should be 
"char_type": ["char", "wchar_t", "ushort"]

to be aligned with expat feature:
// Character type to use (char|ushort|wchar_t) [default=char]
EXPAT_CHAR_TYPE:STRING=char






Discussion:

Resolving patch:
diff --git a/recipes/expat/all/conanfile.py b/recipes/expat/all/conanfile.py
--- a/recipes/expat/all/conanfile.py
+++ b/recipes/expat/all/conanfile.py
@@ -3,6 +3,7 @@
 
 required_conan_version = ">=1.33.0"
 
+
 class ExpatConan(ConanFile):
     name = "expat"
     description = "Fast streaming XML parser written in C."
@@ -11,7 +12,11 @@ class ExpatConan(ConanFile):
     homepage = "https://github.com/libexpat/libexpat"
     license = "MIT"
     settings = "os", "compiler", "build_type", "arch"
-    options = {"shared": [True, False], "fPIC": [True, False], "char_type": ["char", "wchar_t"]}
+    options = {
+        "shared": [True, False],
+        "fPIC": [True, False],
+        "char_type": ["char", "wchar_t", "ushort"],
+    }
     default_options = {"shared": False, "fPIC": True, "char_type": "char"}
     generators = "cmake"
     exports_sources = ["CMakeLists.txt", "patches/*"]
@@ -33,8 +38,11 @@ def configure(self):
         del self.settings.compiler.cppstd
 
     def source(self):
-        tools.get(**self.conan_data["sources"][self.version],
-                  destination=self._source_subfolder, strip_root=True)
+        tools.get(
+            **self.conan_data["sources"][self.version],
+            destination=self._source_subfolder,
+            strip_root=True
+        )
 
     def _configure_cmake(self):
         if self._cmake:
@@ -42,14 +50,14 @@ def _configure_cmake(self):
         self._cmake = CMake(self)
         if tools.Version(self.version) < "2.2.8":
             self._cmake.definitions["BUILD_doc"] = "Off"
-            self._cmake.definitions["BUILD_examples"] =  "Off"
+            self._cmake.definitions["BUILD_examples"] = "Off"
             self._cmake.definitions["BUILD_shared"] = self.options.shared
             self._cmake.definitions["BUILD_tests"] = "Off"
             self._cmake.definitions["BUILD_tools"] = "Off"
         else:
             # These options were renamed in 2.2.8 to be more consistent
             self._cmake.definitions["EXPAT_BUILD_DOCS"] = "Off"
-            self._cmake.definitions["EXPAT_BUILD_EXAMPLES"] =  "Off"
+            self._cmake.definitions["EXPAT_BUILD_EXAMPLES"] = "Off"
             self._cmake.definitions["EXPAT_SHARED_LIBS"] = self.options.shared
             self._cmake.definitions["EXPAT_BUILD_TESTS"] = "Off"
             self._cmake.definitions["EXPAT_BUILD_TOOLS"] = "Off"
@@ -79,5 +87,7 @@ def package_info(self):
         self.cpp_info.libs = tools.collect_libs(self)
         if not self.options.shared:
             self.cpp_info.defines = ["XML_STATIC"]
+        if self.options.get_safe("char_type") in ["wchar_t", "ushort"]:
+            self.cpp_info.defines.append("XML_UNICODE")
         if self.options.get_safe("char_type") == "wchar_t":
             self.cpp_info.defines.append("XML_UNICODE_WCHAR_T")


Test patch: