#! /usr/bin/env python # encoding: utf-8 # Thomas Nagy, 2006 (ita) # notes: # 1. We think it is good to give names to our objects # 2. In practice something like 'libkdegames' might do it better # 3. Any coincidence with characters living or dead is purely coincidental def myfun(self, name): import ccroot env2 = self.env.copy() env2['CXXFLAGS'] = "-Dxxxxxxxxxxxxxxxxxxxxxxx" node = self.path.find_resource(name) task = self.create_task('cxx', env2) task.m_scanner = ccroot.g_c_scanner task.path_lst = self.inc_paths task.defines = self.scanner_defines task.m_inputs = [node] task.m_outputs = [node.change_ext(".o")] self.compiled_tasks.append(task) def build(bld): import Params print "command-line parameter meow is ", Params.g_options.meow # 1. A simple program obj = bld.create_obj('cpp', 'program') obj.source=''' a1.cpp b1.cpp b2.cpp main.cpp ''' obj.includes='.' obj.target='testprogram' obj.defines='LINUX=1 BIDULE' obj.obj_ext = '_1.o' # obj.add_obj_file('kk.o') # <- example on how to add custom object files considered source #obj.mappings["a1.cpp"] = myfun <- example of how to modify the environment for one file # of you need to modify more files, add custom object files or use the objects type # 2. A shared library # The extension (.so) is added automatically obj = bld.create_obj('cpp', 'shlib') obj.source=''' a1.cpp b1.cpp b2.cpp ''' obj.includes = '.' #obj.name = 'peter' obj.target = 'testshlib' obj.inst_var = 'SOME_INSTALL_DIR' # 3. A static library # The extension (.a) is added automatically obj = bld.create_obj('cpp', 'staticlib') obj.source=''' c1.cpp ''' obj.includes = '.' obj.name = 'tony' obj.target = 'teststaticlib' # 4. Another shared library obj = bld.create_obj('cpp', 'shlib') obj.source=''' d1.cpp ''' obj.includes = '.' obj.target = 'shlib1' obj.name = 'john' obj.want_libtool = 1 obj.vnum = '1.2.3' # 5. A program that links against shlib1 obj = bld.create_obj('cpp', 'program') obj.source=''' e1.cpp ''' obj.includes = '.' obj.uselib = 'MYPROG' obj.uselib_local = 'tony john testshlib' # 'tony john peter' # look for 'peter' above obj.target = 'program_dyn_linked' # IMPORTANT WARNING: # uselib_local expects *names*, that is, the field obj.name # by simplicity, when there is no ambiguity: obj.target == obj.name # installing files, headers .. install_files('PREFIX', 'include', 'a1.h') #install_as('PREFIX', 'dir/ahoy.h', 'a1.h') def set_options(opt): # options defined if src/ was to be compiled as a standalone module opt.add_option('--meow', type='string', help='option hidden in the src module', dest='meow') def configure(conf): print "sub-configuration file called (demo)"