A very simple hello world with astade

Add the component

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 8-O

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.

Add the code

For this example we place all our code (one file LOL) 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:

Edit the code

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 ;-)

The Configuration

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:

  • Linux release
  • Linux debug
  • ARM processor (statically linked)
  • Windows (useing DLL)

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:

The Makefile

Open the Makefile with your editor and change the content to this:

# include path
INCLUDE	:= -I../manual
# compiler settings
# 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)
-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.

Additional make targets

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)
	rm -f $(TARGET) *.o .depend
rebuild:	clean build

tutorial/helloworld.txt · Last modified: 2015/05/13 16:38 by thomas
GNU Free Documentation License 1.3
Powered by PHP Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0 Valid HTML5