Jump to content

Development/Gbuild/CheatSheet

From The Document Foundation Wiki

This page consists of a collection of gbuild howto's for people who need to get something done with the build system, but who are not necessarily interested in the details of the build system internals.

Internal source files

Statically link library objects for cppunit target

Example code:

 $(eval $(call gb_CppunitTest_use_library_objects,sc_ucalc, \
     sc \
     scqahelper \
 ))

This code will statically link two libraries - sc and scqahelper - into sc_ucalc cppunit target.

Add a new library to existing module

To add a new library to an existing module, first, add a new .mk file immediately below the module directory and name it Library_<library name>.mk. For example, let's add a new library target named 'scfoo' under the sc module. First you would create

 sc/Library_scfoo.mk

and add at the top of the file

 $(eval $(call gb_Library_Library,scfoo))

to register the library. Then add the Library_scfoo entry to the sc/Module_sc.mk file near the top

 $(eval $(call gb_Module_add_targets,sc,\
       ....
 	Library_scfoo \
       ....
 ))

to make this library a part of the sc module. You would also need to add this library in the Repository.mk file in the top directory, or else you'll get something like

 *** Library scfoo must be registered in Repository.mk.  Stop.

when you try to build the sc module.

External libraries

Targets

gb_CppunitTest_use_library_objects

Specify libraries to statically link to for cppunit target.

gb_Library_Library

Set library target name.

gb_Library_set_include

Specify include paths for headers at build time.

gb_Library_use_externals

Sets the library to link against some possibly external/system libraries. Note that some system libraries in the LibreOffice build use an own copy build in the LibreOffice build itself. This can be triggered by ./configure switches or depend on the platform. gb_Library_use_externals will add the proper include and link switches and dependencies for either scenario.

gb_Library_use_sdk_api

UNO services and interfaces are defined in .idl files, and headers with C++ class declarations are generated from these in the build. If a library uses one of these UNO headers, it needs to declare gb_Library_use_sdk_api for that library -- otherwise gbuild might try to build the c++ objects before the headers are there, if you are unlucky.

gb_Library_use_libraries

Specify dependencies on other internal libraries. These libraries will be dynamically linked at build time.

gb_Library_add_exception_objects

Specify source files to compile for the library, with C++ exception support.

gb_Module_add_targets

Specify libraries that a given module builds. Libraries specified here will be built when running make <module name>.