[svn] r5822: nemerle/trunk/tools: Makefile msbuild-task msbuild-task/MSBuildTask.n msbuild-task/Makefile m...

nazgul svnadmin at nemerle.org
Sat Oct 15 15:10:06 CEST 2005


Log:
Add msbuild-task, it works quite nice now. Configure and install targets should be implemented though

Author: nazgul
Date: Sat Oct 15 15:09:51 2005
New Revision: 5822

Added:
   nemerle/trunk/tools/msbuild-task/
   nemerle/trunk/tools/msbuild-task/MSBuildTask.n   (contents, props changed)
   nemerle/trunk/tools/msbuild-task/Makefile   (contents, props changed)
   nemerle/trunk/tools/msbuild-task/Nemerle.MSBuild.targets   (contents, props changed)
   nemerle/trunk/tools/msbuild-task/Program.n   (contents, props changed)
   nemerle/trunk/tools/msbuild-task/sample.nproj   (contents, props changed)
Modified:
   nemerle/trunk/tools/Makefile

Modified: nemerle/trunk/tools/Makefile
==============================================================================
--- nemerle/trunk/tools/Makefile	(original)
+++ nemerle/trunk/tools/Makefile	Sat Oct 15 15:09:51 2005
@@ -41,12 +41,14 @@
 	fi
 	$(Q)$(MAKE) -C nemerlish all
 	$(Q)$(MAKE) -C nant-task all
+	$(Q)$(MAKE) -C msbuild-task all
 
 install: all
 	$(Q)if test -f cs2n/cs2n.exe ; then \
 	  $(MAKE) -C cs2n install; fi
 	$(Q)$(MAKE) -C nemerlish install
 	$(Q)$(MAKE) -C nant-task all install
+	$(Q)$(MAKE) -C msbuild-task all install
 
 uninstall:
 	$(Q)-$(MAKE) -C cs2n uninstall
@@ -57,3 +59,4 @@
 	$(MAKE) -C nemerlish clean
 	$(MAKE) -C nant-task clean
 	$(MAKE) -C htmldumper clean
+	$(MAKE) -C msbuild-task clean

