Lets do the worlds favorite application, a “HelloWorld” program.
In this tutorial you will learn the priciples of the Astade build system. You will not see anything of Astades UML features. It's just the very beginning
First rightklick the folder called “tutorials” and select “add component”.
Than open the feature dialog of that new createt component and call it “Hallo1” (don't forget a description e.g.: “my very first Astade program”). After that your model should look like that:
Astade has a global configuration, which is called “Active component”. This means, the component, where you are actually working on. Because we are actually working at “Hello1” we should rightclick our “Hello1” component and select “set as active component”. The component will get a green dot, to visualize, that this component is the “active” one.
For this example we place all our code (one file ) into the folder “manual”, That is, because we code it manual, without using any of the Astade coders. Actually this is common for the main.cpp, the part that contains the main(). the “main()” is a plain “C” function and therfore cannot be generated by the Astade coders.
So rightclick the folder “manual” of your component “Hello1” and select “make empty main.cpp”. You should end here:
if you doubbleclick the file “main.cpp” you should get something like this in your editor:
int main(int argc, char** argv) { //Write an implementation for the main function here return 0; }
Change it to:
#include <stdio.h> int main(int argc, char** argv) { printf("Hello world\n"); return 0; }
And we are fine
Next thing we need is called a “Configuration”. You can have as much configurations as you like. They are located inside the component folder. Each configuration comes with its own makefile and normally uses different compile options or even different compilers or are for different target archetectures. Examples for possible configurations are:
For our little example we create a configuration we simply call “release”. So rightclick on the “Hello1” component and select “add configuration”. Give the configuration the name “release”. Than rightclick again and select “copy Makefile”.
Select any Makefile from the template directory (we will change it anyway). You should get this:
Open the Makefile with your editor and change the content to this:
# include path INCLUDE := -I../manual # compiler settings CXXFLAGS := $(INCLUDE) -Wall -O2 # find sources and headers SOURCES := $(wildcard ../auto/*.cpp ../manual/*.cpp) HEADERS := $(wildcard ../auto/*.h ../manual/*.h) # objects go into current directory OBJS := $(notdir $(SOURCES:.cpp=.o)) %.o: ../auto/%.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< %.o: ../manual/%.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< build: $(TARGET) $(TARGET): .depend $(OBJS) $(CXX) -o $@ $(OBJS) $(LDFLAGS) .depend: Makefile $(SOURCES) $(HEADERS) $(CXX) -MM $(CXXFLAGS) $(SOURCES) >$@ -include .depend
TIP There is a <TAB> character in the first position of line 15, 18, 23, 26. This is important! Be careful, that your editor is not changing this into blanks! |
After you changed the makefile, you should be able to build your “hello world” component the first time. Rightlick the configuration. Inside the context menu you will find “build”, which is the target we defined inside the makefile. Select “build” and Astade should open the make window and show you the result of the make process:
The product of the make process can be found inside the configuration subfolder. Open the folder “release”. You can see the file main.o (the opject file) ande the file Hello1 (our program).
You can copy it to somewhere using drag and drop and try to run it. But the better way to do this, is to define some additional make targets for that purpose.
Now add three additional make targets into the makefile (clean, rebuild and run). This targets are reachable in the configuration context menu. You can run our Hello1 now, by just selecting “run” in the configuration context menu.
build: $(TARGET) clean: rm -f $(TARGET) *.o .depend rebuild: clean build run: ./$(TARGET)