Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - QNX C++ Project: adding a custom build step: (14 Items)
   
QNX C++ Project: adding a custom build step  
With our products under Windows built using Visual Studio VC 6.0 we create state machine code with a proprietary Domain 
Specific Language. The source file for a state machine written in this DSL is included in the Visual Studio project and 
has a custom build step setup for it which runs the translation program that converts that DSL source to corresponding C
++ source and header files.

For example: say I have a state machine defined in Machine.smd

I want to run a command: TranslateSMD -source Machine.smd

which generates a set of files like:
    MachineEvent.h
    MachineState.h
    Machine.h
    Machine.inc

along with some automated documentation. These generated files are then included in regular C++ source and header files.


I want to use this same mechanism with our QNX code for Neutrino 6.4. I need to add a similar custom build step for a 
non C/C++ source file to a QNX C++ project (in Momentix 4.5.0). Unfortunately I don't see anything in the documentation 
about how to do it. Can somebody point me to an example?

Thanks
Dan
Re: QNX C++ Project: adding a custom build step  
We have POST_BUILD step definition in IDE, but don't have PRE_BUILD. 
Just because it wasn't requested s far. There is work around. In 
common.mk file for your project add definition of PRE_BUILD macro at the 
same way we create POST_BUILD definition:
define PRE_BUILD
< your statements>
endef

You can also create post_build section through IDE, then rename it to 
PRE_BUILD in common.mk.


On 16/02/2009 3:45 PM, Dan McCormick wrote:
> With our products under Windows built using Visual Studio VC 6.0 we create state machine code with a proprietary 
Domain Specific Language. The source file for a state machine written in this DSL is included in the Visual Studio 
project and has a custom build step setup for it which runs the translation program that converts that DSL source to 
corresponding C++ source and header files.
>
> For example: say I have a state machine defined in Machine.smd
>
> I want to run a command: TranslateSMD -source Machine.smd
>
> which generates a set of files like:
>      MachineEvent.h
>      MachineState.h
>      Machine.h
>      Machine.inc
>
> along with some automated documentation. These generated files are then included in regular C++ source and header 
files.
>
> I want to use this same mechanism with our QNX code for Neutrino 6.4. I need to add a similar custom build step for a 
non C/C++ source file to a QNX C++ project (in Momentix 4.5.0). Unfortunately I don't see anything in the documentation 
about how to do it. Can somebody point me to an example?
>
> Thanks
> Dan
>
>
> _______________________________________________
> General
> http://community.qnx.com/sf/go/post22319
>
>    
Re: QNX C++ Project: adding a custom build step  
Thanks for the help but I'm having problems with the technique. The prebuild step does not execute consistently.

I will have short periods maybe as long as an hour when the build system will run it correctly when I build the project.
 Then something changes and it just ignores the PRE_BUILD section completely for long periods as long as several hours. 
Then something changes and again it executes the PRE_BUILD section for another short period.

I am at a loss of how to trouble shoot this. I find it very frustrating. Eclipse is proving to be an annoying hindrance 
rather than a productivity aid for me.

Dan
Re: QNX C++ Project: adding a custom build step  
PRE_BUILD is qnx recursive make concept and has nothing to do with eclipse.
I am not sure why it is not working but maybe you can add extra target in the makefile to do what you need instead?

Dan McCormick wrote:
> Thanks for the help but I'm having problems with the technique. The prebuild step does not execute consistently.
> 
> I will have short periods maybe as long as an hour when the build system will run it correctly when I build the 
project. Then something changes and it just ignores the PRE_BUILD section completely for long periods as long as several
 hours. Then something changes and again it executes the PRE_BUILD section for another short period.
> 
> I am at a loss of how to trouble shoot this. I find it very frustrating. Eclipse is proving to be an annoying 
hindrance rather than a productivity aid for me.
> 
> Dan
> 
> 
> _______________________________________________
> General
> http://community.qnx.com/sf/go/post22437
> 
Re: QNX C++ Project: adding a custom build step  
I place the following rule in common.mk
	
