Home

Mxx ru

image

Contents

1. engine Sta interface high 0 low taci lO monitor o CHAPTER 6 MXX_RU FOR C C PROJECTS 38 But if RuntimeSubdirObjPlacement used with output subfolder as a root and debug run time mode then the tree would be like that engine interface high low monitor output debug engine interface l high low monitor And all compilation results including exe dll lib etc would be placed inside output debug If CustomSubdir0bjPlacement used with parameters out32 for final results and tmp32 for intermediate then the tree would be like that engine interface high low monitor out32 tmp32 engine interface high low monitor SourceSubdirObjPlacement is used if obj_placement was not defined explicitly 6 1 3 Targets for C C projects These target classes are defined for C C projects in Mxx_ru e MxxRu Cpp ExeTarget for building application targets executable files Can be created by helper function MxxRu Cpp exeTarget e MxxRu Cpp LibTarget for building static libraries lib files Can be created by helper function MxxRu Cpp lib target e MxxRu Cpp Dll1Target for building shared libraries dll or so files and import li braries for them Can be created by helpe
2. See on page 30 and 6 11 2 on page 53 for more details Chapter 4 Examples 4 1 Simple application Imagine we need to compile one C file and make an application onan nua Bb N e e e H e N e O 15 16 17 18 19 20 21 22 23 24 25 26 include lt iostream gt include lt string gt void say_hello std ostream amp to to lt lt Hello lt lt std endl void say_bye std ostream amp to to lt lt Bye lt lt std endl int main say_hello std cout std cout lt lt Simple exe main lt lt std endl say_bye std cout return 0 Following project file would be required for that named prj rb require mxx_ru cpp MxxRu Cpp exe_target target simple_exe 15 CHAPTER 4 EXAMPLES 16 cpp_source main cpp 7 7 You have to run Ruby interpreter with project file to start build process ruby prj rb As a result on Microsoft Windows platform simple_exe exe file would be built Or simple_exe executable on unix platform 4 2 Application with static library Now let s try to break the example resulted above into static library exporting functions say_hello say_bye and basic module using that exported functions We will need those files for the static library e say hpp header file o Xx o wo e N Re hor o if defined _SAY_HPP_ define _
3. Global obj placement may be defined using global obj placement function Action of obj placement will be extended to all subprojects in that case A try to use global and local obj placement simultaneously is erroneous and exception would be thrown It is recommended to set a global obj placement only in a top composite project There are following classes for obj placement in Mxx_ru by default e MxxRu Cpp SourceSubdir0bjPlacement placing all object files obj o to a subfolder of source file folder By default o folder is used For instance for src win init cpp source file object file would be created in src win o That folder will be created if not exists Compiling of resources on Windows platform work the same way The placement of all other results exe lib dll import library etc are defined based on target definition related to current folder e MxxRu Cpp RuntimeSubdir0bjPlacement placing all compilation results to a folder with a name based on runtime type And source folder tree is recreated in side of that folder e MxxRu Cpp CustomSubdir0bjPlacement which places all final build results exe dll so lib a in one folder but intermediate results obj o res in a second duplicating the source folders structure in it For instance for that directory tree engine interface high low monitor and SourceSubdir0bjPlacement used the tree would become like this
4. 6 aie The constructor of QtGen class have two arguments a pointer to target object where generator would be used and a set of preprocessor symbols required to compile a project By default second argument is equal to QT_DLL QT_THREAD_SUPPORT In other words if Qt is used in DLL mode with multithreading support second argument may be omitted For all other cases second argument should contain all preprocessor symbols required for Qt version used For example for statically linked Qt but with multithreading support 1 require mxx_ru cpp qt 2 3 MxxRu Cpp exe_target 4 psa 5 qt generator MxxRu Cpp QtGen new self QT_THREAD_SUPPORT 6 aye 7 A 2 3 Header files definition to generate signal slot implementation sources Header files used to generate source files with moc tool should be defined using h2moc method 1 require mxx_ru cpp qt 2 3 MxxRu Cpp exe_target APPENDIX A QT3 GENERATOR 95 qt generator MxxRu Cpp QtGen new self qt h2moc mywidget hpp o DORA The names defined are searched from current value of sources_root see 6 11 1 on page 52 In example above mywidget hpp file should be in some project folder And results of moc tool would also be placed in that foldel From files defined with h2moc method source files are built with added moc_ prefix and extension changed to cpp So from some project m
5. AbstractTarget using a mxx_add_full_target_name method You may get all the names of files produced using mxx_full_target_names method later It s important to understand that names of intermediate files are not included in that list For example for C C projects object files are not accessible through mxx_full_target_names method 5 1 2 Subtargets Sometimes target requires files produced by other target Library files for example are required by an application target That required targets are called subtargets and their projects are called subprojects Subproject is a usual project created using usual rules of Mxx_ru project files Subpro jects are defined with a call of a method required_prj 1 require mxx_ru cpp 2 3 MxxRu Cpp composite_target MxxRu BUILD_ROOT 4 5 global_include_path 6 7 required_prj oess_1 stdsn prj rb 8 required_prj oess_1 scheme prj rb 9 required_prj oess_1 util_cpp_serializer prj rb 10 required_prj oess_1 file prj rb 11 required_prj oess_1 db prj rb 12 required_prj oess_1 util_ent_enum prj rb 13 required_prj oess_1 util_slice_create prj rb 14 required_prj oess_1 tlv prj rb 15 required_prj method does more then a storage of subproject name it loads and runs that subproject too mxx_required_prjs method allows to get all subproject names CHAPTER 5 THE BASIC IDEA 30 Sub
6. Chapter 5 The basic idea The basic idea of Mxx_ru consist of each project should define target to build The target is defined by an object of class inherited from MxxRu AbstractTarget Only one target per project file is allowed Each target must have an unique alias prj_alias Alias for target is the name of project file it s defined in The basic task for project file is to create a target object and to pass it to Mxx_ru using MxxRu setup_target function As a result Mxx_ru project files are defined by that template in common require mxx_ru lt something gt al 2 3 MxxRu setup_target 4 lt some class gt new lt the name of project file gt 5 lt definition of parameters in the project gt 6 71 In the most widespread cases for simplification of target installation the auxiliary functions are used which hide constructor s calls of the appropriate classes and MxxRu setup_target call For example used in the previous chap ter MxxRu Cpp exe_target MxxRu Cpp lib_target MxxRu Cpp dll_target and MxxRu Cpp composite_target just are such auxiliary functions Usually they have triv ial implementation of a kind 1 def exe_target prj_alias amp block 2 MxxRu setup_target MxxRu Cpp ExeTarget new prj_alias amp block 3 end 5 1 More details about MxxRu Abstract Target Class MxxRu AbstractTarget is a base class for all types of targets This cl
7. N e cpp_source main cpp 9 4 4 4 build rb file build rb is a special project file It should be placed in project root folder and ruby interpreter should be run from that folder Here all global project parameters should be defined If project contains subprojects just like in our case then build rb usually represented as a composite project Here is build rb for our example require mxx_ru cpp MxxRu Cpp composite_target MxxRu BUILD_ROOT required_prj main prj rb global_include_path y XA O Qu e N CHAPTER 4 EXAMPLES 26 4 4 5 Building a project To start build process you should enter project root folder the build rb file should be there and run Ruby interpreter with build rb file as a parameter In our example after building g project on Cygwin platform these files should appear in project root folder build rb exe_dl1_1lib exex inout lib libinout sox main say And these files should appear in lib folder libinout a libsay a 4 4 6 Building a single subproject only To build a single subproject you should enter project root folder where build rb file is and run Ruby interpreter with a subproject file name as a first parameter and mxx cpp 1 argument as a second For example to build the inout subproject you should use this command ruby inout prj rb mxx cpp 1 In that case only
8. hpp extension is used It may be changed by changing a hpp ext attribute value qt generator MxxRu Cpp QtGen new self qt hpp_ext h qt ui myform ui w N From myform ui file myform h file would be generated A 2 10 Extension for moc files generated By default during a moc files generation with moc tool moc extension is used It may be changed by changing a moc_ext attribute value 1 qt generator MxxRu Cpp QtGen new self qt moc_ext cpp moc qt cpp2moc mywidget cpp w N From mywidget cpp file mywidget cpp moc file would be generated A 2 11 The file name of moc tool The file name for moc tool is located in moc_name attribute By default it s equal to moc Changing the value of that attribute allows to set another file name used to run moc tool 1 qt generator MxxRu Cpp QtGen new self qt moc_name usr src qt 4 0 b2 bin moc N A 2 12 The file name of uic tool The file name for uic tool is located in uic_name attribute By default it s equal to uic Changing the value of that attribute allows to set another file name used to run uic tool 1 qt generator MxxRu Cpp QtGen new self qt uic_name usr src qt 4 0 b2 bin uic N
9. inout subproject would be built without any other subprojects In other words build will fail if say subproject wasn t built before because inout project depends from it 4 5 Cleaning Mxx_ru builds a project by default compilation and linking in case of C C projects Mxx_ru also supports reverse operation clean i e removing all files were built In case of C C project clean operation removes all object files libraries executables and other results of compilation and linking You need to run Ruby interpreter with project file name and mxx clean argument to perform clean operation ruby build rb mxx clean Actions performed by clean operation are extended by default to all subprojects the main project depends from If you want to clean a single C C project only you have to pass mxx cpp 1 argument also ruby some subproject prj rb mxx clean mxx cpp 1 CHAPTER 4 EXAMPLES 27 4 6 Rebuilding Sometimes it s required to perform full cleanup of a project and then compile it again Instead of running Ruby twice ruby build rb mxx clean ruby build rb in version 1 3 to Mxx_ru was added mxx rebuid argument which does that at once ruby build rb mxx rebuild As well as in case of mxx clean adding mxx cpp 1 argument would force mxx rebuild mode to only one C C project ruby some subproject prj rb mxx rebuild mxx cpp 1
10. ruby prj ut rb running unit test test exe launching test exe out_0 txt 0 comparing out_0 txt and etalons out_0 txt launching test exe out_1 txt 1 comparing out_1 txt and etalons out_1 txt launching test exe out_128 txt 128 comparing out_0 txt and etalons out_0 txt comparing out_1 txt and etalons out_1 txt comparing out_128 txt and etalons out_128 txt If during a comparison of files mismatches are detected result may look like this ruby prj ut rb running unit test test exe launching test exe out_0 txt 0 comparing out_0 txt and etalons out_0 txt launching test exe out_1 txt 1 comparing out_1 txt and etalons out_1 txt launching test exe out_128 txt 128 comparing out_0 txt and etalons out_0 txt comparing out_1 txt and etalons out_1 txt comparing out_128 txt and etalons out_128 txt lt lt lt Mxx_ru Build_ex Build error test exe out_128 txt 128 returns Error during comparing files out_128 txt etalons out_128 txt Build error test exe out_128 txt 128 returns Mismatch found in line 120 Line in out_128 txt is Hello World gt Line in etalons out_128 txt is Hello world 222 gt gt gt 8 2 3 Features MxxRu TextfileUnittestTarget class performs a simple per string comparison of fil
11. 7 Set path to your unit test projet here s path hello 9 10 MxxRu setup_target 11 MxxRu BinaryUnittestTarget new 12 Set name of your unit test project here 13 path hello test rb 14 Set name of your project to be tested here 15 path prj rb Also in the case of output file option the generated stub is saved into the file specified and nothing is shown to the standard output 10 5 The usage of the stub generator from text editors 10 5 1 VIM The stub generator can be used from VIM by one of the following methods 1 The stub generator is run as an external utility and their output is saved into a concrete file After that this file is loaded and edited as usual CHAPTER 10 PROJECT FILE STUB GENERATORS 92 Imxxrugen cpp exe t my project o some my project prj rb e some my project prj rb lt editing of the project file gt iW 2 A new file is started and the generation result is inserted into it by the help from com mand read cmd This method is based on the fact that the result of generation is shown on the standard output by default The standard output is redirected into the current editor buffer by the editor e some my project prj rb lt new file is opened gt r mxxrugen cpp exe t my project lt editing of the project file gt iW 10 6 The creation of custom templates A template is a Ruby programm which must
12. lrelease etc wms_ctl_1 ru ts qm etc wms_ctl_1 ru qm XA QD wow e N In example above make rule is created to generate an etc wms_ctl_1 ru qm file target of make rule from etc wms_ct1_1 ru ts file dependency of target of make rule using a lrelease tool from Qt toolkit When build of project is run MxxRu MakestyleGenerator is checking qm file for existence If it s not exists or it s modified attribute is earlier then ts file lrelease tool is executed In the other words the logic of usual make rule is performed During a clean operation etc wms_ct1_1 ru qm file is removed But unlike usual make files rules created using a MxxRu MakestyleGenerator are executed before all other actions in project file And in addition to they are run in exact order they are written in a project file Because of that this example 1 generator 2 MxxRu MakestyleGenerator new c b make_c 3 generator 4 MxxRu MakestyleGenerator new b a make_b would not work if b file is not exists since first generator doesn t know anything about any other generators in a project And that s an exact behavior was planned dur ing a MxxRu MakestyleGenerator creation Mxx_ru is not a usual make and all complex operations should be performed using a Mxx_ru tools created for them And MxxRu MakestyleGenerator is the only guarantee that if no such tools exists at a mo ment project sti
13. 1 would be used as a resource identifier For identifier set to 2 resource_id should be set to isolationaware_manifest value 1 MxxRu Cpp Toolsets Vc8 manifest 2 target gt self 3 autogen gt to_default_file 4 mt gt resource_id gt isolationaware_manifest For identifier set to 3 isolationaware nostaticimport manifest 1 MxxRu Cpp Toolsets Vc8 manifest 2 target gt self 3 autogen gt to_default_file 4 mt gt resource_id gt isolationaware_nostaticimport_manifest If manifest is generated into a user specified file name then there is no need to put manifest file twice Mxx_ru will extract the file name needed from autogen parameter 1 MxxRu Cpp Toolsets Vc8 manifest 2 target gt self 3 autogen gt hello_world exe manifest 4 mt gt In that case manifest would be built in from automatically generated hello_world exe manifest file However if manifest file is not automatically generated but given by a developer then file name should be defined explicitly in a mt parameter MxxRu Cpp Toolsets Vc8 manifest target gt self mt gt manifest gt hello_world exe manifest W N e In that case Mxx_ru assumes hello_world exe manifest file already exists it is built in EXE file and not removed after embedding Different parameters for mt ma
14. 6 1 4 An order of build clean execution During a build of C C targets these actions are performed 1 All subprojects build is performed 2 build method is called for all source code generators 3 C C dependency analyzer is executed 4 Compilation of all C files is performed 5 Compilation of all C files is performed 6 Resources are compiled if defined on Windows platform 7 In case of lib target static library is built In case of application and shared library Mac OS bundle target link is performed If import library place was defined for shared library import library is built CHAPTER 6 MXX_RU FOR C C PROJECTS 41 During a clean of C C targets these actions are performed 1 All subprojects clean is performed Clean method is called for all source code generators Removing all object files for all C files Removing all object files for all C files Compiled resources are removed if were defined on Windows platform In case of lib application and shared library Mac OS bundle target target files are removed If import library place was defined for shared library import library is also removed Note CompositeTarget class is building and cleaning subprojects only 6 1 5 Runtime modes Three runtime modes are allowed in Mxx_ru for C C projects debug Debug runtime libraries are used Debug information is added to target release Release runtime libraries are used Optim
15. Additional libraries linking e 56 6 13 1 Selecting static or dynamic libraries explicitly 57 ae 58 ae re o Bd 59 popa 60 6 15 1 include path global_include_pathl 60 A A A ee A 60 GREE EA 60 6 15 4 c_compiler_option global_c_compiler_option 60 Eere 60 E E ENET 60 6 15 7 librarian option global librarian_option 61 re 61 6 16 Manifest support for Visual C 8 9 10 o o o o o oo 61 6 16 1 Installation of the rules of work with the manifests 62 CONTENTS 4 6 16 2 The name of the manifest file for generation of the manifest by a linker r 6 16 3 Manifest Tool 2 0 ee 6 17 Mac OS bundle support a oa a a e le 6 18 Custom tool names 2 e 65 67 7 1 mxx show cmd argument 2 0 0 ee ee 67 7 2 mxx keep tmps argument 2 0 ee 67 7 3 mxx show tmps argument ooa a 68 7 4 mxx dry run argument ooa ee 68 Pah eh a a e ee he a 69 7 6 Adding make rules into a project ooo a a a 69 8 Unit testing support 72 bag b dees E he 4 oes 72 ye Be Buk eae Be ee ee a E 72 Pde hse ee ee RO EE ae oe eS 72 Sa gd es Peas pacbeedo dea4 ade da4 72 Pipa ee be wae Phe dae Pace ee bbe eke Bes 73 peat hag pda et 74 AR 75 E O 75 823 Features louis acy a Ao a AR O A 76 77 wa Dob A a A a eh ee i 77 a Ge ek Bo ee aria la 78 A 78 9 2 2 Adding definitions in presence of pkg config 78 wd Be Ba
16. as to generate different kinds of stubs in the same way For this purpose a generator utility mxxrugen and a set of templates for various project s types have been added into Mxx_ru A name of template is specified to mxxrugen at start cpp exe in the example above with an optional set of template s parameters The mxxrugen utility searches template and uses it for the stub generation Such schema allows extension of list of available templates as Mxx_ru will grow 10 2 The mxxrugen generator The mxxrugen utility is automaticaly installed into bin directory of Ruby interpreter during Mxx_ru RubyGem installation After that mxxrugen can be launched from the command line like a Ruby interpreter itself Synopsis mxxrugen lt mxxrugen options gt template name lt template options gt The mxxrugen utility supports the following options e help print short help for mxxrugen options e I include path PATH an additional path for searching templates By default the mxxrugen searches in the path lt mxxru gt generators where lt mxxru gt is a placement of Mxx_ru e 1 list print list of templates found The option list is intended for determination of list of available templates For example gt mxxrugen list cpp composite c ruby lib ruby gems 1 8 gems Mxx_ru 1 4 0 1ib mxx_ru generators cpp d11 c ruby lib ruby gems 1 8 gems Mxx_ru 1 4 0 lib mxx_ru generators cpp exe c ruby lib ruby gems 1 8 g
17. basic module doesn t know at all whether the library static or dynamic It just points to it s requirements it needs say rb project file to be built All other actions are handled by Mxx_ru subproject compilation library name detection linking library to basic module CHAPTER 4 EXAMPLES 4 3 Application with shared and static libraries Let s make things more complex now we need to create a shared dynamically linked library exporting inout_t class This class is intended for printing Hello in 1t s constructor and Bye in the destructor We can define objects of inout_t class in a functions to print messages to standard output about entering leaving a function Inout library will use modified version of say library there is one more argument in say_hello say_bye functions Here is what we got for e say hpp header file if defined _SAY_HPP_ define _SAY_HPP_ include lt iostream gt include lt string gt void say_hello std ostream amp to const std string amp where JE void say_bye std ostream to const std string amp where 00 s DO A e N e hop O endif N e say cpp implementation file 1 include lt say hpp gt 2 3 void 4 say_hello std ostream amp to const std string amp where 5 4 6 to lt lt where lt lt Hello lt lt std endl al 8 9 void 10 say_bye std ostream amp to const st
18. by linker during an application link After that manifest should be or is placed near to EXE DLL file additional file with name of a kind target manifest for example calculator exe manifest or complex matrix dll manifest or is built in EXE DLL file with a special tool mt exe Manifest Tool Thus the manifest is located in an EXE DLL file as a resource and this resource should have one of special identifiers e 1 CREATEPROCESS_MANIFEST_RESOURCE_ID for EXE file e 2 ISOLATIONAWARE_MANIFEST_RESOURCE_ID for a DLL which is statically linked to the application during a link process using an import library e 3 ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID for a DLL which is dynamically loaded through LoadLibrary call Since the version 1 1 the support of work with the manifests in Visual C 8 0 9 0 10 0 is implemented Mxx_ru allows e to specify rules of work with the manifests by default and these rules will be distributed to all projects which doesn t have their own manifest rules specified CHAPTER 6 MXX_RU FOR C C PROJECTS 62 e to specify rules of work with the manifests for the concrete project default rules will not be distributed to such project e to force linker to generate the manifest during a link process if it is not done the developer should independently give the manifest for his EXE DLL file e to use Manifest Tool for embedding the manifest into an EXE DLL file as with an automatic choice of
19. d11_target some deep path prj rb 2 mae 3 cpp_sources Dir glob cpp 4 because Dir glob would search all cpp files starting from current folder but not from some deep path folder To avoid this you may use mxx_sources_root method MxxRu Cpp d11_target some deep path prj rb 1 2 db 3 cpp_sources Dir glob mxx_sources_root cpp 4 6 11 3 mswin_rc file method mswin_rc_file method is intended to define a name of resource file on Windows plat form If it was set Mxx_ru executes a resource compiler during a project build to get a res file and then links it to the target mswin_rc_file method have two parameters first is required and second is optional First defines the name of rc file Second may contain file names required to build resource file For example ico or bmp files During a use of mswin_rc_file method remember that first parameter value is calcu lated considering a sources_root value But all dependency names should be defined using a full path Example 1 MxxRu Cpp exe_target interface prj rb 2 wan 3 screen_mode MxxRu Cpp SCREEN_WINDOW 4 a 5 mswin_rc_file resources rc 6 interface res mainframe ico 7 interface res document ico 8 interface res toolbar bmp 9 interface res reources rc2 10 11 CHAPTER 6 MXX_RU FOR C C PROJECTS 56 Note The value defined by mswin_rc_file metho
20. deletion shared RTL should be used all the shared libraries have a common heap in that case Type of RTL may be defined using a rtl_mode method The values for RTL type are defined as a constants MxxRu Cpp RTL DEFAULT project have no prefer ence about RTL type used MxxRu Cpp RTL_STATIC static RTL should be used MxxRu Cpp RTL_SHARED shared RTL should be used CHAPTER 6 MXX_RU FOR C C PROJECTS 47 MxxRu Cpp RTL DEFAULT mode is used by default RTL type is a global parameter so it s applied to all projects at once An exception would be thrown on a try of two projects to define different types of RTL If RTL type wasn t defined in default mode toolset will determine it Usually default compiler s RTL type is used An example 1 MxxRu Cpp dll_target 2 target_root lib 3 target my 4 5 rtl_mode MxxRu Cpp RTL_SHARED 6 7 Current RTL mode is available through mxx_rt1_mode method 6 6 Multi threading mode selection On some platforms Microsoft Windows for example it s required to explicitly de fine a type of threading mode used in a project threading mode method should be used to set threading mode in Mxx_ru The values for threading mode are de fined as a constants MxxRu Cpp THREADING_DEFAULT project have no preference about threading modes It s a singlethreaded by itself but still work well in a multithreaded application MxxRu Cpp THREADING_MULTI
21. for each ts file defined For example if there is gui client prj rb with the above contents then there will be two invocation of lupdate in the form lupdate slient gui client ts gui client translations client_ru ts lupdate slient gui client ts gui client translations client_fr ts It means that lupdate is forced to scan the directory with project file and subdirectories below it It means also that name of ts file is relative to project file CHAPTER 9 QT4 GENERATOR 83 9 2 9 Output folder for moc tool By default work results of moc tool are located in the same folder where source data were In some cases it s not so convenient For example during a moving to new Qt version when all old generated files should be removed It would be easier to do if all generated files would be in separate folder In a Mxx_ru Cpp Qt4 class moc_result_subdir attribute exists responsible for deter mining where to put moc results If it is equal to nil the default value then all generated files are placed near the sources they are generated from Otherwise files would be placed into defined subfolder of source folder For example 1 qt generator MxxRu Cpp Qt4 new self qt moc_result_subdir moc qt h2moc h mywidget hpp wo N From h mywidget hpp file h moc moc_mywidget cpp file would be generated The value of moc_result_subdir only matters for files defined using a h2moc and cpp2moc methods 9 2 10 Outp
22. my manifest would force Mxx_ru to write generated manifest file to my manifest file 6 16 3 Manifest Tool If it is required that the manifest should be built in as a resource in resulting EXE DLL file then mt parameter should be defined during a MxxRu Cpp Toolsets Vc8 manifest call For example construction MxxRu Cpp Toolsets Vc8 manifest target gt self autogen gt to_default_file mt gt e N e specifies that manifest is generated by linker the name of manifest file should be generated by Mxx ru manifest should be built in into application by Manifest Tool and after that generated manifest file should be removed If developer wants to store manifest file the description should be changed this way MxxRu Cpp Toolsets Vc8 manifest target gt self autogen gt to_default_file mt gt keep_manifest_file gt true e N e CHAPTER 6 MXX_RU FOR C C PROJECTS 64 The manifest defined this way will be built in into EXE DLL file with resource iden tifier automatically set by Mxx_ru For EXE files 1 is used as identifier for DLL files 2 If there is a need to set identifier explicitly it may be done this way 1 MxxRu Cpp Toolsets Vc8 manifest 2 target gt self 3 autogen gt to_default_file 4 mt gt resource_id gt process_manifest In that case
23. pkg config tool in the system for example on Debian GNU Linux it is possible to use pkg config for detection of Qt4 related files locations and compiler linker options To use pkg config it is necessary to include mxx_ru cpp qt4_via_pkg_config rb in stead of mxx_ru cpp qt4 rb 1 require mxx_ru cpp 2 require mxx_ru cpp qt4_via_pkg_config 3 4 MxxRu setup_project The work scheme of mxx_ru cpp qt4_via_pkg_config rbis CHAPTER 9 QT4 GENERATOR 79 e at first the presence of pkg config is checked by pkg config version command e if pkg config is present in the system then call of Qt4 module leads to pkg config invocations with arguments cflags and libs to detect all information required include paths library paths compiler and linker options e if pkg config isn t present then the work of mxx_ru cpp qt4_via_pkg_config rb is the same as work of mxx_ru cpp qt4 rb For example suppose that we are working on Debian GNU Linux and we need to use QtGui module We specify in the project file require mxx_ru cpp require mxx_ru cpp qt4_via_pkg_config 1 2 Es ares 4 qt generator MxxRu Cpp Qt4 new self 5 qt use_module QT_GUI 6 During the call to qt use_module QT_GUI pkg config is being invoked with argument cflags pkg config cflags The result of such invocation could be like the following DQT_SHARED I usr include qt4 QtGui Those options will be a
24. that case Mxx_ru creates temporary files with unique names executes a tools required and removes that files after processing of project file is done For example a build of a sample from 4 4 on page 21 using a Visual C compiler would bring this output ruby build rb mxx show cmd lt lt lt cl Otmpmxx_ru 3804 1 gt gt gt say cpp lt lt lt lib Otmpmxx_ru 3804 2 gt gt gt lt lt lt cl Otmpmxx_ru 3804 3 gt gt gt inout cpp lt lt lt link tmpmxx_ru 3804 4 gt gt gt Creating library lib inout lib and object lib inout exp lt lt lt cl Otmpmxx_ru 3804 5 gt gt gt 67 CHAPTER 7 ADDITIONAL FEATURES 68 main cpp lt lt lt link Ctmpmxx_ru 3804 6 gt gt gt Where files with names like tmpmxx_ru 0 9 0 9 are temporary files created by Mxx_ru Sometimes during a debug of projects or new toolsets is useful to save temporary files for following analysis It s possible to do using a mxx keep tmps argument passed into Ruby interpreter ruby build rb mxx keep tmps 7 3 mxx show tmps argument mxx show tmps argument is analogue to mxx show cmd argument but for tempo rary response files Mxx_ru puts contents of temporary files to stdout if mxx show tmps is passed to Ruby interpreter For example a build of a sample from 4 4 on page 21 using a Visual C compiler with mxx show cmd and mxx show tmps arguments would bring this output lt lt lt tmp
25. the appropriate identifier of resources and with the obviously given identifier 6 16 1 Installation of the rules of work with the manifests Installation of the rules of work with the manifests is carried out with the help of a MxxRu Cpp Toolsets Vc8 manifest method As parameter this method receives Hash with values describing rules of work with the manifest To set rules for the concrete project it is necessary to call a MxxRu Cpp Toolsets Vc8 manifest method in a project file of the given project having a target parameter set 1 MxxRu Cpp exe_target 2 ots 3 target calculator 4 MxxRu Cpp Toolsets Vc8 manifest 5 target gt self 6 autogen gt to_default_file 7 s Such description specifies that for calculator rb project the manifest should be generated through target gt self construction The manifest will be generated by a linker and will be placed in a calculator exe manifest file it is set by autogen gt to_default_file If target parameter is not defined during a MxxRu Cpp Toolsets Vc8 manifest call Mxx ru will consider that the default manifest is set 1 MxxRu Cpp composite_target MxxRu BUILD_ROOT gt 4 2 see 3 MxxRu Cpp Toolsets Vc8 manifest 4 autogen gt to_default_file 6 y Such description forces Mxx_ru to create manifest with a linker and place the manifests in files with names of a lt targ
26. the libraries Mxx_ru automatically gathers folder names to search for the libraries if these names are passed as a second parameter of lib method In some cases this requirement to pass the search path to lib method may not be ideal For example it may reqiure to define the following code when unix 1 case toolset tag target_os 2 when mswin 3 lib engine tools engines lib 4 lib parser tools parsers lib 5 6 lib engine usr local lib CHAPTER 6 MXX_RU FOR C C PROJECTS 59 7 lib parser usr local lib s end A situation with lib method as well as with lib_static and lib_shared becomes more worse if the library may be placed in one of several folders for example usr 1ib usr loca1 1ib but exactly isn t known where it is In this case it s unclear which path should be defined in lib method To solve this problems 1ib_path method was added into Mxx_ru which allows to define search path for the libraries Using it an example above can be rewriten as the following case toolset tag target_os when mswin lib_path tools engines lib lib_path tools parsers lib when unix lib_path usr local lib end oma Nowa A OU N e lib engine lib parser o Also lib_paths method exists which have Enumerable argument 1 case toolset tag target_os 2 when mswin
27. type it would take Thus by default on linux GCC selects shared library i e 1ibA s0 But if static option would be passed to the GCC then 1A would take static version 1ibA a In some cases developer may want to explicitly set that it s required to use exactly static or exaclty shared library To set requirement of static library 1ib_static method was added and to set requirement of shared library lib_shared was added 1 require mxx_ru cpp 2 3 Mxx_ru Cpp exe_target 4 target some_target 5 A 6 lib engine Linker may choose or libengine a 7 or libengine so 8 lib_static config Linker is forced to choose libconfig a 9 even if libconfig so exists 10 lib_shared gui Linker is forced to choose libgui so 11 even if libgui a exists 12 13 For GCC on Unix a call to 1ib A method is expanded to 1A A call to lib_static A by default is expanded to W1 Bstatic 1A Bdynamic if linker uses Bdynamic mode by default Accordingly a call to lib_shared A would be expanded to W1 Bdynamic 1A Bstatic if linker uses Bstatic mode by default For GCC on Unix Mxx ru v 1 3 assumes linker is always prefers shared libraries i e uses Bdynamic mode by default If it s required to set static mode as default then lib_linking_mode tag should be used with static value during toolset configuration ja export MXX_RU_CPP_TOOLSET gcc_linux lib
28. 0 N Q a e N The names defined are searched from current value of sources_root see 6 11 1 on page 52 In example above mywidget hpp file should be in some project folder And results of moc tool would also be placed in that foldef From files defined with cpp2moc method source files are built with extension changed to cpg So from some project mywidget cpp file some project mywidget moc file would be generated 9 2 6 UI files definition Qt Designer user interface files saved as ui files are defined using a ui method require mxx_ru cpp qt4 MxxRu Cpp exe_target 1 2 3 4 Jes 5 qt generator MxxRu Cpp Qt4 new self 6 oes 7 qt ui myform ui 8 The names defined are searched from current value of sources_root see 6 11 1 on page 52 In example above myform ui file should be in some project folder And results of ui tool would also be placed in that folder From files defined with ui method header files are built with prefix ui_ and exten sion changed to a As result from some project myform ui would be generated file some project ui_myform 9 2 7 Resource files definition Qt4 uses resource files with qrc extension Such files should be translated into cpp files textual form or into rcc files binary form If textual form is used than the resulting cpp files should be added to the list of project s source files The rcc tool is used for resource files
29. 14 Wrong 15 MxxRu Cpp exe_target 16 17 target my 18 c_source my c 19 21 Right Reversed slash at the line end means 22 the next line is a continue of current 23 MxxRu Cpp exe_target 24 25 target my 26 c_source my c 27 A bit more information about MxxRu Cpp LibCollection Sometimes it is necessary to enumerate the same libraries in several project files CHAPTER 6 MXX_RU FOR C C PROJECTS 40 MxxRu Cpp exe_target required_prj cfg prj rb required_prj utils prj rb required_prj logging prj rb XA QD wow e N It is possible to create a project with target type MxxRu Cpp LibCollection to avoid repetition of such enumerations That project will contain all necessary subprojects For example file 1ib common rb 1 MxxRu Cpp lib_collection_target 2 required_prj cfg prj rb 3 required_prj utils prj rb 4 required_prj logging prj rb 5 A then that file is included via required prj MxxRu Cpp exe_target required_prj lib common rb a e N And this will automatically add libraries cfg prj rb utils prj rb and logging prj rb to the current project The target type MxxRu Cpp LibCollection distinguishes from MxxRu Cpp CompositeTarget in that way LibCollection builds full list of all necessary libraries which should be linked with target project
30. 3 lib_paths tools engines lib tools parsers lib 4 when unix 5 lib_paths usr local lib usr lib usr share lib 6 end 7 8 9 lib engine lib parser Method lib_paths can be combined with the features of standard Ruby library and algorithmic features of Ruby language itself For example the following fragment defines as search paths all subfolders that have lib files inside 1 lib_paths Dir x x 1ib inject 1 r fl r lt lt File dirname f uniq 6 14 Optimization mode selection Optimization mode may be selected using optimization method Mxx_ru considers optimization mode during assemble of compiler options for release mode see 6 1 5 on page 41 Optimization by speed is used by default These constants should be used to define optimization mode MxxRu Cpp OPTIM_SIZE Optimization by size of code generated and MxxRu Cpp OPTIM_SPEED optimization by speed of code generated Optimization mode is a local project parameter so defined optimization mode have no effect nor child nor parent projects CHAPTER 6 MXX_RU FOR C C PROJECTS 60 6 15 Functions for setting local global and upspread param eters As can be seen in on page functions to define local upspread and global project parameters are usually look like this lt parameter gt a_value a_type global_ lt parameter gt a_value where lt pa
31. D 256 lt lt lt Mxx_ru Build_ex Build error unittest test active_group exe returns 256 gt gt gt Negative unit test target class Sometimes it is a lot easier to write unit test that alwais fails For example this kind of test helps to check programs libraries classes which must call std abort in some cases Since v 1 6 3 Mxx ru supports this kind of unit tests by MxxRu NegativeBinaryUnittestTarget require mxx_ru binary_unittest al 2 3 MxxRu setup_target 4 MxxRu NegativeBinaryUnittestTarget new 5 some project prj ut rb 6 some project prj rb 7 This class does exactly the same actions that MxxRu BinaryUnittestTarget The only difference is the checking of the exit code for unit test application MxxRu BinaryUnittestTarget requires that exit code is 0 exactly 0 But MxxRu NegativeBinaryUnittestTarget requires that exit code is not 0 8 2 Running unit tests using comparison of text files In some cases it s too difficult to create a binary unit test application controlling test results and returning a zero exit code if successful that applications is required for MxxRu BinaryUnittestTarget class described in 8 1 on page 72 For example it s too difficult to test a text parsing libraries that way More conveniently to create a text appli cation getting one source file as a parameter and saving result as another text file Then for each of source fil
32. LSET gcc_linux unix linux arch x86 set MXX_RU_CPP_TOOLSET vc7 6 3 Toolset access Toolset object can be accessed using a toolset method of a MxxRu Cpp Target class For example 1 MxxRu Cpp exe_target my prj rb 2 oes 3 if vc toolset name 4 5 end 6 7 Note Since toolset method is not static it can be executed only for created target object For instance it was used inside a code block passed into the constructor in example above 6 4 Runtime mode selection inside project file Runtime mode may be defined in a project file using runtime_mode method The values for runtime modes are defined as a constants MxxRu Cpp RUNTIME_DEBUG MxxRu Cpp RUNTIME_DEFAULT MxxRu Cpp RUNTIME_RELEASE By default MxxRu Cpp RUNTIME DEFAULT is used Runtime mode is a global parameter so it s applied to all projects at once Exception would be thrown if two projects will try to set different runtime modes Current runtime mode is available through mxx_runtime_mode method See also on page 6 5 Runtime library type selection On platforms with shared libraries supported some toolsets allow to select one of two runtime library RTL types static RTL code is statically linked into application and shared RTL code is inside shared library linked against application If application have it s own shared libraries and exports C objects created in one library into another for
33. Make on Ruby is a cross platform build tool It s intended for C C languages in general but it s easy to extend for handling other languages In contrast to well known make utility which provides explicit make rules with targets dependencies and build commands Mxx_ru have a template based approach Project file in Mxx_ru is a small Ruby program using already defined class template from Mxx_ru The only thing developer is have to worry about is to create an object of required class and execute some of it s methods 1 2 Features Mxx_ru unifies the build process for applications across different compilers and plat forms It allows to work with different programming languages and functionality of Mxx_ru may vary to reflect each language specifics Here is the features provided for C C languages e Using one project file for different compilers and platforms e Automatic dependency tracking using internal source code analyzer e Ready to use templates for applications dynamic and static libraries e Ready to use template for composite projects when more then one project are com bined together e Resource file compilation on Microsoft Windows platform e Visual C 8 0 manifest support on Microsoft Windows platform e Support for Source code generators and some of ready to use generators such as Qt moc http www ruby lang org CHAPTER 1 INTRODUCTION 7 1 3 A bit of history Mxx_ru is an evolution of M
34. Mxx ru User manual by Yauheni Akhotnikau Contents 1 Introduction 6 CERA ee Bee A e 6 MI E ee ES 6 1 3 A bit of hist ry saa sadace sidia e eaa od aea ee 7 1 4 Thanks 3 32 bee pee ea Gaeeee ee ea ad a o 7 8 oP ee Ho bee ee wo ie ae a ee eR ek Ae A 8 ih fe eee BA EA Rowe be Sane eS aA e ae ons 8 sea bh atm eae es 9 11 Bal Version 16 i aaye aos a e ad Ra e eee a ee Es 11 32 Version Lpf s e crop RAR aa EM Se Rae eG oes 11 oo Version 1 4 sa e s ea sans giosa ee we ee ee ee ES 11 3 4 Version LA ee 12 35 Version Ll epee BA pew e Ree De ee ee eS 14 15 ue ee a Se ee ee eee Ge eee a 15 4 2 Application with static library aooaa 2 20000 16 4 3 Application with shared and static libraries 04 18 eee 21 4 4 1 say Subproject 2 0 20 22 ee ee 22 4 4 2 inout Subproject oaoa aaa ee 23 4 4 3 main subproject e 24 4 4 4 build rbfilel e o 25 4 45 Building a project e e 26 4 46 Building a single subproject Only o 26 AO A A E NE 26 406 Rebuilding ss etaa Poe ad ea e a A a Se a a 27 28 5 1 More details about MxxRu AbstractTarget aoaaa a 28 5 1 1 A names for files created by target o oo aa a 29 E a ER a E TS Qe eee E Ne 29 Li a Be ps dad NE 31 E neh Ga a toes ares oh ae a 31 CONTENTS 3 5 2 More details about MxxRu sebup targetl o 33 6 Mxx_r
35. SAY_HPP_ include lt iostream gt void say_hello std ostream amp to void say_bye std ostream amp to endif e say cpp implementation file 00 s Dm A e N e include lt iostream gt void say_hello std ostream amp to to lt lt Hello lt lt std endl void say_bye std ostream amp to to lt lt Bye lt lt std endl e say rb project file CHAPTER 4 EXAMPLES XA osa e Ww N e 17 require mxx_ru cpp MxxRu Cpp lib_target target say cpp_source say cpp Also we will need those files for the basic module e main cpp implementation file 00 s DO Ow e Qu N p o o 11 include lt iostream gt include lt say hpp gt int main say_hello std cout std cout lt lt Exe and lib main lt lt std endl say_bye std cout return 0 e prj rb project file O N Q al e N e hop o require mxx_ru cpp MxxRu Cpp exe_target target exe_and_lib required_prj say rb include_path cpp_source main cpp You have to run ruby interpreter with a prj rb file as a parameter to build the project including static library and basic module Mxx_ru would build say library and link it to the basic module automatically Notice that you have no need to specify the library name in prj rb project file Moreover the
36. S_STANDARD_CPP_LIBRARY iso_4 zlib MSWindows Resource Linker Options 45 This mode may be useful if project built by Mxx_ru should be linked against project built in other build system 6 2 Mxx_ru setup for C C projects MXX_RU_CPP_TOOLSET environment variable should be defined to use Mxx_ru features with a C C projects The syntax used to define this environment variable is as follows MXX_RU_CPP_TOOLSET lt file gt tag value tag value where lt file gt is the name of rb file from Mxx_ru responsible for C C toolset object creation Toolset names supported are enumerated in a 6 5 table The pairs tag and value would be defined as a tags for selected C C toolset bec_win32_5 Borland C 5 for Microsoft Windows c89_etk_nsk c89 for HP NonStop from eToolkit for Microsoft Windows c89_nsk 89 for HP NonStop icc_win Intel C for Windows gcc_cygwin GNU C C for Cygwin gcc_darwin GNU C C for Mac OS X gcc linux GNU C C for Linux gcc_mingw Minimalist GNU C C for Windows gcc_sparc_solaris GNU C C for Solaris on SPARC vc7 Visual C 7 for Microsoft Windows ve8 Visual C 8 for Microsoft Windows vc9 Visual C 9 for Microsoft Windows vc10 Visual C 10 for Microsoft Windows Examples Table 6 5 Supported toolsets for Mxx ru CHAPTER 6 MXX_RU FOR C C PROJECTS 46 export MXX_RU_CPP_TOO
37. _linking_mode static It s a base class for all C C targets CHAPTER 6 MXX_RU FOR C C PROJECTS 58 If Mxx_ru detects that the same library is used as both static and shared i e in one place it s defined with lib_static but in other place with 1ib_shared inside a project then Mxx_ru throws an exception and stops After adding lib_static lib_shared methods in Mxx_ru the following side effect is appeared Now a connection of static library project with required_prj is equivalent to usage of lib_static method Accordingly a connection of shared library project with required_prj is equivalent to usage of 1ib_shared method 1 A prj rb 2 MxxRu Cpp lib_target target A 3 4 B prj rb 5 MxxRu Cpp dll_target target B 6 7 C prj rb s MxxRu Cpp exe_target 9 target C 10 required_prj A prj rb 11 required_prj B prj rb 12 ns 13 is equivalent to 1 C prj rb 2 MxxRu Cpp exe_target 3 target C 4 lib_static A 5 lib_shared B 6 7 In 1 3 version one question was left unresolved If user wants his application to be linked to only static versions of the libraries Mxx_ru have no separate method to do that The only way to do that is to define static value in link_option But in that case Mxx_ru can t warn if somewhere 1ib_shared method would be used 6 13 2 Enumeration of search paths for
38. _name is specified then that tool will be used only for C files and C files will be compiled by the standard compiler An example export MXX_RU_CPP_TOOLSET gcc_linux compiler_name my gcc linker_name my gcc Chapter 7 Additional features 7 1 mxx show cmd argument By default Mxx_ru doesn t show any information about actions it performs it works like a black box But sometimes it may be useful to know what commands are running They would appear in stdout if mxx show cmd argument is passed to Rube interpreter For example a build of a sample from on page using a GNU C compiler in Cygwin environment mxx show cmd argument would bring this output ruby build rb mxx show cmd lt lt lt g c o say o say o I say say cpp gt gt gt lt lt lt ar r lib libsay a say o say o gt gt gt lt lt lt g c o inout o inout o DINOUT_PRJ I inout inout cpp gt gt gt lt lt lt g shared shared libgcc o libinout so Llib inout o inout o 1stdc lsay W1 out implib lib libinout a export all symbols gt gt gt lt lt lt g c o main o main o I main main cpp gt gt gt lt lt lt g shared libgcc o exe_dl1_lib exe Llib main o main o 1stdc linout gt gt gt 7 2 mxx keep tmps argument To create command strings for some tools on some platforms creation of response files is required It s a temporary text files with values of parameters inside In
39. _option Functions linker_option global_linker_option are used to define additional linker options CHAPTER 6 MXX_RU FOR C C PROJECTS 61 6 15 7 librarian option global librarian option Functions librarian_option global_librarian option are used to define additional librarian options used to create a static libraries 6 15 8 Resource compiler on Microsoft Windows platform mswin_rc_include_path global_mswin_rc_include_path Functions mswin_rc_include path global mswin_rc_include path are used to define header search path s for resource compiler mswin_rc_define global_mswin_rc_define Functions mswin_rc_define global mswin_rc define are used to set preprocessor de fine symbols defined during resource compilation mswin_rc_option global mswin_rc_option Functions mswin_rc_option global _mswin_rc_option are used to pass additional op tions to resource compiler mswin_rlink_option global_mswin_rlink_option Functions mswin_rlink_option global_mswin_rlink_option are used to pass addi tional options to resource linker 6 16 Manifest support for Visual C 8 9 10 In Visual C 8 0 9 0 10 0 the next innovation of Microsoft was realized support of NET manifests for EXE and DLL targets which use Shared RTL library from Visual C The manifest is a XML file describing exact libraries including their versions necessary for the application The manifest file should be or is written manually by developer or generated
40. _path define INOUT_PRJ if mswin toolset tag target_os define INOUT_MSWIN end cpp_source inout cpp Basic module contains following files e main cpp implementation file e N 00 XA QD wo 10 aii 12 13 14 16 17 18 19 20 21 22 23 include lt iostream gt include lt inout hpp gt void some_func inout_t braces some_func std cout lt lt Some functionality lt lt std endl int main inout_t braces main std cout lt lt Exe dll lib main lt lt std endl some_func return 0 e prj rb project file 1 2 require mxx_ru cpp CHAPTER 4 EXAMPLES 21 MxxRu Cpp exe_target 1 target exe_d11_1ib 3 4 6 required_prj inout rb 7 8 include_path 10 cpp_source main cpp ul Notice that basic module doesn t know anything about it s dependency from say library That dependency is tracked automatically by Mxx ru This dependency is very important for Unix platforms unlike such platforms as Microsoft Windows or OS 2 In particular during linking of basic module on unix platform both libraries should be defined in linker parameters In case of Mxx_ru there is no need to define that dependency explicitly Mxx_ru tracks that dependencies and uses them on each platform in a preferred way 4 4 Application with shared and static libraries in different fold
41. a functions with names like global_ lt name gt where name is a name of function used to set a local parameter global_define global_include_path global_compiler_option etc Here is an example of global include path for a composite project For instance MxxRu Cpp composite_target MxxRu BUILD_ROOT gt 4 global_include_path required_prj engine prj rb required_prj interface prj rb s Dm a e Qu N e Current folder would be used as an include directory for all files during a build of both engine prj rb and interface prj rb projects Here is an example of global compiler option 1 MxxRu Cpp dll_target packer prj rb 2 q 3 4 bytes alignment should be used 4 if vc toolset name 5 global_compiler_option Zp4 6 end 7 8 CHAPTER 6 MXX_RU FOR C C PROJECTS 43 Zp4 compiler option would be used for Visual C compiler for all projects com bined within a common project with packer prj rb Upspread parameters are applied for current project and all projects using that project as a subproject no matter how deep they are include each other Upspread parameters are set with the same functions as local are but with a second argument set to a MxxRu Cpp Target OPT_UPSPREAD constant Here is an example of upspread define symbol and upspread include path 1 MxxRu Cpp lib_target pcre prj rb 2 target_root lib 3 target pcr
42. ake tool originally developed by Yauheni Akhotnikay Make was based on wmake from Watcom C initially Then it was completely rewrit ten on C The main task for Make now was a creation of makefile for concrete compilers based on simple text project description This solution was found to be hard to adapt to new tools and platforms so new version of Make was required Next iteration of Make was make tool and self script language interpreter simultaneously But this tool also had a problems with new tools especially when source code generation was required As a result new fourth version of Make was created It was self script interpreter at most and make module functionality was accessible as API functions Fourth version of Make was widely used by Intervale company But it s also reached a limit of opportunities in course of time In particular transitions to new platforms and compilers become more and more difficultly because of limited algorithmic features of Make script language The basic idea of the fifth version remains the same Project file is a small program on interpretable script language Make module functionality is accessible through API functions and classes The only difference was in language chosen it was Ruby 1 4 Thanks The author expresses gratitude to the colleagues from the Intervale company for their patience shown during experiments with Mxx_ru And as to a management of the company for
43. ample Project file of unit test application 1 require mxx_ru cpp 2 3 MxxRu Cpp exe_target test active_group prj rb 4 5 required_prj threads_1 dll rb 6 required_prj so_4 prj rb 7 8 target_root unittest 9 target test active_group 10 11 cpp_source main cpp 12 Unit test project file 1 require mxx_ru binary_unittest 2 3 MxxRu setup_target 4 MxxRu BinaryUnittestTarget new 5 test active_group prj ut rb 6 test active_group prj rb 7 Composite project file 1 require mxx_ru cpp 2 3 MxxRu Cpp composite_target Mxx_ru BUILD_ROOT 4 global_include_path 6 required_prj so_4 prj rb 7 Zaa 8 required_prj test active_group prj ut rb 9 10 Composite project may be run as usual ruby build rb But during a build process next message would appear running unit test unittest test active_group exe If not all unit tests would be successful result of project build may look like this CHAPTER 8 UNIT TESTING SUPPORT 74 main cpp running unit test unittest test active_group exe thread group 0 a_receiever_1 a_receiever_1 a_1 a_receiever_2 a_1 thread group 1 a_receiever_2 2004 09 24 16 58 29 669152 so_4 ret_code cpp 40 test active_group main cpp 347 10000 Invalid threads groups unit test unittest test active_group exe FAILE
44. ample with vc7 toolset you will get ordinal my_test_bundle d11 dynamic link library 6 18 Custom tool names If the following tags defined in MXX_RU_CPP_TOOLSET environment variable then the names which specified by those tags will be used instead of the standard tools names compiler_name C and C files compiler name c_compiler_name C files compiler name cpp compiler_name C files compiler name linker_name Linker name librarian_name Librarian name import_librarian_name Name of librarian for import library creation for example it is actial for Borland C rc_name Resource compiler name mt_name Manifest tool name for Visual C 8 9 10 Table 6 6 The tags for specifying custom tool names If tags c_compiler_name and cpp_compiler_name are defined in MXX_RU_CPP_TOOLSET then a tool whose name specified by c_compiler_name will be used for C files compi lation and for C files a tool whose name specified by cpp_compiler_name If http developer apple com documentation CoreFoundation Conceptual CFBundles CFBundles html CHAPTER 6 MXX_RU FOR C C PROJECTS 66 tags c_compiler_name and compiler_name are defined then a tool with name in tag c_compiler_name will be used for C files and for C files a tool whose name specified by compiler_name If only tag compiler_name is specified then that tool will be used for C and for C files If for example only tag c_compiler
45. ass defines two important methods build for building a target and clean for cleaning build results These methods are defined as abstract inside of MxxRu AbstractTarget In other words it s required to define them in classes inherited from MxxRu AbstractTarget But be cause there is no definition of abstract method in Ruby a try to call any of them from MxxRu AbstractTarget class will throw an exception MxxRu AbstractMethodEx 28 CHAPTER 5 THE BASIC IDEA 29 To support mxx rebuild mode in MxxRu AbstractTarget class also reset method was added It s main task to clear status of a target after build and clean methods call After call of reset method target will be in it s initial state as if there was no previous calls to build or clean Method reset in MxxRu AbstractTarget class is implemented as empty method so inherited classes that doesn t have it s internal state there is no need to redefine it There is one more method defined you can get an alias of a target by calling a prj_alias method 5 1 1 A names for files created by target As usual target is defined to produce one file as a result Executable file for C project DVI file for IATFXproject or jar file for Java project are examples of that But target may produce more then one file in general it s dependent from project type only No matter how much files are produced by a target all their names should be passed to the base class MxxRu
46. ch would be used during project build on Mxx_ru to help make integration with other build system easier For more details see 6 1 9 on page Was added MxxRu Cpp CustomSubdir0bjPlacement class which gives one more method to place build results of C C projects It stores all exe dll so lib a in one folder and all intermediate compilation results such as obj o res e t c in another duplicating file structure of source files in the intermediate folder For more details see on page 3 5 Version 1 2 Added command line arguments mxx brief show mxx brief hide and method MxxRu enable_show_brief for controlling brief description of executed commands Argument prj alias for composite target exe target libtarget and dll_target now optional If it omitted than Mxx_ru try detect prj_alias form Kernelitcaller result assume what call to target method was made directly in project file This allow to write MxxRu Cpp exe_target 3 instead of MxxRu Cpp exe_target some module path prj rb 4 ja 3 See on page for more details Added methods Abstract_targetitrequired prjs Cpp Target c_sources Cpp Targetitcpp sources those accept Enumerable plural form for corre sponding singular analogs New methods can accept result of Dir glob For example 1 MxxRu Cpp exe_target 2 target some_target 3 cpp_sources Dir glob src cpp 4
47. composite target and macos_bundle target are learned to automatically detect an alias of a project if it wasn t given explicitly In that cases ruby project file name is taken where one of auxiliary methods takes place For example given example above can be rewritten to the following MxxRu Cpp exe_target 3 and if file some module prj rb is run as ruby some module prj rb then some module prj rb would be used as an alias It s important to understand that Mxx_ru still requires an unique alias for each project And that classes inherited from MxxRu AbstractTarget such as MxxRu Cpp ExeTarget or MxxRu BinaryUnittestTarget are required to get an alias explicitly in their constructors It s just some auxiliary functions are added and will be added to wide used target types which can detect a project alias based on ruby file name 5 1 4 Source code generators Sometimes we need to generate source files from something using special tools for doing that For example yacc generates source code for syntax analyzers from y files It s clear that different generators operating different types of files and different parame ters for them are required And they produce different amount of source files For example uic tool from Trolltech Qt may produce header and implementation files Keeping that in mind Mxx ru uses a generalized conception of a generator Ther
48. conforms to the following conditions e resides in the subdirectory with the name of template for example the template cpp dll resides in subdirectory cpp d11 e have the name g rb If a template requires some parameters from the user it is prefered to use command line arguments for that It is desirable that a template handles the h help option To use a custom template it is necessary to specify the path to custom template s directory into the include path option mxxrugen I my templates custom lib In such case mxxrugen checks the existance of the file my templates custom lib g rb and if that file exists runs it If the custom lib doesn t exist in the path my templates then mxxrugen continues the search of it between the standard templates Appendix A Qt3 generator A 1 Introduction This chapter describing a C files generator required if Qt3 library http www is used The described generator was tested on Qt version 3 3 3 At use of Qt library there is a necessity of C files generation with Qt tools in three cases 1 When a class inherited from QObject is defined in a header file and slots or signals are defined in that class In that case source file should be created from header file containing implementation of slots and signals For generation moc tool should be used Usually moc_a cpp file would be generated from a h file In other words extension is changed to cpp and moc_ pre
49. cpp file would be generated The value of moc_result_subdir only matters for files defined using a h2moc and cpp2moc methods A 2 7 Output folder for uic tool As well as in previous case during the run of uic by default results are stored in the same folder with source ui file If it isn t desirable then uic_result_subdir method allows to set subfolder of a folder with ui file where uic would store it s results For example 1 qt generator MxxRu Cpp QtGen new self qt uic_result_subdir uic qt ui src dlg ui w N would generate src uic dlg hpp src uic dlg cpp and src uic moc_dlg cpp And src uic path would be automatically included to project s include_path 6 15 1 0on page 60 if it s not changed with hpp_ext attribute see on page 97 Cif it s not changed with cpp_ext attribute see A 2 8 on page 97 7 A PEE FR Taking value of uic_result_subdir into account see on page APPENDIX A QT3 GENERATOR 97 A 2 8 Extension for source files generated By default during a source files generation with moc and ui tools cpp extension is used It may be changed by changing a cpp ext attribute value 1 qt generator MxxRu Cpp QtGen new self qt cpp_ext CC qt h2moc h mywidget H w N From h mywidget H file h mywidget CC file would be generated A 2 9 Extension for header files generated By default during a header files generation with ui tool
50. d string amp where 11 12 to lt lt where lt lt Bye lt lt std endl 13 e say rb project file require mxx_ru cpp MxxRu Cpp lib_target target say include_path cpp_source say cpp o XA QD a gt N Re CHAPTER 4 EXAMPLES Here is inout library files e inout hpp header file p e N 00 N o OW 10 11 12 13 14 16 Ir 18 19 20 21 22 23 24 26 19 if defined _INOUT_HPP_ define _INOUT_HPP_ include lt string gt if defined INOUT_MSWIN if defined INOUT_PRJ define INOUT_TYPE __declspec dllexport ttelse define INOUT_TYPE __declspec dllimport endif else define INOUT_TYPE endif class INOUT_TYPE inout_t public inout_t const std string amp method jinout_tQ private std string m_method ttendif e inout cpp implementation file e N al o N Q 10 11 12 13 14 include lt say hpp gt include lt inout hpp gt inout_t inout_t const std string amp method m_method method say_hello std cout method inout_t inout_t say_bye std cout m_method e inout rb project file CHAPTER 4 EXAMPLES a e N 00 XA oa 10 Ll 12 13 14 16 IT 18 20 require mxx_ru cpp MxxRu Cpp dll_target target inout implib_path required_prj say rb include
51. d have two arguments The first defines library name should be passed into a linker in a way it should be passed In other words on Windows platform it should be the name with an extension but on unix platforms it should be the name without an extension and lib prefix CHAPTER 6 MXX_RU FOR C C PROJECTS 57 Second argument of a lib method defines a path linker should search for that library By default that argument is equal to nil value i e no path is passed into the linker In that case linker would perform search in standard paths for specific platform But if second parameter is not equal to nil then value defined would be passed into the linker as a search path For example if you need to define usr local share mysec lib libtdes 3 4 a library to link against a target on a unix platform you need to call Lib method that way 1 lib tdes 3 4 usr local share mysec lib 6 13 1 Selecting static or dynamic libraries explicitly In 1 3 version two new methods are implemented for BinaryTarget lib_static lib_shared On Windows platform they are simple aliases of lib method But on Unix platform they are intended to say linker to which type of a library static or dynamic it should link against On Unix systems it s common to have the same library let s call it A as a static named 1ibA a and shared named 1ibA so When library name is passed to the linker in 1 option 1A linker chooses by itself what
52. d is taken into account on Windows platform only 6 12 Additional object files linking obj_file method is intended for defining additional object files for a target to be linked against By default Mxx_ru have a list of object files created during a compilation of source files and uses them during a link If project is required to include already compiled object file for example it may be created using other programming language compiler the name of file required should be passed into an obj_file method For example 1 MxxRu Cpp exe_target 2 ie 3 required_prj interface asm fast_transform prj rb 4 ds 5 obj_file interface asm fast_transform linear obj 6 7 Mxx_ru uses an obj_file method in toolset realization for saving an object file names of a project produced during a compilation of source files 6 13 Additional libraries linking lib method is intended for defining an additional libraries target need to link against By default Mxx_ru have a list of libraries required from subprojects But often you need to define a specific usually platform dependent library to link against 1ib method should be used in that case 1 MxxRu Cpp dll_target 2 ae 3 if mswin toolset tag target_os 4 lib winsock 5 elsif unix toolset tag target_os 6 lib socket 7 if bsd toolset tag unix_port 8 lib pthread 9 end 10 end 11 12 lib metho
53. d to set target name prefix explicitly For example for building plug ins thus Nuke expects that name of shared library will be the same with name of plug in e g without lib prefix target prefix method allows to do that 1 MxxRu Cpp dll_target 2 target scene_builder 3 target_prefix suppresing lib prefix addition 4 scene_builder so will be built 6 y 6 8 4 target ext target suffix method By default Mxx_ru detects final file extension from target type and platform For example for executable file exe target on Windows platform exe extension would be used and at the same time on Unix platform no extension would be at all In some cases it s required to set file extension explicitly For example for building plug ins thus Autodesk Maya expects mll extension for plug ins on windows platform or during port of Unix applications to Windows it may be required for dll s have so extensions target_ext method allows to do that MxxRu Cpp exe_target target security_monitor target_ext mod security_monitor mod will be built J MxxRu Cpp dll_target target raytracer target_suffix ml1 10 raytracer mll will be built Note Method target suffix is an alias for target_ext since version 1 4 2 CHAPTER 6 MXX_RU FOR C C PROJECTS 6 8 5 implib path method 50 First of all implib_path method forces Mxx_ru to build import lib
54. dded as compiler options for the projects Then pkg config is invoked with argument libs pkg config libs That could lead to L usr lib qt4 QtGui 1QtGui And those options will be set as linker options for the projects On the systems without pkg config e g Windows Qt generator will work without pkg config invocations So it is safe to use qt4_via_pkg_config even on systems without pkg config 9 2 3 Creation of Qt4 generator Qt4 generator is implemented in MxxRu Cpp Qt4 class To use it object of that class should be created in a project require mxx_ru cpp qt4 MxxRu Cpp exe_target qt generator MxxRu Cpp Qt4 new self CHAPTER 9 QT4 GENERATOR 80 The constructor of Qt4 class have two arguments a pointer to target object where gen erator would be used and a set of preprocessor symbols required to compile a project By default second argument is equal to QT_DLL QT_THREAD_SUPPORT In other words if Qt is used in DLL mode with multithreading support second argument may be omitted For all other cases second argument should contain all preprocessor symbols required for Qt version used For example for statically linked Qt but with multithreading support 1 require mxx_ru cpp qt4 2 3 MxxRu Cpp exe_target 4 5 generator MxxRu Cpp Qt4 new self QT_THREAD_SUPPORT 6 a 7 7 Note The support of those preprocessor symbols is
55. e 4 5 0 4 5 c_source get c 6 c_source maketables c 7 c_source pcre c 8 c_source study c 9 10 define PCRE_STATIC MxxRu Cpp Target OPT_UPSPREAD 11 define SUPPORT_UTF8 MxxRu Cpp Target OPT_UPSPREAD 12 13 include_path pcre MxxRu Cpp Target OPT_UPSPREAD 14 During a build of all projects directly or indirectly used pcre prj rb as a subproject PCRE_STATIC and SUPPORT_UTF8 define symbols would be used and pcre folder would be added to their include folders list 6 1 7 mxx cpp 1 argument Build and clean operation are not applied to subprojects if mxx cpp 1 argument was passed into Ruby interpreter Argument mxx cpp 1 is useful for a single subproject build inside a big composite project The whole composite could take too much time to be built It s wasteful espe cially in a case when recompilation and relinking are not needed for all other subprojects Subproject name and mxx cpp 1 argument are passed into Ruby interpreter instead of composite project name in that case ruby some project prj rb mxx cpp 1 mxx cpp 1 argument can be used for clean and rebuild operation also only subproject s files would be cleaned rebuilt in that case ruby some project prj rb mxx cpp 1 mxx clean ruby another project prj rb mxx cpp 1 mxx rebuild CHAPTER 6 MXX_RU FOR C C PROJECTS 44 6 1 8 mxx cpp no depends analyzer argument mx
56. e is MxxRu AbstractGenerator base class with two methods defined build and clean All generators should be inherited from that base class CHAPTER 5 THE BASIC IDEA 32 As long as different generators requires different approaches to work with Mxx ru doesn t specifies any other interfaces for generators There is only one requirement all generators should be passed to MxxRu AbstractTarget class using generator method Class inherited from MxxRu AbstractTarget is responsible to execute a generator For instance C target classes are executing generators after all subtargets are processed and just before a compilation process Since Mxx_ru does not define any interface to pass instructions to a generator usually usage of a generator looks like that require mxx_ru lt something gt require lt file describing a generator gt e WwW N MxxRu setup_target MxxRu lt target class gt new lt alias gt gen generator lt generator class gt new lt parameters gt gen lt some method gt lt parameters gt O 0 nD A 10 11 12 For example 1 require mxx_ru cpp 2 3 require oess_1 version 4 require oess_1 util_cpp_serializer gen 6 MxxRu Cpp dll_target 7 8 oe 9 ddl_cpp_generator generator 10 Oess_1 Util_cpp_serializer Gen new self 11 12 sources_root impl 13 14 sources_root db_struct 15 cpp_so
57. e should be turned on explicitly Otherwise if RTTI is not required in a project and code should be as fast as possible it may be efficient to turn RTTI off RTTI mode may be defined with a rtti mode method using these constants as a parameter MxxRu Cpp RTTI_DEFAULT project have no preference about RTTI usage MxxRu Cpp RTTI_ENABLED RTTI is required and MxxRu Cpp RTTI_DISABLED RTTI is not needed RTTI mode is a global parameter so it s applied to all projects at once An exception would be thrown if two projects will try to define different RT TI modes MxxRu Cpp dll_target target threads_1 4 0 1 2 3 4 rtl_mode MxxRu Cpp RTL_SHARED 5 threading_mode MxxRu Cpp THREADING_MULTI 6 rtti_mode MxxRu Cpp RTTI_ENABLED 7 8 Current RTTI mode is available through mxx_rtti_mode method 6 8 Setting target file name Note Projects described using MxxRu Cpp CompositeTarget class have no ex plicit target so target_root target target prefix target_ext target suffix and implib_path method calls are ignored 6 8 1 target_root method To define a folder containing a target file target_root method should be used The placement of result is controlled by obj_placement see on page 36 If target_root wasn t defined result would be in a folder chosen by obj_placement If target_root is defined result would be in a folder with name defined by target_root inside a folder chosen by obj_p
58. e te as ee theta at gia ok Se 79 80 80 Cas Bode ee ee Geek on Mee 2 OS 81 bode ade ds Fgh Pee hal eh wh we bi ea eee i 81 se be ga AAs age A ee wk ek 82 9 2 9 Output folder for moc tool 2 0 00002 ee ee 83 9 2 10 Output folder for uic tool aooaa ee 83 9 2 11 Output folder for rec tool 2 0 ee 83 9 2 12 Extension for source files generated 02 84 9 2 13 Extension for header files generated 84 9 2 14 Extension for moc files generated 2 84 9 2 15 The file name of moc tooll 2 22020000 84 9 2 16 The file name of uic tool 2 2 20 2 2 2 84 9 2 17 The file name of rec tool 2 ee ee 85 9 2 18 The file name of lupdate tool and custom lupdate options 85 CONTENTS 5 86 a a a AAA A a See 86 cat a A 87 e 58 10 3 1 cpp composite cpp dll cpp exe cpp lib cpp lib collection 88 10 3 2 cpp build root o ee 90 a os a 90 10 4 1 bin unittestl ee 90 reten 91 A a a A in e S 91 nok a ds a ENE 92 93 Les gaye ae Se ee ne id 93 ae db dy ea sr dda ea 94 ias 94 A ee eee 94 94 95 a S Ree ue te eee ane ee 95 A Boats Oo ee ae el es a ree E 96 ROS ay Sat eee ee et at cs ees ete 96 te cn gOS eee he ee Ba 97 bb atid onion ee Med 97 Km Res Gag Hw FoR ER Oo eg eas 97 asa Re E eh Hee eb God 97 A 2 12 The file name of uic tool Chapter 1 Introduction 1 1 About Mxx_ru Mxx ru
59. el C Windows Table 6 1 Toolset names defined Toolset tags As long as toolset adapted for a specific compiler on specific platform toolset may be used in a project for tuning it for specific platform Tags conception is introduced for that purposes Tag is an unique text key with a text value attached Tags are defined by toolsets themselves and also they may be defined during Mxx_ru setup process Values of tags are available through tag a name a_default nil method Value of tag is returned if tag with name defined is exists in a toolset Otherwise value of a_default argument is returned If tag wasn t defined and a_default nil MxxRu Cpp Toolset UnknownTagEx exception is thrown Some tags are mandatory so they should be defined for all toolsets and all platforms see table 6 2 host_os Operating system build process was run on target_os Operating system build process was run for Table 6 2 Mandatory tags for all toolsets Values for host_os and target_os may vary if cross compiler is used in case of c89 for HP NonStop as an example Operating systems are identified by the names enumerated in the 6 3 table CHAPTER 6 MXX_RU FOR C C PROJECTS 36 mswin 32 bit version of Microsoft Windows tandem_oss OSS subsystem Open System Services for HP NonStop unix different ports of Unix Table 6 3 The names of op
60. ems Mxx_ru 1 4 0 lib mxx_ru generators cpp lib c ruby 1ib ruby gems 1 8 gems Mxx_ru 1 4 0 1ib mxx_ru generators cpp lib collection c ruby 1lib ruby gems 1 8 gems Mxx_ru 1 4 0 1ib mxx_ru geherators shows that five templates are available cpp composite cpp dll cpp exe cpp lib cpp lib collection and all them are a part of Mxx_ru version 1 4 0 CHAPTER 10 PROJECT FILE STUB GENERATORS 88 The option help forces the mxxrugen to print only mxxrugen own otions Templates can have their own lists of options A concrete template must be launched with the help option to get to know a list of this template specific options gt mxxrugen cpp lib collection help Stubs for C C projects generator LibCollection target generator Usage mxxrugen lt mxxrugen options gt cpp lib collection lt options gt t target NAME Target name o output file FILE Output file name h help Show this message gt mxxrugen cpp dll help Stubs for C C projects generator DLL target generator Usage mxxrugen lt mxxrugen options gt cpp d11 lt options gt t target NAME Target name o output file FILE Dutput file name implib path PATH Import library path name h help Show this message Notice A support of the help option is a feature of standard Mxx_ru templates Non standard templates which are included by the include path may not follow this convention 10 3 Standard template
61. en added to MxxRu Cpp Toolset 8 1 4 on page 74 The MxxRu NegativeBinaryUnittestTarget target type has been added as ad dition for MxxRu BinaryUnittestTarget 3 2 Version 1 5 Mxx_ru has been moved to Ruby 1 9 1 Older versions of Ruby are not supported in versions 1 5 Support for Visual C 10 0 has been added Initial support for Intel C on Windows has been added Tested on Intel Parallel Studio 2011 3 3 Version 1 4 Support for Mac OS X has been added Support for Qt4 has been added For more details see 9 on page Support for Visual C 9 0 has been added A new target type for C C projects has been added MxxRu Cpp Lib Collection For more details see 6 1 3 on page A new approach of checking command line arguments has been released Now if a project file is started with argument help then a list of options which are available for this project s type is shown Command line arguments are checked now and unknown arguments lead to the error 11 CHAPTER 3 VERSIONS MXX_RU 12 Custom names of compiler linker librarian and so on can be specified now It is sometimes necessary to start some special version of compiler instead of the standard one For example gcc336 must be used for legacy code when the standard compiler is GCC version 4 Or remote_cl is used for launching cl on a remote host In such situations it is possible to specify names of tools in MXX_RU_CPP_TOOLSET environment variable
62. erating systems For unix platform unizx_port tag is also mandatory It defines the port of unix system It is recommended to use values enumerated in the 6 4 table bsd FreeBSD NetBSD OpenBSD cygwin Cygwin on Microsoft Windows darwin Mac OS X linux GNU Linux solaris Sun Solaris Table 6 4 Unix port names There is more tags may be defined during a Mxx ru setup Example MxxRu Cpp dll_target We want to place results to lib folder on Unix if unix toolset tag target_os target_root lib end target my If any other architecture of CPU used different from Intel x86 it s name should be defined in arch tag if x86 toolset tag arch x86 else end 6 1 2 obj_placement conception Mxx ru allows to control a place to store C C project build results in obj_placement is used for that purposes it s an object of a class inherited from MxxRu Cpp 0bjPlacement That object tells to Mxx_ru where to store object files li braries compiled resources and so on Project may define the type of obj_placement it needs obj_placement should be used for that 2 1 MxxRu Cpp dll_target my rb Other values will be added according to adaptation of Mxx_ru to other platforms CHAPTER 6 MXX_RU FOR C C PROJECTS 37 3 obj_placement 4 MxxRu Cpp RuntimeSubdir0bjPlacement new 5 output 6 7
63. ers There is two serious lacks in the example above 1 All files including headers sources project results of compilation and linking are inside one folder For example these files are located in that folder after building g project on Cygwin platform exe_dl1_lib exex inout cpp inout hpp inout rb libinout a libinout sox libsay a main cpp o prj rb say cpp say hpp say rb It s obvious there would be hard to work in case of growing amount of files in a project 2 Each project file contains include_path instruction It would be more conve nient to have one place to set common parameters for a group of subprojects It is necessary to place each subproject in individual directory under one global folder of project in order to overcome the first lack Assume the following structure of folders and files in our example CHAPTER 4 EXAMPLES 22 inout inout cpp inout hpp prj rb b main main cpp prj rb say prj rb say cpp say hpp puild rb lib folder is intended to store static and shared libraries 4 4 1 say Subproject Here is files say subproject contains e say hpp header file if defined _SAY_HPP_ define _SAY_HPP_ a e N include lt iostream gt include lt string gt void say_hello std ostream amp to const std string amp where 9 void 10 sa
64. es in case sensitive manner A comparison is interrupted on first mismatch In a clean method MxxRu TextfileUnittestTarget class removes all files defined as output file names defined in a first argument of pair method clean method is called when mxx clean argument was passed into Ruby interpreter Chapter 9 Qt4 generator 9 1 Introduction This chapter describing a C files generator required if Qt4 library http www is used The described generator was tested on Qt version 4 4 3 At use of Qt library there is a necessity of C files generation with Qt4 tools in the following cases 1 When a class inherited from QObject is defined in a header file and slots or signals are defined in that class In that case source file should be created from header file containing implementation of slots and signals For generation moc tool should be used Usually moc_a cpp file would be generated from a h file In other words extension is changed to cpp and moc_ prefix is added to the name of file 2 When a class inherited from QObject is defined in a source file In that case additional source file should be created and included into the main source file using include directive 1 2 class MyWidget public QWidget 1 3 4 include mywidget moc For generation moc tool is used Usually a moc file would be generated from a cpp file In other words extension is changed to moc 3 From ui file prod
65. es generation with moc and ui tools cpp extension is used It may be changed by changing a cpp ext attribute value 1 qt generator MxxRu Cpp Qt4 new self qt cpp_ext CC qt h2moc h mywidget H wn From h mywidget H file h mywidget CC file would be generated 9 2 13 Extension for header files generated By default during a header files generation with ui tool h extension is used It may be changed by changing a hpp ext attribute value qt generator MxxRu Cpp Qt4 new self qt hpp_ext H gt ui myform ui wo N e From myform ui file ui_myform H file would be generated 9 2 14 Extension for moc files generated By default during a moc files generation with moc tool moc extension is used It may be changed by changing a moc_ext attribute value 1 qt generator MxxRu Cpp Qt4 new self qt moc_ext cpp moc qt cpp2moc mywidget cpp w N From mywidget cpp file mywidget cpp moc file would be generated 9 2 15 The file name of moc tool The file name for moc tool is located in moc_name attribute By default it s equal to moc Changing the value of that attribute allows to set another file name used to run moc tool 1 qt generator MxxRu Cpp Qt4 new self qt moc_name usr src custom qt 4 5 bin moc N 9 2 16 The file name of uic tool The file name for uic tool is located in uic_name attribute By de
66. es it s reference file of a result And the whole library testing would consists in execution of test application with prepared source file as an input and comparing it s result with a reference That testing scenario also may be applied in cases when testing unit s result depends from source data It would be even better if simple procedure for adding replacing source data without recompiling of a unit test application For instance for libraries performing calculations encoding decoding creating checking of cryptographic signature e t c That CHAPTER 8 UNIT TESTING SUPPORT 75 kind of testing is also applicable into a cases when success of test may be determined by comparison of log files For support of testing that way Mxx_ru gives MxxRu TextfileUnittestTarget class It may be used in a way similar to MxxRu BinaryUnittestTarget it s necessary to create two project files first is responsible for building unit test application and second is responsible to run it with different parameters and analyze it s result 8 2 1 MxxRu TextfileUnittestTarget class MxxRu TextfileUnitestTarget class is intended for defining a targets running one unit test application with different parameters and comparing results after each run with reference results In order to use that class mxx_ru textfile_unittest file should be included into a project require mxx_ru textfile_unittest 1 2 3 MxxRu setup_target 4 MxxRu Te
67. et gt manifest kind for all projects in which there are no own adjustments for work with the manifests The default manifest description may be done in any project Notice however that Mxx_ru will not show any warning if there are several different descriptions would appear Therefore it is recommended to do this description in one place in build rb file To cancel actions of rules by default it is necessary to call MxxRu Cpp Toolsets Vc8 manifest with nil value CHAPTER 6 MXX_RU FOR C C PROJECTS 63 MxxRu Cpp Toolsets Vc8 manifest nil 6 16 2 The name of the manifest file for generation of the manifest by a linker The autogen parameter of a MxxRu Cpp Toolsets Vc8 manifest method speci fies that manifest file should be generated by a linker But it is necessary to specify to the linker in what file the generated manifest should be written down If to_default_file is given as autogen value then Mxx _ru generates manifest file name by itself manifest is added to the full target name Also as autogen value file name may be defined In that case manifest is written down to the file given For example this MxxRu Cpp Toolsets Vc8 manifest target gt self 3 autogen gt to_default_file N would force Mxx ru to generate manifest file name by itself Whereas that MxxRu Cpp Toolsets Vc8 manifest 2 target gt self 3 autogen gt
68. export MXX_RU_CPP_TOOLSET gcc_linux compiler_name gcc336 For more details see on page An ability of project file stub generation has been added A project file stub generator has been added into Mxx_ru to avoid manual creation of most widespread types of project files For example if the following command had been run mxxrugen cpp lib t my_lib o my lib prj rb then file my 1ib prj rb would be created with the content similar to require rubygems gem Mxx_ru gt 1 3 0 1 2 3 4 5 require mxx_ru cpp 6 7 MxxRu Cpp lib_target 8 9 Define your target name here 10 target my_lib 11 12 Enumerate one or more required projects 13 required_prj some project 14 15 Enumerate your C C files here 16 c_source C source file 17 cpp_source C source file 18 19 For more details see 10 on page 3 4 Version 1 3 Libraries list creation method has been changed for GCC toolset The names of all libraries are now inside W1 start group and W1 end group option pair This allows to set library names in random order in project file It was required to set them keeping dependencies resolution order in mind in earlier versions The names of modules and classes of Mxx_ru are now brought to confor mity with standard conventions of Ruby language Now MxxRu is used instead of Mxx_ru AbstractTarget instead of Abstract_tar
69. f Mxx_ru can catch an exception then it does it and shows only description of exception lt lt lt cl tmpmxx_ru 2324 1 gt gt gt say cpp say say cpp 14 fatal error C1075 end of file found before the left brace at say say cpp 11 was matched lt lt lt Mxx_ru Build_ex Build error cl tmpmxx_ru 2324 1 returns 512 gt gt gt 7 6 Adding make rules into a project The basic idea of Mxx_ru consists in simplifying the most of typical actions required to be performed during a project build Because of that Mxx_ru provides a set of templates used to fill data in But sometimes capability provided by templates are not enough For example in current Mxx_ru version no support of localization in Qt applications If Qt project would require for instance to generate qm file from ready ts file it would be impossible to do using current Mxx_ru templates only It would be a good solution to build a feature required into Mxx_ru for using it in a future Qt projects but it s clear that rare developer using Mxx_ru to build his own projects would want to develop Mxx_ru itself In that cases it s only one method remains to use MxxRu MakestyleGenerator class allowing to include an arbitrary make rule into the project CHAPTER 7 ADDITIONAL FEATURES 70 require mxx_ru makestyle_generator generator MxxRu MakestyleGenerator new etc wms_ctl_1 ru qm etc wms_ctl_1 ru ts
70. f the large compound project In this case some project files may try to change a default value for the same parameter In this case Mxx_ru acts as follows e If all projects establish the same value Mxx_ru simply uses this value e If the projects try to establish different default values Mxx_ru takes only first call to default_ into account ignoring all others displaying the warning of the conflict of default values Because Mxx_ru uses only first value at the presence of the conflicts it is recommended to set default values in build rb to be sure such changes were carried out in one place As example it is possible to show how to establish default value for runtime_mode Release rtl mode Shared RTL and rtti_mode enabled for compound project require mxx_ru cpp MxxRu Cpp composite_target MxxRu BUILD_ROOT gt 4 default_rtl_mode MxxRu Cpp RTL_SHARED 1 2 3 4 os 5 default_runtime_mode MxxRu Cpp RUNTIME_RELEASE 6 7 default_rtti_mode MxxRu Cpp RTTI_ENABLED 8 9 CHAPTER 6 MXX_RU FOR C C PROJECTS 52 It is important to understand that the changed default values are used Mxx_ru only if the appropriate mode was not changed obviously For example default value for runtime mode is used only if mxx cpp release and mxx cpp debug keys were not specified in the command line 6 11 Source files definition 6 11 1 sources_root method By default source files are defined in relatio
71. fault it s equal to uic Changing the value of that attribute allows to set another file name used to run uic tool 1 qt generator MxxRu Cpp Qt4 new self qt uic_name usr src custom qt 4 5 bin uic N CHAPTER 9 QT4 GENERATOR 85 9 2 17 The file name of rcc tool The file name for rcc tool is located in rcc_name attribute By default it s equal to rcc Changing the value of that attribute allows to set another file name used to run rcc tool 1 qt generator MxxRu Cpp Qt4 new self qt rcc_name usr src custom qt 4 5 bin rcc N 9 2 18 The file name of lupdate tool and custom lupdate options The file name for lupdate tool is located in lupdate_name attribute By default it s equal to lupdate Changing the value of that attribute allows to set another file name used to run lupdate tool 1 qt generator MxxRu Cpp Qt4 new self qt rcc_name usr src custom qt 4 5 bin lupdate N The options for lupdate tool are contained in lupdate_options attribute By default they are noobsolete slient It is possible to specify those options by modifying lupdate_options value qt generator MxxRu Cpp Qt4 new self Remove option noobsolete and keep other options intact qt lupdate_options qt lupdate_options delete noobsolete Completely change options for lupdate qt lupdate_options pluralonly extensions
72. fix is added to the name of file 2 When a class inherited from QObject is defined in a source file In that case additional source file should be created and included into the main source file using include directive 1 2 class MyWidget public QWidget 1 3 4 include mywidget moc For generation moc tool is used Usually a moc file would be generated from a cpp file In other words extension is changed to moc 3 From ui file produced by Qt Designer header and source files should be created uic tool should be used for generation And then from generated header file additional source file for slots and signals implementation should be created with moc tool Usually from a ui file a hpp a cpp and moc_a cpp files are created Qt generator from Mxx_ru allows to work with all three cases described above 93 APPENDIX A QT3 GENERATOR 94 A 2 Qt generator usage A 2 1 Adding definitions required to a project file Qt generator definition is in a mxx_ru cpp qt rb file and should be included into a project file using a require directive require mxx_ru cpp qt w MxxRu setup_target A 2 2 Creation of Qt generator Qt generator is implemented in MxxRu Cpp QtGen class To use it object of that class should be created in a project 1 require mxx_ru cpp qt 2 3 MxxRu Cpp exe_target 4 wake 5 qt generator MxxRu Cpp QtGen new self
73. following directive would be written pa include some_header hpp This becomes important in some cases of project file structure organization New task test is added into Rakefile to automate run of Mxx_ru unit tests Some tests were converten into unit tests Special mix in TestWithCompilation was imple mented in tests test_with_compilation rb which makes easier creation of unit tests where compilation of test projects is needed Were added BinaryTarget lib_path BinaryTarget lib_paths methods With their help linker knows where to find libraries in case when it isn t convenient or even impossible to do with lib lib_static or lib_shared methods For more details see on page On Windows platform now definition of lib file extension for libraries is optional In previous versions of Mxx_ru it was actual for Visual C toolset Since version 1 3 this toolset checks availability of extension in the name of the library and adds it if needed Was added Cpp Targetittarget_ext method It allows to set any extension for build result For example for DLL it may be mll if we compiling Maya plugin for windows 1 MxxRu Cpp dll_target 2 target my_plugin 3 target_ext mll 4 5 CHAPTER 3 VERSIONS MXX_RU 14 For more details see on page Added mxx cpp extract options mode which forces Mxx_ru to show C C compiler and linker options Given mode allows to get options whi
74. get BinaryUnittestTarget instead of Binary unittest target and so on All old names are preserved as a synonims of new CHAPTER 3 VERSIONS MXX_RU 13 names therefore backwards compatibility is preserved Even in the given manual some examples using old names may be found Compatibility with old naming system will be preserved in the future names were changed just to avoid problems induced by non standard names in future evolution of Mxx_ru Added mxx rebuild mode 4 6 on page 27 Now this command ruby prj rb mxx rebuild is equivalent to this command sequence ruby prj rb mxx clean ruby prj rb Added BinaryTarget lib_static BinaryTarget lib_shared methods They allow to force Unix linker to use concrete type of given library Thus if lib_static method is used to define a library linker would use only static version of the library ignoring shared library with the same name For more details see 6 13 1 on page Added QtGenttuic_result_subdir method It defines which subfolder would be used to store results of uic utility from Trolltech Qt In earlier versions result files were stored in the same folder where source ui file was For more details see A 2 7 on page For uic utility when it ran for cpp file generation short name of hpp file is defined in i argumentuntethered I e instead of src module some_header hpp some_header hpp is sent Accordingly into generated cpp file the
75. ication Visual C compiler builds import library when it sees at least one exported symbol so import library would be built even without definition of implib_path It s recommended to define implib_path anyway for compatibility CHAPTER 6 MXX_RU FOR C C PROJECTS 51 MxxRu Cpp exe_target 1 2 ts 3 screen_mode MxxRu Cpp SCREEN_WINDOW 4 5 screen_mode parameter is a local parameter for a project and it s not applied nor for child projects nor for parent projects Current application type can be accessed using a mxx_screen mode method 6 10 Default values for some global parameters For such parameters as runtime_mode 6 4 on page 46 rtti_mode 6 7 on page 48 rt1_mode 6 5 on page and threading mode 6 6 on page 47 Mxx_ru uses special default values For example if runtime_mode is not explicitly set project would be compiled without optimization and debug information i e not release and not debug In some cases such behavior is not desirable For example to developer it may be more comfortable to build project in release mode by default Mxx_ru allows to change default values for given parameters For this purpose the meth ods with default _ lt parameter gt names are used For example default runtime mode default_rtti_mode etc It is supposed that these methods will be used in build rb for tuning of the whole project But they also can be used inside project files for subprojects o
76. implemented for compatibility with Qt3 support in earlier versions of Mxx_ru Qt4 seems not need such defines 9 2 4 Header files definition to generate signal slot implementation sources Header files used to generate source files with moc tool should be defined using h2moc method require mxx_ru cpp qt4 MxxRu Cpp exe_target 1 2 3 4 na 5 qt generator MxxRu Cpp Qt4 new self 6 sa 7 qt h2moc mywidget hpp 8 The names defined are searched from current value of sources root see 6 11 1 on page 52 In example above mywidget hpp file should be in some project folder And results of moc tool would also be placed in that folder From files defined with h2moc method source files are built with added moc_ prefix and extension changed to cpf So from some project mywidget hpp file some project moc_mywidget cpp file would be generated 9 2 5 Source files definition to generate signal slot implementation sources Source files cpp used to generate signal slot implementation source files moc with moc tool should be defined using cpp2moc method Taking value of moc_result_subdir into account see 9 2 9 9 2 9 2 9 on pag 83 21f it s not changed with cpp ext attribute see 9 2 12 9 2 12 2 12 0n page 84 El CHAPTER 9 QT4 GENERATOR 81 require mxx_ru cpp qt4 MxxRu Cpp exe_target qt generator MxxRu Cpp Qt4 new self qt cpp2moc mywidget cpp 0
77. ions e Intel C on Windows Intel Parallel Studio 2011 e GNU C on unix and windows MinGW and Cygwin platforms e c89 for HP NonStop native version and cross compiler from eToolkit for Windows e Clang C on Linux platform Toolset type should be defined during setup process see 6 2 on page for details otherwise it wouldn t work properly Toolset is an object of a class inherited from MxxRu Cpp Toolset Toolset object is created by Mxx_ru and used for a whole project project name passed to Ruby interpreter and all it s subprojects It s impossible to replace toolset object Access to toolset object is provided through toolset method 34 CHAPTER 6 MXX_RU FOR C C PROJECTS 35 Toolset names Each toolset have it s name available through name method of a MxxRu Cpp Toolset class That name can be used for tuning a project for specific compiler For example 1 MxxRu Cpp exe_target 2 ae 3 if vc toolset name 4 Visual C adaptation 5 cpp_source mswin vc exception_handler cpp 6 elif gcc toolset name 7 GNU C adaptation 8 cpp_source gcc exception_handler cpp 9 end 10 11 Table 6 1 shows already defined names of compilers for a moment bec Borland C Windows c89_nsk c89 for HP NonStop HP NonStop and Windows clang Clang C C Unix Mac OS X and Windows gcc GNU C C Unix Mac OS X and Windows vc Visual C Windows icc_win Int
78. ization is turned on NDEBUG macro is defined default Release runtime libraries are used Optimization is turned off NDEBUG macro is not defined so asserts would work This mode is used by default if no other mode was defined Runtime mode can be defined in two ways 1 2 runtime_mode function in project file For example MxxRu Cpp exe_target 1 runtime_mode MxxRu Cpp RUNTIME_RELEASE In command line using mxx cpp release or mxx cpp debug argument For ex ample ruby build rb mxx cpp release CHAPTER 6 MXX_RU FOR C C PROJECTS 6 1 6 Local global and upspread parameters C C project definition in Mxx_ru consists of parameters enumeration such as target file name source file names libraries and define symbols compiler and linker options etc Some of them such as source file names belongs to project itself But other part can be divided in three parts Local parameters applied to the project itself They have no effect on subprojects nor projects using that project as a subproject Here is an example of local define symbol MxxRu Cpp dll_target target my_dl1 implib_path lib cpp_source my_d11 impl1 cpp defines MY_DLL_PRJ 00 s Dm a e N e Symbol MY_DLL_PRJ if set this way will be available only during a build of my_d11l impl cpp Global parameters are applied to all projects Global parameters are defined using
79. lacement For instance if obj_placement stores files to current folder then if target_root was set to out32 resulting file would be in out32 subfolder of current folder Important It s required to call target_root method before target method call Then during a target execution the name of a target will be created using the target_root value If target_root method is called after a target then already defined filename is modified In a general case if target_root and target are called only once results would be identical But if target_root would be called twice before and after target call result may be different then expected CHAPTER 6 MXX_RU FOR C C PROJECTS 49 6 8 2 target method To define a base name of target file target method should be used Real name would be created with all platform specifics taken into account For example for shared library with base name threads_1 4 0 on windows platfotm threads_1 4 0 dll would be created and on unix platform libthreads_1 4 0 s0 Target name passed into target method should not include any path target_root method should be used to define folder where target should be created before calling a target method 6 8 3 target_prefix method By default Mxx_ru follows platform specific rules for building resulting name of the target For example static and shared libraries on Unix must have prefix lib e g mylib becomes libmylib In some cases it s require
80. lates for unit tests 10 4 1 bin unittest This template is intended for generation of stubs for unit test of MxxRu BinaryUnittestTarget 8 1 on page type Synopsis bin unittest lt path name gt lt template options gt where template options are e o output file FILE optional option which specifies file s name where the gen erated stub must be saved If that name is not specified then the generated stub is printed to the standard output If the path name argument is specified at the generator start mxxrugen bin unittest some my test then that name is used in the body of the generated stub CHAPTER 10 PROJECT FILE STUB GENERATORS 91 require rubygems gem Mxx_ru gt 1 3 0 require mxx_ru cpp Set path to your unit test projet here path some my test oO 0 N OQ A e N MxxRu setup_target MxxRu BinaryUnittestTarget new Set name of your unit test project here path prj ut rb Set name of your project to be tested here path prj rb e RB e e N e ou If the path name is missed but the output file is specified mxxrugen bin unittest o hello hello test rb then the path to output file is used in the generation as if it had been specified as jpath name argument 1 require rubygems 2 3 gem Mxx_ru gt 1 3 0 4 5 require mxx_ru cpp 6
81. lib ruby site ruby on Unix In such case Ruby can automatically find Mxx_ru because these paths used by Ruby as default paths for searching Ruby libraries Also it s possible to check out Mxx_ru into any folder you prefer and define the RUBYLIB environment variable This variable should be the directory where a Mxx_ru archive was checked out For example on Microsoft Windows platform it may be set RUBYLIB d my mxx_ru Or on Unix platform export RUBYLIB my mxx_ru Now you have to setup Mxx_ru for languages and tools you planning to use Note Under some Ruby installation where RubyGems was not installed as part of Ruby by default may be required to specify Ruby interpreter to use rubygems with any Ruby script export RUBYOPT rubygems 2 2 1 Setting up Mxx_ru for C C projects MXX_RU_CPP_TOOLSET environment variable should be defined to use Mxx_ru with a C C projects The syntax used to define this environment variable is as follows MXX_RU_CPP_TOOLSET lt file gt tag value tag value where lt file gt is the name of rb file from Mxx_ru responsible for C C toolset object creation For example bcc_win32_5 Borland C 5 compiler on Microsoft Windows platform clang_linux Clang compiler on Linux platform ve7 Visual C 7 compiler on Microsoft Windows platform vc8 Visual C 8 compiler on Microsoft Windows platform vc9 Visual C 9 compiler
82. ll can be built A constructor of a MxxRu MakestyleGenerator class expecting 4 arguments the last one is optional a target files names of target files for make rule a_dependencies names of dependencies for make rule a_build_cmds A list of commands for building target files a_clean_cmds A list of commands for cleaning up By default target files would be deleted If only one value would be passed into a constructor argument it may be passed using a string as in example above If several values are required to be passed they should be defined as a vector 1 generator 2 MxxRu MakestyleGenerator new 3 Target file names 4 a hp o 5 One dependency for all targets CHAPTER 7 ADDITIONAL FEATURES 71 6 des 7 Build of a targets commands 8 9 make_a 10 make_b_c 11 1 12 Cleanup commands 13 14 destroy_a 15 destroy_b 16 destroy_c 17 18 3 During a build of target files MxxRu MakestyleGenerator runs commands from a_build_cmds argument in specified order If some command returns exit code other then zero exception is thrown During a cleanup process exit codes of commands from a_clean_cmds argument are ignored Chapter 8 Unit testing support 8 1 Unit testing with binary applications 8 1 1 Definition of unit test application Unit test application is a binary application containing unit test code responsible to test some units The success of u
83. lude lt inout inout hpp gt 4 5 inout_t inout_t 6 const std string amp method 7 m_method method 8 9 say_hello std cout method 10 11 12 inout_t inout_tQ 13 14 say_bye std cout m_method 15 Also notice that you have to point subproject name in include directive to load header files from that subproject lt say say hpp gt lt inout inout hpp gt e prj rb project file 1 require mxx_ru cpp 2 3 MxxRu Cpp dll_target 4 target inout 5 implib_path lib 6 7 required_prj say prj rb 8 9 define INOUT_PRJ 1 11 if mswin toolset tag target_os 12 define INOUT_MSWIN 13 end 14 15 cpp_source inout cpp 16 4 4 3 main subproject Here is the files Main subproject contains e main cpp implementation file tinclude lt iostream gt include lt inout inout hpp gt e N e void 6 some_func al CHAPTER 4 EXAMPLES 25 7 8 inout_t braces some_func 9 10 std cout lt lt Some functionality lt lt std endl 11 12 13 int 14 main 15 16 inout_t braces main 17 18 std cout lt lt Exe dll lib main lt lt std endl 19 20 some_func 21 22 return 0 23 e prj rb project file require mxx_ru cpp MxxRu Cpp exe_target target exe_dll_lib required_prj inout prj rb 00 XA Q al e
84. mpl storage 8 This may be handy when project allows to compile itself using different tools CHAPTER 6 MXX_RU FOR C C PROJECTS 53 9 sources_root impl 10 For files in folder oess_1 db impl storage impl 11 12 13 14 15 sources_root site 16 For files in folder oess_1 db site 17 sae 18 sources_root impl 19 For files in folder oess_1 db site impl 20 21 22 23 24 Both methods may be combined For example you may call sources_root with one parameter for a first time and then call it with two parameters MxxRu Cpp exe_target mxxru_prjs interface rb sources_root src interface 1 2 3 4 files from src interface folder 5 c_source main c 6 cpp_source io cpp 7 8 9 sources_root debug files from src interface debug folder 10 cpp_sources io_dumper cpp Current value of sources_root can be obtained by method mxx_sources_root 6 11 2 c_source s cpp_source s methods c_source and cpp_source methods are intended for including source files into a project for C and C languages correspondingly It s important to define all files containing C code only usually they have c extension using a c_source method and files contain ing C code usually they have C cc cp cpp cxx or c extensions using a cpp source method Thats important because different compilers may be used for them
85. multithreading is required MxxRu Cpp THREADING SINGLE singlethreading is required the project can t work in a multithreaded environment By default MxxRu Cpp THREADING_DEFAULT mode is used If threading mode is not equal to MxxRu Cpp THREADING_MULTI and compiler has a requirement to set threading mode explicitly singlethreaded mode is used Threading mode is a global parameter so it s applied to all projects at once An exception would be thrown if two projects will try to define different threading modes 1 MxxRu Cpp dll_target 2 target threads_1 4 0 3 4 rtl_mode MxxRu Cpp RTL_SHARED 5 threading_mode MxxRu Cpp THREADING_MULTI 6 Joa 7 Current threading mode is available through mxx_threading mode method Note For some compilers Visual C for example the names for RTL libraries used are depended on both RTL type and threading mode And compiler may not have libraries for all combinations of RTL types and threading modes For example Visual C 7 doesn t have a singlethreaded shared RTL library and for Visual C 8 RTL libraries for multithreaded mode only are available CHAPTER 6 MXX_RU FOR C C PROJECTS 48 6 7 RTTI mode selection Run Time Type Identification RTTI is turned off by default on some compilers Visual C for example or may be turned off GNU C for instance If project requires RTTI for safe dynamic_cast usage as example then RTTI mod
86. mxx_ru 896 1 c TP Fosay o say obj nologo ML I GX say say cpp gt gt gt lt lt lt cl Otmpmxx_ru 896 1 gt gt gt say cpp lt lt lt tmpmxx_ru 896 2 NOLOGO OUT 1lib say lib say o say obj gt gt gt lt lt lt lib Otmpmxx_ru 896 2 gt gt gt lt lt lt tmpmxx_ru 896 3 c TP Foinout o inout obj nologo ML LD DINOUT_PRJ DINOUT_MSWIN I GX inout inout cpp gt gt gt lt lt lt cl tmpmxx_ru 896 3 gt gt gt inout cpp lt lt lt tmpmxx_ru 896 4 DLL NOLOGO SUBSYSTEM CONSOLE OUT inout d1ll IMPLIB 1ib inout lib LIBPATH lib inout o inout obj say lib gt gt gt lt lt lt link Otmpmxx_ru 896 4 gt gt gt Creating library lib inout lib and object lib inout exp lt lt lt tmpmxx_ru 896 5 c TP Fomain o main obj nologo ML I GX main main cpp gt gt gt lt lt lt cl Otmpmxx_ru 896 5 gt gt gt main cpp lt lt lt tmpmxx_ru 896 6 NOLOGO SUBSYSTEM CONSOLE 0UT exe_d11_lib exe LIBPATH 1ib main o main obj inout lib gt gt gt lt lt lt link Ctmpmxx_ru 896 6 gt gt gt 7 4 mxx dry run argument If mxx dry run argument is passed to Ruby interpreter Mxx_ru would perform only imitation of project build That means all projects are processed all command strings are created including response files creation but tools itself are not executed It s useful to use this argument during a project files debug in combination with mxx show cmd mx
87. n to project s file folder In other words if project alias is interface prj rb then c_source main c cpp_source io cpp N o e construction will force Mxx_ru to search for interface main c and interface io cpp files That way is handy for small projects but sometimes there is a need to explicitly define where to search for source files 1 When sources are placed in other branch of project file structure For example all project files are placed in mxxru_prjs but source files are inside srd Then sources_root method should be called with a single parameter MxxRu Cpp exe_target mxxru_prjs interface rb sources_root src interface c_source main c cpp_source io cpp 00 XA oa e Qu N H 2 When project file structure is too deep It s inconvenient to define full path for each source file sources_root method may be called with two parameters folder name and code block In that case sources_root method works this way it concatenates current source_root value with the first argument and sets result as a new sources_root parameter After that it runs code block was passed to it and restores previous source_root value And this even allows to call sources_root inside that code block MxxRu Cpp d11_target oess_1 db prj rb sources_root impl 4 For files in folder oess_1 db impl sources_root storage 1 2 3 4 6 7 For files in folder oess_1 db i
88. nit test is detected by exit code returned by unit test application If unit test application returns zero the tests are successful 8 1 2 The basic idea For unit test support it s necessary to create two project files First is responsible for building unit test application and second is responsible to run it and analyze it s result It s supposed that project have a composite project file describing all subprojects Unit test project files should be also included into that list In result it turns out that during a build of composite project unit test application is also built and executed If unit test is completed successfully composite project build process would be continued Otherwise build process would be interrupted 8 1 3 Unit test target class In Mxx_ru object of MxxRu BinaryUnittestTarget class is required to include unit test into a project build process File mxx_ru binary_unittest should be included in order to use that class require mxx_ru binary_unittest 1 2 3 MxxRu setup_target 4 MxxRu BinaryUnittestTarget new 5 some project prj ut rb 6 some project prj rb 7 That class gets all it s parameters from it s constructor it s own alias and project name responsible to build unit test application That is the difference of unit test vs regression test in Mxx_ru It s required all unit tests to be suc cessful 72 CHAPTER 8 UNIT TESTING SUPPORT 8 1 4 Ex
89. on Microsoft Windows platform vc10 Visual C 10 compiler on Microsoft Windows platform vc11 Visual C 11 Visual Studio 2012 compiler on Microsoft Windows platform vel2 Visual C 12 Visual Studio 2013 compiler on Microsoft Windows platform gcc_darwin GNU C compiler on Mac OS X platform CHAPTER 2 INSTALLATION 10 gcc linux GNU C compiler on Unix platform including FreeBSD and Linux gcc _sparc_ solaris GNU C compiler on SPARC Solaris platform gcc_cygwin GNU C compiler from Cygwin package on Microsoft Windows platform icc_win Intel C Compiler on Microsoft Windows platform c89_nsk c89 compiler on HP NonStop platform in Open System Services environment The pairs tag and value would be defined as a tags for selected C C toolset Examples export MXX_RU_CPP_TOOLSET gcc_linux unix linux arch x86 set MXX_RU_CPP_TOOLSET vc7 set MXX_RU_CPP_TOOLSET bcc_win32_5 Chapter 3 Versions Mxx ru The following chapter describes all changes in Mxx_ru during version changes It s intended to give compact information of changes in Mxx_ru to advanced users to avoid them search for that changes in the whole text This chapter may be skipped by beginners 3 1 Version 1 6 Mxx_ru has been moved to Ruby 2 0 and 2 1 Support for Visual C 11 0 and 12 0 has been added Support for Clang C compiler on Linux platform has been added Methods force_cpp03 force _cpp11 and force cpp14 have be
90. on some platforms for example gec and g for GNU C On other platforms special compiler parameters are required to tell compiler about type of code passed into it Mxx_ru considers all these features and actively uses them c_ source and cpp_source have two arguments first is required and second is optional The first is source file name Second may contain compiler options added to selected by Mxx ru during a compilation of that file only Usually only one argument is passed CHAPTER 6 MXX_RU FOR C C PROJECTS 54 MxxRu Cpp dll_target required_prj oess_1 defs prj rb Oess_1 setup_platform self target oess_io Oess_1 VERSION define OESS_1__I0__PRJ cpp_source stream cpp cpp_source binstream cpp cpp_source binbuffer cpp cpp_source subbinstream cpp cpp_source mem_buf cpp cpp_source fixed_mem_buf cpp cpp_source bstring_buf cpp Two parameters are used if some file requires specific compiler options define symbol for example e N RP cpp_source interface cpp DLOG_LEVEL 3 cpp_source engine cpp LOG_LEVEL would be defined during compiling of interface cpp only but not for an engine cpp Two parameter version of c_source and cpp_source methods should be used carefully considering following factors e If project may be compiled with more than one compiler different options may be required In other words all these op
91. processing Mxx_ru supports both forms of resources For textual form qrc2cpp method should be used Tf it s not changed with cpp_ext attribute see on page 84 5If it s not changed with hpp_ext attribute see 9 on page 84 Taking value of uic_result_subdir into account see 9 2 10 on page 3Taking value of moc_result_subdir into account see on B CHAPTER 9 QT4 GENERATOR 82 qt generator MxxRu Cpp Qt4 new self sources_root sample qt qrc2cpp basic qrc F N QO a Ae W N e In that case sample basic cpp file will be generated and will be added to the list of project s source files The extension depends from cpp ext attribute 9 2 12 0n page 84 For binary form qrc2rcc method should be used MxxRu Cpp exe_target target bin32 sample qt generator MxxRu Cpp Qt4 new self sources_root plugins qt qrc2rcc plugins qrc In that case bin32 plugins rcc file will be generated Please take into account that for binary resource form the result files is placed into the same directory with projects target 9 2 8 TS files definition Qt4 can make ts files via lupdate tool Those files are defined using ts method MxxRu Cpp exe_target 1 2 or 3 qt MxxRu Cpp Qt4 new self 4 qt ts translations client_ru ts 5 qt ts translations client_fr ts 6 7 During the build Qt4 generator will run lupdate
92. project handling depends from project type but if we proceed from common sense we may assume all subrojects build methods are called from build method of basic project At least this is true for C projects required_prjs method Starting from version 1 2 in Mxx ru required prjs method exists which gets an object of Enumerable type as an argument This allows to rewrite an example above with the following 1 require mxx_ru cpp 2 3 MxxRu Cpp composite_target MxxRu BUILD_ROOT 4 4 5 global_include_path 6 7 required_prjs oess_1 stdsn prj rb 8 0ess_1 scheme prj rb 9 0ess_1 util_cpp_serializer prj rb 10 0ess_1 file prj rb 11 0ess_1 db prj rb 12 o0ess_1 util_ent_enum prj rb 13 0ess_1 util_slice_create prj rb 14 0ess_1 tlv prj rb 15 Also class Dir from standard Ruby library can be used 1 require mxx_ru cpp 2 3 MxxRu Cpp composite_target MxxRu BUILD_ROOT 4 4 5 global_include_path 6 7 required_prjs Dir oess_1 prj rb s y here Dir is used to recursively search all prj rb files in subfolders of oess_1 folder A combination of classes from standard Ruby library and abilities of Ruby language itself allows to use required_prjs with much more complicated constructions For example the project file written below is intended for compilation of all tests placed in subfolders of tes
93. r function MxxRu Cpp d11 target e MxxRu Cpp MacOSBundleTarget for building shared libraries in the form of MacOS bundles Can be created by helper function MxxRu Cpp macos_bundle_target CHAPTER 6 MXX_RU FOR C C PROJECTS 39 e MxxRu Cpp CompositeTarget for composite projects Can be created by helper function MxxRu Cpp composite_target e MxxRu Cpp LibCollection for building and using several libraries static of shared at the same time Can be created by helper function MxxRu Cpp lib_collection_target Object of one of that classes should be created and passed into MxxRu setup_target function for C C projects All classes have constructors allowing to get a code block it s a Ruby language specific So there is no need to create a new class inherited from one of above It s enough to create an object of existing class and pass a code block to it s constructor with all tuning inside that block MxxRu Cpp exe_target Note To ensure Ruby knows that code block is a parameter opening brace should be placed on the same line with a closed round brace of constructor call For example Right MxxRu Cpp exe_target target my c_source my c 1 2 3 a Right 5 MxxRu Cpp exe_target target my 6 c_source my c 7 8 9 Right MxxRu Cpp exe_target 10 target my 11 c_source my c 12 13
94. rameter gt is the name of parameter First function is used to define local or upspread parameter The value of the parameter would be a local if a_type argument would have MxxRu Cpp Target OPT_LOCAL value or wouldn t be defined If a type argument would have the MxxRu Cpp Target OPT_UPSPREAD value then the value of the parameter would be automatically spread to all projects requiring this project Function with a global_ prefix is used to define a global parameter applied to all projects Functions intended for defining a local upspread and global parameters are described in this section 6 15 1 include_path global_include_path Functions include_path and global_include_path are used to define search path s for header files 6 15 2 define global_define Functions define and global_define are used to set preprocessor define symbols used during compilation of C C files 6 15 3 compiler_option global_compiler_option Functions compiler_option global_compiler_option are used to define additional compiler options for both C and C files 6 15 4 c_compiler_option global_c_compiler_option Functions c_compiler_option global_c_compiler_option are used to define addi tional compiler options for C files only 6 15 5 cpp_compiler_option global_cpp_compiler_option Functions cpp_compiler_option global_cpp_compiler_option are used to define ad ditional compiler options for C files only 6 15 6 linker_option global _linker
95. rary on platforms supporting this feature and secondly it defines where this library should be placed implib_path is used for shared libraries only for a moment If implib_path wasn t called import library isn t built Fl 6 8 6 Examples Application name definition 1 MxxRu Cpp exe_target 2 target hello_world 3 4 Placing application inside utest folder 1 MxxRu Cpp exe_target 2 target_root utest 3 target test_packer 4 5 Target shared library should be placed into a current folder on Windows platform and import library into a lib folder but on Unix platform target shared library should be placed into a lib folder also 1 MxxRu Cpp dll_target 2 if mswin toolset tag target_os 3 implib_path lib 4 elsif unix toolset tag target_os 5 target_root lib 6 end 7 8 target oess_defs 1 3 0 9 10 6 9 Selecting an application type GUI Console screen_mode method is intended for application type definition it may be windowed or be console By default Mxx ru is creating a console application special options are defined for compiler and linker Using a screen_mode method project may be transformed into a windowed application MxxRu Cpp SCREEN_WINDOW constant should be passed into the screen_mode method for creating a windowed application or MxxRu Cpp SCREEN_CONSOLE constant for console appl
96. rget Define your target name here target hello world N QD wow gt Ww N If the option target is missed but path s name is specified the path name argument then target s name is produced form path s name all slashes are substituted by points mxxrugen cpp exe some my hello world that produces MxxRu Cpp exe_target Define your target name here target some my hello world N ou e N e If neither target s name nor path s name is specified at the generator start that the notice about necessarity of manual inclusion of those names is inserted into the generated stub For example mxxrungen cpp dll generates CHAPTER 10 PROJECT FILE STUB GENERATORS 90 1 TE 2 MxxRu Cpp dll_target 3 4 Define your target name here 5 target your target name 6 7 Define your import library path here 8 implib_path your import library path 9 10 10 3 2 cpp build root This template is intended for generation of stubs for project build root files which usually have name build rb Synopsis cpp build root lt template options gt where template options are e o output file FILE optional option which specifies file s name where the gen erated stub must be saved If that name is not specified then the generated stub is printed to the standard output 10 4 Standard temp
97. s for C C projects 10 3 1 cpp composite cpp dll cpp exe cpp lib cpp lib collection Those templates is intended for generation of project files of the corresponding types see table cpp composite MxxRu Cpp CompositeTarget cpp dll MxxRu Cpp DllTarget cpp lib MxxRu Cpp LibTarget cpp exe MxxRu Cpp ExeTarget cpp lib collection MxxRu Cpp LibCollection Table 10 1 The correspondence between the names of standard C C templates and the types of C C projects Those templates have single implementation and because of that support the following command line format lt template name gt lt path name gt lt template options gt CHAPTER 10 PROJECT FILE STUB GENERATORS 89 where template options are e t target NAME optional option which specifies project s target name e o output file FILE optional option which specifies file s name where the gen erated stub must be saved If that name is not specified then the generated stub is printed to the standard output e implib path PATH optional option which specifies path s name where the import library is resided This option is used only for templates cpp dll and cpp exe e h help shows short usage help If the option target is specified at the generator start then its value is used as target s name mxxrugen cpp exe t hello world that produces MxxRu Cpp exe_ta
98. searched from current value of sources_root see 6 11 1 on page 52 In example above myform ui file should be in some project folder And results of ui tool would also be placed in that folder From files defined with ui method header files are built with extension changed to hpg and source files are built also with extension changed to cp The names of generated header files are passed to h2moc method for generating implemen tation for signal slot mechanisms As a result from some project myform ui file these files would be generated some project myform hpp some project myform cpp some project moc_myform cp A 2 6 Output folder for moc tool By default work results of moc tool are located in the same folder where source data were In some cases it s not so convenient For example during a moving to new Qt version when all old generated files should be removed It would be easier to do if all generated files would be in separate folder In a Mxx_ru Cpp QtGen class moc_result_subdir attribute exists responsible for de termining where to put moc results If it is equal to nil the default value then all generated files are placed near the sources they are generated from Otherwise files would be placed into defined subfolder of source folder For example 1 qt generator MxxRu Cpp QtGen new self qt moc_result_subdir moc qt h2moc h mywidget hpp w N From h mywidget hpp file h moc moc_mywidget
99. support during development of Mxx_ru Separate thank to Mikhail Lyossin for his heavy and difficult work on translation of the documentation and comments in Mxx_ru to the English language and that due to his enthusiasm Mxx_ru has received the second breath and opportunity of the further development http eao197 narod ru Chapter 2 Installation 2 1 Prerequisites Ruby 1 9 1 is required for using Mxx_ru since v 1 5 0 Ruby 1 8 is required for previous versions of Mxx_ru You may download Ruby installation from http www ruby lang org One Click Ruby Installer for Microsoft Windows is available on rubyinstaller org 2 2 Installing Mxx_ru There is a few ways to install Mxx_ru e Install Mxx_ru as RubyGem gem install Mxx_ru Or to upgrade currently installed Mxx_ru RubyGem gem update Mxx_ru This is a preferred way e Check out Mxx_ru from Subversion repository svn co http svn code sf net p mxxru code lt PATH gt Where PATH is a path to concrete Mxx_ru version in repository For example to get stable version 1 6 3 svn co http svn code sf net p mxxru code tags 1 6 3 or to get development version 1 6 svn co http svn code sf net p mxxru code 1 6 CHAPTER 2 INSTALLATION 9 Working copy of Mxx ru can be placed into any folder It s typi cally named c ruby lib ruby site ruby on Microsoft Windows platform or usr local
100. t folder But some of them are defined as unit tests see S on page 72 and for each of them prj rb files exists for build and prj ut rb for build and running the unit test For such projects only prj ut rb file should be defined All other projects aren t unit tests and contains only prj rb files Exactly them should be included into required prjs call A solution is to find all prj ut rb files at first and then to add all prj rb file names from folders where are no prj ut rb 1 MxxRu Cpp composite_target 2 required_prjs Dir test prj ut rb 3 required_prjs Dir test prj rb delete_if f CHAPTER 5 THE BASIC IDEA 31 Deleting the name of found project file if prj ut rb is found in the same folder File exists File join File dirname f prj ut rb XA O au D 5 1 3 Project aliases Mxx _ru requires for each project to have unique alias the name of project file where project is defined This alias is used by Mxx_ru to ensure that each project is handled only once but not each time it s found in required prj Before Mxx_ru version 1 2 0 in project files it was required to repeat each file name as an alias of the project 1 Mxx_ru setup_target 2 Mxx_ru Cpp Exe_target new some module prj rb 3 sea 4 5 that gave rise to unfavourable criticism of users So in versions 1 2 0 1 4 10 auxiliary meth ods exe_target dll target lib target
101. t is a top target i e target is created in a file passed to Ruby interpreter explicitly During processing of a top target MxxRu setup_target method checks if mxx clean argument was passed in If it was clean method is executed for the target otherwise build method is called If mxx rebuld mode is set then MxxRu setup_target will call clean reset and build in a sequence In fact top target is a first target that executes a MxxRu AbstractTarget constructor Chapter 6 Mxx ru for C C projects 6 1 Introduction Mxx ru offers a ready to use tool sets for building C C projects That tools are described in mxx_ru cpp file That file should be loaded with require directive require mxx_ru cpp To support C C two important conceptions are introduced to Mxx ru toolset and obj_placement Mxx_ru introduces ready classes for such target types as executable file shared library file also known as dynamically loaded library including support of import library library file composite project 6 1 1 Toolset conception Toolset is a collection of tools used for building a project In other words toolset defines a type version and other features of concrete compiler on specific platform Mxx_ru is already adapted for some compilers In particular here is short list of com pilers supported e Borland C 5 on Windows platform e Visual C 12 11 10 9 8 7 and 6 vers
102. tions should be formed inside a project file for each compiler Mxx_ru doesn t performs any check about parameters passed using these methods and doesn t have any check about possible conflicts with parameters already chosen by Mxx_ru For example if Mxx_ru considers that multithreading project with shared library requires MD option for Visual C But there would no detection of a conflict if MT option would be passed using c_source or cpp_source methods in previous Make versions was no way to define a single file specific compiler options so this feature is experimental Because of that there is no guaranty it wouldn t be changed somehow in a future So be ready to rewrite calls of c_source and cpp_source methods used two arguments Methods c_sources cpp_sources are analogous to just described methods but have only one argument of Enumerable type This allows to set several source file names at once in an array for example CHAPTER 6 MXX_RU FOR C C PROJECTS 59 cpp_sources interface cpp engine cpp This may be useful in combination with Dir glob 1 cpp_sources Dir glob some prj cpp NOTE When using Dir glob method it s important to remember that Dir glob thinks that it s argument defines a search path from current folder because Dir glob doesn t know anything about sources_root Therefore the following code is erroneous 1 MxxRu Cpp
103. u for C C projects 34 6 1 Introduction lt s s s etcs sia a a we 34 6 1 1 Toolset concepti0d 000 ee ee ee 34 6 1 2 obj_placement conception 0 0 0 e eee ee 36 6 1 3 Targets for C C projects o o 2 38 6 1 4 An order of build clean execution o o 40 6 1 5 Runtime Modest Al PRE CRLE A 42 6 1 7 mxx cpp l argument 0 2 0 2 0 0 00200004 43 6 1 8 mxx cpp no depends analyzer argument 44 ee ee ee cd 44 te Gs eps eras Sop ee et eee Gee 45 6 3 Toolset access ee 46 Pl ee 46 iced Ao eee ee te abies oe adhe Das Be 46 ee oh See Ge ah ae oe eae eee GE S 47 be ete See Bee See Be aa O ad a 48 Een Genk Pie teats hon tate go Se a ees 48 6 8 1 target_root method 0 0 0 0 0 ee eee eee 48 6 8 2 target method o 0 2 0 00 ee ee ee ee 49 6 8 3 target prefix Method o e o 49 6 8 4 target_ext target_sufix method 49 6 8 5 implib path method o e e e 50 a a e Goh a ee was 50 6 9 Selecting an application type GUI Console 50 Sa I ee a i 51 fe asde dui ma a ado da i A 52 6 11 1 sources root Method o 52 6 11 2 c_source s cpp source s methods o o 53 6 11 3 mswin rc file method 0 0 0 00 eee eee 55 6 12 Additional object files linking o o 56 6 13
104. uced by Qt Designer header file should be created uic is used for generation For example from a ui a file with name ui_a h will be generated 4 From qrc file either a cpp or a rcc file should be created rcc tool is used for gener ation In the case of a cpp file generation the result of generation will automatically be added to the list of project s source files In additional to the cases described above Qt4 generator allows selection of Qt4 modules for a projects For example 77 CHAPTER 9 QT4 GENERATOR 78 1 require mxx_ru cpp qt4 2 3 MxxRu Cpp exe_target 4 eed 5 qt MxxRu Cpp Qt4 new self 6 The project needs Gui Network and Script modules 7 qt use_modules QT_GUI_LIB QT_NETWORK_LIB QT_SCRIPT_LIB 8 A 9 And Qt4 generator allows building of translation ts files form source and ui files For example require mxx_ru cpp qt4 MxxRu Cpp exe_target qt MxxRu Cpp Qt4 new self Project should have translation to Russian qt ts translations client_ru ts O 0 3 O A e N e 9 2 Qt4 generator usage 9 2 1 Adding definitions required to a project file Qt4 generator definition is in mxx_ru cpp qt4 rb file and should be included into a project file using a require directive j require mxx_ru cpp qt4 MxxRu setup_target w 9 2 2 Adding definitions in presence of pkg config In the case when there is
105. ui hpp cpp Chapter 10 Project file stub generators 10 1 Introduction A simple idea is used as the base for project file stub generators as long as too much similar fragments are need to be duplicated at the time of writing project files then it is possible to move this duty to a stub generator A skeleton of a project file is created by a generator and missing information will be included into it For example a generator had been run to create a project file for Hello World mxxrugen cpp exe t hello_world o prj rb and stub file prj rb was created as result require rubygems gem Mxx_ru gt 1 3 0 require mxx_ru cpp MxxRu Cpp exe_target o N O ow gt N Define your target name here 10 target hello_world 11 12 Enumerate one or more required projects 13 required_prj some project 14 15 Enumerate your C C files here 16 c_source C source file 17 cpp_source C source file 18 19 that was modified later by excluding unnecessary details 1 require rubygems 2 3 gem Mxx_ru gt 1 3 0 86 CHAPTER 10 PROJECT FILE STUB GENERATORS 87 4 5 require mxx_ru cpp 6 7 MxxRu Cpp exe_target 8 9 target hello_world 11 cpp_source hello_world cpp Since Mxx_ru is intended to support different kinds of project the stub generation is built in such a way
106. urce unit cpp 16 ddl_cpp_generator ddl_file unit ddl 17 18 cpp_source slice_unit cpp 19 ddl_cpp_generator ddl_file slice_unit ddl 20 21 cpp_source slice_stream_item cpp 22 ddl_cpp_generator ddl_file slice_stream_item ddl 23 24 cpp_source db_slicemap cpp 25 cpp_source std_db_slicemap cpp 26 27 cpp_source db_struct cpp 28 cpp_source std_db_struct cpp CHAPTER 5 THE BASIC IDEA 33 29 30 31 32 Or considering generator method returns a generator you may call it s methods with out saving a reference to it in a variable require mxx_ru cpp require oess_1 util_cpp_serializer gen 1 2 3 4 5 MxxRu Cpp exe_target 6 7 target test stdsn shptr 8 9 required_prj oess_1 defs prj rb 10 required_prj oess_1 io prj rb 12 generator Dess_1 Util_cpp_serializer Gen new self 13 ddl_file main ddl 14 15 cpp_source main cpp 16 mxx_generators method return a list of all generators installed One more way of generators usage is described in 7 6 on page 5 2 More details about MxxRu setup_target Mxx ru contains a map describing compliance of targets to aliases i e names of project files MxxRu setup_target method should be used to add new target to that map Moreover MxxRu setup_target method automatically executes a build or cleaning procedure if target passed to MxxRu setup_targe
107. ut folder for uic tool As well as in previous case during the run of uic by default results are stored in the same folder with source ui file If it isn t desirable then uic_result_subdir method allows to set subfolder of a folder with ui file where uic would store it s results For example 1 qt generator MxxRu Cpp Qt4 new self qt uic_result_subdir uic qt uil src dlg ui w N would generate src uic ui_dlg h And src uic path would be automatically included to project s include_path 6 15 1 on page 60 9 2 11 Output folder for rcc tool By default textual form resources are located in the same folder where source data were In some cases it s not so convenient In a Mxx_ru Cpp Qt4 class qrc_result_subdir attribute exists responsible for determining where to put qrc to cpp translation results Tf it is equal to nil the default value then all generated files are placed near the sources they are generated from Otherwise files would be placed into defined subfolder of source folder For example 1 qt generator MxxRu Cpp Qt4 new self qt qrc_result_subdir res qt qrc2cpp plugins images qrc wo N From plugins images qrc file plugins res images cpp file would be generated The value of grc_result_subdir only matters for files defined using qrc2cpp method CHAPTER 9 QT4 GENERATOR 84 9 2 12 Extension for source files generated By default during a source fil
108. x cpp no depends analyzer argument forces Mxx _ru not to analyze C C dependencies in a source files That analysis is performed by default that may slowdown build process significantly Sometimes with a partial rebuild of a project as example it may be optimal to ignore it mxx cpp no depends analyzer argument should be passed to Ruby interpreter in that case ruby some project prj rb mxx cpp no depends analyzer 6 1 9 mxx cpp extract options mxx cpp extract options argument forces Mxx_ru to show options list of com piler linker instead of project build For example ruby so_4 prj rb mxx cpp extract options for vc7 toolset may print the following C Compiler Options C Compiler Options EHsc GR Compiler options nologo MD LD D__WIN32__ DS0_4_PRJ DS0_4_DLL DMXX_RU_ACE__PLATFORM_WIN32 DWIN32 DMXX_RU_ACE__ACE_HAS_STANDARD_CPP_LIBRARY al Iso_4 zlib Defines __WIN32__ S0_4_PRJ S0_4_DLL MXX_RU_ACE__PLATFORM_WIN32 WIN32 MXX_RU_ACE__ACE_HAS_STANDARD_CPP_LIBRARY Include Paths so_4 zlib Librarian Options NOLOGO Linker Options NOLOGO 2 Added in a 1 0 9 version CHAPTER 6 MXX_RU FOR C C PROJECTS dWIN32 i SUBSYSTEM CONSOLE MSWindows Resource Compiler Defines MSWindows Resource Compiler Include Paths MSWindows Resource Compiler Options d__WIN32 dS0_4_PRJ dS0_4_DLL dMXX_RU_ACE__PLATFORM_WIN32 dMXX_RU_ACE__ACE_HA
109. x show tmps and mxx keep tmps arguments CHAPTER 7 ADDITIONAL FEATURES 69 7 5 Exceptions Ruby is an object oriented programming language with exception mechanisms widely used in For example exception is thrown if Ruby interpreter sees a syntax error in a script Mxx_ru itself also uses exceptions for informing developer about errors encountered One of Mxx _ru features is that in selected architecture for project files it s impossible to handle all types of exceptions by Mxx_ru As a result for example because of syntax error in a project file interpreter may print that stack trace mxx_ru abstract_target rb 187 in require say prj rb 9 syntax error SyntaxError from mxx_ru abstract_target rb 187 in required_prj from inout prj rb 8 from inout prj rb 4 in instance_eval from mxx_ru cpp target rb 1256 in instance_eval from mxx_ru cpp target rb 1256 in initialize from inout prj rb 4 in new from inout prj rb 4 from mxx_ru abstract_target rb 187 in require 11 levels from mxx_ru cpp composite rb 21 in instance_eval from mxx_ru cpp composite rb 21 in initialize from build rb 4 in new from build rb 4 This amount of details may shock for a first time But with a time this problem goes away firstly because amount of syntax errors is reduced with experience and as a second it allows to diagnose problems inside Mxx_ru itself But i
110. xtfileUnittestTarget new 5 some project prj ut rb 6 some project prj rb 4 7 8 9 Description of tests sequence Each execution of unit test application is defined with a launch method First argument of that method is string of parameters for unit test application Second argument is a vector of files to be compared In other words it s allowed for a test application to produce more then one file as a result In a build method of MxxRu TextfileUnittestTarget class Mxx_ru executes build of test application at first On success a sequence of tests is run in their definition order For each successful execution zero exit code was returned a consecutive comparison of result and reference files is performed If all pairs of files are equal next execution is run 8 2 2 Example Unit test project file 1 require mxx_ru textfile_unittest 2 3 MxxRu setup_target 4 MxxRu TextfileUnittestTarget new 5 prj ut rb 6 prj rb 7 8 launch out_0 txt 0 9 pair out_0 txt etalons out_0 txt See s 1 2 on page CHAPTER 8 UNIT TESTING SUPPORT 76 10 11 12 13 14 16 17 18 19 launch out_1 txt 1 pair out_1 txt etalons out_1 txt launch out_128 txt 128 pair out_0 txt etalons out_0 txt pair out_1 txt etalons out_1 txt pair out_128 txt etalons out_128 txt The result of unit test run
111. y vary For example embedding of automatically gen erated manifest with resource identifier set to 3 and preserving the generated manifest file is defined that way 1 MxxRu Cpp Toolsets Vc8 manifest 2 target gt self 3 autogen gt to_default_file 4 mt gt resource_id gt isolationaware_nostaticimport_manifest keep_manifest_file gt true al CHAPTER 6 MXX_RU FOR C C PROJECTS 65 6 17 Mac OS bundle support Note I haven t expirience with programming for Mac OS So the following information could be a bit inaccurate Please take it with care Mac OS has a special file type bundled From Mxx_ru s point of view bundle is a kind of shared library but with important distinctions e bundle should have bundle extension instead of so e bundle should be linked with bundle argument for linker instead of dynamic_1lib A new type of target MacOSBundleTarget and auxiliary function macos_bundle_target have been added in version 1 4 10 for support Mac OS bundles With help of them a bundle could be build using such project type require mxx_ru cpp 1 2 3 Mxx_ru Cpp macos_bundle_target 4 target my_test_bundle 5 c_source my_test_bundle c 6 In version 1 4 10 MacOSBundleTarget has special meaning only form gcc_darwin toolset For other toolsets that type of target is regarded as ordinal shared library So if you try to compile above s
112. y_bye std ostream amp to const std string amp where 11 12 endif 00 XA o A e say cpp implementation file 1 include lt say say hpp gt 2 3 void 4 say_hello std ostream amp to const std string amp where 5 4 6 to lt lt where lt lt Hello lt lt std endl 8 9 void 10 say_bye std ostream amp to const std string amp where 11 CHAPTER 4 EXAMPLES 12 13 to lt lt where lt lt Bye lt lt std endl 23 Note say hpp file is loaded as lt say say hpp gt e prj rb project file a o N Q un require mxx_ru cpp MxxRu Cpp lib_target target_root lib target say cpp_source say cpp 4 4 2 inout Subproject Here is files inout subproject contains e inout hpp header file al po N aon Q 10 LA 12 13 14 16 17 18 19 20 21 22 23 24 26 Hif defined _INOUT_HPP_ define _INOUT_HPP_ include lt string gt if defined INOUT_MSWIN if defined INOUT_PRJ define INOUT_TYPE __declspec dllexport else define INOUT_TYPE __declspec dllimport endif else define INOUT_TYPE endif class INOUT_TYPE inout_t public inout_t const std string amp method inout_t private std string m_method ttendif e inout cpp implementation CHAPTER 4 EXAMPLES 24 1 include lt say say hpp gt 2 3 inc
113. ywidget hpp file some project moc_mywidget cpp file would be generated A 2 4 Source files definition to generate signal slot implementation sources Source files cpp used to generate signal slot implementation source files moc with moc tool should be defined using cpp2moc method 1 require mxx_ru cpp qt MxxRu Cpp exe_target Bes generator MxxRu Cpp QtGen new self E a eoponoet mywidget cpp s The names defined are searched from current value of sources_root see 6 11 1 on page 52 In example above mywidget hpp file should be in some project folder And results of moc tool would also be placed in that folde From files defined with cpp2moc method source files are built with extension changed to pH So from some project mywidget cpp file some project mywidget moc file would be generated A 2 5 UI files definition Qt Designer user interface files saved as ui files are defined using a ui method require mxx_ru cpp qt MxxRu Cpp exe_target qt generator MxxRu Cpp QtGen new self 1 2 3 4 5 6 Taking value of moc_result_subdir into account see if it s not changed with cpp_ext attribute see Taking value of moc result subdir into account tif it s not changed with cpp_ext attribute see on page on page 97 A 2 6 on page on page 1 OO APPENDIX A QT3 GENERATOR 96 7 qt ui myform ui s The names defined are

Download Pdf Manuals

image

Related Search

Related Contents

ET-JR ARM7 LPC2214 Development Board User`s Manual  CableWholesale 30D1-19300  F MANUEL D`INSTALLATION  M30290T-EPB User`s Manual  MANUAL DO UTILIZADOR  AudioSonic CL-505  挫折ばかりしてきた凡人でも 英語が劇的に上達できた最強の法則 最強  TRENTO  取扱説明書  製品マニュアル  

Copyright © All rights reserved.
Failed to retrieve file