示例#1
0
文件: pack.py 项目: shilang/buildc
    def __build_component_deps(build_home, url, cmode, force_update):
        if not os.path.exists(build_home + os.sep + '.build'):
            Util.execute_and_output('mkdir -p ' + build_home + os.sep +
                                    '.build')
        os.chdir(build_home + os.sep + '.build')
        print "Create dir [.build] OK!"

        Util.execute_and_output('rm -rf ' + url[url.rindex("/") + 1:])
        SvnLocalOper.export(url, None, None, Glo.source_svn_user(),
                            Glo.source_svn_passwd(), False)
        print "Export [" + url + "] OK!"

        source_home = build_home + '/.build/' + url[url.rindex("/") + 1:]
        os.chdir(source_home)
        print "Cd " + source_home

        dotrc = Glo.dot_buildc_rc_path()
        if not os.path.exists(dotrc):
            print('Can not found ' + dotrc)
            print('Please run buildc init and then config .buildc.rc!')
            sys.exit(Errors.conf_file_not_found)
        buildc_rc = Load.load_dot_buildc_rc(dotrc)

        buildc_cfg = Load.load_buildc_cfg(Glo.buildc_cfg_path(), Glo.var_str())

        is_valid = Cache.cache_build_by_external_libs(buildc_cfg.external_libs,
                                                      cmode, force_update)
        if is_valid == False:
            os.chdir(build_home)
            print "Cd " + build_home
            return False

        dotrepository = Glo.dot_buildc_repository_path()
        svn_tree = SvnTree()
        svn_tree.import_format_tree_from_file(dotrepository)
        for dependence in buildc_cfg.external_libs:
            Pack.__copy_dependent_all(dependence, svn_tree, buildc_rc,
                                      build_home, cmode)

        os.chdir(build_home)
        print "Cd " + build_home

        print 'Build deps [' + url + '] OK!'
        return True
示例#2
0
文件: pack.py 项目: bigwhite/buildc
    def __build_component_deps(build_home, url, cmode, force_update):
        if not os.path.exists(build_home + os.sep + '.build'):
            Util.execute_and_output('mkdir -p ' + build_home + os.sep + '.build')
        os.chdir(build_home + os.sep + '.build')
        print "Create dir [.build] OK!"

        Util.execute_and_output('rm -rf ' + url[url.rindex("/")+1:])
        SvnLocalOper.export(url, None, None, Glo.source_svn_user(), Glo.source_svn_passwd(), False)
        print "Export [" + url + "] OK!"

        source_home = build_home + '/.build/' + url[url.rindex("/")+1:]
        os.chdir(source_home)
        print "Cd " + source_home

        dotrc = Glo.dot_buildc_rc_path()
        if not os.path.exists(dotrc):
            print('Can not found ' + dotrc)
            print('Please run buildc init and then config .buildc.rc!')
            sys.exit(Errors.conf_file_not_found)
        buildc_rc = Load.load_dot_buildc_rc(dotrc)

        buildc_cfg = Load.load_buildc_cfg(Glo.buildc_cfg_path(), Glo.var_str())

        is_valid = Cache.cache_build_by_external_libs(buildc_cfg.external_libs, cmode, force_update)
        if is_valid == False:
            os.chdir(build_home)
            print "Cd " + build_home
            return False

        dotrepository  = Glo.dot_buildc_repository_path()
        svn_tree = SvnTree()
        svn_tree.import_format_tree_from_file(dotrepository)
        for dependence in buildc_cfg.external_libs:
            Pack.__copy_dependent_all(dependence, svn_tree, buildc_rc, build_home, cmode)

        os.chdir(build_home)
        print "Cd " + build_home

        print 'Build deps [' + url + '] OK!'
        return True
