Exemplo n.º 1
0
def prepare_closure_frontend_compile(temp_devtools_path, descriptors,
                                     namespace_externs_path,
                                     protocol_externs_file):
    temp_frontend_path = path.join(temp_devtools_path, 'front_end')
    checker = dependency_preprocessor.DependencyPreprocessor(
        descriptors, temp_frontend_path, DEVTOOLS_FRONTEND_PATH)
    checker.enforce_dependencies()

    command = common_closure_args + [
        '--externs',
        to_platform_path(GLOBAL_EXTERNS_FILE),
        '--externs',
        namespace_externs_path,
        '--js',
        RUNTIME_FILE,
        '--js',
        ROOT_MODULE_FILE,
    ]

    all_files = descriptors.all_compiled_files() + [WASM_SOURCE_MAP_FILE]
    args = []
    for file in all_files:

        args.extend(['--js', file])
        if 'InspectorBackend.js' in file:
            args.extend(['--js', protocol_externs_file])

        if file.endswith('_bridge.js'):
            generated_file = path.join(
                temp_frontend_path,
                path.relpath(file, DEVTOOLS_FRONTEND_PATH).replace(
                    '_bridge.js', '.js'))
            modular_build.write_file(generated_file, '')
            args.extend(['--js', generated_file])

    for file in descriptors.all_skipped_compilation_files():
        content = ''
        if (file == path.join('sdk', '../SupportedCSSProperties.js')):
            content = 'export const generatedProperties = []; export const generatedPropertyValues = [];'
        if (file == path.join('accessibility', 'ARIAProperties.js')):
            content = 'export const config = {};'
        if (file == path.join('protocol', '../InspectorBackendCommands.js')):
            content = 'export function registerCommands(inspectorBackend) {}'
        # Write a dummy file for skipped compilation files that are autogenerated.
        # We don't type-check this file, but we import them via ES modules
        generated_file = path.join(temp_frontend_path, file)
        modular_build.write_file(generated_file, content)
        args.extend(['--js', generated_file])

    command += args
    command = [
        arg.replace(DEVTOOLS_FRONTEND_PATH, temp_frontend_path)
        for arg in command
    ]
    compiler_args_file = tempfile.NamedTemporaryFile(mode='wt', delete=False)
    try:
        compiler_args_file.write('devtools_frontend %s' % (' '.join(command)))
    finally:
        compiler_args_file.close()
    return compiler_args_file.name
Exemplo n.º 2
0
def prepare_closure_frontend_compile(temp_devtools_path, descriptors,
                                     namespace_externs_path,
                                     protocol_externs_file):
    temp_frontend_path = path.join(temp_devtools_path, 'front_end')
    checker = dependency_preprocessor.DependencyPreprocessor(
        descriptors, temp_frontend_path, DEVTOOLS_FRONTEND_PATH)
    checker.enforce_dependencies()

    command = common_closure_args + [
        '--externs',
        to_platform_path(GLOBAL_EXTERNS_FILE),
        '--externs',
        namespace_externs_path,
        '--js',
        RUNTIME_FILE,
        '--js',
        ROOT_MODULE_FILE,
    ]

    all_files = descriptors.all_compiled_files()
    args = []
    for file in all_files:
        args.extend(['--js', file])
        if 'InspectorBackend.js' in file:
            args.extend(['--js', protocol_externs_file])

    for file in GENERATED_SKIP_COMPILATION_FILES:
        # Write a dummy file for skipped compilation files that are autogenerated.
        # We don't type-check this file, but we import them via ES modules
        generated_file = path.join(temp_frontend_path, file)
        modular_build.write_file(generated_file, '')
        args.extend(['--js', generated_file])

    command += args
    command = [
        arg.replace(DEVTOOLS_FRONTEND_PATH, temp_frontend_path)
        for arg in command
    ]
    compiler_args_file = tempfile.NamedTemporaryFile(mode='wt', delete=False)
    try:
        compiler_args_file.write('devtools_frontend %s' % (' '.join(command)))
    finally:
        compiler_args_file.close()
    return compiler_args_file.name
