aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar pcloudy <pcloudy@google.com>2018-06-13 01:46:40 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-06-13 01:47:46 -0700
commite2d6ba911a070e10421cb06f635bac0a4d981494 (patch)
treee4dac52dd105afebb841e45721004820815f3abe /src
parentb2ad4900c81ab767e736a118f755697a8958ed66 (diff)
Change generated DEF file name from <target name>.def to <target name>.gen.def
This helps avoid name conflicts when users want to generate DEF files by themselves. For example, when using a genrule to do that, people naturally name the def file as <target name>.def. Fixed https://github.com/bazelbuild/bazel/issues/5357 RELNOTES: None PiperOrigin-RevId: 200354303
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java4
-rw-r--r--src/test/py/bazel/bazel_windows_cpp_test.py16
2 files changed, 11 insertions, 9 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java
index 0b19fd488f..91013a9bbc 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java
@@ -1029,7 +1029,9 @@ public class CppHelper {
Artifact defParser,
ImmutableList<Artifact> objectFiles,
String dllName) {
- Artifact defFile = ruleContext.getBinArtifact(ruleContext.getLabel().getName() + ".def");
+ Artifact defFile = ruleContext.getBinArtifact(
+ ruleContext.getLabel().getName()
+ + ".gen" + Iterables.getOnlyElement(CppFileTypes.WINDOWS_DEF_FILE.getExtensions()));
CustomCommandLine.Builder argv = new CustomCommandLine.Builder();
for (Artifact objectFile : objectFiles) {
argv.addDynamicString(objectFile.getExecPathString());
diff --git a/src/test/py/bazel/bazel_windows_cpp_test.py b/src/test/py/bazel/bazel_windows_cpp_test.py
index 1626bb4349..3d21929205 100644
--- a/src/test/py/bazel/bazel_windows_cpp_test.py
+++ b/src/test/py/bazel/bazel_windows_cpp_test.py
@@ -142,7 +142,7 @@ class BazelWindowsCppTest(test_base.TestBase):
# Windows.
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')
+ def_file = os.path.join(bazel_bin, 'A.gen.def')
self.assertTrue(os.path.exists(import_library))
self.assertTrue(os.path.exists(shared_library))
# DEF file shouldn't be generated for //:A
@@ -163,7 +163,7 @@ class BazelWindowsCppTest(test_base.TestBase):
# Windows.
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')
+ def_file = os.path.join(bazel_bin, 'B.gen.def')
self.assertTrue(os.path.exists(import_library))
self.assertTrue(os.path.exists(shared_library))
# DEF file should be generated for //:B
@@ -195,13 +195,13 @@ class BazelWindowsCppTest(test_base.TestBase):
# a_shared_library
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')))
+ self.assertFalse(os.path.exists(os.path.join(bazel_bin, 'A.gen.def')))
# b_import_library
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, 'B.dll')))
# b_def_file
- self.assertTrue(os.path.exists(os.path.join(bazel_bin, 'B.def')))
+ self.assertTrue(os.path.exists(os.path.join(bazel_bin, 'B.gen.def')))
# c_exe
self.assertTrue(os.path.exists(os.path.join(bazel_bin, 'C.exe')))
@@ -362,7 +362,7 @@ class BazelWindowsCppTest(test_base.TestBase):
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')
+ def_file = os.path.join(bazel_bin, 'main/main.dll.gen.def')
self.assertTrue(os.path.exists(main_library))
self.assertTrue(os.path.exists(main_interface))
self.assertTrue(os.path.exists(def_file))
@@ -396,7 +396,7 @@ class BazelWindowsCppTest(test_base.TestBase):
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')
+ def_file = os.path.join(bazel_bin, 'main/main.dll.gen.def')
self.assertTrue(os.path.exists(main_library))
self.assertTrue(os.path.exists(main_interface))
self.assertTrue(os.path.exists(def_file))
@@ -429,7 +429,7 @@ class BazelWindowsCppTest(test_base.TestBase):
# 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.dll.def')
+ def_file = os.path.join(bazel_bin, 'main/main.dll.gen.def')
self.assertTrue(os.path.exists(def_file))
self.AssertFileContentContains(def_file, 'hello_A')
self.AssertFileContentContains(def_file, 'hello_B')
@@ -476,7 +476,7 @@ class BazelWindowsCppTest(test_base.TestBase):
bazel_bin = self.getBazelInfo('bazel-bin')
lib_if = os.path.join(bazel_bin, 'lib.if.lib')
- lib_def = os.path.join(bazel_bin, 'lib.def')
+ lib_def = os.path.join(bazel_bin, 'lib.gen.def')
self.assertTrue(os.path.exists(lib_if))
self.assertFalse(os.path.exists(lib_def))