示例#3
0
    def __check_buildc_cfg(cmode, lib_root_path=None):
        platform_info = Glo.CPU + '_' + cmode[0:2] + '_' + Glo.SYSTEM

        buildc_rc = Load.load_dot_buildc_rc(Glo.dot_buildc_rc_path())
        buildc_cfg = Load.load_buildc_cfg(Glo.buildc_cfg_path(), Glo.var_str())

        cache_libs = []
        dotrepository = Glo.dot_buildc_repository_path()

        cache_svn_tree = CacheSvnTree(buildc_rc.external_repositories)
        cache_svn_tree.import_format_tree_from_file(dotrepository)
        cache_svn_tree.get_cache_libs(None, cmode, cache_libs)

        libs_depend = []
        for (libname, libversion, archives) in buildc_cfg.external_libs:
            is_found = False
            for (cache_libname, cache_libversion, cache_path) in cache_libs:
                if libname == cache_libname and libversion == cache_libversion:
                    path = None
                    if lib_root_path == None:
                        path = cache_path + '/' + libname + '/' + libversion + '/' + platform_info
                    else:
                        path = lib_root_path + '/' + libname + '/' + libversion + '/' + platform_info

                    if not os.path.exists(cache_path + '/' + libname + '/' +
                                          libversion + '/' + platform_info):
                        print 'Can not found [' + cache_path + '/' + libname + '/' + libversion + '/' + platform_info + '] in local library cache!'
                        print 'Please make sure the library [' + cache_path + '/' + libname + '/' + libversion + '/' + platform_info + '] is available!'
                        continue

                    libs_depend.append((libname, libversion, archives, path))

                    is_found = True
                    break
            if not is_found:
                print 'Error: Can not found [' + libname + '] in local library cache!!!!'
                print 'Please make sure the library [' + libname + '] is available!'
                sys.exit(Errors.lib_not_found)

        return libs_depend
示例#4
0
    def __check_buildc_cfg(cmode, lib_root_path = None):
        platform_info = Glo.CPU + '_' + cmode[0:2] + '_' + Glo.SYSTEM

        buildc_rc = Load.load_dot_buildc_rc(Glo.dot_buildc_rc_path())
        buildc_cfg = Load.load_buildc_cfg(Glo.buildc_cfg_path(), Glo.var_str())

        cache_libs = []
        dotrepository = Glo.dot_buildc_repository_path()

        cache_svn_tree = CacheSvnTree(buildc_rc.external_repositories)
        cache_svn_tree.import_format_tree_from_file(dotrepository)
        cache_svn_tree.get_cache_libs(None, cmode, cache_libs)

        libs_depend = []
        for (libname, libversion, archives) in buildc_cfg.external_libs:
            is_found = False
            for (cache_libname, cache_libversion, cache_path) in cache_libs:
                if libname == cache_libname and libversion == cache_libversion:
                    path = None
                    if lib_root_path == None:
                        path = cache_path + '/' + libname + '/' + libversion + '/' + platform_info
                    else:
                        path = lib_root_path + '/' + libname + '/' + libversion + '/' + platform_info

                    if not os.path.exists(cache_path + '/' + libname + '/' + libversion + '/' + platform_info):
                        print 'Can not found [' + cache_path + '/' + libname + '/' + libversion + '/' + platform_info + '] in local library cache!'
                        print 'Please make sure the library [' + cache_path + '/' + libname + '/' + libversion + '/' + platform_info + '] is available!'
                        continue

                    libs_depend.append((libname, libversion, archives, path))

                    is_found = True
                    break
            if not is_found:
                print 'Error: Can not found [' + libname + '] in local library cache!!!!'
                print 'Please make sure the library [' + libname + '] is available!'
                sys.exit(Errors.lib_not_found)

        return libs_depend
示例#5
0
文件: cache.py 项目: bigwhite/buildc
    def cache_build_by_config(buildc_cfg_path, cmode, force_update = True):
        buildc_cfg = Load.load_buildc_cfg(buildc_cfg_path, Glo.var_str())

        is_valid = Cache.cache_build_by_external_libs(buildc_cfg.external_libs, cmode, force_update)
        return is_valid