Exemplo n.º 3
0
def prepare_closure_frontend_compile(temp_devtools_path, descriptors, namespace_externs_path, protocol_externs_file):
    temp_frontend_path = path.join(temp_devtools_path, 'front_end')
    checker = dependency_preprocessor.DependencyPreprocessor(descriptors, temp_frontend_path, DEVTOOLS_FRONTEND_PATH)
    checker.enforce_dependencies()

    command = common_closure_args + [
        '--externs',
        to_platform_path(GLOBAL_EXTERNS_FILE),
        '--externs',
        namespace_externs_path,
        '--js',
        RUNTIME_FILE,
        '--js',
        ROOT_MODULE_FILE,
    ]

    all_files = descriptors.all_compiled_files()
    args = []
    for file in all_files:

        args.extend(['--js', file])
        if 'InspectorBackend.js' in file:
            args.extend(['--js', protocol_externs_file])


        if file.endswith('_bridge.js'):
            generated_file = path.join(temp_frontend_path, path.relpath(file, DEVTOOLS_FRONTEND_PATH).replace('_bridge.js', '.js'))
            modular_build.write_file(generated_file, '')
            args.extend(['--js', generated_file])

    for file in descriptors.all_skipped_compilation_files():
        # Write a dummy file for skipped compilation files that are autogenerated.
        # We don't type-check this file, but we import them via ES modules
        generated_file = path.normpath(path.join(temp_frontend_path, file))
        if not generated_file in args:
            modular_build.write_file(generated_file, '')
            if os.path.basename(generated_file) in [
                    'wasm_source_map.js', 'acorn.mjs', 'acorn-loose.mjs',
                    'acorn-logical-assignment.mjs',
                    'acorn-numeric-separator.mjs', 'marked.esm.js'
            ]:
                with open(
                        generated_file.replace('.js', '_types.js').replace(
                            '.mjs', '_types.mjs')) as f:
                    modular_build.write_file(generated_file, f.read())
            args.extend(['--js', generated_file])

    command += args
    command = [arg.replace(DEVTOOLS_FRONTEND_PATH, temp_frontend_path) for arg in command]
    compiler_args_file = tempfile.NamedTemporaryFile(mode='wt', delete=False)
    try:
        compiler_args_file.write('devtools_frontend %s' % (' '.join(command)))
    finally:
        compiler_args_file.close()
    return compiler_args_file.name
def prepare_closure_frontend_compile(temp_devtools_path, descriptors,
                                     namespace_externs_path,
                                     protocol_externs_file):
    temp_frontend_path = path.join(temp_devtools_path, 'front_end')
    checker = dependency_preprocessor.DependencyPreprocessor(
        descriptors, temp_frontend_path, DEVTOOLS_FRONTEND_PATH)
    checker.enforce_dependencies()

    command = common_closure_args + [
        '--externs',
        to_platform_path(GLOBAL_EXTERNS_FILE),
        '--externs',
        namespace_externs_path,
        '--js',
        RUNTIME_FILE,
        '--js',
        ROOT_MODULE_FILE,
    ]

    all_files = descriptors.all_compiled_files()
    args = []

    # Closure Compiler currently doesn't understand Bounded Generics (see common
    # args comment above), and the files listed below make use of them so we hide
    # warnings for those files.
    bounded_generics = [
        'SourceMapManager.js',
        'CSSWorkspaceBinding.js',
        'SASSSourceMapping.js',
    ]

    for file in bounded_generics:
        args.extend(['--hide_warnings_for', file])

    for file in all_files:
        args.extend(['--js', file])
        if 'InspectorBackend.js' in file:
            args.extend(['--js', protocol_externs_file])

        if file.endswith('_bridge.js'):
            generated_file = path.join(
                temp_frontend_path,
                path.relpath(file, DEVTOOLS_FRONTEND_PATH).replace(
                    '_bridge.js', '.js'))
            modular_build.write_file(generated_file, '')
            args.extend(['--js', generated_file])

    for file in descriptors.all_skipped_compilation_files():
        # Write a dummy file for skipped compilation files that are autogenerated.
        # We don't type-check this file, but we import them via ES modules
        generated_file = path.normpath(path.join(temp_frontend_path, file))
        if not generated_file in args:
            modular_build.write_file(generated_file, '')
            if os.path.basename(generated_file) in [
                    'acorn-logical-assignment.mjs',
                    'acorn-loose.mjs',
                    'acorn-numeric-separator.mjs',
                    'acorn.mjs',
                    'ClientVariations.js',
                    "i18n-bundle.js",
                    'marked.esm.js',
                    'wasm_source_map.js',
            ]:
                with open(
                        generated_file.replace('.js', '_types.js').replace(
                            '.mjs', '_types.mjs')) as f:
                    modular_build.write_file(generated_file, f.read())
            args.extend(['--js', generated_file])

    command += args
    command = [
        arg.replace(DEVTOOLS_FRONTEND_PATH, temp_frontend_path)
        for arg in command
    ]
    compiler_args_file = tempfile.NamedTemporaryFile(mode='wt', delete=False)
    try:
        compiler_args_file.write('devtools_frontend %s' % (' '.join(command)))
    finally:
        compiler_args_file.close()
    return compiler_args_file.name