-
Notifications
You must be signed in to change notification settings - Fork 11
LMK Build System Overview
The lmk application must be run from within the source tree you are trying to build. LMK maintains a project list of all libraries and applications it must build in a file called lmkfiles.lua. This file is stored in the lmkproject directory at the top of the source tree. When you add or remove a library or application to the source tree, you must update the project list. To update the project list you must use the –u option as follows:
% lmk –u
To build your source, you will need to use the –b option. If you do not specify a path, lmk will try and globally rebuild your source tree. If you only want to rebuild the current directory you would specify the path as follows:
% lmk –b .
If a path is specified for the –b option, lmk will build all lmk build files in the specified path. If an lmk build file is specified as a parameter, lmk will only build the target for that file.
The –r option specifies that lmk recurse. This option will only take affect when the –b option is specified with a path. So, the following command:
% lmk –r –b .
Would process all lmk build files found in the current directory and also any lmk build files found in all sub directories to the current directory.
The –f option specifies an alternate script function to use. The default script function is “main”. The main function tries to build the source. Other script functions are: clean, clobber, distclean, and test.
The “clean” function removes all obj files and exported header files. The “clobber” function removes all obj files, exported header files, libraries, and applications. The “distclean” function removes the bin, lib, include, and tmp directories from the top of the lmk project directory. The “test” function runs all unit tests in the project.
To remove object files from the source tree type:
% lmk –f clean
The source tree can be built as an optimized binary or with debug information. Debug is the default. Use the –m option to specify the mode. To build optimized:
% lmk –m opt
Multiple script functions can be specified at the same time. For example, to clean the object files and then rebuilds the source tree:
% lmk –f clean –b –f main –b
The –b option is specified twice because it is the signal for lmk to begin execution with its current state.
LMK uses lua scripts to define a build target in a project. The following functions may be called from within an lmk file:
lmk.set_name (name, options)
lmk.set_type (type)
lmk.add_files (files, options)
lmk.add_libs (libraries, options)
lmk.add_preqs (prerequisite, options)
lmk.add_vars (variables, options)
lmk.set_name (name, options) This function sets the name of the build target. The name should be a string enclosed with quotes. The name must be unique in the project. LMK will detect non-unique names when lmk –u is executed and will raise an error. The options parameter is a lua table of named values. It is optional. The following example specifies that a target name “dmzRenderWin32” should only be build under windows:
lmk.set_name (“dmzRenderWin32”, { win32 = true })
lmk.set_type (type) This function specifies how the target should be built. The type is a string enclosed in quotes. The possible values of type are: exe, shared, and plugin. The type “exe” specifies an application. The type “shared” specifies a shared library that may be linked against. The type “plugin” specifies a shared library that will explicitly loaded by the application and should not be used to link against.
lmk.add_files (files, options) This function adds files to be processed by lmk. The files parameter is a lua table of file names. LKM recognized some file extensions such as .h, .c, and .cpp. The file type may be specified in the options parameter. Please note that various file type should not be mixed and that and add_files call should be made for each file type. The following example adds c++ file that uses an extension other than the one recognized by lmk:
lmk.add_files ({“foo.C”}, {src = “cpp”})
lmk.add_libs (libraries, options) This function adds library dependencies. The libraries parameter is a lua table of library names. The library names must belong to other build targets in the project. The name must match what is set by the dependencies lmk.set_name function. All dependencies added by lmk.add_libs will be included on the targets link line. If the build target depends on 3rd party libraries that are not built as part of the project, they may be specified by the lmk.add_vars function (see bellow). The options parameter is a lua table of named values. It is optional. The following two lines add the library dependencies: dmzRuntime, dmzSystem, and dmzTypes. If the target is be built on a win32 system, the library dependency dmzFooWin32 will also be added.
lmk.add_libs {“dmzRuntime”, “dmzSystem”, “dmzTypes”}
lmk.add_libs ({“dmzFooWin32”}, { win32 = true})
lmk.add_preqs (prerequisites, options) This function works similar to lmk.add_libs except the names listed in the prerequisites are not added to the targets link line. Since the dependency list is not included on the targets link line, executables may also be specified.
lmk.add_vars (variables, options) This function adds variables which are used to enhance and extend the build scripts. Items that may be specified include: include paths, link paths, 3rd party libraries, and lmk template parameters.