Beispiel #1
0
def cmd_configure(params):
    global BUILDCONFIG
    BUILDCONFIG = {}
    BUILDCONFIG.update(buildconfig_defaults)
    if len(params) == 0:
        print '''Please specify SDK configuration:'''
        for k in sorted(buildconfig_sdks.keys()):
            print '%5s - %s' % (k, buildconfig_sdks[k]['SDK_NAME'])
        return
    if params[0] not in buildconfig_sdks:
        print 'Unsupported SDK configuration "%s"' % params[0]
        sys.exit(2)
    BUILDCONFIG.update(buildconfig_sdks[params[0]])
    BUILDCONFIG['SDK_TAG'] = params[0]
    print "Configuring for %s" % BUILDCONFIG['SDK_NAME']

    for item in params[1:]:
        (name, value) = item.split('=')
        try:
            value = int(value)
        except ValueError:
            pass  # not an integer
        BUILDCONFIG[name] = value

    BUILDCONFIG[
        'PYS60_VERSION'] = '%(PYS60_VERSION_MAJOR)s.%(PYS60_VERSION_MINOR)s.%(PYS60_VERSION_MICRO)s %(PYS60_VERSION_TAG)s' % BUILDCONFIG

    # Check if a directory for build dependencies was given
    if BUILDCONFIG.has_key('BUILD_DEPS'):
        # Form the build dependencies include directory path. The
        # drive letter and colon are stripped from the path since the
        # Symbian build system doesn't understand drive letters in
        # paths.
        builddep_includes = os.path.abspath(
            os.path.join(BUILDCONFIG['BUILD_DEPS'], BUILDCONFIG['SDK_TAG'],
                         'include'))[2:]
        if os.path.exists(builddep_includes):
            print "Adding extra include directory %s" % builddep_includes
            BUILDCONFIG['EXTRA_SYSTEMINCLUDE_DIRS'].append(builddep_includes)
    buildconfig_save()

    print "Build configuration:"
    for name, value in sorted(BUILDCONFIG.items()):
        print "  %s=%s" % (name, repr(value))
    BUILDCONFIG['ConfigureError'] = ConfigureError
    for f in template_engine.templatefiles_in_tree(topdir):
        print "Processing template %s" % f
        template_engine.process_file(f, BUILDCONFIG)

    run_in('.', 'bldmake bldfiles')
Beispiel #2
0
def generate_pymodules_zip(base_py_module_paths, base_py_module_names,
                           zip_file):
    """ Creates a zip package picking the files from base_py_module_paths
        and placing them as specified in base_py_module_names"""
    py_zip = zipfile.ZipFile(zip_file, "w")
    for py_path, py_file in zip(base_py_module_paths, base_py_module_names):
        # If the file does not exist then try to run template parser on the
        # corresponding .in file.
        if not os.path.exists(py_path + py_file):
            template_engine.process_file(py_path + py_file + '.in', globals())
        pyc_file = py_file + 'c'
        if os.path.exists(py_path + pyc_file):
            py_file = pyc_file
        py_zip.write(py_path + py_file, py_file, zipfile.ZIP_DEFLATED)
        print "Added :", py_file + " to " + zip_file
    py_zip.close()
