aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build
diff options
context:
space:
mode:
authorGravatar elenairina <elenairina@google.com>2017-08-09 15:03:30 +0200
committerGravatar Marcel Hlopko <hlopko@google.com>2017-08-10 13:38:46 +0200
commitfb20d20580456280b0e64162fdbe86dafca75388 (patch)
tree67cdaf51a0a9e958042c63d8ba0b16f375a3f886 /src/main/java/com/google/devtools/build
parent01122f4d23998ef682f229def584f132a8748d00 (diff)
Add reexports to cc rules and cc_shared_library and cc_static_library semantics
Diffstat (limited to 'src/main/java/com/google/devtools/build')
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCcSharedLibrary.java26
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCcSharedLibraryRule.java49
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCcStaticLibrary.java26
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCcStaticLibraryRule.java50
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCppRuleClasses.java3
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcSharedLibrary.java37
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcStaticLibrary.java37
7 files changed, 228 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCcSharedLibrary.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCcSharedLibrary.java
new file mode 100644
index 0000000000..05a65ea18c
--- /dev/null
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCcSharedLibrary.java
@@ -0,0 +1,26 @@
+// Copyright 2017 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.bazel.rules.cpp;
+
+import com.google.devtools.build.lib.rules.cpp.CcSharedLibrary;
+
+/**
+ * {@code cc_shared_library} rule with Bazel semantics.
+ */
+public class BazelCcSharedLibrary extends CcSharedLibrary {
+ public BazelCcSharedLibrary() {
+ super(BazelCppSemantics.INSTANCE);
+ }
+}
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCcSharedLibraryRule.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCcSharedLibraryRule.java
new file mode 100644
index 0000000000..8143a6caa3
--- /dev/null
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCcSharedLibraryRule.java
@@ -0,0 +1,49 @@
+// Copyright 2017 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.bazel.rules.cpp;
+
+import static com.google.devtools.build.lib.bazel.rules.cpp.BazelCppRuleClasses.DEPS_ALLOWED_RULES;
+import static com.google.devtools.build.lib.packages.Attribute.attr;
+import static com.google.devtools.build.lib.packages.BuildType.LABEL_LIST;
+import static com.google.devtools.build.lib.syntax.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.bazel.rules.cpp.BazelCppRuleClasses.CcBaseRule;
+import com.google.devtools.build.lib.packages.RuleClass;
+import com.google.devtools.build.lib.packages.RuleClass.Builder;
+
+/** Rule definition for the cc_shared_library rule. */
+public final class BazelCcSharedLibraryRule implements RuleDefinition {
+ @Override
+ public RuleClass build(Builder builder, RuleDefinitionEnvironment env) {
+ return builder
+ .add(attr("reexport_deps", LABEL_LIST)
+ .allowedRuleClasses(DEPS_ALLOWED_RULES)
+ .allowedFileTypes())
+ .add(attr("linkopts", STRING_LIST))
+ .build();
+ }
+
+ @Override
+ public Metadata getMetadata() {
+ return RuleDefinition.Metadata.builder()
+ .name("cc_shared_library")
+ .ancestors(CcBaseRule.class, BaseRuleClasses.MakeVariableExpandingRule.class)
+ .factoryClass(BazelCcSharedLibrary.class)
+ .build();
+ }
+}
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCcStaticLibrary.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCcStaticLibrary.java
new file mode 100644
index 0000000000..d7a9c2fc6e
--- /dev/null
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCcStaticLibrary.java
@@ -0,0 +1,26 @@
+// Copyright 2017 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.bazel.rules.cpp;
+
+import com.google.devtools.build.lib.rules.cpp.CcStaticLibrary;
+
+/**
+ * {@code cc_static_library} rule with Bazel semantics.
+ */
+public class BazelCcStaticLibrary extends CcStaticLibrary {
+ public BazelCcStaticLibrary() {
+ super(BazelCppSemantics.INSTANCE);
+ }
+}
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCcStaticLibraryRule.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCcStaticLibraryRule.java
new file mode 100644
index 0000000000..a05f4423df
--- /dev/null
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCcStaticLibraryRule.java
@@ -0,0 +1,50 @@
+// Copyright 2017 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.bazel.rules.cpp;
+
+import static com.google.devtools.build.lib.bazel.rules.cpp.BazelCppRuleClasses.DEPS_ALLOWED_RULES;
+import static com.google.devtools.build.lib.packages.Attribute.attr;
+import static com.google.devtools.build.lib.packages.BuildType.LABEL_LIST;
+import static com.google.devtools.build.lib.syntax.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.bazel.rules.cpp.BazelCppRuleClasses.CcBaseRule;
+import com.google.devtools.build.lib.packages.RuleClass;
+import com.google.devtools.build.lib.packages.RuleClass.Builder;
+
+/** Rule definition for the cc_static_library rule. */
+public final class BazelCcStaticLibraryRule implements RuleDefinition {
+ @Override
+ public RuleClass build(Builder builder, RuleDefinitionEnvironment env) {
+ return builder
+ .add(
+ attr("reexport_deps", LABEL_LIST)
+ .allowedRuleClasses(DEPS_ALLOWED_RULES)
+ .allowedFileTypes())
+ .add(attr("linkopts", STRING_LIST))
+ .build();
+ }
+
+ @Override
+ public Metadata getMetadata() {
+ return RuleDefinition.Metadata.builder()
+ .name("cc_shared_library")
+ .ancestors(CcBaseRule.class, BaseRuleClasses.MakeVariableExpandingRule.class)
+ .factoryClass(BazelCcStaticLibrary.class)
+ .build();
+ }
+}
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCppRuleClasses.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCppRuleClasses.java
index d8bd7f7697..206e439b0f 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCppRuleClasses.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCppRuleClasses.java
@@ -339,6 +339,9 @@ public class BazelCppRuleClasses {
.allowedRuleClasses(DEPS_ALLOWED_RULES)
.allowedFileTypes(CppFileTypes.LINKER_SCRIPT)
.skipAnalysisTimeFileTypeCheck())
+ .add(attr("reexport_deps", LABEL_LIST)
+ .allowedRuleClasses(DEPS_ALLOWED_RULES)
+ .allowedFileTypes())
/*<!-- #BLAZE_RULE($cc_rule).ATTRIBUTE(linkopts) -->
Add these flags to the C++ linker command.
Subject to <a href="make-variables.html">"Make" variable</a> substitution,
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcSharedLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcSharedLibrary.java
new file mode 100644
index 0000000000..289c4fdb4f
--- /dev/null
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcSharedLibrary.java
@@ -0,0 +1,37 @@
+// 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 com.google.devtools.build.lib.analysis.ConfiguredTarget;
+import com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder;
+import com.google.devtools.build.lib.analysis.RuleConfiguredTargetFactory;
+import com.google.devtools.build.lib.analysis.RuleContext;
+
+/**
+ * A ConfiguredTarget for <code>cc_shared_library</code> rules.
+ */
+public abstract class CcSharedLibrary implements RuleConfiguredTargetFactory {
+ private final CppSemantics semantics;
+
+ protected CcSharedLibrary(CppSemantics semantics) {
+ this.semantics = semantics;
+ }
+
+ @Override
+ public ConfiguredTarget create(RuleContext context)
+ throws RuleErrorException, InterruptedException {
+ return new RuleConfiguredTargetBuilder(context).build();
+ }
+} \ No newline at end of file
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcStaticLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcStaticLibrary.java
new file mode 100644
index 0000000000..d7c2006a0d
--- /dev/null
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcStaticLibrary.java
@@ -0,0 +1,37 @@
+// Copyright 2017 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 com.google.devtools.build.lib.analysis.ConfiguredTarget;
+import com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder;
+import com.google.devtools.build.lib.analysis.RuleConfiguredTargetFactory;
+import com.google.devtools.build.lib.analysis.RuleContext;
+
+/**
+ * A ConfiguredTarget for <code>cc_static_library</code> rules.
+ */
+public abstract class CcStaticLibrary implements RuleConfiguredTargetFactory {
+ private final CppSemantics semantics;
+
+ protected CcStaticLibrary(CppSemantics semantics) {
+ this.semantics = semantics;
+ }
+
+ @Override
+ public ConfiguredTarget create(RuleContext context)
+ throws RuleErrorException, InterruptedException {
+ return new RuleConfiguredTargetBuilder(context).build();
+ }
+} \ No newline at end of file