From f9015e7ceb0767309cb6f5a1303b54e7facd2758 Mon Sep 17 00:00:00 2001
From: Petr Rockai <code@fixp.eu>
Date: Mon, 29 Jul 2019 17:24:09 +0000
Subject: [PATCH] test: Construct the cflags for pkgc-unpack dependency chasing
 more carefully.

---
 test/lib/pkgc-unpack | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/test/lib/pkgc-unpack b/test/lib/pkgc-unpack
index baa00d0d4..fe1f67708 100644
--- a/test/lib/pkgc-unpack
+++ b/test/lib/pkgc-unpack
@@ -7,11 +7,15 @@ $ext = "cpp" if $fn =~ m,\.cpp$,;
 my $dir = $fn;
 $dir =~ s,(^|/)([^/]*)$,,;
 my $basename = $2;
+my $file = `cat $fn`;
 
 # copy over any #include files
 my $cc = "$ENV{BINDIR}/../toolchain/clang/bin/clang";
 $cc = "c++ -std=c++14" if $ext eq "cpp";
-my $cflags = "-isystem $ENV{SRCDIR}/dios/include -isystem $ENV{BINDIR}/dios/include";
+my $cflags = "-isystem $ENV{SRCDIR}/dios/include -isystem $ENV{BINDIR}/dios/include -D__divine__";
+$cflags .= " $2" if ( $file =~ m,^(/\*|//) CC_OPTS: (.*?)(\*/)?$,sm );
+$cflags =~ s,\$SRC_ROOT,$ENV{SRCDIR},g;
+
 my $extras = `cd $dir && $cc -MM -MT "" $basename $cflags`;
 $extras =~ s,^: [^ ]*,,; # chop off the file itself
 for my $name ( split /\s+/, $extras )
@@ -24,7 +28,6 @@ for my $name ( split /\s+/, $extras )
 }
 
 # generate the variants
-my $file = `cat $fn`;
 my @var = grep { m#^// V: # } (split /\n/, $file);
 
 for ( @var )
-- 
GitLab