示例#6
0
    def reconfig(cmode, libs_depend, project_root_path = None):
        makerules = Glo.make_rules_path()

        if (Glo.SYSTEM == 'solaris'):
            this_awk = 'nawk'
        else:
            this_awk = 'gawk'
        print "Reconfig [" + makerules + "]..."

        #Warning if we can not found '@Generated by buildc@' embeded in the Make.rules
        f = open(makerules)
        s = f.read(1024)
        if s.find("@Generated by buildc@") == -1:
            print "Warning: Please make sure the Make.rules file is generated by buildc!"
        f.close()

        c = Load.load_buildc_cfg(Glo.buildc_cfg_path(), Glo.var_str())
        project_name, version, author = c.project
        if project_root_path == None:
            topdir = os.path.abspath('./')
        else:
            topdir = project_root_path
        this_os = Glo.SYSTEM
        this_cpu = Glo.CPU
        cmode = cmode

        if cmode == '64-bit':
            if this_os == 'solaris' and this_cpu == 'x86':
                cc = '/usr/sfw/bin/gcc -m64'
            else:
                cc = 'gcc -m64'
        else:
            cc = 'gcc -m32'

        libs         = ''
        includes     = ''
        static_libs  = ''
        dynamic_libs = ''

        lib_roots = ''
        lib_roots_count = len(libs_depend)
        if not lib_roots_count == 0:
            last_lib = libs_depend[lib_roots_count - 1]
        for (libname, libversion, archives, libpath) in libs_depend:
            if libname == last_lib[0]:
                lib_roots += (libname + '_ROOT = ' + libpath + "#@lib_roots_end@")
            else:
                lib_roots += (libname + '_ROOT = ' + libpath + "#@lib_roots@\\n")

            includes += ('-I $(' + libname + '_ROOT)' + '/include ')
            libs += (' -L $(' + libname + '_ROOT)' + '/lib')
            for archive in archives:
                libs += (' -l' + Glo.libname2compile_option(archive))
                if Glo.is_static_lib(archive):
                    static_libs += (' -L $(' + libname + '_ROOT)' + '/lib')
                    static_libs += (' -l' + Glo.libname2compile_option(archive))
                else:
                    dynamic_libs += (' -L $(' + libname + '_ROOT)' + '/lib')
                    dynamic_libs += (' -l' + Glo.libname2compile_option(archive))

        custom_defs = ''
        for cdef in c.custom_defs:
            custom_defs += (cdef + ' ')

        custom_vars = ''
        custom_vars_count = len(c.custom_vars)
        for var in c.custom_vars:
            custom_vars += (var[0] + ' = ' + str(var[1]))
            if var == c.custom_vars[custom_vars_count - 1]:
                custom_vars += "#@custom_vars_end@"
            else:
                custom_vars += "#@custom_vars@\\n"

        custom_includes = ''
        for inc in c.custom_includes:
            custom_includes += ('-I ' + inc + ' ')

        custom_libs = ''
        for (libpath, archives) in c.custom_libs:
            if not len(libpath) == 0:
                custom_libs += (' -L' + libpath)

            for archive in archives:
                custom_libs += (' -l' + Glo.libname2compile_option(archive))
                if Glo.is_static_lib(archive):
                    if not len(libpath) == 0:
                        static_libs += (' -L ' + libpath)
                    static_libs += (' -l' + Glo.libname2compile_option(archive))
                else:
                    if not len(libpath) == 0:
                        dynamic_libs += (' -L ' + libpath)
                    dynamic_libs += (' -l' + Glo.libname2compile_option(archive))

        system_libs = ''
        for (libpath, archives) in c.system_libs:
            if not len(libpath) == 0:
                system_libs += (' -L ' + libpath)

            for archive in archives:
                system_libs += (' -l' + Glo.libname2compile_option(archive))

        cmd  = "sed -e '1,$ s/=.*@topdir@/= "  + Glo.add_backlash(topdir) + "#@topdir@/g' " + Glo.make_rules_path() + '|'
        cmd += "sed -e '1,$ s/=.*@os@/= "      + this_os                          + "#@os@/g'"      + '|'
        cmd += "sed -e '1,$ s/=.*@cpu@/= "     + this_cpu                         + "#@cpu@/g'"     + '|'
        cmd += "sed -e '1,$ s/=.*@cmode@/= "   + cmode                            + "#@cmode@/g'"   + '|'
        cmd += "sed -e '1,$ s/=.*@version@/= " + version                          + "#@version@/g'" + '|'
        cmd += "sed -e '1,$ s/=.*@cc@/= "               + Glo.add_backlash(cc)                   + "#@cc@/g'"                + '|'
        cmd += "sed -e '1,$ s/=.*@default_includes@/= " + Glo.add_backlash(Glo.default_includes) + "#@default_includes@/g'"  + '|'
        cmd += "sed -e '1,$ s/=.*@default_libs@/= "     + Glo.add_backlash(Glo.default_libs)     + "#@default_libs@/g'"      + '|'
        cmd += "sed -e '1,$ s/=.*@custom_includes@/= "  + Glo.add_backlash(custom_includes)      + "#@custom_includes@/g'"   + '|'
        cmd += "sed -e '1,$ s/=.*@custom_libs@/= "      + Glo.add_backlash(custom_libs)          + "#@custom_libs@/g'"       + '|'
        cmd += "sed -e '1,$ s/=.*@system_libs@/= "      + Glo.add_backlash(system_libs)          + "#@system_libs@/g'"       + '|'
        cmd += "sed -e '1,$ s/=.*@static_libs@/= "      + Glo.add_backlash(static_libs)          + "#@static_libs@/g'"       + '|'
        cmd += "sed -e '1,$ s/=.*@dynamic_libs@/= "     + Glo.add_backlash(dynamic_libs)         + "#@dynamic_libs@/g'"      + '|'
        cmd += "sed -e '1,$ s/=.*@custom_defs@/= "      + custom_defs                            + "#@custom_defs@/g'"       + '|'
        cmd += "sed -e '1,$ s/=.*@lib_includes@/= "     + Glo.add_backlash(includes)             + "#@lib_includes@/g'"      + '|'
        cmd += "sed -e '1,$ s/=.*@libs_depend@/= "      + Glo.add_backlash(libs)                 + "#@libs_depend@/g'"       + '|'
        cmd += "sed -e '/^.*@lib_roots@/d'"                          + '|'
        cmd += "sed -e '1,$ s/^.*@lib_roots_end@/@lib_roots@/g'"     + '|'
        cmd += "sed -e '/^.*@custom_vars@/d'"                        + '|'
        cmd += "sed -e '1,$ s/^.*@custom_vars_end@/@custom_vars@/g'" + '|'

        if lib_roots_count == 0:
            cmd += ("sed -e '1,$ s/@lib_roots@/#@lib_roots_end@/g'" + '|')
        else:
            cmd += (this_awk + " '{ sub(/@lib_roots@/, \"" + lib_roots + "\"); print }'" + '|')

        if custom_vars_count == 0:
            cmd += ("sed -e '1,$ s/@custom_vars@/#@custom_vars_end@/g'")
        else:
            cmd += (this_awk + " '{ sub(/@custom_vars@/, \"" + custom_vars + "\"); print }'")

        cmd += "> " + Glo.make_rules_temp_path()

        Util.execute_and_output(cmd)
        Util.execute_and_output('mv ' + Glo.make_rules_temp_path() + ' ' + Glo.make_rules_path())

        print "Reconfig [" + makerules + "] OK!"
