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:defs.bzl", "cc_binary", "cc_library") 19load("//examples/my_c_archive:my_c_archive.bzl", "my_c_archive") 20load("//examples/my_c_compile:my_c_compile.bzl", "my_c_compile") 21 22licenses(["notice"]) 23 24cc_binary( 25 name = "main", 26 srcs = ["main.c"], 27 deps = [":archive"], 28) 29 30my_c_archive( 31 name = "archive", 32 object = ":object", 33 deps = [":bar"], 34) 35 36my_c_compile( 37 name = "object", 38 src = "foo.c", 39) 40 41cc_library( 42 name = "bar", 43 srcs = ["bar.c"], 44) 45 46bzl_library( 47 name = "my_c_archive_bzl", 48 srcs = ["my_c_archive.bzl"], 49 visibility = ["//visibility:private"], 50) 51