DeviceSM.h : DeviceSM.smd
	$(NRTTOOLPATH)/TranslateSMD -os QNX -v -wd "$(PROJECT_ROOT)" -source DeviceSM.smd

The target command is the same one that works those rare times that the PRE_BUILD method executes.

I make sure DeviceSM.h has been deleted.

I build the project. The rule never fires.

What do I need to do to have the build system run my command when DeviceSM.h is out of date relative to DeviceSM.smd?

Dan
Re: QNX C++ Project: adding a custom build step  
You need some other target to be dependent on DeviceSM.h otherwise it won't be running.

Dan McCormick wrote:
> I place the following rule in common.mk
> 	
> DeviceSM.h : DeviceSM.smd
> 	$(NRTTOOLPATH)/TranslateSMD -os QNX -v -wd "$(PROJECT_ROOT)" -source DeviceSM.smd
> 
> The target command is the same one that works those rare times that the PRE_BUILD method executes.
> 
> I make sure DeviceSM.h has been deleted.
> 
> I build the project. The rule never fires.
> 
> What do I need to do to have the build system run my command when DeviceSM.h is out of date relative to DeviceSM.smd?
> 
> Dan
> 
> 
> _______________________________________________
> General
> http://community.qnx.com/sf/go/post22446
> 
Re: QNX C++ Project: adding a custom build step  
When I add an additional target, so that I have...

Device.cpp : DeviceSM.h
	echo "dummy rule"

DeviceSM.h : DeviceSM.smd
	$(NRTTOOLPATH)/TranslateSMD -os QNX -v -wd "$(PROJECT_ROOT)" -source DeviceSM.smd

I get the following error:
	make[2]: *** No rule to make target `DeviceSM.smd', needed by `DeviceSM.h'.

Make doesn't need to do anything to make the target 'DeviceSM.smd' It's a self-contained text file that I provide. It is
 dependent upon nothing else.
Re: QNX C++ Project: adding a custom build step  
Is it in the same directory where make works?

Dan McCormick wrote:
> When I add an additional target, so that I have...
> 
> Device.cpp : DeviceSM.h
> 	echo "dummy rule"
> 
> DeviceSM.h : DeviceSM.smd
> 	$(NRTTOOLPATH)/TranslateSMD -os QNX -v -wd "$(PROJECT_ROOT)" -source DeviceSM.smd
> 
> I get the following error:
> 	make[2]: *** No rule to make target `DeviceSM.smd', needed by `DeviceSM.h'.
> 
> Make doesn't need to do anything to make the target 'DeviceSM.smd' It's a self-contained text file that I provide. It 
is dependent upon nothing else.
> 
> _______________________________________________
> General
> http://community.qnx.com/sf/go/post22457
> 
Re: QNX C++ Project: adding a custom build step  
It's in the same PROJECT_ROOT directory with the rest of the source.

The rules are apparently not invoked until make has recursed down to the directory PROJECT_ROOT/x86/o.

Changing the targets to this works.

Device.cpp : DeviceSM.h ;

DeviceSM.h : ../../DeviceSM.smd
	$(NRTTOOLPATH)/TranslateSMD -os QNX -v -wd "$(PROJECT_ROOT)" -source DeviceSM.smd

It seems a bit round-about but it appears to be working for now. Thanks for the help.

Dan
Re: QNX C++ Project: adding a custom build step  
I am not a makefile expert but this seems to work

SRCDIR=src

all: prepare $(SRCDIR)/file.h

prepare:
         -rm $(SRCDIR)/file.h

$(SRCDIR)/%.h: $(SRCDIR)/%.smd
         cat $<  > $@


Where you can replace "cat" with your command, $< is input, i.e. file.smd and $@ is output i.e. file.h

