Added several functions (to ctype.h, stdlib.h)
"Optimised" some functions in string.h Added dynamic libraries support based on sysfunction 68.19 (experimental) git-svn-id: svn://kolibrios.org@215 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
@@ -1,118 +1,128 @@
|
||||
var fso=new ActiveXObject("Scripting.FileSystemObject");
|
||||
var wsh=WScript.CreateObject("WScript.Shell");
|
||||
var curpath=".";
|
||||
var gccpath="c:\\program files\\MinGW\\MinGW\\bin\\";
|
||||
//var gccpath="cmd.exe /c ";
|
||||
var gccexe="\""+gccpath+"cc1.exe"+"\" ";
|
||||
var asexe="\""+gccpath+"as.exe"+"\" ";
|
||||
var objcopyexe="\""+gccpath+"objcopy.exe"+"\" ";
|
||||
//var gccexe=gccpath+"cc1.exe" ;
|
||||
//var asexe=gccpath+"as.exe";
|
||||
var scriptline="CREATE melibc.a\r\n";
|
||||
ForReading = 1
|
||||
ForWriting = 2
|
||||
ForAppending = 8
|
||||
var fso = new ActiveXObject("Scripting.FileSystemObject");
|
||||
var wsh = new ActiveXObject("WScript.Shell");
|
||||
function alert(mes){WScript.Echo(mes);return mes}
|
||||
function debug(obj){for(key in obj)alert('['+key+']="'+obj[key]+'"')}
|
||||
function getFileContent(filename){
|
||||
var file = fso.OpenTextFile(filename, ForReading);
|
||||
var content = file.ReadAll();
|
||||
file.close();
|
||||
return content;
|
||||
}
|
||||
function include(filename){
|
||||
eval(getFileContent(filename));
|
||||
}
|
||||
function Project(filename){
|
||||
var text = getFileContent(filename);
|
||||
eval("var config = {"+text+"};")
|
||||
for(key in config) this[key] = config[key];
|
||||
if(!this.files) this.files = [];
|
||||
function getFileExt(name){
|
||||
var i = name.lastIndexOf(".");
|
||||
return (i==-1)? "" : name.substr(i);
|
||||
}
|
||||
this.getFileList = function(folder){
|
||||
var f = fso.GetFolder(folder);
|
||||
var fc = new Enumerator(f.SubFolders);
|
||||
for (; !fc.atEnd(); fc.moveNext())
|
||||
{
|
||||
var name = fc.item()+"";
|
||||
if(name[0]!='.' && !this.isIgnored(name))
|
||||
this.getFileList(name);
|
||||
}
|
||||
delete fc;
|
||||
fc = new Enumerator(f.Files);
|
||||
for (; !fc.atEnd(); fc.moveNext())
|
||||
{
|
||||
var name = fc.item()+"";
|
||||
if(name[0]!='.' && !this.isIgnored(name))
|
||||
this.files.push(name);
|
||||
}
|
||||
}
|
||||
this.clean = function(){
|
||||
var fl = new Enumerator(this.files);
|
||||
var fo;
|
||||
for (; !fl.atEnd(); fl.moveNext()){
|
||||
var file = fl.item()
|
||||
switch(getFileExt(file)){
|
||||
case ".o":
|
||||
case ".s":
|
||||
fo = fso.GetFile(file);
|
||||
fo.Delete();
|
||||
break;
|
||||
}
|
||||
}
|
||||
delete fl;
|
||||
}
|
||||
var objList = [];
|
||||
this.compile_asm = function(filename){
|
||||
var objname = filename.replace(/.\w{1,3}$/,".o");
|
||||
objList.push(objname);
|
||||
if(fso.FileExists(objname)) return;
|
||||
wsh.Run(this.fasm+' "'+filename+'" "'+objname+'"',0,true);
|
||||
}
|
||||
this.compile_c = function(filename){
|
||||
var objname = filename.replace(/.\w{1,3}$/,".o");
|
||||
objList.push(objname);
|
||||
if(fso.FileExists(objname)) return;
|
||||
var asmname = filename.replace(/.\w{1,3}$/,".s");
|
||||
var command = "";
|
||||
if(!fso.FileExists(asmname)){
|
||||
command = this.gccpath +"\\"+ this.gccexe + " -nostdinc";
|
||||
if(this.include) command += " -I .\\include";
|
||||
command +=" -DGNUC" +' "'+filename + '" -o "' + asmname + '"';
|
||||
wsh.Run("cmd.exe /c "+command, 0, true);
|
||||
}
|
||||
command = this.gccpath +"\\"+ this.asexe +' "'+ asmname +'" -o "'+ objname +'"';
|
||||
wsh.Run("cmd.exe /c "+command, 0, true);
|
||||
command = this.gccpath +"\\"+ this.objcopyexe +' -O elf32-i386 --remove-leading-char "'+ objname +'"';
|
||||
wsh.Run("cmd.exe /c "+command, 0, true);
|
||||
}
|
||||
this.build = function(){
|
||||
var fl = new Enumerator(this.files);
|
||||
for (; !fl.atEnd(); fl.moveNext()){
|
||||
var file = fl.item()
|
||||
switch(getFileExt(file)){
|
||||
case ".c": this.compile_c(file);break;
|
||||
case ".asm": this.compile_asm(file);break;
|
||||
case ".o": objList.push(file);break;
|
||||
}
|
||||
}
|
||||
delete fl;
|
||||
fl = new Enumerator(objList);
|
||||
|
||||
/* var file = fso.CreateTextFile("OBJLIST.TXT", true);
|
||||
file.Write("CREATE "+this.dstpath+'\\'+this.name+".a\r\n");
|
||||
for (; !fl.atEnd(); fl.moveNext()){file.Write("ADDMOD "+fl.item()+"\r\n");}
|
||||
file.Write("SAVE\r\t");
|
||||
file.Close();
|
||||
wsh.Run(this.gccpath+"\\ar.exe -M < OBJLIST.TXT", 0, true);*/
|
||||
|
||||
var ar = wsh.Exec(this.gccpath+"\\ar.exe -M")
|
||||
ar.StdIn.Write("CREATE "+this.dstpath+'\\'+this.name+".a\r\n");
|
||||
for (; !fl.atEnd(); fl.moveNext()){ar.StdIn.Write("ADDMOD "+fl.item()+"\r\n");}
|
||||
ar.StdIn.Write("SAVE\r\t");
|
||||
}
|
||||
this.rebuild = function(){
|
||||
this.clean();
|
||||
this.build();
|
||||
}
|
||||
this.isIgnored = function(value){
|
||||
for(var i=0; i<this.ignored.length; i++)
|
||||
if (this.ignored[i]==value||this.ignored[i]==getFileExt(value)) return true;
|
||||
return false;
|
||||
}
|
||||
this.nothing = function(){alert("Hello")}
|
||||
this.getFileList(this.srcpath);
|
||||
}
|
||||
|
||||
curpath=".\\string\\";
|
||||
compileasm("memmove");
|
||||
compileasm("memset");
|
||||
curpath=".\\mesys\\";
|
||||
compileasm("backgr");
|
||||
compileasm("button");
|
||||
compileasm("clock");
|
||||
compileasm("date");
|
||||
compileasm("debug_board");
|
||||
compileasm("delay");
|
||||
compileasm("dga");
|
||||
compileasm("draw_bar");
|
||||
compileasm("draw_image");
|
||||
compileasm("draw_window");
|
||||
compileasm("event");
|
||||
compileasm("exit");
|
||||
compileasm("file_58");
|
||||
compileasm("ipc");
|
||||
compileasm("irq");
|
||||
compileasm("keyboard");
|
||||
compileasm("line");
|
||||
compileasm("midi");
|
||||
compileasm("pci");
|
||||
compileasm("pixel");
|
||||
compileasm("process");
|
||||
compileasm("screen");
|
||||
compileasm("sound");
|
||||
compileasm("thread");
|
||||
compileasm("window_redraw");
|
||||
compileasm("write_text");
|
||||
curpath=".\\mem\\";
|
||||
compileasm("memalloc");
|
||||
curpath=".\\mesys\\";
|
||||
compilec("debug_board_");
|
||||
curpath=".\\string\\";
|
||||
compilec("memchr");
|
||||
compilec("memcmp");
|
||||
compilec("strcat");
|
||||
compilec("strchr");
|
||||
compilec("strcmp");
|
||||
compilec("strcoll");
|
||||
compilec("strcpy");
|
||||
compilec("strcspn");
|
||||
compilec("strdup");
|
||||
compilec("strerror");
|
||||
compilec("strlen");
|
||||
compilec("strnbrk");
|
||||
compilec("strncat");
|
||||
compilec("strncmp");
|
||||
compilec("strncpy");
|
||||
compilec("strrchr");
|
||||
compilec("strspn");
|
||||
compilec("strstr");
|
||||
compilec("strtok");
|
||||
compilec("strxfrm");
|
||||
curpath=".\\file\\";
|
||||
compilec("fclose");
|
||||
compilec("fopen");
|
||||
compilec("feof");
|
||||
compilec("fflush");
|
||||
compilec("fgetc");
|
||||
compilec("fgetpos");
|
||||
compilec("fsetpos");
|
||||
compilec("fputc");
|
||||
compilec("fread");
|
||||
compilec("fwrite");
|
||||
compilec("fseek");
|
||||
compilec("ftell");
|
||||
compilec("rewind");
|
||||
compilec("fprintf");
|
||||
compilec("fscanf");
|
||||
compilec("ungetc");
|
||||
curpath=".\\start\\";
|
||||
compileasm("start");
|
||||
//linking
|
||||
scriptline+="SAVE\r\n";
|
||||
linko();
|
||||
function compileasm(filename)
|
||||
{
|
||||
wsh.Run("fasm.exe "+quote(curpath+filename+".asm")+
|
||||
" "+quote(curpath+filename+".o"),0,true);
|
||||
addo(filename);
|
||||
}
|
||||
function compilec(filename)
|
||||
{
|
||||
wsh.Run(gccexe+"-nostdinc -I .\\include -DGNUC " + quote(curpath + filename + ".c")+
|
||||
" -o " + quote(curpath + filename + ".s"),0,true);
|
||||
wsh.Run(asexe+quote(curpath+filename+".s")+" -o "+quote(curpath+filename+".o"),0,true);
|
||||
wsh.Run(objcopyexe+" -O elf32-i386 --remove-leading-char "+quote(curpath+filename+".o"),0,true);
|
||||
addo(filename);
|
||||
}
|
||||
function addo(filename)
|
||||
{
|
||||
scriptline+="ADDMOD "+curpath+filename+".o\r\n";
|
||||
}
|
||||
function linko()
|
||||
{
|
||||
//fso.DeleteFile(".\\melibc.a");
|
||||
var file=fso.OpenTextFile("./script.txt",2,true);
|
||||
file.Write(scriptline);
|
||||
wsh.Run("cmd.exe /c ar.exe -M < ./script.txt",4,true);
|
||||
}
|
||||
function quote(name)
|
||||
{
|
||||
return "\""+name+"\"";
|
||||
}
|
||||
try{var confFile = WScript.Arguments(1);}catch(e){var confFile = "make.cfg";}
|
||||
try{var action = WScript.Arguments(0);}catch(e){var action = "build";}
|
||||
|
||||
var conf = new Project(confFile);
|
||||
conf[action]();
|
||||
|
||||
if(conf.autoclean && action != "clean"){conf["clean"]();}
|
||||
alert("Done");
|
Reference in New Issue
Block a user