forked from KolibriOS/kolibrios
Converted JS building script to GNU makefile ;)
git-svn-id: svn://kolibrios.org@222 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
7f38fb4c37
commit
b648a77792
@ -1,2 +0,0 @@
|
|||||||
cscript compile.js build
|
|
||||||
pause
|
|
@ -1,2 +1,2 @@
|
|||||||
cscript cscript compile.js clean
|
mingw32-make clean
|
||||||
pause
|
pause
|
@ -1,139 +0,0 @@
|
|||||||
ForReading = 1
|
|
||||||
ForWriting = 2
|
|
||||||
ForAppending = 8
|
|
||||||
var fso = new ActiveXObject("Scripting.FileSystemObject");
|
|
||||||
var wsh = new ActiveXObject("WScript.Shell");
|
|
||||||
_DEBUG = true;
|
|
||||||
function _debug(mes)
|
|
||||||
{
|
|
||||||
if(_DEBUG != true) return mes;
|
|
||||||
try{var file = fso.OpenTextFile("debug_info.txt", ForAppending);}
|
|
||||||
catch(e){var file = fso.CreateTextFile("debug_info.txt", true);}
|
|
||||||
file.Write(mes);
|
|
||||||
file.close();
|
|
||||||
return mes;
|
|
||||||
}
|
|
||||||
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(_debug('"'+this.fasm+'" "'+filename+'" "'+objname+'"\n'),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 + '"\n';
|
|
||||||
wsh.Run(_debug("cmd.exe /c "+command), 0, true);
|
|
||||||
}
|
|
||||||
command = '"'+this.gccpath +"\\"+ this.asexe +'" "'+ asmname +'" -o "'+ objname +'"\n';
|
|
||||||
wsh.Run(_debug("cmd.exe /c "+command), 0, true);
|
|
||||||
command = '"'+this.gccpath +"\\"+ this.objcopyexe +'" -O elf32-i386 --remove-leading-char "'+ objname +'"\n';
|
|
||||||
wsh.Run(_debug("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(_debug(this.gccpath+"\\ar.exe -M\n"))
|
|
||||||
ar.StdIn.Write(_debug("CREATE "+this.dstpath+'\\'+this.name+".a\r\n"));
|
|
||||||
for (; !fl.atEnd(); fl.moveNext()){ar.StdIn.Write(_debug("ADDMOD "+fl.item()+"\r\n"));}
|
|
||||||
ar.StdIn.Write(_debug("SAVE\r\n"));
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
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");
|
|
@ -1,12 +0,0 @@
|
|||||||
version: "0.0.1",
|
|
||||||
name: "melibc",
|
|
||||||
autoclean: false,
|
|
||||||
ignored: ["start"],
|
|
||||||
srcpath: ".",
|
|
||||||
dstpath: "..",
|
|
||||||
include: "include",
|
|
||||||
gccpath: "D:\\proganie\\MinGWStudio\\MinGW\\bin",
|
|
||||||
gccexe: "..\\libexec\\gcc\\mingw32\\3.4.2\\cc1.exe",
|
|
||||||
asexe: "as.exe",
|
|
||||||
fasm: "D:\\proganie\\FASM\\FASM.EXE",
|
|
||||||
objcopyexe: "objcopy.exe"
|
|
2
programs/develop/metcc/trunk/libc/make.cmd
Normal file
2
programs/develop/metcc/trunk/libc/make.cmd
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
mingw32-make
|
||||||
|
pause
|
23
programs/develop/metcc/trunk/libc/makefile
Normal file
23
programs/develop/metcc/trunk/libc/makefile
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
INCLUDE = include
|
||||||
|
LIBNAME = melibc.a
|
||||||
|
CC = gcc
|
||||||
|
CFLAGS = -I$(INCLUDE) -nostdinc -DGNUC
|
||||||
|
DIRS := file mesys string mem
|
||||||
|
|
||||||
|
##############################################################
|
||||||
|
#files := $(foreach dir,$(DIRS),$(dir)/$(wildcard $(dir)/*))
|
||||||
|
asmfiles := $(foreach dir,$(DIRS),$(patsubst %.asm, %.o, $(wildcard $(dir)/*.asm)))
|
||||||
|
cfiles := $(foreach dir,$(DIRS),$(patsubst %.c, %.o, $(wildcard $(dir)/*.c)))
|
||||||
|
|
||||||
|
.PHONY: clean all
|
||||||
|
|
||||||
|
all: $(cfiles) $(asmfiles)
|
||||||
|
ar -ru $(LIBNAME) $^
|
||||||
|
|
||||||
|
$(cfiles): $(INCLUDE)/*.h
|
||||||
|
|
||||||
|
$(asmfiles):
|
||||||
|
fasm $*.asm $*.o
|
||||||
|
|
||||||
|
clean:
|
||||||
|
del /F /Q $(subst /,\,$(cfiles)) $(subst /,\,$(asmfiles))
|
@ -1,4 +1,12 @@
|
|||||||
The main file of metcc is "tcc.c". It certainly can be compiled by MinGW Studio.
|
The main file of metcc is "tcc.c". It certainly can be compiled by MinGW Studio.
|
||||||
In order to compile MenuetOS program you must have start.o, metcc.exe in the same
|
In order to compile MenuetOS program you must have start.o, metcc.exe in the same
|
||||||
directory. The command line should be of type "metcc.exe program.c melibc.a -oprogram".
|
directory. The command line should be of type "metcc.exe program.c melibc.a -oprogram".
|
||||||
In order to compile "melibc.a" you should configure paths is compile.js and run it.
|
In order to compile "melibc.a" you should configure paths is compile.js and run it.
|
||||||
|
------------------------------------------------------------------------------------
|
||||||
|
Äëÿ êîìïèëÿöèè melibc íåîáõîäèìî çàïóñòèòü ñêðèïò libc/make.cmd
|
||||||
|
ïî óìîë÷àíèþ ñ÷èòàåòñÿ ÷òî â ïåðåìåííîé îêðóæåíèÿ PATH ó âàñ óêàçàí ïóòü ê ïàêåòó mingw32
|
||||||
|
è ê àññåìáëåðó fasm.
|
||||||
|
------------------------------------------------------------------------------------
|
||||||
|
Äëÿ áîëåå ïîäðîáíûõ èíñòðóêöèé îáðàùàòåñü íà ôîðóì â òåìó
|
||||||
|
http://meos.sysbin.com/viewtopic.php?t=565&highlight=metcc
|
||||||
|
For more help go to link above
|
Loading…
Reference in New Issue
Block a user