示例#7
0
    def __config(cmode, libs_depend, project_root_path = None):
        makerules_tpl = Glo.make_rules_tpl_path()

        if (Glo.SYSTEM == 'solaris'):
            this_awk = 'nawk'
        else:
            this_awk = 'gawk'

        c = Load.load_buildc_cfg(Glo.buildc_cfg_path(), Glo.var_str())
        project_name, version, author = c.project
        date = time.strftime('%Y-%m-%d',time.localtime(time.time()))
        if project_root_path == None:
            topdir = os.path.abspath('./')
        else:
            topdir = project_root_path
        this_os  = Glo.SYSTEM
        this_cpu = Glo.CPU
        cmode = cmode

        if cmode == '64-bit':
            if this_os == 'solaris' and this_cpu == 'x86':
                cc = '/usr/sfw/bin/gcc -m64'
            else:
                cc = 'gcc -m64'
        else:
            cc = 'gcc -m32'

        libs = ''
        includes = ''
        static_libs = ''
        dynamic_libs = ''

        lib_roots = ''
        lib_roots_count = len(libs_depend)
        if not lib_roots_count == 0:
            last_lib = libs_depend[lib_roots_count - 1]
        for (libname, libversion, archives, libpath) in libs_depend:
            if libname == last_lib[0]:
                lib_roots += (libname + '_ROOT = ' + libpath + "#@lib_roots_end@")
            else:
                lib_roots += (libname + '_ROOT = ' + libpath + "#@lib_roots@\\n")

            includes += ('-I $(' + libname + '_ROOT)' + '/include ')
            libs     += (' -L $(' + libname + '_ROOT)' + '/lib')
            for archive in archives:
                libs += (' -l' + Glo.libname2compile_option(archive))
                if Glo.is_static_lib(archive):
                    static_libs += (' -L $(' + libname + '_ROOT)' + '/lib')
                    static_libs += (' -l' + Glo.libname2compile_option(archive))
                else:
                    dynamic_libs += (' -L $(' + libname + '_ROOT)' + '/lib')
                    dynamic_libs += (' -l' + Glo.libname2compile_option(archive))

        custom_defs = ''
        for cdef in c.custom_defs:
            custom_defs += (cdef + ' ')

        custom_vars = ''
        custom_vars_count = len(c.custom_vars)
        for var in c.custom_vars:
            custom_vars += (var[0] + ' = ' + str(var[1]))
            if var == c.custom_vars[custom_vars_count - 1]:
                custom_vars += "#@custom_vars_end@"
            else:
                custom_vars += "#@custom_vars@\\n"

        custom_includes = ''
        for inc in c.custom_includes:
            custom_includes += ('-I ' + inc + ' ')

        custom_libs = ''
        for (libpath, archives) in c.custom_libs:
            if not len(libpath) == 0:
                custom_libs += (' -L ' + libpath)

            for archive in archives:
                custom_libs += (' -l' + Glo.libname2compile_option(archive))
                if Glo.is_static_lib(archive):
                    if not len(libpath) == 0:
                        static_libs += (' -L ' + libpath)
                    static_libs += (' -l' + Glo.libname2compile_option(archive))
                else:
                    if not len(libpath) == 0:
                        dynamic_libs += (' -L ' + libpath)
                    dynamic_libs += (' -l' + Glo.libname2compile_option(archive))

        system_libs = ''
        for (libpath, archives) in c.system_libs:
            if not len(libpath) == 0:
                system_libs += (' -L ' + libpath)

            for archive in archives:
                system_libs += (' -l' + Glo.libname2compile_option(archive))

        cmd  = "sed -e '1,$ s/@project_name@/"     + project_name + "/g' " + makerules_tpl + '|'
        cmd += "sed -e '1,$ s/@author@/"           + author       + "/g'"  + '|'
        cmd += "sed -e '1,$ s/@date@/"             + date         + "/g'"  + '|'
        cmd += "sed -e '1,$ s/@topdir@/"           + Glo.add_backlash(topdir) + "#@topdir@/g'"  + '|'
        cmd += "sed -e '1,$ s/@os@/"               + this_os                          + "#@os@/g'"      + '|'
        cmd += "sed -e '1,$ s/@cpu@/"              + this_cpu                         + "#@cpu@/g'"     + '|'
        cmd += "sed -e '1,$ s/@cmode@/"            + cmode                            + "#@cmode@/g'"   + '|'
        cmd += "sed -e '1,$ s/@version@/"          + version                          + "#@version@/g'" + '|'
        cmd += "sed -e '1,$ s/@cc@/"               + Glo.add_backlash(cc)     + "#@cc@/g'"      + '|'
        cmd += "sed -e '1,$ s/@default_includes@/" + Glo.add_backlash(Glo.default_includes) + "#@default_includes@/g'" + '|'
        cmd += "sed -e '1,$ s/@default_libs@/"     + Glo.add_backlash(Glo.default_libs)     + "#@default_libs@/g'"     + '|'
        cmd += "sed -e '1,$ s/@custom_defs@/"      + custom_defs                                       + "#@custom_defs@/g'"      + '|'
        cmd += "sed -e '1,$ s/@custom_includes@/"  + Glo.add_backlash(custom_includes)         + "#@custom_includes@/g'"  + '|'
        cmd += "sed -e '1,$ s/@custom_libs@/"      + Glo.add_backlash(custom_libs)             + "#@custom_libs@/g'"      + '|'
        cmd += "sed -e '1,$ s/@system_libs@/"      + Glo.add_backlash(system_libs)             + "#@system_libs@/g'"      + '|'
        cmd += "sed -e '1,$ s/@static_libs@/"      + Glo.add_backlash(static_libs)             + "#@static_libs@/g'"      + '|'
        cmd += "sed -e '1,$ s/@dynamic_libs@/"     + Glo.add_backlash(dynamic_libs)            + "#@dynamic_libs@/g'"     + '|'
        cmd += "sed -e '1,$ s/@lib_includes@/"     + Glo.add_backlash(includes)                + "#@lib_includes@/g'"     + '|'
        cmd += "sed -e '1,$ s/@libs_depend@/"      + Glo.add_backlash(libs)                    + "#@libs_depend@/g'"      + '|'

        if lib_roots_count == 0:
            cmd += ("sed -e '1,$ s/@lib_roots@/#@lib_roots_end@/g'" + '|')
        else:
            cmd += (this_awk + " '{ sub(/@lib_roots@/, \"" + lib_roots + "\"); print }'" + '|')

        if custom_vars_count == 0:
            cmd += ("sed -e '1,$ s/@custom_vars@/#@custom_vars_end@/g'")
        else:
            cmd += (this_awk + " '{ sub(/@custom_vars@/, \"" + custom_vars + "\"); print }'")

        cmd += "> " + Glo.make_rules_path()

        Util.execute_and_output(cmd)
