Boost logo

Boost-Build :

From: Pedro Lamarão (pedro.lamarao_at_[hidden])
Date: 2006-03-09 15:15:52


Pedro Lamarão escreveu:
> Has anyone tried to add support to the .NET SDK or Mono?
> I'm studying how to best accomplish this, maybe someone could give me
> some pointers.

The following hack adds support for .cs files compiled with csc.exe to
the msvc toolset. The first file is a patch to msvc.jam, the other is a
new CS type in cs.jam.

It translates no features yet, but compiles a simple EXE or LIB project.

My goal is to produce two targets, dotnet (.NET SDK, not Visual C#) and
mono, with proper auto-detection and feature support.

Index: tools/build/v2/tools/msvc.jam
===================================================================
RCS file: /cvsroot/boost/boost/tools/build/v2/tools/msvc.jam,v
retrieving revision 1.76
diff -u -r1.76 msvc.jam
--- tools/build/v2/tools/msvc.jam 7 Mar 2006 12:59:37 -0000 1.76
+++ tools/build/v2/tools/msvc.jam 9 Mar 2006 20:08:27 -0000
@@ -356,6 +356,7 @@
                 flags msvc.archive .LD $(cond) : $(command[$(i)])$(linker) ;
                 flags msvc.compile .IDL $(cond) : $(command[$(i)])$(idl-compiler) ;
                 flags msvc.compile .MC $(cond) : $(command[$(i)])$(mc-compiler) ;
+ flags msvc.compile .CSC $(cond) : $(command[$(i)])csc ;
 
                 if ! [ os.name ] in NT
                 {
@@ -511,6 +512,10 @@
 
 generators.register [ new pch-generator msvc.compile.pch : PCHEADER : OBJ PCH : <toolset>msvc ] ;
 
+# C# compilation -- csc.exe behaves like a linker
+generators.register-linker msvc.compile.cs2exe : CS : EXE : <toolset>msvc ;
+generators.register-linker msvc.compile.cs2dll : CS : LIB : <toolset>msvc ;
+
 #
 # Declare flags and action for compilation
 #
@@ -582,6 +587,16 @@
     DEPENDS $(<) : [ on $(<) return $(PCH_SOURCE) ] ;
 }
 
+rule compile.cs2exe ( targets + : sources * : properties * )
+{
+ DEPENDS $(<) : [ on $(<) return $(PCH_SOURCE) ] ;
+}
+
+rule compile.cs2lib ( targets + : sources * : properties * )
+{
+ DEPENDS $(<) : [ on $(<) return $(PCH_SOURCE) ] ;
+}
+
 
 # The actions differ only by explicit selection of input language
 actions compile.c bind PCH_HEADER PCH_FILE
@@ -599,6 +614,15 @@
     $(.CC) /Zm800 -nologo -TP -U$(UNDEFS) $(CFLAGS) $(C++FLAGS) $(USER_CFLAGS) @"@($(<[1]:W).rsp:E=$(nl)"$(PCH_SOURCE:W)" $(nl)-D$(DEFINES) $(nl)"-I$(INCLUDES)")" -c -Fo"$(<[1]:W)" /Yc"$(>[1]:D=)" -Fp"$(<[2]:W)"
 }
 
+actions compile.cs2exe
+{
+ $(.CSC) /nologo /target:exe /out:"$(<[1]:W)" @"@($(<[1]:W).rsp:E=$(nl)"$(>)" $(nl)/define:$(DEFINES) $(nl)"/lib:$(INCLUDES)")"
+}
+
+actions compile.cs2lib
+{
+ $(.CSC) /nologo /target:library /out:"$(<[1]:W)" @"@($(<[1]:W).rsp:E=$(nl)"$(>)" $(nl)/define:$(DEFINES) $(nl)"/lib:$(INCLUDES)")"
+}
 
 actions compile.rc
 {

# Copyright Pedro Lamarão (C) 2006.
# Distributed under the Boost Software License, version 1.0.
# (See accompanying file LICENSE_1_0.txt
# or copy at http://www.boost.org/LICENSE_1_0.txt)
type CS : cs ;


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk