Example #1
0
    def pack_create(project_path):
        if project_path == None:
            print "Error: no project name is given!"
            sys.exit(Errors.args_invalid)

        if os.path.exists(project_path):
            print "Error: [" + project_path + "] has already existed!"
            sys.exit(Errors.file_or_dir_exists)

        Util.execute_and_output('mkdir -p ' + project_path)
        Util.execute_and_output('cp ' + Glo.setup_cfg_tpl_path()  + ' ' + project_path + os.sep + 'setup.cfg')
        Util.execute_and_output('mkdir -p ' + project_path + os.sep + 'distributions')
        Util.execute_and_output('mkdir -p ' + project_path + os.sep + 'src' + os.sep + 'app')
        Util.execute_and_output('cp ' + Glo.setup_py_tpl_path()   + ' ' + project_path + os.sep + 'src' + os.sep + 'setup.py')
        Util.execute_and_output('cp ' + Glo.layout_cfg_tpl_path() + ' ' + project_path + os.sep + 'src' + os.sep + 'layout.cfg')
        Util.execute_and_output('touch '    + project_path + os.sep + 'src' + os.sep + 'README')
        Util.execute_and_output('mkdir -p ' + project_path + os.sep + 'src' + os.sep + 'deps')
        Util.execute_and_output('mkdir -p ' + project_path + os.sep + 'src' + os.sep + 'conf')
        Util.execute_and_output('mkdir -p ' + project_path + os.sep + 'src' + os.sep + 'others')
        Util.execute_and_output('mkdir -p ' + project_path + os.sep + 'src' + os.sep + 'scripts')
        Util.execute_and_output('cp ' + Glo.checkc_cfg_tpl_path() + ' ' + project_path + os.sep + 'src' + os.sep + 'scripts' + os.sep + 'deps_check.py')
        Util.execute_and_output('cp ' + Glo.env_gen_py_tpl_path() + ' ' + project_path + os.sep + 'src' + os.sep + 'scripts' + os.sep + 'env_gen.py')
        Util.execute_and_output('touch '    + project_path + os.sep + 'src' + os.sep + 'scripts' + os.sep + '__init__.py')

        return True
Example #2
0
    def cache_remove():
        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)
        for repository in buildc_rc.external_repositories:
            svn_path = repository[0]
            cache_path = Glo.get_local_cache_path(
                svn_path, buildc_rc.external_repositories)

            print "\n===>Begin remove local cache of repository [" + svn_path + ']'
            ret = Util.execute_and_return('rm -rf ' + cache_path)
            if (ret != 0):
                print 'Remove [' + cache_path + '] Failed!'
                sys.exit(ret)
            else:
                print 'Remove [' + cache_path + '] OK!'
            print "\n<=== End remove local cache of repository [" + svn_path + ']'

        dotrepository = Glo.dot_buildc_repository_path()
        svn_tree = SvnTree()
        svn_tree.import_format_tree_from_file(dotrepository)
        svn_tree.take_item_data_by_browse(None, SvnTree.set_empty_node, 1)
        svn_tree.export_format_tree_to_file(dotrepository)
Example #3
0
    def cache_update(cmode, ignore_error):

        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)

        dotrepository = Glo.dot_buildc_repository_path()

        buildc_rc = Load.load_dot_buildc_rc(dotrc)
        cache_svn_tree = CacheSvnTree(buildc_rc.external_repositories)
        cache_svn_tree.import_format_tree_from_file(dotrepository)

        result = cache_svn_tree.check_tree_consistency()
        if result == False:
            return False

        result = cache_svn_tree.is_new_tree(None)
        if result == True:
            print "Warning: local cache does not need to be updated."
            return False

        cache_svn_tree.update_tree(None, cmode, ignore_error)

        cache_svn_tree.export_format_tree_to_file(dotrepository)
Example #4
0
    def pack_build(cmode, tag, force_update):
        build_home = os.getcwd()

        attribute_lists = Pack.__pack_init()
        distribution = attribute_lists.distribution
        source       = attribute_lists.source

        Pack.__do_clean(build_home)

        if "dependences" in list(dir(attribute_lists)):
            dependences = attribute_lists.dependences

            result = Cache.cache_build_by_external_libs(dependences, cmode, force_update)
            if result == False:
                return False

            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)

            dotrepository  = Glo.dot_buildc_repository_path()
            svn_tree = SvnTree()
            svn_tree.import_format_tree_from_file(dotrepository)
            for dependence in dependences:
                Pack.__copy_dependent_library(dependence, svn_tree, buildc_rc, build_home, cmode)

        result = Pack.__do_pack(build_home, source, distribution, cmode, tag, force_update)
        if result == False:
            return False
        return True
Example #5
0
    def __copy_dependent(dependence, svn_tree, buildc_rc, build_home, cmode, dirname):
        if dirname != "include" and dirname != "lib" and dirname != "":
            print 'dirname args invalid'
            sys.exit(Errors.args_invalid)

        (dep_libname, dep_libversion, dep_tagfile) = Glo.get_dependent_name_and_version(dependence)

        h_child_item = svn_tree.get_root_item()
        while(h_child_item != None):
            svn_root_path = svn_tree.get_item_text(h_child_item)
            full_svn_path = svn_root_path + '|' + dep_libname + '|' + dep_libversion + '|' + Glo.CPU + '_' + cmode[0:2] + '_' + Glo.SYSTEM
            leaf_node = svn_tree.find_item(full_svn_path, '|', False, 1)
            if leaf_node != None:

                cache_root_path = Glo.get_local_cache_path(svn_root_path, buildc_rc.external_repositories)
                if cache_root_path == None:
                    print svn_root_path + ' does not exist in .buildc.rc'
                    sys.exit(Errors.conf_item_not_found)

                lib_path      = cache_root_path + '/'     + dep_libname + '/' + dep_libversion + '/' + Glo.CPU + '_' + cmode[0:2] + '_' + Glo.SYSTEM + '/' + dirname
                deps_lib_path = build_home + '/src/deps/' + dep_libname + '/' + dep_libversion + '/' + Glo.CPU + '_' + cmode[0:2] + '_' + Glo.SYSTEM + '/' + dirname

                if dirname == "lib":
                    Pack.__copy_dependent_file(lib_path, deps_lib_path, dep_tagfile)
                else:
                    Pack.__copy_dependent_file(lib_path, deps_lib_path, None)

                return

            h_child_item = svn_tree.get_next_sibling_item(h_child_item)

        print('Can not found ' + dep_libname + '/' + dep_libversion + '/' + Glo.CPU + '_' + cmode[0:2] + '_' + Glo.SYSTEM + \
            ' in external repositories.')
        sys.exit(Errors.file_or_dir_exists)
