Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main.cc

    r37fe352 r05e6eb5  
    2828#include <string>                           // for char_traits, operator<<
    2929
     30#include "CompilationState.h"
    3031#include "../config.h"                      // for CFA_LIBDIR
    3132#include "CodeGen/FixMain.h"                // for FixMain
     
    7273DeclarationNode * parseTree = nullptr;                                  // program parse tree
    7374
    74 extern int yydebug;                                                                             // set for -g flag (Grammar)
    75 bool
    76         astp = false,
    77         bresolvep = false,
    78         bboxp = false,
    79         bcodegenp = false,
    80         ctorinitp = false,
    81         declstatsp = false,
    82         exprp = false,
    83         expraltp = false,
    84         genericsp = false,
    85         libcfap = false,
    86         nopreludep = false,
    87         noprotop = false,
    88         nomainp = false,
    89         parsep = false,
    90         resolvep = false,                                                                       // used in AlternativeFinder
    91         symtabp = false,
    92         treep = false,
    93         tuplep = false,
    94         validp = false,
    95         errorp = false,
    96         codegenp = false,
    97         prettycodegenp = false,
    98         linemarks = false;
    99 
    100 std::string PreludeDirector = "";
    101 
    10275static void parse_cmdline( int argc, char *argv[], const char *& filename );
    10376static void parse( FILE * input, LinkageSpec::Spec linkage, bool shouldExit = false );
     
    209182                        // -l is for initial build ONLY and builtins.cf is not in the lib directory so access it here.
    210183
    211                         assertf( !PreludeDirector.empty(), "Can't find prelude without option --prelude-dir must be used." );
    212 
    213184                        // Read to gcc builtins, if not generating the cfa library
    214                         FILE * gcc_builtins = fopen( (PreludeDirector + "/gcc-builtins.cf").c_str(), "r" );
     185                        FILE * gcc_builtins = fopen( buildingLibrary() ? "../prelude/gcc-builtins.cf" : CFA_LIBDIR "/gcc-builtins.cf", "r" );
    215186                        assertf( gcc_builtins, "cannot open gcc-builtins.cf\n" );
    216187                        parse( gcc_builtins, LinkageSpec::Compiler );
    217188
    218189                        // read the extra prelude in, if not generating the cfa library
    219                         FILE * extras = fopen( (PreludeDirector + "/extras.cf").c_str(), "r" );
     190                        FILE * extras = fopen( buildingLibrary() ? "../prelude/extras.cf" : CFA_LIBDIR "/extras.cf", "r" );
    220191                        assertf( extras, "cannot open extras.cf\n" );
    221192                        parse( extras, LinkageSpec::BuiltinC );
     
    223194                        if ( ! libcfap ) {
    224195                                // read the prelude in, if not generating the cfa library
    225                                 FILE * prelude = fopen( (PreludeDirector + "/prelude.cf").c_str(), "r" );
     196                                FILE * prelude = fopen( buildingLibrary() ? "../prelude/prelude.cf" : CFA_LIBDIR "/prelude.cf", "r" );
    226197                                assertf( prelude, "cannot open prelude.cf\n" );
    227198                                parse( prelude, LinkageSpec::Intrinsic );
    228199
    229200                                // Read to cfa builtins, if not generating the cfa library
    230                                 FILE * builtins = fopen( (PreludeDirector + "/builtins.cf").c_str(), "r" );
     201                                FILE * builtins = fopen( buildingLibrary() ? "../prelude/builtins.cf" : CFA_LIBDIR "/builtins.cf", "r" );
    231202                                assertf( builtins, "cannot open builtins.cf\n" );
    232203                                parse( builtins, LinkageSpec::BuiltinCFA );
     
    303274
    304275                // fix ObjectDecl - replaces ConstructorInit nodes
    305                 PASS( "fixInit", InitTweak::fix( translationUnit, filename, libcfap || treep ) );
     276                PASS( "fixInit", InitTweak::fix( translationUnit, buildingLibrary() ) );
    306277                if ( ctorinitp ) {
    307278                        dump ( translationUnit );
     
    352323                PASS( "codegen", CodeGen::generate( translationUnit, *output, ! noprotop, prettycodegenp, true, linemarks ) );
    353324
    354                 CodeGen::FixMain::fix( *output, (PreludeDirector + "/bootloader.c").c_str() );
     325                CodeGen::FixMain::fix( *output, treep ? "../prelude/bootloader.c" : CFA_LIBDIR "/bootloader.c" );
    355326                if ( output != &cout ) {
    356327                        delete output;
     
    401372
    402373void parse_cmdline( int argc, char * argv[], const char *& filename ) {
    403         enum { Ast, Bbox, Bresolver, CtorInitFix, DeclStats, Expr, ExprAlt, Grammar, LibCFA, Linemarks, Nolinemarks, Nopreamble, Parse, PreludeDir, Prototypes, Resolver, Symbol, Tree, TupleExpansion, Validate, };
     374        enum { Ast, Bbox, Bresolver, CtorInitFix, DeclStats, Expr, ExprAlt, Grammar, LibCFA, Linemarks, Nolinemarks, Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, TupleExpansion, Validate, };
    404375
    405376        static struct option long_opts[] = {
     
    417388                { "no-preamble", no_argument, 0, Nopreamble },
    418389                { "parse", no_argument, 0, Parse },
    419                 { "prelude-dir", required_argument, 0, PreludeDir },
    420390                { "no-prototypes", no_argument, 0, Prototypes },
    421391                { "resolver", no_argument, 0, Resolver },
     
    490460                  case 'p':                                                                             // generate prototypes for preamble functions
    491461                        noprotop = true;
    492                         break;
    493                   case PreludeDir:
    494                         PreludeDirector = optarg;
    495462                        break;
    496463                  case 'm':                                                                             // don't replace the main
Note: See TracChangeset for help on using the changeset viewer.