Difference between revisions of "Fiji/Build System"

m (Fake moved to Fiji Build System: The old title was not visually pleasing to some people)
(Reword "Fiji mAKE" to "Fiji's build system")
Line 1: Line 1:
 
== Introduction ==
 
== Introduction ==
  
Fake is Fiji's build system (''Fiji's mAKE'').  Its goal is to make it extremely simple to define the tasks that are needed for Fiji.
+
The goal of Fiji's build system is to make it extremely simple to define the tasks that are needed for Fiji.
  
Fake finds its ''targets'' in a file called ''Fakefile''.  An example ''Fakefile'' looks like this:
+
The system finds its ''targets'' in a file called ''Fakefile'' (''Fiji's mAKE FILE'').  The contents of that file look like this:
  
 
  all <- example.jar another-example.jar
 
  all <- example.jar another-example.jar
Line 19: Line 19:
 
  target <- prerequisites
 
  target <- prerequisites
  
If a prerequisite is also the target of another rule, Fake builds that target before building the current one.
+
If a prerequisite is also the target of another rule, the program builds that target before building the current one.
  
== Calling Fake ==
+
== Calling Fiji's build system ==
  
If you have a working Fiji launcher, you can call Fake like this:
+
If you have a working Fiji launcher, you can call the build system like this:
  
  ./fiji --fake
+
  ./fiji --build
  
If your Fiji launcher does not work, but you have a working Java, call Fake like this:
+
If your Fiji launcher does not work, but you have a working Java, call it like this:
  
 
  java -jar precompiled/fake.jar
 
  java -jar precompiled/fake.jar
  
You can ask Fake to build only specific targets by passing them as parameters:
+
You can ask the program to build only specific targets by passing them as parameters:
  
  ./fiji --fake ij.jar
+
  ./fiji --build ij.jar
  
 
Further, all variable definitions passed as parameters will override what is found in the Fakefile:
 
Further, all variable definitions passed as parameters will override what is found in the Fakefile:
  
  ./fiji --fake debug=true fake.jar
+
  ./fiji --build debug=true fake.jar
  
 
== Target types ==
 
== Target types ==
Line 47: Line 47:
  
 
;''.jar'' targets:
 
;''.jar'' targets:
:If the target name ends with ''.jar'', a .jar is made.  If the last prerequisite also ends in ''.jar'', Fake will copy that file instead of trying to compile ''.java'' files.
+
:If the target name ends with ''.jar'', a .jar is made.  If the last prerequisite also ends in ''.jar'', the build system will copy that file instead of trying to compile ''.java'' files.
  
:Fake is actually quite clever when it comes to putting the compiled classes into the ''.jar'' files; it figures out in which package the class lives, and uses the corresponding path.
+
:The system is actually quite clever when it comes to putting the compiled classes into the ''.jar'' files; it figures out in which package the class lives, and uses the corresponding path.
  
 
;''.class'' targets:
 
;''.class'' targets:
Line 57: Line 57:
 
:If the last prerequisite ends in ''.cxx'' or ''.c'', the GNU C compiler is called to compile the prerequisites.
 
:If the last prerequisite ends in ''.cxx'' or ''.c'', the GNU C compiler is called to compile the prerequisites.
  
;"SubFake" targets:
+
;"SubBuild" targets:
:If the last prerequisite specifies a directory, Fake looks for a ''Fakefile'' or a ''Makefile'' there.  According to what was found, Fake or ''make'' is called, and the target is copied over to the given destination.
+
:If the last prerequisite specifies a directory, the build system looks for a ''Fakefile'' or a ''Makefile'' there.  According to what was found, Fiji's build system or ''make'' is called, and the target is copied over to the given destination.
  
 
;Special targets:
 
;Special targets:

Revision as of 08:48, 18 December 2008

Introduction

The goal of Fiji's build system is to make it extremely simple to define the tasks that are needed for Fiji.

The system finds its targets in a file called Fakefile (Fiji's mAKE FILE). The contents of that file look like this:

all <- example.jar another-example.jar

example.jar <- example/**/*.java README LICENSE

another-example.jar <- SomeClass.java

This file defines three targets: the default target called 'all', and two targets building .jar files. The operation is defined implicitly by the name of the target.

Nomenclature

The Fakefile contains rules for targets that are defined in the following form:

target <- prerequisites

If a prerequisite is also the target of another rule, the program builds that target before building the current one.

Calling Fiji's build system

If you have a working Fiji launcher, you can call the build system like this:

./fiji --build

If your Fiji launcher does not work, but you have a working Java, call it like this:

java -jar precompiled/fake.jar

You can ask the program to build only specific targets by passing them as parameters:

./fiji --build ij.jar

Further, all variable definitions passed as parameters will override what is found in the Fakefile:

./fiji --build debug=true fake.jar

Target types

The following target types are available:

The all target
The first target in the Fakefile is always the default target. It lists all subtargets that are to be made by default.
.jar targets
If the target name ends with .jar, a .jar is made. If the last prerequisite also ends in .jar, the build system will copy that file instead of trying to compile .java files.
The system is actually quite clever when it comes to putting the compiled classes into the .jar files; it figures out in which package the class lives, and uses the corresponding path.
.class targets
Targets whose name end in .class compile a single .java file (the last prerequisite is used to define that), and copies the resulting .class file (and the other generated classes that are used by this class) to the given destination.
.cxx and '.c' targets
If the last prerequisite ends in .cxx or .c, the GNU C compiler is called to compile the prerequisites.
"SubBuild" targets
If the last prerequisite specifies a directory, the build system looks for a Fakefile or a Makefile there. According to what was found, Fiji's build system or make is called, and the target is copied over to the given destination.
Special targets
Some targets are predefined, but can be overridden in the Fakefile. These include clean, show-vars and others.

Special targets

clean
Remove all generated targets. This target is not well tested. Use with care.
show-vars
Show all defined variables
show-rules
Show all rules (with expanded variables)
check
Instead of building the targets, this target just shows which targets are not up to date and would be built.

Variables

You can define variables in the usual way:

ONE=1

Variables can be referenced in all parts of a rule. Variables can be overridden per-target:

ONE(ij.jar)=2
ij.jar <- bla$ONE.java

Predefined variables

TODO

Other features

Precompiled targets

TODO