Example #6
0
    def config_make(cmode, force_update, lib_root_path = None, project_root_path = None):
        buildc_cfg_path = Glo.buildc_cfg_path()
        if not os.path.exists(buildc_cfg_path):
            print 'Can not found buildc.cfg in current directory!'
            print 'Please run buildc config init to generate this file!'
            sys.exit(Errors.conf_file_not_found)

        if not os.path.exists(Glo.dot_buildc_rc_path()):
            print 'Can not found ~/.buildc.rc!'
            print 'Please run buildc init to generate this file!'
            sys.exit(Errors.conf_file_not_found)

        is_valid = Cache.cache_build_by_config(buildc_cfg_path, cmode, force_update)
        if is_valid == False:
            return False
        libs_depend = Makerules.__check_buildc_cfg(cmode, lib_root_path)

        if not os.path.exists(Glo.make_rules_path()):
            print 'Can not found Make.rules in current directory!'
            Makerules.generate(cmode, libs_depend, project_root_path)
        elif os.path.getsize(Glo.make_rules_path()) == 0:
            print 'The Make.rules file is empty in current directory!'
            Makerules.generate(cmode, libs_depend, project_root_path)
        else:
            Makerules.reconfig(cmode, libs_depend, project_root_path)
        return True
Example #7
0
    def cache_remove():
        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)
        for repository in buildc_rc.external_repositories:
            svn_path   = repository[0]
            cache_path = Glo.get_local_cache_path(svn_path, buildc_rc.external_repositories)

            print "\n===>Begin remove local cache of repository [" + svn_path + ']'
            ret = Util.execute_and_return('rm -rf ' + cache_path)
            if (ret != 0):
                print 'Remove [' + cache_path + '] Failed!'
                sys.exit(ret)
            else:
                print 'Remove [' + cache_path + '] OK!'
            print "\n<=== End remove local cache of repository [" + svn_path + ']'

        dotrepository = Glo.dot_buildc_repository_path()
        svn_tree  = SvnTree()
        svn_tree.import_format_tree_from_file(dotrepository)
        svn_tree.take_item_data_by_browse(None, SvnTree.set_empty_node, 1)
        svn_tree.export_format_tree_to_file(dotrepository)
Example #8
0
    def config_make(cmode,
                    force_update,
                    lib_root_path=None,
                    project_root_path=None):
        buildc_cfg_path = Glo.buildc_cfg_path()
        if not os.path.exists(buildc_cfg_path):
            print 'Can not found buildc.cfg in current directory!'
            print 'Please run buildc config init to generate this file!'
            sys.exit(Errors.conf_file_not_found)

        if not os.path.exists(Glo.dot_buildc_rc_path()):
            print 'Can not found ~/.buildc.rc!'
            print 'Please run buildc init to generate this file!'
            sys.exit(Errors.conf_file_not_found)

        is_valid = Cache.cache_build_by_config(buildc_cfg_path, cmode,
                                               force_update)
        if is_valid == False:
            return False
        libs_depend = Makerules.__check_buildc_cfg(cmode, lib_root_path)

        if not os.path.exists(Glo.make_rules_path()):
            print 'Can not found Make.rules in current directory!'
            Makerules.generate(cmode, libs_depend, project_root_path)
        elif os.path.getsize(Glo.make_rules_path()) == 0:
            print 'The Make.rules file is empty in current directory!'
            Makerules.generate(cmode, libs_depend, project_root_path)
        else:
            Makerules.reconfig(cmode, libs_depend, project_root_path)
        return True
Example #9
0
    def cache_update(cmode, ignore_error):

        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)

        dotrepository = Glo.dot_buildc_repository_path()

        buildc_rc  = Load.load_dot_buildc_rc(dotrc)
        cache_svn_tree = CacheSvnTree(buildc_rc.external_repositories)
        cache_svn_tree.import_format_tree_from_file(dotrepository)

        result = cache_svn_tree.check_tree_consistency()
        if result == False:
            return False

        result = cache_svn_tree.is_new_tree(None)
        if result == True:
            print "Warning: local cache does not need to be updated."
            return False

        cache_svn_tree.update_tree(None, cmode, ignore_error)

        cache_svn_tree.export_format_tree_to_file(dotrepository)
Example #10
0
    def cache_upgrade():
        dotrepository = Glo.dot_buildc_repository_path()

        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)

        Cache.__create_dot_repository(dotrc, dotrepository)
        return True
Example #11
0
    def cache_upgrade():
        dotrepository = Glo.dot_buildc_repository_path()

        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)

        Cache.__create_dot_repository(dotrc, dotrepository)
        return True
Example #12
0
    def config_init():
        buildc_cfg_in = Glo.buildc_cfg_tpl_path()

        buildc_cfg_path = Glo.buildc_cfg_path()
        if not os.path.exists(buildc_cfg_path):
            shutil.copyfile(buildc_cfg_in, buildc_cfg_path)
            print "Copy " + buildc_cfg_in + " to " + buildc_cfg_path + " OK!"
            print "Please config buildc.cfg before you use [buildc config make] command!"
        else:
            print 'buildc.cfg has been already existed! Just config it!'

        return True
Example #13
0
    def init():
        dotrc = Glo.dot_buildc_rc_path()
        if os.path.exists(dotrc):
            print dotrc + ' has been already existed! Just config it!'
        else:
            buildc_rc_in = Glo.buildc_rc_tpl_path()
            if os.path.exists(buildc_rc_in):
                shutil.copyfile(buildc_rc_in, dotrc)
                print "Copy " + buildc_rc_in + " to " + dotrc + " OK!"
                print "Please config " +  dotrc  + " before you use other buildc commands!"

        return True
Example #14
0
    def init():
        dotrc = Glo.dot_buildc_rc_path()
        if os.path.exists(dotrc):
            print dotrc + ' has been already existed! Just config it!'
        else:
            buildc_rc_in = Glo.buildc_rc_tpl_path()
            if os.path.exists(buildc_rc_in):
                shutil.copyfile(buildc_rc_in, dotrc)
                print "Copy " + buildc_rc_in + " to " + dotrc + " OK!"
                print "Please config " + dotrc + " before you use other buildc commands!"

        return True
Example #15
0
    def config_init():
        buildc_cfg_in = Glo.buildc_cfg_tpl_path()

        buildc_cfg_path = Glo.buildc_cfg_path()
        if not os.path.exists(buildc_cfg_path):
            shutil.copyfile(buildc_cfg_in, buildc_cfg_path)
            print "Copy " + buildc_cfg_in + " to " + buildc_cfg_path + " OK!"
            print "Please config buildc.cfg before you use [buildc config make] command!"
        else:
            print 'buildc.cfg has been already existed! Just config it!'

        return True
