diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index 6e070a7b8648..cf23eef32ee2 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -1280,6 +1280,13 @@ def path_normalize_add(path, lis): self.add_additional_options(lang, inc_cl, file_args) self.add_preprocessor_defines(lang, inc_cl, file_defines) self.add_include_dirs(lang, inc_cl, file_inc_dirs) + # Transform filename relative to src dir instead of relative to vcxproj so that the filenames + # for extract_all_objects match + file_abs = os.path.abspath(f"{target.subdir}\\{s}") + file_rel_to_src_dir = os.path.relpath(file_abs, self.source_dir) + dirpart, fnamepart = os.path.split(file_rel_to_src_dir) + file = File(True, dirpart, fnamepart) + ET.SubElement(inc_cl, 'ObjectFileName').text = "$(IntDir)" + self.object_filename_from_source(target, file) for lang in pch_sources: impl = pch_sources[lang][1] if impl and path_normalize_add(impl, previous_sources): diff --git a/test cases/common/235 extract all custom/copy.py b/test cases/common/235 extract all custom/copy.py new file mode 100644 index 000000000000..ff42ac359020 --- /dev/null +++ b/test cases/common/235 extract all custom/copy.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python3 + +import sys +import shutil + +shutil.copyfile(sys.argv[1], sys.argv[2]) diff --git a/test cases/common/235 extract all custom/custom1.c b/test cases/common/235 extract all custom/custom1.c new file mode 100644 index 000000000000..144ec2f34778 --- /dev/null +++ b/test cases/common/235 extract all custom/custom1.c @@ -0,0 +1,4 @@ +int func_custom1(void) +{ + return 0; +} diff --git a/test cases/common/235 extract all custom/gen1.c b/test cases/common/235 extract all custom/gen1.c new file mode 100644 index 000000000000..2522fc0ea2e1 --- /dev/null +++ b/test cases/common/235 extract all custom/gen1.c @@ -0,0 +1,4 @@ +int func_gen1(void) +{ + return 0; +} diff --git a/test cases/common/235 extract all custom/main.c b/test cases/common/235 extract all custom/main.c new file mode 100644 index 000000000000..a25220f5ee26 --- /dev/null +++ b/test cases/common/235 extract all custom/main.c @@ -0,0 +1,25 @@ +int func_custom1(void); +int func_custom2(void); +int func_custom3(void); +int func_custom4(void); +int func_gen1(void); +int func_gen2(void); +int func_gen3(void); +int func_gen4(void); +int func_gen5(void); +int func_gen6(void); + +int main(void) +{ + func_custom1(); + func_custom2(); + func_custom3(); + func_custom4(); + func_gen1(); + func_gen2(); + func_gen3(); + func_gen4(); + func_gen5(); + func_gen6(); + return 0; +} diff --git a/test cases/common/235 extract all custom/meson.build b/test cases/common/235 extract all custom/meson.build new file mode 100644 index 000000000000..6349d456108e --- /dev/null +++ b/test cases/common/235 extract all custom/meson.build @@ -0,0 +1,42 @@ +project('extract all custom', 'c') +fs = import('fs') + +copy = find_program('copy.py') +gen = generator(copy, + output : 'gen_@PLAINNAME@', + arguments: ['@INPUT@', '@OUTPUT@']) +src_gen = gen.process('gen1.c', 'sub/gen2.c') + +i = 0 +src_custom = [] +foreach f : ['custom1.c', 'sub/custom2.c'] + i += 1 + src_custom += [custom_target('custom' + i.to_string(), + input : f, + output : 'gen_' + fs.name(f), + command : [copy, '@INPUT@', '@OUTPUT@']) + ] +endforeach + +s1 = subproject('s1') +sub_a = s1.get_variable('sub_a') +sub_b = s1.get_variable('sub_b') +subsub_a = s1.get_variable('s2').get_variable('subsub_a') + +# Use objects from subproject and subsubproject +a = static_library('a', + sources : [src_gen, src_custom], + objects : [sub_a.extract_all_objects(), subsub_a.extract_all_objects()] +) +e1= executable('e1', + sources: ['main.c'], + link_with : a +) + +# link with lib that uses objects from subproject of subproject +e2 = executable('e2', + sources : ['main.c', src_gen, src_custom], + link_with : [sub_b] +) +test('test_e1', e1) +test('test_e2', e2) diff --git a/test cases/common/235 extract all custom/sub/custom2.c b/test cases/common/235 extract all custom/sub/custom2.c new file mode 100644 index 000000000000..325e14de9253 --- /dev/null +++ b/test cases/common/235 extract all custom/sub/custom2.c @@ -0,0 +1,4 @@ +int func_custom2(void) +{ + return 0; +} diff --git a/test cases/common/235 extract all custom/sub/gen2.c b/test cases/common/235 extract all custom/sub/gen2.c new file mode 100644 index 000000000000..f5e304bce6bf --- /dev/null +++ b/test cases/common/235 extract all custom/sub/gen2.c @@ -0,0 +1,4 @@ +int func_gen2(void) +{ + return 0; +} diff --git a/test cases/common/235 extract all custom/subprojects/s1/custom3.c b/test cases/common/235 extract all custom/subprojects/s1/custom3.c new file mode 100644 index 000000000000..dc6a31c56770 --- /dev/null +++ b/test cases/common/235 extract all custom/subprojects/s1/custom3.c @@ -0,0 +1,4 @@ +int func_custom3(void) +{ + return 0; +} diff --git a/test cases/common/235 extract all custom/subprojects/s1/gen3.c b/test cases/common/235 extract all custom/subprojects/s1/gen3.c new file mode 100644 index 000000000000..ff140493c442 --- /dev/null +++ b/test cases/common/235 extract all custom/subprojects/s1/gen3.c @@ -0,0 +1,4 @@ +int func_gen3(void) +{ + return 0; +} diff --git a/test cases/common/235 extract all custom/subprojects/s1/meson.build b/test cases/common/235 extract all custom/subprojects/s1/meson.build new file mode 100644 index 000000000000..eb1191971ec8 --- /dev/null +++ b/test cases/common/235 extract all custom/subprojects/s1/meson.build @@ -0,0 +1,26 @@ +project('subproj', 'c') + +fs = import('fs') +copy = find_program('../../copy.py') + +i = 2 +src_custom = [] +foreach f : ['custom3.c', 'sub/custom4.c'] + i += 1 + src_custom += [custom_target('custom' + i.to_string(), + input : f, + output : 'gen_' + fs.name(f), + command : [copy, '@INPUT@', '@OUTPUT@']) + ] +endforeach + +gen = generator(copy, + output : 'gen_@PLAINNAME@', + arguments: ['@INPUT@', '@OUTPUT@']) +src_gen = gen.process('gen3.c', 'sub/gen4.c') + +s2 = subproject('s2') +subsub_a = s2.get_variable('subsub_a') + +sub_a = static_library('sub_a', sources : [src_custom, src_gen]) +sub_b = static_library('sub_b', objects : [sub_a.extract_all_objects(), subsub_a.extract_all_objects()]) \ No newline at end of file diff --git a/test cases/common/235 extract all custom/subprojects/s1/sub/custom4.c b/test cases/common/235 extract all custom/subprojects/s1/sub/custom4.c new file mode 100644 index 000000000000..d5f944c83455 --- /dev/null +++ b/test cases/common/235 extract all custom/subprojects/s1/sub/custom4.c @@ -0,0 +1,4 @@ +int func_custom4(void) +{ + return 0; +} diff --git a/test cases/common/235 extract all custom/subprojects/s1/sub/gen4.c b/test cases/common/235 extract all custom/subprojects/s1/sub/gen4.c new file mode 100644 index 000000000000..34e2c719ab12 --- /dev/null +++ b/test cases/common/235 extract all custom/subprojects/s1/sub/gen4.c @@ -0,0 +1,4 @@ +int func_gen4(void) +{ + return 0; +} diff --git a/test cases/common/235 extract all custom/subprojects/s1/subprojects/s2/gen5.c b/test cases/common/235 extract all custom/subprojects/s1/subprojects/s2/gen5.c new file mode 100644 index 000000000000..469058dd2269 --- /dev/null +++ b/test cases/common/235 extract all custom/subprojects/s1/subprojects/s2/gen5.c @@ -0,0 +1,4 @@ +int func_gen5(void) +{ + return 0; +} diff --git a/test cases/common/235 extract all custom/subprojects/s1/subprojects/s2/meson.build b/test cases/common/235 extract all custom/subprojects/s1/subprojects/s2/meson.build new file mode 100644 index 000000000000..12f88d341376 --- /dev/null +++ b/test cases/common/235 extract all custom/subprojects/s1/subprojects/s2/meson.build @@ -0,0 +1,11 @@ +project('subproj', 'c') + +fs = import('fs') +copy = find_program('../../../../copy.py') + +gen = generator(copy, + output : 'gen_@PLAINNAME@', + arguments: ['@INPUT@', '@OUTPUT@']) +src_gen = gen.process('gen5.c', 'sub/gen6.c') + +subsub_a = static_library('subsub_a', sources : [src_gen]) \ No newline at end of file diff --git a/test cases/common/235 extract all custom/subprojects/s1/subprojects/s2/sub/gen6.c b/test cases/common/235 extract all custom/subprojects/s1/subprojects/s2/sub/gen6.c new file mode 100644 index 000000000000..b8a67444bfb5 --- /dev/null +++ b/test cases/common/235 extract all custom/subprojects/s1/subprojects/s2/sub/gen6.c @@ -0,0 +1,4 @@ +int func_gen6(void) +{ + return 0; +}