示例#8
0
    def cache_build_by_config(buildc_cfg_path, cmode, force_update=True):
        buildc_cfg = Load.load_buildc_cfg(buildc_cfg_path, Glo.var_str())

        is_valid = Cache.cache_build_by_external_libs(buildc_cfg.external_libs,
                                                      cmode, force_update)
        return is_valid
示例#9
0
    def reconfig(cmode, libs_depend, project_root_path=None):
        makerules = Glo.make_rules_path()

        if (Glo.SYSTEM == 'solaris'):
            this_awk = 'nawk'
        else:
            this_awk = 'gawk'
        print "Reconfig [" + makerules + "]..."

        #Warning if we can not found '@Generated by buildc@' embeded in the Make.rules
        f = open(makerules)
        s = f.read(1024)
        if s.find("@Generated by buildc@") == -1:
            print "Warning: Please make sure the Make.rules file is generated by buildc!"
        f.close()

        c = Load.load_buildc_cfg(Glo.buildc_cfg_path(), Glo.var_str())
        project_name, version, author = c.project
        if project_root_path == None:
            topdir = os.path.abspath('./')
        else:
            topdir = project_root_path
        this_os = Glo.SYSTEM
        this_cpu = Glo.CPU
        cmode = cmode

        if cmode == '64-bit':
            if this_os == 'solaris' and this_cpu == 'x86':
                cc = '/usr/sfw/bin/gcc -m64'
            else:
                cc = 'gcc -m64'
        else:
            cc = 'gcc -m32'

        libs = ''
        includes = ''
        static_libs = ''
        dynamic_libs = ''

        lib_roots = ''
        lib_roots_count = len(libs_depend)
        if not lib_roots_count == 0:
            last_lib = libs_depend[lib_roots_count - 1]
        for (libname, libversion, archives, libpath) in libs_depend:
            if libname == last_lib[0]:
                lib_roots += (libname + '_ROOT = ' + libpath +
                              "#@lib_roots_end@")
            else:
                lib_roots += (libname + '_ROOT = ' + libpath +
                              "#@lib_roots@\\n")

            includes += ('-I $(' + libname + '_ROOT)' + '/include ')
            libs += (' -L $(' + libname + '_ROOT)' + '/lib')
            for archive in archives:
                libs += (' -l' + Glo.libname2compile_option(archive))
                if Glo.is_static_lib(archive):
                    static_libs += (' -L $(' + libname + '_ROOT)' + '/lib')
                    static_libs += (' -l' +
                                    Glo.libname2compile_option(archive))
                else:
                    dynamic_libs += (' -L $(' + libname + '_ROOT)' + '/lib')
                    dynamic_libs += (' -l' +
                                     Glo.libname2compile_option(archive))

        custom_defs = ''
        for cdef in c.custom_defs:
            custom_defs += (cdef + ' ')

        custom_vars = ''
        custom_vars_count = len(c.custom_vars)
        for var in c.custom_vars:
            custom_vars += (var[0] + ' = ' + str(var[1]))
            if var == c.custom_vars[custom_vars_count - 1]:
                custom_vars += "#@custom_vars_end@"
            else:
                custom_vars += "#@custom_vars@\\n"

        custom_includes = ''
        for inc in c.custom_includes:
            custom_includes += ('-I ' + inc + ' ')

        custom_libs = ''
        for (libpath, archives) in c.custom_libs:
            if not len(libpath) == 0:
                custom_libs += (' -L' + libpath)

            for archive in archives:
                custom_libs += (' -l' + Glo.libname2compile_option(archive))
                if Glo.is_static_lib(archive):
                    if not len(libpath) == 0:
                        static_libs += (' -L ' + libpath)
                    static_libs += (' -l' +
                                    Glo.libname2compile_option(archive))
                else:
                    if not len(libpath) == 0:
                        dynamic_libs += (' -L ' + libpath)
                    dynamic_libs += (' -l' +
                                     Glo.libname2compile_option(archive))

        system_libs = ''
        for (libpath, archives) in c.system_libs:
            if not len(libpath) == 0:
                system_libs += (' -L ' + libpath)

            for archive in archives:
                system_libs += (' -l' + Glo.libname2compile_option(archive))

        cmd = "sed -e '1,$ s/=.*@topdir@/= " + Glo.add_backlash(
            topdir) + "#@topdir@/g' " + Glo.make_rules_path() + '|'
        cmd += "sed -e '1,$ s/=.*@os@/= " + this_os + "#@os@/g'" + '|'
        cmd += "sed -e '1,$ s/=.*@cpu@/= " + this_cpu + "#@cpu@/g'" + '|'
        cmd += "sed -e '1,$ s/=.*@cmode@/= " + cmode + "#@cmode@/g'" + '|'
        cmd += "sed -e '1,$ s/=.*@version@/= " + version + "#@version@/g'" + '|'
        cmd += "sed -e '1,$ s/=.*@cc@/= " + Glo.add_backlash(
            cc) + "#@cc@/g'" + '|'
        cmd += "sed -e '1,$ s/=.*@default_includes@/= " + Glo.add_backlash(
            Glo.default_includes) + "#@default_includes@/g'" + '|'
        cmd += "sed -e '1,$ s/=.*@default_libs@/= " + Glo.add_backlash(
            Glo.default_libs) + "#@default_libs@/g'" + '|'
        cmd += "sed -e '1,$ s/=.*@custom_includes@/= " + Glo.add_backlash(
            custom_includes) + "#@custom_includes@/g'" + '|'
        cmd += "sed -e '1,$ s/=.*@custom_libs@/= " + Glo.add_backlash(
            custom_libs) + "#@custom_libs@/g'" + '|'
        cmd += "sed -e '1,$ s/=.*@system_libs@/= " + Glo.add_backlash(
            system_libs) + "#@system_libs@/g'" + '|'
        cmd += "sed -e '1,$ s/=.*@static_libs@/= " + Glo.add_backlash(
            static_libs) + "#@static_libs@/g'" + '|'
        cmd += "sed -e '1,$ s/=.*@dynamic_libs@/= " + Glo.add_backlash(
            dynamic_libs) + "#@dynamic_libs@/g'" + '|'
        cmd += "sed -e '1,$ s/=.*@custom_defs@/= " + custom_defs + "#@custom_defs@/g'" + '|'
        cmd += "sed -e '1,$ s/=.*@lib_includes@/= " + Glo.add_backlash(
            includes) + "#@lib_includes@/g'" + '|'
        cmd += "sed -e '1,$ s/=.*@libs_depend@/= " + Glo.add_backlash(
            libs) + "#@libs_depend@/g'" + '|'
        cmd += "sed -e '/^.*@lib_roots@/d'" + '|'
        cmd += "sed -e '1,$ s/^.*@lib_roots_end@/@lib_roots@/g'" + '|'
        cmd += "sed -e '/^.*@custom_vars@/d'" + '|'
        cmd += "sed -e '1,$ s/^.*@custom_vars_end@/@custom_vars@/g'" + '|'

        if lib_roots_count == 0:
            cmd += ("sed -e '1,$ s/@lib_roots@/#@lib_roots_end@/g'" + '|')
        else:
            cmd += (this_awk + " '{ sub(/@lib_roots@/, \"" + lib_roots +
                    "\"); print }'" + '|')

        if custom_vars_count == 0:
            cmd += ("sed -e '1,$ s/@custom_vars@/#@custom_vars_end@/g'")
        else:
            cmd += (this_awk + " '{ sub(/@custom_vars@/, \"" + custom_vars +
                    "\"); print }'")

        cmd += "> " + Glo.make_rules_temp_path()

        Util.execute_and_output(cmd)
        Util.execute_and_output('mv ' + Glo.make_rules_temp_path() + ' ' +
                                Glo.make_rules_path())

        print "Reconfig [" + makerules + "] OK!"
