Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat external repositories as system headers for warning purposes. #436

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2021, 2022, 2023 Google LLC
# Copyright 2021, 2022, 2023, 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -12,10 +12,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.

common --enable_platform_specific_config

# Run Pylint by default.
build --aspects='//private:defs.bzl%check_python'
build --output_groups='+check_python'

# The external_include_paths feature has to be specified in .bazelrc because it
# needs to apply to all compile actions in all repositories.
# TODO: File bug against Bazel to make this work as repository-level feature.
build --features=external_include_paths --host_features=external_include_paths

# The next line shouldn’t be necessary.
# TODO: File bug against Bazel.
build:windows --copt=/external:W0

import %workspace%/c-std.bazelrc

try-import %workspace%/github.bazelrc
11 changes: 11 additions & 0 deletions .github/actions/set-up/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,14 @@ runs:
startsWith(inputs.bazel-version, '6.3.') ||
startsWith(inputs.bazel-version, '6.4.')
)
- name: Remove unsupported options
shell: bash
# --host_features was introduced in Bazel 6.1.
run: |
set -efuC
for file in .bazelrc examples/ext/.bazelrc; do
sed -- 's/--host_features=[_[:alnum:]]*//g' "${file}" > "${file}.temp"
mv -- "${file}.temp" "${file}"
done
if: >-
startsWith(inputs.bazel-version, '6.0.')
16 changes: 0 additions & 16 deletions elisp/binary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,8 @@

#include <initializer_list>

#ifdef __GNUC__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wpedantic"
# pragma GCC diagnostic ignored "-Wconversion"
# pragma GCC diagnostic ignored "-Wsign-conversion"
# pragma GCC diagnostic ignored "-Woverflow"
#endif
#ifdef _MSC_VER
# pragma warning(push, 3)
#endif
#include "absl/status/statusor.h"
#include "absl/types/span.h"
#ifdef __GNUC__
# pragma GCC diagnostic pop
#endif
#ifdef _MSC_VER
# pragma warning(pop)
#endif

#include "elisp/platform.h"
#include "elisp/process.h"
Expand Down
16 changes: 0 additions & 16 deletions elisp/emacs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,8 @@

#include <initializer_list>

#ifdef __GNUC__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wpedantic"
# pragma GCC diagnostic ignored "-Wconversion"
# pragma GCC diagnostic ignored "-Wsign-conversion"
# pragma GCC diagnostic ignored "-Woverflow"
#endif
#ifdef _MSC_VER
# pragma warning(push, 3)
#endif
#include "absl/status/statusor.h"
#include "absl/types/span.h"
#ifdef __GNUC__
# pragma GCC diagnostic pop
#endif
#ifdef _MSC_VER
# pragma warning(pop)
#endif

#include "elisp/platform.h"
#include "elisp/process.h"
Expand Down
16 changes: 0 additions & 16 deletions elisp/launcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,12 @@

#include <cstdlib>

#ifdef __GNUC__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wpedantic"
# pragma GCC diagnostic ignored "-Wconversion"
# pragma GCC diagnostic ignored "-Wsign-conversion"
# pragma GCC diagnostic ignored "-Woverflow"
#endif
#ifdef _MSC_VER
# pragma warning(push, 3)
#endif
#include "absl/container/fixed_array.h"
#include "absl/log/log.h"
#include "absl/meta/type_traits.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/types/span.h"
#ifdef __GNUC__
# pragma GCC diagnostic pop
#endif
#ifdef _MSC_VER
# pragma warning(pop)
#endif

#include "elisp/platform.h"
#include "elisp/main.h"
Expand Down
16 changes: 0 additions & 16 deletions elisp/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,8 @@

#include <initializer_list>

#ifdef __GNUC__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wpedantic"
# pragma GCC diagnostic ignored "-Wconversion"
# pragma GCC diagnostic ignored "-Wsign-conversion"
# pragma GCC diagnostic ignored "-Woverflow"
#endif
#ifdef _MSC_VER
# pragma warning(push, 3)
#endif
#include "absl/status/statusor.h"
#include "absl/types/span.h"
#ifdef __GNUC__
# pragma GCC diagnostic pop
#endif
#ifdef _MSC_VER
# pragma warning(pop)
#endif