Added: nemerle/trunk/tools/msbuild-task/MSBuildTask.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/tools/msbuild-task/MSBuildTask.n	Sat Oct 15 15:09:51 2005
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2005 Kamil Skalski <nazgul at nemerle.org>
+ * Copyright (c) 2005 The University of Wroclaw.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *    1. Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *    2. Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *    3. The name of the University may not be used to endorse or promote
+ *       products derived from this software without specific prior
+ *       written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE UNIVERSITY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+using System;
+using System.IO;
+using System.Collections;
+using System.Reflection;
+
+using Microsoft.Build.Framework;
+using Microsoft.Build.Tasks;
+using Microsoft.Build.Utilities;
+
+using Nemerle.Utility;
+
+namespace Nemerle.Tools.MSBuildTask
+{
+  public class Ncc : ManagedCompiler
+  {
+    protected override ToolName : string
+    {
+      get { "ncc.exe"; }
+    }
+    
+    protected override GenerateFullPathToTool () : string {
+      def my_file = typeof(Ncc).Assembly.Location;
+      def ncc_file = Path.Combine (Path.GetDirectoryName(my_file), ToolName);
+      ncc_file
+    } 
+  
+    protected override AddResponseFileCommands(commandLine : CommandLineBuilderExtension) : void
+    {
+      commandLine.AppendSwitch ("/no-color");
+      commandLine.AppendSwitchIfNotNull("/lib:", base.AdditionalLibPaths, ",");
+      commandLine.AppendSwitchIfNotNull("/nowarn:", this.DisabledWarnings, ",");
+      when (NoStandardLib)
+        commandLine.AppendSwitch("/nostdlib");
+      when (WarningLevel != 4)
+        commandLine.AppendSwitchIfNotNull("/warn:", WarningLevel.ToString());
+      commandLine.AppendSwitchIfNotNull("/doc:", this.DocumentationFile);
+      commandLine.AppendSwitchUnquotedIfNotNull("/define:", base.DefineConstants);
+
+      match (Bag ["EmitDebugInformation"]) {
+        | x is bool when x => 
+          commandLine.AppendSwitch("/debug");
+        | null | _ => ()
+     }
+      
+      
+      Bag ["EmitDebugInformation"] = null; // prevent standard handling by ManagedCompiler
+      base.AddResponseFileCommands(commandLine);
+
+      when (base.ResponseFiles != null)
+      {
+        def items = base.ResponseFiles;
+        foreach (it in items)
+          commandLine.AppendSwitchIfNotNull("/fromfile:", it.ItemSpec);
+      }
+      
+      when (base.References != null)
+      {
+        def items = base.References;
+        foreach (it in items)
+          commandLine.AppendSwitchIfNotNull("/ref:", it.ItemSpec);
+      }
+      
+    }
+
+    protected override LogEventsFromTextOutput(singleLine : string, messageImportance : MessageImportance) : void
+    {
+      def get_location (before) {
+        def str = singleLine.Substring (0, singleLine.IndexOf (before));
+        if (string.IsNullOrEmpty (str)) (null, 0,0,0,0)
+        else {
+          def parts = Nemerle.Collections.List.FromArray (str.Split (':'));
+          match (parts) {
+            | [file, _] => (file, 0, 0, 0, 0)
+            | [file, line, col, _] => (file, int.Parse (line), int.Parse (col), int.Parse (line), int.Parse (col))
+            | [file, line1, col1, line2, col2, _] => (file, int.Parse (line1), int.Parse (col1), int.Parse (line2), int.Parse (col2))
+            | _ => (null, 0,0,0,0)
+          }
+        }
+      }
+    
+      if (singleLine.IndexOf ("error:") != -1) {
+        def (file, l1, c1, l2, c2) = get_location ("error:");
+        Log.LogError (null, null, null, file, l1, c1, l2, c2, singleLine.Substring (singleLine.IndexOf ("error:") + 7));
+      }
+      else if (singleLine.IndexOf ("warning:") != -1) {
+        def (file, l1, c1, l2, c2) = get_location ("warning:");
+        Log.LogWarning (null, null, null, file, l1, c1, l2, c2, singleLine.Substring (singleLine.IndexOf ("warning:") + 9));
+      }
+      else if (singleLine.IndexOf ("debug:") != -1) {
+        def (file, l1, c1, l2, c2) = get_location ("debug:");
+        Log.LogMessage (null, null, null, file, l1, c1, l2, c2, singleLine.Substring (singleLine.IndexOf ("debug:") + 7));
+      }
+      else _ = Log.LogMessageFromText(singleLine, messageImportance);
+    }
+   
+    protected override GetResponseFileSwitch(responseFilePath : string) : string
+    {
+      "/from-file:\"" + responseFilePath + "\"";
+    }
+          
+    [Accessor (flags = WantSetter)]
+    mutable _disabled_warnings : array [string];
+
+    [Accessor (flags = WantSetter)]
+    mutable _documentation_file : string;
+
+    [Accessor (flags = WantSetter)]
+    mutable _no_standard_lib : bool = false;
+
+    [Accessor (flags = WantSetter)]
+    mutable _warning_level : int = 4;
+        
+    [Accessor (flags = WantSetter)]
+    mutable _warnings_as_errors : bool;
+  }
+}
\ No newline at end of file

