pike.git / NT / tools / rntcc

version» Context lines:

pike.git/NT/tools/rntcc:4:   // Written by Fredrik Hubinette.      inherit "lib.pike";      // Verbose is default for now, this can be turned off one this   // frontend has been refined to where it does not require more   // debugging.      int verbose=1;    + // Temporary variable + int linking_failed; +  + string get_ext(string file) + { +  sscanf(file=lower_case(reverse(file)),"%s.",file); +  return reverse(file); + } +    int compile(string *sources,    string dest,    string errorfile,    string *cflags)   {    int ret;    mixed cmd;    if(!dest)    {    string tmp=reverse(sources[0]);    sscanf(tmp,"%*s.%s",tmp);    dest=reverse(tmp)+".o";    }       dest=fixpath(dest);       sources=Array.map(sources,fixpath); -  if(lower_case(sources[0][strlen(sources[0])-3..])==".s") +  switch(get_ext(sources[0]))    { -  cmd=({ "wasm", "-fe"+errorfile, "-fo"+dest,})+ sources; -  }else{ +  case "c":    cmd=({ "wcc386" }) + cflags + ({"-fr"+errorfile, "-fo"+dest}) + sources; -  +  break; +  +  case "cpp": +  case "cc": +  cmd=({ "wpp386" }) + cflags + ({"-fr"+errorfile, "-fo"+dest}) + sources; +  break; +  +  case "s": +  cmd=({ "wasm", "-fe"+errorfile, "-fo"+dest,})+ sources;    }       if(verbose)    return do_cmd(cmd);    else    return silent_do_cmd(cmd);   }      string check_errorfile(string errorfile)   {
pike.git/NT/tools/rntcc:58:    werror("Error in compilation detected. "+line+"\n");    exit(1);    }    }   }      int main(int argc, string *argv)   {    string target;    string operation="link"; -  string *cflags=({}); +  string *cflags=({"-d__WIN32__","-d_WIN32"});    string *ldopts=({"OPTION","STACK=8m"});    string *libraries=({});    string *objects=({});    string *sources=({});    int debug,optimize;    string output;    int share=0;       mixed *opts=Getopt.find_all_options(argv, aggregate(    ({"oper_pre",Getopt.NO_ARG, ({"-E"}) }),
pike.git/NT/tools/rntcc:189:    case "output":    output=option[1];    break;    }    }       // Scan through the remaining arguments    argv=Getopt.get_args(argv);    foreach(argv[1..], string tmp)    { -  string ext; +     if(tmp[0]=='-')    {    werror("Unrecognized option "+tmp+".\n");    exit(1);    } -  sscanf(reverse(tmp),"%s.",ext); +        // Recognize which files need to be compiled -  switch(ext) +  switch(get_ext(tmp))    { -  case "bil": +     case "o": -  case "jbo": +     case "a": -  case "lld": +  case "obj": +  case "dll": +  case "lib":    objects+=({tmp});    break;       default:    sources+=({tmp});    }    }       if(output) rm(output);   
pike.git/NT/tools/rntcc:233:    default:    werror("Unknown operation "+operation+".\n");    exit(1);       case "compile":    compile(sources,output,errorfile,cflags);    break;       case "preprocess":    { +  switch(get_ext(sources[0])) +  { +  default: +  case "c":    int ret=silent_do_cmd( ({"wcc386","-p","-fr"+errorfile}) + cflags + Array.map(sources, fixpath));    break; -  +  +  case "cc": +  case "cpp": +  int ret=silent_do_cmd( ({"wpp386","-p","-fr"+errorfile}) + cflags + Array.map(sources, fixpath)); +  break;    } -  +  break; +  }       case "link":    foreach(sources, string source)    {    string obj=reverse(source);    sscanf(obj,"%*s.%s",obj);    obj=reverse(obj)+".obj";       compile( ({source}), obj, errorfile, cflags);    objects+=({obj});    check_errorfile(errorfile);    }    -  + // objects+=({"BINMODE.OBJ"});    string ldfile="TMP"+getpid()+".lk";    if(!output) output="a.out";    rm(ldfile);    -  +     target=output;    if(!share) target+=".exe";       string linkopts=("NAME "+target+" " +    ldopts*" "+" "+    "FILE "+Array.map(objects,fixpath)*","+" "+    sprintf("%{LIBRARY %s %}",libraries));    Stdio.write_file(ldfile,linkopts);    if(verbose)    werror("DOING wlink "+linkopts+"\n");      #if 0    Process.system("cat "+ldfile);    write("\n");   #endif -  +  linking_failed=0;       silent_do_cmd( ({"wlink","@"+ldfile }), lambda(string data)    {    if(search(data," W1008:")!=-1) -  exit(1); +  linking_failed++;    });       if(getenv("CLEANUP")!="no")    rm(ldfile); -  +  +  if(linking_failed) exit(1);    }       check_errorfile(errorfile);       if(target)    {    if(!file_stat(target))    {    werror("RNTCC: output file not generated.\n");    exit(1);