meson_to_hermetic: Add build state tracker

First part of capturing the transient state of build configs.
Currently adds prototype classes, does not assign any values yet.

Test: Run build-<platform>-turnip.sh
Bug: 357080225
Change-Id: I3a5e04610041f93c1b2b9079296085386a372c19
This commit is contained in:
= 2024-09-16 21:02:11 +00:00
parent 53e17f1524
commit 667533d690
5 changed files with 90 additions and 12 deletions

View file

@ -72,6 +72,7 @@ platforms = 'none'
gallium-drivers = 'swrast'
vulkan-drivers = ''
glx = 'disabled'
shared-glapi = 'disabled'
[project_config.host_machine]
cpu_family = 'x86_64'

View file

@ -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 = {}

View file

@ -331,3 +331,7 @@ def install_data(
sources=[],
):
return
def subdir(dir_=''):
return

View file

@ -510,7 +510,17 @@ class Compiler(ABC):
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

View file

@ -240,7 +240,17 @@ class BazelGenerator(impl.Compiler):
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 @@ class MesonTranslator:
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 @@ def close_output_file():
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 @@ def module_import(name: str):
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 @@ def _get_command_args(
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