sheepy

build system (sheepy) and package manager (spm) for C
git clone https://spartatek.se/git/sheepy.git
Log | Files | Refs | README | LICENSE

commit 9ae102222d6bf11dbe2d522d591f50ec7c6808c9
parent afe8eca93fdb9e103033fa959d16e5b9d51cdcc3
Author: Remy Noulin <loader2x@gmail.com>
Date:   Thu, 31 Dec 2020 14:58:17 +0100

fix bug missing dependencies when a header file is included multiple times

For example, a program has 3 headers:
- a.h, b.h and c.h
- b.h includes a.h
- c.h includes a.h

With this patch, c.h depends on a.h.
Before this patch c.h didn't depend on a.h and c.c compilation was not
triggered

src/sheepy.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

Diffstat:
Msrc/sheepy.c | 12+++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/sheepy.c b/src/sheepy.c @@ -1062,8 +1062,7 @@ int MAIN(int ARGC, char** ARGV) { // check if c includes itself char *fN; fN = strdup(basename(s)); - // !hasG(inc, s): add to inc only new files to avoid infinite loops - if (!eqG(fN, fileName) && !hasG(inc, s)) { + if (!eqG(fN, fileName)) { // add new include to inc array char *tmp = catS(fileDir, "/", s); iNormalizePath(&tmp); @@ -1078,7 +1077,10 @@ int MAIN(int ARGC, char** ARGV) { // because main.c is in buildPath and the compiler needs // to find the headers if (symlinkFile(realFPath, buildFPath)) { - pushG(inc, tmp); + // !hasG(inc, s): add to inc only new files to avoid infinite loops + if (!hasG(inc, s)) { + pushG(inc, tmp); + } pushG(depFiles, tmp); } freeManyS(tmp, realFPath, buildFPath); @@ -1115,7 +1117,7 @@ int MAIN(int ARGC, char** ARGV) { castS(cL, cl) char *s = getInclude(cL); // !hasG(inc, s): add to inc only new files to avoid infinite loops - if (s && !hasG(inc, s)) { + if (s) { char *tmp = catS(fileDir, "/", s); iNormalizePath(&tmp); char *realFPath = catS(actualDir, "/", tmp); @@ -1127,7 +1129,7 @@ int MAIN(int ARGC, char** ARGV) { // check if c includes itself char *fN; fN = strdup(basename(s)); - if (!eqG(fN, fileName)) { + if (!eqG(fN, fileName) && !hasG(inc, s)) { // add new include to inc array pushG(inc, tmp); }