<commit_before># Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Helper functions to configure Bazel

$Env:USE_BAZEL_VERSION="5.3.1"

# Create output directory for Bazel. Bazel creates really long paths,
# sometimes exceeding the Windows limits. Using a short name for the
# root of the Bazel output directory works around this problem.
# We do this in C: (the boot disk) because T: (the tmpfs / build disk)
# is too small for the Bazel directory.
$bazel_root="C:\b"
if (-not (Test-Path $bazel_root)) {
    Write-Host -ForegroundColor Yellow "`n$(Get-Date -Format o) Create bazel user root (${bazel_root})"
    New-Item -ItemType Directory -Path $bazel_root | Out-Null
}

function Get-Bazel-Common-Flags {
    return @("--output_user_root=${bazel_root}")
}

function Get-Bazel-Build-Flags {
    param ($BuildName)
    # These flags are shared by all builds
    $build_flags = @(
        "--keep_going",
        "--per_file_copt=^//google/cloud@-W3",
        "--per_file_copt=^//google/cloud@-WX",
        "--per_file_copt=^//google/cloud@-experimental:external",
        "--per_file_copt=^//google/cloud@-external:W0",
        "--per_file_copt=^//google/cloud@-external:anglebrackets",
        # Disable warnings on generated proto files.
        "--per_file_copt=.*\.pb\.cc@/wd4244"
    )
    # TODO(#9531) - enable release builds for MSVC 2017
    if (($BuildName -like "bazel-release*") -and ($BuildName -ne "bazel-release-2017")) {
        $build_flags += ("-c", "opt")
    }

    if (-not (Test-Path env:KOKORO_GFILE_DIR)) {
        return $build_flags
    }
    if (-not (Test-Path "${env:KOKORO_GFILE_DIR}/kokoro-run-key.json")) {
        return $build_flags
    }

    # If we have the right credentials, tell bazel to cache build results in a GCS
    # bucket. Note: this will not cache external deps, so the "fetch" below will
    # not hit this cache.
    Write-Host "$(Get-Date -Format o) Using bazel remote cache: ${BAZEL_CACHE}/windows/${BuildName}"<commit_msg>ci: enable MSVC 2017 + Release build (#9924)<commit_after># Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Helper functions to configure Bazel

$Env:USE_BAZEL_VERSION="5.3.1"

# Create output directory for Bazel. Bazel creates really long paths,
# sometimes exceeding the Windows limits. Using a short name for the
# root of the Bazel output directory works around this problem.
# We do this in C: (the boot disk) because T: (the tmpfs / build disk)
# is too small for the Bazel directory.
$bazel_root="C:\b"
if (-not (Test-Path $bazel_root)) {
    Write-Host -ForegroundColor Yellow "`n$(Get-Date -Format o) Create bazel user root (${bazel_root})"
    New-Item -ItemType Directory -Path $bazel_root | Out-Null
}

function Get-Bazel-Common-Flags {
    return @("--output_user_root=${bazel_root}")
}

function Get-Bazel-Build-Flags {
    param ($BuildName)
    # These flags are shared by all builds
    $build_flags = @(
        "--keep_going",
        "--per_file_copt=^//google/cloud@-W3",
        "--per_file_copt=^//google/cloud@-WX",
        "--per_file_copt=^//google/cloud@-experimental:external",
        "--per_file_copt=^//google/cloud@-external:W0",
        "--per_file_copt=^//google/cloud@-external:anglebrackets",
        # Disable warnings on generated proto files.
        "--per_file_copt=.*\.pb\.cc@/wd4244"
    )
    if ($BuildName -like "bazel-release*") {
        $build_flags += ("-c", "opt")
    }

    if (-not (Test-Path env:KOKORO_GFILE_DIR)) {
        return $build_flags
    }
    if (-not (Test-Path "${env:KOKORO_GFILE_DIR}/kokoro-run-key.json")) {
        return $build_flags
    }

    # If we have the right credentials, tell bazel to cache build results in a GCS
    # bucket. Note: this will not cache external deps, so the "fetch" below will
    # not hit this cache.
    Write-Host "$(Get-Date -Format o) Using bazel remote cache: ${BAZEL_CACHE}/windows/${BuildName}"
{'fraction_non_alphanumeric': 0.12175850891410049, 'fraction_numerical': 0.01094003241491086, 'mean_word_length': 3.3307017543859647, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '2952024', 'n_tokens_mistral': 1611, 'n_tokens_neox': 1549, 'n_words': 520}