]> git.tdb.fi Git - builder.git/blob - source/lib/objectfile.cpp
Refactor transitive dependencies to work on all targets
[builder.git] / source / lib / objectfile.cpp
1 #include <msp/core/algorithm.h>
2 #include <msp/fs/utils.h>
3 #include "builder.h"
4 #include "component.h"
5 #include "objectfile.h"
6 #include "sourcefile.h"
7 #include "sourcepackage.h"
8
9 using namespace std;
10 using namespace Msp;
11
12 ObjectFile::ObjectFile(Builder &b, const Component &c, SourceFile &s):
13         FileTarget(b, c.get_package(), generate_target_path(c, s.get_path())),
14         source(s)
15 {
16         component = &c;
17         add_dependency(source);
18 }
19
20 FS::Path ObjectFile::generate_target_path(const Component &comp, const FS::Path &src)
21 {
22         string fn = comp.flatten_source_path(src);
23         const Architecture &arch = comp.get_package().get_builder().get_current_arch();
24         return comp.get_temp_directory()/arch.create_filename<ObjectFile>(FS::basepart(fn));
25 }
26
27 void ObjectFile::set_used_in_shared_library(bool u)
28 {
29         used_in_shlib = u;
30 }
31
32 void ObjectFile::collect_build_info(BuildInfo &binfo) const
33 {
34         Target::collect_build_info(binfo);
35         binfo.update_from(component->get_build_info_for_path(source.get_path()));
36 }