Example #16
0
    def generate(cmode, libs_depend, project_root_path = None):
        makerules     = Glo.make_rules_path()
        makerules_tpl = Glo.make_rules_tpl_path()
        if not os.path.exists(makerules_tpl):
            print 'Can not found ['+ makerules_tpl + ']'
            sys.exit(Errors.tpl_file_not_found)

        print "Generate [" + makerules + "] ..."
        print "Config [" +  makerules  + "] ..."
        Makerules.__config(cmode, libs_depend, project_root_path)
        print "Config [" +  makerules  + "] OK!"
        print "Generate [" + makerules + "] OK!"
Example #17
0
    def generate(cmode, libs_depend, project_root_path=None):
        makerules = Glo.make_rules_path()
        makerules_tpl = Glo.make_rules_tpl_path()
        if not os.path.exists(makerules_tpl):
            print 'Can not found [' + makerules_tpl + ']'
            sys.exit(Errors.tpl_file_not_found)

        print "Generate [" + makerules + "] ..."
        print "Config [" + makerules + "] ..."
        Makerules.__config(cmode, libs_depend, project_root_path)
        print "Config [" + makerules + "] OK!"
        print "Generate [" + makerules + "] OK!"
Example #18
0
    def __build_component_src(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

        is_valid = Makerules.config_make(cmode, force_update,
                                         "$(shell cd ../.; pwd)/deps",
                                         "$(shell cd .; pwd)")
        if is_valid == False:
            os.chdir(build_home)
            print "Cd " + build_home
            return False

        print "Config Make.rules OK!"
        Util.execute_and_output('rm -f buildc.cfg')
        print "Remove buildc.cfg OK!"

        cmd_str =\
"""#! /bin/sh

topdir=`pwd`
parentdir=`cd ../.; pwd`
sed -e "1,$ s%=.*@topdir@%= $topdir#@topdir@%g" Make.rules |\
sed -e "1,$ s%\$(shell cd ../.; pwd)/deps%$parentdir/deps%g"\
> .Make.rules
mv .Make.rules Make.rules

echo "config Make.rules OK!"
"""
        f = open("configure", "w")
        f.write(cmd_str)
        f.close()
        Util.execute_and_output('chmod +x configure')
        print "Create configure OK!"

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

        print 'Build src [' + url + '] OK!'
        return True
Example #19
0
    def cache_init():
        dotrepository = Glo.dot_buildc_repository_path()
        if os.path.exists(dotrepository):
            print dotrepository + ' has been already existed!'
            return False

        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)

        Cache.__create_dot_repository(dotrc, dotrepository)
        return True
Example #20
0
    def cache_init():
        dotrepository = Glo.dot_buildc_repository_path()
        if os.path.exists(dotrepository):
            print dotrepository + ' has been already existed!'
            return False

        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)

        Cache.__create_dot_repository(dotrc, dotrepository)
        return True
Example #21
0
    def check_consistency():
        dotrc = Glo.dot_buildc_rc_path()
        if not os.path.exists(dotrc):
            print 'Can not found ~/.buildc.rc!'
            print 'Please run buildc init to generate this file!'
            sys.exit(Errors.conf_file_not_found)

        dotrepository  = Glo.dot_buildc_repository_path()
        buildc_rc      = Load.load_dot_buildc_rc(dotrc)
        cache_svn_tree = CacheSvnTree(buildc_rc.external_repositories)
        cache_svn_tree.import_format_tree_from_file(dotrepository)

        result = cache_svn_tree.check_tree_consistency()
        if result == False:
            return False
Example #22
0
    def check_consistency():
        dotrc = Glo.dot_buildc_rc_path()
        if not os.path.exists(dotrc):
            print 'Can not found ~/.buildc.rc!'
            print 'Please run buildc init to generate this file!'
            sys.exit(Errors.conf_file_not_found)

        dotrepository = Glo.dot_buildc_repository_path()
        buildc_rc = Load.load_dot_buildc_rc(dotrc)
        cache_svn_tree = CacheSvnTree(buildc_rc.external_repositories)
        cache_svn_tree.import_format_tree_from_file(dotrepository)

        result = cache_svn_tree.check_tree_consistency()
        if result == False:
            return False
Example #23
0
    def cache_remove_by_cmode(cmode):
        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)
        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.remove_tree(None, cmode)

        cache_svn_tree.export_format_tree_to_file(dotrepository)
Example #24
0
    def cache_remove_by_cmode(cmode):
        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)
        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.remove_tree(None, cmode)

        cache_svn_tree.export_format_tree_to_file(dotrepository)
Example #25
0
    def get_cache_libs(self, item, cmode, cache_libs):
        if (item == None):
            h_child_item = self.get_root_item()
        else:
            h_child_item = self.get_child_item(item)

        while(h_child_item != None):
            if (self.get_child_item(h_child_item) == None):
                item_text = self.get_item_text(h_child_item)
                if item_text == Glo.CPU + '_' + cmode[0:2] + '_' + Glo.SYSTEM:
                    full_svn_path = self.get_full_path(h_child_item, '|')[0]

                    svn_root_path = full_svn_path[:str(full_svn_path).find('|')]
                    cache_root_path = Glo.get_local_cache_path(svn_root_path, self.__repositories)
                    if cache_root_path == None:
                        print svn_root_path + ' does not exist in .buildc.rc'
                        sys.exit(Errors.conf_item_not_found)

                    full_cache_path = cache_root_path + '|' + full_svn_path[str(full_svn_path).find('|')+1:]
                    real_cache_path = str(full_cache_path).replace('|', '/')
                    real_cache_version_path = real_cache_path[:str(real_cache_path).rfind('/')]
                    real_cache_name_path    = real_cache_version_path[:str(real_cache_version_path).rfind('/')]
                    cache_libversion = real_cache_version_path[str(real_cache_version_path).rfind('/')+1:]
                    cache_libname    = real_cache_name_path[str(real_cache_name_path).rfind('/')+1:]
                    cache_libs.append((cache_libname, cache_libversion, os.path.expanduser(cache_root_path)))

            self.get_cache_libs(h_child_item, cmode, cache_libs)
            h_child_item = self.get_next_sibling_item(h_child_item)
