Example #1
0
def generateMsvsMapFiles(version, configs):
    productAppend = '.' + version
    products = [
        'blpwtk2' + productAppend + '.dll',
        'blpcr_egl' + productAppend + '.dll',
        'blpcr_glesv2' + productAppend + '.dll',
        'blpwtk2_subprocess' + productAppend + '.exe',
        os.path.join(swiftFolderName, 'blpcr_egl' + productAppend + '.dll'),
        os.path.join(swiftFolderName, 'blpcr_glesv2' + productAppend + '.dll'),
    ]

    for config in configs:
        srcBinDir = os.path.join(srcDir, 'out', 'static_' + config)
        for p in products:
            binPath = os.path.join(srcBinDir, p)
            mapPath = os.path.join(
                srcBinDir,
                re.match('(.*)[.](?:\\bdll\\b|\\bexe\\b)$', p).group(1) +
                '.map')

            if os.path.exists(mapPath):
                print("Generating MSVS map file for " + p)

                # Append a '.llvm' to the original map file
                shutil.move(mapPath, mapPath + '.llvm')

                # Execute dumpbin to generate the dumpbin-style map file
                rc = bbutil.shellExecNoPipe('dumpbin -map {0} > {1}'.format(
                    binPath, mapPath + '.dumpbin'))
                if rc != 0:
                    raise Exception("dumpbin failed to generate map file")

                # Execute msvs_map.py to generate MSVS-style map file
                rc = bbutil.shellExecNoPipe(
                    'python src/build/msvs_map.py --llvm-map {0} --dumpbin-map {1} > {2}'
                    .format(mapPath + '.llvm', mapPath + '.dumpbin', mapPath))
                if rc != 0:
                    raise Exception("msvs_map.py failed to generate map file")
            else:
                print("Not generating MSVS map file for " + p)
Example #2
0
def main(args):
    outDir = None
    doClean = False
    doTag = False
    doPushTag = True
    doGenerateMap = True

    for i in range(len(args)):
        if args[i] == '--outdir':
            outDir = args[i + 1]
        elif args[i] == '--clean':
            doClean = True
        elif args[i] == '--noclean':
            doClean = False
        elif args[i] == '--maketag':
            doTag = True
        elif args[i] == '--nopushtag':
            doPushTag = False
        elif args[i] == '--nomap':
            doGenerateMap = False
        elif args[i] == '--version':
            version = args[i + 1]
        elif args[i].startswith('-'):
            print(
                "Usage: make_devkit.py --outdir <outdir> --version [--clean] [--maketag [--nopushtag] ] [--gn] [--nomap]"
            )
            return 1

    if not outDir:
        raise Exception("Specify outdir using --outdir")

    if not os.path.exists(outDir):
        raise Exception("Output directory does not exist: " + outDir)

    if not version:
        raise Exception("Specify a version number using --version")

    os.chdir(chromiumDir)
    version = content_version + '_' + version
    destDir = os.path.join(outDir, version)

    # Pre-flight checks
    if os.path.exists(destDir):
        raise Exception("Path already exists: " + destDir)

    rc = bbutil.shellExecNoPipe('which dumpbin')
    if rc != 0:
        raise Exception("Please make sure dumpbin is in your PATH")

    if doClean:
        print("Cleaning source tree...")
        sys.stdout.flush()
        buildOutDir = os.path.join(srcDir, 'out')
        if os.path.exists(buildOutDir):
            shutil.rmtree(buildOutDir)
        bbutil.shellExec('git clean -fdx')

    with open('devkit_version.txt', 'w') as f:
        f.write(version)

    os.environ['GN_GENERATORS'] = 'ninja'

    if doGenerateMap:
        applyVariableToEnvironment('GN_DEFINES', 'bb_generate_map_files',
                                   'true')

    print("srcDir is : " + srcDir)
    os.chdir(srcDir)

    rc = bbutil.shellExecNoPipe('python build/runhooks.py')
    if rc != 0:
        return rc

    print("Building Debug...")
    sys.stdout.flush()
    rc = bbutil.shellExecNoPipe(
        'python build/blpwtk2.py static debug --bb_version')
    if rc != 0:
        return rc

    rc = bbutil.shellExecNoPipe('ninja.exe -C out/static_debug blpwtk2_all')
    if rc != 0:
        return rc

    print("Building Release...")
    sys.stdout.flush()
    applyVariableToEnvironment('GN_DEFINES', 'is_official_build', 'true')
    rc = bbutil.shellExecNoPipe(
        'python build/blpwtk2.py static release --bb_version')
    if rc != 0:
        return rc

    rc = bbutil.shellExecNoPipe('ninja.exe -C out/static_release blpwtk2_all')
    if rc != 0:
        return rc

    os.chdir("..")

    print("Creating devkit at " + destDir)
    sys.stdout.flush()
    os.mkdir(destDir)
    os.mkdir(os.path.join(destDir, 'bin'))
    os.mkdir(os.path.join(destDir, 'bin', 'debug'))
    os.mkdir(os.path.join(destDir, 'bin', 'release'))
    os.mkdir(os.path.join(destDir, 'include'))
    os.mkdir(os.path.join(destDir, 'lib'))
    os.mkdir(os.path.join(destDir, 'lib', 'debug'))
    os.mkdir(os.path.join(destDir, 'lib', 'release'))

    if doGenerateMap:
        generateMsvsMapFiles(version)

    copyIncludeFiles(destDir)
    copyBin(destDir, version, doGenerateMap)
    copyLib(destDir, version)

    if doTag:
        print("Adding generated code to source control...")
        sys.stdout.flush()
        addGenFiles()

    # Copy version.txt *after* committing the generated files so that the sha in
    # the version.txt file includes the generated code.
    copyVersionFile(destDir)

    if doTag:
        print("Creating tag...")
        sys.stdout.flush()
        versions = version.split('_')
        crVersion = versions[0]
        bbVersion = versions[1]
        tag = 'devkit/stable/' + crVersion + '/' + bbVersion
        rc = bbutil.shellExecNoPipe('git tag -fm "devkit ' + tag + '" ' + tag)
        if rc != 0:
            return rc
        print("Tag '" + tag + "' created.")

        if doPushTag:
            print("Pushing tag...")
            rc = bbutil.shellExecNoPipe('git push origin tag ' + tag)
            if rc != 0:
                return rc

    print("Compressing...")
    sys.stdout.flush()
    os.chdir(outDir)
    rc = bbutil.shellExecNoPipe('7zr.exe a {}.7z {}'.format(version, version))
    if rc != 0:
        return rc

    print("All done!")
    return 0