Ejemplo n.º 1
0
    def __do_pack(build_home, source, distribution, cmode, tag, force_update):
        url = ''

        pack_path = ""
        if tag != None:
            url       = tag
            pack_path = 'app'
            result = Pack.__build_source(build_home, url, cmode, force_update, source[0]["binary_prefix"], pack_path)
            if result == False:
                return False
        else:
            for index in range(len(source)):
                url = source[index]["trunk"]
                if dict(source[index]).get("pack_path") == None:
                    pack_path = 'app'
                else:
                    pack_path = source[index]["pack_path"]
                result = Pack.__build_source(build_home, url, cmode, force_update, source[index]["binary_prefix"], pack_path)
                if result == False:
                    return False

        Pack.__build_version(build_home, source, cmode, tag)

        Util.execute_and_output('rm -fr ' + build_home + '/.build')
        print('Del [.build] OK!')

        Pack.__make_package(build_home, distribution, cmode)
        return True
Ejemplo n.º 2
0
    def memory_free_size():
        size = 0

        system_name = SystemLocalInfo.system()
        if system_name == 'linux':
            s = Util.execute_and_output('free -m', True)
            if s == None:
                SystemLocalInfo.error_info_str = "checking for free -m command fails ... no"
                return -1

            s_prefix = 'buffers/cache'
            s_code   = s[s.find(s_prefix):s.find(s_prefix)+50]
            size = re.findall("\d+", s_code)[1]
            return int(size)
        elif system_name == 'solaris':
            s = Util.execute_and_output('top | head -n 4', True)
            if s == None:
                SystemLocalInfo.error_info_str = "checking for top | head -n 4 command fails ... no"
                return -1

            size = re.findall("(\d+)M free mem", s)[0]
            return int(size)
        else:
            SystemLocalInfo.error_info_str = None
            return -1
Ejemplo n.º 3
0
    def system_bit():
        bit = None

        system_name = SystemLocalInfo.system()
        if system_name == 'linux':
            bit = Util.execute_and_output('getconf LONG_BIT')
            return bit
        elif system_name == 'solaris':
            bit = Util.execute_and_output('isainfo -b')
            return bit
        else:
            return 'unknown'
Ejemplo n.º 4
0
    def system_version():
        version = None

        system_name = SystemLocalInfo.system()
        if system_name == 'linux':
            s = Util.execute_and_output('cat /etc/redhat-release')
            s_prefix = 'release'
            s_code   = s[s.find(s_prefix):s.find(s_prefix)+50]
            version = re.findall("((\d+\.)*\d+)", s_code)[0][0]
            return version
        elif system_name == 'solaris':
            version = Util.execute_and_output('uname -r')
            return version
        else:
            return 'unknown'
Ejemplo n.º 5
0
    def memory_total_size():
        size = 0

        system_name = SystemLocalInfo.system()
        if system_name == 'linux':
            s = Util.execute_and_output('free -m', True)
            if s == None:
                SystemLocalInfo.error_info_str = "checking for free -m command fails ... no"
                return -1

            size = re.findall("\d+", s)[0]
            return int(size)
        elif system_name == 'solaris':
            s = Util.execute_and_output('/usr/sbin/prtconf -vp | grep Mem')
            size = re.findall("\d+", s)[0]
            return int(size)
        else:
            SystemLocalInfo.error_info_str = None
            return -1
Ejemplo n.º 6
0
    def get_shell_type():
        cmd_output = Util.execute_and_output('echo $SHELL')
        match_str = re.findall('\/.*\/.*', cmd_output)[0]

        if match_str == '/bin/csh':
            return 'csh'
        elif match_str == '/bin/bash':
            return 'bash'
        else:
            return 'unknown'
Ejemplo n.º 7
0
    def cpu():
        s = Util.execute_and_output('uname -p')

        if (s == 'sparc'):
            return 'sparc'
        if (s == 'i386'):
            return 'x86'
        if (s == 'x86_64'):
            return 'x86'
        else:
            return 'unknown'
Ejemplo n.º 8
0
    def system():
        s = Util.execute_and_output('uname -s')

        if (s == 'Linux'):
            return 'linux'
        if (s == 'SunOS'):
            return 'solaris'
        if (s == 'CYGWIN_NT-6.1-WOW64'):
            return 'CYGWIN_NT-6.1-WOW64'
        else:
            return 'unknown'
