From 9e9d6ed5f69cc899906e3eeaf7adc8cb5a001164 Mon Sep 17 00:00:00 2001 From: Yun Peng Date: Thu, 30 Jun 2016 14:44:24 +0000 Subject: 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 --- tools/cpp/wrapper/bin/pydir/msvc_cl.py | 2 +- tools/cpp/wrapper/bin/pydir/msvc_link.py | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'tools/cpp/wrapper/bin') 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 -- cgit v1.2.3