Merge "meson_to_hermetic: Add build state tracker" into main
diff --git a/meson_to_hermetic/aosp.toml b/meson_to_hermetic/aosp.toml
index 3c7c088..4941de8 100644
--- a/meson_to_hermetic/aosp.toml
+++ b/meson_to_hermetic/aosp.toml
@@ -72,6 +72,7 @@
 gallium-drivers = 'swrast'
 vulkan-drivers = ''
 glx = 'disabled'
+shared-glapi = 'disabled'
 
 [project_config.host_machine]
 cpu_family = 'x86_64'
diff --git a/meson_to_hermetic/meson_build_state.py b/meson_to_hermetic/meson_build_state.py
new file mode 100644
index 0000000..cb6ac06
--- /dev/null
+++ b/meson_to_hermetic/meson_build_state.py
@@ -0,0 +1,51 @@
+"""
+Copyright 2024 Google LLC
+SPDX-License-Identifier: MIT
+"""
+
+class StaticLibrary:
+    """
+    Represents the cc_library_static / cc_library module in build files
+    """
+    def __init__(self):
+        """
+        Attributes here favor a Soong attribute naming scheme
+        """
+        self.name: str = ''
+        self.srcs: list[str] = []
+        # In Bazel, these headers are one merged list.
+        self.generated_headers: list[str] = []
+        self.generated_sources: list[str] = []
+        # In Bazel, these c options are copts
+        self.cstd: str = ''
+        self.cpp_std: str = ''
+        self.conlyflags: list[str] = []
+        self.cppflags: list[str] = []
+
+        self.deps: list[str] = []
+        self.target_compatible_with: list[str] = []
+        self.visibility: list[str] = []
+
+        self.local_include_dirs: list[str] = []
+        self.static_libs: list[str] = []
+        self.whole_static_libs: list[str] = []
+        self.shared_libs: list[str] = []
+        self.header_libs: list[str] = []
+
+class CustomTarget:
+    """
+    Denoted as genrule in both build files
+    """
+    def __init__(self):
+        self.name: str = ''
+        self.srcs: list[str] = []
+        self.out: list[str] = [] # 'outs' in bazel
+        self.tools: list[str] = []
+        self.export_include_dirs: list[str] = []
+        self.cmd: str = ''
+
+class PythonCustomTarget(CustomTarget):
+    def __init__(self):
+        super().__init__()
+        self.imports: list[str] = []
+        self.version = {}
diff --git a/meson_to_hermetic/meson_common.py b/meson_to_hermetic/meson_common.py
index cf64ce5..bac4a3e 100644
--- a/meson_to_hermetic/meson_common.py
+++ b/meson_to_hermetic/meson_common.py
@@ -331,3 +331,7 @@
     sources=[],
 ):
     return
+
+
+def subdir(dir_=''):
+    return
diff --git a/meson_to_hermetic/meson_impl.py b/meson_to_hermetic/meson_impl.py
index 7df48dd..25fa79c 100644
--- a/meson_to_hermetic/meson_impl.py
+++ b/meson_to_hermetic/meson_impl.py
@@ -510,7 +510,17 @@
 
 
 class PkgConfigModule:
-    def generate(self, lib, name='', description='', extra_cflags=None):
+    def generate(
+        self,
+        lib,
+        name='',
+        description='',
+        extra_cflags=None,
+        filebase='',
+        version='',
+        libraries=None,
+        libraries_private=None,
+    ):
         pass
 
 
diff --git a/meson_to_hermetic/meson_to_hermetic.py b/meson_to_hermetic/meson_to_hermetic.py
index 596b788..195f5e0 100644
--- a/meson_to_hermetic/meson_to_hermetic.py
+++ b/meson_to_hermetic/meson_to_hermetic.py
@@ -240,7 +240,17 @@
 
 
 class BazelPkgConfigModule(impl.PkgConfigModule):
-    def generate(self, lib, name='', description='', extra_cflags=None):
+    def generate(
+        self,
+        lib,
+        name='',
+        description='',
+        extra_cflags=None,
+        filebase='',
+        version='',
+        libraries=None,
+        libraries_private=None,
+    ):
         if extra_cflags is None:
             extra_cflags = []
         impl.fprint('# package library')
@@ -274,7 +284,9 @@
         print('CONFIG:', self._config_file)
         self._init_metadata()
         _generator = (
-            SoongGenerator(self.config.cpu_family) if self._build.lower() == 'soong' else BazelGenerator(self.config.cpu_family)
+            SoongGenerator(self.config.cpu_family)
+            if self._build.lower() == 'soong'
+            else BazelGenerator(self.config.cpu_family)
         )
         self._generator: impl.Compiler = _generator
         return self
@@ -351,10 +363,6 @@
     impl.close_output_file()
 
 
-def load_config_file():
-    impl.load_config_file(meson_translator.config_file)
-
-
 def add_subdirs_to_set(dir_, dir_set):
     subdirs = os.listdir(dir_)
     for subdir in subdirs:
@@ -419,7 +427,9 @@
         return impl.PkgConfigModule()
     if name == 'pkgconfig' and meson_translator.host_machine.lower() == 'linux':
         return impl.PkgConfigModule()
-    exit(f'Unhandled module: "{name}" for host machine: "{meson_translator.host_machine}"')
+    exit(
+        f'Unhandled module: "{name}" for host machine: "{meson_translator.host_machine}"'
+    )
 
 
 def load_dependencies():
@@ -997,10 +1007,12 @@
     for command_item in command[1:]:
         if isinstance(command_item, list):
             for item in command_item:
-                assert type(item) is impl.File
-                args.append(
-                    _location_wrapper(item.name) if location_wrap else item.name
-                )
+                if type(item) is impl.File:
+                    args.append(
+                        _location_wrapper(item.name) if location_wrap else item.name
+                    )
+                elif type(item) is str:
+                    args.append(item)
             continue
 
         assert type(command_item) is str