else
ln -sf $path/source "$INCLUDEDIR/msp/$i"
fi
- sources="$sources `find $path/source -name '*.cpp'`"
+ sources="$sources `find $path/source \( -name windows -prune \) -o \( -name '*.cpp' -print \)`"
fi
done
exit 1
fi
+for i in "$INCLUDEDIR/msp/"*/unix; do
+ CFLAGS="$CFLAGS -iquote $i -iquote ${i%/unix}"
+done
+
echo "Compiling builder-stage1. This may take several minutes."
g++ $sources -o builder-stage1 $CFLAGS $LIBS
echo "Using builder-stage1 to compile builder."
}
}
+BuildInfo Component::get_build_info_for_path(const FS::Path &path) const
+{
+ // XXX Cache these and check that the directories actually exist before adding them
+ BuildInfo binfo = build_info;
+ if(!overlays.empty())
+ {
+ FS::Path dir = FS::dirname(path);
+ string last = FS::basename(dir);
+ for(OverlayList::const_iterator i=overlays.begin(); i!=overlays.end(); ++i)
+ if(last==*i)
+ {
+ dir = FS::dirname(dir);
+ break;
+ }
+
+ for(SourceList::const_iterator i=sources.begin(); i!=sources.end(); ++i)
+ if(dir==*i)
+ {
+ binfo.local_incpath.push_back(dir);
+ for(OverlayList::const_iterator j=overlays.begin(); j!=overlays.end(); ++j)
+ binfo.local_incpath.push_back(*i/ *j);
+ }
+ }
+ return binfo;
+}
+
void Component::create_targets() const
{
Builder &builder = package.get_builder();
FS::Path path(*i);
if(FS::is_dir(path))
{
- package.get_builder().get_logger().log("files", format("Traversing %s", path));
- list<string> sfiles = list_files(path);
- for(list<string>::iterator j=sfiles.begin(); j!=sfiles.end(); ++j)
- files.push_back(path / *j);
+ SourceList dirs;
+ dirs.push_back(path);
+ for(OverlayList::const_iterator j=overlays.begin(); j!=overlays.end(); ++j)
+ {
+ FS::Path opath = path / *j;
+ if(FS::is_dir(opath))
+ dirs.push_back(opath);
+ }
+ for(SourceList::const_iterator j=dirs.begin(); j!=dirs.end(); ++j)
+ {
+ package.get_builder().get_logger().log("files", format("Traversing %s", *j));
+ list<string> sfiles = list_files(*j);
+ for(list<string>::iterator k=sfiles.begin(); k!=sfiles.end(); ++k)
+ files.push_back(*j / *k);
+ }
}
else
+ {
files.push_back(path);
+ for(OverlayList::const_iterator j=overlays.begin(); j!=overlays.end(); ++j)
+ {
+ FS::Path opath = FS::dirname(path)/ *j/FS::basename(path);
+ if(FS::is_reg(opath))
+ files.push_back(opath);
+ }
+ }
}
return files;
{
add("if_arch", &Loader::if_arch);
add("if_feature", &Loader::if_feature);
+ add("overlay", &Loader::overlay);
add("source", &Loader::source);
add("install", &Component::install);
add("install_map", &Loader::install_map);
load_sub(obj.install_map, obj.package.get_source_directory());
}
+void Component::Loader::overlay(const string &o)
+{
+ obj.overlays.push_back(o);
+}
+
void Component::Loader::require(const string &n)
{
Package *req = obj.package.get_builder().get_package_manager().find_package(n);
void if_arch(const std::string &);
void if_feature(const std::string &);
void install_map();
+ void overlay(const std::string &);
void require(const std::string &);
void source(const std::string &);
void use(const std::string &);
};
typedef std::list<Msp::FS::Path> SourceList;
+ typedef std::list<std::string> OverlayList;
typedef std::list<const Component *> UseList;
protected:
Type type;
std::string name;
SourceList sources;
+ OverlayList overlays;
bool install;
BuildInfo build_info;
Package::Requirements requires;
directories or individual files. */
const SourceList &get_sources() const { return sources; }
+ const OverlayList &get_overlays() const { return overlays; }
+
protected:
/** Returns a list of all source files for the component. */
SourceList collect_source_files() const;
const BuildInfo &get_build_info() const { return build_info; }
+ BuildInfo get_build_info_for_path(const Msp::FS::Path &) const;
+
void create_targets() const;
};
#include <msp/fs/utils.h>
+#include "component.h"
#include "filetarget.h"
#include "installmap.h"
FS::Path InstallMap::get_install_location(const FileTarget &target) const
{
+ const Component *comp = target.get_component();
+ unsigned overlay_depth = 0;
+ if(comp && !comp->get_overlays().empty())
+ {
+ const Component::OverlayList &overlays = comp->get_overlays();
+ string last_dir = FS::basename(FS::dirname(target.get_path()));
+ for(Component::OverlayList::const_iterator i=overlays.begin(); i!=overlays.end(); ++i)
+ if(last_dir==*i)
+ overlay_depth = 1;
+ }
+
const FS::Path &source = target.get_path();
FS::Path install = target.get_install_location();
for(list<Entry>::const_iterator i=entries.begin(); i!=entries.end(); ++i)
FS::Path install_base = FS::common_ancestor(install, i->install);
if(install_base.size()>1)
{
- install = i->install/FS::dirname(source).subpath(i->source.size());
+ install = i->install/source.subpath(i->source.size(), source_depth-1-overlay_depth);
break;
}
}
FS::Path displaced = tgt->get_path()/FS::relative(file->get_path(), rtgt->get_path());
if(Target *ddep = builder.get_vfs().get_target(displaced))
deps_to_add.push_back(ddep);
+ else
+ {
+ const Component *tcomp = file->get_component();
+ const Component::OverlayList &overlays = tcomp->get_overlays();
+ string last_dir = FS::basename(FS::dirname(displaced));
+ for(Component::OverlayList::const_iterator j=overlays.begin(); j!=overlays.end(); ++j)
+ if(last_dir==*j)
+ {
+ displaced = displaced.subpath(0, displaced.size()-2)/FS::basename(file->get_path());
+ if((ddep = builder.get_vfs().get_target(displaced)))
+ deps_to_add.push_back(ddep);
+ }
+ }
}
else
deps_to_add.push_back(*i);