Example #26
0
    def __build_component_src(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

        is_valid = Makerules.config_make(cmode, force_update, "$(shell cd ../.; pwd)/deps", "$(shell cd .; pwd)")
        if is_valid == False:
            os.chdir(build_home)
            print "Cd " + build_home
            return False

        print "Config Make.rules OK!"
        Util.execute_and_output('rm -f buildc.cfg')
        print "Remove buildc.cfg OK!"

        cmd_str =\
"""#! /bin/sh

topdir=`pwd`
parentdir=`cd ../.; pwd`
sed -e "1,$ s%=.*@topdir@%= $topdir#@topdir@%g" Make.rules |\
sed -e "1,$ s%\$(shell cd ../.; pwd)/deps%$parentdir/deps%g"\
> .Make.rules
mv .Make.rules Make.rules

echo "config Make.rules OK!"
"""
        f = open("configure", "w")
        f.write(cmd_str)
        f.close()
        Util.execute_and_output('chmod +x configure')
        print "Create configure OK!"

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

        print 'Build src [' + url + '] OK!'
        return True
Example #27
0
    def cache_build_by_external_libs(external_libs, cmode, force_update=True):
        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)
        dotrepository = Glo.dot_buildc_repository_path()
        cache_svn_tree = CacheSvnTree(buildc_rc.external_repositories)
        cache_svn_tree.import_format_tree_from_file(dotrepository)

        is_valid = True

        for dependence in external_libs:
            (dep_libname, dep_libversion
             ) = Glo.get_dependent_name_and_version(dependence)[0:2]
            print '\n===>Begin build library [' + dep_libname + ' ' + dep_libversion + ']'
            result = Cache.build_dependent_and_fault_tolerant(
                cache_svn_tree, True, dep_libname, dep_libversion, cmode,
                force_update)
            print '<=== End build library [' + dep_libname + ' ' + dep_libversion + ']'
            if result == False:
                is_valid = False
                break

        if is_valid == False:
            is_valid = True

            cache_svn_tree = CacheSvnTree(buildc_rc.external_repositories)
            cache_svn_tree.import_format_tree_from_file(dotrepository)
            for dependence in external_libs:
                (dep_libname, dep_libversion
                 ) = Glo.get_dependent_name_and_version(dependence)[0:2]
                print '\n===>Begin build library [' + dep_libname + ' ' + dep_libversion + ']'
                result = Cache.build_dependent_and_fault_tolerant(
                    cache_svn_tree, False, dep_libname, dep_libversion, cmode,
                    force_update)
                print '<=== End build library [' + dep_libname + ' ' + dep_libversion + ']'
                if result == False:
                    is_valid = False

        cache_svn_tree.export_format_tree_to_file(dotrepository)
        return is_valid
Example #28
0
    def remove_tree(self, item, cmode):
        if (item == None):
            h_child_item = self.get_root_item()
        else:
            h_child_item = self.get_child_item(item)

        while(h_child_item != None):
            if (self.get_child_item(h_child_item) == None):
                item_text = self.get_item_text(h_child_item)
                if str(item_text).find("_" + cmode[0:2] + "_") != -1:
                    full_svn_path = self.get_full_path(h_child_item, '|')[0]

                    svn_root_path = full_svn_path[:str(full_svn_path).find('|')]
                    cache_root_path = Glo.get_local_cache_path(svn_root_path, self.__repositories)
                    if cache_root_path == None:
                        print svn_root_path + ' does not exist in .buildc.rc'
                        sys.exit(Errors.conf_item_not_found)

                    full_cache_path = cache_root_path + '|' + full_svn_path[str(full_svn_path).find('|')+1:]
                    real_cache_path = str(full_cache_path).replace('|', '/')
                    real_cache_version_path = real_cache_path[:str(real_cache_path).rfind('/')]
                    real_cache_name_path    = real_cache_version_path[:str(real_cache_version_path).rfind('/')]
                    if h_child_item.data == 'none':
                        if os.path.exists(real_cache_path):
                            ret = Util.execute_and_return("rm -rf " + real_cache_path + "/.svn " + real_cache_path)
                            if (ret != 0):
                                print 'Remove [' + real_cache_path + '] Failed!'
                                sys.exit(ret)
                            else:
                                print 'Remove [' + real_cache_path + '] OK!'
                    else:
                        if not os.path.exists(real_cache_path):
                            pass
                        else:
                            ret = Util.execute_and_return("rm -rf " + real_cache_path + "/.svn " + real_cache_path)
                            if (ret != 0):
                                print 'Remove [' + real_cache_path + '] Failed!'
                                sys.exit(ret)
                            else:
                                print 'Remove [' + real_cache_path + '] OK!'

                    if os.path.exists(real_cache_version_path):
                        if len(os.listdir(real_cache_version_path)) == 0:
                            os.rmdir(real_cache_version_path)
                    if os.path.exists(real_cache_name_path):
                        if len(os.listdir(real_cache_name_path)) == 0:
                            os.rmdir(real_cache_name_path)
                    if os.path.exists(cache_root_path):
                        if len(os.listdir(cache_root_path)) == 0:
                            os.rmdir(cache_root_path)

                    h_child_item.data = 'none'

            self.remove_tree(h_child_item, cmode)
            h_child_item = self.get_next_sibling_item(h_child_item)
Example #29
0
    def pack_create(project_path):
        if project_path == None:
            print "Error: no project name is given!"
            sys.exit(Errors.args_invalid)

        if os.path.exists(project_path):
            print "Error: [" + project_path + "] has already existed!"
            sys.exit(Errors.file_or_dir_exists)

        Util.execute_and_output('mkdir -p ' + project_path)
        Util.execute_and_output('cp ' + Glo.setup_cfg_tpl_path() + ' ' +
                                project_path + os.sep + 'setup.cfg')
        Util.execute_and_output('mkdir -p ' + project_path + os.sep +
                                'distributions')
        Util.execute_and_output('mkdir -p ' + project_path + os.sep + 'src' +
                                os.sep + 'app')
        Util.execute_and_output('cp ' + Glo.setup_py_tpl_path() + ' ' +
                                project_path + os.sep + 'src' + os.sep +
                                'setup.py')
        Util.execute_and_output('cp ' + Glo.layout_cfg_tpl_path() + ' ' +
                                project_path + os.sep + 'src' + os.sep +
                                'layout.cfg')
        Util.execute_and_output('touch ' + project_path + os.sep + 'src' +
                                os.sep + 'README')
        Util.execute_and_output('mkdir -p ' + project_path + os.sep + 'src' +
                                os.sep + 'deps')
        Util.execute_and_output('mkdir -p ' + project_path + os.sep + 'src' +
                                os.sep + 'conf')
        Util.execute_and_output('mkdir -p ' + project_path + os.sep + 'src' +
                                os.sep + 'others')
        Util.execute_and_output('mkdir -p ' + project_path + os.sep + 'src' +
                                os.sep + 'scripts')
        Util.execute_and_output('cp ' + Glo.checkc_cfg_tpl_path() + ' ' +
                                project_path + os.sep + 'src' + os.sep +
                                'scripts' + os.sep + 'deps_check.py')
        Util.execute_and_output('cp ' + Glo.env_gen_py_tpl_path() + ' ' +
                                project_path + os.sep + 'src' + os.sep +
                                'scripts' + os.sep + 'env_gen.py')
        Util.execute_and_output('touch ' + project_path + os.sep + 'src' +
                                os.sep + 'scripts' + os.sep + '__init__.py')

        return True
