Exemplo n.º 1
0
def addGenFiles():
    configs = ['debug', 'release']

    def wantedFile(fname):
        fname = fname.lower()
        return fname.endswith('.h')     \
            or fname.endswith('.hpp')   \
            or fname.endswith('.c')     \
            or fname.endswith('.cc')    \
            or fname.endswith('.cpp')

    filesToAdd = []
    for config in configs:
        genDir = os.path.join(srcDir, 'out', 'static_' + config, 'gen')
        for dirpath, dirnames, filenames in os.walk(genDir):
            dirnames[:] = filter(lambda d: d != 'ffmpeg', dirnames)
            filenames = filter(lambda f: wantedFile(f), filenames)
            for f in filenames:
                f = os.path.relpath(os.path.join(dirpath, f))
                filesToAdd.append(f)
                if len(filesToAdd) > 20:
                    cmd = 'git add -f -- ' + ' '.join(filesToAdd)
                    bbutil.shellExec(cmd)
                    filesToAdd = []
    if filesToAdd:
        cmd = 'git add -f -- ' + ' '.join(filesToAdd)
        bbutil.shellExec(cmd)

    cmd = 'git commit -m "Add generated files"'
    bbutil.shellExec(cmd)
Exemplo n.º 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