Beispiel #3
0
def cmd_configure(params):
    global BUILDCONFIG
    BUILDCONFIG = {}
    BUILDCONFIG.update(buildconfig_defaults)
    parser = OptionParser()
    parser.add_option("-p", "--profile_log", dest="profile",
            action="store_true", default=False,
            help="Profile log generator for python [default: %default]")
    parser.add_option("-v", "--version", dest="version", default='2.0.0',
            help="Python release version [default: %default]")
    parser.add_option("--compiler-flags", dest="compiler_flags",
            default='',
            help="Compiler flags to be used while building the python" +
                 " interpreter core [default: %default]")
    parser.add_option("--internal-projects", dest="internal_proj",
            action="store_true", default=False,
            help="Builds internal projects like 'interpreter-startup, " +
                 "run_testapp etc...  [default: %default]")
    parser.add_option("--version-tag", dest="version_tag", default='final',
            help="Specify release tag [default: %default]")
    parser.add_option("-s", "--sdk", dest="sdk", default='50armv5',
            help="Specify the version of sdk to use, choose any version " +
                 "from %s"%",".join(buildconfig_sdks.keys()) +
                 "[default: %default]")
    parser.add_option("-c", "--caps", dest="dll_caps",
            default='LocalServices NetworkServices ReadUserData ' +
                    'WriteUserData UserEnvironment Location',
            help="Specify DLL capability within quotes [default: %default]")
    parser.add_option("--debug-device", dest="debug_device",
            action='store_true',
            help="Build device builds in debug mode.")
    parser.add_option("--include-internal-src", action='store_true',
            dest="include_internal_src", default=False,
            help="Include the source under ..\internal-src for build." +
                 " [default: %default]")
    parser.add_option("--exe-caps", dest="exe_caps",
            help="Specify EXEs capability within quotes. " +
                 "If nothing is specified this will be same as DLL " +
                 "capabilities")
    parser.add_option("--compression-type",
            default='', dest="compression_type",
            help="Modify the compression type of all the " +
                 "E32Image files generated, using 'elftran " +
                 "-compressionmethod'. Refer elftran help for valid " +
                 "compression types. If the type is given as '', " +
                 "elftran is not invoked for modifying the compression type." +
                 " [default: '']")
    parser.add_option("-k", "--key", dest="key",
            help="Specify key name," +
                 " [default:  NONE] - packages are left unsigned")
    parser.add_option("--keydir", dest="keydir", default='..\\keys',
            help="Specify key path [default: %default])")
    parser.add_option("--do-not-compile-pyfiles",
            dest="do_not_compile_pyfiles", action="store_true", default=False,
            help="Do not compile the .py files under src. You can disable the "
                 "compilation if the Python version on the host system is not "
                 "bytecode compatible with the Python used in PyS60 "
                 "[default: %default]")
    parser.add_option("--build-profile",
            dest="build_profile", default='integration',
            help="Use this option to set the build_config variable, "
                 "BUILD_PROFILE to 'integration' or 'release'. BUILD_PROFILE "
                 "can then be used in the template processing. "
                 "[default: %default]")

    (options, args) = parser.parse_args()

    if not options.do_not_compile_pyfiles and \
                                      pys60_magic_number != imp.get_magic():
        raise SystemError("Not compiling the .py files: " + \
              "Python version(%s) " % sys.version.split()[0] + \
              "not bytecode compatible with the Python version " + \
              "used in PyS60(%s)." % BUILDCONFIG['PY_ON_BUILD_SERVER'])

    if options.sdk not in buildconfig_sdks:
        print 'Unsupported SDK configuration "%s"' % options.sdk
        sys.exit(2)

    # Find out if coverage called configure. There are chances that the cfg
    # file is missing or CTC_COVERAGE key is not present. We just ignore it.
    try:
        BUILDCONFIG_temp = eval(open(BUILDCONFIG_FILE, 'rt').read())
        if BUILDCONFIG_temp['CTC_COVERAGE']:
            BUILDCONFIG['CTC_COVERAGE'] = True
    except:
        pass
    BUILDCONFIG['PYS60_VERSION_NUM'] = options.version
    BUILDCONFIG['PYS60_VERSION'] = '%s %s' %(options.version,
                                             options.version_tag)
    [major, minor, micro] = options.version.split('.')
    BUILDCONFIG['PYS60_VERSION_MAJOR'] = major
    BUILDCONFIG['PYS60_VERSION_MINOR'] = minor
    BUILDCONFIG['PYS60_VERSION_MICRO'] = micro
    BUILDCONFIG['BUILD_PROFILE'] = options.build_profile
    if options.compiler_flags:
        BUILDCONFIG['COMPILER_FLAGS'] = "OPTION " \
        + options.compiler_flags
        log_file = topdir + "\\build\\regrtest_emulator_x86.log"
        if os.path.exists(log_file):
            open(log_file, "a+").write("\n" +
                "Build Info -- Name : <Compiler Flags>, Value : <" +
                options.compiler_flags + ">")
            # Running it again to get the compiler tags into the XML. In the
            # future when new build info metrics will be added, this can be
            # run at the end after appending all the values to emu log.
            run_cmd('python tools\\regrtest_log_to_cruisecontrol.py ' +
                    ' regrtest_emulator_x86.log')
    BUILDCONFIG['PYS60_VERSION_TAG'] = options.version_tag
    BUILDCONFIG['PROFILE_LOG'] = options.profile
    buildconfig_save()
    if options.key:
        BUILDCONFIG['SIGN_KEY'] = options.keydir + '\\' + \
        '%s' % options.key + '.key'
        BUILDCONFIG['SIGN_CERT'] = options.keydir + '\\' + \
        '%s' % options.key + '.crt'
        BUILDCONFIG['SIGN_PASS'] = ''
    BUILDCONFIG['DLL_CAPABILITIES'] = options.dll_caps
    if not options.exe_caps:
        BUILDCONFIG['EXE_CAPABILITIES'] = options.dll_caps
    else:
        BUILDCONFIG['EXE_CAPABILITIES'] = options.exe_caps
    BUILDCONFIG['COMPRESSION_TYPE'] = options.compression_type
    BUILDCONFIG.update(buildconfig_sdks[options.sdk])
    if options.debug_device:
        print "Configuring the device build as debug(UDEB)"
        BUILDCONFIG['DEVICE_BUILD'] = 'udeb'
    if options.internal_proj:
        global INTERNAL_PROJ
        BUILDCONFIG['INTERNAL_PROJ'] = True

    BUILDCONFIG['INCLUDE_INTERNAL_SRC'] = options.include_internal_src
    BUILDCONFIG['MOD_REPO'] = False

    print "Configuring for %s" % options.sdk
    buildconfig_save()
    # Check if a directory for build dependencies was given
    if 'BUILD_DEPS' in BUILDCONFIG:
        # Form the build dependencies include directory path. The
        # drive letter and colon are stripped from the path since the
        # Symbian build system doesn't understand drive letters in
        # paths.
        builddep_includes = os.path.abspath(os.path.join(
                            BUILDCONFIG['BUILD_DEPS'], BUILDCONFIG['SDK_TAG'],
                            'include'))[2:]
        if os.path.exists(builddep_includes):
            print "Adding extra include directory %s" % builddep_includes
            BUILDCONFIG['EXTRA_SYSTEMINCLUDE_DIRS'].append(builddep_includes)
    buildconfig_save()
    print "Build configuration:"
    for name, value in sorted(BUILDCONFIG.items()):
        print "  %s=%s" % (name, repr(value))
    BUILDCONFIG['ConfigureError'] = ConfigureError

    build_dirs = ['']
    if options.include_internal_src:
        build_dirs.append('..\\internal-src')
        build_dirs.append('..\\extraprojs')
    if not options.do_not_compile_pyfiles:
        compileall.compile_dir('newcore\\Lib', rx=re.compile('/[.]svn'))
    prev_dir = os.getcwd()
    os.chdir('newcore\\Symbian\\src')
    execfile('module_config_parser.py', BUILDCONFIG)
    os.chdir(prev_dir)

    # Go through all directories that have template files that need processing.
    for dir_ in build_dirs:
        for f in fileutil.all_files(dir_, '*.in'):
            # Omit newcore from template processing for now.
            if (f.startswith('newcore\\') or f.startswith('build\\')) and \
            not f.startswith('newcore\\Symbian\\') and \
            not f.startswith('newcore\\Doc\\s60'):
                print "Ignoring", f
                continue
            print "Processing template", f
            template_engine.process_file(f, BUILDCONFIG)

    for x in get_project_details('path'):
        run_in(x, 'bldmake clean')
        run_in(x, 'bldmake bldfiles')
