aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
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 /tools
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 'tools')
-rw-r--r--tools/cpp/wrapper/bin/pydir/msvc_cl.py2
-rw-r--r--tools/cpp/wrapper/bin/pydir/msvc_link.py14
2 files changed, 8 insertions, 8 deletions
diff --git a/tools/cpp/wrapper/bin/pydir/msvc_cl.py b/tools/cpp/wrapper/bin/pydir/msvc_cl.py
index 7983099311..ed6d966a6e 100644
--- a/tools/cpp/wrapper/bin/pydir/msvc_cl.py
+++ b/tools/cpp/wrapper/bin/pydir/msvc_cl.py
@@ -63,7 +63,7 @@ GCCPATTERNS = [
('-Wl,-rpath(.+)', []),
('-B(.+)', []),
('-static', []),
- ('-shared', []),
+ ('-shared', ['/DLL']),
('-std=(.+)', []),
]
diff --git a/tools/cpp/wrapper/bin/pydir/msvc_link.py b/tools/cpp/wrapper/bin/pydir/msvc_link.py
index e081ab622b..95f1315652 100644
--- a/tools/cpp/wrapper/bin/pydir/msvc_link.py
+++ b/tools/cpp/wrapper/bin/pydir/msvc_link.py
@@ -33,7 +33,7 @@ LINKPATTERNS = [
('-l(.+)', ['lib$0.so']),
('-L(.+)', ['/LIBPATH:$PATH0']),
('-static', []),
- ('-shared', []),
+ ('-shared', ['/DLL']),
('-whole-archive', []),
('-no-whole-archive', []),
('-rdynamic', []),
@@ -74,10 +74,10 @@ class MsvcLinker(msvc_tools.WindowsRunner):
for arg in parser.options:
if '/OUT:' in arg:
name = arg[5:]
- # if output file ends with .so.exe, we generate dll library.
- if name.endswith('.so.exe'):
+ # if output file ends with .so, we generate dll library.
+ if name.endswith('.so'):
default_args.append('/DLL')
- self.output_dll_file = os.path.normpath(name[0:-7])
+ self.output_dll_file = os.path.normpath(name[0:-3])
break
if not name:
raise msvc_tools.Error('No output file name specified!')
@@ -89,9 +89,9 @@ class MsvcLinker(msvc_tools.WindowsRunner):
with open(name, 'w'):
os.utime(name, None)
else:
- # If the output name ends in .so, .lo, or .a, it is a library, otherwise
+ # If the output name ends in .lo, or .a, it is a library, otherwise
# we need to use link to create an executable.
- if os.path.splitext(name)[1] not in ['.a', '.lo', '.so']:
+ if os.path.splitext(name)[1] not in ['.a', '.lo']:
tool = 'link'
if not parser.target_arch:
@@ -126,7 +126,7 @@ class MsvcLinker(msvc_tools.WindowsRunner):
ret_code = self.RunBinary(tool, default_args + parser.options,
parser.target_arch, parser)
if not ret_code and self.output_dll_file:
- shutil.copyfile(self.output_dll_file + '.so.exe',
+ shutil.copyfile(self.output_dll_file + '.so',
self.output_dll_file + '.dll')
return ret_code