Пример #1
0
def gn_host_tools(ctx: PresubmitContext):
    build.gn_gen(ctx.repo_root,
                 ctx.output_dir,
                 pw_target_config='"//targets/host/target_config.gni"',
                 pw_target_toolchain='"//pw_toolchain:host_clang_os"',
                 pw_build_host_tools='true')
    build.ninja(ctx.output_dir, 'host_tools')
Пример #2
0
def static_analysis(ctx: PresubmitContext):
    """Check that files pass static analyzer checks."""
    build.gn_gen(ctx.root, ctx.output_dir,
                 '--export-compile-commands=host_clang_debug')
    build.ninja(ctx.output_dir, 'host_clang_debug')

    compile_commands = ctx.output_dir.joinpath('compile_commands.json')
    analyzer_output = ctx.output_dir.joinpath('analyze-build-output')

    if analyzer_output.exists():
        shutil.rmtree(analyzer_output)

    call('analyze-build',
         '--cdb',
         compile_commands,
         '--exclude',
         'third_party',
         '--output',
         analyzer_output,
         cwd=ctx.root,
         env=build.env_with_clang_vars())

    # Search for reports under output directory.
    reports = list(analyzer_output.glob('*/report*'))
    if len(reports) != 0:
        archive = shutil.make_archive(str(analyzer_output), 'zip',
                                      reports[0].parent)
        _LOG.error('Static analyzer found errors: %s', archive)
        _LOG.error('To view report, open: %s',
                   Path(reports[0]).parent.joinpath('index.html'))
        raise PresubmitFailure
Пример #3
0
def oss_fuzz_build(ctx: PresubmitContext):
    build.gn_gen(ctx.repo_root,
                 ctx.output_dir,
                 oss_fuzz_enabled='true',
                 pw_target_toolchain='"//pw_toolchain:host_clang_og"',
                 pw_sanitizer='"address"')
    build.ninja(ctx.output_dir)
Пример #4
0
def python_checks(ctx: PresubmitContext):
    build.gn_gen(ctx.root, ctx.output_dir)
    build.ninja(
        ctx.output_dir,
        ':python.lint',
        ':python.tests',
        ':target_support_packages.lint',
        ':target_support_packages.tests',
    )
Пример #5
0
def gn_teensy_build(ctx: PresubmitContext):
    build.install_package(ctx.package_root, 'teensy')
    build.gn_gen(ctx.root,
                 ctx.output_dir,
                 pw_arduino_build_CORE_PATH='"{}"'.format(str(
                     ctx.package_root)),
                 pw_arduino_build_CORE_NAME='teensy',
                 pw_arduino_build_PACKAGE_NAME='teensy/avr',
                 pw_arduino_build_BOARD='teensy40')
    build.ninja(ctx.output_dir, *_at_all_optimization_levels('arduino'))
Пример #6
0
def gn_quick_build_check(ctx: PresubmitContext):
    build.gn_gen(ctx.root, ctx.output_dir)

    # TODO(pwbug/255): Switch to optimized GCC builds when this is fixed.
    # See comment in _at_all_optimization_levels() above for details.
    optimization_level = 'size_optimized'
    if _HOST_COMPILER == 'gcc':
        optimization_level = 'debug'

    build.ninja(ctx.output_dir, f'host_{_HOST_COMPILER}_{optimization_level}',
                'stm32f429i_size_optimized', 'python.tests', 'python.lint')
Пример #7
0
def gn_gcc_build(ctx: PresubmitContext):
    build.gn_gen(ctx.root, ctx.output_dir)

    # Skip optimized host GCC builds for now, since GCC sometimes emits spurious
    # warnings.
    #
    #   -02: GCC 9.3 emits spurious maybe-uninitialized warnings
    #   -0s: GCC 8.1 (Mingw-w64) emits a spurious nonnull warning
    #
    # TODO(pwbug/255): Enable optimized GCC builds when this is fixed.
    build.ninja(ctx.output_dir, 'host_gcc_debug')
Пример #8
0
def gn_nanopb_build(ctx: PresubmitContext):
    build.install_package(ctx.package_root, 'nanopb')
    build.gn_gen(ctx.root,
                 ctx.output_dir,
                 dir_pw_third_party_nanopb='"{}"'.format(ctx.package_root /
                                                         'nanopb'))
    build.ninja(
        ctx.output_dir,
        *_at_all_optimization_levels('stm32f429i'),
        *_at_all_optimization_levels('host_clang'),
    )
Пример #9
0
def clang_tidy(ctx: PresubmitContext):
    build.gn_gen(ctx.root, ctx.output_dir, '--export-compile-commands')
    build.ninja(ctx.output_dir)
    build.ninja(ctx.output_dir, '-t', 'compdb', 'objcxx', 'cxx')

    run_clang_tidy = None
    for var in ('PW_PIGWEED_CIPD_INSTALL_DIR', 'PW_CIPD_INSTALL_DIR'):
        if var in os.environ:
            possibility = os.path.join(os.environ[var],
                                       'share/clang/run-clang-tidy.py')
            if os.path.isfile(possibility):
                run_clang_tidy = possibility
                break

    checks = ','.join(_CLANG_TIDY_CHECKS)
    call(
        run_clang_tidy,
        f'-p={ctx.output_dir}',
        f'-checks={checks}',
        # TODO(pwbug/45) not sure if this is needed.
        # f'-extra-arg-before=-warnings-as-errors={checks}',
        *ctx.paths)
