aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp
diff options
context:
space:
mode:
authorGravatar plf <plf@google.com>2018-07-19 11:37:58 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-07-19 11:39:52 -0700
commit769f72eb475cea0f4113ac49dd66dc3fda0608de (patch)
treec84325774eb00fbb7dc3c7f7a67095159bfbe9ed /src/main/java/com/google/devtools/build/lib/bazel/rules/cpp
parentcfa35f3750d1ae37935bdf402a0cee306672795b (diff)
C++: Implements Skylark cc_common.compile()/link().
Working towards #4570. RELNOTES:none PiperOrigin-RevId: 205274676
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/bazel/rules/cpp')
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCcModule.java107
1 files changed, 107 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCcModule.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCcModule.java
new file mode 100644
index 0000000000..3b3d944e74
--- /dev/null
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCcModule.java
@@ -0,0 +1,107 @@
+// Copyright 2018 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.actions.Artifact;
+import com.google.devtools.build.lib.analysis.skylark.SkylarkRuleContext;
+import com.google.devtools.build.lib.rules.cpp.CcCompilationHelper.CompilationInfo;
+import com.google.devtools.build.lib.rules.cpp.CcCompilationInfo;
+import com.google.devtools.build.lib.rules.cpp.CcCompilationOutputs;
+import com.google.devtools.build.lib.rules.cpp.CcLinkParams;
+import com.google.devtools.build.lib.rules.cpp.CcLinkingHelper.LinkingInfo;
+import com.google.devtools.build.lib.rules.cpp.CcLinkingInfo;
+import com.google.devtools.build.lib.rules.cpp.CcModule;
+import com.google.devtools.build.lib.rules.cpp.CcModule.CcSkylarkInfo;
+import com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.FeatureConfiguration;
+import com.google.devtools.build.lib.rules.cpp.CcToolchainProvider;
+import com.google.devtools.build.lib.rules.cpp.CcToolchainVariables;
+import com.google.devtools.build.lib.rules.cpp.LinkerInputs.LibraryToLink;
+import com.google.devtools.build.lib.skylarkbuildapi.cpp.BazelCcModuleApi;
+import com.google.devtools.build.lib.syntax.EvalException;
+import com.google.devtools.build.lib.syntax.Runtime;
+import com.google.devtools.build.lib.syntax.SkylarkList;
+
+/**
+ * A module that contains Skylark utilities for C++ support.
+ *
+ * <p>This is a work in progress. The API is guarded behind --experimental_enable_cc_skylark_api.
+ * The API is under development and unstable.
+ */
+public class BazelCcModule extends CcModule
+ implements BazelCcModuleApi<
+ CcToolchainProvider,
+ FeatureConfiguration,
+ CompilationInfo,
+ CcCompilationInfo,
+ CcCompilationOutputs,
+ LinkingInfo,
+ CcLinkingInfo,
+ CcToolchainVariables,
+ LibraryToLink,
+ CcLinkParams,
+ CcSkylarkInfo> {
+
+ @Override
+ public CompilationInfo compile(
+ SkylarkRuleContext skylarkRuleContext,
+ FeatureConfiguration skylarkFeatureConfiguration,
+ CcToolchainProvider skylarkCcToolchainProvider,
+ SkylarkList<Artifact> sources,
+ SkylarkList<Artifact> headers,
+ Object skylarkIncludes,
+ Object skylarkCopts,
+ SkylarkList<CcCompilationInfo> ccCompilationInfos)
+ throws EvalException {
+ return BazelCcModule.compile(
+ BazelCppSemantics.INSTANCE,
+ skylarkRuleContext,
+ skylarkFeatureConfiguration,
+ skylarkCcToolchainProvider,
+ sources,
+ headers,
+ skylarkIncludes,
+ skylarkCopts,
+ /* generateNoPicOutputs= */ "conditionally",
+ /* generatePicOutputs= */ "conditionally",
+ /* skylarkAdditionalCompilationInputs= */ Runtime.NONE,
+ /* skylarkAdditionalIncludeScanningRoots= */ Runtime.NONE,
+ ccCompilationInfos,
+ /* purpose= */ Runtime.NONE);
+ }
+
+ @Override
+ public LinkingInfo link(
+ SkylarkRuleContext skylarkRuleContext,
+ FeatureConfiguration skylarkFeatureConfiguration,
+ CcToolchainProvider skylarkCcToolchainProvider,
+ CcCompilationOutputs ccCompilationOutputs,
+ Object skylarkLinkopts,
+ Object dynamicLibrary,
+ SkylarkList<CcLinkingInfo> skylarkCcLinkingInfos,
+ boolean neverLink)
+ throws InterruptedException, EvalException {
+ return BazelCcModule.link(
+ BazelCppSemantics.INSTANCE,
+ skylarkRuleContext,
+ skylarkFeatureConfiguration,
+ skylarkCcToolchainProvider,
+ ccCompilationOutputs,
+ skylarkLinkopts,
+ /* shouldCreateStaticLibraries= */ true,
+ dynamicLibrary,
+ skylarkCcLinkingInfos,
+ neverLink);
+ }
+}