Dan McCormick wrote:
> When I add an additional target, so that I have...
> 
> Device.cpp : DeviceSM.h
> 	echo "dummy rule"
> 
> DeviceSM.h : DeviceSM.smd
> 	$(NRTTOOLPATH)/TranslateSMD -os QNX -v -wd "$(PROJECT_ROOT)" -source DeviceSM.smd
> 
> I get the following error:
> 	make[2]: *** No rule to make target `DeviceSM.smd', needed by `DeviceSM.h'.
> 
> Make doesn't need to do anything to make the target 'DeviceSM.smd' It's a self-contained text file that I provide. It 
is dependent upon nothing else.
> 
> _______________________________________________
> General
> http://community.qnx.com/sf/go/post22457
> 
Re: QNX C++ Project: adding a custom build step  
Hi Elena,

I was able to get this solution to work and work reliably by using the following...

SRCDIR=../..

all: prepare $(SRCDIR)/DeviceSM.h

prepare:
	 rm -f $(SRCDIR)/DeviceSM.h

$(SRCDIR)/DeviceSM.h: $(SRCDIR)/DeviceSM.smd
	$(NRTTOOLPATH)/TranslateSMD -os QNX -v -wd "$(PROJECT_ROOT)" -source DeviceSM.smd

I suppose the only part of this solution that might be brittle is setting SRCDIR to ../.. but as long as you folks don't
 alter the directory layout for projects it ought to be okay.

Thanks for your help.

Dan
Re: QNX C++ Project: adding a custom build step  
That's another story. BesidesPRE_BUILD, you have to add one more macro: 
EXTRA_DEPS+=DeviceSM.smd

On 18/02/2009 10:35 AM, Dan McCormick wrote:
> Thanks for the help but I'm having problems with the technique. The prebuild step does not execute consistently.
>
> I will have short periods maybe as long as an hour when the build system will run it correctly when I build the 
project. Then something changes and it just ignores the PRE_BUILD section completely for long periods as long as several
 hours. Then something changes and again it executes the PRE_BUILD section for another short period.
>
> I am at a loss of how to trouble shoot this. I find it very frustrating. Eclipse is proving to be an annoying 
hindrance rather than a productivity aid for me.
>
> Dan
>
>
> _______________________________________________
> General
> http://community.qnx.com/sf/go/post22437
>
>    
Re: QNX C++ Project: adding a custom build step  
Alex,

Afraid it's not working for me. I added the macro EXTRA_DEPS+=DeviceSM.smd

That resulted in following errors.

make[2]: *** [devu_xmca.o] Error 1
make[2]: *** No rule to make target `DeviceSM.smd', needed by `C:/users/dan/OPC_Code/QNX/devu_xmca/x86/o/devu_xmca'.
make[2]: Target `all' not remade because of errors.
make[2]: Leaving directory `C:/users/dan/OPC_Code/QNX/devu_xmca/x86/o'

Tried a variant to account for being two levels down from the actual project root (EXTRA_DEPS+=../../DeviceSM.smd). No 
errors generated about the target 'DeviceSM.smd' but the build process again ignores the entire PRE_BUILD step.

Dan
Re: QNX C++ Project: adding a custom build step  
It is path problems again. If you add full path just to prove this point it would probably work.

I suggest use target dependency, since you made it work already.


Dan McCormick wrote:
> Alex,
> 
> Afraid it's not working for me. I added the macro EXTRA_DEPS+=DeviceSM.smd
> 
> That resulted in following errors.
> 
> make[2]: *** [devu_xmca.o] Error 1
> make[2]: *** No rule to make target `DeviceSM.smd', needed by `C:/users/dan/OPC_Code/QNX/devu_xmca/x86/o/devu_xmca'.
> make[2]: Target `all' not remade because of errors.
> make[2]: Leaving directory `C:/users/dan/OPC_Code/QNX/devu_xmca/x86/o'
> 
> Tried a variant to account for being two levels down from the actual project root (EXTRA_DEPS+=../../DeviceSM.smd). No
 errors generated about the target 'DeviceSM.smd' but the build process again ignores the entire PRE_BUILD step.
> 
> Dan
> 
> _______________________________________________
> General
> http://community.qnx.com/sf/go/post22473
>