diff --git a/features/BUILD b/features/BUILD new file mode 100644 index 0000000..e8f03d0 --- /dev/null +++ b/features/BUILD @@ -0,0 +1,55 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:feature_set.bzl", "cc_feature_set") + +cc_feature_set( + name = "features", + all_of = [ + "//features/linux_platform", + "//features/qnx_platform", + "//features/markers:no_legacy_features", + "//features/markers:supports_pic", + "//features/markers:supports_dynamic_linker", + "//features/markers:supports_fission", + "//features/markers:supports_header_path_normalization", + "//features/unfiltered_compile_flags", + "//features/default_compile_flags", + "//features/random_seed", + "//features/include_paths", + "//features/preprocessor_defines", + "//features/user_compile_flags", + "//features/compiler_input_flags", + "//features/compiler_output_flags", + "//features/dependency_file", + "//features/per_object_debug_info", + "//features/includes", + "//features/archiver_flags", + "//features/linker_param_file", + "//features/library_search_directories", + "//features/shared_flag", + "//features/output_execpath_flags", + "//features/runtime_library_search_directories", + "//features/libraries_to_link", + "//features/user_link_flags", + "//features/linkstamps", + "//features/fission_support", + "//features/force_pic_flags", + "//features/strip_debug_symbols", + "//features/static_libgcc", + "//features/pic", + "//features/use_pthread", + "//features/gcc_coverage_map_format", + ], + visibility = ["//visibility:public"], +) diff --git a/features/all_wall_warnings/BUILD b/features/all_wall_warnings/BUILD new file mode 100644 index 0000000..23481e5 --- /dev/null +++ b/features/all_wall_warnings/BUILD @@ -0,0 +1,136 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "linux_all_wall_args", + actions = [ + "@rules_cc//cc/toolchains/actions:c_compile_actions", + "@rules_cc//cc/toolchains/actions:cpp_compile_actions", + ], + args = [ + "-Waddress", + "-Warray-bounds=1", + "-Warray-compare", + "-Warray-parameter=2", + "-Wbool-operation", + "-Wchar-subscripts", + "-Wcomment", + "-Wdangling-else", + "-Wdangling-pointer=2", + "-Wduplicate-decl-specifier", + "-Wenum-compare", + "-Wformat-contains-nul", + "-Wformat-diag", + "-Wformat-extra-args", + "-Wformat-overflow=1", + "-Wformat-truncation=1", + "-Wformat-zero-length", + "-Wformat=1", + "-Wframe-address", + "-Winfinite-recursion", + "-Winit-self", + "-Wint-in-bool-context", + "-Wmain", + "-Wmaybe-uninitialized", + "-Wmemset-elt-size", + "-Wmemset-transposed-args", + "-Wmisleading-indentation", + "-Wmismatched-dealloc", + "-Wmissing-attributes", + "-Wmissing-braces", + "-Wmultistatement-macros", + "-Wnonnull", + "-Wnonnull-compare", + "-Wopenmp-simd", + "-Wpacked-not-aligned", + "-Wparentheses", + "-Wrestrict", + "-Wreturn-type", + "-Wsequence-point", + "-Wsign-compare", + "-Wsizeof-array-div", + "-Wsizeof-pointer-div", + "-Wsizeof-pointer-memaccess", + "-Wstrict-aliasing", + "-Wstrict-overflow=1", + "-Wswitch", + "-Wtautological-compare", + "-Wtrigraphs", + "-Wuninitialized", + "-Wunknown-pragmas", + "-Wunused", + "-Wunused-but-set-variable", + "-Wunused-const-variable=1", + "-Wunused-function", + "-Wunused-label", + "-Wunused-local-typedefs", + "-Wunused-value", + "-Wunused-variable", + "-Wuse-after-free=2", + "-Wvolatile-register-var", + "-Wzero-length-bounds", + ], + visibility = ["//visibility:public"], +) + +cc_args( + name = "linux_all_wall_c_args", + actions = ["@rules_cc//cc/toolchains/actions:c_compile_actions"], + args = [ + "-Wimplicit", + "-Wimplicit-function-declaration", + "-Wimplicit-int", + "-Wpointer-sign", + "-Wvla-parameter", + ], + visibility = ["//visibility:public"], +) + +cc_args( + name = "linux_all_wall_cxx_args", + actions = ["@rules_cc//cc/toolchains/actions:cpp_compile_actions"], + args = [ + "-Waligned-new", + "-Wc++11-compat", + "-Wc++14-compat", + "-Wc++17-compat", + "-Wc++20-compat", + "-Wcatch-value", + "-Wclass-memaccess", + "-Wdelete-non-virtual-dtor", + "-Wmismatched-new-delete", + "-Woverloaded-virtual", + "-Wpessimizing-move", + "-Wrange-loop-construct", + "-Wuseless-cast", + ], + visibility = ["//visibility:public"], +) + +cc_feature( + name = "all_wall_warnings", + args = select({ + "@platforms//os:linux": [ + ":linux_all_wall_args", + ":linux_all_wall_c_args", + ":linux_all_wall_cxx_args", + ], + "@platforms//os:qnx": [], + }), + feature_name = "all_wall_warnings", + implies = ["//features/strict_warnings:strict_warnings"], + visibility = ["//visibility:public"], +) diff --git a/features/archiver_flags/BUILD b/features/archiver_flags/BUILD new file mode 100644 index 0000000..030860d --- /dev/null +++ b/features/archiver_flags/BUILD @@ -0,0 +1,77 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") +load("@rules_cc//cc/toolchains:nested_args.bzl", "cc_nested_args") + +cc_args( + name = "archiver_static_flag_args", + actions = ["@rules_cc//cc/toolchains/actions:ar_actions"], + args = ["rcsD"], + visibility = ["//visibility:public"], +) + +cc_args( + name = "archiver_output_execpath_args", + actions = ["@rules_cc//cc/toolchains/actions:ar_actions"], + args = ["{output_execpath}"], + format = {"output_execpath": "@rules_cc//cc/toolchains/variables:output_execpath"}, + requires_not_none = "@rules_cc//cc/toolchains/variables:output_execpath", + visibility = ["//visibility:public"], +) + +cc_nested_args( + name = "archiver_object_file_entry", + args = ["{lib_name}"], + format = {"lib_name": "@rules_cc//cc/toolchains/variables:libraries_to_link.name"}, + requires_equal = "@rules_cc//cc/toolchains/variables:libraries_to_link.type", + requires_equal_value = "object_file", +) + +cc_nested_args( + name = "archiver_object_file_group_entry", + args = ["{object_file}"], + format = {"object_file": "@rules_cc//cc/toolchains/variables:libraries_to_link.object_files"}, + iterate_over = "@rules_cc//cc/toolchains/variables:libraries_to_link.object_files", + requires_equal = "@rules_cc//cc/toolchains/variables:libraries_to_link.type", + requires_equal_value = "object_file_group", +) + +cc_nested_args( + name = "archiver_iterate_libraries", + iterate_over = "@rules_cc//cc/toolchains/variables:libraries_to_link", + nested = [ + ":archiver_object_file_entry", + ":archiver_object_file_group_entry", + ], +) + +cc_args( + name = "archiver_libraries_args", + actions = ["@rules_cc//cc/toolchains/actions:ar_actions"], + nested = [":archiver_iterate_libraries"], + requires_not_none = "@rules_cc//cc/toolchains/variables:libraries_to_link", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "archiver_flags", + args = [ + ":archiver_static_flag_args", + ":archiver_output_execpath_args", + ":archiver_libraries_args", + ], + feature_name = "archiver_flags", + visibility = ["//visibility:public"], +) diff --git a/features/compiler_input_flags/BUILD b/features/compiler_input_flags/BUILD new file mode 100644 index 0000000..01612f2 --- /dev/null +++ b/features/compiler_input_flags/BUILD @@ -0,0 +1,34 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "compiler_input_flags_args", + actions = ["@rules_cc//cc/toolchains/actions:compile_actions"], + args = [ + "-c", + "{source_file}", + ], + format = {"source_file": "@rules_cc//cc/toolchains/variables:source_file"}, + requires_not_none = "@rules_cc//cc/toolchains/variables:source_file", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "compiler_input_flags", + args = [":compiler_input_flags_args"], + feature_name = "compiler_input_flags", + visibility = ["//visibility:public"], +) diff --git a/features/compiler_library_search_paths/BUILD b/features/compiler_library_search_paths/BUILD new file mode 100644 index 0000000..cab64ed --- /dev/null +++ b/features/compiler_library_search_paths/BUILD @@ -0,0 +1,40 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "compiler_library_search_paths_args", + actions = [ + "@rules_cc//cc/toolchains/actions:source_compile_actions", + "@rules_cc//cc/toolchains/actions:cpp_link_executable", + "@rules_cc//cc/toolchains/actions:cpp_link_dynamic_library", + "@rules_cc//cc/toolchains/actions:cpp_link_nodeps_dynamic_library", + ], + args = ["-Wl,-rpath,{compiler_library_search_paths}"], + format = {"compiler_library_search_paths": "@rules_cc//cc/toolchains/variables:compiler_library_search_paths"}, + iterate_over = "@rules_cc//cc/toolchains/variables:compiler_library_search_paths", + requires_not_none = "@rules_cc//cc/toolchains/variables:compiler_library_search_paths", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "compiler_library_search_paths", + args = [":compiler_library_search_paths_args"], + feature_name = "compiler_library_search_paths", + requires_any_of = ["//features/linux_platform"], + visibility = ["//visibility:public"], +) + +# ERROR diff --git a/features/compiler_output_flags/BUILD b/features/compiler_output_flags/BUILD new file mode 100644 index 0000000..3adc126 --- /dev/null +++ b/features/compiler_output_flags/BUILD @@ -0,0 +1,54 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "output_assembly_file_args", + actions = ["@rules_cc//cc/toolchains/actions:compile_actions"], + args = ["-S"], + requires_not_none = "@rules_cc//cc/toolchains/variables:output_assembly_file", + visibility = ["//visibility:public"], +) + +cc_args( + name = "output_preprocess_file_args", + actions = ["@rules_cc//cc/toolchains/actions:compile_actions"], + args = ["-E"], + requires_not_none = "@rules_cc//cc/toolchains/variables:output_preprocess_file", + visibility = ["//visibility:public"], +) + +cc_args( + name = "output_file_args", + actions = ["@rules_cc//cc/toolchains/actions:compile_actions"], + args = [ + "-o", + "{output_file}", + ], + format = {"output_file": "@rules_cc//cc/toolchains/variables:output_file"}, + requires_not_none = "@rules_cc//cc/toolchains/variables:output_file", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "compiler_output_flags", + args = [ + ":output_assembly_file_args", + ":output_preprocess_file_args", + ":output_file_args", + ], + feature_name = "compiler_output_flags", + visibility = ["//visibility:public"], +) diff --git a/features/default_compile_flags/BUILD b/features/default_compile_flags/BUILD new file mode 100644 index 0000000..0b25a6e --- /dev/null +++ b/features/default_compile_flags/BUILD @@ -0,0 +1,141 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") +load("@rules_cc//cc/toolchains:feature_constraint.bzl", "cc_feature_constraint") + +cc_args( + name = "default_compile_flags_args", + actions = ["@rules_cc//cc/toolchains/actions:compile_actions"], + args = select( + { + "@platforms//os:linux": [ + "-U_FORTIFY_SOURCE", + "-D_XOPEN_SOURCE=700", + "-fstack-protector", + "-fdiagnostics-color=always", + "-fno-omit-frame-pointer", + "-ffunction-sections", + "-fdata-sections", + "-fno-canonical-system-headers", + "-no-canonical-prefixes", + "-z noexecstack", + ], + "@platforms//os:qnx": [ + "-fno-canonical-system-headers", + ], + "//conditions:default": [], + }, + ), +) + +# x86_64 requires -m64; other architectures need no CPU flags here +cc_args( + name = "target_cpu_flags_args", + actions = ["@rules_cc//cc/toolchains/actions:compile_actions"], + args = select({ + "@platforms//cpu:x86_64": ["-m64"], + "//conditions:default": [], + }), + visibility = ["//visibility:public"], +) + +cc_feature_constraint( + name = "not_gnu11", + none_of = ["//features/markers:gnu11"], +) + +cc_feature_constraint( + name = "is_gnu11", + all_of = ["//features/markers:gnu11"], +) + +cc_args( + name = "c_std_c11_args", + actions = ["@rules_cc//cc/toolchains/actions:c_compile_actions"], + args = ["-std=c11"], + requires_any_of = [":not_gnu11"], +) + +cc_args( + name = "c_std_gnu11_args", + actions = ["@rules_cc//cc/toolchains/actions:c_compile_actions"], + args = ["-std=gnu11"], + requires_any_of = [":is_gnu11"], +) + +cc_args( + name = "default_cxx_compile_flags_args", + actions = ["@rules_cc//cc/toolchains/actions:cpp_compile_actions"], + args = ["-std=c++17"] + + select({ + "@platforms//os:qnx": [ + "-D_QNX_SOURCE", + ], + "//conditions:default": [], + }), +) + +cc_feature_constraint( + name = "is_dbg", + all_of = ["//features/markers:dbg"], +) + +cc_args( + name = "dbg_compile_flags_args", + actions = ["@rules_cc//cc/toolchains/actions:compile_actions"], + args = [ + "-Og", + "-g3", + ], + requires_any_of = [":is_dbg"], +) + +cc_feature_constraint( + name = "is_opt", + all_of = ["//features/markers:opt"], +) + +cc_feature_constraint( + name = "is_fastbuild", + all_of = ["//features/markers:fastbuild"], +) + +cc_args( + name = "opt_compile_flags_args", + actions = ["@rules_cc//cc/toolchains/actions:compile_actions"], + args = [ + "-O2", + "-DNDEBUG", + ], + requires_any_of = [ + ":is_opt", + ":is_fastbuild", + ], +) + +cc_feature( + name = "default_compile_flags", + args = [ + ":default_compile_flags_args", + ":target_cpu_flags_args", + ":c_std_c11_args", + ":c_std_gnu11_args", + ":default_cxx_compile_flags_args", + ":dbg_compile_flags_args", + ":opt_compile_flags_args", + ], + feature_name = "default_compile_flags", + visibility = ["//visibility:public"], +) diff --git a/features/default_link_flags/BUILD b/features/default_link_flags/BUILD new file mode 100644 index 0000000..ce841cb --- /dev/null +++ b/features/default_link_flags/BUILD @@ -0,0 +1,90 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") +load("@rules_cc//cc/toolchains:feature_constraint.bzl", "cc_feature_constraint") + +cc_feature_constraint( + name = "is_opt", + all_of = ["//features/markers:opt"], +) + +# compress-debug only when neither opt nor fastbuild +cc_feature_constraint( + name = "not_opt_not_fastbuild", + none_of = [ + "//features/markers:opt", + "//features/markers:fastbuild", + ], +) + +# Linux base link flags +cc_args( + name = "linux_base_link_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + args = [ + "-lm", + "-ldl", + "-lrt", + "-static-libstdc++", + "-static-libgcc", + ], + visibility = ["//visibility:public"], +) + +cc_args( + name = "linux_opt_link_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + args = ["-Wl,--gc-sections"], + requires_any_of = [":is_opt"], + visibility = ["//visibility:public"], +) + +cc_args( + name = "linux_debug_compress_link_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + args = ["-Wl,--compress-debug-sections=zlib"], + requires_any_of = [":not_opt_not_fastbuild"], + visibility = ["//visibility:public"], +) + +# QNX static link flags (the -V routing flag stays in toolchain config template) +cc_args( + name = "qnx_base_link_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + args = [ + "-Wl,-z,relro", + "-Wl,-z,now", + "-Wl,--push-state", + "-Wl,--as-needed", + "-lc++", + "-lm", + "-Wl,--pop-state", + ], + visibility = ["//visibility:public"], +) + +cc_feature( + name = "default_link_flags", + args = select({ + "@platforms//os:linux": [ + ":linux_base_link_args", + ":linux_opt_link_args", + ":linux_debug_compress_link_args", + ], + "@platforms//os:qnx": [":qnx_base_link_args"], + }), + feature_name = "default_link_flags", + visibility = ["//visibility:public"], +) diff --git a/features/dependency_file/BUILD b/features/dependency_file/BUILD new file mode 100644 index 0000000..dedcb16 --- /dev/null +++ b/features/dependency_file/BUILD @@ -0,0 +1,88 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") +load("@rules_cc//cc/toolchains:feature_constraint.bzl", "cc_feature_constraint") + +_COMPILE_ACTIONS = [ + "@rules_cc//cc/toolchains/actions:assemble", + "@rules_cc//cc/toolchains/actions:preprocess_assemble", + "@rules_cc//cc/toolchains/actions:c_compile", + "@rules_cc//cc/toolchains/actions:cpp_compile", + "@rules_cc//cc/toolchains/actions:cpp_module_compile", + "@rules_cc//cc/toolchains/actions:cpp_header_parsing", +] + +# Linux: standard -MD -MF flags +cc_args( + name = "dependency_file_linux_args", + actions = _COMPILE_ACTIONS, + args = [ + "-MD", + "-MF", + "{dependency_file}", + ], + format = {"dependency_file": "@rules_cc//cc/toolchains/variables:dependency_file"}, + requires_not_none = "@rules_cc//cc/toolchains/variables:dependency_file", + visibility = ["//visibility:public"], +) + +# QNX: QCC-wrapped flags — explicit filename (dependency_file_named_implicitly is NOT active) +cc_feature_constraint( + name = "not_dep_named_implicitly", + none_of = ["//features/markers:dependency_file_named_implicitly"], +) + +cc_args( + name = "dependency_file_qnx_explicit_args", + actions = _COMPILE_ACTIONS, + args = [ + "-Wc,-MD,{dependency_file}", + "-Wp,-MD,{dependency_file}", + ], + format = {"dependency_file": "@rules_cc//cc/toolchains/variables:dependency_file"}, + requires_any_of = [":not_dep_named_implicitly"], + requires_not_none = "@rules_cc//cc/toolchains/variables:dependency_file", + visibility = ["//visibility:public"], +) + +# QNX: QCC-wrapped flags — implicit filename (dependency_file_named_implicitly IS active) +cc_feature_constraint( + name = "is_dep_named_implicitly", + all_of = ["//features/markers:dependency_file_named_implicitly"], +) + +cc_args( + name = "dependency_file_qnx_implicit_args", + actions = _COMPILE_ACTIONS, + args = [ + "-Wc,-MD", + "-Wp,-MD", + ], + requires_any_of = [":is_dep_named_implicitly"], + visibility = ["//visibility:public"], +) + +cc_feature( + name = "dependency_file", + args = select({ + "@platforms//os:linux": [":dependency_file_linux_args"], + "@platforms//os:qnx": [ + ":dependency_file_qnx_explicit_args", + ":dependency_file_qnx_implicit_args", + ], + }), + feature_name = "dependency_file", + visibility = ["//visibility:public"], +) diff --git a/features/fission_support/BUILD b/features/fission_support/BUILD new file mode 100644 index 0000000..dbd63c8 --- /dev/null +++ b/features/fission_support/BUILD @@ -0,0 +1,31 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "fission_support_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + args = ["-Wl,--gdb-index"], + requires_not_none = "@rules_cc//cc/toolchains/variables:is_using_fission", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "fission_support", + args = [":fission_support_args"], + feature_name = "fission_support", + requires_any_of = ["//features/linux_platform"], + visibility = ["//visibility:public"], +) diff --git a/features/force_pic_flags/BUILD b/features/force_pic_flags/BUILD new file mode 100644 index 0000000..7470791 --- /dev/null +++ b/features/force_pic_flags/BUILD @@ -0,0 +1,31 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "force_pic_flags_args", + actions = ["@rules_cc//cc/toolchains/actions:cpp_link_executable"], + args = ["-pie"], + requires_not_none = "@rules_cc//cc/toolchains/variables:force_pic", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "force_pic_flags", + args = [":force_pic_flags_args"], + feature_name = "force_pic_flags", + requires_any_of = ["//features/linux_platform"], + visibility = ["//visibility:public"], +) diff --git a/features/fully_static_link/BUILD b/features/fully_static_link/BUILD new file mode 100644 index 0000000..15096d4 --- /dev/null +++ b/features/fully_static_link/BUILD @@ -0,0 +1,34 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "fully_static_link_args", + actions = [ + "@rules_cc//cc/toolchains/actions:cpp_link_executable", + "@rules_cc//cc/toolchains/actions:cpp_link_dynamic_library", + "@rules_cc//cc/toolchains/actions:cpp_link_nodeps_dynamic_library", + ], + args = ["-static"], + visibility = ["//visibility:public"], +) + +cc_feature( + name = "fully_static_link", + args = [":fully_static_link_args"], + feature_name = "fully_static_link", + requires_any_of = ["//features/linux_platform"], + visibility = ["//visibility:public"], +) diff --git a/features/gcc_coverage_map_format/BUILD b/features/gcc_coverage_map_format/BUILD new file mode 100644 index 0000000..c5dae21 --- /dev/null +++ b/features/gcc_coverage_map_format/BUILD @@ -0,0 +1,62 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") +load("@rules_cc//cc/toolchains:feature_set.bzl", "cc_feature_set") + +cc_feature_set( + name = "requires_coverage", + all_of = ["//features/markers:coverage"], + visibility = ["//visibility:public"], +) + +cc_args( + name = "coverage_compile_args", + actions = [ + "@rules_cc//cc/toolchains/actions:c_compile", + "@rules_cc//cc/toolchains/actions:cpp_compile", + "@rules_cc//cc/toolchains/actions:cpp_module_compile", + "@rules_cc//cc/toolchains/actions:preprocess_assemble", + ], + args = [ + "-fprofile-arcs", + "-ftest-coverage", + ], + visibility = ["//visibility:public"], +) + +cc_args( + name = "linux_coverage_link_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + args = ["--coverage"], + visibility = ["//visibility:public"], +) + +cc_args( + name = "qnx_coverage_link_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + args = ["-lgcov"], + visibility = ["//visibility:public"], +) + +cc_feature( + name = "gcc_coverage_map_format", + args = [":coverage_compile_args"] + select({ + "@platforms//os:linux": [":linux_coverage_link_args"], + "@platforms//os:qnx": [":qnx_coverage_link_args"], + }), + feature_name = "gcc_coverage_map_format", + requires_any_of = [":requires_coverage"], + visibility = ["//visibility:public"], +) diff --git a/features/include_paths/BUILD b/features/include_paths/BUILD new file mode 100644 index 0000000..676bab8 --- /dev/null +++ b/features/include_paths/BUILD @@ -0,0 +1,59 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "quote_include_paths_args", + actions = ["@rules_cc//cc/toolchains/actions:source_compile_actions"], + args = [ + "-iquote", + "{quote_include_paths}", + ], + format = {"quote_include_paths": "@rules_cc//cc/toolchains/variables:quote_include_paths"}, + iterate_over = "@rules_cc//cc/toolchains/variables:quote_include_paths", + visibility = ["//visibility:public"], +) + +cc_args( + name = "include_paths_args", + actions = ["@rules_cc//cc/toolchains/actions:source_compile_actions"], + args = ["-I{include_paths}"], + format = {"include_paths": "@rules_cc//cc/toolchains/variables:include_paths"}, + iterate_over = "@rules_cc//cc/toolchains/variables:include_paths", + visibility = ["//visibility:public"], +) + +cc_args( + name = "system_include_paths_args", + actions = ["@rules_cc//cc/toolchains/actions:source_compile_actions"], + args = [ + "-isystem", + "{system_include_paths}", + ], + format = {"system_include_paths": "@rules_cc//cc/toolchains/variables:system_include_paths"}, + iterate_over = "@rules_cc//cc/toolchains/variables:system_include_paths", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "include_paths", + args = [ + ":quote_include_paths_args", + ":include_paths_args", + ":system_include_paths_args", + ], + feature_name = "include_paths", + visibility = ["//visibility:public"], +) diff --git a/features/includes/BUILD b/features/includes/BUILD new file mode 100644 index 0000000..c685308 --- /dev/null +++ b/features/includes/BUILD @@ -0,0 +1,36 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "includes_args", + actions = ["@rules_cc//cc/toolchains/actions:source_compile_actions"], + args = [ + "-include", + "{includes}", + ], + format = {"includes": "@rules_cc//cc/toolchains/variables:includes"}, + iterate_over = "@rules_cc//cc/toolchains/variables:includes", + requires_not_none = "@rules_cc//cc/toolchains/variables:includes", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "includes", + args = [":includes_args"], + feature_name = "includes", + requires_any_of = ["//features/linux_platform"], + visibility = ["//visibility:public"], +) diff --git a/features/libraries_to_link/BUILD b/features/libraries_to_link/BUILD new file mode 100644 index 0000000..09e96a5 --- /dev/null +++ b/features/libraries_to_link/BUILD @@ -0,0 +1,105 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") +load("@rules_cc//cc/toolchains:nested_args.bzl", "cc_nested_args") + +# static_library: dispatch on is_whole_archive +cc_nested_args( + name = "whole_archive_static_library", + args = [ + "-Wl,--whole-archive", + "{lib_name}", + "-Wl,--no-whole-archive", + ], + format = {"lib_name": "@rules_cc//cc/toolchains/variables:libraries_to_link.name"}, + requires_true = "@rules_cc//cc/toolchains/variables:libraries_to_link.is_whole_archive", +) + +cc_nested_args( + name = "non_whole_archive_static_library", + args = ["{lib_name}"], + format = {"lib_name": "@rules_cc//cc/toolchains/variables:libraries_to_link.name"}, + requires_false = "@rules_cc//cc/toolchains/variables:libraries_to_link.is_whole_archive", +) + +cc_nested_args( + name = "static_library_dispatch", + nested = [ + ":whole_archive_static_library", + ":non_whole_archive_static_library", + ], + requires_equal = "@rules_cc//cc/toolchains/variables:libraries_to_link.type", + requires_equal_value = "static_library", +) + +cc_nested_args( + name = "object_file_entry", + args = ["{lib_name}"], + format = {"lib_name": "@rules_cc//cc/toolchains/variables:libraries_to_link.name"}, + requires_equal = "@rules_cc//cc/toolchains/variables:libraries_to_link.type", + requires_equal_value = "object_file", +) + +cc_nested_args( + name = "object_file_group_entry", + args = ["{object_file}"], + format = {"object_file": "@rules_cc//cc/toolchains/variables:libraries_to_link.object_files"}, + iterate_over = "@rules_cc//cc/toolchains/variables:libraries_to_link.object_files", + requires_equal = "@rules_cc//cc/toolchains/variables:libraries_to_link.type", + requires_equal_value = "object_file_group", +) + +cc_nested_args( + name = "dynamic_library_entry", + args = ["-l{lib_name}"], + format = {"lib_name": "@rules_cc//cc/toolchains/variables:libraries_to_link.name"}, + requires_equal = "@rules_cc//cc/toolchains/variables:libraries_to_link.type", + requires_equal_value = "dynamic_library", +) + +cc_nested_args( + name = "versioned_dynamic_library_entry", + args = ["-l:{lib_name}"], + format = {"lib_name": "@rules_cc//cc/toolchains/variables:libraries_to_link.name"}, + requires_equal = "@rules_cc//cc/toolchains/variables:libraries_to_link.type", + requires_equal_value = "versioned_dynamic_library", +) + +cc_nested_args( + name = "iterate_libraries", + iterate_over = "@rules_cc//cc/toolchains/variables:libraries_to_link", + nested = [ + ":static_library_dispatch", + ":object_file_entry", + ":object_file_group_entry", + ":dynamic_library_entry", + ":versioned_dynamic_library_entry", + ], +) + +cc_args( + name = "libraries_to_link_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + nested = [":iterate_libraries"], + requires_not_none = "@rules_cc//cc/toolchains/variables:libraries_to_link", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "libraries_to_link", + args = [":libraries_to_link_args"], + feature_name = "libraries_to_link", + visibility = ["//visibility:public"], +) diff --git a/features/library_search_directories/BUILD b/features/library_search_directories/BUILD new file mode 100644 index 0000000..1f65428 --- /dev/null +++ b/features/library_search_directories/BUILD @@ -0,0 +1,32 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "library_search_directories_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + args = ["-L{library_search_directories}"], + format = {"library_search_directories": "@rules_cc//cc/toolchains/variables:library_search_directories"}, + iterate_over = "@rules_cc//cc/toolchains/variables:library_search_directories", + requires_not_none = "@rules_cc//cc/toolchains/variables:library_search_directories", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "library_search_directories", + args = [":library_search_directories_args"], + feature_name = "library_search_directories", + visibility = ["//visibility:public"], +) diff --git a/features/linker_param_file/BUILD b/features/linker_param_file/BUILD new file mode 100644 index 0000000..cc097bb --- /dev/null +++ b/features/linker_param_file/BUILD @@ -0,0 +1,34 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "linker_param_file_args", + actions = [ + "@rules_cc//cc/toolchains/actions:link_actions", + "@rules_cc//cc/toolchains/actions:ar_actions", + ], + args = ["@{linker_param_file}"], + format = {"linker_param_file": "@rules_cc//cc/toolchains/variables:linker_param_file"}, + requires_not_none = "@rules_cc//cc/toolchains/variables:linker_param_file", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "linker_param_file", + args = [":linker_param_file_args"], + feature_name = "linker_param_file", + visibility = ["//visibility:public"], +) diff --git a/features/linkstamps/BUILD b/features/linkstamps/BUILD new file mode 100644 index 0000000..c403cd1 --- /dev/null +++ b/features/linkstamps/BUILD @@ -0,0 +1,33 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "linkstamps_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + args = ["{linkstamp_paths}"], + format = {"linkstamp_paths": "@rules_cc//cc/toolchains/variables:linkstamp_paths"}, + iterate_over = "@rules_cc//cc/toolchains/variables:linkstamp_paths", + requires_not_none = "@rules_cc//cc/toolchains/variables:linkstamp_paths", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "linkstamps", + args = [":linkstamps_args"], + feature_name = "linkstamps", + requires_any_of = ["//features/linux_platform"], + visibility = ["//visibility:public"], +) diff --git a/features/linux_platform/BUILD b/features/linux_platform/BUILD new file mode 100644 index 0000000..78fd395 --- /dev/null +++ b/features/linux_platform/BUILD @@ -0,0 +1,20 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_feature( + name = "linux_platform", + feature_name = "linux_platform", + visibility = ["//visibility:public"], +) diff --git a/features/markers/BUILD b/features/markers/BUILD new file mode 100644 index 0000000..92899bf --- /dev/null +++ b/features/markers/BUILD @@ -0,0 +1,94 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +# Capability markers — enabled state is set at toolchain assembly, not here. +cc_feature( + name = "no_legacy_features", + feature_name = "no_legacy_features", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "supports_pic", + feature_name = "supports_pic", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "supports_dynamic_linker", + feature_name = "supports_dynamic_linker", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "dbg", + feature_name = "dbg", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "opt", + feature_name = "opt", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "fastbuild", + feature_name = "fastbuild", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "coverage", + feature_name = "coverage", + visibility = ["//visibility:public"], +) + +## Linux specficic +cc_feature( + name = "supports_fission", + feature_name = "supports_fission", + requires_any_of = ["//features/linux_platform"], + visibility = ["//visibility:public"], +) + +cc_feature( + name = "supports_header_path_normalization", + feature_name = "supports_header_path_normalization", + requires_any_of = ["//features/linux_platform"], + visibility = ["//visibility:public"], +) + +cc_feature( + name = "gnu11", + feature_name = "gnu11", + requires_any_of = ["//features/linux_platform"], + visibility = ["//visibility:public"], +) + +## QNX only +cc_feature( + name = "dependency_file_named_implicitly", + feature_name = "dependency_file_named_implicitly", + requires_any_of = ["//features/qnx_platform"], + visibility = ["//visibility:public"], +) + +# Linked runtime control +cc_feature( + name = "static_link_cpp_runtimes", + feature_name = "static_link_cpp_runtimes", + visibility = ["//visibility:public"], +) diff --git a/features/minimal_warnings/BUILD b/features/minimal_warnings/BUILD new file mode 100644 index 0000000..ec91111 --- /dev/null +++ b/features/minimal_warnings/BUILD @@ -0,0 +1,89 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +# Linux +cc_args( + name = "linux_minimal_warnings_args", + actions = [ + "@rules_cc//cc/toolchains/actions:c_compile_actions", + "@rules_cc//cc/toolchains/actions:cpp_compile_actions", + ], + args = [ + "-Wall", + "-Wcast-align", + "-Wcast-qual", + "-Wformat-nonliteral", + "-Wformat-signedness", + "-Wformat=2", + "-Wmissing-format-attribute", + "-Wpointer-arith", + "-Wredundant-decls", + "-Wreturn-local-addr", + "-Wsizeof-array-argument", + "-Wundef", + "-Wwrite-strings", + ], + visibility = ["//visibility:public"], +) + +cc_args( + name = "linux_minimal_warnings_c_args", + actions = ["@rules_cc//cc/toolchains/actions:c_compile_actions"], + args = [ + "-Wbad-function-cast", + "-Wmissing-prototypes", + ], + visibility = ["//visibility:public"], +) + +cc_args( + name = "linux_minimal_warnings_cxx_args", + actions = ["@rules_cc//cc/toolchains/actions:cpp_compile_actions"], + args = [ + "-Wodr", + "-Wreorder", + ], + visibility = ["//visibility:public"], +) + +# QNX +cc_args( + name = "qnx_minimal_warnings_args", + actions = [ + "@rules_cc//cc/toolchains/actions:c_compile_actions", + "@rules_cc//cc/toolchains/actions:cpp_compile_actions", + ], + args = [ + "-Wall", + "-Wno-error=deprecated-declarations", + "-Wno-error=mismatched-new-delete", + ], + visibility = ["//visibility:public"], +) + +cc_feature( + name = "minimal_warnings", + args = select({ + "@platforms//os:linux": [ + ":linux_minimal_warnings_args", + ":linux_minimal_warnings_c_args", + ":linux_minimal_warnings_cxx_args", + ], + "@platforms//os:qnx": [":qnx_minimal_warnings_args"], + }), + feature_name = "minimal_warnings", + visibility = ["//visibility:public"], +) diff --git a/features/output_execpath_flags/BUILD b/features/output_execpath_flags/BUILD new file mode 100644 index 0000000..e9cbcdb --- /dev/null +++ b/features/output_execpath_flags/BUILD @@ -0,0 +1,34 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "output_execpath_flags_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + args = [ + "-o", + "{output_execpath}", + ], + format = {"output_execpath": "@rules_cc//cc/toolchains/variables:output_execpath"}, + requires_not_none = "@rules_cc//cc/toolchains/variables:output_execpath", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "output_execpath_flags", + args = [":output_execpath_flags_args"], + feature_name = "output_execpath_flags", + visibility = ["//visibility:public"], +) diff --git a/features/per_object_debug_info/BUILD b/features/per_object_debug_info/BUILD new file mode 100644 index 0000000..1eb288b --- /dev/null +++ b/features/per_object_debug_info/BUILD @@ -0,0 +1,40 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "per_object_debug_info_args", + actions = [ + "@rules_cc//cc/toolchains/actions:assemble", + "@rules_cc//cc/toolchains/actions:preprocess_assemble", + "@rules_cc//cc/toolchains/actions:c_compile", + "@rules_cc//cc/toolchains/actions:cpp_compile", + "@rules_cc//cc/toolchains/actions:cpp_module_codegen", + ], + args = [ + "-gsplit-dwarf", + "-g", + ], + requires_not_none = "@rules_cc//cc/toolchains/variables:per_object_debug_info_file", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "per_object_debug_info", + args = [":per_object_debug_info_args"], + feature_name = "per_object_debug_info", + requires_any_of = ["//features/linux_platform"], + visibility = ["//visibility:public"], +) diff --git a/features/pic/BUILD b/features/pic/BUILD new file mode 100644 index 0000000..5d0c864 --- /dev/null +++ b/features/pic/BUILD @@ -0,0 +1,37 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "pic_args", + actions = [ + "@rules_cc//cc/toolchains/actions:assemble", + "@rules_cc//cc/toolchains/actions:preprocess_assemble", + "@rules_cc//cc/toolchains/actions:c_compile", + "@rules_cc//cc/toolchains/actions:cpp_compile", + "@rules_cc//cc/toolchains/actions:cpp_module_codegen", + "@rules_cc//cc/toolchains/actions:cpp_module_compile", + ], + args = ["-fPIC"], + requires_not_none = "@rules_cc//cc/toolchains/variables:pic", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "pic", + args = [":pic_args"], + feature_name = "pic", + visibility = ["//visibility:public"], +) diff --git a/features/preprocessor_defines/BUILD b/features/preprocessor_defines/BUILD new file mode 100644 index 0000000..b7bf963 --- /dev/null +++ b/features/preprocessor_defines/BUILD @@ -0,0 +1,31 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "preprocessor_defines_args", + actions = ["@rules_cc//cc/toolchains/actions:source_compile_actions"], + args = ["-D{preprocessor_defines}"], + format = {"preprocessor_defines": "@rules_cc//cc/toolchains/variables:preprocessor_defines"}, + iterate_over = "@rules_cc//cc/toolchains/variables:preprocessor_defines", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "preprocessor_defines", + args = [":preprocessor_defines_args"], + feature_name = "preprocessor_defines", + visibility = ["//visibility:public"], +) diff --git a/features/qnx_platform/BUILD b/features/qnx_platform/BUILD new file mode 100644 index 0000000..7eb012c --- /dev/null +++ b/features/qnx_platform/BUILD @@ -0,0 +1,20 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_feature( + name = "qnx_platform", + feature_name = "qnx_platform", + visibility = ["//visibility:public"], +) diff --git a/features/random_seed/BUILD b/features/random_seed/BUILD new file mode 100644 index 0000000..d0c33d1 --- /dev/null +++ b/features/random_seed/BUILD @@ -0,0 +1,36 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "random_seed_args", + actions = [ + "@rules_cc//cc/toolchains/actions:c_compile", + "@rules_cc//cc/toolchains/actions:cpp_compile", + "@rules_cc//cc/toolchains/actions:cpp_module_compile", + "@rules_cc//cc/toolchains/actions:cpp_module_codegen", + ], + args = ["-frandom-seed={output_file}"], + format = {"output_file": "@rules_cc//cc/toolchains/variables:output_file"}, + requires_not_none = "@rules_cc//cc/toolchains/variables:output_file", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "random_seed", + args = [":random_seed_args"], + feature_name = "random_seed", + visibility = ["//visibility:public"], +) diff --git a/features/runtime_library_search_directories/BUILD b/features/runtime_library_search_directories/BUILD new file mode 100644 index 0000000..5c248fd --- /dev/null +++ b/features/runtime_library_search_directories/BUILD @@ -0,0 +1,74 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") +load("@rules_cc//cc/toolchains:nested_args.bzl", "cc_nested_args") + +# Linux: fork rpath on is_cc_test +cc_nested_args( + name = "linux_rpath_test", + args = ["-Wl,-rpath,$ORIGIN/{dir}"], + format = {"dir": "@rules_cc//cc/toolchains/variables:runtime_library_search_directories"}, + requires_true = "@rules_cc//cc/toolchains/variables:is_cc_test", +) + +cc_nested_args( + name = "linux_rpath_exec", + args = ["-Wl,-rpath,$EXEC_ORIGIN/{dir}"], + format = {"dir": "@rules_cc//cc/toolchains/variables:runtime_library_search_directories"}, + requires_false = "@rules_cc//cc/toolchains/variables:is_cc_test", +) + +cc_nested_args( + name = "linux_rpath_iterate", + iterate_over = "@rules_cc//cc/toolchains/variables:runtime_library_search_directories", + nested = [ + ":linux_rpath_test", + ":linux_rpath_exec", + ], +) + +cc_args( + name = "runtime_dirs_linux_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + nested = [":linux_rpath_iterate"], + requires_not_none = "@rules_cc//cc/toolchains/variables:runtime_library_search_directories", + visibility = ["//visibility:public"], +) + +# QNX: always $EXEC_ORIGIN, QCC uses -Wl,-rpath +cc_nested_args( + name = "qnx_rpath_iterate", + args = ["-Wl,-rpath,$EXEC_ORIGIN/{dir}"], + format = {"dir": "@rules_cc//cc/toolchains/variables:runtime_library_search_directories"}, + iterate_over = "@rules_cc//cc/toolchains/variables:runtime_library_search_directories", +) + +cc_args( + name = "runtime_dirs_qnx_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + nested = [":qnx_rpath_iterate"], + requires_not_none = "@rules_cc//cc/toolchains/variables:runtime_library_search_directories", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "runtime_library_search_directories", + args = select({ + "@platforms//os:linux": [":runtime_dirs_linux_args"], + "@platforms//os:qnx": [":runtime_dirs_qnx_args"], + }), + feature_name = "runtime_library_search_directories", + visibility = ["//visibility:public"], +) diff --git a/features/shared_flag/BUILD b/features/shared_flag/BUILD new file mode 100644 index 0000000..8b5d30d --- /dev/null +++ b/features/shared_flag/BUILD @@ -0,0 +1,29 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "shared_flag_args", + actions = ["@rules_cc//cc/toolchains/actions:dynamic_library_link_actions"], + args = ["-shared"], + visibility = ["//visibility:public"], +) + +cc_feature( + name = "shared_flag", + args = [":shared_flag_args"], + feature_name = "shared_flag", + visibility = ["//visibility:public"], +) diff --git a/features/static_libgcc/BUILD b/features/static_libgcc/BUILD new file mode 100644 index 0000000..4d03679 --- /dev/null +++ b/features/static_libgcc/BUILD @@ -0,0 +1,40 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") +load("@rules_cc//cc/toolchains:feature_constraint.bzl", "cc_feature_constraint") + +cc_feature_constraint( + name = "is_static_link_cpp_runtimes", + all_of = ["//features/markers:static_link_cpp_runtimes"], +) + +cc_args( + name = "static_libgcc_args", + actions = [ + "@rules_cc//cc/toolchains/actions:cpp_link_executable", + "@rules_cc//cc/toolchains/actions:cpp_link_dynamic_library", + ], + args = ["-static-libgcc"], + requires_any_of = [":is_static_link_cpp_runtimes"], + visibility = ["//visibility:public"], +) + +cc_feature( + name = "static_libgcc", + args = [":static_libgcc_args"], + feature_name = "static_libgcc", + requires_any_of = ["//features/linux_platform"], + visibility = ["//visibility:public"], +) diff --git a/features/strict_warnings/BUILD b/features/strict_warnings/BUILD new file mode 100644 index 0000000..cae06a4 --- /dev/null +++ b/features/strict_warnings/BUILD @@ -0,0 +1,71 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "linux_strict_warnings_args", + actions = [ + "@rules_cc//cc/toolchains/actions:c_compile_actions", + "@rules_cc//cc/toolchains/actions:cpp_compile_actions", + ], + args = [ + "-Wbool-compare", + "-Wconversion", + "-Wdouble-promotion", + "-Wextra", + "-Winvalid-pch", + "-Wlogical-not-parentheses", + "-Wlogical-op", + "-Wpedantic", + "-Wswitch-bool", + "-Wunused-but-set-parameter", + "-Wvla", + ], + visibility = ["//visibility:public"], +) + +cc_args( + name = "linux_strict_warnings_cxx_args", + actions = ["@rules_cc//cc/toolchains/actions:cpp_compile_actions"], + args = ["-Wnarrowing"], + visibility = ["//visibility:public"], +) + +cc_args( + name = "qnx_strict_warnings_args", + actions = [ + "@rules_cc//cc/toolchains/actions:c_compile_actions", + "@rules_cc//cc/toolchains/actions:cpp_compile_actions", + ], + args = [ + "-Wextra", + "-Wpedantic", + ], + visibility = ["//visibility:public"], +) + +cc_feature( + name = "strict_warnings", + args = select({ + "@platforms//os:linux": [ + ":linux_strict_warnings_args", + ":linux_strict_warnings_cxx_args", + ], + "@platforms//os:qnx": [":qnx_strict_warnings_args"], + }), + feature_name = "strict_warnings", + implies = ["//features/minimal_warnings:minimal_warnings"], + visibility = ["//visibility:public"], +) diff --git a/features/strip_debug_symbols/BUILD b/features/strip_debug_symbols/BUILD new file mode 100644 index 0000000..fa8877e --- /dev/null +++ b/features/strip_debug_symbols/BUILD @@ -0,0 +1,31 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "strip_debug_symbols_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + args = ["-Wl,-S"], + requires_not_none = "@rules_cc//cc/toolchains/variables:strip_debug_symbols", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "strip_debug_symbols", + args = [":strip_debug_symbols_args"], + feature_name = "strip_debug_symbols", + requires_any_of = ["//features/linux_platform"], + visibility = ["//visibility:public"], +) diff --git a/features/sysroot_link_flags/BUILD b/features/sysroot_link_flags/BUILD new file mode 100644 index 0000000..d447655 --- /dev/null +++ b/features/sysroot_link_flags/BUILD @@ -0,0 +1,34 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") +load("@rules_cc//cc/toolchains/args:sysroot.bzl", "cc_sysroot") + +cc_sysroot( + name = "sysroot_link_flags_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + args = ["-Wl,--sysroot={sysroot}"], + requires_not_none = "@rules_cc//cc/toolchains/variables:sysroot", + sysroot = "@rules_cc//cc/toolchains/variables:sysroot", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "sysroot_link_flags", + args = [":sysroot_link_flags_args"], + feature_name = "sysroot_link_flags", + requires_any_of = ["//features/linux_platform"], + visibility = ["//visibility:public"], +) + +# ERROR diff --git a/features/unfiltered_compile_flags/BUILD b/features/unfiltered_compile_flags/BUILD new file mode 100644 index 0000000..8ea2d00 --- /dev/null +++ b/features/unfiltered_compile_flags/BUILD @@ -0,0 +1,37 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "unfiltered_compile_flags_args", + actions = [ + "@rules_cc//cc/toolchains/actions:c_compile_actions", + "@rules_cc//cc/toolchains/actions:cpp_compile_actions", + ], + args = [ + "-D__DATE__=\"redacted\"", + "-D__TIMESTAMP__=\"redacted\"", + "-D__TIME__=\"redacted\"", + "-Wno-builtin-macro-redefined", + ], + visibility = ["//visibility:public"], +) + +cc_feature( + name = "unfiltered_compile_flags", + args = [":unfiltered_compile_flags_args"], + feature_name = "unfiltered_compile_flags", + visibility = ["//visibility:public"], +) diff --git a/features/use_pthread/BUILD b/features/use_pthread/BUILD new file mode 100644 index 0000000..9edc560 --- /dev/null +++ b/features/use_pthread/BUILD @@ -0,0 +1,30 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "use_pthread_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + args = ["-pthread"], + visibility = ["//visibility:public"], +) + +cc_feature( + name = "use_pthread", + args = [":use_pthread_args"], + feature_name = "use_pthread", + requires_any_of = ["//features/linux_platform"], + visibility = ["//visibility:public"], +) diff --git a/features/user_compile_flags/BUILD b/features/user_compile_flags/BUILD new file mode 100644 index 0000000..f5a6702 --- /dev/null +++ b/features/user_compile_flags/BUILD @@ -0,0 +1,32 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "user_compile_flags_args", + actions = ["@rules_cc//cc/toolchains/actions:compile_actions"], + args = ["{user_compile_flags}"], + format = {"user_compile_flags": "@rules_cc//cc/toolchains/variables:user_compile_flags"}, + iterate_over = "@rules_cc//cc/toolchains/variables:user_compile_flags", + requires_not_none = "@rules_cc//cc/toolchains/variables:user_compile_flags", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "user_compile_flags", + args = [":user_compile_flags_args"], + feature_name = "user_compile_flags", + visibility = ["//visibility:public"], +) diff --git a/features/user_link_flags/BUILD b/features/user_link_flags/BUILD new file mode 100644 index 0000000..d4e30f2 --- /dev/null +++ b/features/user_link_flags/BUILD @@ -0,0 +1,32 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "user_link_flags_args", + actions = ["@rules_cc//cc/toolchains/actions:link_actions"], + args = ["{user_link_flags}"], + format = {"user_link_flags": "@rules_cc//cc/toolchains/variables:user_link_flags"}, + iterate_over = "@rules_cc//cc/toolchains/variables:user_link_flags", + requires_not_none = "@rules_cc//cc/toolchains/variables:user_link_flags", + visibility = ["//visibility:public"], +) + +cc_feature( + name = "user_link_flags", + args = [":user_link_flags_args"], + feature_name = "user_link_flags", + visibility = ["//visibility:public"], +) diff --git a/features/warnings_as_errors/BUILD b/features/warnings_as_errors/BUILD new file mode 100644 index 0000000..4065051 --- /dev/null +++ b/features/warnings_as_errors/BUILD @@ -0,0 +1,48 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +load("@rules_cc//cc/toolchains:args.bzl", "cc_args") +load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature") + +cc_args( + name = "linux_warnings_as_errors_args", + actions = [ + "@rules_cc//cc/toolchains/actions:c_compile_actions", + "@rules_cc//cc/toolchains/actions:cpp_compile_actions", + ], + args = [ + "-Werror", + "-Wno-error=deprecated-declarations", + ], + visibility = ["//visibility:public"], +) + +cc_args( + name = "qnx_warnings_as_errors_args", + actions = [ + "@rules_cc//cc/toolchains/actions:c_compile_actions", + "@rules_cc//cc/toolchains/actions:cpp_compile_actions", + ], + args = ["-Werror"], + visibility = ["//visibility:public"], +) + +cc_feature( + name = "warnings_as_errors", + args = select({ + "@platforms//os:linux": [":linux_warnings_as_errors_args"], + "@platforms//os:qnx": [":qnx_warnings_as_errors_args"], + }), + feature_name = "warnings_as_errors", + visibility = ["//visibility:public"], +)