Skip to content

Instantly share code, notes, and snippets.

@oquenchil
oquenchil / features.bzl
Created August 12, 2022 10:14
Features Clang Modules
def get_header_module_features(target_cpu):
"""Returns features that control header modules."""
# Configure header modules:
#
# We have different features for module consumers and producers:
# 'header_modules' is enabled for targets that support being compiled as a
# header module.
# 'use_header_modules' is enabled for targets that want to use the provided
@oquenchil
oquenchil / cc_static_library.bzl
Created October 6, 2021 12:55
Example cc_static_library.bzl
"""Provides a rule that outputs a monolithic static library."""
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")
TOOLS_CPP_REPO = "@bazel_tools"
def _cc_static_library_impl(ctx):
output_lib = ctx.actions.declare_file("{}.a".format(ctx.attr.name))
output_flags = ctx.actions.declare_file("{}.link".format(ctx.attr.name))
@oquenchil
oquenchil / legacy_cc_starlark_api_shim.bzl
Last active October 30, 2020 15:30
Utility functions that replace old C++ Starlark API using the new API.
# Copyright 2019 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,