Ejemplo n.º 9
0
    def __do_component_src_pack(build_home, source, distribution, cmode, tag, force_update):
        url = ''
        if tag != None:
            url = tag
            is_valid = Pack.__build_component_src(build_home, url, cmode, force_update)
            if is_valid == False:
                return False
        else:
            for index in range(len(source)):
                url = source[index]["trunk"]
                is_valid = Pack.__build_component_src(build_home, url, cmode, force_update)
                if is_valid == False:
                    return False

        Pack.__build_version(build_home, source, cmode, tag)

        Pack.__make_component_src_package(build_home, distribution, cmode)

        Util.execute_and_output('rm -fr ' + build_home + '/.build')
        print 'Del [.build] OK!'
        return True
Ejemplo n.º 10
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
Ejemplo n.º 11
0
    def __make_component_all_package(build_home, distribution, cmode):
        os.chdir(build_home)

        Util.execute_and_output('mkdir -p ' + build_home + os.sep + '.package')
        print "Create dir [.package] OK!"

        target_prefix = distribution["packname"] + \
               '-' + distribution["version"] + \
               '-' + Glo.CPU + \
               '-' + Glo.SYSTEM + \
               '-' + cmode[:2] + 'bit' + '-full' + Glo.PACK_SUFFIX

        src_path = build_home + os.sep + 'src' + os.sep + 'deps'
        dst_path = build_home + os.sep + '.package' + os.sep + target_prefix + os.sep + 'deps'
        DataOper.copy_tree_ex(src_path, dst_path, [".svn"], ["*"], True)
        print "copy %s to %s" % (src_path, dst_path)

        src_path = build_home + '/.build'
        dst_path = build_home + '/.package/' + target_prefix
        DataOper.copy_tree_ex(src_path, dst_path, [".svn"], ["*"], True)
        print "copy %s to %s" % (src_path, dst_path)
        shutil.copy2(build_home + '/src/VERSION', build_home + '/.package/' + target_prefix)

        os.chdir(build_home + os.sep + '.package')
        print "Cd " + build_home + os.sep + '.package'

        Util.execute_and_output('tar cvf ' + target_prefix + '.tar ' + target_prefix)
        print 'Generate ' + target_prefix + '.tar' + ' OK!'

        Util.execute_and_output('gzip ' + target_prefix + '.tar')
        print('Zip ' + target_prefix + '.tar' + ' OK!')

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

        Util.execute_and_output('mv .package/' + target_prefix + '.tar.gz ' + 'distributions')
        Util.execute_and_output('rm -fr ' + build_home + '/.package')
        print 'Del [.package] OK!'

        print 'Make target [' + target_prefix + '.tar.gz] OK!'
Ejemplo n.º 12
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
Ejemplo n.º 13
0
    def __make_component_src_package(build_home, distribution, cmode):
        os.chdir(build_home)

        Util.execute_and_output('mkdir -p ' + build_home + os.sep + '.package')
        print "Create dir [.package] OK!"

        target_prefix = distribution["packname"] + \
               '-' + distribution["version"] + \
               '-' + Glo.CPU + \
               '-' + Glo.SYSTEM + \
               '-' + cmode[:2] + 'bit' + '-src' + Glo.PACK_SUFFIX

        src_path = build_home + '/.build'
        dst_path = build_home + '/.package/' + target_prefix
        DataOper.copy_tree_ex(src_path, dst_path, [".svn"], ["*"], True)
        print "copy %s to %s" % (src_path, dst_path)

        shutil.copy2(build_home + '/src/VERSION',
                     build_home + '/.package/' + target_prefix)

        os.chdir(build_home + os.sep + '.package')
        print "Cd " + build_home + os.sep + '.package'

        Util.execute_and_output('tar cvf ' + target_prefix + '.tar ' +
                                target_prefix)
        print 'Generate ' + target_prefix + '.tar' + ' OK!'

        Util.execute_and_output('gzip ' + target_prefix + '.tar')
        print('Zip ' + target_prefix + '.tar' + ' OK!')

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

        Util.execute_and_output('mv .package/' + target_prefix + '.tar.gz ' +
                                'distributions')
        Util.execute_and_output('rm -fr ' + build_home + '/.package')
        print 'Del [.package] OK!'

        print 'Make target [' + target_prefix + '.tar.gz] OK!'