Example #30
0
    def __copy_dependent(dependence, svn_tree, buildc_rc, build_home, cmode,
                         dirname):
        if dirname != "include" and dirname != "lib" and dirname != "":
            print 'dirname args invalid'
            sys.exit(Errors.args_invalid)

        (dep_libname, dep_libversion,
         dep_tagfile) = Glo.get_dependent_name_and_version(dependence)

        h_child_item = svn_tree.get_root_item()
        while (h_child_item != None):
            svn_root_path = svn_tree.get_item_text(h_child_item)
            full_svn_path = svn_root_path + '|' + dep_libname + '|' + dep_libversion + '|' + Glo.CPU + '_' + cmode[
                0:2] + '_' + Glo.SYSTEM
            leaf_node = svn_tree.find_item(full_svn_path, '|', False, 1)
            if leaf_node != None:

                cache_root_path = Glo.get_local_cache_path(
                    svn_root_path, buildc_rc.external_repositories)
                if cache_root_path == None:
                    print svn_root_path + ' does not exist in .buildc.rc'
                    sys.exit(Errors.conf_item_not_found)

                lib_path = cache_root_path + '/' + dep_libname + '/' + dep_libversion + '/' + Glo.CPU + '_' + cmode[
                    0:2] + '_' + Glo.SYSTEM + '/' + dirname
                deps_lib_path = build_home + '/src/deps/' + dep_libname + '/' + dep_libversion + '/' + Glo.CPU + '_' + cmode[
                    0:2] + '_' + Glo.SYSTEM + '/' + dirname

                if dirname == "lib":
                    Pack.__copy_dependent_file(lib_path, deps_lib_path,
                                               dep_tagfile)
                else:
                    Pack.__copy_dependent_file(lib_path, deps_lib_path, None)

                return

            h_child_item = svn_tree.get_next_sibling_item(h_child_item)

        print('Can not found ' + dep_libname + '/' + dep_libversion + '/' + Glo.CPU + '_' + cmode[0:2] + '_' + Glo.SYSTEM + \
            ' in external repositories.')
        sys.exit(Errors.file_or_dir_exists)
Example #31
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
Example #32
0
    def __build_source(build_home, url, cmode, force_update, binary_prefix,
                       pack_path):
        Util.execute_and_output('mkdir -p ' + build_home + os.sep + '.build')
        os.chdir(build_home + os.sep + '.build')
        print "Create dir [.build] OK!"

        SvnLocalOper.export(url, None, None, Glo.source_svn_user(),
                            Glo.source_svn_passwd(), False)
        print "Export [" + url + "] OK!"

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

        result = Makerules.config_make(cmode, force_update)
        if result == False:
            print "Config Make.rules Error!"
            os.chdir(build_home)
            print "Cd " + build_home
            return False

        print "Config Make.rules OK!"

        Pack.__make(cmode)
        print "Make OK!"

        if pack_path != "":
            des_path = build_home + os.sep + 'src' + os.sep + pack_path
            if not os.path.exists(des_path):
                os.mkdir(des_path)
            Util.execute_and_output('cp ' + binary_prefix + '* ' + des_path)
            print "Copy binary file to [" + build_home + os.sep + 'src' + os.sep + pack_path + ']' + " OK!"

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

        print 'Build source [' + url + '] OK!'
        return True
Example #33
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
Example #34
0
    def cache_build_by_external_libs(external_libs, cmode, force_update = True):
        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)
        dotrepository  = Glo.dot_buildc_repository_path()
        cache_svn_tree = CacheSvnTree(buildc_rc.external_repositories)
        cache_svn_tree.import_format_tree_from_file(dotrepository)

        is_valid = True

        for dependence in external_libs:
            (dep_libname, dep_libversion) = Glo.get_dependent_name_and_version(dependence)[0:2]
            print '\n===>Begin build library [' + dep_libname + ' ' + dep_libversion + ']'
            result = Cache.build_dependent_and_fault_tolerant(cache_svn_tree, True, dep_libname, dep_libversion, cmode, force_update)
            print '<=== End build library [' + dep_libname + ' ' + dep_libversion + ']'
            if result == False:
                is_valid = False
                break

        if is_valid == False:
            is_valid = True

            cache_svn_tree = CacheSvnTree(buildc_rc.external_repositories)
            cache_svn_tree.import_format_tree_from_file(dotrepository)
            for dependence in external_libs:
                (dep_libname, dep_libversion) = Glo.get_dependent_name_and_version(dependence)[0:2]
                print '\n===>Begin build library [' + dep_libname + ' ' + dep_libversion + ']'
                result = Cache.build_dependent_and_fault_tolerant(cache_svn_tree, False, dep_libname, dep_libversion, cmode, force_update)
                print '<=== End build library [' + dep_libname + ' ' + dep_libversion + ']'
                if result == False:
                    is_valid = False

        cache_svn_tree.export_format_tree_to_file(dotrepository)
        return is_valid
Example #35
0
    def __build_source(build_home, url, cmode, force_update, binary_prefix, pack_path):
        Util.execute_and_output('mkdir -p ' + build_home + os.sep + '.build')
        os.chdir(build_home + os.sep + '.build')
        print "Create dir [.build] OK!"

        SvnLocalOper.export(url, None, None, Glo.source_svn_user(), Glo.source_svn_passwd(), False)
        print "Export [" + url + "] OK!"

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

        result = Makerules.config_make(cmode, force_update)
        if result == False:
            print "Config Make.rules Error!"
            os.chdir(build_home)
            print "Cd " + build_home
            return False

        print "Config Make.rules OK!"

        Pack.__make(cmode)
        print "Make OK!"

        if pack_path != "":
            des_path = build_home + os.sep + 'src' + os.sep + pack_path
            if not os.path.exists(des_path):
                os.mkdir(des_path)
            Util.execute_and_output('cp ' + binary_prefix + '* ' + des_path)
            print "Copy binary file to [" + build_home + os.sep + 'src' + os.sep + pack_path + ']' + " OK!"

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

        print 'Build source [' + url + '] OK!'
        return True
Example #36
0
    def pack_build(cmode, tag, force_update):
        build_home = os.getcwd()

        attribute_lists = Pack.__pack_init()
        distribution = attribute_lists.distribution
        source = attribute_lists.source

        Pack.__do_clean(build_home)

        if "dependences" in list(dir(attribute_lists)):
            dependences = attribute_lists.dependences

            result = Cache.cache_build_by_external_libs(
                dependences, cmode, force_update)
            if result == False:
                return False

            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)

            dotrepository = Glo.dot_buildc_repository_path()
            svn_tree = SvnTree()
            svn_tree.import_format_tree_from_file(dotrepository)
            for dependence in dependences:
                Pack.__copy_dependent_library(dependence, svn_tree, buildc_rc,
                                              build_home, cmode)

        result = Pack.__do_pack(build_home, source, distribution, cmode, tag,
                                force_update)
        if result == False:
            return False
        return True
Example #37
0
    def update_tree(self, item, cmode, ignore_error):
        if (item == None):
            h_child_item = self.get_root_item()
        else:
            h_child_item = self.get_child_item(item)

        while(h_child_item != None):
            if (self.get_child_item(h_child_item) == None):
                item_text = self.get_item_text(h_child_item)
                if str(item_text).find("_" + cmode[0:2] + "_") != -1:
                    full_svn_path = self.get_full_path(h_child_item, '|')[0]
                    real_svn_path = str(full_svn_path).replace('|', '/')

                    svn_root_path = full_svn_path[:str(full_svn_path).find('|')]
                    cache_root_path = Glo.get_local_cache_path(svn_root_path, self.__repositories)
                    if cache_root_path == None:
                        print svn_root_path + ' does not exist in .buildc.rc'
                        sys.exit(Errors.conf_item_not_found)

                    full_cache_path = cache_root_path + '|' + full_svn_path[str(full_svn_path).find('|')+1:]
                    real_cache_path = str(full_cache_path).replace('|', '/')
                    real_cache_version_path = real_cache_path[:str(real_cache_path).rfind('/')]
                    real_cache_name_path    = real_cache_version_path[:str(real_cache_version_path).rfind('/')]
                    dep_libname    = real_cache_name_path[str(real_cache_name_path).rfind('/')+1:]
                    dep_libversion = real_cache_version_path[str(real_cache_version_path).rfind('/')+1:]
                    (trunk_user, trunk_passwd) = self.__get_user_and_passwd_by_url(svn_root_path)
                    svn_revision_code = SvnLocalOper.get_svn_info_revision_code(real_svn_path, True, trunk_user, trunk_passwd)
                    if h_child_item.data == 'none':
                        if os.path.exists(real_cache_path):
                            Util.execute_and_return("rm -rf " + real_cache_path)

                    else:
                        if not os.path.exists(real_cache_path):
                            print 'library [' + dep_libname + ' ' + dep_libversion + '] does not exist!'
                            print 'Checkout [' + real_svn_path + ']...'
                            SvnLocalOper.checkout(real_svn_path, real_cache_path, ignore_error, trunk_user, trunk_passwd)
                            print 'Checkout [' + real_svn_path + '] OK!'
                        else:
                            cache_revision_code = SvnLocalOper.get_svn_info_revision_code(real_cache_path, None)
                            if svn_revision_code != cache_revision_code:
                                print 'Update [' + dep_libname + ' ' + dep_libversion + ']...'
                                SvnLocalOper.update(real_cache_path, ignore_error, trunk_user, trunk_passwd)
                                print 'Update [' + dep_libname + ' ' + dep_libversion + '] OK!'

                        h_child_item.data = svn_revision_code

            self.update_tree(h_child_item, cmode, ignore_error)
            h_child_item = self.get_next_sibling_item(h_child_item)
Example #38
0
    def __get_url_and_cache_path_list(self):
        url_and_cache_path_list = list()

        url        = None
        cache_path = None
        for item in self.__repositories:
            repository = Glo.get_repository(item)

            if len(repository) == Glo.ONE_TUPLE:
                url = repository[0]

                cache_path = '~/buildc_libs/'
                cache_path += url[str(url).rfind('/')+1:]
                cache_path = os.path.abspath(os.path.expanduser(cache_path))
            elif len(repository) == Glo.TWO_TUPLE or len(repository) == Glo.THREE_TUPLE:
                (url, cache_path) = (repository[0], repository[1])
                cache_path = os.path.abspath(os.path.expanduser(cache_path))
            else:
                print 'tuple number invalid in .buildc.rc'
                sys.exit(Errors.tuple_number_invalid)

            url_and_cache_path_list.append((url, cache_path))
        return url_and_cache_path_list
Example #39
0
    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
Example #40
0
    def get_cache_libs(self, item, cmode, cache_libs):
        if (item == None):
            h_child_item = self.get_root_item()
        else:
            h_child_item = self.get_child_item(item)

        while (h_child_item != None):
            if (self.get_child_item(h_child_item) == None):
                item_text = self.get_item_text(h_child_item)
                if item_text == Glo.CPU + '_' + cmode[0:2] + '_' + Glo.SYSTEM:
                    full_svn_path = self.get_full_path(h_child_item, '|')[0]

                    svn_root_path = full_svn_path[:str(full_svn_path).find('|'
                                                                           )]
                    cache_root_path = Glo.get_local_cache_path(
                        svn_root_path, self.__repositories)
                    if cache_root_path == None:
                        print svn_root_path + ' does not exist in .buildc.rc'
                        sys.exit(Errors.conf_item_not_found)

                    full_cache_path = cache_root_path + '|' + full_svn_path[
                        str(full_svn_path).find('|') + 1:]
                    real_cache_path = str(full_cache_path).replace('|', '/')
                    real_cache_version_path = real_cache_path[:str(
                        real_cache_path).rfind('/')]
                    real_cache_name_path = real_cache_version_path[:str(
                        real_cache_version_path).rfind('/')]
                    cache_libversion = real_cache_version_path[
                        str(real_cache_version_path).rfind('/') + 1:]
                    cache_libname = real_cache_name_path[
                        str(real_cache_name_path).rfind('/') + 1:]
                    cache_libs.append((cache_libname, cache_libversion,
                                       os.path.expanduser(cache_root_path)))

            self.get_cache_libs(h_child_item, cmode, cache_libs)
            h_child_item = self.get_next_sibling_item(h_child_item)
