Merge "Avoid particular includes in NDK"
diff --git a/tools/icu4c_srcgen/generate_ndk.py b/tools/icu4c_srcgen/generate_ndk.py
index 6254a2c..82c7023 100755
--- a/tools/icu4c_srcgen/generate_ndk.py
+++ b/tools/icu4c_srcgen/generate_ndk.py
@@ -170,6 +170,8 @@
     with open(urename_path, "w") as out:
         out.write(modified)
 
+IGNORED_INCLUDE_DEPENDENCY = {
+}
 
 def main():
     """Parse the ICU4C headers and generate the shim libicu."""
@@ -179,6 +181,7 @@
     decl_filters = [StableDeclarationFilter()]
     decl_filters.append(AllowlistedDeclarationFilter(allowlisted_apis))
     parser = DeclaredFunctionsParser(decl_filters, [])
+    parser.set_ignored_include_dependency(IGNORED_INCLUDE_DEPENDENCY)
 
     parser.parse()
 
diff --git a/tools/icu4c_srcgen/genutil.py b/tools/icu4c_srcgen/genutil.py
index a459f23..d652ac2 100644
--- a/tools/icu4c_srcgen/genutil.py
+++ b/tools/icu4c_srcgen/genutil.py
@@ -158,6 +158,7 @@
         self.decl_filters = decl_filters
         self.allowlisted_decl_filters = allowlisted_decl_filter
         self.va_functions_mapping = {}
+        self.ignored_include_dependency = {}
 
         # properties to store the parsing result
         self.all_headers = []
@@ -186,6 +187,13 @@
         inserted as the 3rd argument."""
         self.va_functions_mapping = mapping
 
+    def set_ignored_include_dependency(self, mapping):
+        """
+        A sample mapping is { "ulocdata.h" : [ "uloc.h", "ures.h" ] }.
+        The include dependencies will explicitly be ignored when producing header_paths_to_copy.
+        """
+        self.ignored_include_dependency = mapping
+
     @property
     def header_includes(self):
         """Return all headers declaring the functions returned in get_all_declared_functions.
@@ -304,10 +312,16 @@
             self.all_header_paths_to_copy.add(header)
         while file_queue:
             file = file_queue.pop()
+            file_basename = os.path.basename(file)
             if file in file_processed:
                 continue
             file_processed.add(file)
             for header in header_dependencies[file]:
+                header_basename = os.path.basename(header)
+                # Skip this header if this dependency is explicitly ignored
+                if file_basename in self.ignored_include_dependency and \
+                    header_basename in self.ignored_include_dependency[file_basename]:
+                    continue
                 if header in header_dependencies:  # Do not care non-icu4c headers
                     self.all_header_paths_to_copy.add(header)
                     file_queue.appendleft(header)