aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Yun Peng <pcloudy@google.com>2016-06-30 14:44:24 +0000
committerGravatar Lukacs Berki <lberki@google.com>2016-07-01 07:09:12 +0000
commit9e9d6ed5f69cc899906e3eeaf7adc8cb5a001164 (patch)
tree49709abace8caadc3946cc6aa2d356f392a4193e /src
parent583c46160fcc3cbf185550aa7013ed7a8d3a39c6 (diff)
Make building dll less a hack on Windows
Add .dll as a shared library type like .so If we have target: cc_binary( name = "bar.dll", srcs = ["bar.cc"], linkshared = 1, ) Now we can build a dll using bazel build //foo:bar.dll If the target name is still bar.so, the wrapper script also build the dll by copying the output file to bar.dll. -- Change-Id: Ie3d1fb83965ddf691d0cc4734a61a0b0ce89d948 Reviewed-on: https://bazel-review.googlesource.com/#/c/3931 MOS_MIGRATED_REVID=126301390
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java8
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppFileTypes.java2
2 files changed, 6 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java
index c31f6ab688..061e6fea73 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java
@@ -185,9 +185,11 @@ public abstract class CcBinary implements RuleConfiguredTargetFactory {
// if cc_binary includes "linkshared=1", then gcc will be invoked with
// linkopt "-shared", which causes the result of linking to be a shared
// library. In this case, the name of the executable target should end
- // in ".so".
- PathFragment binaryPath =
- new PathFragment(ruleContext.getTarget().getName() + OsUtils.executableExtension());
+ // in ".so" or "dylib" or ".dll".
+ PathFragment binaryPath = new PathFragment(ruleContext.getTarget().getName());
+ if (!isLinkShared(ruleContext)) {
+ binaryPath = new PathFragment(binaryPath.getPathString() + OsUtils.executableExtension());
+ }
Artifact binary = ruleContext.getPackageRelativeArtifact(
binaryPath, ruleContext.getConfiguration().getBinDirectory());
CppLinkAction.Builder linkActionBuilder =
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppFileTypes.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppFileTypes.java
index c3bd853ff6..ef6e7a1570 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppFileTypes.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppFileTypes.java
@@ -116,7 +116,7 @@ public final class CppFileTypes {
};
- public static final FileType SHARED_LIBRARY = FileType.of(".so", ".dylib");
+ public static final FileType SHARED_LIBRARY = FileType.of(".so", ".dylib", ".dll");
public static final FileType INTERFACE_SHARED_LIBRARY = FileType.of(".ifso");
public static final FileType LINKER_SCRIPT = FileType.of(".ld", ".lds", ".ldscript");
// Matches shared libraries with version names in the extension, i.e.