Subversion Repositories Kolibri OS

Rev

Rev 215 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 215 Rev 216
Line 1... Line 1...
1
ForReading = 1
1
ForReading = 1
2
ForWriting = 2 
2
ForWriting = 2 
3
ForAppending = 8 
3
ForAppending = 8 
4
var fso = new ActiveXObject("Scripting.FileSystemObject");
4
var fso = new ActiveXObject("Scripting.FileSystemObject");
5
var wsh = new ActiveXObject("WScript.Shell");
5
var wsh = new ActiveXObject("WScript.Shell");
-
 
6
_DEBUG = true;
-
 
7
function _debug(mes)
-
 
8
{
-
 
9
	if(_DEBUG != true) return mes;
-
 
10
	try{var file = fso.OpenTextFile("debug_info.txt", ForAppending);}
-
 
11
	catch(e){var file = fso.CreateTextFile("debug_info.txt", true);}
-
 
12
	file.Write(mes);
-
 
13
	file.close();
-
 
14
	return mes;
-
 
15
}
6
function alert(mes){WScript.Echo(mes);return mes}
16
function alert(mes){WScript.Echo(mes);return mes}
-
 
17
 
7
function debug(obj){for(key in obj)alert('['+key+']="'+obj[key]+'"')}
18
function debug(obj){for(key in obj)alert('['+key+']="'+obj[key]+'"')}
8
function getFileContent(filename){
19
function getFileContent(filename){
9
	var file = fso.OpenTextFile(filename, ForReading);
20
	var file = fso.OpenTextFile(filename, ForReading);
10
	var content = file.ReadAll();
21
	var content = file.ReadAll();
11
	file.close();
22
	file.close();
Line 59... Line 70...
59
	var objList = [];
70
	var objList = [];
60
	this.compile_asm = function(filename){
71
	this.compile_asm = function(filename){
61
		var objname = filename.replace(/.\w{1,3}$/,".o");
72
		var objname = filename.replace(/.\w{1,3}$/,".o");
62
 		objList.push(objname);
73
 		objList.push(objname);
63
		if(fso.FileExists(objname)) return;
74
		if(fso.FileExists(objname)) return;
64
		wsh.Run(this.fasm+' "'+filename+'" "'+objname+'"',0,true);
75
		wsh.Run(_debug('"'+this.fasm+'" "'+filename+'" "'+objname+'"\n'),0,true);
65
	}
76
	}
66
	this.compile_c = function(filename){
77
	this.compile_c = function(filename){
67
		var objname = filename.replace(/.\w{1,3}$/,".o");
78
		var objname = filename.replace(/.\w{1,3}$/,".o");
68
 		objList.push(objname);
79
 		objList.push(objname);
69
		if(fso.FileExists(objname)) return;
80
		if(fso.FileExists(objname)) return;
70
		var asmname = filename.replace(/.\w{1,3}$/,".s");
81
		var asmname = filename.replace(/.\w{1,3}$/,".s");
71
		var command = "";
82
		var command = "";
72
		if(!fso.FileExists(asmname)){
83
		if(!fso.FileExists(asmname)){
73
			command = this.gccpath +"\\"+ this.gccexe + " -nostdinc";
84
			command = '"'+this.gccpath +"\\"+ this.gccexe + "\" -nostdinc";
74
			if(this.include) command += " -I .\\include";
85
			if(this.include) command += " -I .\\include";
75
			command +=" -DGNUC" +' "'+filename + '" -o "' + asmname + '"';
86
			command +=" -DGNUC" +' "'+filename + '" -o "' + asmname + '"\n';
76
			wsh.Run("cmd.exe /c "+command, 0, true);
87
			wsh.Run(_debug("cmd.exe /c "+command), 0, true);
77
		}
88
		}
78
		command = this.gccpath +"\\"+ this.asexe +' "'+ asmname +'" -o "'+ objname +'"';
89
		command = '"'+this.gccpath +"\\"+ this.asexe +'" "'+ asmname +'" -o "'+ objname +'"\n';
79
		wsh.Run("cmd.exe /c "+command, 0, true);
90
		wsh.Run(_debug("cmd.exe /c "+command), 0, true);
80
		command = this.gccpath +"\\"+ this.objcopyexe +' -O elf32-i386 --remove-leading-char "'+ objname +'"';
91
		command = '"'+this.gccpath +"\\"+ this.objcopyexe +'" -O elf32-i386 --remove-leading-char "'+ objname +'"\n';
81
		wsh.Run("cmd.exe /c "+command, 0, true);
92
		wsh.Run(_debug("cmd.exe /c "+command), 0, true);
82
	}
93
	}
83
	this.build = function(){
94
	this.build = function(){
84
		var fl = new Enumerator(this.files);
95
		var fl = new Enumerator(this.files);
85
		for (; !fl.atEnd(); fl.moveNext()){
96
		for (; !fl.atEnd(); fl.moveNext()){
86
			var file = fl.item()
97
			var file = fl.item()
Line 98... Line 109...
98
		for (; !fl.atEnd(); fl.moveNext()){file.Write("ADDMOD "+fl.item()+"\r\n");}
109
		for (; !fl.atEnd(); fl.moveNext()){file.Write("ADDMOD "+fl.item()+"\r\n");}
99
		file.Write("SAVE\r\t");
110
		file.Write("SAVE\r\t");
100
		file.Close();
111
		file.Close();
101
		wsh.Run(this.gccpath+"\\ar.exe -M < OBJLIST.TXT", 0, true);*/
112
		wsh.Run(this.gccpath+"\\ar.exe -M < OBJLIST.TXT", 0, true);*/
Line 102... Line 113...
102
		
113
		
103
		var ar = wsh.Exec(this.gccpath+"\\ar.exe -M")
114
		var ar = wsh.Exec(_debug(this.gccpath+"\\ar.exe -M\n"))
104
		ar.StdIn.Write("CREATE "+this.dstpath+'\\'+this.name+".a\r\n");
115
		ar.StdIn.Write(_debug("CREATE "+this.dstpath+'\\'+this.name+".a\r\n"));
105
		for (; !fl.atEnd(); fl.moveNext()){ar.StdIn.Write("ADDMOD "+fl.item()+"\r\n");}
116
		for (; !fl.atEnd(); fl.moveNext()){ar.StdIn.Write(_debug("ADDMOD "+fl.item()+"\r\n"));}
106
		ar.StdIn.Write("SAVE\r\t");
117
		ar.StdIn.Write(_debug("SAVE\r\n"));
107
	}
118
	}
108
	this.rebuild = function(){
119
	this.rebuild = function(){
109
		this.clean();
120
		this.clean();
110
		this.build();
121
		this.build();