Added: nemerle/trunk/tools/msbuild-task/Makefile
==============================================================================
--- (empty file)
+++ nemerle/trunk/tools/msbuild-task/Makefile	Sat Oct 15 15:09:51 2005
@@ -0,0 +1,71 @@
+#
+# Copyright (c) 2005 The University of Wroclaw.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#    1. Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#    2. Redistributions in binary form must reproduce the above copyright
+#       notice, this list of conditions and the following disclaimer in the
+#       documentation and/or other materials provided with the distribution.
+#    3. The name of the University may not be used to endorse or promote
+#       products derived from this software without specific prior
+#       written permission.
+# 
+# THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+# NO EVENT SHALL THE UNIVERSITY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+# Include configuration determined by configure script.
+TOP = ../..
+include $(TOP)/config.mak
+
+############################################################
+# VARIABLES
+############################################################
+
+EXECUTE = $(NET_ENGINE) $(NET_FLAGS)
+
+############################################################
+# OUTPUT
+############################################################
+
+MKDIR = @echo MKDIR $1
+TAR   = @echo TAR   $1
+CP    = @echo CP    $1
+INST  = @echo INSTALL $1
+
+############################################################
+# TARGETS
+############################################################
+
+ifeq ($(MSBUILD),)
+all:
+	$(Q)true
+	
+install:
+	$(Q)true
+else
+all: Nemerle.MSBuild.Tasks.dll
+
+install: all
+	$(INST) Nemerle.MSBuild.Tasks.dll
+	$(Q)install -d $(DESTDIR)
+	$(Q)install -m755 Nemerle.MSBuild.Tasks.dll $(DESTDIR)
+endif
+
+Nemerle.MSBuild.Tasks.dll: MSBuildTask.n
+	$(EXECUTE) $(TOP)/ncc/out.stage3/ncc.exe -q -r:Microsoft.Build.Tasks.dll -out $@ -t:library MSBuildTask.n
+
+clean:
+	rm -f *.exe *.dll core core.[0-9]*

