Fix immutable frozen set bug in defs.bzl

When adding tags to a native cc_library rule that is created through a macro we
were not properly considering the case where the tags came from a different
file and therefore were frozen. This caused an error.

RELNOTES:none
PiperOrigin-RevId: 283039855
Change-Id: Id4cb45675a08ca65196f4f7771abdd5bb0705b79
This commit is contained in:
Googler 2019-11-29 04:18:45 -08:00 committed by Copybara-Service
parent 03ae87bea3
commit cfe68f6bc7
4 changed files with 55 additions and 1 deletions

View File

@ -21,7 +21,7 @@ _MIGRATION_TAG = "__CC_RULES_MIGRATION_DO_NOT_USE_WILL_BREAK__"
def _add_tags(attrs): def _add_tags(attrs):
if "tags" in attrs and attrs["tags"] != None: if "tags" in attrs and attrs["tags"] != None:
attrs["tags"] += [_MIGRATION_TAG] attrs["tags"] = attrs["tags"] + [_MIGRATION_TAG]
else: else:
attrs["tags"] = [_MIGRATION_TAG] attrs["tags"] = [_MIGRATION_TAG]
return attrs return attrs

View File

@ -0,0 +1,24 @@
# 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,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
load("//cc:defs.bzl", "cc_library")
load(":tags.bzl", "TAGS")
licenses(["notice"])
cc_library(
name = "foo",
srcs = ["foo.cc"],
tags = TAGS,
)

View File

@ -0,0 +1,13 @@
// 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,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

View File

@ -0,0 +1,17 @@
# 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,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Example tags defined in a separate file.
"""
TAGS = ["first_tag", "second_tag"]