示例#10
0
    def __config(cmode, libs_depend, project_root_path=None):
        makerules_tpl = Glo.make_rules_tpl_path()

        if (Glo.SYSTEM == 'solaris'):
            this_awk = 'nawk'
        else:
            this_awk = 'gawk'

        c = Load.load_buildc_cfg(Glo.buildc_cfg_path(), Glo.var_str())
        project_name, version, author = c.project
        date = time.strftime('%Y-%m-%d', time.localtime(time.time()))
        if project_root_path == None:
            topdir = os.path.abspath('./')
        else:
            topdir = project_root_path
        this_os = Glo.SYSTEM
        this_cpu = Glo.CPU
        cmode = cmode

        if cmode == '64-bit':
            if this_os == 'solaris' and this_cpu == 'x86':
                cc = '/usr/sfw/bin/gcc -m64'
            else:
                cc = 'gcc -m64'
        else:
            cc = 'gcc -m32'

        libs = ''
        includes = ''
        static_libs = ''
        dynamic_libs = ''

        lib_roots = ''
        lib_roots_count = len(libs_depend)
        if not lib_roots_count == 0:
            last_lib = libs_depend[lib_roots_count - 1]
        for (libname, libversion, archives, libpath) in libs_depend:
            if libname == last_lib[0]:
                lib_roots += (libname + '_ROOT = ' + libpath +
                              "#@lib_roots_end@")
            else:
                lib_roots += (libname + '_ROOT = ' + libpath +
                              "#@lib_roots@\\n")

            includes += ('-I $(' + libname + '_ROOT)' + '/include ')
            libs += (' -L $(' + libname + '_ROOT)' + '/lib')
            for archive in archives:
                libs += (' -l' + Glo.libname2compile_option(archive))
                if Glo.is_static_lib(archive):
                    static_libs += (' -L $(' + libname + '_ROOT)' + '/lib')
                    static_libs += (' -l' +
                                    Glo.libname2compile_option(archive))
                else:
                    dynamic_libs += (' -L $(' + libname + '_ROOT)' + '/lib')
                    dynamic_libs += (' -l' +
                                     Glo.libname2compile_option(archive))

        custom_defs = ''
        for cdef in c.custom_defs:
            custom_defs += (cdef + ' ')

        custom_vars = ''
        custom_vars_count = len(c.custom_vars)
        for var in c.custom_vars:
            custom_vars += (var[0] + ' = ' + str(var[1]))
            if var == c.custom_vars[custom_vars_count - 1]:
                custom_vars += "#@custom_vars_end@"
            else:
                custom_vars += "#@custom_vars@\\n"

        custom_includes = ''
        for inc in c.custom_includes:
            custom_includes += ('-I ' + inc + ' ')

        custom_libs = ''
        for (libpath, archives) in c.custom_libs:
            if not len(libpath) == 0:
                custom_libs += (' -L ' + libpath)

            for archive in archives:
                custom_libs += (' -l' + Glo.libname2compile_option(archive))
                if Glo.is_static_lib(archive):
                    if not len(libpath) == 0:
                        static_libs += (' -L ' + libpath)
                    static_libs += (' -l' +
                                    Glo.libname2compile_option(archive))
                else:
                    if not len(libpath) == 0:
                        dynamic_libs += (' -L ' + libpath)
                    dynamic_libs += (' -l' +
                                     Glo.libname2compile_option(archive))

        system_libs = ''
        for (libpath, archives) in c.system_libs:
            if not len(libpath) == 0:
                system_libs += (' -L ' + libpath)

            for archive in archives:
                system_libs += (' -l' + Glo.libname2compile_option(archive))

        cmd = "sed -e '1,$ s/@project_name@/" + project_name + "/g' " + makerules_tpl + '|'
        cmd += "sed -e '1,$ s/@author@/" + author + "/g'" + '|'
        cmd += "sed -e '1,$ s/@date@/" + date + "/g'" + '|'
        cmd += "sed -e '1,$ s/@topdir@/" + Glo.add_backlash(
            topdir) + "#@topdir@/g'" + '|'
        cmd += "sed -e '1,$ s/@os@/" + this_os + "#@os@/g'" + '|'
        cmd += "sed -e '1,$ s/@cpu@/" + this_cpu + "#@cpu@/g'" + '|'
        cmd += "sed -e '1,$ s/@cmode@/" + cmode + "#@cmode@/g'" + '|'
        cmd += "sed -e '1,$ s/@version@/" + version + "#@version@/g'" + '|'
        cmd += "sed -e '1,$ s/@cc@/" + Glo.add_backlash(cc) + "#@cc@/g'" + '|'
        cmd += "sed -e '1,$ s/@default_includes@/" + Glo.add_backlash(
            Glo.default_includes) + "#@default_includes@/g'" + '|'
        cmd += "sed -e '1,$ s/@default_libs@/" + Glo.add_backlash(
            Glo.default_libs) + "#@default_libs@/g'" + '|'
        cmd += "sed -e '1,$ s/@custom_defs@/" + custom_defs + "#@custom_defs@/g'" + '|'
        cmd += "sed -e '1,$ s/@custom_includes@/" + Glo.add_backlash(
            custom_includes) + "#@custom_includes@/g'" + '|'
        cmd += "sed -e '1,$ s/@custom_libs@/" + Glo.add_backlash(
            custom_libs) + "#@custom_libs@/g'" + '|'
        cmd += "sed -e '1,$ s/@system_libs@/" + Glo.add_backlash(
            system_libs) + "#@system_libs@/g'" + '|'
        cmd += "sed -e '1,$ s/@static_libs@/" + Glo.add_backlash(
            static_libs) + "#@static_libs@/g'" + '|'
        cmd += "sed -e '1,$ s/@dynamic_libs@/" + Glo.add_backlash(
            dynamic_libs) + "#@dynamic_libs@/g'" + '|'
        cmd += "sed -e '1,$ s/@lib_includes@/" + Glo.add_backlash(
            includes) + "#@lib_includes@/g'" + '|'
        cmd += "sed -e '1,$ s/@libs_depend@/" + Glo.add_backlash(
            libs) + "#@libs_depend@/g'" + '|'

        if lib_roots_count == 0:
            cmd += ("sed -e '1,$ s/@lib_roots@/#@lib_roots_end@/g'" + '|')
        else:
            cmd += (this_awk + " '{ sub(/@lib_roots@/, \"" + lib_roots +
                    "\"); print }'" + '|')

        if custom_vars_count == 0:
            cmd += ("sed -e '1,$ s/@custom_vars@/#@custom_vars_end@/g'")
        else:
            cmd += (this_awk + " '{ sub(/@custom_vars@/, \"" + custom_vars +
                    "\"); print }'")

        cmd += "> " + Glo.make_rules_path()

        Util.execute_and_output(cmd)