Usage
Create an Ada project
Now create a new Rhapsody project
Caution
To create an Ada model, Rhapsody.ini file must be updated with default language equals to ada, before opening Eclipse.
Select menu File/New/Other…:
Choose Rhapsody Project:
Set the name of your project and press “Finish”:
You can now create your Rhapsody model as usual.
Generate Rhapsody project
When you will need to generate the code, select menu
code generator/regenerate/<your config>
A popup window will ask you to connect the configuration to an IDE project. Click yes
Select the Ada project which already exists or create a new one:
Ada project contains 2 Files which must be updated by code generator
- <Ada_project_name>.gpr
- Makefile
- <Ada_project_name>.gpr
This file describes project configuration. In order to build the Rhapsody project, the Ada project must be updated with generated folders:
<Ada_project_name>.gpr :
project My_Ada_Project is for Main use ("MainDefaultComponent.adb"); for Object_Dir use "objs"; for Source_Dirs use ("D:/WORK/Eclipse RiA/eclipse/workspace/my_ada_project", "D:/WORK/Eclipse RiA/eclipse/workspace/my_ada_project/default"); package Compiler is for Default_Switches ("ada") use ("-g", "-gnato", "-gnatwa", "-fstack-check"); end Compiler; package Builder is for Default_Switches ("ada") use ("-g", "-gnatQ"); end Builder; package Ide is for Compiler_Command ("ada") use "gnatmake"; end Ide; end My_Ada_Project;
The <Ada_project_name>.gpr file is updated with generated folders.
Makefile
The Ada project make file can be also updated with the Rhapsody command .
The build: label of this file calls GNAT builder. It can be replaced by our usual build command:
# Build executables for all mains defined by the project. build: # $(GNATMAKE) -P "$(GPRPATH)" "C:\Program Files\IBM\Rational\Rhapsody\7.5.1\share\etc\Executer.exe" "\"C:\Program Files\IBM\Rational\Rhapsody\7.5.1\share\etc\GnatMake.bat\" DefaultComponent.bat
In order to update those 2 files, code generator can be updated with custom makefiles
We should add new properties to generate Makefile and <Ada_project_name>.gpr files.
The new properties should be added in <Rhp_install_dir>/Share/properties/siteAda.prp file. Here is an example of the definition of new properties:
Subject Ada_CG Metaclass Configuration Property Environment Enum"GNAT,OBJECTADA,RAVEN_PPC,SPARK,GNATVxWorks,Test_Env,GNAT_Eclipse" "GNAT" end Metaclass GNAT_Eclipse Property AdditionalReservedWords String "" Property AdaPathContent MultiLine "<\"\\n\"><\",\"><\"\\.\"><\" $AdaCGIDEWorkspace/$AdaCGIDEProject\"><\"\\\\\"><\"/\"><\",\"><\"\\\", \\\"\">" Property BuildCommandSet Enum"Debug,Release" "Debug" Property CompileCommand MultiLine "" Property CompileSwitches MultiLine "" Property CPPCompileDebug String "" Property CPPCompileRelease String "" Property DependencyRule String "" Property EntryPoint String "" Property ErrorMessageTokensFormat String "ToTalNumberOfTokens=2,FileTokenPosition=1,LineTokenPosition=2" Property ExeExtension String ".exe" Property FileDependencies String "" Property ImpExtension String ".adb" Property Include String "" Property InvokeExecutable String "\"$executable\"" Property InvokeMake String "\"$OMROOT/etc/Executer.exe\" \"\\\"$OMROOT\\etc\\GnatMake.bat\\\" $makefile $maketarget\"" Property IsFileNameShort Bool"False" Property LibExtension String ".a" Property LinkDebug String "" Property LinkRelease String "" Property LinkSwitches String "" Property MakeExtension String ".bat" Property MakeFileContent MultiLine "" Property MakeFileNameForExe1 String "gnat.adc" Property MakeFileContentForExe1 MultiLine "$AdaCGGnatAdc" Property MakeFileNameForExe2 String "$ComponentName$MakeExtension" Property MakeFileContentForExe2 MultiLine "$AdaCGGnatMakefile" Property MakeFileNameForExe3 String "Makefile" Property MakeFileContentForExe3 MultiLine "# You may edit this makefile as long as you keep these original # target names defined. # Not intended for manual invocation. # Invoked if automatic builds are enabled. # Analyzes only on those sources that have changed. # Does not build executables. autobuild: $(GNATMAKE) -gnatc -c -k -P \"$(GPRPATH)\" # Clean the root project of all build products. clean: $(GNATCLEAN) -P \"$(GPRPATH)\" # Clean root project and all imported projects too. clean_tree: $(GNATCLEAN) -P \"$(GPRPATH)\" –r # Check *all* sources for errors, even those not changed. # Does not build executables. analyze: $(GNATMAKE) -f -gnatc -c -k -P \"$(GPRPATH)\" # Build executables for all mains defined by the project. build: # $(GNATMAKE) -P \"$(GPRPATH)\" $OMROOT\\etc\\Executer.exe \"\\\"$AdaCGOMROOTSingleSlashes\\etc\\GnatMake.bat\\\" $ComponentName$MakeExtension # Clean, then build executables for all mains defined by the project. rebuild: clean build " Property MakeFileNameForExe4 String "ada_project.gpr" Property MakeFileContentForExe4 MultiLine "project $AdaCGIDEProject is for Main use (\"Main$ComponentName.adb\"); package Compiler is for Default_Switches (\"ada\") use (\"-g\",\"-gnato\", \"-gnatwa\", \"-fstack-check\"); end Compiler; package Builder is for Default_Switches (\"ada\") use (\"-g\",\"-gnatQ\"); end Builder; package Ide is for Compiler_Command (\"ada\") use \"gnatmake\"; end Ide; for Source_Dirs use (\"$AdaCGAdaPath\"); end $AdaCGIDEProject; " Property MakeFileNameForLib String "$ComponentName$MakeExtension" Property MakeFileContentForLib MultiLine "$AdaCGGnatMakefile" Property OSFileSystemCaseSensitive Bool "False" Property ObjCleanCommand String "" Property ObjExtension String ".o" Property ObjectName String "" Property ObjectsDirectory String "" Property ParseErrorMessage String "([^:]+)[:]([0-9]+)[:]" Property QuoteOMROOT Bool "True" Property RemoteHost String "" Property SpecExtension String ".ads" Property UseNonZeroStdInputHandle Bool "True" Property UseRemoteHost Bool "False" end end
IDE project name and IDE workspace location can be read from tags on configuration level:
- IDEName : Eclipse
- IDEProject : Ada project name
- IDEWorkspace : workspace path
Some new macros enable user to use them in custom makefiles:
- AdaCGIDEName
- AdaCGIDEProject
- AdaCGIDEWorkspace
Build the project
To build the project, use the menu Project/Build Current Project in an Ada perspective:
Run the project
In order to be able to run the model you must configure external tools: