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
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)
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)
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)
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
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
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)
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
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
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
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
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
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
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
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