Skip to content

Commit

Permalink
[WIP] SQUASHME
Browse files Browse the repository at this point in the history
  • Loading branch information
oleavr committed Feb 7, 2024
1 parent 14f4145 commit 287b22c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
15 changes: 15 additions & 0 deletions mesonbuild/coredata.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,10 @@ def copy_to_native(self) -> CoreData:
other.__dict__[k] = v

# TODO: Copy options
print("\nself.options:")
import pprint
pprint.pp(self.options)
print("\n")

other.cross_files = []

Expand Down Expand Up @@ -947,6 +951,11 @@ def copy_build_options_from_regular_ones(self) -> bool:
return dirty

def set_options(self, options: T.Dict[OptionKey, T.Any], subproject: str = '', first_invocation: bool = False) -> bool:
print(f"\n=== set_options() subproject='{subproject}'")
import pprint
pprint.pp(options)
print("===\n")

dirty = False
if not self.is_cross_build():
options = {k: v for k, v in options.items() if k.machine is not MachineChoice.BUILD}
Expand Down Expand Up @@ -985,9 +994,15 @@ def set_default_options(self, default_options: T.MutableMapping[OptionKey, str],
options: T.MutableMapping[OptionKey, T.Any] = OrderedDict()
for k, v in default_options.items():
if not subproject or k.subproject == subproject:
print('keeping:', k)
options[k] = v
else:
print('dropping:', k)
options.update(env.options)
env.options = options
import pprint
pprint.pp(options)
print('^^^\n')

# Create a subset of options, keeping only project and builtin
# options for this subproject.
Expand Down
24 changes: 23 additions & 1 deletion mesonbuild/interpreter/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,10 @@ def do_subproject(self, subp_name: str, kwargs: kwtypes.DoSubproject, force_meth
return self.disabled_subproject(subp_name, subp_id, disabled_feature=feature)

default_options = {k.evolve(subproject=subp_name): v for k, v in kwargs['default_options'].items()}
print('\n\nPOTATO')
import pprint
pprint.pp(default_options)
print('\n\n')

if subp_name == '':
raise InterpreterException('Subproject name must not be empty.')
Expand Down Expand Up @@ -985,6 +989,11 @@ def _do_subproject_meson(self, subp_name: str, subp_id: str, subdir: str,

if native and self.coredata.is_cross_build():
new_build = self.build.copy_to_native()
default_options = {k.as_build(): v for k, v in default_options.items()}
print('\n=== fixed up default_options:')
import pprint
pprint.pp(default_options)
print('\n')
else:
new_build = self.build.copy()
subi = Interpreter(new_build, self.backend, subp_name, subp_id, subdir, self.subproject_dir,
Expand Down Expand Up @@ -1069,6 +1078,9 @@ def _do_subproject_cargo(self, subp_name: str, subp_id: str, subdir: str,
def get_option_internal(self, optname: str) -> coredata.UserOption:
key = OptionKey.from_string(optname).evolve(subproject=self.subproject)

if self.environment.is_native_clone and key.is_project():
key = key.as_build()

if not key.is_project():
for opts in [self.coredata.options, compilers.base_options]:
v = opts.get(key)
Expand Down Expand Up @@ -1214,7 +1226,10 @@ def func_project(self, node: mparser.FunctionNode, args: T.Tuple[str, T.List[str
if os.path.exists(option_file):
oi = optinterpreter.OptionInterpreter(self.subproject)
oi.process(option_file)
self.coredata.update_project_options(oi.options)
opts = oi.options
if self.environment.is_native_clone:
opts = {k.as_build(): v for k, v in opts.items()}
self.coredata.update_project_options(opts)
self.add_build_def_file(option_file)

if self.subproject:
Expand All @@ -1223,6 +1238,10 @@ def func_project(self, node: mparser.FunctionNode, args: T.Tuple[str, T.List[str
else:
self.project_default_options = kwargs['default_options']

print('\n=== func_project:', proj_name)
print("self.project_default_options:", self.project_default_options)
print('===\n')

# Do not set default_options on reconfigure otherwise it would override
# values previously set from command line. That means that changing
# default_options in a project will trigger a reconfigure but won't
Expand Down Expand Up @@ -1801,6 +1820,9 @@ def func_dependency(self, node: mparser.BaseNode, args: T.Tuple[T.List[str]], kw
raise InvalidArguments('"allow_fallback" argument must be boolean')
fallback = kwargs.get('fallback')
default_options = kwargs.get('default_options')
print('\n*** dependency()', names)
print('default_options:', default_options)
print('\n')
df = DependencyFallbacksHolder(self, names, allow_fallback, default_options)
df.set_fallback(fallback)
not_found_message = kwargs.get('not_found_message', '')
Expand Down
1 change: 1 addition & 0 deletions mesonbuild/interpreter/type_checking.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ def _override_options_convertor(raw: T.Union[str, T.List[str], T.Dict[str, T.Uni
for each in raw:
k, v = split_equal_string(each)
output[OptionKey.from_string(k)] = v
print('result:', output)
return output
return {OptionKey.from_string(k): v for k, v in raw.items()}

Expand Down
2 changes: 1 addition & 1 deletion mesonbuild/utils/universal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2191,7 +2191,7 @@ def _classify_argument(key: 'OptionKey') -> OptionType:
assert key.machine is MachineChoice.HOST, str(key)
return OptionType.BACKEND
else:
assert key.machine is MachineChoice.HOST, str(key)
assert key.subproject or key.machine is MachineChoice.HOST, str(key)
return OptionType.PROJECT


Expand Down

0 comments on commit 287b22c

Please sign in to comment.