meson_to_hermetic: Fix cpu/cpu family not syncing on project configs
Also handles some new configs that are needed for lavapipe Test: Run build-<platform>-turnip.sh Bug: 357080225 Change-Id: I6270cabbc3916b3bb3d2167957ae561a4893e514
This commit is contained in:
parent
ac809dc919
commit
04614c57c9
5 changed files with 21 additions and 75 deletions
|
|
@ -69,8 +69,9 @@ name = 'glibc_x86_64_build'
|
||||||
|
|
||||||
[project_config.meson_options]
|
[project_config.meson_options]
|
||||||
platforms = 'none'
|
platforms = 'none'
|
||||||
gallium-drivers = ''
|
gallium-drivers = 'swrast'
|
||||||
vulkan-drivers = 'swrast'
|
vulkan-drivers = ''
|
||||||
|
glx = 'disabled'
|
||||||
|
|
||||||
[project_config.host_machine]
|
[project_config.host_machine]
|
||||||
cpu_family = 'x86_64'
|
cpu_family = 'x86_64'
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,6 @@ _gRelativeDir = ''
|
||||||
_gProjectCflags = []
|
_gProjectCflags = []
|
||||||
_gProjectCppflags = []
|
_gProjectCppflags = []
|
||||||
|
|
||||||
# Parameters set by config file
|
|
||||||
_gCpuFamily = 'unknown'
|
|
||||||
_gCpu = _gCpuFamily
|
|
||||||
|
|
||||||
_gProjectVersion = 'unknown'
|
_gProjectVersion = 'unknown'
|
||||||
_gProjectOptions = []
|
_gProjectOptions = []
|
||||||
|
|
||||||
|
|
@ -54,8 +50,10 @@ class File:
|
||||||
|
|
||||||
|
|
||||||
class Machine:
|
class Machine:
|
||||||
def __init__(self, system):
|
def __init__(self, system, cpu, cpu_family):
|
||||||
self._system = system
|
self._system = system
|
||||||
|
self._cpu = cpu
|
||||||
|
self._cpu_family = cpu_family
|
||||||
|
|
||||||
def system(self):
|
def system(self):
|
||||||
return self._system
|
return self._system
|
||||||
|
|
@ -64,10 +62,10 @@ class Machine:
|
||||||
self._system = system
|
self._system = system
|
||||||
|
|
||||||
def cpu_family(self):
|
def cpu_family(self):
|
||||||
return _gCpuFamily
|
return self._cpu_family
|
||||||
|
|
||||||
def cpu(self):
|
def cpu(self):
|
||||||
return _gCpuFamily
|
return self._cpu
|
||||||
|
|
||||||
|
|
||||||
class DependencyTargetType(Enum):
|
class DependencyTargetType(Enum):
|
||||||
|
|
@ -383,8 +381,9 @@ class Meson:
|
||||||
|
|
||||||
|
|
||||||
class Compiler(ABC):
|
class Compiler(ABC):
|
||||||
def __init__(self):
|
def __init__(self, cpu_family):
|
||||||
self._id = 'clang'
|
self._id = 'clang'
|
||||||
|
self._cpu_family = cpu_family
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def has_header_symbol(
|
def has_header_symbol(
|
||||||
|
|
@ -503,7 +502,7 @@ class Compiler(ABC):
|
||||||
exit('Unhandled library: ' + name)
|
exit('Unhandled library: ' + name)
|
||||||
|
|
||||||
def sizeof(self, string):
|
def sizeof(self, string):
|
||||||
table = _get_sizeof_table()
|
table = _get_sizeof_table(self._cpu_family)
|
||||||
|
|
||||||
if string not in table:
|
if string not in table:
|
||||||
exit('Unhandled compiler sizeof: ' + string)
|
exit('Unhandled compiler sizeof: ' + string)
|
||||||
|
|
@ -572,36 +571,6 @@ def get_project_options():
|
||||||
return _gProjectOptions
|
return _gProjectOptions
|
||||||
|
|
||||||
|
|
||||||
def load_config_file(filename):
|
|
||||||
if not filename.endswith('.toml'):
|
|
||||||
exit('Config file that is not .toml is not supported.')
|
|
||||||
|
|
||||||
with open(filename, 'rb') as f:
|
|
||||||
data = tomllib.load(f)
|
|
||||||
project_configs = data.get('project_config')
|
|
||||||
if project_configs is None:
|
|
||||||
exit(f'meson_options not defined in {filename}.')
|
|
||||||
project_config = project_configs[0]
|
|
||||||
# TODO(bpnguyen): Make so project config isn't hardcoded to pick the first set of configs
|
|
||||||
host_machine_settings = project_config.get('host_machine')
|
|
||||||
for key in host_machine_settings:
|
|
||||||
match key:
|
|
||||||
case 'cpu_family':
|
|
||||||
cpu_fam = host_machine_settings.get(key)
|
|
||||||
global _gCpuFamily
|
|
||||||
_gCpuFamily = cpu_fam
|
|
||||||
print(f'Config: cpu_family={_gCpuFamily}')
|
|
||||||
case 'cpu':
|
|
||||||
cpu = host_machine_settings.get(key)
|
|
||||||
global _gCpu
|
|
||||||
_gCpu = cpu
|
|
||||||
print(f'Config: cpu={_gCpu}')
|
|
||||||
case 'host_machine' | 'build_machine':
|
|
||||||
continue
|
|
||||||
case _: # Default case
|
|
||||||
exit(f'Unhandled config key: {key}')
|
|
||||||
|
|
||||||
|
|
||||||
def add_project_arguments(args, language=[], native=False):
|
def add_project_arguments(args, language=[], native=False):
|
||||||
global _gProjectCflags, _gProjectCppflags
|
global _gProjectCflags, _gProjectCppflags
|
||||||
if type(args) is not list:
|
if type(args) is not list:
|
||||||
|
|
@ -630,15 +599,15 @@ def get_project_cppflags():
|
||||||
return _gProjectCppflags
|
return _gProjectCppflags
|
||||||
|
|
||||||
|
|
||||||
def _get_sizeof_table():
|
def _get_sizeof_table(cpu_family):
|
||||||
table_32 = {'void*': 4}
|
table_32 = {'void*': 4}
|
||||||
table_64 = {'void*': 8}
|
table_64 = {'void*': 8}
|
||||||
if _gCpuFamily == 'arm':
|
if cpu_family == 'arm' or cpu_family == 'x86_64':
|
||||||
table = table_32
|
table = table_32
|
||||||
elif _gCpuFamily == 'aarch64':
|
elif cpu_family == 'aarch64':
|
||||||
table = table_64
|
table = table_64
|
||||||
else:
|
else:
|
||||||
exit('sizeof unhandled cpu family: %s' % _gCpuFamily)
|
exit('sizeof unhandled cpu family: %s' % cpu_family)
|
||||||
return table
|
return table
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -274,7 +274,7 @@ class MesonTranslator:
|
||||||
print('CONFIG:', self._config_file)
|
print('CONFIG:', self._config_file)
|
||||||
self._init_metadata()
|
self._init_metadata()
|
||||||
_generator = (
|
_generator = (
|
||||||
SoongGenerator() if self._build.lower() == 'soong' else BazelGenerator()
|
SoongGenerator(self.config.cpu_family) if self._build.lower() == 'soong' else BazelGenerator(self.config.cpu_family)
|
||||||
)
|
)
|
||||||
self._generator: impl.Compiler = _generator
|
self._generator: impl.Compiler = _generator
|
||||||
return self
|
return self
|
||||||
|
|
@ -417,7 +417,9 @@ def module_import(name: str):
|
||||||
return BazelPkgConfigModule()
|
return BazelPkgConfigModule()
|
||||||
if name == 'pkgconfig' and meson_translator.host_machine.lower() == 'android':
|
if name == 'pkgconfig' and meson_translator.host_machine.lower() == 'android':
|
||||||
return impl.PkgConfigModule()
|
return impl.PkgConfigModule()
|
||||||
exit(f'Unhandled module: {name}')
|
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}"')
|
||||||
|
|
||||||
|
|
||||||
def load_dependencies():
|
def load_dependencies():
|
||||||
|
|
|
||||||
|
|
@ -39,17 +39,13 @@ def get_variable(name: str):
|
||||||
|
|
||||||
|
|
||||||
meson = impl.Meson(meson_translator.generator)
|
meson = impl.Meson(meson_translator.generator)
|
||||||
host_machine = impl.Machine(meson_translator.host_machine)
|
host_machine = impl.Machine(meson_translator.host_machine, meson_translator.config.cpu, meson_translator.config.cpu_family)
|
||||||
build_machine = impl.Machine(meson_translator.build_machine)
|
build_machine = impl.Machine(meson_translator.build_machine, meson_translator.config.cpu, meson_translator.config.cpu_family)
|
||||||
|
|
||||||
### Open the build definition file
|
### Open the build definition file
|
||||||
open_output_file()
|
open_output_file()
|
||||||
|
|
||||||
|
|
||||||
### Load config
|
|
||||||
load_config_file()
|
|
||||||
|
|
||||||
|
|
||||||
### Load dependencies
|
### Load dependencies
|
||||||
load_dependencies()
|
load_dependencies()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,28 +35,6 @@ class TestConfigParsing(unittest.TestCase):
|
||||||
I.E. *.toml files
|
I.E. *.toml files
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def test_load_config_file(self):
|
|
||||||
path = abs_toml_path / 'test.toml'
|
|
||||||
impl.load_config_file(str(path))
|
|
||||||
|
|
||||||
self.assertEqual(impl._gCpuFamily, 'cpu_family_test', 'gCpuFamily was not assigned '
|
|
||||||
'correctly after parsing')
|
|
||||||
self.assertEqual(impl._gCpu, 'cpu_test', 'gCpu was not assigned correctly after parsing')
|
|
||||||
|
|
||||||
def test_load_config_file_fails_non_toml(self):
|
|
||||||
with self.assertRaises(SystemExit):
|
|
||||||
impl.load_config_file('non_toml.txt')
|
|
||||||
|
|
||||||
def test_no_project_config_defined(self):
|
|
||||||
with self.assertRaises(SystemExit):
|
|
||||||
path = abs_toml_path / 'empty.toml'
|
|
||||||
impl.load_config_file(str(path))
|
|
||||||
|
|
||||||
def test_invalid_host_setting(self):
|
|
||||||
with self.assertRaises(SystemExit):
|
|
||||||
path = str(abs_toml_path / 'unhandled_host_settings.toml')
|
|
||||||
impl.load_config_file(path)
|
|
||||||
|
|
||||||
def test_load_dependencies(self):
|
def test_load_dependencies(self):
|
||||||
expected = {
|
expected = {
|
||||||
'test_dep': {
|
'test_dep': {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue