def install(target, destination): if isinstance(target, list): for t in target: install(t, destination) elif isinstance(target, basestring): install(internal.Target(target), destination) else: filename = target.file target.name = 'install_' + target.name register_path_for_create(destination) print 'install: ' + target.name print print target.name + ": " + filename + ' | ' + destination print "\t" + platform().install(filename, destination) if target.output: soname_fullpath = target.stem + '.' + target.output.version.soname_version( ) symlink(destination + '/' + os.path.basename(target.file), destination + '/' + os.path.basename(soname_fullpath)) symlink(destination + '/' + os.path.basename(soname_fullpath), destination + '/' + os.path.basename(target.stem)) return target
def Compile( sourcefile, objectfile = None, directive = ''): """ Compiles a source file to an object file, with excplicit directives :param sourcefile: name of the sourcefile (src/myfile.cpp) :param objectfile: optional name of the output object file (obj/myfile.o) :param directive: optional compile directive for this TU, default '' :return: the target (which contains the name of the objectfile) """ if not objectfile: objectfile = platform().default_object_name( sourcefile) target = plumbing.target( plumbing.normalize_path( objectfile), objectfile, 'target_' + plumbing.normalize_string( objectfile)) target.source = plumbing.normalize_path( sourcefile); object_directory = os.path.dirname( target.file) dependency_file = plumbing.dependency_file_name( target.file) cross_object_file = plumbing.cross_object_name( target.file) print "#" print "# compiling {0} to {1}".format( sourcefile, objectfile) print print "-include " + dependency_file print print 'compile: ' + target.name print print target.name + ': ' + target.file print print target.file + ": " + target.source + ' | ' + object_directory print '\t' + platform().compile( target.source, target.file, directive) print '\t' + platform().header_dependency( target.source, [ cross_object_file, target.file], dependency_file) print print 'cross: ' + cross_object_file print print cross_object_file + ": " + target.source + ' | ' + object_directory print '\t' + platform().cross_compile( target.source, cross_object_file, directive) print '\t' + platform().header_dependency( target.source, [ cross_object_file, target.file], dependency_file) print plumbing.register_object_path_for_clean( object_directory) plumbing.register_path_for_create( object_directory) return target
def LinkArchive(name,objectfiles): """ Links an archive :param: name name of the binary with out prefix or suffix. :param: objectfiles object files that is linked :return: target name """ target = plumbing.target( plumbing.archive_name_path( name), name) return plumbing.link( platform().link_archive, target, objectfiles, [])
def LinkUnittest(name,objectfiles,libraries = [], test_target = True): """ LinkIsolatedUnittest(name,objectfiles,libs) :param: name name of the unittest executable :param: objectfiles object files that is linked :param: libraries dependent libraries (optional) :param: tets_target if true, a test target is generated. (True is the default) """ target = plumbing.target( plumbing.executable_name_path( name)) # # We add the unittest lib for the user... # plumbing.link( platform().link_executable, target, objectfiles, libraries + platform().unittest_libraries) plumbing.deploy( target, 'client') if test_target: plumbing.set_ld_path() print "test: " + 'test_' + target.name print print 'test_' + target.name + ": " + target.name print "\t @LD_LIBRARY_PATH=$(LOCAL_LD_LIBRARY_PATH) $(PRE_UNITTEST_DIRECTIVE) " + target.file + " $(ISOLATED_UNITTEST_DIRECTIVES)" print return target
def LinkLibrary(output,objectfiles,libs = []): """ Links a shared library :param name name of the binary with out prefix or suffix. :param objectfiles object files that is linked :param libs dependent libraries :return: target name """ target = plumbing.target( output, output, operation = plumbing.shared_library_name_path) plumbing.link( platform().link_library, target, objectfiles, libs) plumbing.deploy( target, 'lib') return target
def LinkExecutable( name, objectfiles, libraries = []): """ Links an executable :param name name of the binary with out prefix or suffix. :param objectfiles object files that is linked :param libs dependent libraries :return: target name """ target = plumbing.target( plumbing.executable_name_path( name), name) plumbing.link( platform().link_executable, target, objectfiles, libraries) plumbing.deploy( target, 'exe') return target;
def link(operation, target, objectfiles, libraries, linkdirectives='', prefix=''): internal.validate_list(objectfiles) internal.validate_list(libraries) filename = target.file print "#" print "# Links: " + os.path.basename(filename) # # extract file if some is targets # objectfiles = internal.target_files(objectfiles) dependent_targets = library_targets(libraries) # # Convert library targets to names/files, # libraries = internal.target_base(libraries) destination_path = os.path.dirname(filename) print print "link: " + target.name print print target.name + ': ' + filename print print ' objects_' + target.name + ' = ' + internal.multiline( object_name_list(objectfiles)) print print ' libs_' + target.name + ' = ' + internal.multiline( platform().link_directive(libraries)) print print ' #' print ' # possible dependencies to other targets (in this makefile)' print ' depenency_' + target.name + ' = ' + internal.multiline( dependent_targets) print print filename + ': $(objects_' + target.name + ') $(depenency_' + target.name + ')' + " $(USER_CASUAL_MAKE_FILE) | " + destination_path print '\t' + prefix + operation(filename, '$(objects_' + target.name + ')', '$(libs_' + target.name + ')', linkdirectives) if target.output: soname_fullpath = target.stem + '.' + target.output.version.soname_version( ) symlink(target.file, soname_fullpath) symlink(soname_fullpath, target.stem) print register_file_for_clean(filename) register_path_for_create(destination_path) return target
def symlink(filename, linkname): print '\t' + platform().remove(linkname) print '\t' + platform().symlink(filename, linkname)