Added: nemerle/trunk/tools/msbuild-task/Nemerle.MSBuild.targets
==============================================================================
--- (empty file)
+++ nemerle/trunk/tools/msbuild-task/Nemerle.MSBuild.targets	Sat Oct 15 15:09:51 2005
@@ -0,0 +1,217 @@
+ďťż
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+
+    <UsingTask
+      TaskName="Nemerle.Tools.MSBuildTask.Ncc" 
+      AssemblyFile="Nemerle.MSBuild.Tasks.dll"/>
+
+
+    <PropertyGroup>
+        <MSBuildAllProjects>$(MSBuildAllProjects);Nemerle.targets</MSBuildAllProjects>
+        <DefaultLanguageSourceExtension>.n</DefaultLanguageSourceExtension>
+        <Language>Nemerle</Language>
+    </PropertyGroup>
+
+    <!--
+    The CreateManifestResourceNames target create the manifest resource names
+	from the .RESX files.
+
+        [IN]
+        @(ResxWithNoCulture) - The names the non-culture .RESX files.
+        @(ResxWithCulture) - The names the culture .RESX files.
+        @(NonResxWithNoCulture) - The names of the non-culture non-RESX
+		                          files (like bitmaps, etc).
+								  
+        @(NonResxWithCulture) - The names of the culture non-RESX
+		                       files (like bitmaps, etc).
+
+        [OUT]
+        @(ManifestResourceWithNoCultureName) - The corresponding manifest
+		                                       resource name (.RESOURCE)
+											   
+        @(ManifestResourceWithCultureName) - The corresponding manifest
+		                                     resource name (.RESOURCE)
+											 
+        @(ManifestNonResxWithNoCulture) - The corresponding manifest
+		                                  resource name.
+										  
+        @(ManifestNonResxWithCulture) - The corresponding manifest
+		                               resource name.
+
+    For Nemerle applications the transformation is like:
+
+        Resources1.resx => RootNamespace.Resources1 => Build into main assembly
+        
+		SubFolder\Resources1.resx =>
+			RootNamespace.SubFolder.Resources1 =>
+				Build into main assembly
+        
+		Resources1.fr.resx =>
+			RootNamespace.Resources1.fr =>
+				Build into satellite assembly
+				
+        Resources1.notaculture.resx =>
+			RootNamespace.Resources1.notaculture =>
+				Build into main assembly
+
+    For other project systems, this transformation may be different.
+    -->
+	
+    <PropertyGroup>
+        <CreateManifestResourceNamesDependsOn>
+		</CreateManifestResourceNamesDependsOn>
+    </PropertyGroup>
+    <Target
+        Name="CreateManifestResourceNames"
+        Condition="'
+			@(ResxWithNoCulture)
+			@(ResxWithCulture)
+			@(NonResxWithNoCulture)
+			@(NonResxWithCulture)'!=''"
+			
+        DependsOnTargets="$(CreateManifestResourceNamesDependsOn)"
+        >
+
+        <!-- Create the target resource names for non-culture resx files.
+        <CreateNemerleManifestResourceName
+			Condition="'@(ResxWithNoCulture)'!=''"
+			ResourceFiles="@(ResxWithNoCulture)"
+			RootNamespace="$(RootNamespace)">
+			
+			<Output
+				TaskParameter="ManifestResourceNames"
+				ItemName="ManifestResourceWithNoCultureName"/>
+
+        </CreateCSharpManifestResourceName>--> 
+
+        <!-- Create the target resource names for culture resx files. 
+        <CreateCSharpManifestResourceName
+			Condition="'@(ResxWithCulture)'!=''"
+			ResourceFiles="@(ResxWithCulture)"
+			RootNamespace="$(RootNamespace)">
+
+            <Output
+				TaskParameter="ManifestResourceNames"
+				ItemName="ManifestResourceWithCultureName"/>
+
+        </CreateCSharpManifestResourceName>-->
+
+        <!--
+		Create the target resource names for non-culture non-resx files.
+	    
+        <CreateCSharpManifestResourceName
+			Condition="'@(NonResxWithNoCulture)'!=''"
+			ResourceFiles="@(NonResxWithNoCulture)"
+			RootNamespace="$(RootNamespace)">
+
+            <Output
+				TaskParameter="ManifestResourceNames"
+				ItemName="ManifestNonResxWithNoCulture"/>
+
+        </CreateCSharpManifestResourceName>-->
+
+        <!-- Create the target resource names for culture non-resx files. 
+        <CreateCSharpManifestResourceName
+			Condition="'@(NonResxWithCulture)'!=''"
+			ResourceFiles="@(NonResxWithCulture)"
+			RootNamespace="$(RootNamespace)">
+
+            <Output
+				TaskParameter="ManifestResourceNames"
+				ItemName="ManifestNonResxWithCulture"/>
+
+        </CreateCSharpManifestResourceName>-->
+    </Target>
+
+    <PropertyGroup>
+
+        <!-- "None" is not technically a valid DebugType, so we can't pass it in as such
+             to the compiler.  So here, we modify the properties so they make sense. -->
+        <DebugSymbols Condition=" '$(DebugType)' == 'none' ">false</DebugSymbols>
+        <DebugType    Condition=" '$(DebugType)' == 'none' "></DebugType>    
+
+        <_DisabledWarnings>$(NoWarn)</_DisabledWarnings>
+        
+        <!-- Provide a facility to override UseHostCompilerIfAvailable-->
+        <UseHostCompilerIfAvailable Condition=" '$(UseHostCompilerIfAvailable)' == ''">true</UseHostCompilerIfAvailable>
+
+    </PropertyGroup>
+
+
+    <ItemGroup>
+        <DocFileItem Include="$(DocumentationFile)" Condition="'$(DocumentationFile)'!=''"/>
+    </ItemGroup>
+
+    <PropertyGroup>
+        <CoreCompileDependsOn>_ComputeNonExistentFileProperty</CoreCompileDependsOn>
+    </PropertyGroup>
+    <Target
+        Name="CoreCompile"
+        Inputs="$(MSBuildAllProjects);
+                @(Compile);
+                @(ManifestResourceWithNoCulture);
+                $(ApplicationIcon);
+                $(AssemblyOriginatorKeyFile);
+                @(ManifestNonResxWithNoCultureOnDisk);
+                @(ReferencePath);
+                @(CompiledLicenseFile);
+                @(EmbeddedDocumentation);                
+                @(CustomAdditionalCompileInputs)"
+        Outputs="@(DocFileItem);
+                 @(IntermediateAssembly);
+                 $(NonExistentFile);
+                 @(CustomAdditionalCompileOutputs)"
+        DependsOnTargets="$(CoreCompileDependsOn)"
+    >
+       
+        <Ncc
+              AdditionalLibPaths="$(AdditionalLibPaths)"
+              DefineConstants="$(DefineConstants)"
+              DisabledWarnings="$(_DisabledWarnings)"
+              DocumentationFile="@(DocFileItem)"
+              EmitDebugInformation="$(DebugSymbols)"              
+              KeyFile="$(KeyOriginatorFile)"
+              NoLogo="$(NoLogo)"
+              NoStandardLib="$(NoStdLib)"              
+              Optimize="$(Optimize)"
+              OutputAssembly="@(IntermediateAssembly)"
+              References="@(ReferencePath)"
+              Resources="@(ManifestResourceWithNoCulture);@(ManifestNonResxWithNoCultureOnDisk);@(CompiledLicenseFile)"
+              ResponseFiles="$(CompilerResponseFile)"
+              Sources="@(Compile)"
+              TargetType="$(OutputType)"
+              ToolPath="$(CscToolPath)"
+              TreatWarningsAsErrors="$(TreatWarningsAsErrors)"
+              WarningLevel="$(WarningLevel)"
+              WarningsAsErrors="$(WarningsAsErrors)"
+              />
+
+    </Target>
+    
+    <Import Project="$(MSBuildBinPath)\Microsoft.Common.targets" />
+</Project>
+
+<!--
+              AddModules="@(AddModules)"
+              AllowUnsafeBlocks="$(AllowUnsafeBlocks)"
+              BaseAddress="$(BaseAddress)"
+              CheckForOverflowUnderflow="$(CheckForOverflowUnderflow)"
+              CodePage="$(CodePage)"
+              DebugType="$(DebugType)"
+              DelaySign="$(DelaySign)"
+              ErrorReport="$(ErrorReport)"
+              FileAlignment="$(FileAlignment)"
+              GenerateFullPaths="$(GenerateFullPaths)"
+              KeyContainer="$(KeyContainerName)"
+              LangVersion="$(LangVersion)"
+              MainEntryPoint="$(StartupObject)"
+              ModuleAssemblyName="$(ModuleAssemblyName)"
+              NoConfig="true"
+              PdbFile="$(PdbFile)" 
+              Platform="$(PlatformTarget)"
+              UseHostCompilerIfAvailable="$(UseHostCompilerIfAvailable)"
+              Utf8Output="$(Utf8Output)"
+              WarningsNotAsErrors="$(WarningsNotAsErrors)"
+              Win32Icon="$(ApplicationIcon)"
+              Win32Resource="$(Win32Resource)"
+-->
\ No newline at end of file

