Skip to content

Commit

Permalink
Fix build order for targets which depend on auto-generated files
Browse files Browse the repository at this point in the history
These auto-generated files should always be rebuilt first, and hence must be
listed first in the dependencies. Otherwise, if we add a command to a
Protocol.txt file and also implement that command in the Commands.cpp source
file, we might try to compile Commands.cpp before rebuilding
autogen_Protocol.h, which will fail with a compile error, which prevents Make
from reaching the autogen_Protocol.cpp target which would cause the header file
to be updated as a side effect, which would resolve the compile error.
  • Loading branch information
qris committed Dec 4, 2017
1 parent a84c436 commit 5039ac3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions infrastructure/makebuildenv.pl.in
Expand Up @@ -872,8 +872,15 @@ __E
{
my $make;

# then... do the cpp files...
# Then, do the cpp files. Ensure that @objs_extra (from Makefile.extra) are listed
# first in the output dependencies (@objs), since any changed to their own
# dependencies (e.g. a Protocol.txt file) must cause them to be rebuilt before we
# attempt to compile any other source files, otherwise those other files might not
# compile (due to newly defined Commands not existing in the autogen_Protocol.h
# file yet) which could cause us to fail to even try to build the later dependencies
# that would fix the problem.
my @objs = @objs_extra;

for my $file (@items)
{
my $is_c = $file =~ m@(([^/]+)\.c)\Z@i;
Expand Down Expand Up @@ -939,7 +946,7 @@ __E
}

my $prefixed_end_target = "\$(${var_prefix}_OUTBASE)/$mod/$end_target_file";
my $o_file_list = join(' ',map {"\$(${var_prefix}_OUTBASE)/$mod/$_.o"} sort @objs);
my $o_file_list = join(' ',map {"\$(${var_prefix}_OUTBASE)/$mod/$_.o"} @objs);
my @prefixed_lib_files = map {"\$(${var_prefix}_OUTBASE)/$_"} @lib_files;
my @prefixed_dep_targets = map {"\$(${var_prefix}_OUTBASE)/$_"} @dep_targets;

Expand Down

0 comments on commit 5039ac3

Please sign in to comment.