Example #41
0
    def __get_url_and_cache_path_list(self):
        url_and_cache_path_list = list()

        url = None
        cache_path = None
        for item in self.__repositories:
            repository = Glo.get_repository(item)

            if len(repository) == Glo.ONE_TUPLE:
                url = repository[0]

                cache_path = '~/buildc_libs/'
                cache_path += url[str(url).rfind('/') + 1:]
                cache_path = os.path.abspath(os.path.expanduser(cache_path))
            elif len(repository) == Glo.TWO_TUPLE or len(
                    repository) == Glo.THREE_TUPLE:
                (url, cache_path) = (repository[0], repository[1])
                cache_path = os.path.abspath(os.path.expanduser(cache_path))
            else:
                print 'tuple number invalid in .buildc.rc'
                sys.exit(Errors.tuple_number_invalid)

            url_and_cache_path_list.append((url, cache_path))
        return url_and_cache_path_list
Example #42
0
    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
Example #43
0
    def build_dependent(self,
                        dep_libname,
                        dep_libversion,
                        cmode,
                        force_update=True):
        lib_flag = False

        h_child_item = self.get_root_item()
        while (h_child_item != None):
            svn_root_path = self.get_item_text(h_child_item)
            full_svn_path = svn_root_path + '|' + dep_libname + '|' + dep_libversion + '|' + Glo.CPU + '_' + cmode[
                0:2] + '_' + Glo.SYSTEM
            real_svn_path = str(full_svn_path).replace('|', '/')
            leaf_node = self.find_item(full_svn_path, '|', False, 1)
            if leaf_node != None:
                lib_flag = True

                cache_root_path = Glo.get_local_cache_path(
                    svn_root_path, self.__repositories)
                if cache_root_path == None:
                    print svn_root_path + ' does not exist in .buildc.rc'
                    sys.exit(Errors.conf_item_not_found)

                full_cache_path = cache_root_path + '|' + dep_libname + '|' + dep_libversion + '|' + Glo.CPU + '_' + cmode[
                    0:2] + '_' + Glo.SYSTEM
                real_cache_path = str(full_cache_path).replace('|', '/')
                (trunk_user, trunk_passwd
                 ) = self.__get_user_and_passwd_by_url(svn_root_path)
                svn_revision_code = SvnLocalOper.get_svn_info_revision_code(
                    real_svn_path, True, trunk_user, trunk_passwd)
                if svn_revision_code == "":
                    return False
                if leaf_node.data == 'none':
                    if os.path.exists(real_cache_path):
                        Util.execute_and_return("rm -rf " + real_cache_path)

                    print 'library [' + dep_libname + ' ' + dep_libversion + '] does not exist!'
                    print 'Checkout [' + real_svn_path + ']...'
                    result = SvnLocalOper.checkout(real_svn_path,
                                                   real_cache_path, True,
                                                   trunk_user, trunk_passwd)
                    if result == False:
                        return False
                    print 'Checkout [' + real_svn_path + '] OK!'
                    leaf_node.data = svn_revision_code
                else:
                    if not os.path.exists(real_cache_path):
                        print 'library [' + dep_libname + ' ' + dep_libversion + '] does not exist!'
                        print 'Checkout [' + real_svn_path + ']...'
                        result = SvnLocalOper.checkout(real_svn_path,
                                                       real_cache_path, True,
                                                       trunk_user,
                                                       trunk_passwd)
                        if result == False:
                            return False
                        print 'Checkout [' + real_svn_path + '] OK!'
                        leaf_node.data = svn_revision_code
                    else:
                        if force_update:
                            cache_revision_code = SvnLocalOper.get_svn_info_revision_code(
                                real_cache_path, True)
                            if cache_revision_code == "":
                                return False
                            if svn_revision_code != cache_revision_code:
                                print 'Update [' + dep_libname + ' ' + dep_libversion + ']...'
                                result = SvnLocalOper.update(
                                    real_cache_path, True, trunk_user,
                                    trunk_passwd)
                                if result == False:
                                    return False
                                print 'Update [' + dep_libname + ' ' + dep_libversion + '] OK!'
                            leaf_node.data = svn_revision_code
                        else:
                            print "Do not use force_update, skip the update check!"
                            pass

                break

            h_child_item = self.get_next_sibling_item(h_child_item)

        if lib_flag == True:
            return True
        else:
            return False
Example #44
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)
Example #45
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
Example #46
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!"
Example #47
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
Example #48
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!"
Example #49
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)
Example #50
0
    def update_tree(self, item, cmode, ignore_error):
        if (item == None):
            h_child_item = self.get_root_item()
        else:
            h_child_item = self.get_child_item(item)

        while (h_child_item != None):
            if (self.get_child_item(h_child_item) == None):
                item_text = self.get_item_text(h_child_item)
                if str(item_text).find("_" + cmode[0:2] + "_") != -1:
                    full_svn_path = self.get_full_path(h_child_item, '|')[0]
                    real_svn_path = str(full_svn_path).replace('|', '/')

                    svn_root_path = full_svn_path[:str(full_svn_path).find('|'
                                                                           )]
                    cache_root_path = Glo.get_local_cache_path(
                        svn_root_path, self.__repositories)
                    if cache_root_path == None:
                        print svn_root_path + ' does not exist in .buildc.rc'
                        sys.exit(Errors.conf_item_not_found)

                    full_cache_path = cache_root_path + '|' + full_svn_path[
                        str(full_svn_path).find('|') + 1:]
                    real_cache_path = str(full_cache_path).replace('|', '/')
                    real_cache_version_path = real_cache_path[:str(
                        real_cache_path).rfind('/')]
                    real_cache_name_path = real_cache_version_path[:str(
                        real_cache_version_path).rfind('/')]
                    dep_libname = real_cache_name_path[str(real_cache_name_path
                                                           ).rfind('/') + 1:]
                    dep_libversion = real_cache_version_path[
                        str(real_cache_version_path).rfind('/') + 1:]
                    (trunk_user, trunk_passwd
                     ) = self.__get_user_and_passwd_by_url(svn_root_path)
                    svn_revision_code = SvnLocalOper.get_svn_info_revision_code(
                        real_svn_path, True, trunk_user, trunk_passwd)
                    if h_child_item.data == 'none':
                        if os.path.exists(real_cache_path):
                            Util.execute_and_return("rm -rf " +
                                                    real_cache_path)

                    else:
                        if not os.path.exists(real_cache_path):
                            print 'library [' + dep_libname + ' ' + dep_libversion + '] does not exist!'
                            print 'Checkout [' + real_svn_path + ']...'
                            SvnLocalOper.checkout(real_svn_path,
                                                  real_cache_path,
                                                  ignore_error, trunk_user,
                                                  trunk_passwd)
                            print 'Checkout [' + real_svn_path + '] OK!'
                        else:
                            cache_revision_code = SvnLocalOper.get_svn_info_revision_code(
                                real_cache_path, None)
                            if svn_revision_code != cache_revision_code:
                                print 'Update [' + dep_libname + ' ' + dep_libversion + ']...'
                                SvnLocalOper.update(real_cache_path,
                                                    ignore_error, trunk_user,
                                                    trunk_passwd)
                                print 'Update [' + dep_libname + ' ' + dep_libversion + '] OK!'

                        h_child_item.data = svn_revision_code

            self.update_tree(h_child_item, cmode, ignore_error)
            h_child_item = self.get_next_sibling_item(h_child_item)