Ejemplo n.º 14
0
    def export(svn_path, download_path = None, ignore_error = None, trunk_user = None, trunk_pass = None, ignore_hint = True):
        if download_path != None:
            Util.execute_and_output("rm -rf " + download_path)

        cmd_str  = "svn export " + "\"" + svn_path +"\""
        if download_path != None:
            cmd_str += " " + "\"" + download_path +"\""
        if trunk_user != None and trunk_pass != None and \
            trunk_user != "" and trunk_pass != "":
            cmd_str += " " + "--username " + trunk_user
            cmd_str += " " + "--password " + trunk_pass
        cmd_str += " --no-auth-cache"

        if not ignore_hint:
            print "command: " + cmd_str
        err = Util.execute_and_return(cmd_str)
        if err != 0:
            print "Failed to execute cmd [%s], errno = [%d]" % (cmd_str, err)
            if (ignore_error == None):
                sys.exit(err)
            return False
        return True
Ejemplo n.º 15
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
Ejemplo n.º 16
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
Ejemplo n.º 17
0
    def get_svn_ls(svn_path, ignore_error = None, trunk_user = None, trunk_pass = None):
        cmd_str = "svn ls " + "\"" + svn_path +"\""
        if trunk_user != None and trunk_pass != None and \
            trunk_user != "" and trunk_pass != "":
            cmd_str += " " + "--username " + trunk_user
            cmd_str += " " + "--password " + trunk_pass
        cmd_str += " --no-auth-cache"

        svn_ls_str = Util.execute_and_output(cmd_str, ignore_error)
        if svn_ls_str == None:
            return []
        if svn_ls_str == "":
            return []
        item_nodes = str(svn_ls_str).split("\n")
        return item_nodes
Ejemplo n.º 18
0
    def __make_package(build_home, distribution, cmode):
        os.chdir(build_home)

        Util.execute_and_output('mkdir -p ' + build_home + os.sep + '.package')
        print "Create dir [.package] OK!"

        target_prefix = distribution["packname"] + \
                '-' + distribution["version"] + \
                '-' + Glo.CPU + \
                '-' + Glo.SYSTEM + \
                '-' + cmode[:2] + 'bit' + Glo.PACK_SUFFIX

        src_path = build_home + os.sep + 'src'
        dst_path = build_home + os.sep + '.package' + os.sep + target_prefix
        DataOper.copy_tree_ex(src_path, dst_path, [".svn"], ["*"], True)
        print "copy %s to %s" % (src_path, dst_path)

        os.chdir(build_home + os.sep + '.package')
        print "Cd " + build_home + os.sep + '.package'

        Util.execute_and_output('tar cvf ' + target_prefix + '.tar ' + target_prefix)
        print 'Generate ' + target_prefix + '.tar' + ' OK!'

        Util.execute_and_output('gzip ' + target_prefix + '.tar')
        print('Zip ' + target_prefix + '.tar' + ' OK!')

        os.chdir(build_home)
        print('Cd ' + build_home)
        des_path = 'distributions'
        if not os.path.exists(des_path):
            os.mkdir(des_path)
        Util.execute_and_output('mv .package/' + target_prefix + '.tar.gz ' + des_path)
        Util.execute_and_output('rm -fr ' + build_home + '/.package')
        print 'Del [.package] OK!'

        print('Make target [' + target_prefix + '.tar.gz] OK!')
Ejemplo n.º 19
0
    def __do_component_src_pack(build_home, source, distribution, cmode, tag,
                                force_update):
        url = ''
        if tag != None:
            url = tag
            is_valid = Pack.__build_component_src(build_home, url, cmode,
                                                  force_update)
            if is_valid == False:
                return False
        else:
            for index in range(len(source)):
                url = source[index]["trunk"]
                is_valid = Pack.__build_component_src(build_home, url, cmode,
                                                      force_update)
                if is_valid == False:
                    return False

        Pack.__build_version(build_home, source, cmode, tag)

        Pack.__make_component_src_package(build_home, distribution, cmode)

        Util.execute_and_output('rm -fr ' + build_home + '/.build')
        print 'Del [.build] OK!'
        return True