#include "elisp/platform.h"

Expand Down
16 changes: 0 additions & 16 deletions elisp/process.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,6 @@
#include <utility>
#include <vector>

#ifdef __GNUC__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wpedantic"
# pragma GCC diagnostic ignored "-Wconversion"
# pragma GCC diagnostic ignored "-Wsign-conversion"
# pragma GCC diagnostic ignored "-Woverflow"
#endif
#ifdef _MSC_VER
# pragma warning(push, 3)
#endif
#include "absl/algorithm/container.h"
#include "absl/base/attributes.h"
#include "absl/base/nullability.h"
Expand All @@ -78,12 +68,6 @@
#include "absl/strings/str_join.h"
#include "absl/types/span.h"
#include "tools/cpp/runfiles/runfiles.h"
#ifdef __GNUC__
# pragma GCC diagnostic pop
#endif
#ifdef _MSC_VER
# pragma warning(pop)
#endif

#ifdef __APPLE__
# include <crt_externs.h> // for _NSGetEnviron
Expand Down
16 changes: 0 additions & 16 deletions elisp/process.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,8 @@
#include <initializer_list>
#include <string_view> // IWYU pragma: keep

#ifdef __GNUC__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wpedantic"
# pragma GCC diagnostic ignored "-Wconversion"
# pragma GCC diagnostic ignored "-Wsign-conversion"
# pragma GCC diagnostic ignored "-Woverflow"
#endif
#ifdef _MSC_VER
# pragma warning(push, 3)
#endif
#include "absl/status/statusor.h"
#include "absl/types/span.h"
#ifdef __GNUC__
# pragma GCC diagnostic pop
#endif
#ifdef _MSC_VER
# pragma warning(pop)
#endif

#include "elisp/platform.h"

Expand Down
15 changes: 0 additions & 15 deletions elisp/proto/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,6 @@
# error Emacs module header too old
#endif

#ifdef __GNUC__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wconversion"
# pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
#ifdef _MSC_VER
# pragma warning(push, 3)
# pragma warning(disable : 4090 4244 4267 4334)
#endif
#include "absl/base/attributes.h"
#include "absl/base/config.h"
#include "google/protobuf/any.upb.h"
Expand All @@ -165,12 +156,6 @@
#include "upb/util/required_fields.h"
#include "upb/wire/decode.h"
#include "upb/wire/encode.h"
#ifdef __GNUC__
# pragma GCC diagnostic pop
#endif
#ifdef _MSC_VER
# pragma warning(pop)
#endif

/// Global variables

Expand Down
16 changes: 0 additions & 16 deletions elisp/test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,8 @@

#include <initializer_list>

#ifdef __GNUC__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wpedantic"
# pragma GCC diagnostic ignored "-Wconversion"
# pragma GCC diagnostic ignored "-Wsign-conversion"
# pragma GCC diagnostic ignored "-Woverflow"
#endif
#ifdef _MSC_VER
# pragma warning(push, 3)
#endif
#include "absl/status/statusor.h"
#include "absl/types/span.h"
#ifdef __GNUC__
# pragma GCC diagnostic pop
#endif
#ifdef _MSC_VER
# pragma warning(pop)
#endif

#include "elisp/platform.h"
#include "elisp/process.h"
Expand Down
5 changes: 5 additions & 0 deletions examples/ext/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# The external_include_paths feature has to be specified in .bazelrc because it
# needs to apply to all compile actions in all repositories.
# TODO: File bug against Bazel to make this work as repository-level feature.
build --features=external_include_paths --host_features=external_include_paths

import %workspace%/../../c-std.bazelrc

try-import %workspace%/../../github.bazelrc
9 changes: 9 additions & 0 deletions private/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,15 @@ COPTS = select({
"-pedantic",
"-pedantic-errors",
],
}) + select({
Label("//private:clang"): [
# This shouldn’t be needed, but the external_include_paths feature
# doesn’t work on macOS.
# TODO: File bug against Bazel.
"--system-header-prefix=absl/",
"--system-header-prefix=upb/",
],
Label("//conditions:default"): [],
})

CXXOPTS = select({
Expand Down
Loading