Пример #10
0
def source_is_in_build_files(ctx: PresubmitContext):
    """Checks that source files are in the GN and Bazel builds."""
    gn_gens_to_run = (
        (ctx.output_dir.joinpath('arm'), _ARM_GEN_ARGS),
        (ctx.output_dir.joinpath('clang'), _CLANG_GEN_ARGS),
        (ctx.output_dir.joinpath('docs'), _DOCS_GEN_ARGS),
        (ctx.output_dir.joinpath('qemu'), _QEMU_GEN_ARGS),
    )

    for directory, args in gn_gens_to_run:
        build.gn_gen(ctx.repo_root, directory, args)

    missing = build.check_builds_for_files(_SOURCES_IN_BUILD,
                                           ctx.paths,
                                           bazel_dirs=[ctx.repo_root],
                                           gn_dirs=[
                                               (ctx.repo_root, path)
                                               for path, _ in gn_gens_to_run
                                           ])

    if missing:
        _LOG.warning(
            'All source files must appear in BUILD and BUILD.gn files')
        raise PresubmitFailure
Пример #11
0
def gn_gcc_build(ctx: PresubmitContext):
    build.gn_gen(
        ctx.repo_root, ctx.output_dir,
        build.gn_args(pw_target_config='"//targets/host/target_config.gni"',
                      pw_target_toolchain='"//pw_toolchain:host_gcc_os"'))
    build.ninja(ctx.output_dir)
Пример #12
0
def oss_fuzz_build(ctx: PresubmitContext):
    build.gn_gen(ctx.root,
                 ctx.output_dir,
                 pw_toolchain_OSS_FUZZ_ENABLED=True,
                 pw_toolchain_SANITIZER="address")
    build.ninja(ctx.output_dir, "host_clang")
Пример #13
0
def gn_host_tools(ctx: PresubmitContext):
    build.gn_gen(ctx.root, ctx.output_dir, pw_build_HOST_TOOLS=True)
    build.ninja(ctx.output_dir)
Пример #14
0
def gn_docs_build(ctx: PresubmitContext):
    build.gn_gen(ctx.root, ctx.output_dir)
    build.ninja(ctx.output_dir, 'docs')
Пример #15
0
def gn_arm_build(ctx: PresubmitContext):
    build.gn_gen(ctx.root, ctx.output_dir)
    build.ninja(ctx.output_dir, *_at_all_optimization_levels('stm32f429i'))
Пример #16
0
def oss_fuzz_build(ctx: PresubmitContext):
    build.gn_gen(ctx.root, ctx.output_dir, pw_toolchain_OSS_FUZZ_ENABLED=True)
    build.ninja(ctx.output_dir, "fuzzers")
Пример #17
0
def gn_host_build(ctx: PresubmitContext):
    build.gn_gen(ctx.root, ctx.output_dir)
    build.ninja(ctx.output_dir,
                *_at_all_optimization_levels(f'host_{_HOST_COMPILER}'))
Пример #18
0
def gn_gcc_build(ctx: PresubmitContext):
    build.gn_gen(ctx.root, ctx.output_dir)
    build.ninja(ctx.output_dir, "host_gcc")
Пример #19
0
def gn_qemu_build(ctx: PresubmitContext):
    build.gn_gen(ctx.root, ctx.output_dir)
    build.ninja(ctx.output_dir, *_at_all_optimization_levels('qemu_gcc'))
Пример #20
0
def gn_quick_build_check(ctx: PresubmitContext):
    build.gn_gen(ctx.root, ctx.output_dir)
    build.ninja(ctx.output_dir, 'host_clang_size_optimized',
                'stm32f429i_size_optimized', 'python.tests', 'python.lint')
Пример #21
0
def gn_clang_build(ctx: PresubmitContext):
    build.gn_gen(ctx.repo_root, ctx.output_dir, _CLANG_GEN_ARGS)
    build.ninja(ctx.output_dir)
Пример #22
0
def gn_arm_build(ctx: PresubmitContext):
    build.gn_gen(ctx.root, ctx.output_dir)
    build.ninja(ctx.output_dir, "stm32f429i")
Пример #23
0
def gn_qemu_build(ctx: PresubmitContext):
    build.gn_gen(ctx.root, ctx.output_dir)
    build.ninja(ctx.output_dir, "qemu")
Пример #24
0
def gn_clang_build(ctx: PresubmitContext):
    build.gn_gen(ctx.root, ctx.output_dir)
    build.ninja(ctx.output_dir, *_at_all_optimization_levels('host_clang'))
Пример #25
0
def gn_arm_build(ctx: PresubmitContext):
    build.gn_gen(ctx.repo_root, ctx.output_dir, _ARM_GEN_ARGS)
    build.ninja(ctx.output_dir)
Пример #26
0
def gn_docs_build(ctx: PresubmitContext):
    build.gn_gen(ctx.repo_root, ctx.output_dir, _DOCS_GEN_ARGS)
    build.ninja(ctx.output_dir, 'docs:docs')
Пример #27
0
def gn_full_build_check(ctx: PresubmitContext):
    build.gn_gen(ctx.root, ctx.output_dir)
    build.ninja(ctx.output_dir, *_at_all_optimization_levels('stm32f429i'),
                *_at_all_optimization_levels(f'host_{_HOST_COMPILER}'),
                'python.tests', 'python.lint', 'docs')