Ejemplo n.º 20
0
    def get_svn_ls(svn_path,
                   ignore_error=None,
                   trunk_user=None,
                   trunk_pass=None):
        cmd_str = "svn ls " + "\"" + svn_path + "\""
        if trunk_user != None and trunk_pass != None and \
            trunk_user != "" and trunk_pass != "":
            cmd_str += " " + "--username " + trunk_user
            cmd_str += " " + "--password " + trunk_pass
        cmd_str += " --no-auth-cache"

        svn_ls_str = Util.execute_and_output(cmd_str, ignore_error)
        if svn_ls_str == None:
            return []
        if svn_ls_str == "":
            return []
        item_nodes = str(svn_ls_str).split("\n")
        return item_nodes
Ejemplo n.º 21
0
    def get_svn_info_revision_code(path, ignore_error = None, trunk_user = None, trunk_pass = None):
        cmd_str  = "svn info " + "\"" + path +"\""
        if trunk_user != None and trunk_pass != None and \
            trunk_user != "" and trunk_pass != "":
            cmd_str += " " + "--username " + trunk_user
            cmd_str += " " + "--password " + trunk_pass
        cmd_str += " --no-auth-cache"
        svn_info_str = Util.execute_and_output(cmd_str, ignore_error)

        if svn_info_str == None:
            return ""
        if svn_info_str.startswith("svn: warning:"):
            return ""

        revision_code = re.findall(" (\d+)\n", svn_info_str)
        #revision_code: list of two elements, a revision number, a last changed rev

        if len(revision_code) == 0:
            return ""

        return revision_code[0]
Ejemplo n.º 22
0
    def get_svn_info_revision_code(path,
                                   ignore_error=None,
                                   trunk_user=None,
                                   trunk_pass=None):
        cmd_str = "svn info " + "\"" + path + "\""
        if trunk_user != None and trunk_pass != None and \
            trunk_user != "" and trunk_pass != "":
            cmd_str += " " + "--username " + trunk_user
            cmd_str += " " + "--password " + trunk_pass
        cmd_str += " --no-auth-cache"
        svn_info_str = Util.execute_and_output(cmd_str, ignore_error)

        if svn_info_str == None:
            return ""
        if svn_info_str.startswith("svn: warning:"):
            return ""

        revision_code = re.findall(" (\d+)\n", svn_info_str)
        #revision_code: list of two elements, a revision number, a last changed rev

        if len(revision_code) == 0:
            return ""

        return revision_code[0]
Ejemplo n.º 23
0
    def harddisk_free_size():
        size = 0

        system_name = SystemLocalInfo.system()

        s = Util.execute_and_output("df -h | sed \'1d\'")
        step = 6
        unit = 1024
        s_list = re.split('[\t\n]?\s\s*|\n', s)
        if len(s_list) % step != 0:
            print "error: the length of the list is invalid."
            sys.exit(Errors.logical_errors)
        if system_name == 'linux':
            index = 3
            count = len(s_list) / step
            size = 0
            i = 0
            while (i < count):
                if str(s_list[index])[-1] == "G":
                    size += float(str(s_list[index])[:-1]) * unit * unit
                elif str(s_list[index])[-1] == "M":
                    size += float(str(s_list[index])[:-1]) * unit
                elif str(s_list[index])[-1] == "K":
                    size += float(str(s_list[index])[:-1])
                else:
                    if str(s_list[index]) == "0":
                        size += 0
                    else:
                        print "error: the list element is invalid."
                        sys.exit(Errors.logical_errors)
                index += step
                i += 1

            size = int(size / unit / unit)
            return size

        elif system_name == 'solaris':
            index = 3
            count = len(s_list) / step
            size = 0

            swap_num = 0
            i = 0
            while (i < count):
                if str(s_list[index-3]).startswith("/dev/dsk") == False and \
                    str(s_list[index-3]) != "swap":
                    index += step
                    i += 1
                    continue

                if str(s_list[index - 3]) == "swap":
                    swap_num += 1
                    if swap_num > 1:
                        index += step
                        i += 1
                        continue

                if str(s_list[index])[-1] == "G":
                    size += float(str(s_list[index])[:-1]) * unit * unit
                elif str(s_list[index])[-1] == "M":
                    size += float(str(s_list[index])[:-1]) * unit
                elif str(s_list[index])[-1] == "K":
                    size += float(str(s_list[index])[:-1])
                else:
                    if str(s_list[index]) == "0":
                        size += 0
                    else:
                        print "error: the list element is invalid."
                        sys.exit(Errors.logical_errors)

                index += step
                i += 1

            size = int(size / unit / unit)
            return size

        else:
            return -1
