ninja: fix handling of rust structured_sources in rare case

In the even that all of the inputs are generated, and they're all
generated into the same folder, and there are no subfolders, we would
fail to correctly handle all of the files after the main file. Let's fix
that.t
This commit is contained in:
Dylan Baker 2022-03-18 19:46:47 -07:00
parent f9445300b3
commit 9b83fc5ece
5 changed files with 42 additions and 4 deletions

View File

@ -1709,17 +1709,24 @@ class NinjaBackend(backends.Backend):
_ods, main_rust_file = self.__generate_compile_structure(target)
orderdeps.extend(_ods)
else:
# The only way to get here is to have only files in the "root"
# positional argument, which are all generated into the same
# directory
g = target.structured_sources.first_file()
if isinstance(g, File):
main_rust_file = g.rel_to_builddir(self.build_to_src)
elif isinstance(g, GeneratedList):
main_rust_file = os.path.join(self.get_target_private_dir(target), i)
main_rust_file = os.path.join(self.get_target_private_dir(target), g.get_outputs()[0])
else:
main_rust_file = os.path.join(g.get_subdir(), i)
orderdeps.extend([os.path.join(self.build_to_src, target.subdir, s)
for s in target.structured_sources.as_list()])
main_rust_file = os.path.join(g.get_subdir(), g.get_outputs()[0])
for f in target.structured_sources.as_list():
if isinstance(f, File):
orderdeps.append(f.rel_to_builddir(self.build_to_src))
else:
orderdeps.extend([os.path.join(self.build_to_src, f.subdir, s)
for s in f.get_outputs()])
for i in target.get_sources():
if not rustc.can_compile(i):

View File

@ -0,0 +1,5 @@
include!(r#"@dir@/include.rs"#);
pub fn main() {
priv_func();
}

View File

@ -37,3 +37,22 @@ executable(
)
test('no-copy', find_program('no_copy_test.py'), args : meson.current_build_dir())
subdir('src2')
executable('copy-no-gen', srcs2)
m_src = configure_file(
input : 'main-gen-copy.rs',
output : 'main-gen-copy.rs',
configuration : {'dir' : meson.current_build_dir().replace('\\', '/')},
)
m_src2 = configure_file(
input : 'priv.rs',
output : 'include.rs',
copy : true
)
executable('gen-no-copy', structured_sources([m_src, m_src2]))

View File

@ -0,0 +1,3 @@
fn priv_func() {
std::process::exit(0);
}

View File

@ -0,0 +1,4 @@
srcs2 = structured_sources(
['main-unique.rs'],
{'foo': 'foo/mod.rs'},
)