Author: rolf
Date: 2007-01-15 03:37:41 -0500 (Mon, 15 Jan 2007)
New Revision: 71006

Added:
   trunk/mono-basic/tools/
   trunk/mono-basic/tools/Changelog
   trunk/mono-basic/tools/extract-source/
   trunk/mono-basic/tools/extract-source/Makefile
   trunk/mono-basic/tools/extract-source/extract-source.sln
   trunk/mono-basic/tools/extract-source/extract-source.vb
   trunk/mono-basic/tools/extract-source/extract-source.vbproj
Log:
2007-01-15  Rolf Bjarne Kvinge  <[EMAIL PROTECTED]>

        * Added extract-source.


Added: trunk/mono-basic/tools/Changelog
===================================================================
--- trunk/mono-basic/tools/Changelog    2007-01-15 07:39:50 UTC (rev 71005)
+++ trunk/mono-basic/tools/Changelog    2007-01-15 08:37:41 UTC (rev 71006)
@@ -0,0 +1,3 @@
+2007-01-15  Rolf Bjarne Kvinge  <[EMAIL PROTECTED]>
+
+       * Added extract-source.
\ No newline at end of file


Property changes on: trunk/mono-basic/tools/extract-source
___________________________________________________________________
Name: svn:ignore
   + bin
My Project
obj
*.exe


Added: trunk/mono-basic/tools/extract-source/Makefile
===================================================================
--- trunk/mono-basic/tools/extract-source/Makefile      2007-01-15 07:39:50 UTC 
(rev 71005)
+++ trunk/mono-basic/tools/extract-source/Makefile      2007-01-15 08:37:41 UTC 
(rev 71006)
@@ -0,0 +1,2 @@
+all:
+       vbnc extract-source.vb -r:System.Xml.dll
\ No newline at end of file

Added: trunk/mono-basic/tools/extract-source/extract-source.sln
===================================================================
--- trunk/mono-basic/tools/extract-source/extract-source.sln    2007-01-15 
07:39:50 UTC (rev 71005)
+++ trunk/mono-basic/tools/extract-source/extract-source.sln    2007-01-15 
08:37:41 UTC (rev 71006)
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "extract-source", 
"extract-source.vbproj", "{F635D8E1-317C-4E06-90EB-F7E9A7368580}"
+EndProject
+Global
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution
+               Debug|Any CPU = Debug|Any CPU
+               Release|Any CPU = Release|Any CPU
+       EndGlobalSection
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution
+               {F635D8E1-317C-4E06-90EB-F7E9A7368580}.Debug|Any CPU.ActiveCfg 
= Debug|Any CPU
+               {F635D8E1-317C-4E06-90EB-F7E9A7368580}.Debug|Any CPU.Build.0 = 
Debug|Any CPU
+               {F635D8E1-317C-4E06-90EB-F7E9A7368580}.Release|Any 
CPU.ActiveCfg = Release|Any CPU
+               {F635D8E1-317C-4E06-90EB-F7E9A7368580}.Release|Any CPU.Build.0 
= Release|Any CPU
+       EndGlobalSection
+       GlobalSection(SolutionProperties) = preSolution
+               HideSolutionNode = FALSE
+       EndGlobalSection
+EndGlobal