Beispiel #4
0
def readconfig_and_generate():
    """It returns a map of lists of py, pyds, builtin,excluded etc
    """
    global dep_map
    pyd_modules = []
    builtin_modules = []
    base_py_module_paths = []
    base_py_module_names = []
    modulename_list = []
    modulename_in_list = []
    mmp_files = []
    configdotc_list = []
    pkgfile_list = []
    std_repo_pys = []
    std_repo_pyds = []
    repo_py_module_names = []
    repo_py_module_paths = []
    repo_pyds = []
    std_base_pys = []
    ext_modules_path = []
    ext_module_names = []
    ext_modules = []
    ext_pyd_names = []
    ext_pyd_path = []
    ext_pyds = []
    ext_mod_cfg_paths = []
    ext_mod_cfg_names = []
    testapp_pkg_files = []
    # This list is maintained so that the ext modules are not part of
    # module-repo\\standard. But are a part of packaging and going with the
    # runtime
    mod_repo_base_excluded_list = []
    mod_repo_excluded_list = []
    template_engine.process_file('modules.cfg.in', globals())
    config_file = open('modules.cfg', 'r')
    for line in config_file:
        line1 = line.rstrip('\n')
        line = line1.strip()
        if line in [
                'PYD', 'BUILTIN', 'PY_MODULES', 'EXT-MODULES', 'EXT-PYD',
                'EXT-MOD-CFGS'
        ]:
            module_type = line
            continue
        if line and line[0] != '#':
            if module_type == 'PYD':
                pyd_modules.append(line.split(','))
                # Update the type of the pyd to the dep_map
                mod_map = {}
                try:
                    mod_map['type'] = line.split(',')[2]
                except:
                    mod_map['type'] = 'repo'
                mod_map['deps'] = []
                file_name = line.split(',')[0]
                dep_map[file_name] = mod_map

            elif module_type == 'BUILTIN':
                builtin_modules += line.split('=')
                mod_map = {}
                mod_map['type'] = 'base'
                mod_map['deps'] = []
                dep_map[line.split('=')[0]] = mod_map

            elif module_type == 'PY_MODULES':
                module_data = line.split(':')
                try:
                    py_mod_type = module_data[2]
                except:
                    py_mod_type = 'repo'

                # Update the type of the py to the dep_map
                if module_data[1].endswith('.py'):
                    mod_map = {}
                    mod_map['type'] = py_mod_type
                    dep_map[module_data[1].replace('.py',
                                                   '').replace('\\',
                                                               '.')] = mod_map

                    if py_mod_type != 'base':
                        repo_py_module_paths.append(module_data[0])
                        repo_py_module_names.append(module_data[1])
                    else:
                        base_py_module_paths.append(module_data[0])
                        base_py_module_names.append(module_data[1])

            elif module_type == 'EXT-MODULES':
                ext_modules_path.append(line.split(':')[0])
                ext_module_names.append(line.split(':')[1])
                try:
                    ext_mod_type = line.split(':')[2]
                except:
                    ext_mod_type = 'repo'
                ext_modules.append(line.split(':')[0] + \
                    os.path.basename(line.split(':')[1]))

                if ext_mod_type != 'base':
                    repo_py_module_paths.append(line.split(':')[0])
                    repo_py_module_names.append(os.path.basename(\
                                                       line.split(':')[1]))
                    mod_repo_excluded_list.append(line.split(':')[0] + \
                                       os.path.basename(line.split(':')[1]))
                else:
                    base_py_module_paths.append(line.split(':')[0])
                    base_py_module_names.append(
                        os.path.basename(line.split(':')[1]))
                    mod_repo_base_excluded_list.append(line.split(':')[0] + \
                                          os.path.basename(line.split(':')[1]))

            elif module_type == 'EXT-PYD':
                ext_pyd_path.append(line.split(':')[0])
                ext_pyd_names.append(line.split(':')[1])
                ext_pyds.append(line.split(':')[0] + \
                    os.path.basename(line.split(':')[1]))
                try:
                    ext_pyd_type = line.split(':')[2]
                except:
                    ext_pyd_type = 'repo'
                ext_pyd_file = os.path.basename(
                    os.path.splitext(line.split(':')[1])[0])
                if ext_pyd_type == 'base':
                    pkgfile_list.append(ext_pyd_file)
                else:
                    testapp_pkg_files.append(ext_pyd_file)

            elif module_type == 'EXT-MOD-CFGS':
                ext_mod_cfg_paths.append(line.split(':')[0])
                ext_mod_cfg_names.append(line.split(':')[1])

    for i in range(len(base_py_module_paths)):
        std_repo_pys.append(base_py_module_paths[i] + base_py_module_names[i])
    for i in range(len(repo_py_module_paths)):
        std_base_pys.append(repo_py_module_paths[i] + \
            repo_py_module_names[i])

    # Remove the ext-modules so that they are not part of standard modules
    for mod in mod_repo_excluded_list:
        std_base_pys.remove(mod)
    for mod in mod_repo_base_excluded_list:
        std_repo_pys.remove(mod)

    config_file.close()
    for module in pyd_modules:
        mmp_list = module[1].split('=')[1]
        genmmpfile(module[0], mmp_list.split('"')[1])
        modulename_list.append(module[0])
        std_repo_pyds.append(PREFIX + module[0] + '.pyd')
        modulename_in_list.append(module[0] + '.mmp.in')
        if 'base' in module:
            pkgfile_list.append(PREFIX + module[0])
        else:
            repo_pyds.append(PREFIX + module[0])

    modulename_in = open(module_in_path, 'w')
    for module in modulename_in_list:
        modulename_in.write(
            os.path.dirname(os.getcwd()) + '\\group\\' + module + '\n')
    for files in fileutil.all_files(os.path.dirname(os.getcwd()),
                                    '*.template'):
        files = files.rstrip('.template')
        modulename_in.write(files + '\n')
    modulename_in.close()
    bldinf_append(modulename_list)
    pkg_append(pkgfile_list)

    for x in range(0, len(builtin_modules), 2):
        configdotc_list.append(builtin_modules[x])
        mmp_files.append(builtin_modules[x + 1])
    genconfigdotc(configdotc_list)

    return {
        "mmp_files": mmp_files,
        "base_py_module_paths": base_py_module_paths,
        "base_py_module_names": base_py_module_names,
        "std_repo_pys": std_repo_pys,
        "std_repo_pyds": std_repo_pyds,
        "repo_py_module_paths": repo_py_module_paths,
        "repo_py_module_names": repo_py_module_names,
        "std_base_pys": std_base_pys,
        "repo_pyds": repo_pyds,
        "ext_module_names": ext_module_names,
        "ext_modules": ext_modules,
        "ext_pyds": ext_pyds,
        "ext_pyd_names": ext_pyd_names,
        "ext_mod_cfg_paths": ext_mod_cfg_paths,
        "ext_mod_cfg_names": ext_mod_cfg_names,
        "testapp_pkg_files": testapp_pkg_files
    }