Ejemplo n.º 24
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!"
Ejemplo n.º 25
0
    def harddisk_free_size():
        size = 0

        system_name = SystemLocalInfo.system()

        s = Util.execute_and_output("df -h | sed \'1d\'")
        step = 6
        unit = 1024
        s_list = re.split('[\t\n]?\s\s*|\n', s)
        if len(s_list) % step != 0:
            print "error: the length of the list is invalid."
            sys.exit(Errors.logical_errors)
        if system_name == 'linux':
            index = 3
            count = len(s_list) / step
            size = 0
            i = 0
            while(i < count):
                if str(s_list[index])[-1] == "G":
                    size += float(str(s_list[index])[:-1])*unit*unit
                elif str(s_list[index])[-1] == "M":
                    size += float(str(s_list[index])[:-1])*unit
                elif str(s_list[index])[-1] == "K":
                    size += float(str(s_list[index])[:-1])
                else:
                    if str(s_list[index]) == "0":
                        size += 0
                    else:
                        print "error: the list element is invalid."
                        sys.exit(Errors.logical_errors)
                index += step
                i += 1

            size = int(size/unit/unit)
            return size

        elif system_name == 'solaris':
            index = 3
            count = len(s_list) / step
            size = 0

            swap_num = 0
            i = 0
            while(i < count):
                if str(s_list[index-3]).startswith("/dev/dsk") == False and \
                    str(s_list[index-3]) != "swap":
                    index += step
                    i += 1
                    continue

                if str(s_list[index-3]) == "swap":
                    swap_num += 1
                    if swap_num > 1:
                        index += step
                        i += 1
                        continue

                if str(s_list[index])[-1] == "G":
                    size += float(str(s_list[index])[:-1])*unit*unit
                elif str(s_list[index])[-1] == "M":
                    size += float(str(s_list[index])[:-1])*unit
                elif str(s_list[index])[-1] == "K":
                    size += float(str(s_list[index])[:-1])
                else:
                    if str(s_list[index]) == "0":
                        size += 0
                    else:
                        print "error: the list element is invalid."
                        sys.exit(Errors.logical_errors)

                index += step
                i += 1

            size = int(size/unit/unit)
            return size

        else:
            return -1
Ejemplo n.º 26
0
    def __do_clean(build_home):
        Util.execute_and_output('rm -fr ' + build_home + '/.build')
        print 'Clean [.build] OK!'

        Util.execute_and_output('rm -fr ' + build_home + '/.package')
        print 'Clean [.package] OK!'

        Util.execute_and_output('rm -f ' + build_home + '/src/app/*')
        print 'Clean [./src/app] OK!'

        Util.execute_and_output('rm -f ' + build_home + '/src/lib/*')
        print 'Clean [./src/lib] OK!'

        Util.execute_and_output('rm -fr ' + build_home + '/src/deps/*')
        print 'Clean [./src/deps] OK!'

        Util.execute_and_output('rm -f ' + build_home +
                                '/distributions/*.tar.gz')
        print 'Clean [./distributions] OK!'

        return True
Ejemplo n.º 27
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)
Ejemplo n.º 28
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
Ejemplo n.º 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
Ejemplo n.º 30
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)
Ejemplo n.º 31
0
    def __do_clean(build_home):
        Util.execute_and_output('rm -fr ' + build_home + '/.build')
        print 'Clean [.build] OK!'

        Util.execute_and_output('rm -fr ' + build_home + '/.package')
        print 'Clean [.package] OK!'

        Util.execute_and_output('rm -f ' + build_home + '/src/app/*')
        print 'Clean [./src/app] OK!'

        Util.execute_and_output('rm -f ' + build_home + '/src/lib/*')
        print 'Clean [./src/lib] OK!'

        Util.execute_and_output('rm -fr ' + build_home + '/src/deps/*')
        print 'Clean [./src/deps] OK!'

        Util.execute_and_output('rm -f ' + build_home + '/distributions/*.tar.gz')
        print 'Clean [./distributions] OK!'

        return True
Ejemplo n.º 32
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!"