diff --git a/backends.py b/backends.py index 563557d31..81062f988 100644 --- a/backends.py +++ b/backends.py @@ -220,7 +220,12 @@ class Backend(): if is_unity: unity_src.append(src) else: - obj_list.append(self.generate_single_compile(target, outfile, src, True)) + # Generated targets are ordered deps because the must exist + # before the sources compiling them are used. After the first + # compile we get precise dependency info from dep files. + # This should work in all cases. If it does not, then just + # move them from orderdeps to proper deps. + obj_list.append(self.generate_single_compile(target, outfile, src, True, [], header_deps)) for src in target.get_sources(): if not self.environment.is_header(src): src_list.append(src) @@ -229,7 +234,7 @@ class Backend(): target.get_subdir(), src) unity_src.append(abs_src) else: - obj_list.append(self.generate_single_compile(target, outfile, src, False, header_deps)) + obj_list.append(self.generate_single_compile(target, outfile, src, False, [], header_deps)) obj_list += self.flatten_object_list(target) if is_unity: for src in self.generate_unity_files(target, unity_src): diff --git a/ninjabackend.py b/ninjabackend.py index f692aba10..7d7d91be9 100644 --- a/ninjabackend.py +++ b/ninjabackend.py @@ -594,7 +594,7 @@ class NinjaBackend(backends.Backend): elem.add_item('COMMAND', cmdlist) elem.write(outfile) - def generate_single_compile(self, target, outfile, src, is_generated=False, header_deps=[]): + def generate_single_compile(self, target, outfile, src, is_generated=False, header_deps=[], order_deps=[]): compiler = self.get_compiler_for_source(src) commands = self.generate_basic_compiler_flags(target, compiler) commands.append(compiler.get_include_arg(self.get_target_private_dir(target))) @@ -645,6 +645,10 @@ class NinjaBackend(backends.Backend): if not '/' in d: d = os.path.join(self.get_target_private_dir(target), d) element.add_dep(d) + for d in order_deps: + if not '/' in d: + d = os.path.join(self.get_target_private_dir(target), d) + element.add_orderdep(d) element.add_orderdep(pch_dep) element.add_item('DEPFILE', dep_file) element.add_item('FLAGS', commands) diff --git a/test cases/frameworks/4 qt5/meson.build b/test cases/frameworks/4 qt5/meson.build index 2eefafd93..53bf1a82f 100644 --- a/test cases/frameworks/4 qt5/meson.build +++ b/test cases/frameworks/4 qt5/meson.build @@ -4,8 +4,8 @@ qt5dep = dependency('qt5', modules : 'Widgets') q5exe = executable('qt5app', sources : ['main.cpp', 'mainWindow.cpp'], # Sources that don't need preprocessing. -moc_headers : ['mainWindow.h'], # These need to be fed through the moc tool before use. -ui_files : 'mainWindow.ui', # XML files that need to be compiled with the uic tol. +moc_headers : ['mainWindow.h'], # These need to be fed through the moc tool before use. +ui_files : 'mainWindow.ui', # XML files that need to be compiled with the uic tol. qresources : ['stuff.qrc', 'stuff2.qrc'], # Resource files for rcc compiler. deps : qt5dep)