forked from mesonbuild/meson
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
interpreter: Fix extract_object subproject validation
Fixes: mesonbuild#12519
- Loading branch information
Showing
11 changed files
with
61 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,57 @@ | ||
project('object extraction', 'c') | ||
|
||
if meson.is_unity() | ||
message('Skipping extraction test because this is a Unity build.') | ||
else | ||
lib1 = library('somelib', 'src/lib.c') | ||
lib2 = library('somelib2', 'lib.c', 'header.h', 'lib2.c') | ||
|
||
obj1 = lib1.extract_objects('src/lib.c') | ||
obj2 = lib2.extract_objects(['lib.c']) | ||
obj3 = lib2.extract_objects(files('lib.c')) | ||
obj4 = lib2.extract_objects(['lib.c', 'lib.c']) | ||
obj5 = lib2.extract_objects(['lib.c', 'header.h']) | ||
obj6 = lib2.extract_all_objects(recursive: true) | ||
|
||
e1 = executable('main1', 'main.c', objects : obj1) | ||
e2 = executable('main2', 'main.c', objects : obj2) | ||
e3 = executable('main3', 'main.c', objects : obj3) | ||
e4 = executable('main4', 'main.c', objects : obj4) | ||
e5 = executable('main5', 'main.c', objects : obj5) | ||
e6 = executable('main6', 'main.c', objects : obj6) | ||
|
||
ct_src = custom_target('lib3.c', output: 'lib3.c', capture: true, | ||
command: [find_program('create-source.py'), 'lib.c']) | ||
lib3 = library('somelib3', ct_src) | ||
e7 = executable('main7', 'main.c', objects: lib3.extract_objects(ct_src[0])) | ||
e8 = executable('main8', 'main.c', objects: lib3.extract_objects(ct_src)) | ||
error('MESON_SKIP_TEST, Skipping extraction test because this is a Unity build.') | ||
endif | ||
|
||
gen = generator(find_program('create-source.py'), arguments: ['@INPUT@'], | ||
output: '@[email protected]', capture: true) | ||
gen_src = gen.process('lib.c') | ||
lib4 = library('somelib4', gen_src) | ||
e9 = executable('main9', 'main.c', objects: lib4.extract_objects(gen_src)) | ||
lib1 = library('somelib', 'src/lib.c') | ||
lib2 = library('somelib2', 'lib.c', 'header.h', 'lib2.c') | ||
obj1 = lib1.extract_objects('src/lib.c') | ||
obj2 = lib2.extract_objects(['lib.c']) | ||
obj3 = lib2.extract_objects(files('lib.c')) | ||
obj4 = lib2.extract_objects(['lib.c', 'lib.c']) | ||
obj5 = lib2.extract_objects(['lib.c', 'header.h']) | ||
obj6 = lib2.extract_all_objects(recursive: true) | ||
e1 = executable('main1', 'main.c', objects : obj1) | ||
e2 = executable('main2', 'main.c', objects : obj2) | ||
e3 = executable('main3', 'main.c', objects : obj3) | ||
e4 = executable('main4', 'main.c', objects : obj4) | ||
e5 = executable('main5', 'main.c', objects : obj5) | ||
e6 = executable('main6', 'main.c', objects : obj6) | ||
ct_src = custom_target('lib3.c', output: 'lib3.c', capture: true, | ||
command: [find_program('create-source.py'), 'lib.c']) | ||
lib3 = library('somelib3', ct_src) | ||
e7 = executable('main7', 'main.c', objects: lib3.extract_objects(ct_src[0])) | ||
e8 = executable('main8', 'main.c', objects: lib3.extract_objects(ct_src)) | ||
gen = generator(find_program('create-source.py'), arguments: ['@INPUT@'], | ||
output: '@[email protected]', capture: true) | ||
gen_src = gen.process('lib.c') | ||
lib4 = library('somelib4', gen_src) | ||
e9 = executable('main9', 'main.c', objects: lib4.extract_objects(gen_src)) | ||
custom_target('custom_target with object inputs', output: 'objs', | ||
input: [obj1, obj2, obj3, obj5, obj6], | ||
build_by_default: true, | ||
command: [find_program('check-obj.py'), meson.backend(), '@INPUT@'], | ||
capture: true) | ||
test('extraction test 1', e1) | ||
test('extraction test 2', e2) | ||
test('extraction test 3', e3) | ||
test('extraction test 4', e4) | ||
test('extraction test 5', e5) | ||
test('extraction test 6', e6) | ||
test('extraction test 7', e7) | ||
test('extraction test 8', e8) | ||
test('extraction test 9', e9) | ||
|
||
custom_target('custom_target with object inputs', output: 'objs', | ||
input: [obj1, obj2, obj3, obj5, obj6], | ||
build_by_default: true, | ||
command: [find_program('check-obj.py'), meson.backend(), '@INPUT@'], | ||
capture: true) | ||
lib = subproject('sub').get_variable('lib') | ||
testcase expect_error('Tried to extract objects from a different subproject.') | ||
lib.extract_objects() | ||
endtestcase | ||
|
||
test('extraction test 1', e1) | ||
test('extraction test 2', e2) | ||
test('extraction test 3', e3) | ||
test('extraction test 4', e4) | ||
test('extraction test 5', e5) | ||
test('extraction test 6', e6) | ||
test('extraction test 7', e7) | ||
test('extraction test 8', e8) | ||
test('extraction test 9', e9) | ||
cc = meson.get_compiler('c') | ||
lib = cc.find_library('z', required: false) | ||
if lib.found() | ||
testcase expect_error('Unknown method .*', how: 're') | ||
lib.extract_objects() | ||
endtestcase | ||
endif |
4 changes: 4 additions & 0 deletions
4
test cases/common/22 object extraction/subprojects/sub/meson.build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
project('sub', 'c') | ||
|
||
lib = static_library('a', 'source.c') | ||
lib.extract_objects() |
5 changes: 5 additions & 0 deletions
5
test cases/common/22 object extraction/subprojects/sub/source.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
int func(void); | ||
|
||
int func(void) { | ||
return 1; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
test cases/failing/16 extract from subproject/subprojects/sub_project/meson.build
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
test cases/failing/16 extract from subproject/subprojects/sub_project/sub_lib.c
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.