3 This file is part of builder
4 Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
9 #include <msp/strings/regex.h>
11 #include "component.h"
13 #include "sourcefile.h"
18 SourceFile::SourceFile(Builder &b, const Component *c, const string &n):
19 Target(b, c?&c->get_package():0, n),
24 Parses include directives from the file and looks up the appropriate targets
27 void SourceFile::find_depends()
29 DependencyCache &deps_cache=comp->get_package().get_deps_cache();
30 if(mtime>deps_cache.get_mtime())
32 ifstream in(name.c_str());
35 Regex r_include("^[ \t]*#include[ \t]+([\"<].*)[\">]");
38 while(getline(in, line))
39 if(RegMatch match=r_include.match(line))
40 includes.push_back(match[1].str);
42 deps_cache.set_deps(name, includes);
45 includes=deps_cache.get_deps(name);
47 const StringList &incpath=comp->get_build_info().incpath;
48 const string &arch=comp->get_package().get_arch();
50 string path=name.substr(0, name.rfind('/'));
51 for(list<string>::iterator i=includes.begin(); i!=includes.end(); ++i)
53 Target *hdr=builder.get_header(*i, arch, path, incpath);