aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/markdown/Reference-manual.md11
-rw-r--r--docs/markdown/snippets/build-target-found.md16
-rw-r--r--mesonbuild/cmake/interpreter.py4
-rw-r--r--mesonbuild/compilers/compilers.py2
-rw-r--r--mesonbuild/interpreter/interpreterobjects.py25
-rw-r--r--mesonbuild/interpreterbase/baseobjects.py2
-rwxr-xr-xrun_project_tests.py7
-rw-r--r--test cases/cmake/25 assembler/main.c18
-rw-r--r--test cases/cmake/25 assembler/meson.build9
-rw-r--r--test cases/cmake/25 assembler/subprojects/cmTest/CMakeLists.txt45
-rw-r--r--test cases/cmake/25 assembler/subprojects/cmTest/cmTest.c8
-rw-r--r--test cases/cmake/25 assembler/subprojects/cmTest/cmTestAsm.s4
-rw-r--r--test cases/common/182 find override/meson.build10
-rw-r--r--test cases/common/182 find override/otherdir/meson.build4
14 files changed, 151 insertions, 14 deletions
diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md
index fec4e74..aedfda1 100644
--- a/docs/markdown/Reference-manual.md
+++ b/docs/markdown/Reference-manual.md
@@ -2561,6 +2561,12 @@ module](#shared_module).
this and will also allow Meson to setup inter-target dependencies
correctly. Please file a bug if that doesn't work for you.
+- `path()` *(since 0.59.0)* **(deprecated)**: does the exact same
+ as `full_path()`. **NOTE:** This function is solely kept for compatebility
+ with [`external program`](#external-program-object) objects. It will be
+ removed once the, also deprecated, corresponding `path()` function in the
+ `external program` object is removed.
+
- `private_dir_include()`: returns a opaque value that works like
`include_directories` but points to the private directory of this
target, usually only needed if an another target needs to access
@@ -2568,6 +2574,11 @@ module](#shared_module).
- `name()` *(since 0.54.0)*: returns the target name.
+- `found()` *(since 0.59.0)*: Always returns `true`. This function is meant
+ to make executables objects feature compatible with
+ [`external program`](#external-program-object) objects. This simplifies
+ use-cases where an executable is used instead of an external program.
+
### `configuration` data object
diff --git a/docs/markdown/snippets/build-target-found.md b/docs/markdown/snippets/build-target-found.md
new file mode 100644
index 0000000..60c5083
--- /dev/null
+++ b/docs/markdown/snippets/build-target-found.md
@@ -0,0 +1,16 @@
+## New `build target` methods
+
+The [`build target` object](Reference-manual.md#build-target-object) now supports
+the following two functions, to ensure feature compatebility with
+[`external program` objects](Reference-manual.html#external-program-object):
+
+- `found()`: Always returns `true`. This function is meant
+ to make executables objects feature compatible with
+ `external program` objects. This simplifies
+ use-cases where an executable is used instead of an external program.
+
+- `path()`: **(deprecated)** does the exact same as `full_path()`.
+ **NOTE:** This function is solely kept for compatebility
+ with `external program` objects. It will be
+ removed once the, also deprecated, corresponding `path()` function in the
+ `external program` object is removed.
diff --git a/mesonbuild/cmake/interpreter.py b/mesonbuild/cmake/interpreter.py
index f79f7d2..745def1 100644
--- a/mesonbuild/cmake/interpreter.py
+++ b/mesonbuild/cmake/interpreter.py
@@ -24,7 +24,7 @@ from .traceparser import CMakeTraceParser, CMakeGeneratorTarget
from .. import mlog, mesonlib
from ..mesonlib import MachineChoice, OrderedSet, version_compare, path_is_in_root, relative_to_if_possible, OptionKey
from ..mesondata import mesondata
-from ..compilers.compilers import lang_suffixes, header_suffixes, obj_suffixes, lib_suffixes, is_header
+from ..compilers.compilers import assembler_suffixes, lang_suffixes, header_suffixes, obj_suffixes, lib_suffixes, is_header
from ..programs import ExternalProgram
from enum import Enum
from functools import lru_cache
@@ -435,7 +435,7 @@ class ConverterTarget:
self.link_libraries = temp
# Filter out files that are not supported by the language
- supported = list(header_suffixes) + list(obj_suffixes)
+ supported = list(assembler_suffixes) + list(header_suffixes) + list(obj_suffixes)
for i in self.languages:
supported += list(lang_suffixes[i])
supported = [f'.{x}' for x in supported]
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index efe521c..ff87819 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -73,6 +73,8 @@ c_suffixes = lang_suffixes['c'] + ('h',) # type: T.Tuple[str, ...]
# List of languages that by default consume and output libraries following the
# C ABI; these can generally be used interchangeably
clib_langs = ('objcpp', 'cpp', 'objc', 'c', 'fortran',) # type: T.Tuple[str, ...]
+# List of assembler suffixes that can be linked with C code directly by the linker
+assembler_suffixes: T.Tuple[str, ...] = ('s', 'S')
# List of languages that can be linked with C code directly by the linker
# used in build.py:process_compilers() and build.py:get_dynamic_linker()
clink_langs = ('d', 'cuda') + clib_langs # type: T.Tuple[str, ...]
diff --git a/mesonbuild/interpreter/interpreterobjects.py b/mesonbuild/interpreter/interpreterobjects.py
index 7c4e75e..744f69c 100644
--- a/mesonbuild/interpreter/interpreterobjects.py
+++ b/mesonbuild/interpreter/interpreterobjects.py
@@ -582,19 +582,14 @@ class ExternalProgramHolder(ObjectHolder[ExternalProgram]):
return self._full_path()
def _full_path(self) -> str:
- exe = self.held_object
- # TODO: How is this case even possible? Why can this hold a build.Executable?
- if isinstance(exe, build.Executable):
- assert self.interpreter.backend is not None
- return self.interpreter.backend.get_target_filename_abs(exe)
if not self.found():
raise InterpreterException('Unable to get the path of a not-found external program')
- path = exe.get_path()
+ path = self.held_object.get_path()
assert path is not None
- return exe.get_path()
+ return path
def found(self) -> bool:
- return isinstance(self.held_object, build.Executable) or self.held_object.found()
+ return self.held_object.found()
class ExternalLibraryHolder(ObjectHolder[ExternalLibrary]):
def __init__(self, el: ExternalLibrary, interpreter: 'Interpreter'):
@@ -790,6 +785,8 @@ class BuildTargetHolder(ObjectHolder[_BuildTarget]):
'get_id': self.get_id_method,
'outdir': self.outdir_method,
'full_path': self.full_path_method,
+ 'path': self.path_method,
+ 'found': self.found_method,
'private_dir_include': self.private_dir_include_method,
})
@@ -810,6 +807,12 @@ class BuildTargetHolder(ObjectHolder[_BuildTarget]):
@noPosargs
@noKwargs
+ @FeatureNew('BuildTarget.found', '0.59.0')
+ def found_method(self, args: T.List[TYPE_var], kwargs: TYPE_kwargs) -> bool:
+ return True
+
+ @noPosargs
+ @noKwargs
def private_dir_include_method(self, args: T.List[TYPE_var], kwargs: TYPE_kwargs) -> build.IncludeDirs:
return build.IncludeDirs('', [], False, [self.interpreter.backend.get_target_private_dir(self._target_object)])
@@ -820,6 +823,12 @@ class BuildTargetHolder(ObjectHolder[_BuildTarget]):
@noPosargs
@noKwargs
+ @FeatureDeprecated('BuildTarget.path', '0.55.0', 'Use BuildTarget.full_path instead')
+ def path_method(self, args: T.List[TYPE_var], kwargs: TYPE_kwargs) -> str:
+ return self.interpreter.backend.get_target_filename_abs(self._target_object)
+
+ @noPosargs
+ @noKwargs
def outdir_method(self, args: T.List[TYPE_var], kwargs: TYPE_kwargs) -> str:
return self.interpreter.backend.get_target_dir(self._target_object)
diff --git a/mesonbuild/interpreterbase/baseobjects.py b/mesonbuild/interpreterbase/baseobjects.py
index d910e51..d82aad2 100644
--- a/mesonbuild/interpreterbase/baseobjects.py
+++ b/mesonbuild/interpreterbase/baseobjects.py
@@ -58,7 +58,7 @@ class InterpreterObject:
if not getattr(method, 'no-args-flattening', False):
args = flatten(args)
return method(args, kwargs)
- raise InvalidCode('Unknown method "%s" in object.' % method_name)
+ raise InvalidCode(f'Unknown method "{method_name}" in object {self} of type {type(self).__name__}.')
class MesonInterpreterObject(InterpreterObject):
''' All non-elementary objects and non-object-holders should be derived from this '''
diff --git a/run_project_tests.py b/run_project_tests.py
index 2e9992a..3522009 100755
--- a/run_project_tests.py
+++ b/run_project_tests.py
@@ -224,6 +224,7 @@ class InstalledFile:
@functools.total_ordering
class TestDef:
def __init__(self, path: Path, name: T.Optional[str], args: T.List[str], skip: bool = False):
+ self.category = path.parts[1]
self.path = path
self.name = name
self.args = args
@@ -1270,9 +1271,9 @@ def _run_tests(all_tests: T.List[T.Tuple[str, T.List[TestDef], bool]],
continue
# Handle skipped tests
- if (result is None) or (('MESON_SKIP_TEST' in result.stdo) and (skippable(name, t.path.as_posix()))):
+ if (result is None) or (('MESON_SKIP_TEST' in result.stdo) and (skippable(t.category, t.path.as_posix()))):
f.update_log(TestStatus.SKIP)
- current_test = ET.SubElement(current_suite, 'testcase', {'name': testname, 'classname': name})
+ current_test = ET.SubElement(current_suite, 'testcase', {'name': testname, 'classname': t.category})
ET.SubElement(current_test, 'skipped', {})
skipped_tests += 1
continue
@@ -1323,7 +1324,7 @@ def _run_tests(all_tests: T.List[T.Tuple[str, T.List[TestDef], bool]],
current_test = ET.SubElement(
current_suite,
'testcase',
- {'name': testname, 'classname': name, 'time': '%.3f' % total_time}
+ {'name': testname, 'classname': t.category, 'time': '%.3f' % total_time}
)
if result.msg != '':
ET.SubElement(current_test, 'failure', {'message': result.msg})
diff --git a/test cases/cmake/25 assembler/main.c b/test cases/cmake/25 assembler/main.c
new file mode 100644
index 0000000..5aef967
--- /dev/null
+++ b/test cases/cmake/25 assembler/main.c
@@ -0,0 +1,18 @@
+#include <stdint.h>
+#include <stdio.h>
+
+int32_t cmTestFunc(void);
+
+int main(void)
+{
+ if (cmTestFunc() > 4200)
+ {
+ printf("Test success.\n");
+ return 0;
+ }
+ else
+ {
+ printf("Test failure.\n");
+ return 1;
+ }
+}
diff --git a/test cases/cmake/25 assembler/meson.build b/test cases/cmake/25 assembler/meson.build
new file mode 100644
index 0000000..7180356
--- /dev/null
+++ b/test cases/cmake/25 assembler/meson.build
@@ -0,0 +1,9 @@
+project('assembler test', ['c', 'cpp'])
+
+cm = import('cmake')
+
+sub_pro = cm.subproject('cmTest')
+sub_dep = sub_pro.dependency('cmTest')
+
+exe1 = executable('exe1', ['main.c'], dependencies: [sub_dep])
+test('test1', exe1)
diff --git a/test cases/cmake/25 assembler/subprojects/cmTest/CMakeLists.txt b/test cases/cmake/25 assembler/subprojects/cmTest/CMakeLists.txt
new file mode 100644
index 0000000..5fb7cd6
--- /dev/null
+++ b/test cases/cmake/25 assembler/subprojects/cmTest/CMakeLists.txt
@@ -0,0 +1,45 @@
+cmake_minimum_required(VERSION 3.5)
+
+project(cmTest)
+
+#Detect processor
+if ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "amd64")
+ SET(TEST_PROCESSOR "x86_64")
+elseif ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86_64")
+ SET(TEST_PROCESSOR "x86_64")
+elseif ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "i386")
+ SET(TEST_PROCESSOR "x86")
+elseif ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "i686")
+ SET(TEST_PROCESSOR "x86")
+elseif ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm")
+ SET(TEST_PROCESSOR "arm")
+elseif ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "aarch64")
+ SET(TEST_PROCESSOR "arm")
+else ()
+ message(FATAL_ERROR, 'MESON_SKIP_TEST: Unsupported Assembler Platform')
+endif ()
+
+#Detect ABI
+if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
+ SET(TEST_ABI "sysv")
+elseif ("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD")
+ SET(TEST_ABI "sysv")
+elseif ("${CMAKE_SYSTEM_NAME}" MATCHES "NetBSD")
+ SET(TEST_ABI "sysv")
+elseif ("${CMAKE_SYSTEM_NAME}" MATCHES "OpenBSD")
+ SET(TEST_ABI "sysv")
+else ()
+ message(FATAL_ERROR, 'MESON_SKIP_TEST: Unsupported Assembler Platform')
+endif ()
+
+SET(TEST_PLATFORM "${TEST_PROCESSOR}-${TEST_ABI}")
+
+if ( ("${TEST_PLATFORM}" MATCHES "x86_64-sysv")
+ OR ("${TEST_PLATFORM}" MATCHES "x86-sysv")
+ OR ("${TEST_PLATFORM}" MATCHES "arm-sysv"))
+ SET(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
+ enable_language(ASM)
+ SET(TEST_SOURCE "cmTestAsm.s")
+endif ()
+
+add_library(cmTest STATIC cmTest.c ${TEST_SOURCE})
diff --git a/test cases/cmake/25 assembler/subprojects/cmTest/cmTest.c b/test cases/cmake/25 assembler/subprojects/cmTest/cmTest.c
new file mode 100644
index 0000000..e32415c
--- /dev/null
+++ b/test cases/cmake/25 assembler/subprojects/cmTest/cmTest.c
@@ -0,0 +1,8 @@
+#include <stdint.h>
+
+extern const int32_t cmTestArea;
+
+int32_t cmTestFunc(void)
+{
+ return cmTestArea;
+}
diff --git a/test cases/cmake/25 assembler/subprojects/cmTest/cmTestAsm.s b/test cases/cmake/25 assembler/subprojects/cmTest/cmTestAsm.s
new file mode 100644
index 0000000..8aa83a6
--- /dev/null
+++ b/test cases/cmake/25 assembler/subprojects/cmTest/cmTestAsm.s
@@ -0,0 +1,4 @@
+.text
+.globl cmTestArea
+cmTestArea:
+ .long 4242
diff --git a/test cases/common/182 find override/meson.build b/test cases/common/182 find override/meson.build
index b277459..8dcbac7 100644
--- a/test cases/common/182 find override/meson.build
+++ b/test cases/common/182 find override/meson.build
@@ -1,8 +1,10 @@
project('find program override', 'c')
gencodegen = find_program('gencodegen', required : false)
+six_prog = find_program('six_meson_exe', required : false)
assert(not gencodegen.found(), 'gencodegen is an internal program, should not be found')
+assert(not six_prog.found(), 'six_meson_exe is an internal program, should not be found')
# Test the check-if-found-else-override workflow
if not gencodegen.found()
@@ -13,3 +15,11 @@ subdir('otherdir')
tool = find_program('sometool')
assert(tool.found())
+assert(tool.full_path() != '')
+assert(tool.full_path() == tool.path())
+
+# six_meson_exe is an overritten project executable
+six_prog = find_program('six_meson_exe')
+assert(six_prog.found())
+assert(six_prog.full_path() != '')
+assert(six_prog.full_path() == six_prog.path())
diff --git a/test cases/common/182 find override/otherdir/meson.build b/test cases/common/182 find override/otherdir/meson.build
index 5cefc88..7deff40 100644
--- a/test cases/common/182 find override/otherdir/meson.build
+++ b/test cases/common/182 find override/otherdir/meson.build
@@ -10,6 +10,10 @@ e = executable('six', 'main.c', src)
test('six', e)
+# Override stuff with an executables
+meson.override_find_program('six_meson_exe', e)
+
+
# The same again, but this time with a program that was generated
# with configure_file.