<commit_before>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2021 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Build and test all of the Zephyr boards.

This is the entry point for the custom firmware builder workflow recipe.
"""

import argparse
import multiprocessing
import pathlib
import re
import shlex
import subprocess
import sys

import zmake.project
from chromite.api.gen_sdk.chromite.api import firmware_pb2
from google.protobuf import json_format  # pylint: disable=import-error

DEFAULT_BUNDLE_DIRECTORY = "/tmp/artifact_bundles"
DEFAULT_BUNDLE_METADATA_FILE = "/tmp/artifact_bundle_metadata"

# Boards that we want to track the coverage of our own files specifically.
SPECIAL_BOARDS = ["herobrine", "krabby", "nivviks", "skyrim", "kingler"]


def log_cmd(cmd):
    """Log subprocess command."""
    print(" ".join(shlex.quote(str(x)) for x in cmd))
    sys.stdout.flush()


def run_twister(platform_ec, code_coverage=False, extra_args=None):
    """Build the tests using twister."""
    cmd = [
        platform_ec / "twister",
        "--outdir",
        platform_ec / "twister-out",
        "-v",
        "-i",
        "-p",
        "native_posix",
        "-p",
        "unit_testing",
        "--no-upload-cros-rdb",
    ]

    if extra_args:
        cmd.extend(extra_args)

    if code_coverage:
        # Tell Twister to collect coverage data. We must specify an explicit platform
        # type in this case, as well.
        cmd.extend(
            [
                "--coverage",
            ]
        )
    log_cmd(cmd)
    subprocess.run(cmd, check=True, cwd=platform_ec, stdin=subprocess.DEVNULL)

<commit_msg>cq: Pass the compiler to twister<commit_after>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2021 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Build and test all of the Zephyr boards.

This is the entry point for the custom firmware builder workflow recipe.
"""

import argparse
import multiprocessing
import pathlib
import re
import shlex
import subprocess
import sys

import zmake.project
from chromite.api.gen_sdk.chromite.api import firmware_pb2
from google.protobuf import json_format  # pylint: disable=import-error

DEFAULT_BUNDLE_DIRECTORY = "/tmp/artifact_bundles"
DEFAULT_BUNDLE_METADATA_FILE = "/tmp/artifact_bundle_metadata"

# Boards that we want to track the coverage of our own files specifically.
SPECIAL_BOARDS = ["herobrine", "krabby", "nivviks", "skyrim", "kingler"]


def log_cmd(cmd):
    """Log subprocess command."""
    print(" ".join(shlex.quote(str(x)) for x in cmd))
    sys.stdout.flush()


def run_twister(platform_ec, code_coverage=False, extra_args=None):
    """Build the tests using twister."""
    cmd = [
        platform_ec / "twister",
        "--outdir",
        platform_ec / "twister-out",
        "-v",
        "-i",
        "-p",
        "native_posix",
        "-p",
        "unit_testing",
        "--no-upload-cros-rdb",
        "-x=CMAKE_C_COMPILER=/usr/bin/x86_64-pc-linux-gnu-gcc",
        "-x=CMAKE_CXX_COMPILER=/usr/bin/x86_64-pc-linux-gnu-g++",
    ]

    if extra_args:
        cmd.extend(extra_args)

    if code_coverage:
        # Tell Twister to collect coverage data. We must specify an explicit platform
        # type in this case, as well.
        cmd.extend(
            [
                "--coverage",
            ]
        )
    log_cmd(cmd)
    subprocess.run(cmd, check=True, cwd=platform_ec, stdin=subprocess.DEVNULL)


{'fraction_non_alphanumeric': 0.11215729714760454, 'fraction_numerical': 0.006092495153697037, 'mean_word_length': 2.858974358974359, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1046149', 'n_tokens_mistral': 1193, 'n_tokens_neox': 1144, 'n_words': 329}