Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge upstream #1

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
import com.google.devtools.build.lib.rules.core.CoreRules;
import com.google.devtools.build.lib.rules.cpp.CcSharedLibraryRule;
import com.google.devtools.build.lib.rules.cpp.CcStarlarkInternal;
import com.google.devtools.build.lib.rules.cpp.CcStaticLibraryRule;
import com.google.devtools.build.lib.rules.cpp.proto.CcProtoLibraryRule;
import com.google.devtools.build.lib.rules.objc.BazelObjcStarlarkInternal;
import com.google.devtools.build.lib.rules.objc.ObjcStarlarkInternal;
Expand Down Expand Up @@ -505,6 +506,7 @@ public void init(ConfiguredRuleClassProvider.Builder builder) {
builder.addRuleDefinition(new AndroidNdkRepositoryRule());
builder.addRuleDefinition(new LocalConfigPlatformRule());
builder.addRuleDefinition(new CcSharedLibraryRule());
builder.addRuleDefinition(new CcStaticLibraryRule());

try {
builder.addWorkspaceFileSuffix(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,18 @@ public final class BuildLanguageOptions extends OptionsBase {
+ "cc_shared_library will be available")
public boolean experimentalCcSharedLibrary;

@Option(
name = "experimental_cc_static_library",
defaultValue = "false",
documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS,
effectTags = {OptionEffectTag.BUILD_FILE_SEMANTICS, OptionEffectTag.LOADING_AND_ANALYSIS},
metadataTags = {
OptionMetadataTag.EXPERIMENTAL,
},
help =
"If set to true, rule attributes and Starlark API methods needed for the rule "
+ "cc_static_library will be available")
public boolean experimentalCcStaticLibrary;
@Option(
name = "incompatible_require_linker_input_cc_api",
defaultValue = "true",
Expand Down Expand Up @@ -724,6 +736,7 @@ public StarlarkSemantics toStarlarkSemantics() {
.setBool(EXPERIMENTAL_GOOGLE_LEGACY_API, experimentalGoogleLegacyApi)
.setBool(EXPERIMENTAL_PLATFORMS_API, experimentalPlatformsApi)
.setBool(EXPERIMENTAL_CC_SHARED_LIBRARY, experimentalCcSharedLibrary)
.setBool(EXPERIMENTAL_CC_STATIC_LIBRARY, experimentalCcStaticLibrary)
.setBool(EXPERIMENTAL_REPO_REMOTE_EXEC, experimentalRepoRemoteExec)
.setBool(EXPERIMENTAL_DISABLE_EXTERNAL_PACKAGE, experimentalDisableExternalPackage)
.setBool(EXPERIMENTAL_SIBLING_REPOSITORY_LAYOUT, experimentalSiblingRepositoryLayout)
Expand Down Expand Up @@ -814,6 +827,7 @@ public StarlarkSemantics toStarlarkSemantics() {
public static final String EXPERIMENTAL_BZL_VISIBILITY = "+experimental_bzl_visibility";
public static final String CHECK_BZL_VISIBILITY = "+check_bzl_visibility";
public static final String EXPERIMENTAL_CC_SHARED_LIBRARY = "-experimental_cc_shared_library";
public static final String EXPERIMENTAL_CC_STATIC_LIBRARY = "-experimental_cc_static_library";
public static final String EXPERIMENTAL_DISABLE_EXTERNAL_PACKAGE =
"-experimental_disable_external_package";
public static final String EXPERIMENTAL_ENABLE_ANDROID_MIGRATION_APIS =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,12 @@ public boolean checkExperimentalCcSharedLibrary(StarlarkThread thread) throws Ev
return thread.getSemantics().getBool(BuildLanguageOptions.EXPERIMENTAL_CC_SHARED_LIBRARY);
}

@Override
public boolean checkExperimentalCcStaticLibrary(StarlarkThread thread) throws EvalException {
isCalledFromStarlarkCcCommon(thread);
return thread.getSemantics().getBool(BuildLanguageOptions.EXPERIMENTAL_CC_STATIC_LIBRARY);
}

@Override
public boolean getIncompatibleDisableObjcLibraryTransition(StarlarkThread thread)
throws EvalException {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2014 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.
package com.google.devtools.build.lib.rules.cpp;

import static com.google.devtools.build.lib.packages.Attribute.attr;
import static com.google.devtools.build.lib.packages.Type.STRING_LIST;

import com.google.devtools.build.lib.analysis.BaseRuleClasses;
import com.google.devtools.build.lib.analysis.RuleDefinition;
import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment;
import com.google.devtools.build.lib.packages.RuleClass;

/** A dummy rule for <code>cc_static_library</code> rule. */
public class CcStaticLibraryRule implements RuleDefinition {
@Override
public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env) {
return builder
.add(
attr("tags", STRING_LIST)
.orderIndependent()
.taggable()
.nonconfigurable("low-level attribute, used in TargetUtils without configurations"))
.build();
}

@Override
public Metadata getMetadata() {
return Metadata.builder()
.name("cc_static_library")
.factoryClass(BaseRuleClasses.EmptyRuleConfiguredTargetFactory.class)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,13 @@ LinkerInputT createLinkerInput(
documented = false)
boolean checkExperimentalCcSharedLibrary(StarlarkThread thread) throws EvalException;

@StarlarkMethod(
name = "check_experimental_cc_static_library",
doc = "DO NOT USE. This is to guard use of cc_static_library.",
useStarlarkThread = true,
documented = false)
boolean checkExperimentalCcStaticLibrary(StarlarkThread thread) throws EvalException;

@StarlarkMethod(
name = "incompatible_disable_objc_library_transition",
useStarlarkThread = true,
Expand Down
3 changes: 3 additions & 0 deletions src/main/starlark/builtins_bzl/common/cc/action_names.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ CLIF_MATCH_ACTION_NAME = "clif-match"
# A string constant for the obj copy actions.
OBJ_COPY_ACTION_NAME = "objcopy_embed_data"

VALIDATE_STATIC_LIBRARY = "validate-static-library"

ACTION_NAMES = struct(
c_compile = C_COMPILE_ACTION_NAME,
cpp_compile = CPP_COMPILE_ACTION_NAME,
Expand Down Expand Up @@ -122,4 +124,5 @@ ACTION_NAMES = struct(
objcpp_compile = OBJCPP_COMPILE_ACTION_NAME,
clif_match = CLIF_MATCH_ACTION_NAME,
objcopy_embed_data = OBJ_COPY_ACTION_NAME,
validate_static_library = VALIDATE_STATIC_LIBRARY,
)
5 changes: 5 additions & 0 deletions src/main/starlark/builtins_bzl/common/cc/cc_common.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,10 @@ def _check_experimental_cc_shared_library():
cc_common_internal.check_private_api(allowlist = _PRIVATE_STARLARKIFICATION_ALLOWLIST)
return cc_common_internal.check_experimental_cc_shared_library()

def _check_experimental_cc_static_library():
cc_common_internal.check_private_api(allowlist = _PRIVATE_STARLARKIFICATION_ALLOWLIST)
return cc_common_internal.check_experimental_cc_static_library()

def _incompatible_disable_objc_library_transition():
cc_common_internal.check_private_api(allowlist = _PRIVATE_STARLARKIFICATION_ALLOWLIST)
return cc_common_internal.incompatible_disable_objc_library_transition()
Expand Down Expand Up @@ -908,6 +912,7 @@ cc_common = struct(
merge_compilation_contexts = _merge_compilation_contexts,
merge_linking_contexts = _merge_linking_contexts,
check_experimental_cc_shared_library = _check_experimental_cc_shared_library,
check_experimental_cc_static_library = _check_experimental_cc_static_library,
create_module_map = _create_module_map,
create_debug_context = _create_debug_context,
merge_debug_context = _merge_debug_context,
Expand Down
2 changes: 2 additions & 0 deletions src/main/starlark/builtins_bzl/common/cc/cc_helper.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,8 @@ cc_helper = struct(
linker_scripts = _linker_scripts,
copts_filter = _copts_filter,
package_exec_path = _package_exec_path,
get_base_name = _get_base_name,
replace_name = _replace_name,
repository_exec_path = _repository_exec_path,
proto_output_root = _proto_output_root,
cc_toolchain_build_variables = _cc_toolchain_build_variables,
Expand Down
Loading
Loading