Changeset 4dcaed2 for src/main.cc


Ignore:
Timestamp:
Aug 5, 2018, 1:13:35 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer
Children:
37fe352
Parents:
534e4e4
Message:

Added prelude-dir argument for cfa-cpp

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main.cc

    r534e4e4 r4dcaed2  
    9898        linemarks = false;
    9999
     100std::string PreludeDirector = "";
     101
    100102static void parse_cmdline( int argc, char *argv[], const char *& filename );
    101103static void parse( FILE * input, LinkageSpec::Spec linkage, bool shouldExit = false );
     
    207209                        // -l is for initial build ONLY and builtins.cf is not in the lib directory so access it here.
    208210
     211                        assertf( (libcfap | treep) != PreludeDirector.empty(), "When building in tree option --prelude-dir must be used." );
     212
    209213                        // Read to gcc builtins, if not generating the cfa library
    210                         FILE * gcc_builtins = fopen( libcfap | treep ? PRELUDE_BUILDDIR "/gcc-builtins.cf" : CFA_LIBDIR "/gcc-builtins.cf", "r" );
     214                        FILE * gcc_builtins = fopen( libcfap | treep ? (PreludeDirector + "/gcc-builtins.cf").c_str() : CFA_LIBDIR "/gcc-builtins.cf", "r" );
    211215                        assertf( gcc_builtins, "cannot open gcc-builtins.cf\n" );
    212216                        parse( gcc_builtins, LinkageSpec::Compiler );
    213217
    214218                        // read the extra prelude in, if not generating the cfa library
    215                         FILE * extras = fopen( libcfap | treep ? PRELUDE_BUILDDIR "/extras.cf" : CFA_LIBDIR "/extras.cf", "r" );
     219                        FILE * extras = fopen( libcfap | treep ? (PreludeDirector + "/extras.cf").c_str() : CFA_LIBDIR "/extras.cf", "r" );
    216220                        assertf( extras, "cannot open extras.cf\n" );
    217221                        parse( extras, LinkageSpec::BuiltinC );
     
    219223                        if ( ! libcfap ) {
    220224                                // read the prelude in, if not generating the cfa library
    221                                 FILE * prelude = fopen( treep ? PRELUDE_BUILDDIR "/prelude.cf" : CFA_LIBDIR "/prelude.cf", "r" );
     225                                FILE * prelude = fopen( treep ? (PreludeDirector + "/prelude.cf").c_str() : CFA_LIBDIR "/prelude.cf", "r" );
    222226                                assertf( prelude, "cannot open prelude.cf\n" );
    223227                                parse( prelude, LinkageSpec::Intrinsic );
    224228
    225229                                // Read to cfa builtins, if not generating the cfa library
    226                                 FILE * builtins = fopen( libcfap | treep ? PRELUDE_BUILDDIR "/builtins.cf" : CFA_LIBDIR "/builtins.cf", "r" );
     230                                FILE * builtins = fopen( libcfap | treep ? (PreludeDirector + "/builtins.cf").c_str() : CFA_LIBDIR "/builtins.cf", "r" );
    227231                                assertf( builtins, "cannot open builtins.cf\n" );
    228232                                parse( builtins, LinkageSpec::BuiltinCFA );
     
    348352                PASS( "codegen", CodeGen::generate( translationUnit, *output, ! noprotop, prettycodegenp, true, linemarks ) );
    349353
    350                 CodeGen::FixMain::fix( *output, treep ? PRELUDE_BUILDDIR "/bootloader.c" : CFA_LIBDIR "/bootloader.c" );
     354                CodeGen::FixMain::fix( *output, treep ? (PreludeDirector + "/bootloader.c").c_str() : CFA_LIBDIR "/bootloader.c" );
    351355                if ( output != &cout ) {
    352356                        delete output;
     
    397401
    398402void parse_cmdline( int argc, char * argv[], const char *& filename ) {
    399         enum { Ast, Bbox, Bresolver, CtorInitFix, DeclStats, Expr, ExprAlt, Grammar, LibCFA, Linemarks, Nolinemarks, Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, TupleExpansion, Validate, };
     403        enum { Ast, Bbox, Bresolver, CtorInitFix, DeclStats, Expr, ExprAlt, Grammar, LibCFA, Linemarks, Nolinemarks, Nopreamble, Parse, PreludeDir, Prototypes, Resolver, Symbol, Tree, TupleExpansion, Validate, };
    400404
    401405        static struct option long_opts[] = {
     
    413417                { "no-preamble", no_argument, 0, Nopreamble },
    414418                { "parse", no_argument, 0, Parse },
     419                { "prelude-dir", required_argument, 0, PreludeDir },
    415420                { "no-prototypes", no_argument, 0, Prototypes },
    416421                { "resolver", no_argument, 0, Resolver },
     
    485490                  case 'p':                                                                             // generate prototypes for preamble functions
    486491                        noprotop = true;
     492                        break;
     493                  case PreludeDir:
     494                        PreludeDirector = optarg;
    487495                        break;
    488496                  case 'm':                                                                             // don't replace the main
Note: See TracChangeset for help on using the changeset viewer.