diff options
author | 2018-05-22 06:38:08 -0700 | |
---|---|---|
committer | 2018-05-22 06:39:30 -0700 | |
commit | 5c4f3b59fb4aa06da2c368c764cf0d9056ab287a (patch) | |
tree | 335cfaab0b3950556127cc8af24841a80fb29a20 /src/test/py | |
parent | d34f306eb5ad3bc6060bac5611956c3b2da6f2d1 (diff) |
CROSSTOOL: Make C++ compiled and linked artifact name pattern configurable
This change makes Bazel respect artifact name patterns specified in
CROSSTOOL.
Users cannot specify any arbitrary name pattern, it must ends with allowed
extensions. For example, for dynamic library, it can only ends with .so,
.dylib or .dll, otherwise Bazel throws an error.
Change-Id: I21d9e6fa7c3a282e1a9b8ff29679b00925cddb33
PiperOrigin-RevId: 197553413
Diffstat (limited to 'src/test/py')
-rw-r--r-- | src/test/py/bazel/bazel_windows_cpp_test.py | 83 |
1 files changed, 41 insertions, 42 deletions
diff --git a/src/test/py/bazel/bazel_windows_cpp_test.py b/src/test/py/bazel/bazel_windows_cpp_test.py index 71d8231dc2..1b85d5f1df 100644 --- a/src/test/py/bazel/bazel_windows_cpp_test.py +++ b/src/test/py/bazel/bazel_windows_cpp_test.py @@ -140,8 +140,8 @@ class BazelWindowsCppTest(test_base.TestBase): # TODO(pcloudy): change suffixes to .lib and .dll after making DLL # extensions correct on # Windows. - import_library = os.path.join(bazel_bin, 'libA.ifso') - shared_library = os.path.join(bazel_bin, 'libA.so') + import_library = os.path.join(bazel_bin, 'A.if.lib') + shared_library = os.path.join(bazel_bin, 'A.dll') def_file = os.path.join(bazel_bin, 'A.def') self.assertTrue(os.path.exists(import_library)) self.assertTrue(os.path.exists(shared_library)) @@ -161,8 +161,8 @@ class BazelWindowsCppTest(test_base.TestBase): # TODO(pcloudy): change suffixes to .lib and .dll after making DLL # extensions correct on # Windows. - import_library = os.path.join(bazel_bin, 'libB.ifso') - shared_library = os.path.join(bazel_bin, 'libB.so') + import_library = os.path.join(bazel_bin, 'B.if.lib') + shared_library = os.path.join(bazel_bin, 'B.dll') def_file = os.path.join(bazel_bin, 'B.def') self.assertTrue(os.path.exists(import_library)) self.assertTrue(os.path.exists(shared_library)) @@ -176,7 +176,7 @@ class BazelWindowsCppTest(test_base.TestBase): '--features=no_windows_export_all_symbols' ]) self.AssertExitCode(exit_code, 1, stderr) - self.assertIn('output \'libB.ifso\' was not created', ''.join(stderr)) + self.assertIn('output \'B.if.lib\' was not created', ''.join(stderr)) def testBuildCcBinaryWithDependenciesDynamicallyLinked(self): self.createProjectFiles() @@ -191,15 +191,15 @@ class BazelWindowsCppTest(test_base.TestBase): # extensions correct on # Windows. # a_import_library - self.assertTrue(os.path.exists(os.path.join(bazel_bin, 'libA.ifso'))) + self.assertTrue(os.path.exists(os.path.join(bazel_bin, 'A.if.lib'))) # a_shared_library - self.assertTrue(os.path.exists(os.path.join(bazel_bin, 'libA.so'))) + self.assertTrue(os.path.exists(os.path.join(bazel_bin, 'A.dll'))) # a_def_file self.assertFalse(os.path.exists(os.path.join(bazel_bin, 'A.def'))) # b_import_library - self.assertTrue(os.path.exists(os.path.join(bazel_bin, 'libB.ifso'))) + self.assertTrue(os.path.exists(os.path.join(bazel_bin, 'B.if.lib'))) # b_shared_library - self.assertTrue(os.path.exists(os.path.join(bazel_bin, 'libB.so'))) + self.assertTrue(os.path.exists(os.path.join(bazel_bin, 'B.dll'))) # b_def_file self.assertTrue(os.path.exists(os.path.join(bazel_bin, 'B.def'))) # c_exe @@ -220,11 +220,11 @@ class BazelWindowsCppTest(test_base.TestBase): exit_code, _, stderr = self.RunBazel(['build', '//main:main']) self.AssertExitCode(exit_code, 0, stderr) - # Test if libA.so and libB.so are copied to the directory of main.exe + # Test if A.dll and B.dll are copied to the directory of main.exe main_bin = os.path.join(bazel_bin, 'main/main.exe') self.assertTrue(os.path.exists(main_bin)) - self.assertTrue(os.path.exists(os.path.join(bazel_bin, 'main/libA.so'))) - self.assertTrue(os.path.exists(os.path.join(bazel_bin, 'main/libB.so'))) + self.assertTrue(os.path.exists(os.path.join(bazel_bin, 'main/A.dll'))) + self.assertTrue(os.path.exists(os.path.join(bazel_bin, 'main/B.dll'))) # Run the binary to see if it runs successfully exit_code, stdout, stderr = self.RunProgram([main_bin]) @@ -245,12 +245,12 @@ class BazelWindowsCppTest(test_base.TestBase): ]) # //main:main depends on both //lib:A and //:A, - # their dlls are both called libA.so, + # their dlls are both called A.dll, # so there should be a conflict error exit_code, _, stderr = self.RunBazel(['build', '//main:main']) self.AssertExitCode(exit_code, 1, stderr) self.assertIn( - 'ERROR: file \'main/libA.so\' is generated by these conflicting ' + 'ERROR: file \'main/A.dll\' is generated by these conflicting ' 'actions:', ''.join(stderr)) def testBuildDifferentCcBinariesDependOnConflictDLLs(self): @@ -282,7 +282,7 @@ class BazelWindowsCppTest(test_base.TestBase): exit_code, _, stderr = self.RunBazel(['build', '//main:other_main']) self.AssertExitCode(exit_code, 1, stderr) self.assertIn( - 'ERROR: file \'main/libA.so\' is generated by these conflicting ' + 'ERROR: file \'main/A.dll\' is generated by these conflicting ' 'actions:', ''.join(stderr)) def testDynamicLinkingMSVCRT(self): @@ -337,7 +337,7 @@ class BazelWindowsCppTest(test_base.TestBase): 'main/BUILD', [ 'cc_binary(', - ' name = "main.so",', + ' name = "main.dll",', ' srcs = ["main.cc"],', ' deps = ["//:B"],', # Transitively depends on //:A ' linkstatic = 1,' @@ -348,19 +348,19 @@ class BazelWindowsCppTest(test_base.TestBase): bazel_bin = self.getBazelInfo('bazel-bin') exit_code, _, stderr = self.RunBazel([ - 'build', '//main:main.so', '--output_groups=default,interface_library' + 'build', '//main:main.dll', '--output_groups=default,interface_library' ]) self.AssertExitCode(exit_code, 0, stderr) - main_library = os.path.join(bazel_bin, 'main/main.so') - main_interface = os.path.join(bazel_bin, 'main/main.ifso') - def_file = os.path.join(bazel_bin, 'main/main.so.def') + main_library = os.path.join(bazel_bin, 'main/main.dll') + main_interface = os.path.join(bazel_bin, 'main/main.dll.if.lib') + def_file = os.path.join(bazel_bin, 'main/main.dll.def') self.assertTrue(os.path.exists(main_library)) self.assertTrue(os.path.exists(main_interface)) self.assertTrue(os.path.exists(def_file)) - # libA.so and libB.so should not be copied. - self.assertFalse(os.path.exists(os.path.join(bazel_bin, 'main/libA.so'))) - self.assertFalse(os.path.exists(os.path.join(bazel_bin, 'main/libB.so'))) + # A.dll and B.dll should not be copied. + self.assertFalse(os.path.exists(os.path.join(bazel_bin, 'main/A.dll'))) + self.assertFalse(os.path.exists(os.path.join(bazel_bin, 'main/B.dll'))) self.AssertFileContentContains(def_file, 'hello_A') self.AssertFileContentContains(def_file, 'hello_B') self.AssertFileContentContains(def_file, 'hello_C') @@ -371,7 +371,7 @@ class BazelWindowsCppTest(test_base.TestBase): 'main/BUILD', [ 'cc_binary(', - ' name = "main.so",', + ' name = "main.dll",', ' srcs = ["main.cc"],', ' deps = ["//:B"],', # Transitively depends on //:A ' linkstatic = 0,' @@ -382,19 +382,19 @@ class BazelWindowsCppTest(test_base.TestBase): bazel_bin = self.getBazelInfo('bazel-bin') exit_code, _, stderr = self.RunBazel([ - 'build', '//main:main.so', '--output_groups=default,interface_library' + 'build', '//main:main.dll', '--output_groups=default,interface_library' ]) self.AssertExitCode(exit_code, 0, stderr) - main_library = os.path.join(bazel_bin, 'main/main.so') - main_interface = os.path.join(bazel_bin, 'main/main.ifso') - def_file = os.path.join(bazel_bin, 'main/main.so.def') + main_library = os.path.join(bazel_bin, 'main/main.dll') + main_interface = os.path.join(bazel_bin, 'main/main.dll.if.lib') + def_file = os.path.join(bazel_bin, 'main/main.dll.def') self.assertTrue(os.path.exists(main_library)) self.assertTrue(os.path.exists(main_interface)) self.assertTrue(os.path.exists(def_file)) - # libA.so and libB.so should be copied. - self.assertTrue(os.path.exists(os.path.join(bazel_bin, 'main/libA.so'))) - self.assertTrue(os.path.exists(os.path.join(bazel_bin, 'main/libB.so'))) + # A.dll and B.dll should be copied. + self.assertTrue(os.path.exists(os.path.join(bazel_bin, 'main/A.dll'))) + self.assertTrue(os.path.exists(os.path.join(bazel_bin, 'main/B.dll'))) # hello_A and hello_B should not be exported. self.AssertFileContentNotContains(def_file, 'hello_A') self.AssertFileContentNotContains(def_file, 'hello_B') @@ -406,7 +406,7 @@ class BazelWindowsCppTest(test_base.TestBase): 'main/BUILD', [ 'cc_binary(', - ' name = "main.so",', + ' name = "main.dll",', ' srcs = ["main.cc"],', ' deps = ["//:B"],', # Transitively depends on //:A ' linkstatic = 1,' @@ -416,12 +416,12 @@ class BazelWindowsCppTest(test_base.TestBase): bazel_bin = self.getBazelInfo('bazel-bin') exit_code, _, stderr = self.RunBazel( - ['build', '//main:main.so', '--output_groups=def_file']) + ['build', '//main:main.dll', '--output_groups=def_file']) self.AssertExitCode(exit_code, 0, stderr) # Although windows_export_all_symbols is not specified for this target, # we should still be able to get the DEF file by def_file output group. - def_file = os.path.join(bazel_bin, 'main/main.so.def') + def_file = os.path.join(bazel_bin, 'main/main.dll.def') self.assertTrue(os.path.exists(def_file)) self.AssertFileContentContains(def_file, 'hello_A') self.AssertFileContentContains(def_file, 'hello_B') @@ -441,7 +441,6 @@ class BazelWindowsCppTest(test_base.TestBase): self.ScratchFile('WORKSPACE') self.ScratchFile('lib.cc', ['void hello() {}']) self.ScratchFile('my_lib.def', [ - 'LIBRARY liblib.so', 'EXPORTS', ' ?hello@@YAXXZ', ]) @@ -453,7 +452,7 @@ class BazelWindowsCppTest(test_base.TestBase): ')', '', 'cc_binary(', - ' name = "lib.so",', + ' name = "lib_dy.dll",', ' srcs = ["lib.cc"],', ' win_def_file = "my_lib.def",', ' linkshared = 1,', @@ -468,13 +467,13 @@ class BazelWindowsCppTest(test_base.TestBase): ]) bazel_bin = self.getBazelInfo('bazel-bin') - lib_ifso = os.path.join(bazel_bin, 'liblib.ifso') + lib_if = os.path.join(bazel_bin, 'lib.if.lib') lib_def = os.path.join(bazel_bin, 'lib.def') - self.assertTrue(os.path.exists(lib_ifso)) + self.assertTrue(os.path.exists(lib_if)) self.assertFalse(os.path.exists(lib_def)) # Test specifying DEF file in cc_binary - exit_code, _, stderr = self.RunBazel(['build', '//:lib.so', '-s']) + exit_code, _, stderr = self.RunBazel(['build', '//:lib_dy.dll', '-s']) self.AssertExitCode(exit_code, 0, stderr) self.assertIn('/DEF:my_lib.def', ''.join(stderr)) @@ -483,9 +482,9 @@ class BazelWindowsCppTest(test_base.TestBase): self.ScratchFile('BUILD', [ 'cc_import(', ' name = "a_import",', - ' static_library = "A.a",', - ' shared_library = "A.so",', - ' interface_library = "A.ifso",', + ' static_library = "A.lib",', + ' shared_library = "A.dll",', + ' interface_library = "A.if.lib",', ' hdrs = ["a.h"],', ' alwayslink = 1,', ')', |