Skip to content

Commit

Permalink
Revert PR12972 as a regression.
Browse files Browse the repository at this point in the history
Revert "interpreter: when overriding a dependency make its name match"

This reverts commit b1340e9.

Revert "dependency: define equality and hash operators for Dependency"

This reverts commit 6d713e4.

This caused some projects to fail to build, such as libplacebo and
libepoxy. Taking libplacebo as the example, the produced build.ninja
does not include libvulkan.so as a linker input for
src/libplacebo.so.338.

We are probably getting dependency hashing wrong somewhere. Unsure where
exactly and unsure how to create a test case. We are also deep into rc2.
Revert it for now and try to re-land these changes for 1.6.

Bug: https://bugs.gentoo.org/935443
Fixes: mesonbuild#13352
  • Loading branch information
eli-schwartz committed Jul 5, 2024
1 parent 140c557 commit 0392722
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 41 deletions.
12 changes: 0 additions & 12 deletions mesonbuild/dependencies/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2013-2018 The Meson development team
# Copyright © 2024 Intel Corporation

# This file contains the detection logic for external dependencies.
# Custom logic for several other packages are in separate files.
Expand Down Expand Up @@ -107,9 +106,6 @@ def _process_include_type_kw(cls, kwargs: T.Dict[str, T.Any]) -> str:
return kwargs['include_type']

def __init__(self, type_name: DependencyTypeName, kwargs: T.Dict[str, T.Any]) -> None:
# This allows two Dependencies to be compared even after being copied.
# The purpose is to allow the name to be changed, but still have a proper comparison
self.__id = id(self)
self.name = f'dep{id(self)}'
self.version: T.Optional[str] = None
self.language: T.Optional[str] = None # None means C-like
Expand All @@ -128,14 +124,6 @@ def __init__(self, type_name: DependencyTypeName, kwargs: T.Dict[str, T.Any]) ->
self.featurechecks: T.List['FeatureCheckBase'] = []
self.feature_since: T.Optional[T.Tuple[str, str]] = None

def __eq__(self, other: object) -> bool:
if not isinstance(other, Dependency):
return NotImplemented
return self.__id == other.__id

def __hash__(self) -> int:
return self.__id

def __repr__(self) -> str:
return f'<{self.__class__.__name__} {self.name}: {self.is_found}>'

Expand Down
13 changes: 1 addition & 12 deletions mesonbuild/interpreter/mesonmain.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2012-2021 The Meson development team
# Copyright © 2021-2024 Intel Corporation
# Copyright © 2021 Intel Corporation
from __future__ import annotations

import copy
import os
import typing as T

Expand Down Expand Up @@ -348,16 +347,6 @@ def override_dependency_method(self, args: T.Tuple[str, dependencies.Dependency]
if not name:
raise InterpreterException('First argument must be a string and cannot be empty')

# Make a copy since we're going to mutate.
#
# dep = declare_dependency()
# meson.override_dependency('foo', dep)
# meson.override_dependency('foo-1.0', dep)
# dep = dependency('foo')
# dep.name() # == 'foo-1.0'
dep = copy.copy(dep)
dep.name = name

optkey = OptionKey('default_library', subproject=self.interpreter.subproject)
default_library = self.interpreter.coredata.get_option(optkey)
assert isinstance(default_library, str), 'for mypy'
Expand Down
18 changes: 1 addition & 17 deletions test cases/common/98 subproject subdir/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2016-2023 The Meson Developers
# Copyright © 2024 Intel Corporation

project('proj', 'c')
subproject('sub')
libSub = dependency('sub', fallback: ['sub', 'libSub'])
Expand All @@ -10,19 +6,7 @@ exe = executable('prog', 'prog.c', dependencies: libSub)
test('subproject subdir', exe)

# Verify the subproject has placed dependency override.
d = dependency('sub-1.0')

# verify that the name is the overridden name
assert(d.name() == 'sub-1.0', 'name was not properly set, should have been "sub-1.0", but was @0@'.format(d.name()))

# Verify that when a dependency object is used for two overrides, the correct
# name is used
meson.override_dependency('new-dep', d)
d2 = dependency('new-dep')
assert(d2.name() == 'new-dep', 'name was not properly set, should have been "new-dep", but was @0@'.format(d2.name()))

# And that the old dependency wasn't changed
assert(d.name() == 'sub-1.0', 'original dependency was mutated.')
dependency('sub-1.0')

# Verify we can now take 'sub' dependency without fallback, but only version 1.0.
dependency('sub')
Expand Down

0 comments on commit 0392722

Please sign in to comment.