]> git.tdb.fi Git - builder.git/blobdiff - source/buildinfo.cpp
More sophisticated handling of language standards
[builder.git] / source / buildinfo.cpp
index 114a368ecc96feabec39807621d1dc0d1a363e85..1cafbd3b866344d2665181393b7e1fa0855ea197 100644 (file)
@@ -28,6 +28,7 @@ void unique(list<T> &l)
 
 BuildInfo::BuildInfo():
        libmode(DYNAMIC),
+       rpath_mode(NO_RPATH),
        threads(false),
        debug(false),
        optimize(0),
@@ -64,6 +65,7 @@ void BuildInfo::update_from(const BuildInfo &bi, UpdateLevel level)
                sysroot = bi.sysroot;
                local_incpath.insert(local_incpath.begin(), bi.local_incpath.begin(), bi.local_incpath.end());
                libmode = bi.libmode;
+               rpath_mode = bi.rpath_mode;
                for(LibModeMap::const_iterator i=bi.libmodes.begin(); i!=bi.libmodes.end(); ++i)
                        libmodes[i->first] = i->second;
                keep_symbols.insert(keep_symbols.end(), bi.keep_symbols.begin(), bi.keep_symbols.end());
@@ -82,6 +84,23 @@ void BuildInfo::update_from(const BuildInfo &bi, UpdateLevel level)
 }
 
 
+BuildInfo::LanguageStandard::LanguageStandard(const string &std)
+{
+       string::size_type num = string::npos;
+       for(string::size_type i=0; (num==string::npos && i<std.size()); ++i)
+               if(isdigit(static_cast<unsigned char>(std[i])))
+                       num = i;
+       type = std.substr(0, num);
+       year = lexical_cast<unsigned>(std.substr(num));
+       year += (year<70 ? 2000 : 1900);
+}
+
+string BuildInfo::LanguageStandard::str() const
+{
+       return format("%s%02d", type, year%100);
+}
+
+
 BuildInfo::Loader::Loader(BuildInfo &bi):
        DataFile::ObjectLoader<BuildInfo>(bi)
 {
@@ -95,6 +114,7 @@ BuildInfo::Loader::Loader(BuildInfo &bi):
        add("libmode",  &Loader::libmode_for_lib);
        add("local_incpath", &Loader::local_incpath);
        add("optimize", &BuildInfo::optimize);
+       add("runtime_path_mode", &BuildInfo::rpath_mode);
        add("standard", &Loader::standard);
        add("strip",    &BuildInfo::strip);
        add("sysroot",  &Loader::sysroot);
@@ -162,3 +182,16 @@ void operator>>(const LexicalConverter &conv, BuildInfo::LibraryMode &libmode)
        else
                throw lexical_error(format("Conversion of '%s' to LibraryMode", conv.get()));
 }
+
+
+void operator>>(const LexicalConverter &conv, BuildInfo::RuntimePathMode &rpath_mode)
+{
+       if(conv.get()=="NONE")
+               rpath_mode = BuildInfo::NO_RPATH;
+       else if(conv.get()=="RELATIVE")
+               rpath_mode = BuildInfo::RELATIVE;
+       else if(conv.get()=="ABSOLUTE")
+               rpath_mode = BuildInfo::ABSOLUTE;
+       else
+               throw lexical_error(format("Conversion of '%s' to RuntimePathMode", conv.get()));
+}