├── .bazelrc ├── .bazelversion ├── .gitattributes ├── .github └── workflows │ └── main.yaml ├── .gitignore ├── BUILD.bazel ├── CONTRIBUTING.md ├── LICENSE ├── MODULE.bazel ├── NOTICE ├── README.md ├── WORKSPACE ├── api ├── BUILD.bazel ├── README.md ├── auth │ ├── BUILD.bazel │ ├── auth.pb.go │ └── auth.proto ├── credshelper │ ├── BUILD.bazel │ ├── credshelper.pb.go │ └── credshelper.proto ├── defs.bzl ├── log │ ├── BUILD.bazel │ ├── log.pb.go │ └── log.proto ├── proxy │ ├── BUILD.bazel │ ├── depscache.pb.go │ ├── depscache.proto │ ├── mismatch_ignore_rule.pb.go │ ├── mismatch_ignore_rule.proto │ ├── proxy.pb.go │ └── proxy.proto ├── scandeps │ ├── BUILD.bazel │ ├── cppscandeps.pb.go │ └── cppscandeps.proto ├── stat │ ├── BUILD.bazel │ ├── stat.pb.go │ └── stat.proto └── stats │ ├── BUILD.bazel │ ├── stats.pb.go │ └── stats.proto ├── cmd ├── bigquery │ ├── BUILD.bazel │ └── main.go ├── bootstrap │ ├── BUILD.bazel │ └── main.go ├── downloadmismatch │ ├── BUILD.bazel │ └── main.go ├── dumpstats │ ├── BUILD.bazel │ └── main.go ├── logdump │ ├── BUILD.bazel │ └── main.go ├── metricsuploader │ ├── BUILD.bazel │ └── main.go ├── reclientreport │ ├── BUILD.bazel │ └── main.go ├── reproxy │ ├── BUILD.bazel │ └── main.go ├── reproxystatus │ ├── BUILD.bazel │ ├── README.md │ └── main.go ├── reproxytool │ ├── BUILD.bazel │ ├── main.go │ └── usage2csv │ │ ├── BUILD.bazel │ │ └── usage2csv.go ├── rewrapper │ ├── BUILD.bazel │ └── main.go ├── rpl2cloudtrace │ ├── BUILD.bazel │ └── rpl2cloudtrace.go ├── rpl2trace │ ├── BUILD.bazel │ └── rpl2trace.go └── scandeps │ ├── BUILD.bazel │ ├── sampleclient │ ├── BUILD.bazel │ └── main.go │ ├── scandeps.cc │ └── server │ ├── BUILD.bazel │ ├── server.cc │ └── server.h ├── configs ├── BUILD.bazel ├── defs.bzl ├── linux │ ├── LICENSE │ ├── cc │ │ ├── BUILD │ │ ├── MODULE.bazel │ │ ├── REPO.bazel │ │ ├── WORKSPACE │ │ ├── armeabi_cc_toolchain_config.bzl │ │ ├── builtin_include_directory_paths │ │ ├── cc_toolchain_config.bzl │ │ ├── cc_wrapper.sh │ │ ├── module.modulemap │ │ ├── tools │ │ │ └── cpp │ │ │ │ └── empty.cc │ │ └── validate_static_library.sh │ └── config │ │ └── BUILD └── windows │ ├── LICENSE │ ├── cc │ ├── BUILD │ ├── MODULE.bazel │ ├── REPO.bazel │ ├── WORKSPACE │ ├── armeabi_cc_toolchain_config.bzl │ ├── builtin_include_directory_paths_clangcl │ ├── builtin_include_directory_paths_mingw │ ├── builtin_include_directory_paths_msvc │ ├── clang_installation_error.bat │ ├── get_env.bat │ ├── msys_gcc_installation_error.bat │ ├── vc_installation_error_arm.bat │ ├── vc_installation_error_arm64.bat │ └── windows_cc_toolchain_config.bzl │ └── config │ └── BUILD ├── docs └── cmd-line-flags.md ├── examples ├── proxyclient │ ├── BUILD.bazel │ ├── main.go │ └── testdata │ │ ├── test.cpp │ │ └── test.h └── remoteecho │ ├── BUILD.bazel │ └── main.go ├── experiments ├── api │ └── experiment │ │ ├── BUILD.bazel │ │ ├── experiment.pb.go │ │ └── experiment.proto ├── cmd │ ├── exprunner │ │ ├── BUILD.bazel │ │ └── main.go │ ├── runner │ │ ├── BUILD.bazel │ │ └── main.go │ └── tabulator │ │ ├── BUILD.bazel │ │ └── main.go └── internal │ └── pkg │ ├── experiment │ ├── BUILD.bazel │ └── experiment.go │ ├── gcs │ ├── BUILD.bazel │ └── gcs.go │ ├── perfgate │ ├── BUILD.bazel │ └── perfgate.go │ ├── runner │ ├── BUILD.bazel │ └── runner.go │ ├── tabulator │ ├── BUILD.bazel │ └── tabulator.go │ └── vm │ ├── BUILD.bazel │ └── vm.go ├── gclient.bzl ├── go.mod ├── go.sum ├── goma ├── BUILD.bazel ├── archive_linux.sh ├── archive_macosx.sh └── archive_windows.sh ├── internal └── pkg │ ├── auth │ ├── BUILD.bazel │ ├── auth.go │ ├── auth_test.go │ └── fakes │ │ ├── BUILD.bazel │ │ └── fakeadc.go │ ├── auxiliary │ ├── BUILD.bazel │ ├── auxiliary.go │ ├── auxiliary_test.go │ └── testdata │ │ ├── backend │ │ ├── BUILD.bazel │ │ └── backend_side_auxiliary_metadata.proto │ │ └── client │ │ ├── BUILD.bazel │ │ └── client_side_auxiliary_metadata.proto │ ├── bigquery │ ├── BUILD.bazel │ ├── bigquery.go │ └── bigquery_test.go │ ├── bigquerytranslator │ ├── BUILD.bazel │ ├── translator.go │ └── translator_test.go │ ├── bootstrap │ ├── BUILD.bazel │ ├── bootstrap.go │ ├── sigint_unix.go │ └── sigint_windows.go │ ├── collectlogfiles │ ├── BUILD.bazel │ ├── collectlogfiles.go │ └── collectlogfiles_test.go │ ├── cppdependencyscanner │ ├── BUILD.bazel │ ├── cppdepscanner.go │ ├── cppdepsscanner_test.go │ └── depsscannerclient │ │ ├── BUILD.bazel │ │ ├── depsscannerclient.go │ │ └── depsscannerclient_test.go │ ├── deps │ ├── BUILD.bazel │ ├── parser.go │ └── parser_test.go │ ├── diagnostics │ ├── BUILD.bazel │ ├── diagnostics.go │ ├── simpleclientserver.go │ └── simpleclientserver_test.go │ ├── downloadmismatch │ ├── BUILD.bazel │ ├── diff.go │ ├── download.go │ └── download_test.go │ ├── event │ ├── BUILD.bazel │ └── event.go │ ├── execroot │ ├── BUILD.bazel │ └── execroot.go │ ├── features │ ├── BUILD.bazel │ └── features.go │ ├── ignoremismatch │ ├── BUILD.bazel │ ├── ignoremismatch.go │ ├── ignoremismatch_test.go │ ├── ignorerule.go │ ├── ignorerule_test.go │ ├── outputfilepathrule.go │ ├── outputfilepathrule_test.go │ └── test_config.textproto │ ├── inputprocessor │ ├── BUILD.bazel │ ├── action │ │ ├── archive │ │ │ ├── BUILD.bazel │ │ │ ├── preprocessor.go │ │ │ └── preprocessor_test.go │ │ ├── clangcl │ │ │ ├── BUILD.bazel │ │ │ ├── flagsparser.go │ │ │ ├── flagsparser_test.go │ │ │ ├── preprocessor.go │ │ │ └── preprocessor_test.go │ │ ├── clanglink │ │ │ ├── BUILD.bazel │ │ │ ├── ar_reader.go │ │ │ ├── ar_reader_test.go │ │ │ ├── flagsparser.go │ │ │ ├── flagsparser_test.go │ │ │ ├── preprocessor.go │ │ │ └── testdata │ │ │ │ ├── bsd.a │ │ │ │ ├── byte_alignment.a │ │ │ │ ├── gnu.a │ │ │ │ ├── malformed.a │ │ │ │ ├── testarchive.a │ │ │ │ └── thinarchive.a │ │ ├── clanglint │ │ │ ├── BUILD.bazel │ │ │ ├── preprocessor.go │ │ │ └── preprocessor_test.go │ │ ├── cppcompile │ │ │ ├── BUILD.bazel │ │ │ ├── flagsparser.go │ │ │ ├── flagsparser_test.go │ │ │ ├── preprocessor.go │ │ │ ├── preprocessor_darwin_test.go │ │ │ └── preprocessor_test.go │ │ ├── d8 │ │ │ ├── BUILD.bazel │ │ │ ├── flagsparser.go │ │ │ ├── preprocessor.go │ │ │ └── preprocessor_test.go │ │ ├── headerabi │ │ │ ├── BUILD.bazel │ │ │ ├── flagsparser.go │ │ │ ├── flagsparser_test.go │ │ │ ├── preprocessor.go │ │ │ └── preprocessor_test.go │ │ ├── javac │ │ │ ├── BUILD.bazel │ │ │ ├── flagsparser.go │ │ │ ├── preprocessor.go │ │ │ └── preprocessor_test.go │ │ ├── metalava │ │ │ ├── BUILD.bazel │ │ │ ├── flagsparser.go │ │ │ ├── flagsparser_test.go │ │ │ ├── preprocessor.go │ │ │ └── preprocessor_test.go │ │ ├── nacl │ │ │ ├── BUILD.bazel │ │ │ ├── preprocessor.go │ │ │ └── preprocessor_test.go │ │ ├── r8 │ │ │ ├── BUILD.bazel │ │ │ ├── flagsparser.go │ │ │ ├── preprocessor.go │ │ │ └── preprocessor_test.go │ │ ├── tool │ │ │ ├── BUILD.bazel │ │ │ ├── flagsparser.go │ │ │ ├── preprocessor.go │ │ │ └── preprocessor_test.go │ │ └── typescript │ │ │ ├── BUILD.bazel │ │ │ ├── preprocessor.go │ │ │ ├── preprocessor_test.go │ │ │ ├── testdata │ │ │ ├── test_extends │ │ │ │ └── tsconfig_ext.json │ │ │ ├── test_inputs │ │ │ │ ├── a │ │ │ │ │ ├── b │ │ │ │ │ │ └── t2.ts │ │ │ │ │ └── t1.ts │ │ │ │ ├── c │ │ │ │ │ └── t3.tsx │ │ │ │ ├── tsconfig_files.json │ │ │ │ └── tsconfig_include.json │ │ │ ├── test_noextends │ │ │ │ └── tsconfig_no_ext.json │ │ │ ├── test_singlefile │ │ │ │ └── test.ts │ │ │ └── test_transitive │ │ │ │ ├── a │ │ │ │ ├── t1.ts │ │ │ │ ├── t2.ts │ │ │ │ └── t3.tsx │ │ │ │ ├── b │ │ │ │ └── bb │ │ │ │ │ └── t1.ts │ │ │ │ ├── c │ │ │ │ ├── t1.ts │ │ │ │ ├── t2.ts │ │ │ │ └── t3.ts │ │ │ │ ├── d │ │ │ │ ├── t1.tsx │ │ │ │ ├── t2.ts │ │ │ │ └── t3.ts │ │ │ │ ├── e │ │ │ │ ├── t1.ts │ │ │ │ ├── t2.ts │ │ │ │ └── t3.d.ts │ │ │ │ └── tsconfig.json │ │ │ ├── tsconfig_parser.go │ │ │ ├── tsconfig_parser_test.go │ │ │ ├── tsfile_parser.go │ │ │ ├── tsfile_parser_test.go │ │ │ ├── tsinputs.go │ │ │ └── tsinputs_test.go │ ├── args │ │ ├── BUILD.bazel │ │ ├── scanner.go │ │ └── scanner_test.go │ ├── clangparser │ │ ├── BUILD.bazel │ │ ├── clangparser.go │ │ ├── clangparser_test.go │ │ └── gen_clang_flags │ │ │ ├── BUILD.bazel │ │ │ └── main.go │ ├── depscache │ │ ├── BUILD.bazel │ │ ├── depscache.go │ │ ├── depscache_test.go │ │ └── minimalfilecache.go │ ├── flags │ │ ├── BUILD.bazel │ │ └── flags.go │ ├── flagsparser │ │ ├── BUILD.bazel │ │ └── flagsparser.go │ ├── fs_case_insensitive.go │ ├── fs_case_insensitive_test.go │ ├── fs_unix.go │ ├── fs_unix_test.go │ ├── inputprocessor.go │ ├── inputprocessor_test.go │ └── toolchain │ │ ├── BUILD.bazel │ │ ├── inputfiles.go │ │ ├── testdata │ │ ├── a.txt │ │ ├── b.txt │ │ ├── executable │ │ ├── executable2 │ │ ├── executable3 │ │ └── remote_toolchain_inputs │ │ ├── testdata2 │ │ ├── a.txt │ │ ├── b.txt │ │ ├── executable │ │ └── executable_remote_toolchain_inputs │ │ ├── toolchain.go │ │ └── toolchain_test.go │ ├── interceptors │ ├── BUILD.bazel │ ├── interceptors.go │ ├── truncate.go │ └── truncate_test.go │ ├── ipc │ ├── BUILD.bazel │ ├── dial_posix.go │ ├── dial_windows.go │ ├── doc.go │ ├── features_posix.go │ ├── features_windows.go │ ├── listen_posix.go │ └── listen_windows.go │ ├── labels │ ├── BUILD.bazel │ ├── labels.go │ └── labels_test.go │ ├── localresources │ ├── BUILD.bazel │ ├── manager.go │ ├── manager_darwin.go │ ├── manager_linux.go │ ├── manager_test.go │ ├── manager_windows.go │ └── usage │ │ ├── BUILD.bazel │ │ ├── usage.go │ │ └── usage_test.go │ ├── logger │ ├── BUILD.bazel │ ├── logger.go │ └── logger_test.go │ ├── loghttp │ ├── BUILD.bazel │ └── loghttp.go │ ├── monitoring │ ├── BUILD.bazel │ ├── monitoring.go │ └── monitoring_test.go │ ├── pathtranslator │ ├── BUILD.bazel │ ├── pathtranslator.go │ └── pathtranslator_test.go │ ├── printer │ ├── BUILD.bazel │ └── printer.go │ ├── protoencoding │ ├── BUILD │ └── protoencoding.go │ ├── rbeflag │ ├── BUILD.bazel │ ├── rbeflag.go │ └── rbeflag_test.go │ ├── reproxy │ ├── BUILD.bazel │ ├── action.go │ ├── action_test.go │ ├── compare.go │ ├── debug.go │ ├── forecast.go │ ├── forecast_test.go │ ├── localexec.go │ ├── localexec_test.go │ ├── server.go │ ├── server_test.go │ ├── stash.go │ └── timeout.go │ ├── reproxypid │ ├── BUILD.bazel │ ├── reproxypid.go │ └── reproxypid_test.go │ ├── reproxystatus │ ├── BUILD.bazel │ ├── reproxystatus.go │ └── reproxystatus_test.go │ ├── rewrapper │ ├── BUILD.bazel │ ├── rewrapper.go │ └── rewrapper_test.go │ ├── rsp │ ├── BUILD.bazel │ ├── rsp.go │ └── rsp_test.go │ ├── scandeps │ ├── BUILD.bazel │ ├── csd_include_processor.cc │ ├── csdutils │ │ ├── BUILD.bazel │ │ ├── adjust_cmd.cc │ │ ├── adjust_cmd.h │ │ ├── adjust_cmd_test.cc │ │ ├── parse_deps.cc │ │ ├── parse_deps.h │ │ ├── parse_deps_test.cc │ │ ├── parse_env.cc │ │ ├── parse_env.h │ │ └── parse_env_test.cc │ ├── goma_include_processor.cc │ ├── include_processor.h │ ├── scandeps.cc │ └── scandeps.h │ ├── stats │ ├── BUILD.bazel │ ├── stats.go │ └── stats_test.go │ ├── subprocess │ ├── BUILD.bazel │ ├── subprocess.go │ ├── subprocess_test.go │ ├── subprocess_unix.go │ └── subprocess_windows.go │ ├── tarfs │ ├── BUILD.bazel │ ├── tarfs.go │ ├── tarfs_test.go │ └── testdata │ │ └── test.tar │ └── version │ ├── BUILD.bazel │ ├── version.go │ └── version_test.go ├── linters ├── BUILD.bazel └── run_in_workspace.sh ├── llvm ├── BUILD.bazel └── clang-options-82e851.json ├── module_extensions ├── BUILD.bazel ├── llvm.bzl └── llvm_project.bzl ├── pkg └── inputprocessor │ ├── BUILD.bazel │ ├── fake │ ├── BUILD.bazel │ └── executor.go │ ├── inputprocessor.go │ ├── inputprocessor_test.go │ └── testdata │ └── sample_android_command.txt ├── renovate.json5 ├── scripts ├── install_precommit.sh ├── precommit.sh ├── regenpbgo.sh ├── sha.bat └── sha.sh ├── settings.bzl ├── third_party ├── android_toolchain │ ├── BUILD.androidtoolchain │ ├── BUILD.bazel │ └── android_toolchain_repo.bzl ├── goma │ ├── BUILD.bazel │ └── BUILD.goma └── patches │ ├── README.md │ ├── bazel │ ├── BUILD.bazel │ ├── LICENSE │ ├── rfcc.patch │ ├── rules_go.patch │ └── zlib.patch │ ├── goma │ ├── BUILD.bazel │ ├── LICENSE │ ├── breakpad.patch │ ├── goma_subprocess.patch │ └── protobuf.patch │ ├── llvm │ ├── BUILD.bazel │ ├── LICENSE │ ├── llvm-bazel-libsupport.patch │ ├── llvm-bzl-config.patch │ ├── llvm-bzl-tblgen.patch │ ├── llvm-delay-sanitizer-args-parsing.patch │ └── llvm-project-overlay-exectools.patch │ └── opencensus-go-exporter-stackdriver │ ├── BUILD.bazel │ ├── LICENSE │ └── opencensus-stackdriver-interval.patch ├── tools ├── BUILD.bazel ├── build_defs.bzl ├── copy_to_workspace.sh ├── diff_gen_vs_workspace.sh ├── imports.go └── nogo_config.json ├── transitions ├── BUILD.bazel └── defs.bzl └── version.bzl /.gitattributes: -------------------------------------------------------------------------------- 1 | *win.cfg text=auto 2 | *win.sh text=auto 3 | *.bat text=auto 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore backup files. 2 | *~ 3 | # Ignore Vim swap files. 4 | .*.sw* 5 | # Ignore bazel directories. 6 | /bazel-* 7 | # Ignore Vim swap files. 8 | .*.sw* 9 | # Ignore IntelliJ files. 10 | .ijwb 11 | # Ignore downloaded integration test data. 12 | tests/integ/testdata/clang* 13 | tests/integ/testdata/javac 14 | tests/integ/testdata/java 15 | tests/integ/testdata/macsysroot 16 | tests/integ/testdata/sysroot 17 | tests/integ/clang.tar 18 | tests/integ/testdata/chromium/src/third_party 19 | tests/integ/testdata/chromium/src/build 20 | tests/integ/testdata/chromium/zip 21 | tests/integ/testdata/chromium/RE_CLIENT_CHROMIUM_DIR 22 | # Ignore integration test artifacts 23 | *.o 24 | *.so 25 | *.d 26 | *.deps 27 | .vscode 28 | 29 | # MacOS, ignore the .DS_Store files it puts everywhere 30 | .DS_Store 31 | 32 | # Directory in which bigquery schema is generated by scripts/gen_reproxy_log_bigquery_schema.sh 33 | reproxy_log_bigquery_schema 34 | 35 | # Ignore codelab outputs 36 | codelabs/**/out.txt 37 | 38 | # Ignore Android Prebuilts 39 | configs/linux_android1404/cc/android_prebuilts 40 | 41 | # This file is currently not stable as per https://github.com/bazelbuild/bazel/issues/20369 42 | MODULE.bazel.lock 43 | 44 | # User specific bazelrc 45 | user.bazelrc -------------------------------------------------------------------------------- /WORKSPACE: -------------------------------------------------------------------------------- 1 | ## Empty WORKSPACE file to signify migration to bzlmod -------------------------------------------------------------------------------- /api/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain") 2 | 3 | # Defines a proto toolchain for using the protoc-gen-bq-schema plugin 4 | # This target should not be used anywhere except for the definition of bq_schema_proto_library 5 | # Documentation for this is hard to find, best to just read the implementation 6 | # of this rule and of proto_common.compile in https://github.com/bazelbuild/bazel/blob/7.1.2/src/main/starlark/builtins_bzl/common/proto/ 7 | proto_lang_toolchain( 8 | name = "bq_schema_proto_lang_toolchain", 9 | command_line = "--bq-schema_out=%s/api", # %s will be substituted for the bazel-bin directory 10 | output_files = "multiple", # multiple is required as protoc-gen-bq-schema expects a base directory as an output flag not a single file 11 | plugin = "@com_github_googlecloudplatform_protoc_gen_bq_schema//:protoc-gen-bq-schema", 12 | plugin_format_flag = "--plugin=protoc-gen-bq-schema=%s", # %s will be substituted for the plugin executable 13 | runtime = "@com_google_protobuf//:protobuf", 14 | visibility = ["//api:__subpackages__"], 15 | ) 16 | -------------------------------------------------------------------------------- /api/README.md: -------------------------------------------------------------------------------- 1 | After you making any change to the .proto files here, make sure you run 2 | 3 | ```bash 4 | ./scripts/regenpbgo.sh 5 | ``` 6 | 7 | to get the .pb.go file updated before you submit a CL for review. -------------------------------------------------------------------------------- /api/auth/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") 3 | load("@rules_proto//proto:defs.bzl", "proto_library") 4 | load("//tools:build_defs.bzl", "go_proto_checkedin_test") 5 | 6 | go_proto_checkedin_test( 7 | name = "proto_test", 8 | proto = ":auth_go_proto", 9 | ) 10 | 11 | proto_library( 12 | name = "auth_proto", 13 | srcs = ["auth.proto"], 14 | visibility = ["//visibility:public"], 15 | deps = ["@com_google_protobuf//:timestamp_proto"], 16 | ) 17 | 18 | go_proto_library( 19 | name = "auth_go_proto", 20 | importpath = "github.com/bazelbuild/reclient/api/auth", 21 | proto = ":auth_proto", 22 | visibility = ["//visibility:public"], 23 | ) 24 | 25 | go_library( 26 | name = "auth", 27 | embed = [":auth_go_proto"], 28 | importpath = "github.com/bazelbuild/reclient/api/auth", 29 | visibility = ["//visibility:public"], 30 | ) 31 | -------------------------------------------------------------------------------- /api/auth/auth.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | import "google/protobuf/timestamp.proto"; 18 | 19 | package auth; 20 | 21 | option go_package = "github.com/bazelbuild/reclient/api/auth"; 22 | 23 | message AuthMechanism { 24 | enum Value { 25 | // Invalid value, should always specify a value. 26 | UNSPECIFIED = 0; 27 | reserved 1, 3; 28 | // Application default credentials. 29 | ADC = 2; 30 | // GCE based authentication. 31 | GCE = 4; 32 | // A credential file with service account credentials. 33 | CREDENTIAL_FILE = 5; 34 | // No authentication is used. 35 | NONE = 6; 36 | // External credentials helper is used. 37 | CREDENTIALSHELPER = 7; 38 | } 39 | } 40 | 41 | // Stores information used for authenticating to the remote execution service. 42 | message Credentials { 43 | // Authentication mechanism. 44 | AuthMechanism.Value mechanism = 1; 45 | // The token string. 46 | string token = 2; 47 | reserved 3; 48 | reserved "created_at"; 49 | // Token expiry. 50 | google.protobuf.Timestamp expiry = 4; 51 | // Reauth expiry. 52 | google.protobuf.Timestamp refresh_expiry = 5; 53 | // Credshelper command digest in canonical form of hash/size. 54 | string credsHelperCmdDigest = 6; 55 | } 56 | -------------------------------------------------------------------------------- /api/credshelper/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") 3 | load("@rules_proto//proto:defs.bzl", "proto_library") 4 | load("//tools:build_defs.bzl", "go_proto_checkedin_test") 5 | 6 | go_proto_checkedin_test( 7 | name = "proto_test", 8 | proto = ":credshelper_go_proto", 9 | ) 10 | 11 | proto_library( 12 | name = "credshelper_proto", 13 | srcs = ["credshelper.proto"], 14 | visibility = ["//visibility:public"], 15 | deps = ["@com_google_protobuf//:timestamp_proto"], 16 | ) 17 | 18 | go_proto_library( 19 | name = "credshelper_go_proto", 20 | importpath = "github.com/bazelbuild/reclient/api/credshelper", 21 | proto = ":credshelper_proto", 22 | visibility = ["//visibility:public"], 23 | ) 24 | 25 | go_library( 26 | name = "credshelper", 27 | embed = [":credshelper_go_proto"], 28 | importpath = "github.com/bazelbuild/reclient/api/credshelper", 29 | visibility = ["//visibility:public"], 30 | ) 31 | -------------------------------------------------------------------------------- /api/credshelper/credshelper.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | import "google/protobuf/timestamp.proto"; 18 | 19 | package credshelper; 20 | 21 | // Stores information used for authenticating to the remote execution service. 22 | message CachedCredentials { 23 | // Authentication mechanism. 24 | string mechanism = 1; 25 | // The token string. 26 | string token = 2; 27 | // Token expiry. 28 | google.protobuf.Timestamp expiry = 3; 29 | // Reauth expiry. 30 | google.protobuf.Timestamp refresh_expiry = 4; 31 | } 32 | -------------------------------------------------------------------------------- /api/defs.bzl: -------------------------------------------------------------------------------- 1 | """ Defines bq_schema_proto_library for generating bigquery schemas. """ 2 | load("@rules_proto//proto:defs.bzl", "proto_common") 3 | 4 | def _bq_schema_proto_library_impl(ctx): 5 | """ Implementation of bq_schema_proto_library 6 | 7 | Logic is inspired by _py_proto_aspect_impl in https://github.com/protocolbuffers/protobuf/blob/main/bazel/py_proto_library.bzl 8 | """ 9 | generated_sources = proto_common.declare_generated_files( 10 | actions = ctx.actions, 11 | proto_info = ctx.attr.src[ProtoInfo], 12 | extension = ".schema", 13 | ) 14 | additional_args = ctx.actions.args() 15 | additional_args.add("--bq-schema_opt=single-message") 16 | proto_common.compile( 17 | actions = ctx.actions, 18 | proto_info = ctx.attr.src[ProtoInfo], 19 | proto_lang_toolchain_info = ctx.attr._proto_lang_toolchain[proto_common.ProtoLangToolchainInfo], 20 | generated_files = generated_sources, 21 | additional_args = additional_args, 22 | ) 23 | return [DefaultInfo( 24 | files = depset(generated_sources), 25 | )] 26 | 27 | bq_schema_proto_library = rule( 28 | doc = """ Generates a bigquery schema from a proto file using protoc-gen-bq-schema 29 | 30 | Args: 31 | src: Label of the proto_library rule for the bigquery schema 32 | 33 | Example: 34 | 35 | proto_library( 36 | name = "example_proto", 37 | srcs = ["example.proto"] 38 | ) 39 | 40 | bq_schema_proto_library( 41 | name = "example_bq_schema_proto", 42 | src = ":example_proto" 43 | ) 44 | 45 | """, 46 | implementation = _bq_schema_proto_library_impl, 47 | attrs = { 48 | "src": attr.label(providers = [ProtoInfo]), 49 | "_proto_lang_toolchain": attr.label(default = "//api:bq_schema_proto_lang_toolchain", providers = [proto_common.ProtoLangToolchainInfo]) 50 | } 51 | ) 52 | -------------------------------------------------------------------------------- /api/proxy/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") 3 | load("@rules_proto//proto:defs.bzl", "proto_library") 4 | load("//tools:build_defs.bzl", "go_proto_checkedin_test") 5 | 6 | # gazelle:resolve proto go/api/command/command.proto @com_github_bazelbuild_remote_apis_sdks//go/api/command:cmd_proto 7 | # gazelle:resolve proto go go/api/command/command.proto @com_github_bazelbuild_remote_apis_sdks//go/api/command 8 | 9 | go_proto_checkedin_test( 10 | name = "proto_test", 11 | proto = ":proxy_go_proto", 12 | ) 13 | 14 | proto_library( 15 | name = "proxy_proto", 16 | srcs = [ 17 | "depscache.proto", 18 | "mismatch_ignore_rule.proto", 19 | "proxy.proto", 20 | ], 21 | visibility = ["//visibility:public"], 22 | deps = [ 23 | "//api/log:log_proto", 24 | "//api/stats:stats_proto", 25 | "@com_github_bazelbuild_remote_apis_sdks//go/api/command:cmd_proto", 26 | "@com_google_protobuf//:timestamp_proto", 27 | ], 28 | ) 29 | 30 | go_proto_library( 31 | name = "proxy_go_proto", 32 | compilers = ["@io_bazel_rules_go//proto:go_grpc"], 33 | importpath = "github.com/bazelbuild/reclient/api/proxy", 34 | proto = ":proxy_proto", 35 | visibility = ["//visibility:public"], 36 | deps = [ 37 | "//api/log", 38 | "//api/stats", 39 | "@com_github_bazelbuild_remote_apis_sdks//go/api/command", 40 | ], 41 | ) 42 | 43 | go_library( 44 | name = "proxy", 45 | embed = [":proxy_go_proto"], 46 | importpath = "github.com/bazelbuild/reclient/api/proxy", 47 | visibility = ["//visibility:public"], 48 | ) 49 | -------------------------------------------------------------------------------- /api/proxy/mismatch_ignore_rule.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package proxy; 18 | 19 | option go_package = "github.com/bazelbuild/reclient/api/proxy"; 20 | 21 | // A collection of rules. If any of the rule decides to ignore a mismatch, the 22 | // mismatch will be marked as ignored. 23 | message MismatchIgnoreConfig { 24 | repeated Rule rules = 1; 25 | } 26 | 27 | // A rule defines the logic of how to check whether a mismatch can be ignored or 28 | // not. 29 | message Rule { 30 | oneof rule_spec { 31 | OutputFilePathRuleSpec output_file_path_rule_spec = 1; 32 | } 33 | } 34 | 35 | // Output file path rule will be matched if an action with diffs contains any 36 | // output file of which the path matches the pattern. 37 | message OutputFilePathRuleSpec { 38 | RegexPattern path_pattern = 1; 39 | } 40 | 41 | // Represents a regex pattern. 42 | message RegexPattern { 43 | // The regular expression 44 | string expression = 1; 45 | 46 | // Denotes if the pattern is inverted, i.e if the regular expression 47 | // will match everything except the above expression. 48 | bool inverted = 2; 49 | } 50 | -------------------------------------------------------------------------------- /api/scandeps/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@com_github_grpc_grpc//bazel:cc_grpc_library.bzl", "cc_grpc_library") 2 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 3 | load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") 4 | load("@rules_proto//proto:defs.bzl", "proto_library") 5 | load("//tools:build_defs.bzl", "go_proto_checkedin_test") 6 | 7 | go_proto_checkedin_test( 8 | name = "proto_test", 9 | proto = ":scandeps_go_proto", 10 | ) 11 | 12 | proto_library( 13 | name = "scandeps_proto", 14 | srcs = ["cppscandeps.proto"], 15 | visibility = ["//visibility:public"], 16 | deps = [ 17 | "@com_google_protobuf//:duration_proto", 18 | "@com_google_protobuf//:empty_proto", 19 | ], 20 | ) 21 | 22 | cc_proto_library( 23 | name = "scandeps_cc_proto", 24 | deps = [ 25 | ":scandeps_proto", 26 | ], 27 | ) 28 | 29 | cc_grpc_library( 30 | name = "scandeps_cc", 31 | srcs = [":scandeps_proto"], 32 | grpc_only = True, 33 | visibility = ["//visibility:public"], 34 | deps = [":scandeps_cc_proto"], 35 | ) 36 | 37 | go_proto_library( 38 | name = "scandeps_go_proto", 39 | compilers = ["@io_bazel_rules_go//proto:go_grpc"], 40 | importpath = "github.com/bazelbuild/reclient/api/scandeps", 41 | proto = ":scandeps_proto", 42 | visibility = ["//visibility:public"], 43 | ) 44 | 45 | go_library( 46 | name = "scandeps", 47 | embed = [":scandeps_go_proto"], 48 | importpath = "github.com/bazelbuild/reclient/api/scandeps", 49 | visibility = ["//visibility:public"], 50 | ) 51 | -------------------------------------------------------------------------------- /api/stat/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") 3 | load("@rules_proto//proto:defs.bzl", "proto_library") 4 | load("//tools:build_defs.bzl", "go_proto_checkedin_test") 5 | 6 | go_proto_checkedin_test( 7 | name = "proto_test", 8 | proto = ":stat_go_proto", 9 | ) 10 | 11 | proto_library( 12 | name = "stat_proto", 13 | srcs = ["stat.proto"], 14 | visibility = ["//visibility:public"], 15 | ) 16 | 17 | go_proto_library( 18 | name = "stat_go_proto", 19 | importpath = "github.com/bazelbuild/reclient/api/stat", 20 | proto = ":stat_proto", 21 | visibility = ["//visibility:public"], 22 | ) 23 | 24 | go_library( 25 | name = "stat", 26 | embed = [":stat_go_proto"], 27 | importpath = "github.com/bazelbuild/reclient/api/stat", 28 | visibility = ["//visibility:public"], 29 | ) 30 | -------------------------------------------------------------------------------- /api/stat/stat.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package stats; 18 | 19 | option go_package = "github.com/bazelbuild/reclient/api/stat"; 20 | 21 | // Outlier represents a command with an unusually large value in the stat. 22 | message Outlier { 23 | string command_id = 1; 24 | int64 value = 2; 25 | } 26 | 27 | message Stat { 28 | // The metric/stat name. 29 | string name = 1; 30 | 31 | // The number of all the true values for booleans, the sum of all the 32 | // values for ints. 33 | int64 count = 2; 34 | 35 | message Value { 36 | string name = 1; 37 | int64 count = 2; 38 | } 39 | // For enum stats, the count of each value. 40 | repeated Value counts_by_value = 3; 41 | 42 | // A list of commands that have the highest values. 43 | repeated Outlier outliers = 4; 44 | 45 | int64 median = 5; 46 | int64 percentile75 = 6; 47 | int64 percentile85 = 7; 48 | int64 percentile95 = 8; 49 | double average = 9; 50 | } -------------------------------------------------------------------------------- /api/stats/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") 3 | load("@rules_proto//proto:defs.bzl", "proto_library") 4 | load("//api:defs.bzl", "bq_schema_proto_library") 5 | load("//tools:build_defs.bzl", "go_proto_checkedin_test") 6 | 7 | go_proto_checkedin_test( 8 | name = "proto_test", 9 | proto = ":stats_go_proto", 10 | ) 11 | 12 | proto_library( 13 | name = "stats_proto", 14 | srcs = ["stats.proto"], 15 | visibility = ["//visibility:public"], 16 | deps = [ 17 | "//api/log:log_proto", 18 | "//api/stat:stat_proto", 19 | ], 20 | ) 21 | 22 | go_proto_library( 23 | name = "stats_go_proto", 24 | importpath = "github.com/bazelbuild/reclient/api/stats", 25 | proto = ":stats_proto", 26 | visibility = ["//visibility:public"], 27 | deps = [ 28 | "//api/log", 29 | "//api/stat", 30 | ], 31 | ) 32 | 33 | go_library( 34 | name = "stats", 35 | embed = [":stats_go_proto"], 36 | importpath = "github.com/bazelbuild/reclient/api/stats", 37 | visibility = ["//visibility:public"], 38 | ) 39 | 40 | bq_schema_proto_library( 41 | name = "stats_bq_schema_proto", 42 | src = ":stats_proto", 43 | ) 44 | -------------------------------------------------------------------------------- /cmd/bigquery/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | go_library( 4 | name = "bigquery_lib", 5 | srcs = ["main.go"], 6 | importpath = "github.com/bazelbuild/reclient/cmd/bigquery", 7 | visibility = ["//visibility:private"], 8 | deps = [ 9 | "//api/log", 10 | "//internal/pkg/bigquery", 11 | "//internal/pkg/bigquerytranslator", 12 | "//internal/pkg/logger", 13 | "//internal/pkg/rbeflag", 14 | "@com_github_golang_glog//:glog", 15 | ], 16 | ) 17 | 18 | go_binary( 19 | name = "bigquery", 20 | embed = [":bigquery_lib"], 21 | visibility = ["//visibility:public"], 22 | ) 23 | -------------------------------------------------------------------------------- /cmd/bootstrap/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | go_library( 4 | name = "bootstrap_lib", 5 | srcs = ["main.go"], 6 | importpath = "github.com/bazelbuild/reclient/cmd/bootstrap", 7 | visibility = ["//visibility:private"], 8 | deps = [ 9 | "//api/log", 10 | "//api/stats", 11 | "//internal/pkg/auth", 12 | "//internal/pkg/bootstrap", 13 | "//internal/pkg/event", 14 | "//internal/pkg/logger", 15 | "//internal/pkg/loghttp", 16 | "//internal/pkg/pathtranslator", 17 | "//internal/pkg/rbeflag", 18 | "//internal/pkg/stats", 19 | "//internal/pkg/version", 20 | "@com_github_bazelbuild_remote_apis_sdks//go/api/command", 21 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 22 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/credshelper", 23 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/moreflag", 24 | "@com_github_golang_glog//:glog", 25 | "@org_golang_google_grpc//credentials/oauth", 26 | "@org_golang_google_protobuf//proto", 27 | ], 28 | ) 29 | 30 | go_binary( 31 | name = "bootstrap", 32 | args = ["--re_proxy=$(location //cmd/reproxy:reproxy)"], 33 | data = ["//cmd/reproxy"], 34 | embed = [":bootstrap_lib"], 35 | visibility = ["//visibility:public"], 36 | ) 37 | -------------------------------------------------------------------------------- /cmd/downloadmismatch/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | go_library( 4 | name = "downloadmismatch_lib", 5 | srcs = ["main.go"], 6 | importpath = "github.com/bazelbuild/reclient/cmd/downloadmismatch", 7 | visibility = ["//visibility:private"], 8 | deps = [ 9 | "//internal/pkg/downloadmismatch", 10 | "//internal/pkg/rbeflag", 11 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/flags", 12 | ], 13 | ) 14 | 15 | go_binary( 16 | name = "downloadmismatch", 17 | embed = [":downloadmismatch_lib"], 18 | visibility = ["//visibility:public"], 19 | ) 20 | -------------------------------------------------------------------------------- /cmd/dumpstats/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | go_library( 4 | name = "dumpstats_lib", 5 | srcs = ["main.go"], 6 | importpath = "github.com/bazelbuild/reclient/cmd/dumpstats", 7 | visibility = ["//visibility:private"], 8 | deps = [ 9 | "//api/log", 10 | "//internal/pkg/bootstrap", 11 | "//internal/pkg/logger", 12 | "//internal/pkg/rbeflag", 13 | "//internal/pkg/stats", 14 | "//internal/pkg/version", 15 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/moreflag", 16 | "@com_github_golang_glog//:glog", 17 | ], 18 | ) 19 | 20 | go_binary( 21 | name = "dumpstats", 22 | embed = [":dumpstats_lib"], 23 | visibility = ["//visibility:public"], 24 | ) 25 | -------------------------------------------------------------------------------- /cmd/logdump/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | go_library( 4 | name = "logdump_lib", 5 | srcs = ["main.go"], 6 | importpath = "github.com/bazelbuild/reclient/cmd/logdump", 7 | visibility = ["//visibility:private"], 8 | deps = [ 9 | "//api/log", 10 | "//internal/pkg/logger", 11 | "//internal/pkg/rbeflag", 12 | "//internal/pkg/version", 13 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/moreflag", 14 | "@com_github_golang_glog//:glog", 15 | "@org_golang_google_protobuf//proto", 16 | ], 17 | ) 18 | 19 | go_binary( 20 | name = "logdump", 21 | embed = [":logdump_lib"], 22 | visibility = ["//visibility:public"], 23 | ) 24 | -------------------------------------------------------------------------------- /cmd/metricsuploader/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | go_library( 4 | name = "metricsuploader_lib", 5 | srcs = ["main.go"], 6 | importpath = "github.com/bazelbuild/reclient/cmd/metricsuploader", 7 | visibility = ["//visibility:private"], 8 | deps = [ 9 | "//api/stats", 10 | "//internal/pkg/bigquery", 11 | "//internal/pkg/collectlogfiles", 12 | "//internal/pkg/monitoring", 13 | "//internal/pkg/rbeflag", 14 | "//internal/pkg/stats", 15 | "//internal/pkg/version", 16 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/client", 17 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/flags", 18 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/moreflag", 19 | "@com_github_golang_glog//:glog", 20 | "@org_golang_google_grpc//credentials/oauth", 21 | "@org_golang_google_protobuf//proto", 22 | "@org_golang_x_oauth2//:oauth2", 23 | ], 24 | ) 25 | 26 | go_binary( 27 | name = "metricsuploader", 28 | embed = [":metricsuploader_lib"], 29 | visibility = ["//visibility:public"], 30 | ) 31 | -------------------------------------------------------------------------------- /cmd/reclientreport/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | go_library( 4 | name = "reclientreport_lib", 5 | srcs = ["main.go"], 6 | importpath = "github.com/bazelbuild/reclient/cmd/reclientreport", 7 | visibility = ["//visibility:private"], 8 | deps = [ 9 | "//internal/pkg/collectlogfiles", 10 | "//internal/pkg/rbeflag", 11 | "//internal/pkg/reproxypid", 12 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/moreflag", 13 | "@com_github_golang_glog//:glog", 14 | ], 15 | ) 16 | 17 | go_binary( 18 | name = "reclientreport", 19 | embed = [":reclientreport_lib"], 20 | visibility = ["//visibility:public"], 21 | ) 22 | -------------------------------------------------------------------------------- /cmd/reproxystatus/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | go_library( 4 | name = "reproxystatus_lib", 5 | srcs = ["main.go"], 6 | importpath = "github.com/bazelbuild/reclient/cmd/reproxystatus", 7 | visibility = ["//visibility:private"], 8 | deps = [ 9 | "//internal/pkg/printer", 10 | "//internal/pkg/rbeflag", 11 | "//internal/pkg/reproxystatus", 12 | "@com_github_fatih_color//:color", 13 | "@com_github_gosuri_uilive//:uilive", 14 | ], 15 | ) 16 | 17 | go_binary( 18 | name = "reproxystatus", 19 | embed = [":reproxystatus_lib"], 20 | visibility = ["//visibility:public"], 21 | ) 22 | -------------------------------------------------------------------------------- /cmd/reproxystatus/README.md: -------------------------------------------------------------------------------- 1 | # User Guide for `reproxystatus` 2 | 3 | `reproxystatus` is a binary that can be used to monitor build stats for running 4 | instances of `reproxy`. 5 | Source code can be found in this directory. 6 | 7 | ## Usage 8 | 9 | Invoking `reproxystatus` with no arguments will print build stats for all 10 | running instances of `reproxy` with `--server_address=unix://...` or 11 | `--server_address=pipe://...`. 12 | 13 | If `reproxy` is running on a tcp ip and port, or if you only want to show stats 14 | for one instance then you must pass the same `--server_address` to 15 | `reproxystatus` that was passed to `reproxy`. 16 | 17 | To see live output throughout a build, wrap the call to `reproxystatus` with a 18 | tool like `watch`, eg: 19 | 20 | ``` 21 | $ watch /path/to/reproxystatus 22 | ``` 23 | 24 | ## Sample output 25 | 26 | ``` 27 | $ /path/to/reproxystatus 28 | Reproxy(unix:///path/to/unix.sock) is OK 29 | Actions completed: 26935 (26756 cache hit, 179 racing local) 30 | Actions in progress: 20 31 | ``` 32 | -------------------------------------------------------------------------------- /cmd/reproxytool/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | go_library( 4 | name = "reproxytool_lib", 5 | srcs = ["main.go"], 6 | importpath = "github.com/bazelbuild/reclient/cmd/reproxytool", 7 | visibility = ["//visibility:private"], 8 | deps = [ 9 | "//cmd/reproxytool/usage2csv", 10 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/client", 11 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/flags", 12 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/tool", 13 | "@com_github_golang_glog//:glog", 14 | ], 15 | ) 16 | 17 | go_binary( 18 | name = "reproxytool", 19 | embed = [":reproxytool_lib"], 20 | target_compatible_with = select({ 21 | "@platforms//os:linux": [], 22 | "//conditions:default": ["@platforms//:incompatible"], 23 | }), 24 | visibility = ["//visibility:public"], 25 | ) 26 | -------------------------------------------------------------------------------- /cmd/reproxytool/usage2csv/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "usage2csv", 5 | srcs = ["usage2csv.go"], 6 | importpath = "github.com/bazelbuild/reclient/cmd/reproxytool/usage2csv", 7 | visibility = ["//visibility:public"], 8 | deps = ["@com_github_golang_glog//:glog"], 9 | ) 10 | -------------------------------------------------------------------------------- /cmd/rewrapper/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | go_library( 4 | name = "rewrapper_lib", 5 | srcs = ["main.go"], 6 | importpath = "github.com/bazelbuild/reclient/cmd/rewrapper", 7 | visibility = ["//visibility:private"], 8 | deps = [ 9 | "//api/proxy", 10 | "//internal/pkg/ipc", 11 | "//internal/pkg/protoencoding", 12 | "//internal/pkg/rbeflag", 13 | "//internal/pkg/rewrapper", 14 | "//internal/pkg/version", 15 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/moreflag", 16 | "@com_github_golang_glog//:glog", 17 | ], 18 | ) 19 | 20 | go_binary( 21 | name = "rewrapper", 22 | embed = [":rewrapper_lib"], 23 | visibility = ["//visibility:public"], 24 | ) 25 | -------------------------------------------------------------------------------- /cmd/rpl2cloudtrace/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | go_library( 4 | name = "rpl2cloudtrace_lib", 5 | srcs = ["rpl2cloudtrace.go"], 6 | importpath = "github.com/bazelbuild/reclient/cmd/rpl2cloudtrace", 7 | visibility = ["//visibility:private"], 8 | deps = [ 9 | "//api/log", 10 | "//internal/pkg/labels", 11 | "//internal/pkg/logger", 12 | "//internal/pkg/rbeflag", 13 | "@com_github_bazelbuild_remote_apis_sdks//go/api/command", 14 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/moreflag", 15 | "@com_github_golang_glog//:glog", 16 | "@com_google_cloud_go_trace//apiv2", 17 | "@org_golang_google_genproto//googleapis/devtools/cloudtrace/v2:cloudtrace", 18 | "@org_golang_google_genproto_googleapis_rpc//status", 19 | "@org_golang_google_grpc//codes", 20 | "@org_golang_google_grpc//status", 21 | "@org_golang_google_protobuf//types/known/timestamppb", 22 | ], 23 | ) 24 | 25 | go_binary( 26 | name = "rpl2cloudtrace", 27 | embed = [":rpl2cloudtrace_lib"], 28 | visibility = ["//visibility:public"], 29 | ) 30 | -------------------------------------------------------------------------------- /cmd/rpl2trace/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | go_library( 4 | name = "rpl2trace_lib", 5 | srcs = ["rpl2trace.go"], 6 | importpath = "github.com/bazelbuild/reclient/cmd/rpl2trace", 7 | visibility = ["//visibility:private"], 8 | deps = [ 9 | "//api/log", 10 | "//internal/pkg/logger", 11 | "//internal/pkg/rbeflag", 12 | "@com_github_bazelbuild_remote_apis_sdks//go/api/command", 13 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/moreflag", 14 | "@com_github_golang_glog//:glog", 15 | ], 16 | ) 17 | 18 | go_binary( 19 | name = "rpl2trace", 20 | embed = [":rpl2trace_lib"], 21 | visibility = ["//visibility:public"], 22 | ) 23 | -------------------------------------------------------------------------------- /cmd/scandeps/sampleclient/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | go_library( 4 | name = "sampleclient_lib", 5 | srcs = ["main.go"], 6 | importpath = "github.com/bazelbuild/reclient/cmd/scandeps/sampleclient", 7 | tags = [ 8 | "manual", 9 | ], 10 | visibility = ["//visibility:private"], 11 | deps = [ 12 | "//api/scandeps", 13 | "//internal/pkg/ipc", 14 | "@com_github_golang_glog//:glog", 15 | "@com_github_google_uuid//:uuid", 16 | "@org_golang_google_grpc//codes", 17 | "@org_golang_google_grpc//status", 18 | "@org_golang_google_protobuf//types/known/emptypb", 19 | ], 20 | ) 21 | 22 | go_binary( 23 | name = "sampleclient", 24 | embed = [":sampleclient_lib"], 25 | target_compatible_with = select({ 26 | "//:goma_input_processor_config": [], 27 | "//conditions:default": ["@platforms//:incompatible"], 28 | }), 29 | visibility = ["//visibility:public"], 30 | ) 31 | -------------------------------------------------------------------------------- /cmd/scandeps/server/BUILD.bazel: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "scandeps_server_lib", 3 | srcs = [ 4 | "server.cc", 5 | "server.h", 6 | ], 7 | hdrs = ["server.h"], 8 | tags = ["manual"], 9 | visibility = ["//:__subpackages__"], 10 | deps = [ 11 | "//api/scandeps:scandeps_cc", 12 | "//internal/pkg/scandeps", 13 | "@com_github_grpc_grpc//:grpc++", 14 | ] + select({ 15 | "//:goma_input_processor_config_windows": [ 16 | "@com_github_google_glog//:glog", 17 | ], 18 | "//:clangscandeps_input_processor_config": [ 19 | "@com_github_google_glog//:glog", 20 | ], 21 | "//conditions:default": [ 22 | "@goma//:glog", 23 | ], 24 | }), 25 | ) 26 | -------------------------------------------------------------------------------- /configs/BUILD.bazel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazelbuild/reclient/9139556d0e2c77e57cfad0105207b7dfbdcfaf70/configs/BUILD.bazel -------------------------------------------------------------------------------- /configs/defs.bzl: -------------------------------------------------------------------------------- 1 | """Constants for platform configs.""" 2 | WINDOWS_DOCKER_IMAGE = "us-central1-docker.pkg.dev/kokoro-container-bakery/re-client/reclient-builder-win@sha256:9ba393f95f26222a8674d7de68b68222a741e5dca4fd22ba766804b01c6c47df" 3 | LINUX_DOCKER_IMAGE = "us-central1-docker.pkg.dev/kokoro-container-bakery/re-client/reclient-builder@sha256:426fb44bddb255f0c366679068015705469fdd460d336faaad6c63f4de02b77a" -------------------------------------------------------------------------------- /configs/linux/cc/MODULE.bazel: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Bazel now uses Bzlmod by default to manage external dependencies. 3 | # Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel. 4 | # 5 | # For more details, please check https://github.com/bazelbuild/bazel/issues/18958 6 | ############################################################################### 7 | -------------------------------------------------------------------------------- /configs/linux/cc/REPO.bazel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazelbuild/reclient/9139556d0e2c77e57cfad0105207b7dfbdcfaf70/configs/linux/cc/REPO.bazel -------------------------------------------------------------------------------- /configs/linux/cc/WORKSPACE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazelbuild/reclient/9139556d0e2c77e57cfad0105207b7dfbdcfaf70/configs/linux/cc/WORKSPACE -------------------------------------------------------------------------------- /configs/linux/cc/builtin_include_directory_paths: -------------------------------------------------------------------------------- 1 | This file is generated by cc_configure and contains builtin include directories 2 | that /usr/lib/llvm-17/bin/clang reported. This file is a dependency of every compilation action and 3 | changes to it will be reflected in the action cache key. When some of these 4 | paths change, Bazel will make sure to rerun the action, even though none of 5 | declared action inputs or the action commandline changes. 6 | 7 | /usr/lib/llvm-17/lib/clang/17/include 8 | /usr/local/include 9 | /usr/include/x86_64-linux-gnu 10 | /usr/include 11 | /usr/lib/llvm-17/lib/clang/17/share 12 | /usr/include/c++/9 13 | /usr/include/x86_64-linux-gnu/c++/9 14 | /usr/include/c++/9/backward 15 | /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk 16 | -------------------------------------------------------------------------------- /configs/linux/cc/cc_wrapper.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright 2015 The Bazel Authors. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # Ship the environment to the C++ action 18 | # 19 | set -eu 20 | 21 | OUTPUT= 22 | 23 | function parse_option() { 24 | local -r opt="$1" 25 | if [[ "${OUTPUT}" = "1" ]]; then 26 | OUTPUT=$opt 27 | elif [[ "$opt" = "-o" ]]; then 28 | # output is coming 29 | OUTPUT=1 30 | fi 31 | } 32 | 33 | # let parse the option list 34 | for i in "$@"; do 35 | if [[ "$i" = @* && -r "${i:1}" ]]; then 36 | while IFS= read -r opt 37 | do 38 | parse_option "$opt" 39 | done < "${i:1}" || exit 1 40 | else 41 | parse_option "$i" 42 | fi 43 | done 44 | 45 | # Set-up the environment 46 | 47 | 48 | # Call the C++ compiler 49 | /usr/lib/llvm-17/bin/clang "$@" 50 | 51 | # Generate an empty file if header processing succeeded. 52 | if [[ "${OUTPUT}" == *.h.processed ]]; then 53 | echo -n > "${OUTPUT}" 54 | fi 55 | -------------------------------------------------------------------------------- /configs/linux/cc/tools/cpp/empty.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | int main() {} -------------------------------------------------------------------------------- /configs/linux/config/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//configs:defs.bzl", "LINUX_DOCKER_IMAGE") 16 | 17 | # This file is auto-generated by github.com/bazelbuild/bazel-toolchains/pkg/rbeconfigsgen 18 | # and should not be modified directly. 19 | 20 | package(default_visibility = ["//visibility:public"]) 21 | 22 | toolchain( 23 | name = "cc-toolchain", 24 | exec_compatible_with = [ 25 | "@platforms//os:linux", 26 | "@platforms//cpu:x86_64", 27 | "@bazel_tools//tools/cpp:clang", 28 | "@linux_android1404//:no_android_toolchain", 29 | ], 30 | target_compatible_with = [ 31 | "@platforms//os:linux", 32 | "@platforms//cpu:x86_64", 33 | ], 34 | toolchain = "//configs/linux/cc:cc-compiler-k8", 35 | toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", 36 | ) 37 | 38 | platform( 39 | name = "platform", 40 | constraint_values = [ 41 | "@platforms//os:linux", 42 | "@platforms//cpu:x86_64", 43 | "@bazel_tools//tools/cpp:clang", 44 | ], 45 | exec_properties = { 46 | "container-image": "docker://" + LINUX_DOCKER_IMAGE, 47 | "OSFamily": "Linux", 48 | }, 49 | parents = ["@local_config_platform//:host"], 50 | ) 51 | -------------------------------------------------------------------------------- /configs/windows/cc/MODULE.bazel: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Bazel now uses Bzlmod by default to manage external dependencies. 3 | # Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel. 4 | # 5 | # For more details, please check https://github.com/bazelbuild/bazel/issues/18958 6 | ############################################################################### 7 | -------------------------------------------------------------------------------- /configs/windows/cc/REPO.bazel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazelbuild/reclient/9139556d0e2c77e57cfad0105207b7dfbdcfaf70/configs/windows/cc/REPO.bazel -------------------------------------------------------------------------------- /configs/windows/cc/WORKSPACE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazelbuild/reclient/9139556d0e2c77e57cfad0105207b7dfbdcfaf70/configs/windows/cc/WORKSPACE -------------------------------------------------------------------------------- /configs/windows/cc/builtin_include_directory_paths_clangcl: -------------------------------------------------------------------------------- 1 | This file is generated by cc_configure and contains builtin include directories 2 | that clang-cl reported. This file is a dependency of every compilation action and 3 | changes to it will be reflected in the action cache key. When some of these 4 | paths change, Bazel will make sure to rerun the action, even though none of 5 | declared action inputs or the action commandline changes. 6 | 7 | 8 | -------------------------------------------------------------------------------- /configs/windows/cc/builtin_include_directory_paths_mingw: -------------------------------------------------------------------------------- 1 | This file is generated by cc_configure and contains builtin include directories 2 | that mingw reported. This file is a dependency of every compilation action and 3 | changes to it will be reflected in the action cache key. When some of these 4 | paths change, Bazel will make sure to rerun the action, even though none of 5 | declared action inputs or the action commandline changes. 6 | 7 | "c:/tools/msys64/mingw64/", 8 | 9 | -------------------------------------------------------------------------------- /configs/windows/cc/builtin_include_directory_paths_msvc: -------------------------------------------------------------------------------- 1 | This file is generated by cc_configure and contains builtin include directories 2 | that msvc reported. This file is a dependency of every compilation action and 3 | changes to it will be reflected in the action cache key. When some of these 4 | paths change, Bazel will make sure to rerun the action, even though none of 5 | declared action inputs or the action commandline changes. 6 | 7 | 8 | -------------------------------------------------------------------------------- /configs/windows/cc/clang_installation_error.bat: -------------------------------------------------------------------------------- 1 | :: Copyright 2019 The Bazel Authors. All rights reserved. 2 | :: 3 | :: Licensed under the Apache License, Version 2.0 (the "License"); 4 | :: you may not use this file except in compliance with the License. 5 | :: You may obtain a copy of the License at 6 | :: 7 | :: http://www.apache.org/licenses/LICENSE-2.0 8 | :: 9 | :: Unless required by applicable law or agreed to in writing, software 10 | :: distributed under the License is distributed on an "AS IS" BASIS, 11 | :: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | :: See the License for the specific language governing permissions and 13 | :: limitations under the License. 14 | 15 | @echo OFF 16 | 17 | echo. 1>&2 18 | echo The target you are compiling requires the Clang compiler. 1>&2 19 | echo Bazel couldn't find a valid Clang installation on your machine. 1>&2 20 | 21 | echo Please check your installation following https://bazel.build/docs/windows#using 1>&2 22 | echo. 1>&2 23 | 24 | exit /b 1 25 | -------------------------------------------------------------------------------- /configs/windows/cc/get_env.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\VCVARSALL.BAT" amd64 -vcvars_ver=14.29.30133 > NUL 3 | echo PATH=%PATH%,INCLUDE=%INCLUDE%,LIB=%LIB%,WINDOWSSDKDIR=%WINDOWSSDKDIR% 4 | -------------------------------------------------------------------------------- /configs/windows/cc/msys_gcc_installation_error.bat: -------------------------------------------------------------------------------- 1 | :: Copyright 2018 The Bazel Authors. All rights reserved. 2 | :: 3 | :: Licensed under the Apache License, Version 2.0 (the "License"); 4 | :: you may not use this file except in compliance with the License. 5 | :: You may obtain a copy of the License at 6 | :: 7 | :: http://www.apache.org/licenses/LICENSE-2.0 8 | :: 9 | :: Unless required by applicable law or agreed to in writing, software 10 | :: distributed under the License is distributed on an "AS IS" BASIS, 11 | :: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | :: See the License for the specific language governing permissions and 13 | :: limitations under the License. 14 | 15 | @echo OFF 16 | 17 | echo. 1>&2 18 | echo The target you are compiling requires MSYS gcc / MINGW gcc. 1>&2 19 | echo Bazel couldn't find gcc installation on your machine. 1>&2 20 | echo Please install MSYS gcc / MINGW gcc and set BAZEL_SH environment variable 1>&2 21 | echo. 1>&2 22 | 23 | exit /b 1 24 | -------------------------------------------------------------------------------- /configs/windows/cc/vc_installation_error_arm.bat: -------------------------------------------------------------------------------- 1 | :: Copyright 2017 The Bazel Authors. All rights reserved. 2 | :: 3 | :: Licensed under the Apache License, Version 2.0 (the "License"); 4 | :: you may not use this file except in compliance with the License. 5 | :: You may obtain a copy of the License at 6 | :: 7 | :: http://www.apache.org/licenses/LICENSE-2.0 8 | :: 9 | :: Unless required by applicable law or agreed to in writing, software 10 | :: distributed under the License is distributed on an "AS IS" BASIS, 11 | :: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | :: See the License for the specific language governing permissions and 13 | :: limitations under the License. 14 | 15 | @echo OFF 16 | 17 | echo. 1>&2 18 | echo The target you are compiling requires Visual C++ build tools. 1>&2 19 | echo Bazel couldn't find a valid Visual C++ build tools installation on your machine. 1>&2 20 | echo. 1>&2 21 | echo Visual C++ build tools seems to be installed at C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC 1>&2 22 | echo But Bazel can't find the following tools: 1>&2 23 | echo cl.exe, link.exe, lib.exe 1>&2 24 | echo for arm target architecture 1>&2 25 | echo. 1>&2 26 | echo Please check your installation following https://bazel.build/docs/windows#using 1>&2 27 | echo. 1>&2 28 | 29 | exit /b 1 30 | -------------------------------------------------------------------------------- /configs/windows/cc/vc_installation_error_arm64.bat: -------------------------------------------------------------------------------- 1 | :: Copyright 2017 The Bazel Authors. All rights reserved. 2 | :: 3 | :: Licensed under the Apache License, Version 2.0 (the "License"); 4 | :: you may not use this file except in compliance with the License. 5 | :: You may obtain a copy of the License at 6 | :: 7 | :: http://www.apache.org/licenses/LICENSE-2.0 8 | :: 9 | :: Unless required by applicable law or agreed to in writing, software 10 | :: distributed under the License is distributed on an "AS IS" BASIS, 11 | :: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | :: See the License for the specific language governing permissions and 13 | :: limitations under the License. 14 | 15 | @echo OFF 16 | 17 | echo. 1>&2 18 | echo The target you are compiling requires Visual C++ build tools. 1>&2 19 | echo Bazel couldn't find a valid Visual C++ build tools installation on your machine. 1>&2 20 | echo. 1>&2 21 | echo Visual C++ build tools seems to be installed at C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC 1>&2 22 | echo But Bazel can't find the following tools: 1>&2 23 | echo cl.exe, link.exe, lib.exe 1>&2 24 | echo for arm64 target architecture 1>&2 25 | echo. 1>&2 26 | echo Please check your installation following https://bazel.build/docs/windows#using 1>&2 27 | echo. 1>&2 28 | 29 | exit /b 1 30 | -------------------------------------------------------------------------------- /configs/windows/config/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Bazel Authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("//configs:defs.bzl", "WINDOWS_DOCKER_IMAGE") 16 | 17 | # This file is auto-generated by github.com/bazelbuild/bazel-toolchains/pkg/rbeconfigsgen 18 | # and should not be modified directly. 19 | 20 | package(default_visibility = ["//visibility:public"]) 21 | 22 | toolchain( 23 | name = "cc-toolchain", 24 | exec_compatible_with = [ 25 | "@platforms//os:windows", 26 | "@platforms//cpu:x86_64", 27 | "@bazel_tools//tools/cpp:clang-cl", 28 | ], 29 | target_compatible_with = [ 30 | "@platforms//os:windows", 31 | "@platforms//cpu:x86_64", 32 | "@bazel_tools//tools/cpp:clang-cl", 33 | ], 34 | toolchain = "//configs/windows/cc:cc-compiler-x64_windows-clang-cl", 35 | toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", 36 | ) 37 | 38 | platform( 39 | name = "platform", 40 | constraint_values = [ 41 | "@platforms//os:windows", 42 | "@platforms//cpu:x86_64", 43 | "@bazel_tools//tools/cpp:clang-cl", 44 | ], 45 | exec_properties = { 46 | "container-image": "docker://" + WINDOWS_DOCKER_IMAGE, 47 | "OSFamily": "Windows", 48 | }, 49 | parents = ["@local_config_platform//:host"], 50 | ) 51 | -------------------------------------------------------------------------------- /examples/proxyclient/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | go_library( 4 | name = "proxyclient_lib", 5 | srcs = ["main.go"], 6 | importpath = "github.com/bazelbuild/reclient/examples/proxyclient", 7 | visibility = ["//visibility:public"], 8 | deps = [ 9 | "//api/proxy", 10 | "@com_github_bazelbuild_remote_apis_sdks//go/api/command", 11 | "@org_golang_google_grpc//:grpc", 12 | ], 13 | ) 14 | 15 | go_binary( 16 | name = "proxyclient", 17 | data = glob(["testdata/**"]), 18 | embed = [":proxyclient_lib"], 19 | visibility = ["//visibility:public"], 20 | ) 21 | -------------------------------------------------------------------------------- /examples/proxyclient/testdata/test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | #include "test.h" 18 | 19 | int main(int argc, char** argv) { 20 | std::cout << "Hello World!" << std::endl; 21 | return RET; 22 | } 23 | -------------------------------------------------------------------------------- /examples/proxyclient/testdata/test.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef TEST_H_ 16 | #define TEST_H_ 17 | 18 | #define RET 0 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /examples/remoteecho/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | go_library( 4 | name = "remoteecho_lib", 5 | srcs = ["main.go"], 6 | importpath = "github.com/bazelbuild/reclient/examples/remoteecho", 7 | visibility = ["//visibility:private"], 8 | deps = [ 9 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 10 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/filemetadata", 11 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/flags", 12 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/moreflag", 13 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/outerr", 14 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/rexec", 15 | "@com_github_golang_glog//:glog", 16 | ], 17 | ) 18 | 19 | go_binary( 20 | name = "remoteecho", 21 | embed = [":remoteecho_lib"], 22 | visibility = ["//visibility:public"], 23 | ) 24 | -------------------------------------------------------------------------------- /experiments/api/experiment/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") 3 | load("@rules_proto//proto:defs.bzl", "proto_library") 4 | load("//tools:build_defs.bzl", "go_proto_checkedin_test") 5 | 6 | go_proto_checkedin_test( 7 | name = "proto_test", 8 | proto = ":experiment_go_proto", 9 | ) 10 | 11 | proto_library( 12 | name = "experiment_proto", 13 | srcs = ["experiment.proto"], 14 | visibility = ["//visibility:public"], 15 | deps = [ 16 | "//api/log:log_proto", 17 | "//api/stat:stat_proto", 18 | "//api/stats:stats_proto", 19 | ], 20 | ) 21 | 22 | go_proto_library( 23 | name = "experiment_go_proto", 24 | importpath = "github.com/bazelbuild/reclient/experiments/api/experiment", 25 | proto = ":experiment_proto", 26 | visibility = ["//visibility:public"], 27 | deps = [ 28 | "//api/log", 29 | "//api/stat", 30 | "//api/stats", 31 | ], 32 | ) 33 | 34 | go_library( 35 | name = "experiment", 36 | embed = [":experiment_go_proto"], 37 | importpath = "github.com/bazelbuild/reclient/experiments/api/experiment", 38 | visibility = ["//visibility:public"], 39 | ) 40 | -------------------------------------------------------------------------------- /experiments/cmd/exprunner/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | go_library( 4 | name = "exprunner_lib", 5 | srcs = ["main.go"], 6 | importpath = "github.com/bazelbuild/reclient/experiments/cmd/exprunner", 7 | visibility = ["//visibility:private"], 8 | deps = [ 9 | "//experiments/internal/pkg/perfgate", 10 | "//experiments/internal/pkg/runner", 11 | "//experiments/internal/pkg/tabulator", 12 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/moreflag", 13 | "@com_github_golang_glog//:glog", 14 | ], 15 | ) 16 | 17 | go_binary( 18 | name = "exprunner", 19 | embed = [":exprunner_lib"], 20 | visibility = ["//visibility:public"], 21 | ) 22 | -------------------------------------------------------------------------------- /experiments/cmd/runner/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | go_library( 4 | name = "runner_lib", 5 | srcs = ["main.go"], 6 | importpath = "github.com/bazelbuild/reclient/experiments/cmd/runner", 7 | visibility = ["//visibility:private"], 8 | deps = [ 9 | "//experiments/internal/pkg/runner", 10 | "@com_github_golang_glog//:glog", 11 | ], 12 | ) 13 | 14 | go_binary( 15 | name = "runner", 16 | embed = [":runner_lib"], 17 | visibility = ["//visibility:public"], 18 | ) 19 | -------------------------------------------------------------------------------- /experiments/cmd/tabulator/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | go_library( 4 | name = "tabulator_lib", 5 | srcs = ["main.go"], 6 | importpath = "github.com/bazelbuild/reclient/experiments/cmd/tabulator", 7 | visibility = ["//visibility:private"], 8 | deps = [ 9 | "//experiments/internal/pkg/tabulator", 10 | "@com_github_golang_glog//:glog", 11 | ], 12 | ) 13 | 14 | go_binary( 15 | name = "tabulator", 16 | embed = [":tabulator_lib"], 17 | visibility = ["//visibility:public"], 18 | ) 19 | -------------------------------------------------------------------------------- /experiments/cmd/tabulator/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package main is the main package for the experiment tabulator binary. 16 | // 17 | // This binary stores an experiment's results into a BigQuery table for 18 | // easy querying. 19 | // 20 | // Example: 21 | // bazelisk run //experiments/cmd/tabulator:tabulator -- --experiment_name=BouncyRacing-20201005-1940 22 | package main 23 | 24 | import ( 25 | "flag" 26 | 27 | "github.com/bazelbuild/reclient/experiments/internal/pkg/tabulator" 28 | 29 | log "github.com/golang/glog" 30 | ) 31 | 32 | const ( 33 | dataset = "results" 34 | table = "results" 35 | ) 36 | 37 | var ( 38 | gcpProject = flag.String("gcp_project", "foundry-x-experiments", "Name of the GCP project to store bigquery data in") 39 | resBucket = flag.String("results_bucket", "foundry-x-experiments-results", "Name of the GCS bucket containing experiment results") 40 | expName = flag.String("experiment_name", "", "Name of the experiment folder in the results bucket") 41 | ) 42 | 43 | func main() { 44 | flag.Parse() 45 | if err := tabulator.RunExperimentResultCollector(*resBucket, *expName, *gcpProject); err != nil { 46 | log.Fatalf("Error running tabulator: %v", err) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /experiments/internal/pkg/experiment/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "experiment", 5 | srcs = ["experiment.go"], 6 | data = [ 7 | "//cmd/bootstrap", 8 | "//cmd/dumpstats", 9 | "//cmd/reproxy", 10 | "//cmd/rewrapper", 11 | ], 12 | importpath = "github.com/bazelbuild/reclient/experiments/internal/pkg/experiment", 13 | visibility = ["//experiments:__subpackages__"], 14 | deps = [ 15 | "//experiments/api/experiment", 16 | "//experiments/internal/pkg/gcs", 17 | "//experiments/internal/pkg/vm", 18 | "@com_github_golang_glog//:glog", 19 | "@io_bazel_rules_go//go/tools/bazel", 20 | "@org_golang_google_protobuf//proto", 21 | "@org_golang_x_sync//errgroup", 22 | ], 23 | ) 24 | -------------------------------------------------------------------------------- /experiments/internal/pkg/gcs/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "gcs", 5 | srcs = ["gcs.go"], 6 | importpath = "github.com/bazelbuild/reclient/experiments/internal/pkg/gcs", 7 | visibility = ["//experiments:__subpackages__"], 8 | deps = ["@com_github_golang_glog//:glog"], 9 | ) 10 | -------------------------------------------------------------------------------- /experiments/internal/pkg/perfgate/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "perfgate", 5 | srcs = ["perfgate.go"], 6 | importpath = "github.com/bazelbuild/reclient/experiments/internal/pkg/perfgate", 7 | visibility = ["//experiments:__subpackages__"], 8 | deps = [ 9 | "//experiments/internal/pkg/gcs", 10 | "@com_github_golang_glog//:glog", 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /experiments/internal/pkg/runner/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "runner", 5 | srcs = ["runner.go"], 6 | importpath = "github.com/bazelbuild/reclient/experiments/internal/pkg/runner", 7 | visibility = ["//experiments:__subpackages__"], 8 | deps = [ 9 | "//experiments/api/experiment", 10 | "//experiments/internal/pkg/experiment", 11 | "//experiments/internal/pkg/gcs", 12 | "@org_golang_google_protobuf//encoding/prototext", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /experiments/internal/pkg/tabulator/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "tabulator", 5 | srcs = ["tabulator.go"], 6 | importpath = "github.com/bazelbuild/reclient/experiments/internal/pkg/tabulator", 7 | visibility = ["//experiments:__subpackages__"], 8 | deps = [ 9 | "//api/stats", 10 | "//experiments/api/experiment", 11 | "//experiments/internal/pkg/gcs", 12 | "@com_github_golang_glog//:glog", 13 | "@com_google_cloud_go_bigquery//:bigquery", 14 | "@org_golang_google_protobuf//encoding/prototext", 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /experiments/internal/pkg/vm/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "vm", 5 | srcs = ["vm.go"], 6 | importpath = "github.com/bazelbuild/reclient/experiments/internal/pkg/vm", 7 | visibility = ["//experiments:__subpackages__"], 8 | deps = [ 9 | "//experiments/api/experiment", 10 | "@com_github_golang_glog//:glog", 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /internal/pkg/auth/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "auth", 5 | srcs = ["auth.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/auth", 7 | visibility = ["//:__subpackages__"], 8 | deps = [ 9 | "@com_github_golang_glog//:glog", 10 | "@org_golang_x_oauth2//:oauth2", 11 | "@org_golang_x_oauth2//google", 12 | ], 13 | ) 14 | 15 | go_test( 16 | name = "auth_test", 17 | srcs = ["auth_test.go"], 18 | embed = [":auth"], 19 | ) 20 | -------------------------------------------------------------------------------- /internal/pkg/auth/fakes/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "fakes", 5 | srcs = ["fakeadc.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/auth/fakes", 7 | visibility = ["//:__subpackages__"], 8 | ) 9 | -------------------------------------------------------------------------------- /internal/pkg/auth/fakes/fakeadc.go: -------------------------------------------------------------------------------- 1 | package fakes 2 | 3 | import ( 4 | "encoding/json" 5 | "net/http" 6 | "net/http/httptest" 7 | "strconv" 8 | "testing" 9 | "time" 10 | ) 11 | 12 | // StartTokenValidationServer sets up a fake tokeninfo endpoint that responds with the given expiry for the given token. 13 | func StartTokenValidationServer(t *testing.T, exp time.Time, validToken string) string { 14 | t.Helper() 15 | fakeTokenServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 16 | switch r.URL.Path { 17 | case "/tokeninfo": 18 | token := r.URL.Query().Get("access_token") 19 | if token != validToken { 20 | t.Errorf("Expected query param access_token=%s, got access_token=%s", validToken, token) 21 | } 22 | resp := map[string]interface{}{ 23 | "exp": strconv.FormatInt(exp.Unix(), 10), 24 | } 25 | w.WriteHeader(http.StatusOK) 26 | json.NewEncoder(w).Encode(resp) 27 | case "/token": 28 | resp := map[string]interface{}{ 29 | "access_token": "adcToken", 30 | "expires_in": 3600, 31 | "refresh_token": "refresh", 32 | "scope": "https://www.googleapis.com/auth/pubsub", 33 | "token_type": "Bearer", 34 | } 35 | w.Header().Set("Content-Type", "application/json") 36 | w.WriteHeader(http.StatusOK) 37 | json.NewEncoder(w).Encode(resp) 38 | default: 39 | t.Errorf("Unexpected request path, got '%s'", r.URL.Path) 40 | } 41 | })) 42 | t.Cleanup(fakeTokenServer.Close) 43 | return fakeTokenServer.URL 44 | } 45 | -------------------------------------------------------------------------------- /internal/pkg/auxiliary/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "auxiliary", 5 | srcs = ["auxiliary.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/auxiliary", 7 | visibility = ["//:__subpackages__"], 8 | deps = [ 9 | "@com_github_golang_glog//:glog", 10 | "@org_golang_google_protobuf//encoding/protojson", 11 | "@org_golang_google_protobuf//proto", 12 | "@org_golang_google_protobuf//reflect/protodesc", 13 | "@org_golang_google_protobuf//reflect/protoreflect", 14 | "@org_golang_google_protobuf//reflect/protoregistry", 15 | "@org_golang_google_protobuf//types/descriptorpb", 16 | "@org_golang_google_protobuf//types/dynamicpb", 17 | ], 18 | ) 19 | 20 | go_test( 21 | name = "auxiliary_test", 22 | srcs = ["auxiliary_test.go"], 23 | data = [ 24 | "//internal/pkg/auxiliary/testdata/backend:backend_RBE_specific_api_proto", 25 | "//internal/pkg/auxiliary/testdata/client:client_RBE_specific_api_proto", 26 | ], 27 | embed = [":auxiliary"], 28 | deps = [ 29 | "@com_github_google_go_cmp//cmp", 30 | "@io_bazel_rules_go//go/tools/bazel", 31 | "@org_golang_google_protobuf//proto", 32 | "@org_golang_google_protobuf//reflect/protoreflect", 33 | "@org_golang_google_protobuf//types/dynamicpb", 34 | ], 35 | ) 36 | -------------------------------------------------------------------------------- /internal/pkg/auxiliary/testdata/backend/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") 3 | load("@rules_proto//proto:defs.bzl", "proto_library") 4 | 5 | proto_library( 6 | name = "backend_RBE_specific_api_proto", 7 | srcs = ["backend_side_auxiliary_metadata.proto"], 8 | visibility = ["//internal/pkg/auxiliary:__subpackages__"], 9 | ) 10 | 11 | go_proto_library( 12 | name = "backend_RBE_specific_api_go_proto", 13 | importpath = "github.com/bazelbuild/reclient/internal/pkg/auxiliary/testdata/backend", 14 | proto = ":backend_RBE_specific_api_proto", 15 | visibility = ["//internal/pkg/auxiliary:__subpackages__"], 16 | ) 17 | 18 | go_library( 19 | name = "backend", 20 | embed = [":backend_RBE_specific_api_go_proto"], 21 | importpath = "github.com/bazelbuild/reclient/internal/pkg/auxiliary/testdata/backend", 22 | visibility = ["//:__subpackages__"], 23 | ) 24 | -------------------------------------------------------------------------------- /internal/pkg/auxiliary/testdata/backend/backend_side_auxiliary_metadata.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package backend_RBE_specific_api; 4 | 5 | message WorkerResourceUsage { 6 | 7 | double cpu_pct_average = 1; 8 | 9 | double cpu_peak_usage = 2; 10 | 11 | double mem_pct_average = 3; 12 | 13 | double mem_peak_usage = 4; 14 | } 15 | 16 | message WorkerAuxiliaryMetadata { 17 | string platform = 1; 18 | 19 | string version = 2; 20 | 21 | WorkerResourceUsage worker_usg = 3; 22 | 23 | string region = 4; 24 | } -------------------------------------------------------------------------------- /internal/pkg/auxiliary/testdata/client/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") 3 | load("@rules_proto//proto:defs.bzl", "proto_library") 4 | 5 | proto_library( 6 | name = "client_RBE_specific_api_proto", 7 | srcs = ["client_side_auxiliary_metadata.proto"], 8 | visibility = ["//internal/pkg/auxiliary:__subpackages__"], 9 | ) 10 | 11 | go_proto_library( 12 | name = "client_RBE_specific_api_go_proto", 13 | importpath = "github.com/bazelbuild/reclient/internal/pkg/auxiliary/testdata/client", 14 | proto = ":client_RBE_specific_api_proto", 15 | visibility = ["//internal/pkg/auxiliary:__subpackages__"], 16 | ) 17 | 18 | go_library( 19 | name = "client", 20 | embed = [":client_RBE_specific_api_go_proto"], 21 | importpath = "github.com/bazelbuild/reclient/internal/pkg/auxiliary/testdata/client", 22 | visibility = ["//:__subpackages__"], 23 | ) 24 | -------------------------------------------------------------------------------- /internal/pkg/auxiliary/testdata/client/client_side_auxiliary_metadata.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package client_RBE_specific_api; 4 | 5 | message Usage { 6 | 7 | double cpu_pct = 1; 8 | 9 | double cpu_peak = 2; 10 | 11 | double mem_pct = 3; 12 | 13 | double mem_peak = 4; 14 | } 15 | 16 | message AuxiliaryMetadata { 17 | reserved 1; 18 | 19 | reserved 2; 20 | 21 | Usage usage = 3; 22 | 23 | reserved 4; 24 | } -------------------------------------------------------------------------------- /internal/pkg/bigquery/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "bigquery", 5 | srcs = ["bigquery.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/bigquery", 7 | visibility = ["//:__subpackages__"], 8 | deps = [ 9 | "//internal/pkg/bigquerytranslator", 10 | "@com_github_eapache_go_resiliency//retrier", 11 | "@com_github_golang_glog//:glog", 12 | "@com_google_cloud_go_bigquery//:bigquery", 13 | "@org_golang_google_api//googleapi", 14 | "@org_golang_google_api//option", 15 | "@org_golang_google_grpc//credentials/oauth", 16 | "@org_golang_google_protobuf//encoding/protojson", 17 | ], 18 | ) 19 | 20 | go_test( 21 | name = "bigquery_test", 22 | srcs = ["bigquery_test.go"], 23 | embed = [":bigquery"], 24 | deps = [ 25 | "@com_github_eapache_go_resiliency//retrier", 26 | "@org_golang_google_api//googleapi", 27 | ], 28 | ) 29 | -------------------------------------------------------------------------------- /internal/pkg/bigquerytranslator/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "bigquerytranslator", 5 | srcs = ["translator.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/bigquerytranslator", 7 | visibility = ["//:__subpackages__"], 8 | deps = [ 9 | "//api/log", 10 | "@com_github_bazelbuild_remote_apis_sdks//go/api/command", 11 | "@com_google_cloud_go_bigquery//:bigquery", 12 | ], 13 | ) 14 | 15 | go_test( 16 | name = "bigquerytranslator_test", 17 | srcs = ["translator_test.go"], 18 | embed = [":bigquerytranslator"], 19 | deps = [ 20 | "//api/log", 21 | "@com_github_bazelbuild_remote_apis_sdks//go/api/command", 22 | "@com_github_google_go_cmp//cmp", 23 | "@com_google_cloud_go_bigquery//:bigquery", 24 | ], 25 | ) 26 | -------------------------------------------------------------------------------- /internal/pkg/bootstrap/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "bootstrap", 5 | srcs = [ 6 | "bootstrap.go", 7 | "sigint_unix.go", 8 | "sigint_windows.go", 9 | ], 10 | importpath = "github.com/bazelbuild/reclient/internal/pkg/bootstrap", 11 | visibility = ["//:__subpackages__"], 12 | deps = [ 13 | "//api/proxy", 14 | "//api/stats", 15 | "//internal/pkg/event", 16 | "//internal/pkg/ipc", 17 | "//internal/pkg/reproxypid", 18 | "@com_github_bazelbuild_remote_apis_sdks//go/api/command", 19 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 20 | "@com_github_golang_glog//:glog", 21 | "@org_golang_google_grpc//connectivity", 22 | ] + select({ 23 | "@io_bazel_rules_go//go/platform:windows": [ 24 | "@org_golang_x_sys//windows", 25 | ], 26 | "//conditions:default": [], 27 | }), 28 | ) 29 | -------------------------------------------------------------------------------- /internal/pkg/bootstrap/sigint_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | //go:build !windows 16 | 17 | package bootstrap 18 | 19 | import ( 20 | "os" 21 | 22 | log "github.com/golang/glog" 23 | ) 24 | 25 | // Sigint sends a SIGINT signal to the process with a given pid 26 | func Sigint(pid int) error { 27 | process, err := os.FindProcess(pid) 28 | if err != nil { 29 | log.Warningf("Failed to find process %v: %v", pid, err) 30 | return err 31 | } 32 | if err := process.Signal(os.Interrupt); err != nil { 33 | log.Warningf("Failed to kill process %v: %v", pid, err) 34 | return err 35 | } 36 | return nil 37 | } 38 | 39 | // Doesn't do anything. We need this to match Windows function definitions 40 | // as sigint implementation on Windows is not always reliable 41 | func terminate(pid int) error { 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /internal/pkg/collectlogfiles/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "collectlogfiles", 5 | srcs = ["collectlogfiles.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/collectlogfiles", 7 | visibility = ["//:__subpackages__"], 8 | deps = [ 9 | "//api/stats", 10 | "//internal/pkg/logger", 11 | "//internal/pkg/pathtranslator", 12 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/client", 13 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 14 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/filemetadata", 15 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/uploadinfo", 16 | "@com_github_golang_glog//:glog", 17 | ], 18 | ) 19 | 20 | go_test( 21 | name = "collectlogfiles_test", 22 | srcs = ["collectlogfiles_test.go"], 23 | embed = [":collectlogfiles"], 24 | deps = [ 25 | "//api/stats", 26 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/client", 27 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/digest", 28 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/fakes", 29 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/filemetadata", 30 | "@com_github_google_go_cmp//cmp", 31 | "@org_golang_google_protobuf//testing/protocmp", 32 | ], 33 | ) 34 | -------------------------------------------------------------------------------- /internal/pkg/cppdependencyscanner/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "cppdependencyscanner", 5 | srcs = ["cppdepscanner.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/cppdependencyscanner", 7 | visibility = ["//:__subpackages__"], 8 | deps = [ 9 | "//api/scandeps", 10 | "//internal/pkg/cppdependencyscanner/depsscannerclient", 11 | "//internal/pkg/features", 12 | "//internal/pkg/ipc", 13 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 14 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/outerr", 15 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/retry", 16 | "@com_github_golang_glog//:glog", 17 | "@org_golang_google_grpc//codes", 18 | "@org_golang_google_grpc//status", 19 | "@org_golang_google_protobuf//types/known/emptypb", 20 | ], 21 | ) 22 | 23 | go_test( 24 | name = "cppdependencyscanner_test", 25 | srcs = ["cppdepsscanner_test.go"], 26 | embed = [":cppdependencyscanner"], 27 | deps = [ 28 | "//api/scandeps", 29 | "//internal/pkg/ipc", 30 | "@com_github_google_go_cmp//cmp", 31 | "@com_github_google_uuid//:uuid", 32 | "@org_golang_google_grpc//:grpc", 33 | "@org_golang_google_grpc//codes", 34 | "@org_golang_google_grpc//status", 35 | "@org_golang_google_protobuf//testing/protocmp", 36 | "@org_golang_google_protobuf//types/known/emptypb", 37 | ], 38 | ) 39 | -------------------------------------------------------------------------------- /internal/pkg/cppdependencyscanner/depsscannerclient/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "depsscannerclient", 5 | srcs = ["depsscannerclient.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/cppdependencyscanner/depsscannerclient", # keep 7 | visibility = ["//:__subpackages__"], 8 | deps = [ 9 | "//api/scandeps", 10 | "//internal/pkg/diagnostics", 11 | "//internal/pkg/ipc", 12 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 13 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/outerr", 14 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/retry", 15 | "@com_github_golang_glog//:glog", 16 | "@org_golang_google_grpc//codes", 17 | "@org_golang_google_grpc//status", 18 | "@org_golang_google_protobuf//types/known/emptypb", 19 | ], 20 | ) 21 | 22 | go_test( 23 | name = "depsscannerclient_test", 24 | srcs = ["depsscannerclient_test.go"], 25 | embed = [":depsscannerclient"], 26 | deps = [ 27 | "//api/scandeps", 28 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 29 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/outerr", 30 | "@com_github_google_go_cmp//cmp", 31 | "@com_github_google_uuid//:uuid", 32 | "@org_golang_google_grpc//:grpc", 33 | "@org_golang_google_protobuf//types/known/emptypb", 34 | ], 35 | ) 36 | -------------------------------------------------------------------------------- /internal/pkg/deps/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "deps", 5 | srcs = ["parser.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/deps", 7 | visibility = ["//:__subpackages__"], 8 | deps = [ 9 | "//internal/pkg/event", 10 | "//internal/pkg/logger", 11 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/digest", 12 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/filemetadata", 13 | "@com_github_golang_glog//:glog", 14 | ], 15 | ) 16 | 17 | go_test( 18 | name = "deps_test", 19 | size = "small", 20 | srcs = ["parser_test.go"], 21 | embed = [":deps"], 22 | deps = [ 23 | "//api/log", 24 | "//internal/pkg/event", 25 | "//internal/pkg/execroot", 26 | "//internal/pkg/logger", 27 | "@com_github_bazelbuild_remote_apis_sdks//go/api/command", 28 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/digest", 29 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/filemetadata", 30 | "@com_github_google_go_cmp//cmp", 31 | ], 32 | ) 33 | -------------------------------------------------------------------------------- /internal/pkg/diagnostics/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "diagnostics", 5 | srcs = [ 6 | "diagnostics.go", 7 | "simpleclientserver.go", 8 | ], 9 | importpath = "github.com/bazelbuild/reclient/internal/pkg/diagnostics", 10 | visibility = ["//:__subpackages__"], 11 | deps = ["@com_github_golang_glog//:glog"], 12 | ) 13 | 14 | go_test( 15 | name = "diagnostics_test", 16 | srcs = ["simpleclientserver_test.go"], 17 | embed = [":diagnostics"], 18 | ) 19 | -------------------------------------------------------------------------------- /internal/pkg/diagnostics/diagnostics.go: -------------------------------------------------------------------------------- 1 | // Package diagnostics is used to provide diagnostic functionality to triage 2 | // problems with reclient during failure scenarios. 3 | package diagnostics 4 | 5 | import ( 6 | "context" 7 | 8 | log "github.com/golang/glog" 9 | ) 10 | 11 | // DiagnosticInputs struct holds key state necessary for diagnostics to run. 12 | type DiagnosticInputs struct { 13 | UDSAddr string 14 | } 15 | 16 | // Run runs the diagnostics. 17 | func Run(ctx context.Context, in *DiagnosticInputs) { 18 | if err := CheckUDSAddrWorks(ctx, in.UDSAddr); err != nil { 19 | log.Errorf("DIAGNOSTIC_ERROR: UDS address check for %v had errors: %v", in.UDSAddr, err) 20 | } else { 21 | log.Infof("DIAGNOSTIC_SUCCESS: UDS address %v works with toy RPC server", in.UDSAddr) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /internal/pkg/diagnostics/simpleclientserver_test.go: -------------------------------------------------------------------------------- 1 | package diagnostics 2 | 3 | import ( 4 | "context" 5 | "os" 6 | "path/filepath" 7 | "runtime" 8 | "testing" 9 | ) 10 | 11 | func TestCheckUDSAddrWorks(t *testing.T) { 12 | var addr string 13 | if runtime.GOOS == "windows" { 14 | addr = "unix:" + filepath.Join(os.TempDir(), "test.sock") 15 | } else { 16 | addr = "unix://" + filepath.Join(os.TempDir(), "test.sock") 17 | } 18 | 19 | if err := CheckUDSAddrWorks(context.Background(), addr); err != nil { 20 | t.Errorf("CheckUDSAddrWorks(%v) failed: %v", addr, err) 21 | } 22 | } 23 | func TestCheckUDSAddrWorks_InvalidAddress(t *testing.T) { 24 | var addr string 25 | if runtime.GOOS == "windows" { 26 | addr = "unix:X:\\tmp\\test.sock" 27 | } else { 28 | addr = "unix:///rooooot/test.sock" 29 | } 30 | 31 | if err := CheckUDSAddrWorks(context.Background(), addr); err == nil { 32 | t.Errorf("CheckUDSAddrWorks(%v) expected error but succeeded", addr) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /internal/pkg/downloadmismatch/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "downloadmismatch", 5 | srcs = [ 6 | "diff.go", 7 | "download.go", 8 | ], 9 | importpath = "github.com/bazelbuild/reclient/internal/pkg/downloadmismatch", 10 | visibility = ["//:__subpackages__"], 11 | deps = [ 12 | "//api/stats", 13 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/client", 14 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/digest", 15 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/tool", 16 | "@org_golang_google_protobuf//proto", 17 | ], 18 | ) 19 | 20 | go_test( 21 | name = "downloadmismatch_test", 22 | srcs = ["download_test.go"], 23 | embed = [":downloadmismatch"], 24 | deps = [ 25 | "//api/log", 26 | "//api/stats", 27 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/digest", 28 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/fakes", 29 | "@org_golang_google_protobuf//proto", 30 | ], 31 | ) 32 | -------------------------------------------------------------------------------- /internal/pkg/event/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "event", 5 | srcs = ["event.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/event", 7 | visibility = ["//:__subpackages__"], 8 | ) 9 | -------------------------------------------------------------------------------- /internal/pkg/execroot/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "execroot", 5 | testonly = 1, 6 | srcs = ["execroot.go"], 7 | importpath = "github.com/bazelbuild/reclient/internal/pkg/execroot", 8 | visibility = ["//:__subpackages__"], 9 | ) 10 | -------------------------------------------------------------------------------- /internal/pkg/features/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "features", 5 | srcs = ["features.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/features", 7 | visibility = ["//:__subpackages__"], 8 | ) 9 | -------------------------------------------------------------------------------- /internal/pkg/ignoremismatch/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # Packages for mismatch ignoring. 2 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 3 | 4 | go_library( 5 | name = "ignoremismatch", 6 | srcs = [ 7 | "ignoremismatch.go", 8 | "ignorerule.go", 9 | "outputfilepathrule.go", 10 | ], 11 | importpath = "github.com/bazelbuild/reclient/internal/pkg/ignoremismatch", 12 | visibility = ["//:__subpackages__"], 13 | deps = [ 14 | "//api/log", 15 | "//api/proxy", 16 | "@com_github_golang_glog//:glog", 17 | "@org_golang_google_protobuf//encoding/prototext", 18 | ], 19 | ) 20 | 21 | go_test( 22 | name = "ignoremismatch_test", 23 | srcs = [ 24 | "ignoremismatch_test.go", 25 | "ignorerule_test.go", 26 | "outputfilepathrule_test.go", 27 | ], 28 | data = ["test_config.textproto"], 29 | embed = [":ignoremismatch"], 30 | deps = [ 31 | "//api/log", 32 | "//api/proxy", 33 | ], 34 | ) 35 | -------------------------------------------------------------------------------- /internal/pkg/ignoremismatch/ignorerule.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package ignoremismatch 16 | 17 | import ( 18 | "fmt" 19 | 20 | lpb "github.com/bazelbuild/reclient/api/log" 21 | ppb "github.com/bazelbuild/reclient/api/proxy" 22 | ) 23 | 24 | type ignoreRule interface { 25 | shouldIgnore(mismatch *lpb.Verification_Mismatch) (bool, error) 26 | } 27 | 28 | func createFromRuleProto(rpb *ppb.Rule) (ignoreRule, error) { 29 | switch rpb.RuleSpec.(type) { 30 | case *ppb.Rule_OutputFilePathRuleSpec: 31 | return outputFilePathRule{ 32 | spec: rpb.GetOutputFilePathRuleSpec(), 33 | }, nil 34 | } 35 | return nil, fmt.Errorf("couldn't find a rule implementation for rule spec %v", rpb.GetRuleSpec()) 36 | } 37 | -------------------------------------------------------------------------------- /internal/pkg/ignoremismatch/ignorerule_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package ignoremismatch 16 | 17 | import ( 18 | "testing" 19 | 20 | ppb "github.com/bazelbuild/reclient/api/proxy" 21 | ) 22 | 23 | func TestRuleCreationFailure(t *testing.T) { 24 | rpb := &ppb.Rule{} 25 | 26 | if _, err := createFromRuleProto(rpb); err == nil { 27 | t.Errorf("Expect error while creating mismatch rule but succeeded") 28 | } 29 | } 30 | 31 | func TestRuleCreationSuccess(t *testing.T) { 32 | rpb := &ppb.Rule{ 33 | RuleSpec: &ppb.Rule_OutputFilePathRuleSpec{ 34 | OutputFilePathRuleSpec: &ppb.OutputFilePathRuleSpec{}, 35 | }, 36 | } 37 | 38 | if _, err := createFromRuleProto(rpb); err != nil { 39 | t.Errorf("Expect successful rule creation, got: %v", err) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /internal/pkg/ignoremismatch/outputfilepathrule.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package ignoremismatch 16 | 17 | import ( 18 | "fmt" 19 | "regexp" 20 | 21 | lpb "github.com/bazelbuild/reclient/api/log" 22 | ppb "github.com/bazelbuild/reclient/api/proxy" 23 | ) 24 | 25 | type outputFilePathRule struct { 26 | spec *ppb.OutputFilePathRuleSpec 27 | } 28 | 29 | func (r outputFilePathRule) shouldIgnore(mismatch *lpb.Verification_Mismatch) (bool, error) { 30 | re, err := regexp.Compile(r.spec.GetPathPattern().Expression) 31 | if err != nil { 32 | return false, fmt.Errorf("invalid regular expression %v", r.spec.GetPathPattern().Expression) 33 | } 34 | matched := re.MatchString(mismatch.Path) 35 | return r.spec.PathPattern.Inverted != matched, nil 36 | } 37 | -------------------------------------------------------------------------------- /internal/pkg/ignoremismatch/test_config.textproto: -------------------------------------------------------------------------------- 1 | rules { 2 | output_file_path_rule_spec { 3 | path_pattern { 4 | expression: ".*" 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_test( 4 | name = "inputprocessor_test", 5 | srcs = [ 6 | "fs_case_insensitive_test.go", 7 | "fs_unix_test.go", 8 | "inputprocessor_test.go", 9 | ], 10 | embed = [":inputprocessor"], 11 | deps = [ 12 | "//internal/pkg/execroot", 13 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 14 | "@com_github_google_go_cmp//cmp", 15 | "@com_github_google_go_cmp//cmp/cmpopts", 16 | ], 17 | ) 18 | 19 | go_library( 20 | name = "inputprocessor", 21 | srcs = [ 22 | "fs_case_insensitive.go", 23 | "fs_unix.go", 24 | "inputprocessor.go", 25 | ], 26 | importpath = "github.com/bazelbuild/reclient/internal/pkg/inputprocessor", 27 | visibility = ["//:__subpackages__"], 28 | deps = [ 29 | "//internal/pkg/inputprocessor/flags", 30 | "//internal/pkg/inputprocessor/flagsparser", 31 | "//internal/pkg/inputprocessor/toolchain", 32 | "//internal/pkg/localresources", 33 | "//internal/pkg/pathtranslator", 34 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/cache", 35 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 36 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/filemetadata", 37 | "@com_github_golang_glog//:glog", 38 | ], 39 | ) 40 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/archive/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "archive", 5 | srcs = ["preprocessor.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/inputprocessor/action/archive", 7 | visibility = ["//:__subpackages__"], 8 | deps = [ 9 | "//internal/pkg/inputprocessor", 10 | "//internal/pkg/inputprocessor/flags", 11 | "//internal/pkg/rsp", 12 | ], 13 | ) 14 | 15 | go_test( 16 | name = "archive_test", 17 | srcs = ["preprocessor_test.go"], 18 | embed = [":archive"], 19 | deps = [ 20 | "//internal/pkg/execroot", 21 | "//internal/pkg/inputprocessor", 22 | "//internal/pkg/inputprocessor/flags", 23 | "@com_github_google_go_cmp//cmp", 24 | "@com_github_google_go_cmp//cmp/cmpopts", 25 | ], 26 | ) 27 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/clangcl/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "clangcl", 5 | srcs = [ 6 | "flagsparser.go", 7 | "preprocessor.go", 8 | ], 9 | importpath = "github.com/bazelbuild/reclient/internal/pkg/inputprocessor/action/clangcl", 10 | visibility = ["//:__subpackages__"], 11 | deps = [ 12 | "//internal/pkg/inputprocessor", 13 | "//internal/pkg/inputprocessor/action/cppcompile", 14 | "//internal/pkg/inputprocessor/args", 15 | "//internal/pkg/inputprocessor/clangparser", 16 | "//internal/pkg/inputprocessor/flags", 17 | "//internal/pkg/rsp", 18 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/cache", 19 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 20 | "@com_github_golang_glog//:glog", 21 | ], 22 | ) 23 | 24 | go_test( 25 | name = "clangcl_test", 26 | srcs = [ 27 | "flagsparser_test.go", 28 | "preprocessor_test.go", 29 | ], 30 | embed = [":clangcl"], 31 | deps = [ 32 | "//api/scandeps", 33 | "//internal/pkg/execroot", 34 | "//internal/pkg/inputprocessor", 35 | "//internal/pkg/inputprocessor/action/cppcompile", 36 | "//internal/pkg/inputprocessor/flags", 37 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 38 | "@com_github_google_go_cmp//cmp", 39 | "@com_github_google_go_cmp//cmp/cmpopts", 40 | ], 41 | ) 42 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/clanglink/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "clanglink", 5 | srcs = [ 6 | "ar_reader.go", 7 | "flagsparser.go", 8 | "preprocessor.go", 9 | ], 10 | importpath = "github.com/bazelbuild/reclient/internal/pkg/inputprocessor/action/clanglink", 11 | visibility = ["//:__subpackages__"], 12 | deps = [ 13 | "//internal/pkg/features", 14 | "//internal/pkg/inputprocessor", 15 | "//internal/pkg/inputprocessor/args", 16 | "//internal/pkg/inputprocessor/clangparser", 17 | "//internal/pkg/inputprocessor/flags", 18 | "//internal/pkg/rsp", 19 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/cache", 20 | "@com_github_golang_glog//:glog", 21 | ], 22 | ) 23 | 24 | go_test( 25 | name = "clanglink_test", 26 | srcs = [ 27 | "ar_reader_test.go", 28 | "flagsparser_test.go", 29 | ], 30 | data = glob(["testdata/*"]), 31 | embed = [":clanglink"], 32 | deps = [ 33 | "//internal/pkg/execroot", 34 | "//internal/pkg/inputprocessor", 35 | "//internal/pkg/inputprocessor/flags", 36 | "@com_github_google_go_cmp//cmp", 37 | "@com_github_google_go_cmp//cmp/cmpopts", 38 | "@io_bazel_rules_go//go/tools/bazel", 39 | ], 40 | ) 41 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/clanglink/preprocessor.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package clanglink performs include processing given a valid clang link action. 16 | package clanglink 17 | 18 | import ( 19 | "fmt" 20 | 21 | "github.com/bazelbuild/reclient/internal/pkg/inputprocessor" 22 | ) 23 | 24 | // Preprocessor is the preprocessor of clang cpp link actions. 25 | type Preprocessor struct { 26 | *inputprocessor.BasePreprocessor 27 | ARDeepScan bool 28 | } 29 | 30 | // ParseFlags parses the commands flags and populates the ActionSpec object with inferred 31 | // information. 32 | func (p *Preprocessor) ParseFlags() error { 33 | f, err := parseFlags(p.Ctx, p.Options.Cmd, p.Options.WorkingDir, p.Options.ExecRoot, p.ARDeepScan) 34 | if err != nil { 35 | p.Err = fmt.Errorf("flag parsing failed. %v", err) 36 | return p.Err 37 | } 38 | p.Flags = f 39 | p.FlagsToActionSpec() 40 | return nil 41 | } 42 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/clanglink/testdata/bsd.a: -------------------------------------------------------------------------------- 1 | ! 2 | #1/26 0 0 0 644 40 ` 3 | bsd_extended_file_name.txtHello, world! 4 | #1/34 0 0 0 664 38 ` 5 | another_bsd_extended_file_name.txtBye 6 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/clanglink/testdata/byte_alignment.a: -------------------------------------------------------------------------------- 1 | ! 2 | odd 0 0 0 644 4 ` 3 | odd 4 | even 0 0 0 644 4 ` 5 | evennew_file 0 0 0 644 5 ` 6 | data 7 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/clanglink/testdata/gnu.a: -------------------------------------------------------------------------------- 1 | ! 2 | // 64 ` 3 | gnu_extended_file_name.txt/ 4 | another_gnu_extended_file_name.txt/ 5 | /0 0 0 0 664 14 ` 6 | Hello, world! 7 | /28 0 0 0 664 4 ` 8 | Bye 9 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/clanglink/testdata/malformed.a: -------------------------------------------------------------------------------- 1 | foo.o 0 0 0 644 4 ` 2 | foo 3 | bar.o 0 0 0 644 4 ` 4 | bar 5 | baz.o 0 0 0 644 4 ` 6 | baz -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/clanglink/testdata/testarchive.a: -------------------------------------------------------------------------------- 1 | ! 2 | foo.o 0 0 0 644 4 ` 3 | foo 4 | bar.o 0 0 0 644 4 ` 5 | bar 6 | baz.o 0 0 0 644 4 ` 7 | baz 8 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/clanglink/testdata/thinarchive.a: -------------------------------------------------------------------------------- 1 | ! 2 | // 24 ` 3 | DirA/foo.o/ 4 | DirB/bar.o/ 5 | /0 0 0 0 664 9999 ` 6 | /12 0 0 0 664 9999 ` 7 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/clanglint/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "clanglint", 5 | srcs = ["preprocessor.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/inputprocessor/action/clanglint", 7 | visibility = ["//:__subpackages__"], 8 | deps = [ 9 | "//internal/pkg/inputprocessor/action/cppcompile", 10 | "//internal/pkg/inputprocessor/flags", 11 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/cache", 12 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 13 | "@com_github_golang_glog//:glog", 14 | ], 15 | ) 16 | 17 | go_test( 18 | name = "clanglint_test", 19 | srcs = ["preprocessor_test.go"], 20 | embed = [":clanglint"], 21 | deps = [ 22 | "//api/scandeps", 23 | "//internal/pkg/inputprocessor", 24 | "//internal/pkg/inputprocessor/action/cppcompile", 25 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 26 | "@com_github_google_go_cmp//cmp", 27 | ], 28 | ) 29 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/cppcompile/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "cppcompile", 5 | srcs = [ 6 | "flagsparser.go", 7 | "preprocessor.go", 8 | ], 9 | importpath = "github.com/bazelbuild/reclient/internal/pkg/inputprocessor/action/cppcompile", 10 | visibility = ["//visibility:public"], 11 | deps = [ 12 | "//api/scandeps", 13 | "//internal/pkg/cppdependencyscanner", 14 | "//internal/pkg/event", 15 | "//internal/pkg/inputprocessor", 16 | "//internal/pkg/inputprocessor/clangparser", 17 | "//internal/pkg/inputprocessor/depscache", 18 | "//internal/pkg/inputprocessor/flags", 19 | "//internal/pkg/logger", 20 | "//internal/pkg/pathtranslator", 21 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/cache", 22 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 23 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/digest", 24 | "@com_github_golang_glog//:glog", 25 | "@org_golang_x_sync//semaphore", 26 | ], 27 | ) 28 | 29 | go_test( 30 | name = "cppcompile_test", 31 | srcs = [ 32 | "flagsparser_test.go", 33 | "preprocessor_darwin_test.go", 34 | "preprocessor_test.go", 35 | ], 36 | embed = [":cppcompile"], 37 | deps = [ 38 | "//api/scandeps", 39 | "//internal/pkg/execroot", 40 | "//internal/pkg/inputprocessor", 41 | "//internal/pkg/inputprocessor/depscache", 42 | "//internal/pkg/inputprocessor/flags", 43 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 44 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/filemetadata", 45 | "@com_github_google_go_cmp//cmp", 46 | "@com_github_google_go_cmp//cmp/cmpopts", 47 | ], 48 | ) 49 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/d8/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "d8", 5 | srcs = [ 6 | "flagsparser.go", 7 | "preprocessor.go", 8 | ], 9 | importpath = "github.com/bazelbuild/reclient/internal/pkg/inputprocessor/action/d8", 10 | visibility = ["//:__subpackages__"], 11 | deps = [ 12 | "//internal/pkg/inputprocessor", 13 | "//internal/pkg/inputprocessor/args", 14 | "//internal/pkg/inputprocessor/flags", 15 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 16 | ], 17 | ) 18 | 19 | go_test( 20 | name = "d8_test", 21 | srcs = ["preprocessor_test.go"], 22 | embed = [":d8"], 23 | deps = [ 24 | "//internal/pkg/execroot", 25 | "//internal/pkg/inputprocessor", 26 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 27 | "@com_github_google_go_cmp//cmp", 28 | "@com_github_google_go_cmp//cmp/cmpopts", 29 | ], 30 | ) 31 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/headerabi/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "headerabi", 5 | srcs = [ 6 | "flagsparser.go", 7 | "preprocessor.go", 8 | ], 9 | importpath = "github.com/bazelbuild/reclient/internal/pkg/inputprocessor/action/headerabi", 10 | visibility = ["//visibility:public"], 11 | deps = [ 12 | "//internal/pkg/inputprocessor/action/cppcompile", 13 | "//internal/pkg/inputprocessor/args", 14 | "//internal/pkg/inputprocessor/clangparser", 15 | "//internal/pkg/inputprocessor/flags", 16 | ], 17 | ) 18 | 19 | go_test( 20 | name = "headerabi_test", 21 | srcs = [ 22 | "flagsparser_test.go", 23 | "preprocessor_test.go", 24 | ], 25 | embed = [":headerabi"], 26 | deps = [ 27 | "//api/scandeps", 28 | "//internal/pkg/execroot", 29 | "//internal/pkg/inputprocessor", 30 | "//internal/pkg/inputprocessor/action/cppcompile", 31 | "//internal/pkg/inputprocessor/flags", 32 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 33 | "@com_github_google_go_cmp//cmp", 34 | "@com_github_google_go_cmp//cmp/cmpopts", 35 | ], 36 | ) 37 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/javac/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "javac", 5 | srcs = [ 6 | "flagsparser.go", 7 | "preprocessor.go", 8 | ], 9 | importpath = "github.com/bazelbuild/reclient/internal/pkg/inputprocessor/action/javac", 10 | visibility = ["//:__subpackages__"], 11 | deps = [ 12 | "//internal/pkg/inputprocessor", 13 | "//internal/pkg/inputprocessor/args", 14 | "//internal/pkg/inputprocessor/flags", 15 | "//internal/pkg/rsp", 16 | ], 17 | ) 18 | 19 | go_test( 20 | name = "javac_test", 21 | srcs = ["preprocessor_test.go"], 22 | embed = [":javac"], 23 | deps = [ 24 | "//internal/pkg/execroot", 25 | "//internal/pkg/inputprocessor", 26 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 27 | "@com_github_google_go_cmp//cmp", 28 | "@com_github_google_go_cmp//cmp/cmpopts", 29 | ], 30 | ) 31 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/javac/preprocessor.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package javac performs include processing given a valid javac action. 16 | package javac 17 | 18 | import ( 19 | "fmt" 20 | 21 | "github.com/bazelbuild/reclient/internal/pkg/inputprocessor" 22 | ) 23 | 24 | // Preprocessor is the preprocessor of java compile actions. 25 | type Preprocessor struct { 26 | *inputprocessor.BasePreprocessor 27 | } 28 | 29 | // ParseFlags parses the commands flags and populates the ActionSpec object with inferred 30 | // information. 31 | func (p *Preprocessor) ParseFlags() error { 32 | f, err := parseFlags(p.Ctx, p.Options.Cmd, p.Options.WorkingDir, p.Options.ExecRoot) 33 | if err != nil { 34 | p.Err = fmt.Errorf("flag parsing failed. %v", err) 35 | return p.Err 36 | } 37 | p.Flags = f 38 | p.FlagsToActionSpec() 39 | return nil 40 | } 41 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/metalava/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "metalava", 5 | srcs = [ 6 | "flagsparser.go", 7 | "preprocessor.go", 8 | ], 9 | importpath = "github.com/bazelbuild/reclient/internal/pkg/inputprocessor/action/metalava", 10 | visibility = ["//:__subpackages__"], 11 | deps = [ 12 | "//internal/pkg/inputprocessor", 13 | "//internal/pkg/inputprocessor/args", 14 | "//internal/pkg/inputprocessor/flags", 15 | "//internal/pkg/rsp", 16 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/cache", 17 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 18 | ], 19 | ) 20 | 21 | go_test( 22 | name = "metalava_test", 23 | srcs = [ 24 | "flagsparser_test.go", 25 | "preprocessor_test.go", 26 | ], 27 | embed = [":metalava"], 28 | deps = [ 29 | "//internal/pkg/execroot", 30 | "//internal/pkg/inputprocessor", 31 | "//internal/pkg/inputprocessor/flags", 32 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 33 | "@com_github_google_go_cmp//cmp", 34 | "@com_github_google_go_cmp//cmp/cmpopts", 35 | ], 36 | ) 37 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/nacl/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "nacl", 5 | srcs = ["preprocessor.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/inputprocessor/action/nacl", 7 | visibility = ["//:__subpackages__"], 8 | deps = [ 9 | "//internal/pkg/inputprocessor/action/cppcompile", 10 | "//internal/pkg/inputprocessor/flags", 11 | ], 12 | ) 13 | 14 | go_test( 15 | name = "nacl_test", 16 | srcs = ["preprocessor_test.go"], 17 | embed = [":nacl"], 18 | deps = [ 19 | "//api/scandeps", 20 | "//internal/pkg/inputprocessor", 21 | "//internal/pkg/inputprocessor/action/cppcompile", 22 | ], 23 | ) 24 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/r8/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "r8", 5 | srcs = [ 6 | "flagsparser.go", 7 | "preprocessor.go", 8 | ], 9 | importpath = "github.com/bazelbuild/reclient/internal/pkg/inputprocessor/action/r8", 10 | visibility = ["//:__subpackages__"], 11 | deps = [ 12 | "//internal/pkg/inputprocessor", 13 | "//internal/pkg/inputprocessor/args", 14 | "//internal/pkg/inputprocessor/flags", 15 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/cache", 16 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 17 | ], 18 | ) 19 | 20 | go_test( 21 | name = "r8_test", 22 | srcs = ["preprocessor_test.go"], 23 | embed = [":r8"], 24 | deps = [ 25 | "//internal/pkg/execroot", 26 | "//internal/pkg/inputprocessor", 27 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 28 | "@com_github_google_go_cmp//cmp", 29 | "@com_github_google_go_cmp//cmp/cmpopts", 30 | ], 31 | ) 32 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/tool/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "tool", 5 | srcs = [ 6 | "flagsparser.go", 7 | "preprocessor.go", 8 | ], 9 | importpath = "github.com/bazelbuild/reclient/internal/pkg/inputprocessor/action/tool", 10 | visibility = ["//:__subpackages__"], 11 | deps = [ 12 | "//internal/pkg/inputprocessor", 13 | "//internal/pkg/inputprocessor/flags", 14 | ], 15 | ) 16 | 17 | go_test( 18 | name = "tool_test", 19 | srcs = ["preprocessor_test.go"], 20 | embed = [":tool"], 21 | deps = [ 22 | "//internal/pkg/execroot", 23 | "//internal/pkg/inputprocessor", 24 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 25 | "@com_github_google_go_cmp//cmp", 26 | "@com_github_google_go_cmp//cmp/cmpopts", 27 | ], 28 | ) 29 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/tool/flagsparser.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package tool 16 | 17 | import ( 18 | "context" 19 | "fmt" 20 | 21 | "github.com/bazelbuild/reclient/internal/pkg/inputprocessor/flags" 22 | ) 23 | 24 | // parseFlags is used to parse the flags in a tool invocation command. 25 | func parseFlags(ctx context.Context, command []string, workingDir, execRoot string) (*flags.CommandFlags, error) { 26 | numArgs := len(command) 27 | if numArgs < 1 { 28 | return nil, fmt.Errorf("insufficient number of arguments in command: %v", command) 29 | } 30 | 31 | res := &flags.CommandFlags{ 32 | WorkingDirectory: workingDir, 33 | ExecRoot: execRoot, 34 | ExecutablePath: command[0], 35 | } 36 | for _, arg := range command[1:] { 37 | res.Flags = append(res.Flags, &flags.Flag{Value: arg}) 38 | } 39 | return res, nil 40 | } 41 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/tool/preprocessor.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package tool 16 | 17 | import ( 18 | "fmt" 19 | 20 | "github.com/bazelbuild/reclient/internal/pkg/inputprocessor" 21 | ) 22 | 23 | // Preprocessor is the context for processing tool type actions. 24 | type Preprocessor struct { 25 | *inputprocessor.BasePreprocessor 26 | } 27 | 28 | // ParseFlags parses the commands flags and populates the ActionSpec object with inferred 29 | // information. 30 | func (p *Preprocessor) ParseFlags() error { 31 | f, err := parseFlags(p.Ctx, p.Options.Cmd, p.Options.WorkingDir, p.Options.ExecRoot) 32 | if err != nil { 33 | p.Err = fmt.Errorf("flag parsing failed. %v", err) 34 | return p.Err 35 | } 36 | p.Flags = f 37 | p.FlagsToActionSpec() 38 | return nil 39 | } 40 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/typescript/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "typescript", 5 | srcs = [ 6 | "preprocessor.go", 7 | "tsconfig_parser.go", 8 | "tsfile_parser.go", 9 | "tsinputs.go", 10 | ], 11 | importpath = "github.com/bazelbuild/reclient/internal/pkg/inputprocessor/action/typescript", 12 | visibility = ["//:__subpackages__"], 13 | deps = [ 14 | "//internal/pkg/inputprocessor", 15 | "//internal/pkg/pathtranslator", 16 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 17 | "@com_github_karrick_godirwalk//:godirwalk", 18 | ], 19 | ) 20 | 21 | go_test( 22 | name = "typescript_test", 23 | srcs = [ 24 | "preprocessor_test.go", 25 | "tsconfig_parser_test.go", 26 | "tsfile_parser_test.go", 27 | "tsinputs_test.go", 28 | ], 29 | data = glob(["testdata/**/*"]), 30 | embed = [":typescript"], 31 | deps = [ 32 | "//internal/pkg/execroot", 33 | "//internal/pkg/inputprocessor", 34 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 35 | "@com_github_google_go_cmp//cmp", 36 | "@com_github_google_go_cmp//cmp/cmpopts", 37 | "@io_bazel_rules_go//go/tools/bazel", 38 | ], 39 | ) 40 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/typescript/testdata/test_extends/tsconfig_ext.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "extends": "../test_noextends/tsconfig_no_ext.json", 4 | "compilerOptions": { 5 | "module": "esnext", 6 | "target": "esnext", 7 | "checkJs": true, 8 | "allowJs": true, 9 | "noEmitOnError": true, 10 | "strict": true, 11 | "forceConsistentCasingInFileNames": true, 12 | "noImplicitReturns": true, 13 | "noFallthroughCasesInSwitch": true, 14 | "composite": true, 15 | "declaration": true, 16 | "sourceMap": true, 17 | "inlineSources": true 18 | }, 19 | "include": [ 20 | "a/", 21 | "b/", 22 | "c/", 23 | "d/" 24 | ], 25 | "references": [ 26 | {"path": "../r1"}, 27 | {"path": "../r2/r3"} 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/typescript/testdata/test_inputs/a/b/t2.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/typescript/testdata/test_inputs/a/t1.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import * from './b/t2.ts' 18 | import * from "../c/t3.js" 19 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/typescript/testdata/test_inputs/c/t3.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/typescript/testdata/test_inputs/tsconfig_files.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | "a/b/t2.ts", 4 | "c/t3.tsx" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/typescript/testdata/test_inputs/tsconfig_include.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": [ 3 | "a/", 4 | "c/" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/typescript/testdata/test_noextends/tsconfig_no_ext.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "include": [ 4 | "a/", 5 | "b/", 6 | "c/" 7 | ], 8 | "files": [ 9 | "testfile/a.ts", 10 | "testfile/b.ts", 11 | "testfile/c.ts" 12 | ], 13 | "exclude": [ 14 | "a/a", 15 | "a/b" 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/typescript/testdata/test_singlefile/test.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import "./a" 18 | import "./b" 19 | import './c' 20 | import "./aa/bb/c" 21 | import 'b/cc/a' 22 | import {a} from 'c/cc' 23 | import * as d from '../dd/ddd' 24 | 25 | console.log("test") 26 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/typescript/testdata/test_transitive/a/t1.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | console.log("t1") 18 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/typescript/testdata/test_transitive/a/t2.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import * from "./t3.js" 18 | 19 | console.log("t2") 20 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/typescript/testdata/test_transitive/a/t3.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | console.log("t3") 18 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/typescript/testdata/test_transitive/b/bb/t1.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | console.log("test b/t1") 18 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/typescript/testdata/test_transitive/c/t1.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | console.log("test c/t1") 18 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/typescript/testdata/test_transitive/c/t2.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import * from './t3.ts' 18 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/typescript/testdata/test_transitive/c/t3.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import * from "../d/t1.js" 18 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/typescript/testdata/test_transitive/d/t1.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import * from "./t2" 18 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/typescript/testdata/test_transitive/d/t2.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import * from "./t3.js" 18 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/typescript/testdata/test_transitive/d/t3.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import * from "../e/t1.ts" 18 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/typescript/testdata/test_transitive/e/t1.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import * from "./t2.ts" 18 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/typescript/testdata/test_transitive/e/t2.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import {a} from "./t3.d.ts" 18 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/typescript/testdata/test_transitive/e/t3.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | console.log("test e/t3") 18 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/action/typescript/testdata/test_transitive/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": [ 3 | "a/", 4 | "b/" 5 | ], 6 | "files": [ 7 | "c/t1.ts", 8 | "c/t2.ts", 9 | "d/t1.tsx", 10 | "e/t1.ts" 11 | ], 12 | "references": [ 13 | {"path":"../test_inputs/tsconfig_include.json"} 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/args/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "args", 5 | srcs = ["scanner.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/inputprocessor/args", 7 | visibility = ["//:__subpackages__"], 8 | ) 9 | 10 | go_test( 11 | name = "args_test", 12 | srcs = ["scanner_test.go"], 13 | embed = [":args"], 14 | deps = ["@com_github_google_go_cmp//cmp"], 15 | ) 16 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/clangparser/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | genrule( 4 | name = "generate_clang_flags", 5 | srcs = ["//llvm:clang-options"], 6 | outs = ["clang_flags.go"], 7 | cmd = "./$(location //internal/pkg/inputprocessor/clangparser/gen_clang_flags:gen_clang_flags) --input $(location //llvm:clang-options) -o $@", 8 | tools = ["//internal/pkg/inputprocessor/clangparser/gen_clang_flags"], 9 | visibility = ["//visibility:public"], 10 | ) 11 | 12 | go_library( 13 | name = "clangparser", 14 | srcs = [ 15 | "clang_flags.go", 16 | "clangparser.go", 17 | ], 18 | importpath = "github.com/bazelbuild/reclient/internal/pkg/inputprocessor/clangparser", 19 | visibility = ["//visibility:public"], 20 | deps = [ 21 | "//internal/pkg/inputprocessor/args", 22 | "//internal/pkg/inputprocessor/flags", 23 | "//internal/pkg/rsp", 24 | ], 25 | ) 26 | 27 | go_test( 28 | name = "clangparser_test", 29 | size = "small", 30 | srcs = ["clangparser_test.go"], 31 | data = glob(["testdata/**"]), 32 | embed = [":clangparser"], 33 | deps = [ 34 | "//internal/pkg/execroot", 35 | "//internal/pkg/inputprocessor/args", 36 | "//internal/pkg/inputprocessor/flags", 37 | "@com_github_google_go_cmp//cmp", 38 | ], 39 | ) 40 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/clangparser/gen_clang_flags/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | go_library( 4 | name = "gen_clang_flags_lib", 5 | srcs = ["main.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/inputprocessor/clangparser/gen_clang_flags", 7 | visibility = ["//visibility:private"], 8 | ) 9 | 10 | go_binary( 11 | name = "gen_clang_flags", 12 | embed = [":gen_clang_flags_lib"], 13 | visibility = ["//:__subpackages__"], 14 | ) 15 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/depscache/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "depscache", 5 | srcs = [ 6 | "depscache.go", 7 | "minimalfilecache.go", 8 | ], 9 | importpath = "github.com/bazelbuild/reclient/internal/pkg/inputprocessor/depscache", 10 | visibility = ["//:__subpackages__"], 11 | deps = [ 12 | "//api/proxy", 13 | "//internal/pkg/event", 14 | "//internal/pkg/features", 15 | "//internal/pkg/logger", 16 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/cache", 17 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/digest", 18 | "@com_github_golang_glog//:glog", 19 | "@org_golang_google_protobuf//proto", 20 | "@org_golang_google_protobuf//types/known/timestamppb", 21 | "@org_golang_x_sync//singleflight", 22 | ], 23 | ) 24 | 25 | go_test( 26 | name = "depscache_test", 27 | srcs = ["depscache_test.go"], 28 | embed = [":depscache"], 29 | deps = [ 30 | "//internal/pkg/execroot", 31 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/filemetadata", 32 | "@com_github_google_go_cmp//cmp", 33 | "@com_github_google_go_cmp//cmp/cmpopts", 34 | ], 35 | ) 36 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/flags/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "flags", 5 | srcs = ["flags.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/inputprocessor/flags", 7 | visibility = ["//visibility:public"], 8 | ) 9 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/flagsparser/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "flagsparser", 5 | srcs = ["flagsparser.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/inputprocessor/flagsparser", 7 | visibility = ["//visibility:public"], 8 | deps = [ 9 | "//internal/pkg/inputprocessor/args", 10 | "//internal/pkg/inputprocessor/flags", 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/fs_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | //go:build !windows && !darwin 16 | 17 | package inputprocessor 18 | 19 | import ( 20 | "os" 21 | "path/filepath" 22 | "strings" 23 | ) 24 | 25 | type pathNormalizer struct{} 26 | 27 | // cross is need for fs_case_insensitive.go, but not used here. 28 | func newPathNormalizer(cross bool) pathNormalizer { 29 | return pathNormalizer{} 30 | } 31 | 32 | func (pathNormalizer) normalize(execRoot, pathname string) (string, error) { 33 | f := strings.TrimLeft(filepath.Clean(pathname), string(filepath.Separator)) 34 | _, err := os.Stat(filepath.Join(execRoot, f)) 35 | return f, err 36 | } 37 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/toolchain/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "toolchain", 5 | srcs = [ 6 | "inputfiles.go", 7 | "toolchain.go", 8 | ], 9 | importpath = "github.com/bazelbuild/reclient/internal/pkg/inputprocessor/toolchain", 10 | visibility = ["//:__subpackages__"], 11 | deps = [ 12 | "//internal/pkg/pathtranslator", 13 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/cache", 14 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 15 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/filemetadata", 16 | "@com_github_golang_glog//:glog", 17 | ], 18 | ) 19 | 20 | go_test( 21 | name = "toolchain_test", 22 | size = "small", 23 | srcs = ["toolchain_test.go"], 24 | data = glob([ 25 | "testdata/*", 26 | "testdata2/*", 27 | ]), 28 | embed = [":toolchain"], 29 | deps = [ 30 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 31 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/filemetadata", 32 | "@com_github_google_go_cmp//cmp", 33 | "@io_bazel_rules_go//go/tools/bazel", 34 | ], 35 | ) 36 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/toolchain/testdata/a.txt: -------------------------------------------------------------------------------- 1 | foobar -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/toolchain/testdata/b.txt: -------------------------------------------------------------------------------- 1 | barfoo -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/toolchain/testdata/executable: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | exit 0 -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/toolchain/testdata/executable2: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | exit 0 -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/toolchain/testdata/executable3: -------------------------------------------------------------------------------- 1 | fake non-executable 2 | -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/toolchain/testdata/remote_toolchain_inputs: -------------------------------------------------------------------------------- 1 | # This line should be ignored. 2 | // This line should be ignored. 3 | # Spaces should be trimmed from the beggining of the line. 4 | # Tabs should be trimmed from the beginning of the line. 5 | a.txt 6 | b.txt 7 | c.txt -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/toolchain/testdata2/a.txt: -------------------------------------------------------------------------------- 1 | foobar -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/toolchain/testdata2/b.txt: -------------------------------------------------------------------------------- 1 | barfoo -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/toolchain/testdata2/executable: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | exit 0 -------------------------------------------------------------------------------- /internal/pkg/inputprocessor/toolchain/testdata2/executable_remote_toolchain_inputs: -------------------------------------------------------------------------------- 1 | # This line should be ignored. 2 | // This line should be ignored. 3 | # Spaces should be trimmed from the beggining of the line. 4 | # Tabs should be trimmed from the beginning of the line. 5 | a.txt 6 | b.txt 7 | -------------------------------------------------------------------------------- /internal/pkg/interceptors/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "interceptors", 5 | srcs = [ 6 | "interceptors.go", 7 | "truncate.go", 8 | ], 9 | importpath = "github.com/bazelbuild/reclient/internal/pkg/interceptors", 10 | visibility = ["//:__subpackages__"], 11 | deps = [ 12 | "//api/proxy", 13 | "//internal/pkg/protoencoding", 14 | "@com_github_golang_glog//:glog", 15 | "@org_golang_google_grpc//:grpc", 16 | "@org_golang_google_protobuf//proto", 17 | ], 18 | ) 19 | 20 | go_test( 21 | name = "interceptors_test", 22 | size = "small", 23 | srcs = ["truncate_test.go"], 24 | embed = [":interceptors"], 25 | deps = [ 26 | "//api/proxy", 27 | "@com_github_bazelbuild_remote_apis_sdks//go/api/command", 28 | "@org_golang_google_grpc//:grpc", 29 | "@org_golang_google_protobuf//proto", 30 | ], 31 | ) 32 | -------------------------------------------------------------------------------- /internal/pkg/ipc/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package ipc provides IPC functionality between rewrapper(client) and reproxy(server). 16 | package ipc 17 | 18 | const ( 19 | // GrpcMaxMsgSize is the max value of gRPC response that can be received by the client (in bytes) 20 | GrpcMaxMsgSize = 1024 * 1024 * 32 // 32MB (default is 4MB) 21 | 22 | // GrpcMaxListenSize is the max value of the gRPC response that can be listened for by the proxy. 23 | // This is message size received from rewrapper. 24 | // Limiting this to a smaller value than reception from RBE due to performance issues on intel macs 25 | // when this is set to 32MB. 26 | GrpcMaxListenSize = 1024 * 1024 * 8 27 | ) 28 | -------------------------------------------------------------------------------- /internal/pkg/ipc/features_posix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | //go:build !windows 16 | 17 | package ipc 18 | 19 | const ( 20 | // GrpcCxxSupportsUDS is true because the grpc cpp library supports uds on mac and linux. 21 | GrpcCxxSupportsUDS = true 22 | ) 23 | -------------------------------------------------------------------------------- /internal/pkg/ipc/features_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | //go:build windows 16 | 17 | package ipc 18 | 19 | import ( 20 | "sync" 21 | "syscall" 22 | "unsafe" 23 | ) 24 | 25 | // This function is copied over from an internal package in Go 26 | // https://github.com/golang/go/blob/aa97a012b4be393c1725c16a78b92dea81632378/src/internal/syscall/windows/version_windows.go#L95 27 | var supportUnixSocket = sync.OnceValue(func() bool { 28 | var size uint32 29 | // First call to get the required buffer size in bytes. 30 | // Ignore the error, it will always fail. 31 | _, _ = syscall.WSAEnumProtocols(nil, nil, &size) 32 | n := int32(size) / int32(unsafe.Sizeof(syscall.WSAProtocolInfo{})) 33 | // Second call to get the actual protocols. 34 | buf := make([]syscall.WSAProtocolInfo, n) 35 | n, err := syscall.WSAEnumProtocols(nil, &buf[0], &size) 36 | if err != nil { 37 | return false 38 | } 39 | for i := int32(0); i < n; i++ { 40 | if buf[i].AddressFamily == syscall.AF_UNIX { 41 | return true 42 | } 43 | } 44 | return false 45 | }) 46 | 47 | var ( 48 | GrpcCxxSupportsUDS = supportUnixSocket() 49 | ) 50 | -------------------------------------------------------------------------------- /internal/pkg/ipc/listen_posix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | //go:build !windows 16 | 17 | package ipc 18 | 19 | import ( 20 | "fmt" 21 | "net" 22 | "os" 23 | "strings" 24 | ) 25 | 26 | // Listen announces on the serverAddr to accept grpc connection. 27 | func Listen(serverAddr string) (net.Listener, error) { 28 | network := "tcp" 29 | address := serverAddr 30 | if strings.HasPrefix(address, "unix://") { 31 | network = "unix" 32 | address = strings.TrimPrefix(address, "unix://") 33 | if _, err := os.Stat(address); err == nil { 34 | if err := os.RemoveAll(address); err != nil { 35 | return nil, fmt.Errorf("failed to remove socket file %q: %v", address, err) 36 | } 37 | } 38 | } 39 | return net.Listen(network, address) 40 | } 41 | -------------------------------------------------------------------------------- /internal/pkg/ipc/listen_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | //go:build windows 16 | 17 | package ipc 18 | 19 | import ( 20 | "net" 21 | "strings" 22 | 23 | winio "github.com/Microsoft/go-winio" 24 | ) 25 | 26 | // Listen announces on the serverAddr to accept grpc connection. 27 | // If serverAddr is `pipe://`, it listens on named pipe `\\.\pipe\`. 28 | func Listen(serverAddr string) (net.Listener, error) { 29 | network := "tcp" 30 | address := serverAddr 31 | if strings.HasPrefix(address, "pipe://") { 32 | network = "pipe" 33 | address = `\\.\pipe\` + strings.TrimPrefix(address, "pipe://") 34 | return winio.ListenPipe(address, &winio.PipeConfig{ 35 | InputBufferSize: 64 * 1024, 36 | OutputBufferSize: 128 * 1024, 37 | }) 38 | 39 | } 40 | return net.Listen(network, address) 41 | } 42 | -------------------------------------------------------------------------------- /internal/pkg/labels/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "labels", 5 | srcs = ["labels.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/labels", 7 | visibility = ["//:__subpackages__"], 8 | deps = [ 9 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/cache", 10 | "@com_github_golang_glog//:glog", 11 | ], 12 | ) 13 | 14 | go_test( 15 | name = "labels_test", 16 | srcs = ["labels_test.go"], 17 | embed = [":labels"], 18 | deps = ["@com_github_google_go_cmp//cmp"], 19 | ) 20 | -------------------------------------------------------------------------------- /internal/pkg/localresources/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # gazelle:ignore 2 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 3 | 4 | go_library( 5 | name = "localresources", 6 | srcs = [ 7 | "manager.go", 8 | "manager_darwin.go", 9 | "manager_linux.go", 10 | "manager_windows.go", 11 | ], 12 | importpath = "github.com/bazelbuild/reclient/internal/pkg/localresources", 13 | visibility = ["//:__subpackages__"], 14 | deps = [ 15 | "@org_golang_x_sync//semaphore:go_default_library", 16 | ] + select({ 17 | "@io_bazel_rules_go//go/platform:android": [ 18 | "@com_github_golang_glog//:go_default_library", 19 | ], 20 | "@io_bazel_rules_go//go/platform:darwin": [ 21 | "@com_github_golang_glog//:go_default_library", 22 | ], 23 | "@io_bazel_rules_go//go/platform:ios": [ 24 | "@com_github_golang_glog//:go_default_library", 25 | ], 26 | "@io_bazel_rules_go//go/platform:linux": [ 27 | "@com_github_golang_glog//:go_default_library", 28 | ], 29 | "@io_bazel_rules_go//go/platform:windows": [ 30 | "@com_github_golang_glog//:go_default_library", 31 | ], 32 | "//conditions:default": [], 33 | }), 34 | ) 35 | 36 | go_test( 37 | name = "localresources_test", 38 | srcs = ["manager_test.go"], 39 | embed = [":localresources"], 40 | ) 41 | -------------------------------------------------------------------------------- /internal/pkg/localresources/manager_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package localresources 16 | 17 | import ( 18 | "encoding/binary" 19 | "syscall" 20 | 21 | log "github.com/golang/glog" 22 | ) 23 | 24 | // TotalRAMMBs returns the amount of system memory in MegaBytes. 25 | func TotalRAMMBs() int64 { 26 | memSizeStr, err := syscall.Sysctl("hw.memsize") 27 | if err != nil { 28 | log.Errorf("Failed to get system memory size: %v", err) 29 | return 0 30 | } 31 | memSizeBytes := append([]byte(memSizeStr), make([]byte, 8-len(memSizeStr))...) 32 | memSize := binary.LittleEndian.Uint64(memSizeBytes) 33 | return int64(memSize) / 1024 / 1024 34 | } 35 | -------------------------------------------------------------------------------- /internal/pkg/localresources/manager_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package localresources 16 | 17 | import ( 18 | "syscall" 19 | 20 | log "github.com/golang/glog" 21 | ) 22 | 23 | // TotalRAMMBs returns the amount of system memory in MegaBytes. 24 | func TotalRAMMBs() int64 { 25 | var info syscall.Sysinfo_t 26 | err := syscall.Sysinfo(&info) 27 | if err != nil { 28 | log.Errorf("Failed to get system memory size: %v", err) 29 | return 0 30 | } 31 | return int64(uint64(info.Totalram) * uint64(info.Unit) / 1024 / 1024) 32 | } 33 | -------------------------------------------------------------------------------- /internal/pkg/localresources/manager_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package localresources 16 | 17 | import ( 18 | "syscall" 19 | "unsafe" 20 | 21 | log "github.com/golang/glog" 22 | ) 23 | 24 | // TotalRAMMBs returns the amount of system memory in MegaBytes. 25 | func TotalRAMMBs() int64 { 26 | k := syscall.NewLazyDLL("kernel32.dll") 27 | p := k.NewProc("GetPhysicallyInstalledSystemMemory") 28 | var memKB int64 29 | 30 | // https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getphysicallyinstalledsystemmemory 31 | ret, _, err := p.Call(uintptr(unsafe.Pointer(&memKB))) 32 | // Call always returns non-nil error 33 | // https://golang.org/src/syscall/dll_windows.go 34 | if ret == 0 { 35 | log.Errorf("Failed to get system memory size: %v", err) 36 | return 0 37 | } 38 | return memKB / 1024 39 | } 40 | -------------------------------------------------------------------------------- /internal/pkg/localresources/usage/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "usage", 5 | srcs = ["usage.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/localresources/usage", 7 | visibility = ["//:__subpackages__"], 8 | deps = [ 9 | "@com_github_golang_glog//:glog", 10 | "@com_github_shirou_gopsutil_v3//process", 11 | ], 12 | ) 13 | 14 | go_test( 15 | name = "usage_test", 16 | srcs = ["usage_test.go"], 17 | embed = [":usage"], 18 | deps = [ 19 | "@com_github_google_go_cmp//cmp", 20 | "@com_github_google_go_cmp//cmp/cmpopts", 21 | "@com_github_shirou_gopsutil_v3//process", 22 | ], 23 | ) 24 | -------------------------------------------------------------------------------- /internal/pkg/logger/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "logger", 5 | srcs = ["logger.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/logger", 7 | visibility = ["//:__subpackages__"], 8 | deps = [ 9 | "//api/log", 10 | "//api/proxy", 11 | "//api/stat", 12 | "//api/stats", 13 | "//internal/pkg/auxiliary", 14 | "//internal/pkg/bigquery", 15 | "//internal/pkg/bigquerytranslator", 16 | "//internal/pkg/ignoremismatch", 17 | "//internal/pkg/localresources/usage", 18 | "//internal/pkg/monitoring", 19 | "//internal/pkg/protoencoding", 20 | "//internal/pkg/stats", 21 | "@com_github_bazelbuild_remote_apis_sdks//go/api/command", 22 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 23 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/digest", 24 | "@com_github_golang_glog//:glog", 25 | "@org_golang_google_protobuf//encoding/prototext", 26 | "@org_golang_google_protobuf//proto", 27 | ], 28 | ) 29 | 30 | go_test( 31 | name = "logger_test", 32 | size = "small", 33 | srcs = ["logger_test.go"], 34 | embed = [":logger"], 35 | deps = [ 36 | "//api/log", 37 | "//api/proxy", 38 | "//api/stats", 39 | "//internal/pkg/event", 40 | "@com_github_bazelbuild_remote_apis_sdks//go/api/command", 41 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 42 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/digest", 43 | "@com_github_google_go_cmp//cmp", 44 | "@org_golang_google_protobuf//testing/protocmp", 45 | ], 46 | ) 47 | -------------------------------------------------------------------------------- /internal/pkg/loghttp/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "loghttp", 5 | srcs = ["loghttp.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/loghttp", 7 | visibility = ["//:__subpackages__"], 8 | deps = [ 9 | "@com_github_golang_glog//:glog", 10 | "@com_github_google_uuid//:uuid", 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /internal/pkg/loghttp/loghttp.go: -------------------------------------------------------------------------------- 1 | package loghttp 2 | 3 | import ( 4 | "net/http" 5 | "net/http/httputil" 6 | 7 | log "github.com/golang/glog" 8 | "github.com/google/uuid" 9 | ) 10 | 11 | // Register wraps http.DefaultTransport with logging of the requests and responses. 12 | func Register() { 13 | http.DefaultTransport = &glogTransport{base: http.DefaultTransport} 14 | } 15 | 16 | type glogTransport struct { 17 | base http.RoundTripper 18 | } 19 | 20 | func (g *glogTransport) RoundTrip(req *http.Request) (*http.Response, error) { 21 | reqid := uuid.New().String() 22 | if reqStr, err := httputil.DumpRequest(req, true); err == nil { 23 | log.Infof("%v: HTTP Request: %v", reqid, string(reqStr)) 24 | } else { 25 | log.Infof("%v: HTTP Request: %v", reqid, req) 26 | } 27 | resp, err := g.base.RoundTrip(req) 28 | if err != nil { 29 | log.Infof("%v: HTTP Error: %v", reqid, err) 30 | return nil, err 31 | } 32 | if respStr, err := httputil.DumpResponse(resp, true); err == nil { 33 | log.Infof("%v: HTTP Response: %v", reqid, string(respStr)) 34 | } else { 35 | log.Infof("%v: HTTP Response: %v", reqid, resp) 36 | } 37 | return resp, nil 38 | } 39 | -------------------------------------------------------------------------------- /internal/pkg/monitoring/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "monitoring", 5 | srcs = ["monitoring.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/monitoring", 7 | visibility = ["//:__subpackages__"], 8 | deps = [ 9 | "//api/log", 10 | "//api/stats", 11 | "//internal/pkg/event", 12 | "//internal/pkg/labels", 13 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 14 | "@com_github_golang_glog//:glog", 15 | "@com_github_google_uuid//:uuid", 16 | "@io_opencensus_go//stats", 17 | "@io_opencensus_go//stats/view", 18 | "@io_opencensus_go//tag", 19 | "@io_opencensus_go_contrib_exporter_stackdriver//:stackdriver", 20 | "@org_golang_google_api//option", 21 | "@org_golang_google_grpc//codes", 22 | "@org_golang_google_grpc//credentials/oauth", 23 | "@org_golang_google_grpc//status", 24 | ], 25 | ) 26 | 27 | go_test( 28 | name = "monitoring_test", 29 | srcs = ["monitoring_test.go"], 30 | embed = [":monitoring"], 31 | deps = [ 32 | "//api/log", 33 | "//internal/pkg/event", 34 | "//internal/pkg/stats", 35 | "@com_github_bazelbuild_remote_apis_sdks//go/api/command", 36 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 37 | "@com_github_google_go_cmp//cmp", 38 | "@com_github_google_go_cmp//cmp/cmpopts", 39 | "@io_opencensus_go//stats", 40 | "@io_opencensus_go//tag", 41 | "@io_opencensus_go_contrib_exporter_stackdriver//:stackdriver", 42 | ], 43 | ) 44 | -------------------------------------------------------------------------------- /internal/pkg/pathtranslator/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "pathtranslator", 5 | srcs = ["pathtranslator.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/pathtranslator", 7 | visibility = ["//:__subpackages__"], 8 | ) 9 | 10 | go_test( 11 | name = "pathtranslator_test", 12 | srcs = ["pathtranslator_test.go"], 13 | embed = [":pathtranslator"], 14 | deps = ["@com_github_google_go_cmp//cmp"], 15 | ) 16 | -------------------------------------------------------------------------------- /internal/pkg/printer/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "printer", 5 | srcs = ["printer.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/printer", 7 | visibility = ["//:__subpackages__"], 8 | deps = [ 9 | "@com_github_fatih_color//:color", 10 | "@com_github_golang_glog//:glog", 11 | "@com_github_vardius_progress_go//:progress-go", 12 | ], 13 | ) 14 | -------------------------------------------------------------------------------- /internal/pkg/protoencoding/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 16 | 17 | go_library( 18 | name = "protoencoding", 19 | srcs = ["protoencoding.go"], 20 | importpath = "github.com/bazelbuild/reclient/internal/pkg/protoencoding", 21 | visibility = ["//:__subpackages__"], 22 | deps = ["@org_golang_google_protobuf//encoding/prototext"], 23 | ) 24 | -------------------------------------------------------------------------------- /internal/pkg/protoencoding/protoencoding.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package protoencoding 16 | 17 | import "google.golang.org/protobuf/encoding/prototext" 18 | 19 | var ( 20 | // TextWithIndent formats protos into multiline textprotos indented with tabs. 21 | TextWithIndent = prototext.MarshalOptions{ 22 | Multiline: true, 23 | Indent: "\t", 24 | } 25 | ) 26 | -------------------------------------------------------------------------------- /internal/pkg/rbeflag/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "rbeflag", 5 | srcs = ["rbeflag.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/rbeflag", 7 | visibility = ["//:__subpackages__"], 8 | deps = ["@com_github_golang_glog//:glog"], 9 | ) 10 | 11 | go_test( 12 | name = "rbeflag_test", 13 | srcs = ["rbeflag_test.go"], 14 | embed = [":rbeflag"], 15 | ) 16 | -------------------------------------------------------------------------------- /internal/pkg/reproxy/stash.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package reproxy 16 | 17 | import ( 18 | "io" 19 | "os" 20 | "path/filepath" 21 | 22 | "github.com/google/uuid" 23 | ) 24 | 25 | // StashFiles copies the given files to a temporary location. It returns a function that 26 | // restores the original files. 27 | func StashFiles(paths []string) func() { 28 | parentDir := os.TempDir() 29 | newFiles := make(map[string]string) 30 | for _, srcPath := range paths { 31 | source, err := os.Open(srcPath) 32 | if err != nil { 33 | continue 34 | } 35 | defer source.Close() 36 | destPath := filepath.Join(parentDir, uuid.New().String()) 37 | destination, err := os.Create(destPath) 38 | if err != nil { 39 | continue 40 | } 41 | defer destination.Close() 42 | _, err = io.Copy(destination, source) 43 | if err != nil { 44 | continue 45 | } 46 | err = destination.Sync() 47 | if err != nil { 48 | continue 49 | } 50 | si, err := os.Stat(srcPath) 51 | if err != nil { 52 | continue 53 | } 54 | err = os.Chmod(destPath, si.Mode()) 55 | if err != nil { 56 | continue 57 | } 58 | newFiles[destPath] = srcPath 59 | } 60 | return func() { 61 | for dup, orig := range newFiles { 62 | os.Rename(dup, orig) 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /internal/pkg/reproxy/timeout.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package reproxy 16 | 17 | import ( 18 | "context" 19 | "os" 20 | "time" 21 | 22 | "github.com/bazelbuild/reclient/internal/pkg/interceptors" 23 | 24 | log "github.com/golang/glog" 25 | ) 26 | 27 | // IdleTimeout checks the latest request received timestamp and sends a SIGINT signal 28 | // if last request received is greater than the expected idle timeout. 29 | func IdleTimeout(ctx context.Context, timeout time.Duration) { 30 | if timeout == 0 { 31 | log.Infof("No reproxy idle timeout set.") 32 | return 33 | } 34 | 35 | log.Infof("Idle timeout set to %v", timeout) 36 | for { 37 | select { 38 | case <-ctx.Done(): 39 | return 40 | case <-time.After(time.Until(interceptors.LatestRequestTimestamp().Add(timeout))): 41 | if time.Since(interceptors.LatestRequestTimestamp()) >= timeout { 42 | log.Infof("idle timeout reached, exiting...") 43 | pid := os.Getpid() 44 | p, err := os.FindProcess(pid) 45 | if err != nil { 46 | log.Warningf("unable to find process with pid %v, graceful exit failed: %v", pid, err) 47 | os.Exit(0) 48 | } 49 | if err := p.Signal(os.Interrupt); err != nil { 50 | log.Warningf("unable to send SIGINT to process %+v, graceful exit failed: %v", p, err) 51 | os.Exit(0) 52 | } 53 | } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /internal/pkg/reproxypid/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "reproxypid", 5 | srcs = ["reproxypid.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/reproxypid", 7 | visibility = ["//:__subpackages__"], 8 | deps = [ 9 | "//internal/pkg/subprocess", 10 | "@com_github_golang_glog//:glog", 11 | ], 12 | ) 13 | 14 | go_test( 15 | name = "reproxypid_test", 16 | srcs = ["reproxypid_test.go"], 17 | embed = [":reproxypid"], 18 | ) 19 | -------------------------------------------------------------------------------- /internal/pkg/reproxystatus/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "reproxystatus", 5 | srcs = ["reproxystatus.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/reproxystatus", 7 | visibility = ["//:__subpackages__"], 8 | deps = [ 9 | "//api/log", 10 | "//api/proxy", 11 | "//internal/pkg/ipc", 12 | "@com_github_fatih_color//:color", 13 | ], 14 | ) 15 | 16 | go_test( 17 | name = "reproxystatus_test", 18 | srcs = ["reproxystatus_test.go"], 19 | embed = [":reproxystatus"], 20 | deps = [ 21 | "//api/log", 22 | "//api/proxy", 23 | "//internal/pkg/ipc", 24 | "@com_github_google_go_cmp//cmp", 25 | "@com_github_google_uuid//:uuid", 26 | "@org_golang_google_grpc//:grpc", 27 | ], 28 | ) 29 | -------------------------------------------------------------------------------- /internal/pkg/rewrapper/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "rewrapper", 5 | srcs = ["rewrapper.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/rewrapper", 7 | visibility = ["//:__subpackages__"], 8 | deps = [ 9 | "//api/proxy", 10 | "//internal/pkg/rsp", 11 | "@com_github_bazelbuild_remote_apis_sdks//go/api/command", 12 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 13 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/retry", 14 | "@org_golang_google_grpc//:grpc", 15 | "@org_golang_google_grpc//codes", 16 | "@org_golang_google_grpc//status", 17 | "@org_golang_google_protobuf//types/known/timestamppb", 18 | ], 19 | ) 20 | 21 | go_test( 22 | name = "rewrapper_test", 23 | size = "small", 24 | srcs = ["rewrapper_test.go"], 25 | embed = [":rewrapper"], 26 | deps = [ 27 | "//api/proxy", 28 | "@com_github_bazelbuild_remote_apis_sdks//go/api/command", 29 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 30 | "@com_github_google_go_cmp//cmp", 31 | "@org_golang_google_grpc//:grpc", 32 | "@org_golang_google_grpc//codes", 33 | "@org_golang_google_grpc//status", 34 | "@org_golang_google_protobuf//testing/protocmp", 35 | "@org_golang_google_protobuf//types/known/timestamppb", 36 | ], 37 | ) 38 | -------------------------------------------------------------------------------- /internal/pkg/rsp/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "rsp", 5 | srcs = ["rsp.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/rsp", 7 | visibility = ["//:__subpackages__"], 8 | deps = [ 9 | "//internal/pkg/inputprocessor/args", 10 | ], 11 | ) 12 | 13 | go_test( 14 | name = "rsp_test", 15 | srcs = ["rsp_test.go"], 16 | embed = [":rsp"], 17 | deps = [ 18 | "//internal/pkg/inputprocessor/args", 19 | "@com_github_google_go_cmp//cmp", 20 | ], 21 | ) 22 | -------------------------------------------------------------------------------- /internal/pkg/scandeps/csdutils/BUILD.bazel: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "adjust_cmd", 3 | srcs = [ 4 | "adjust_cmd.cc", 5 | "adjust_cmd.h", 6 | ], 7 | hdrs = [ 8 | "adjust_cmd.h", 9 | ], 10 | visibility = ["//internal/pkg:__subpackages__"], 11 | ) 12 | 13 | cc_test( 14 | name = "adjust_cmd_test", 15 | size = "small", 16 | srcs = ["adjust_cmd_test.cc"], 17 | deps = [ 18 | ":adjust_cmd", 19 | "@com_google_googletest//:gtest_main", 20 | ], 21 | ) 22 | 23 | cc_library( 24 | name = "parse_deps", 25 | srcs = [ 26 | "parse_deps.cc", 27 | "parse_deps.h", 28 | ], 29 | hdrs = [ 30 | "parse_deps.h", 31 | ], 32 | visibility = ["//internal/pkg:__subpackages__"], 33 | ) 34 | 35 | cc_test( 36 | name = "parse_deps_test", 37 | size = "small", 38 | srcs = ["parse_deps_test.cc"], 39 | deps = [ 40 | ":parse_deps", 41 | "@com_google_googletest//:gtest_main", 42 | ], 43 | ) 44 | 45 | cc_library( 46 | name = "parse_env", 47 | srcs = [ 48 | "parse_env.cc", 49 | "parse_env.h", 50 | ], 51 | hdrs = [ 52 | "parse_env.h", 53 | ], 54 | visibility = ["//internal/pkg:__subpackages__"], 55 | ) 56 | 57 | cc_test( 58 | name = "parse_env_test", 59 | size = "small", 60 | srcs = ["parse_env_test.cc"], 61 | deps = [ 62 | ":parse_env", 63 | "@com_google_googletest//:gtest_main", 64 | ], 65 | ) 66 | -------------------------------------------------------------------------------- /internal/pkg/scandeps/csdutils/adjust_cmd.h: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef INTERNAL_PKG_SCANDEPS_CSDUTILS_ADJUST_CMD_H_ 16 | #define INTERNAL_PKG_SCANDEPS_CSDUTILS_ADJUST_CMD_H_ 17 | #include 18 | #include 19 | #include 20 | 21 | namespace csdutils { 22 | // Adjusts the given command to be compatible with clangscandeps. 23 | void AdjustCmd(std::vector& cmd, std::string filename, 24 | const std::set& ignoredPlugins); 25 | } // namespace csdutils 26 | 27 | #endif // INTERNAL_PKG_SCANDEPS_CSDUTILS_ADJUST_CMD_H_ -------------------------------------------------------------------------------- /internal/pkg/scandeps/csdutils/parse_deps.cc: -------------------------------------------------------------------------------- 1 | 2 | #include "parse_deps.h" 3 | 4 | #include 5 | 6 | // deps format 7 | // : ... 8 | // is space sparated 9 | // '\'+newline is space 10 | // '\'+space is an escaped space (not separater) 11 | std::set csdutils::ParseDeps(std::string_view depsStr) { 12 | std::set dependencies; 13 | 14 | // Skip until ':' 15 | size_t start = depsStr.find_first_of(":"); 16 | if (start < 0) { 17 | return dependencies; 18 | } 19 | auto deps = depsStr.substr(start + 1); 20 | 21 | std::string dependency; 22 | for (int i = 0; i < deps.length(); i++) { 23 | char c = deps[i]; 24 | 25 | // Skip spaces and append dependency. 26 | if (c == ' ' || c == '\t' || c == '\n') { 27 | if (dependency.length() > 0) { 28 | dependencies.insert(dependency); 29 | } 30 | dependency.clear(); 31 | continue; 32 | } 33 | 34 | // \\ followed by \n is a space. Skip this character. 35 | if (c == '\\' && i + 1 < deps.length() && deps[i + 1] == '\n') { 36 | continue; 37 | } 38 | 39 | // \\ followed by a ' ' is not an escape character. Only append ' '. 40 | if (c == '\\' && i + 1 < deps.length() && deps[i + 1] == ' ') { 41 | dependency += ' '; 42 | i++; 43 | } else { 44 | dependency += c; 45 | } 46 | } 47 | 48 | if (dependency.length() > 0) { 49 | dependencies.insert(dependency); 50 | } 51 | 52 | return dependencies; 53 | } -------------------------------------------------------------------------------- /internal/pkg/scandeps/csdutils/parse_deps.h: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef INTERNAL_PKG_SCANDEPS_CSDUTILS_PARSE_DEPS_H_ 16 | #define INTERNAL_PKG_SCANDEPS_CSDUTILS_PARSE_DEPS_H_ 17 | #include 18 | #include 19 | #include 20 | 21 | namespace csdutils { 22 | // deps format 23 | // : ... 24 | // is space sparated 25 | // '\'+newline is space 26 | // '\'+space is an escaped space (not separater) 27 | std::set ParseDeps(std::string_view depsStr); 28 | } // namespace csdutils 29 | 30 | #endif // INTERNAL_PKG_SCANDEPS_CSDUTILS_PARSE_DEPS_H_ -------------------------------------------------------------------------------- /internal/pkg/scandeps/csdutils/parse_deps_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "parse_deps.h" 16 | 17 | #include 18 | 19 | #include 20 | #include 21 | 22 | TEST(ParseDepsTest, BasicTest) { 23 | EXPECT_EQ(csdutils::ParseDeps( 24 | "example.o: example.c /usr/include/stdio.h /path/with\\ " 25 | "space/file.h \\\n /some/file/on/another/line"), 26 | std::set({"example.c", "/usr/include/stdio.h", 27 | "/path/with space/file.h", 28 | "/some/file/on/another/line"})); 29 | } 30 | -------------------------------------------------------------------------------- /internal/pkg/scandeps/csdutils/parse_env.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "parse_env.h" 16 | 17 | #include 18 | #include 19 | 20 | std::set csdutils::ParsePluginsToIgnore(const char* envVal) { 21 | if (envVal == NULL || *envVal == '\0') { 22 | return {}; 23 | } 24 | std::stringstream ss(envVal); 25 | std::set result; 26 | while (ss.good()) { 27 | std::string substr; 28 | getline(ss, substr, ','); 29 | result.insert(substr); 30 | } 31 | return result; 32 | }; -------------------------------------------------------------------------------- /internal/pkg/scandeps/csdutils/parse_env.h: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef INTERNAL_PKG_SCANDEPS_CSDUTILS_PARSE_ENV_H_ 16 | #define INTERNAL_PKG_SCANDEPS_CSDUTILS_PARSE_ENV_H_ 17 | 18 | #include 19 | #include 20 | 21 | namespace csdutils { 22 | 23 | std::set ParsePluginsToIgnore(const char* envVal); 24 | } // namespace csdutils 25 | 26 | #endif // INTERNAL_PKG_SCANDEPS_CSDUTILS_PARSE_ENV_H_ -------------------------------------------------------------------------------- /internal/pkg/scandeps/csdutils/parse_env_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "parse_env.h" 16 | 17 | #include 18 | 19 | #include 20 | #include 21 | 22 | TEST(ParsePluginsToIgnoreTest, EmptyVal) { 23 | const char envVar[1] = {0}; 24 | EXPECT_EQ(csdutils::ParsePluginsToIgnore(envVar), std::set({})); 25 | } 26 | 27 | TEST(ParsePluginsToIgnoreTest, NullVal) { 28 | EXPECT_EQ(csdutils::ParsePluginsToIgnore(NULL), std::set({})); 29 | } 30 | 31 | TEST(ParsePluginsToIgnoreTest, SinglePlugin) { 32 | EXPECT_EQ(csdutils::ParsePluginsToIgnore("someplugin"), 33 | std::set({"someplugin"})); 34 | } 35 | 36 | TEST(ParsePluginsToIgnoreTest, MultiplePlugins) { 37 | EXPECT_EQ(csdutils::ParsePluginsToIgnore("someplugin,anotherplugin"), 38 | std::set({"someplugin", "anotherplugin"})); 39 | } 40 | -------------------------------------------------------------------------------- /internal/pkg/stats/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "stats", 5 | srcs = ["stats.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/stats", 7 | visibility = ["//:__subpackages__"], 8 | deps = [ 9 | "//api/log", 10 | "//api/stat", 11 | "//api/stats", 12 | "//internal/pkg/event", 13 | "//internal/pkg/labels", 14 | "//internal/pkg/localresources", 15 | "//internal/pkg/protoencoding", 16 | "//internal/pkg/reproxystatus", 17 | "@com_github_bazelbuild_remote_apis_sdks//go/api/command", 18 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 19 | "@com_github_golang_glog//:glog", 20 | "@com_github_google_uuid//:uuid", 21 | "@com_google_cloud_go_bigquery//:bigquery", 22 | "@org_golang_google_protobuf//encoding/protojson", 23 | "@org_golang_google_protobuf//proto", 24 | ], 25 | ) 26 | 27 | go_test( 28 | name = "stats_test", 29 | size = "small", 30 | srcs = ["stats_test.go"], 31 | embed = [":stats"], 32 | deps = [ 33 | "//api/log", 34 | "//api/stat", 35 | "//api/stats", 36 | "@com_github_bazelbuild_remote_apis_sdks//go/api/command", 37 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 38 | "@com_github_google_go_cmp//cmp", 39 | "@com_github_google_go_cmp//cmp/cmpopts", 40 | "@com_google_cloud_go_bigquery//:bigquery", 41 | "@org_golang_google_protobuf//testing/protocmp", 42 | "@org_golang_google_protobuf//types/known/timestamppb", 43 | ], 44 | ) 45 | -------------------------------------------------------------------------------- /internal/pkg/subprocess/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "subprocess", 5 | srcs = [ 6 | "subprocess.go", 7 | "subprocess_unix.go", 8 | "subprocess_windows.go", 9 | ], 10 | importpath = "github.com/bazelbuild/reclient/internal/pkg/subprocess", 11 | visibility = ["//visibility:public"], 12 | deps = [ 13 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 14 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/outerr", 15 | "@com_github_golang_glog//:glog", 16 | ] + select({ 17 | "@io_bazel_rules_go//go/platform:windows": [ 18 | "@com_github_kolesnikovae_go_winjob//:go-winjob", 19 | ], 20 | "//conditions:default": [], 21 | }), 22 | ) 23 | 24 | go_test( 25 | name = "subprocess_test", 26 | srcs = ["subprocess_test.go"], 27 | embed = [":subprocess"], 28 | deps = [ 29 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", 30 | "@com_github_bazelbuild_remote_apis_sdks//go/pkg/outerr", 31 | ], 32 | ) 33 | -------------------------------------------------------------------------------- /internal/pkg/tarfs/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "tarfs", 5 | srcs = ["tarfs.go"], 6 | importpath = "github.com/bazelbuild/reclient/internal/pkg/tarfs", 7 | visibility = ["//:__subpackages__"], 8 | deps = ["@com_github_golang_glog//:glog"], 9 | ) 10 | 11 | go_test( 12 | name = "tarfs_test", 13 | srcs = ["tarfs_test.go"], 14 | data = glob(["testdata/**"]), 15 | embed = [":tarfs"], 16 | ) 17 | -------------------------------------------------------------------------------- /internal/pkg/tarfs/tarfs_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package tarfs 16 | 17 | import ( 18 | "io/ioutil" 19 | "os" 20 | "testing" 21 | ) 22 | 23 | const ( 24 | tarFilePath = "testdata/test.tar" 25 | indexFile = "index.html" 26 | ) 27 | 28 | func TestTarfs(t *testing.T) { 29 | tarFile, err := os.Open(tarFilePath) 30 | if err != nil { 31 | t.Fatalf("Unable to open file %v: %v", tarFilePath, err) 32 | } 33 | defer tarFile.Close() 34 | fileBytes, err := ioutil.ReadAll(tarFile) 35 | if err != nil { 36 | t.Fatalf("Unable to read file %v: %v", tarFilePath, err) 37 | } 38 | 39 | tarFS, err := NewTarFSFromBytes(fileBytes) 40 | if err != nil { 41 | t.Fatalf("Unable to create tarfs from bytes: %v", err) 42 | } 43 | tf, err := tarFS.Open(indexFile) 44 | if err != nil { 45 | t.Errorf("Unable to open file: %v", err) 46 | } 47 | defer tf.Close() 48 | 49 | wantContents := "\n\n" 50 | gotContents, err := ioutil.ReadAll(tf) 51 | if err != nil { 52 | t.Fatalf("Unable to read file: %v", err) 53 | } 54 | if string(gotContents) != wantContents { 55 | t.Fatalf("File %v in tar, expected %v, got %v", indexFile, wantContents, string(gotContents)) 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /internal/pkg/version/version_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package version 16 | 17 | import ( 18 | "regexp" 19 | "strings" 20 | "testing" 21 | ) 22 | 23 | var ( 24 | expectedVersionFormat = regexp.MustCompile("(\\d+)\\.(\\d+)\\.(\\d+)\\.(([a-z0-9])+)") 25 | ) 26 | 27 | func TestVersionIsDefined(t *testing.T) { 28 | if v := CurrentVersion(); strings.Contains(v, undef) { 29 | t.Fatalf("CurrentVersion()=%v contains %q, expected a git commit sha instead", v, undef) 30 | } 31 | } 32 | 33 | func TestVersionInExpectedFormat(t *testing.T) { 34 | matches := expectedVersionFormat.FindAllString(CurrentVersion(), -1) 35 | if len(matches) != 1 { 36 | t.Fatalf("CurrentVersion()=%v not in expected format, match=%v, want %d matches, got %d", CurrentVersion(), matches, 1, len(matches)) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /linters/BUILD.bazel: -------------------------------------------------------------------------------- 1 | sh_binary( 2 | name = "clang-format", 3 | srcs = ["run_in_workspace.sh"], 4 | args = [ 5 | "$(location @llvm-project//clang:clang-format)", 6 | "-style", 7 | "google", 8 | ], 9 | data = [ 10 | "@llvm-project//clang:clang-format", 11 | ], 12 | tags = [ 13 | "local", 14 | "manual", 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /linters/run_in_workspace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2023 Google LLC 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | 17 | # Fail on any error. 18 | set -o errexit 19 | set -o nounset 20 | set -o pipefail 21 | 22 | tool="$(realpath "$1")" 23 | 24 | cd "$BUILD_WORKSPACE_DIRECTORY" 25 | 26 | "$tool" "${@:2}" -------------------------------------------------------------------------------- /llvm/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@bazel_skylib//rules:diff_test.bzl", "diff_test") 2 | load("@llvm_version//:defs.bzl", "LLVM_COMMIT") 3 | 4 | # Refer to go/rbe/dev/x/playbook/upgrading_clang_scan_deps if you are 5 | # running into a missing file error in this library when upgrading 6 | # clang-scan-deps version. 7 | CLANG_OPTIONS_FILE = "clang-options-" + LLVM_COMMIT[:6] + ".json" 8 | 9 | filegroup( 10 | name = "clang-options", 11 | srcs = [ 12 | CLANG_OPTIONS_FILE, 13 | ], 14 | visibility = ["//visibility:public"], 15 | ) 16 | 17 | diff_test( 18 | name = "clang_options_test", 19 | file1 = CLANG_OPTIONS_FILE, 20 | file2 = "@llvm-project//clang:clang-options.json", 21 | # Test fails with file not found error on windows 22 | target_compatible_with = select({ 23 | "@platforms//os:linux": [], 24 | "@platforms//os:macos": [], 25 | "//conditions:default": ["@platforms//:incompatible"], 26 | }), 27 | ) 28 | -------------------------------------------------------------------------------- /module_extensions/BUILD.bazel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazelbuild/reclient/9139556d0e2c77e57cfad0105207b7dfbdcfaf70/module_extensions/BUILD.bazel -------------------------------------------------------------------------------- /module_extensions/llvm_project.bzl: -------------------------------------------------------------------------------- 1 | """Apply llvm_configure to produce a llvm-project repo.""" 2 | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 3 | load("@llvm//utils/bazel:configure.bzl", "llvm_configure") 4 | 5 | 6 | def _llvm_project_impl(ctx): 7 | http_archive( 8 | name = "llvm_zlib", 9 | build_file = "@llvm//utils/bazel/third_party_build:zlib-ng.BUILD", 10 | sha256 = "e36bb346c00472a1f9ff2a0a4643e590a254be6379da7cddd9daeb9a7f296731", 11 | strip_prefix = "zlib-ng-2.0.7", 12 | urls = [ 13 | "https://github.com/zlib-ng/zlib-ng/archive/refs/tags/2.0.7.zip", 14 | ], 15 | ) 16 | http_archive( 17 | name = "llvm_zstd", 18 | build_file = "@llvm//utils/bazel/third_party_build:zstd.BUILD", 19 | sha256 = "7c42d56fac126929a6a85dbc73ff1db2411d04f104fae9bdea51305663a83fd0", 20 | strip_prefix = "zstd-1.5.2", 21 | urls = [ 22 | "https://github.com/facebook/zstd/releases/download/v1.5.2/zstd-1.5.2.tar.gz", 23 | ], 24 | ) 25 | llvm_configure(name = "llvm-project") 26 | 27 | llvm_project = module_extension( 28 | implementation = _llvm_project_impl, 29 | ) -------------------------------------------------------------------------------- /pkg/inputprocessor/fake/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "fake", 5 | testonly = 1, 6 | srcs = ["executor.go"], 7 | importpath = "github.com/bazelbuild/reclient/pkg/inputprocessor/fake", 8 | visibility = ["//visibility:public"], 9 | deps = ["@com_github_bazelbuild_remote_apis_sdks//go/pkg/command"], 10 | ) 11 | -------------------------------------------------------------------------------- /scripts/install_precommit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright 2023 Google LLC 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # Script to install the precommit hook to your local git folder. 17 | if [ ! -f .git/hooks/pre-commit ]; then 18 | echo "#!/bin/bash" > .git/hooks/pre-commit 19 | fi 20 | if ! grep -q scripts/precommit.sh .git/hooks/pre-commit; then 21 | echo scripts/precommit.sh >> .git/hooks/pre-commit 22 | fi 23 | chmod +x .git/hooks/pre-commit 24 | -------------------------------------------------------------------------------- /scripts/regenpbgo.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright 2023 Google LLC 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # This script regenerates all `.pb.go` files under //api/... by running 17 | # all *_copy_pbgo_files rules under the //api/... directory generated 18 | # by the go_proto_checkedin_test macro in //tools/build_defs.bzl 19 | # Use as follows: 20 | # 21 | # ./scripts/regenpbgo.sh 22 | 23 | set -eux 24 | 25 | for r in $(bazelisk query "filter('_copy_pbgo_files', kind(sh_binary, @@//...))") 26 | do 27 | bazelisk run "$r" 28 | done 29 | -------------------------------------------------------------------------------- /scripts/sha.bat: -------------------------------------------------------------------------------- 1 | :: 2 | :: Copyright 2023 Google LLC 3 | :: 4 | :: Licensed under the Apache License, Version 2.0 (the "License"); 5 | :: you may not use this file except in compliance with the License. 6 | :: You may obtain a copy of the License at 7 | :: 8 | :: http://www.apache.org/licenses/LICENSE-2.0 9 | :: 10 | :: Unless required by applicable law or agreed to in writing, software 11 | :: distributed under the License is distributed on an "AS IS" BASIS, 12 | :: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | :: See the License for the specific language governing permissions and 14 | :: limitations under the License. 15 | :: 16 | 17 | @echo off 18 | 19 | :: This script is used to print current git SHA so that Bazel's workspace command 20 | :: can consume it. 21 | for /f "usebackq tokens=*" %%h in (`git rev-parse HEAD`) do echo STABLE_VERSION_SHA %%h 22 | -------------------------------------------------------------------------------- /scripts/sha.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2023 Google LLC 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # This script is used to print current git SHA so that Bazel's workspace command 17 | # can consume it. 18 | 19 | # Use googler sha script if it exists, this script does not exist in the 20 | # open source repo. 21 | test -f scripts/sha_internal.sh && exec scripts/sha_internal.sh 22 | 23 | if gitSha=$(git rev-parse HEAD); then 24 | echo STABLE_VERSION_SHA "$gitSha" 25 | else 26 | echo STABLE_VERSION_SHA unknown 27 | fi -------------------------------------------------------------------------------- /settings.bzl: -------------------------------------------------------------------------------- 1 | ScannerProvider = provider(fields = ["scanner"]) 2 | scanners = ["clangscandeps", "goma"] 3 | 4 | def _impl(ctx): 5 | scanner = ctx.build_setting_value 6 | if scanner not in scanners: 7 | fail(str(ctx.label) + " include scanner can only be {" + 8 | ", ".join(scanners) + "} but was set to " + 9 | scanner) 10 | return ScannerProvider(scanner = scanner) 11 | 12 | include_scanner_rule = rule( 13 | implementation = _impl, 14 | build_setting = config.string(flag = True), 15 | ) 16 | -------------------------------------------------------------------------------- /third_party/android_toolchain/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # Empty file so bazel will recognize the directory. 2 | -------------------------------------------------------------------------------- /third_party/goma/BUILD.bazel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazelbuild/reclient/9139556d0e2c77e57cfad0105207b7dfbdcfaf70/third_party/goma/BUILD.bazel -------------------------------------------------------------------------------- /third_party/patches/bazel/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # Empty file so bazel will recognize the directory. 2 | -------------------------------------------------------------------------------- /third_party/patches/bazel/rfcc.patch: -------------------------------------------------------------------------------- 1 | --- foreign_cc/ninja.bzl 2024-06-04 15:36:26.027523988 +0000 2 | +++ foreign_cc/ninja.bzl.new 2024-06-04 15:35:50.507565367 +0000 3 | @@ -51,7 +51,11 @@ 4 | script = [] 5 | 6 | root = detect_root(ctx.attr.lib_source) 7 | - script.append("##symlink_contents_to_dir## $$EXT_BUILD_ROOT$$/{} $$BUILD_TMPDIR$$ False".format(root)) 8 | + 9 | + script.append("TMP_EXT=${EXT_BUILD_ROOT//\\\\/\\/}") 10 | + script.append("TMP_TMP=${BUILD_TMPDIR//\\\\/\\/}") 11 | + script.append("rm -rf $TMP_TMP/*") 12 | + script.append("ln -sf $$TMP_EXT$$/{}/* $$TMP_TMP$$".format(root)) 13 | 14 | data = ctx.attr.data + ctx.attr.build_data 15 | 16 | -------------------------------------------------------------------------------- /third_party/patches/bazel/rules_go.patch: -------------------------------------------------------------------------------- 1 | --- go/private/rules/binary.bzl 2 | +++ go/private/rules/binary.bzl.new 3 | @@ -510,10 +510,13 @@ exit /b %GO_EXIT_CODE% 4 | output = bat, 5 | content = cmd, 6 | ) 7 | + bargs = ctx.actions.args() 8 | + bargs.add("/c", bat.path.replace("/", "\\")) 9 | ctx.actions.run( 10 | - executable = bat, 11 | + executable = "cmd", 12 | + arguments = [bargs], 13 | inputs = depset( 14 | - ctx.files.srcs + [sdk.go], 15 | + ctx.files.srcs + [sdk.go] + [bat], 16 | transitive = [sdk.headers, sdk.srcs, sdk.tools], 17 | ), 18 | outputs = [out, gotmp], 19 | -------------------------------------------------------------------------------- /third_party/patches/bazel/zlib.patch: -------------------------------------------------------------------------------- 1 | --- BUILD.bazel 2024-11-26 07:07:06.138656017 +0000 2 | +++ BUILD.bazel.new 2024-11-26 07:10:26.946468038 +0000 3 | @@ -62,7 +62,7 @@ 4 | outs = _ZLIB_PREFIXED_HEADERS, 5 | cmd_bash = "cp $(SRCS) $(@D)/zlib/include/", 6 | cmd_bat = " && ".join( 7 | - ["@copy /Y \"$(location %s)\" \"$(@D)\\zlib\\include\\\" >NUL" % 8 | + ["@copy /Y $(location %s) $(@D)\\zlib\\include\\ >NUL" % 9 | s for s in _ZLIB_HEADERS], 10 | ), 11 | ) 12 | -------------------------------------------------------------------------------- /third_party/patches/goma/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # Empty file so bazel will recognize the directory. 2 | -------------------------------------------------------------------------------- /third_party/patches/goma/LICENSE: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Goma Authors. All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are 5 | // met: 6 | // 7 | // * Redistributions of source code must retain the above copyright 8 | // notice, this list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above 10 | // copyright notice, this list of conditions and the following disclaimer 11 | // in the documentation and/or other materials provided with the 12 | // distribution. 13 | // * Neither the name of Google Inc. nor the names of its 14 | // contributors may be used to endorse or promote products derived from 15 | // this software without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /third_party/patches/goma/breakpad.patch: -------------------------------------------------------------------------------- 1 | --- client/third_party/breakpad/BUILD.gn 2024-06-11 15:04:34.411557138 +0000 2 | +++ client/third_party/breakpad/BUILD.gn.new 2024-06-11 15:10:20.827239929 +0000 3 | @@ -37,6 +37,7 @@ 4 | "-Wno-non-c-typedef-for-linkage", # typedef struct{} Options 5 | "-Wno-tautological-constant-out-of-range-compare", 6 | "-Wno-unused-parameter", # argc of main in sym_upload.cc 7 | + "-Wno-deprecated-declarations", 8 | ] 9 | } 10 | if (is_win_gcc) { 11 | @@ -56,7 +57,7 @@ 12 | } 13 | 14 | if (is_clang) { 15 | - cflags = [ "-Wno-unused-parameter" ] 16 | + cflags = [ "-Wno-unused-parameter", "-Wno-deprecated-declarations" ] 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /third_party/patches/goma/goma_subprocess.patch: -------------------------------------------------------------------------------- 1 | --- client/client/subprocess.cc 2023-02-01 14:40:35 2 | +++ client/client/subprocess.cc.new 2023-02-03 15:44:27 3 | @@ -18,6 +18,7 @@ 4 | #include 5 | #include 6 | #include 7 | +#include 8 | 9 | #include "absl/strings/str_join.h" 10 | #include "absl/strings/string_view.h" 11 | @@ -40,6 +41,10 @@ namespace devtools_goma { 12 | 13 | namespace { 14 | 15 | +#ifndef _WIN32 16 | +std::mutex popen_mutex; 17 | +#endif 18 | + 19 | #ifdef _WIN32 20 | std::string GetPathExt(const std::vector& envs) { 21 | return GetEnvFromEnvIter(envs.begin(), envs.end(), "PATHEXT"); 22 | @@ -179,7 +184,11 @@ std::string ReadCommandOutputByPopen(const std::string& prog, 23 | if (option == MERGE_STDOUT_STDERR) 24 | commandline += " 2>&1"; 25 | 26 | - FILE* p = popen(commandline.c_str(), "r"); 27 | + FILE* p = nullptr; 28 | + { 29 | + std::lock_guard guard(popen_mutex); 30 | + p = popen(commandline.c_str(), "r"); 31 | + } 32 | CHECK(p) << "popen for " << prog << " (" << commandline << ") failed"; 33 | 34 | std::ostringstream strbuf; 35 | @@ -196,7 +205,11 @@ std::string ReadCommandOutputByPopen(const std::string& prog, 36 | strbuf.write(buf, len); 37 | } 38 | 39 | - int exit_status = pclose(p); 40 | + int exit_status; 41 | + { 42 | + std::lock_guard guard(popen_mutex); 43 | + exit_status = pclose(p); 44 | + } 45 | if (status) { 46 | *status = exit_status; 47 | } else { 48 | -------------------------------------------------------------------------------- /third_party/patches/llvm/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # Empty file so bazel will recognize the directory. 2 | -------------------------------------------------------------------------------- /third_party/patches/llvm/llvm-bzl-config.patch: -------------------------------------------------------------------------------- 1 | diff --git a/utils/bazel/configure.bzl b/utils/bazel/configure.bzl 2 | --- a/utils/bazel/configure.bzl (revision 82e851a407c52d65ce65e7aa58453127e67d42a0) 3 | +++ b/utils/bazel/configure.bzl (date 1705188246176) 4 | @@ -32,7 +32,7 @@ 5 | ] 6 | 7 | def _overlay_directories(repository_ctx): 8 | - src_path = repository_ctx.path(Label("@llvm-raw//:WORKSPACE")).dirname 9 | + src_path = repository_ctx.path(Label("@llvm//:WORKSPACE")).dirname 10 | bazel_path = src_path.get_child("utils").get_child("bazel") 11 | overlay_path = bazel_path.get_child("llvm-project-overlay") 12 | script_path = bazel_path.get_child("overlay_directories.py") 13 | -------------------------------------------------------------------------------- /third_party/patches/llvm/llvm-bzl-tblgen.patch: -------------------------------------------------------------------------------- 1 | diff --git a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel 2 | index 037719a51dd1..99a6942341fb 100644 3 | --- a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel 4 | +++ b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel 5 | @@ -1484,6 +1484,20 @@ gentbl( 6 | ], 7 | ) 8 | 9 | +gentbl( 10 | + name = "driver_options_json_gen", 11 | + tbl_outs = [( 12 | + "", 13 | + "clang-options.json", 14 | + )], 15 | + tblgen = "//llvm:llvm-tblgen", 16 | + tblgen_args = "--dump-json", 17 | + td_file = "include/clang/Driver/Options.td", 18 | + td_srcs = [ 19 | + "//llvm:include/llvm/Option/OptParser.td", 20 | + ], 21 | +) 22 | + 23 | cc_library( 24 | name = "driver", 25 | srcs = glob( 26 | -------------------------------------------------------------------------------- /third_party/patches/llvm/llvm-delay-sanitizer-args-parsing.patch: -------------------------------------------------------------------------------- 1 | diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp 2 | index ca992528ac2e..96695ef5b562 100644 3 | --- a/clang/lib/Driver/ToolChains/Clang.cpp 4 | +++ b/clang/lib/Driver/ToolChains/Clang.cpp 5 | @@ -6351,8 +6351,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, 6 | options::OPT_no_offload_new_driver, false)) 7 | CmdArgs.push_back("--offload-new-driver"); 8 | 9 | - SanitizeArgs.addArgs(TC, Args, CmdArgs, InputType); 10 | - 11 | const XRayArgs &XRay = TC.getXRayArgs(); 12 | XRay.addArgs(TC, Args, CmdArgs, InputType); 13 | 14 | @@ -7176,6 +7174,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, 15 | } 16 | } 17 | 18 | + // This needs to run after -Xclang argument forwarding to pick up the target 19 | + // features enabled through -Xclang -target-feature flags. 20 | + SanitizeArgs.addArgs(TC, Args, CmdArgs, InputType); 21 | + 22 | // With -save-temps, we want to save the unoptimized bitcode output from the 23 | // CompileJobAction, use -disable-llvm-passes to get pristine IR generated 24 | // by the frontend. 25 | -------------------------------------------------------------------------------- /third_party/patches/llvm/llvm-project-overlay-exectools.patch: -------------------------------------------------------------------------------- 1 | diff --git a/utils/bazel/llvm-project-overlay/clang-tools-extra/clang-tidy/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang-tools-extra/clang-tidy/BUILD.bazel 2 | index bbabc5397e98..317863de3b36 100644 3 | --- a/utils/bazel/llvm-project-overlay/clang-tools-extra/clang-tidy/BUILD.bazel 4 | +++ b/utils/bazel/llvm-project-overlay/clang-tools-extra/clang-tidy/BUILD.bazel 5 | @@ -57,7 +57,7 @@ genrule( 6 | srcs = ["misc/ConfusableTable/confusables.txt"], 7 | outs = ["Confusables.inc"], 8 | cmd = "$(location :confusable_table_builder) $(SRCS) $(OUTS)", 9 | - exec_tools = [":confusable_table_builder"], 10 | + tools = [":confusable_table_builder"], 11 | visibility = ["//visibility:private"], 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /third_party/patches/opencensus-go-exporter-stackdriver/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # Empty file so bazel will recognize the directory. 2 | -------------------------------------------------------------------------------- /third_party/patches/opencensus-go-exporter-stackdriver/opencensus-stackdriver-interval.patch: -------------------------------------------------------------------------------- 1 | diff --git a/metrics.go b/metrics.go 2 | index 902b776..edebc93 100644 3 | --- a/metrics.go 4 | +++ b/metrics.go 5 | @@ -25,7 +25,7 @@ import ( 6 | "strings" 7 | 8 | "github.com/golang/protobuf/ptypes/any" 9 | - "github.com/golang/protobuf/ptypes/timestamp" 10 | + "time" 11 | "go.opencensus.io/trace" 12 | "google.golang.org/protobuf/proto" 13 | 14 | @@ -369,7 +369,7 @@ func (se *statsExporter) metricTsToMpbPoint(ts *metricdata.TimeSeries, metricKin 15 | 16 | // If we have a last value aggregation point i.e. MetricDescriptor_GAUGE 17 | // StartTime should be nil. 18 | - startTime := timestampProto(ts.StartTime) 19 | + startTime := &ts.StartTime 20 | if metricKind == googlemetricpb.MetricDescriptor_GAUGE { 21 | startTime = nil 22 | } 23 | @@ -383,7 +383,7 @@ func (se *statsExporter) metricTsToMpbPoint(ts *metricdata.TimeSeries, metricKin 24 | return sptl, nil 25 | } 26 | 27 | -func metricPointToMpbPoint(startTime *timestamp.Timestamp, pt *metricdata.Point, projectID string) (*monitoringpb.Point, error) { 28 | +func metricPointToMpbPoint(startTime *time.Time, pt *metricdata.Point, projectID string) (*monitoringpb.Point, error) { 29 | if pt == nil { 30 | return nil, nil 31 | } 32 | @@ -395,11 +395,14 @@ func metricPointToMpbPoint(startTime *timestamp.Timestamp, pt *metricdata.Point, 33 | 34 | mpt := &monitoringpb.Point{ 35 | Value: mptv, 36 | - Interval: &monitoringpb.TimeInterval{ 37 | - StartTime: startTime, 38 | + } 39 | + if startTime == nil { 40 | + mpt.Interval = &monitoringpb.TimeInterval{ 41 | EndTime: timestampProto(pt.Time), 42 | - }, 43 | + } 44 | + return mpt, nil 45 | } 46 | + mpt.Interval = toValidTimeIntervalpb(*startTime, pt.Time) 47 | return mpt, nil 48 | } 49 | -------------------------------------------------------------------------------- /tools/copy_to_workspace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2023 Google LLC 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # This script copies a list of bazel generated files to the source directory. 17 | # This script is meant to be run as a bazel sh_binary. 18 | # The env var BUILD_WORKSPACE_DIRECTORY should be set by bazel. 19 | # In a bazel build file, use as follows: 20 | # 21 | # native.sh_binary( 22 | # name = "my_copy_target", 23 | # srcs = ["//tools:copy_to_workspace.sh"], 24 | # args = [ 25 | # package_name(), 26 | # "$(execpaths :my_gen_files)", 27 | # ], 28 | # data = [ 29 | # ":my_gen_files", 30 | # ], 31 | # ) 32 | 33 | # Fail on any error. 34 | set -o errexit 35 | set -o nounset 36 | set -o pipefail 37 | 38 | pkg="$1" 39 | cd "$BUILD_WORKSPACE_DIRECTORY" || exit 1 40 | for file in "${@:2}" 41 | do 42 | cp -f "$file" "$pkg/$(basename "$file")" 43 | done 44 | -------------------------------------------------------------------------------- /tools/imports.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package tools 16 | 17 | import ( 18 | // Dependencies of non-exported code, specified here so that 19 | // go.mod and go.sum remain consistent 20 | _ "cloud.google.com/go/monitoring/apiv3/v2" 21 | _ "cloud.google.com/go/storage" 22 | _ "github.com/hectane/go-acl" 23 | _ "github.com/pkg/xattr" 24 | 25 | _ "golang.org/x/tools/go/analysis" // Used as tools by bazel nogo analyzers 26 | ) 27 | -------------------------------------------------------------------------------- /tools/nogo_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "_base": { 3 | "description": "Base config that all subsequent analyzers, even unspecified will inherit.", 4 | "exclude_files": { 5 | "third_party/": "exclude all third_party code for all analyzers" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /transitions/BUILD.bazel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bazelbuild/reclient/9139556d0e2c77e57cfad0105207b7dfbdcfaf70/transitions/BUILD.bazel -------------------------------------------------------------------------------- /version.bzl: -------------------------------------------------------------------------------- 1 | VERSION_MAJOR = "0" 2 | VERSION_MINOR = "180" 3 | VERSION_PATCH = "0" 4 | --------------------------------------------------------------------------------