Added: nemerle/trunk/tools/msbuild-task/Program.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/tools/msbuild-task/Program.n	Sat Oct 15 15:09:51 2005
@@ -0,0 +1,4 @@
+macro A() { <[ () ]> }
+
+Nemerle.IO.print ("Hello, World!\n");
+Nemerle.IO.print ("Hello, World1111!\n");

Added: nemerle/trunk/tools/msbuild-task/sample.nproj
==============================================================================
--- (empty file)
+++ nemerle/trunk/tools/msbuild-task/sample.nproj	Sat Oct 15 15:09:51 2005
@@ -0,0 +1,39 @@
+<Project
+	DefaultTargets="Build"
+	xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+	
+  <PropertyGroup>
+    <!--
+	Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{950108FD-0A71-499B-9970-B6DB4619DC03}</ProjectGuid>
+	-->
+    <OutputType>Exe</OutputType>
+    <RootNamespace>NemerleSample</RootNamespace>
+    <AssemblyName>NemerleSample</AssemblyName>
+  </PropertyGroup>
+  
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  
+  <ItemGroup>
+    <Reference Include="Nemerle.Compiler" />
+  </ItemGroup>
+  
+  <ItemGroup>
+    <Compile Include="Program.n" />
+  </ItemGroup>
+  
+ 
+  <Import Project="$(PROGRAMFILES)\Nemerle\Nemerle.MSBuild.targets" />
+</Project>



More information about the svn mailing list