Example #51
0
    def build_dependent(self, dep_libname, dep_libversion, cmode, force_update = True):
        lib_flag = False

        h_child_item = self.get_root_item()
        while(h_child_item != None):
            svn_root_path = self.get_item_text(h_child_item)
            full_svn_path = svn_root_path + '|' + dep_libname + '|' + dep_libversion + '|' + Glo.CPU + '_' + cmode[0:2] + '_' + Glo.SYSTEM
            real_svn_path = str(full_svn_path).replace('|', '/')
            leaf_node = self.find_item(full_svn_path, '|', False, 1)
            if leaf_node != None:
                lib_flag = True

                cache_root_path = Glo.get_local_cache_path(svn_root_path, self.__repositories)
                if cache_root_path == None:
                    print svn_root_path + ' does not exist in .buildc.rc'
                    sys.exit(Errors.conf_item_not_found)

                full_cache_path = cache_root_path + '|' + dep_libname + '|' + dep_libversion + '|' + Glo.CPU + '_' + cmode[0:2] + '_' + Glo.SYSTEM
                real_cache_path = str(full_cache_path).replace('|', '/')
                (trunk_user, trunk_passwd) = self.__get_user_and_passwd_by_url(svn_root_path)
                svn_revision_code = SvnLocalOper.get_svn_info_revision_code(real_svn_path, True, trunk_user, trunk_passwd)
                if svn_revision_code == "":
                    return False
                if leaf_node.data == 'none':
                    if os.path.exists(real_cache_path):
                        Util.execute_and_return("rm -rf " + real_cache_path)

                    print 'library [' + dep_libname + ' ' + dep_libversion + '] does not exist!'
                    print 'Checkout [' + real_svn_path + ']...'
                    result = SvnLocalOper.checkout(real_svn_path, real_cache_path, True, trunk_user, trunk_passwd)
                    if result == False:
                        return False
                    print 'Checkout [' + real_svn_path + '] OK!'
                    leaf_node.data = svn_revision_code
                else:
                    if not os.path.exists(real_cache_path):
                        print 'library [' + dep_libname + ' ' + dep_libversion + '] does not exist!'
                        print 'Checkout [' + real_svn_path + ']...'
                        result = SvnLocalOper.checkout(real_svn_path, real_cache_path, True, trunk_user, trunk_passwd)
                        if result == False:
                            return False
                        print 'Checkout [' + real_svn_path + '] OK!'
                        leaf_node.data = svn_revision_code
                    else:
                        if force_update:
                            cache_revision_code = SvnLocalOper.get_svn_info_revision_code(real_cache_path, True)
                            if cache_revision_code == "":
                                return False
                            if svn_revision_code != cache_revision_code:
                                print 'Update [' + dep_libname + ' ' + dep_libversion + ']...'
                                result = SvnLocalOper.update(real_cache_path, True, trunk_user, trunk_passwd)
                                if result == False:
                                    return False
                                print 'Update [' + dep_libname + ' ' + dep_libversion + '] OK!'
                            leaf_node.data = svn_revision_code
                        else:
                            print "Do not use force_update, skip the update check!"
                            pass

                break

            h_child_item = self.get_next_sibling_item(h_child_item)

        if lib_flag == True:
            return True
        else:
            return False
Example #52
0
    def remove_tree(self, item, cmode):
        if (item == None):
            h_child_item = self.get_root_item()
        else:
            h_child_item = self.get_child_item(item)

        while (h_child_item != None):
            if (self.get_child_item(h_child_item) == None):
                item_text = self.get_item_text(h_child_item)
                if str(item_text).find("_" + cmode[0:2] + "_") != -1:
                    full_svn_path = self.get_full_path(h_child_item, '|')[0]

                    svn_root_path = full_svn_path[:str(full_svn_path).find('|'
                                                                           )]
                    cache_root_path = Glo.get_local_cache_path(
                        svn_root_path, self.__repositories)
                    if cache_root_path == None:
                        print svn_root_path + ' does not exist in .buildc.rc'
                        sys.exit(Errors.conf_item_not_found)

                    full_cache_path = cache_root_path + '|' + full_svn_path[
                        str(full_svn_path).find('|') + 1:]
                    real_cache_path = str(full_cache_path).replace('|', '/')
                    real_cache_version_path = real_cache_path[:str(
                        real_cache_path).rfind('/')]
                    real_cache_name_path = real_cache_version_path[:str(
                        real_cache_version_path).rfind('/')]
                    if h_child_item.data == 'none':
                        if os.path.exists(real_cache_path):
                            ret = Util.execute_and_return("rm -rf " +
                                                          real_cache_path +
                                                          "/.svn " +
                                                          real_cache_path)
                            if (ret != 0):
                                print 'Remove [' + real_cache_path + '] Failed!'
                                sys.exit(ret)
                            else:
                                print 'Remove [' + real_cache_path + '] OK!'
                    else:
                        if not os.path.exists(real_cache_path):
                            pass
                        else:
                            ret = Util.execute_and_return("rm -rf " +
                                                          real_cache_path +
                                                          "/.svn " +
                                                          real_cache_path)
                            if (ret != 0):
                                print 'Remove [' + real_cache_path + '] Failed!'
                                sys.exit(ret)
                            else:
                                print 'Remove [' + real_cache_path + '] OK!'

                    if os.path.exists(real_cache_version_path):
                        if len(os.listdir(real_cache_version_path)) == 0:
                            os.rmdir(real_cache_version_path)
                    if os.path.exists(real_cache_name_path):
                        if len(os.listdir(real_cache_name_path)) == 0:
                            os.rmdir(real_cache_name_path)
                    if os.path.exists(cache_root_path):
                        if len(os.listdir(cache_root_path)) == 0:
                            os.rmdir(cache_root_path)

                    h_child_item.data = 'none'

            self.remove_tree(h_child_item, cmode)
            h_child_item = self.get_next_sibling_item(h_child_item)