Changeset 1ee048fd for driver


Ignore:
Timestamp:
Aug 13, 2019, 3:25:57 PM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
d65f92c
Parents:
ef46abb
Message:

All tests pass with distributed compilation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified driver/cfa.cc

    ref46abb r1ee048fd  
    3838
    3939
    40 bool prefix( string arg, string pre ) {
     40bool prefix( const string & arg, const string & pre ) {
    4141        return arg.substr( 0, pre.size() ) == pre;
    4242} // prefix
    4343
    44 bool suffix( string arg ) {
    45         enum { NumSuffixes = 3 };
    46         static const string suffixes[NumSuffixes] = { "cfa", "hfa", "ifa" };
    47         //std::cerr << arg << std::endl;
    48         size_t dot = arg.find_last_of( "." );
    49         //std::cerr << dot << " " << (dot != string::npos ? arg.substr( dot + 1 ) : "fred" ) << std::endl;
    50         if ( dot == string::npos ) return false;
    51         const string * end = suffixes + NumSuffixes;
    52         return std::find( suffixes, end, arg.substr( dot + 1 ) ) != end;
     44inline bool ends_with(const string & str, const string & sfix) {
     45        if (sfix.size() > str.size()) return false;
     46        return std::equal(str.rbegin(), str.rbegin() + sfix.size(), sfix.rbegin(), sfix.rend());
     47}
     48
     49bool suffix( const string & arg ) {
     50        static const string suffixes[] = { ".cfa", ".hfa", ".cfa.ii" };
     51        for(const auto sfix : suffixes) {
     52                if(arg.size() <= sfix.size()) continue;
     53                size_t pos = arg.find_last_of(sfix);
     54                size_t exp = (arg.size() - 1);
     55                if(pos == exp) return true;
     56        }
     57        return false;
    5358} // suffix
    5459
     
    116121        bool m64 = false;                                                                       // -m64 flag
    117122        bool intree = false;
     123        bool compiling_libs = false;
    118124        bool disttree = false;
    119125
     
    133139
    134140        // process command-line arguments
    135 
    136         args[nargs] = "-x";                                                                     // turn off language
    137         nargs += 1;
    138         args[nargs] = "c";
    139         nargs += 1;
    140141
    141142        for ( int i = 1; i < argc; i += 1 ) {
     
    183184                        } else if ( arg == "-dist-tree" ) {
    184185                                disttree = true;
     186                        } else if ( arg == "-cfalib") {
     187                                compiling_libs = true;
    185188                        } else if ( arg == "-compiler" ) {
    186189                                // use the user specified compiler
     
    375378        } else {
    376379                libbase = TOP_BUILDDIR "libcfa/";
     380        }
     381
     382        if( compiling_libs ) {
    377383                args[nargs] = "-D__CFA_FLAG__=-t";
    378384                nargs += 1;
     
    564570        cerr << "args:" << endl;
    565571        for ( int i = 0; args[i] != NULL; i += 1 ) {
    566                 cerr << " \"" << args[i] << "\"" << endl;
     572                cerr << " \"" << args[i] << "\" ";
    567573        } // for
     574        cerr << endl;
    568575        #endif // __DEBUG_H__
    569576
Note: See TracChangeset for help on using the changeset viewer.