add testcase for bad things with add_project_dependencies

Test that add_project_dependencies() can only be used before build targets
have been declared.  Also test that one cannot use override_dependency
on a superproject to inject a superproject's build products into the
subproject.  This would violate the rule that build products cannot be used
with add_project_dependencies() (similar to e.g. compiler.has_function),
so check that meson detects the situation correctly.
pull/10347/head
Paolo Bonzini 3 years ago committed by Eli Schwartz
parent 3a960023d3
commit 2f68aa21e8
  1. 2
      test cases/failing/124 override and add_project_dependency/inc/lib.h
  2. 3
      test cases/failing/124 override and add_project_dependency/lib.c
  3. 8
      test cases/failing/124 override and add_project_dependency/meson.build
  4. 10
      test cases/failing/124 override and add_project_dependency/subprojects/a/meson.build
  5. 6
      test cases/failing/124 override and add_project_dependency/subprojects/a/prog.c
  6. 7
      test cases/failing/124 override and add_project_dependency/test.json
  7. 2
      test cases/failing/125 targets before add_project_dependency/inc/lib.h
  8. 3
      test cases/failing/125 targets before add_project_dependency/lib.c
  9. 5
      test cases/failing/125 targets before add_project_dependency/meson.build
  10. 7
      test cases/failing/125 targets before add_project_dependency/test.json

@ -0,0 +1,3 @@
#include <stdio.h>
#include "lib.h"
void f() {puts("hello");}

@ -0,0 +1,8 @@
project('super', 'c')
inc = include_directories('inc')
lib = static_library('sneaky', 'lib.c', include_directories: inc)
meson.override_dependency('sneaky',
declare_dependency(link_with: lib, include_directories: inc))
subproject('a')

@ -0,0 +1,10 @@
project('a', 'c')
dep = dependency('sneaky')
# does not work
add_project_dependencies(dep, language: 'c')
executable('prog', 'prog.c')
# this would work instead:
# executable('prog', 'prog.c', dependencies: dep)

@ -0,0 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/124 override and add_project_dependency/subprojects/a/meson.build:6:0: ERROR: Dependencies must be external dependencies"
}
]
}

@ -0,0 +1,3 @@
#include <stdio.h>
#include "lib.h"
void f() {puts("hello");}

@ -0,0 +1,5 @@
project('test', 'c')
static_library('lib', 'lib.c')
inc = include_directories('inc')
add_project_dependencies(declare_dependency(include_directories: inc), language: 'c')

@ -0,0 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/125 targets before add_project_dependency/meson.build:5:0: ERROR: Tried to use 'add_project_dependencies' after a build target has been declared."
}
]
}
Loading…
Cancel
Save