Hi!

This is one of the last bits of functionality from the (dwindling)
pr-msvc-support branch in Libtool (the remaining bit is triggering
the ar-lib script with a new macro and some things related to that).

MSVC only recognizes .c and .cpp as source files, if you say e.g.
foo.cc, it will treat it as an object file. Many projects do not use
.cpp for its C++ files, so this patch will make it work for a bunch
of more projects.

I have not added .C to the list of C++ extensions as Windows typically
has a case insensitive file system, and then you don't know if the
user meant C or C++...

Ok for the msvc branch?

Cheers,
Peter
>From 8ad9d6ddfb664a527be7e3030a43b822363bc71a Mon Sep 17 00:00:00 2001
From: Peter Rosin <p...@lysator.liu.se>
Date: Fri, 13 Aug 2010 15:09:14 +0200
Subject: [PATCH] Support more C++ extensions for MSVC in the compile script.

* lib/compile (func_cl_wrapper): MSVC only recognizes the .cpp
extension as C++, unless it's given a hint. So hint about
.cc, .cxx, c++ and C++. Also do path conversion on .c, .cpp
and .lib files.
* lib/compile3.test: Test the C++ hinting.

Signed-off-by: Peter Rosin <p...@lysator.liu.se>
---
 ChangeLog           |    9 +++++++++
 lib/compile         |   12 +++++++++++-
 tests/compile3.test |    4 ++++
 3 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2a1c514..7a89be5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-08-13  Peter Rosin  <p...@lysator.liu.se>
+
+       Support more C++ extensions for MSVC in the compile script.
+       * lib/compile (func_cl_wrapper): MSVC only recognizes the .cpp
+       extension as C++, unless it's given a hint. So hint about
+       .cc, .cxx, c++ and C++. Also do path conversion on .c, .cpp
+       and .lib files.
+       * lib/compile3.test: Test the C++ hinting.
+
 2010-08-12  Peter Rosin  <p...@lysator.liu.se>
 
        Enable the use of "link -lib" as the wrapped archiver.
diff --git a/lib/compile b/lib/compile
index bdb4ccb..1920723 100755
--- a/lib/compile
+++ b/lib/compile
@@ -1,7 +1,7 @@
 #! /bin/sh
 # Wrapper for compilers which do not understand `-c -o'.
 
-scriptversion=2010-08-07.06; # UTC
+scriptversion=2010-08-13.13; # UTC
 
 # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009, 2010 Free Software
 # Foundation, Inc.
@@ -129,6 +129,16 @@ func_cl_wrapper ()
          eat=1
          linker_opts="$linker_opts $2"
          ;;
+       [!-]*.cc | [!-]*.cxx | [!-]*.[cC]++)
+         func_file_conv "$1"
+         set x "$@" -Tp"$file"
+         shift
+         ;;
+       [!-]*.c | [!-]*.cpp | [!-]*.lib | [!-]*.LIB | [!-]*.Lib)
+         func_file_conv "$1"
+         set x "$@" "$file"
+         shift
+         ;;
        *)
          set x "$@" "$1"
          shift
diff --git a/tests/compile3.test b/tests/compile3.test
index fc5cd8e..b77237b 100755
--- a/tests/compile3.test
+++ b/tests/compile3.test
@@ -42,4 +42,8 @@ test x"$opts" = x"-c foo.c -Fofoo.obj -Ibaz"
 opts=`./compile ./cl -c foo.c -o foo.o -Ibaz`
 test x"$opts" = x"-c foo.c -Fofoo.o -Ibaz"
 
+# Check if compile handles "foo.cc" as C++.
+opts=`./compile ./cl -c foo.cc -o foo.o -Ibaz`
+test x"$opts" = x"-c -Tpfoo.cc -Fofoo.o -Ibaz"
+
 :
-- 
1.6.4.2

Reply via email to