Skip to content

Commit

Permalink
Enable compiler_param_file in Windows MSVC toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed Jan 5, 2023
1 parent e2759df commit cb33a36
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/test/py/bazel/bazel_windows_cpp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,9 @@ def testDynamicLinkingMSVCRT(self):
paramfile = os.path.join(bazel_output,
'x64_windows-fastbuild/bin/A_0.dll-2.params')
self.AssertExitCode(exit_code, 0, stderr)
self.assertIn('/MD', ''.join(stderr))
self.AssertFileContentContains(paramfile, '/MD')
self.AssertFileContentContains(paramfile, '/DEFAULTLIB:msvcrt.lib')
self.assertNotIn('/MT', ''.join(stderr))
self.AssertFileContentNotContains(paramfile, '/MT')
self.AssertFileContentNotContains(paramfile, '/DEFAULTLIB:libcmt.lib')

# Test build in debug mode.
Expand All @@ -400,9 +400,9 @@ def testDynamicLinkingMSVCRT(self):
paramfile = os.path.join(bazel_output,
'x64_windows-dbg/bin/A_0.dll-2.params')
self.AssertExitCode(exit_code, 0, stderr)
self.assertIn('/MDd', ''.join(stderr))
self.AssertFileContentContains(paramfile, '/MDd')
self.AssertFileContentContains(paramfile, '/DEFAULTLIB:msvcrtd.lib')
self.assertNotIn('/MTd', ''.join(stderr))
self.AssertFileContentNotContains(paramfile, '/MTd')
self.AssertFileContentNotContains(paramfile, '/DEFAULTLIB:libcmtd.lib')

def testStaticLinkingMSVCRT(self):
Expand Down Expand Up @@ -1071,6 +1071,22 @@ def testBuildArm64CppBinaryWithMsvcCLAndCpuArm64Windows(self):
self.AssertExitCode(exit_code, 0, stderr)
self.assertIn('arm64\\cl.exe', ''.join(stderr))

def testLongCompileCommandLines(self):
self.CreateWorkspaceWithDefaultRepos('WORKSPACE')
self.ScratchFile('BUILD', [
'cc_library(',
' name = "long",',
' srcs = ["long.cc"],',
' includes = 110 * [450 * "aa"]',
')',
])
self.ScratchFile('long.cc')

exit_code, _, stderr = self.RunBazel([
'build', '--verbose_failures', '//:long'
])
self.AssertExitCode(exit_code, 0, stderr)


if __name__ == '__main__':
unittest.main()
1 change: 1 addition & 0 deletions tools/cpp/windows_cc_toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ def _impl(ctx):

compiler_param_file_feature = feature(
name = "compiler_param_file",
enabled = True,
)

copy_dynamic_libraries_to_binary_feature = feature(
Expand Down

0 comments on commit cb33a36

Please sign in to comment.