Added: trunk/mono-basic/tools/extract-source/extract-source.vb
===================================================================
--- trunk/mono-basic/tools/extract-source/extract-source.vb     2007-01-15 
07:39:50 UTC (rev 71005)
+++ trunk/mono-basic/tools/extract-source/extract-source.vb     2007-01-15 
08:37:41 UTC (rev 71006)
@@ -0,0 +1,150 @@
+' extract-source.vb
+'
+' Rolf Bjarne Kvinge  ([EMAIL PROTECTED])
+'
+' 
+' Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+'
+' Permission is hereby granted, free of charge, to any person obtaining
+' a copy of this software and associated documentation files (the
+' "Software"), to deal in the Software without restriction, including
+' without limitation the rights to use, copy, modify, merge, publish,
+' distribute, sublicense, and/or sell copies of the Software, and to
+' permit persons to whom the Software is furnished to do so, subject to
+' the following conditions:
+' 
+' The above copyright notice and this permission notice shall be
+' included in all copies or substantial portions of the Software.
+' 
+' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+' EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+' MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+' NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+' LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+' OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+' WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Imports System
+Imports System.Collections
+Imports Microsoft.VisualBasic
+
+Module extract_source
+
+    Sub ShowHelp()
+        Console.WriteLine("Extracts sources from a vb project file (.vbproj, 
VS2005 file format)")
+        Console.WriteLine(vbTab & "-s[ource]:<vbproj file>")
+        Console.WriteLine(vbTab & "-d[estination]:<destination file>")
+        Console.WriteLine(vbTab & "-m[ode]:win|windows|linux")
+        Console.WriteLine(vbTab & "-b[asepath]:<optional base path to append 
to all paths in project file>")
+    End Sub
+
+    Function Main(ByVal args As String()) As Integer
+        Dim source As String = Nothing, destination As String = Nothing, mode 
As String = Nothing, basepath As String = Nothing
+
+        For Each arg As String In args
+            If arg.StartsWith("-") = False AndAlso arg.StartsWith("/") = False 
Then
+                ShowHelp()
+                Return 1
+            End If
+            Dim name, value As String
+            Dim idx As Integer
+            arg = arg.Substring(1)
+            idx = arg.IndexOfAny(New Char() {":"c, "="c})
+            If idx = -1 Then
+                ShowHelp()
+                Return 1
+            End If
+            name = arg.Substring(0, idx)
+            value = arg.Substring(idx + 1)
+            Select Case name.ToUpperInvariant
+                Case "B", "BASEPATH"
+                    basepath = value
+                Case "S", "SOURCE"
+                    source = value
+                Case "D", "DESTINATION", "DEST"
+                    destination = value
+                Case "M", "MODE"
+                    Select Case value.ToUpperInvariant
+                        Case "WIN", "W", "WINDOWS"
+                            mode = "w"
+                        Case "L", "LINUX", "LIN"
+                            mode = "l"
+                        Case Else
+                            ShowHelp()
+                            Return 1
+                    End Select
+                    mode = value
+                Case "H", "HELP", "?"
+                    ShowHelp()
+                    Return 0
+                Case Else
+                    ShowHelp()
+                    Return 1
+            End Select
+        Next
+
+        If mode = "" OrElse source = "" OrElse destination = "" Then
+            ShowHelp()
+            Return 1
+        End If
+
+        Try
+            Extract(source, destination, mode, basepath)
+        Catch ex As Exception
+            Console.WriteLine(ex.Message)
+        End Try
+
+    End Function
+
+    Sub Extract(ByVal VBProjFileName As String, ByVal DestinationFile As 
String, ByVal mode As String, ByVal basepath As String)
+        Dim sources As String()
+
+        sources = GetSources(VBProjFileName, basepath)
+        Select Case mode.ToUpperInvariant
+            Case "W"
+                IO.File.WriteAllText(DestinationFile, Join(sources, vbCrLf))
+            Case "L"
+                IO.File.WriteAllText(DestinationFile, Join(sources, 
vbLf).Replace("\"c, "/"c))
+            Case Else
+                Throw New Exception("Invalid mode: " & mode)
+        End Select
+
+    End Sub
+
+    Function GetSources(ByVal File As String, ByVal BasePath As String) As 
String()
+        Dim files As New Generic.List(Of String)
+
+        If BasePath Is Nothing Then BasePath = String.Empty
+
+        Using x As New Xml.XmlTextReader(File)
+            Dim i As Integer
+            While x.Read()
+                Dim filename As String
+                Dim prefix As String
+                prefix = ""
+                filename = ""
+                If x.Name = "Compile" AndAlso x.NodeType = 
Xml.XmlNodeType.Element Then
+                    x.MoveToAttribute("Include")
+                    filename = x.Value
+                ElseIf x.Name = "EmbeddedResource" AndAlso x.NodeType = 
Xml.XmlNodeType.Element Then
+                    x.MoveToAttribute("Include")
+                    filename = x.Value
+                    prefix = "-res:"
+                End If
+                If filename <> "" Then
+                    filename = BasePath & x.Value
+                    filename = filename.Replace("%29", ")")
+                    filename = filename.Replace("%28", "(")
+                    filename = prefix & filename
+                    If filename.Contains(" "c) Then
+                        filename = """" & filename & """"
+                    End If
+                    files.Add(filename)
+                    i += 1
+                End If
+            End While
+        End Using
+
+        Return files.ToArray
+    End Function
+End Module

Added: trunk/mono-basic/tools/extract-source/extract-source.vbproj
===================================================================
--- trunk/mono-basic/tools/extract-source/extract-source.vbproj 2007-01-15 
07:39:50 UTC (rev 71005)
+++ trunk/mono-basic/tools/extract-source/extract-source.vbproj 2007-01-15 
08:37:41 UTC (rev 71006)
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" 
xmlns="http://schemas.microsoft.com/developer/msbuild/2003";>
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>8.0.50727</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{F635D8E1-317C-4E06-90EB-F7E9A7368580}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <StartupObject>extract_source.extract_source</StartupObject>
+    <RootNamespace>extract_source</RootNamespace>
+    <AssemblyName>extract-source</AssemblyName>
+    <MyType>Console</MyType>
+    <OptionStrict>On</OptionStrict>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' 
">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <DefineDebug>true</DefineDebug>
+    <DefineTrace>true</DefineTrace>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DocumentationFile>extract-source.xml</DocumentationFile>
+    
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
+    <DefineConstants>_MYTYPE="Empty"</DefineConstants>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 
'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <DefineDebug>false</DefineDebug>
+    <DefineTrace>true</DefineTrace>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DocumentationFile>extract-source.xml</DocumentationFile>
+    
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Deployment" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Import Include="Microsoft.VisualBasic" />
+    <Import Include="System" />
+    <Import Include="System.Collections" />
+    <Import Include="System.Collections.Generic" />
+    <Import Include="System.Data" />
+    <Import Include="System.Diagnostics" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="extract-source.vb" />
+  </ItemGroup>
+  <ItemGroup>
+    <Folder Include="My Project\" />
+  </ItemGroup>
+  <Import Project="$(MSBuildBinPath)\Microsoft.VisualBasic.targets" />
+  <!-- To modify your build process, add your task inside one of the targets 
below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to