A new build system?
Posted: Thu Jun 18, 2009 11:00 am
Well, recently I've had some "fun" trying to get my makefiles to work with both GNU make and BSD make(which there are actually many versions for) and I just got generally fed up with the make syntax.
So, I am wanting to make a new build system, even if it's so I can compile my own stuff easy(if it gets that far lol)
My requirements are this: No dependencies(only LibC), Made in either C or C++(probably C), lightweight: as in, I don't have to have configuration files everywhere(either on my system or in the project directory), Powerful enough to handle big projects easily, Powerful enough that it won't one day have a million extensions making things incompatible(as in, powerful enough that extensions aren't needed in most cases).
The closest thing I've seen to such a system is Cmake, but I consider it to be a little messy and plus it has dependencies. You must use make to use the makefiles it generates and such.
One big problem with make(I am referring to POSIX make as it is the standard GNU and BSD both share) is it's difficult(if not impossible) to just straight compile all files of a certain type in one directory to another directory. such as src/*.c to obj/*.o Cause no one actually wants to manually add to a makefile each time you make a new source file.
Well, I came up with this syntax of how things can work. I know it isn't quite consistent yet and such, but tell me what you think. (Also, I'm aiming for easy to parse and one pass/interpreted line-by-line)
Note, that there will be an optional common actions include for things like compile() and link()
And I don't wish for it to be so powerful you could make an application for, but I would like something possibly dynamic. Also, I'm not sure I want to support anything but string variables.
edit:
My main goal with this though is to make it so things are much easier to maintain and much easier to understand to an outsider.(as in, anyone who knows C, Java, C++, etc have an idea of what is going on in this)
I want to take the black magic out of build systems.
So, I am wanting to make a new build system, even if it's so I can compile my own stuff easy(if it gets that far lol)
My requirements are this: No dependencies(only LibC), Made in either C or C++(probably C), lightweight: as in, I don't have to have configuration files everywhere(either on my system or in the project directory), Powerful enough to handle big projects easily, Powerful enough that it won't one day have a million extensions making things incompatible(as in, powerful enough that extensions aren't needed in most cases).
The closest thing I've seen to such a system is Cmake, but I consider it to be a little messy and plus it has dependencies. You must use make to use the makefiles it generates and such.
One big problem with make(I am referring to POSIX make as it is the standard GNU and BSD both share) is it's difficult(if not impossible) to just straight compile all files of a certain type in one directory to another directory. such as src/*.c to obj/*.o Cause no one actually wants to manually add to a makefile each time you make a new source file.
Well, I came up with this syntax of how things can work. I know it isn't quite consistent yet and such, but tell me what you think. (Also, I'm aiming for easy to parse and one pass/interpreted line-by-line)
Code: Select all
compile src/test1.c to obj/test1.o if out of date:
compile($src,$trg){
exec([$CC $CFLAGS -c $src -o $trg]);
};
default(){
if older("obj/test1.o","src/test1.c") { //if test1.o is older than test1.c
compile("src/test1.c","obj/test1.o");
} else {
exec("echo \"Target is up to date\" ");
}
}
..continuation to also link obj/test1.o to test1
link($objs,$trg){
exec([$CC $LDFLAGS -o $trg $objs]);
}
default(){
string $objs;
if older("obj/test1.o","src/test1.c") { //if test1.o is older than test1.c
compile("src/test1.c","obj/test1.o");
} else {
exec("echo \"Target is up to date\" ");
}
$objs=concat($objs,"obj/test1.o ");
$objs=concat($objs,"objs/other_objects.o ");
link($objs,"bin/test1");
}
complicated example to compile all .c files in src/ to .o files in objs/
and then link them all(only if out of date though) (using compile and link from before)
for example, it contains files: main.c test.c foo.c no.f
default(){
string $cfiles;
string $objfiles;
cd("src/");
$cfiles=file_glob("*.c"); //this is so we get main.c not src/main.c
cd("..");
for_each($cfiles," ") = $this_file{ //for each element in cfiles seperated by " ". Put current element in this_file
string $this_obj;
$this_obj=glob_replace($this_file,"*.c","*.o"); //replace main.c with main.o, *.c with *.o
$this_obj=concat("objs/",$this_obj); //make it so it's objs/main.o
$this_file=concat("src/",$this_file); //make it so it's src/main.c
if(older($this_obj,$this_file)){
compile($this_file,$this_obj);
}
$objfiles=concat($objfiles,$this_obj);
}
link($objfiles,"bin/a.out");
}
Note, that there will be an optional common actions include for things like compile() and link()
And I don't wish for it to be so powerful you could make an application for, but I would like something possibly dynamic. Also, I'm not sure I want to support anything but string variables.
edit:
My main goal with this though is to make it so things are much easier to maintain and much easier to understand to an outsider.(as in, anyone who knows C, Java, C++, etc have an idea of what is going on in this)
I want to take the black magic out of build systems.