• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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# Example showing how to create a custom Starlark rule that rules_cc can depend on
16
17load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
18load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
19load("@rules_cc//cc:cc_library.bzl", "cc_library")
20load("//examples/my_c_archive:my_c_archive.bzl", "my_c_archive")
21load("//examples/my_c_compile:my_c_compile.bzl", "my_c_compile")
22
23licenses(["notice"])
24
25cc_binary(
26    name = "main",
27    srcs = ["main.c"],
28    deps = [":archive"],
29)
30
31my_c_archive(
32    name = "archive",
33    object = ":object",
34    deps = [":bar"],
35)
36
37my_c_compile(
38    name = "object",
39    src = "foo.c",
40)
41
42cc_library(
43    name = "bar",
44    srcs = ["bar.c"],
45)
46
47bzl_library(
48    name = "my_c_archive_bzl",
49    srcs = ["my_c_archive.bzl"],
50    visibility = ["//visibility:private"],
51)
52