From 0f8609da532babefc869c81637bafbee12513bdd Mon Sep 17 00:00:00 2001 From: "Joel W. Reed" Date: Sat, 1 Dec 2007 22:56:15 -0500 Subject: [PATCH] fix.build --- class/OpenTF.Common/FileType.cs | 146 ++++++++++++++++--------------- class/OpenTF.Common/Makefile | 41 ++++----- class/OpenTF.Common/NoFileType.cs | 15 +++- class/OpenTF.Common/OpenTF.Common.csproj | 122 +++++++------------------- 4 files changed, 136 insertions(+), 188 deletions(-) rewrite class/OpenTF.Common/Makefile (89%) rewrite class/OpenTF.Common/OpenTF.Common.csproj (71%) diff --git a/class/OpenTF.Common/FileType.cs b/class/OpenTF.Common/FileType.cs index 984643e..f4a121f 100644 --- a/class/OpenTF.Common/FileType.cs +++ b/class/OpenTF.Common/FileType.cs @@ -32,78 +32,80 @@ using System.IO; using System.Runtime.InteropServices; using Mono.Unix; -class FileTypeDatabase +namespace OpenTF.Common { - [DllImport("magic")] - private extern static IntPtr magic_open(int flags); - - [DllImport("magic")] - private extern static void magic_close(IntPtr magic_cookie); - - [DllImport("magic")] - private extern static IntPtr magic_file(IntPtr magic_cookie, string filename); - - [DllImport("magic")] - private extern static int magic_load(IntPtr magic_cookie, IntPtr x); - - private static IntPtr _magic = IntPtr.Zero; - - static FileTypeDatabase() - { - _magic = magic_open(0); - if (_magic == IntPtr.Zero) - { - Console.WriteLine("Warning: failed to open libmagic database"); - return; - } - - magic_load(_magic, IntPtr.Zero); - } - - ~FileTypeDatabase() - { - if (_magic != IntPtr.Zero) - magic_close(_magic); - } - - public static bool ShouldBeExecutable(string filename) - { - if (_magic == IntPtr.Zero) return false; - string desc = Marshal.PtrToStringAuto(magic_file(_magic, filename)); - if (String.IsNullOrEmpty(desc)) - { - Console.WriteLine("Error querying file type for " + filename); - return false; - } - - return desc.Contains("executable"); - } - - public static void MakeExecutable(string filename) - { - Mono.Unix.Native.Stat stat; - if (0 == Mono.Unix.Native.Syscall.stat(filename, out stat)) - { - Mono.Unix.Native.FilePermissions fp = stat.st_mode | Mono.Unix.Native.FilePermissions.S_IXUSR; - Mono.Unix.Native.Syscall.chmod(filename, fp); - } - } - - public static void SetPermissions(List fileList) + class FileTypeDatabase { - Console.Write("Setting permissions..."); - - int i = 0; - foreach (string file in fileList) - { - if (0 == (i % 100)) Console.Write("."); - i++; - - if (! ShouldBeExecutable(file)) continue; - MakeExecutable(file); - } - - Console.WriteLine(" done!"); + [DllImport("magic")] + private extern static IntPtr magic_open(int flags); + + [DllImport("magic")] + private extern static void magic_close(IntPtr magic_cookie); + + [DllImport("magic")] + private extern static IntPtr magic_file(IntPtr magic_cookie, string filename); + + [DllImport("magic")] + private extern static int magic_load(IntPtr magic_cookie, IntPtr x); + + private static IntPtr _magic = IntPtr.Zero; + + static FileTypeDatabase() + { + _magic = magic_open(0); + if (_magic == IntPtr.Zero) + { + Console.WriteLine("Warning: failed to open libmagic database"); + return; + } + + magic_load(_magic, IntPtr.Zero); + } + + ~FileTypeDatabase() + { + if (_magic != IntPtr.Zero) + magic_close(_magic); + } + + public static bool ShouldBeExecutable(string filename) + { + if (_magic == IntPtr.Zero) return false; + string desc = Marshal.PtrToStringAuto(magic_file(_magic, filename)); + if (String.IsNullOrEmpty(desc)) + { + Console.WriteLine("Error querying file type for " + filename); + return false; + } + + return desc.Contains("executable"); + } + + public static void MakeExecutable(string filename) + { + Mono.Unix.Native.Stat stat; + if (0 == Mono.Unix.Native.Syscall.stat(filename, out stat)) + { + Mono.Unix.Native.FilePermissions fp = stat.st_mode | Mono.Unix.Native.FilePermissions.S_IXUSR; + Mono.Unix.Native.Syscall.chmod(filename, fp); + } + } + + public static void SetPermissions(List fileList) + { + Console.Write("Setting permissions..."); + + int i = 0; + foreach (string file in fileList) + { + if (0 == (i % 100)) Console.Write("."); + i++; + + if (! ShouldBeExecutable(file)) continue; + MakeExecutable(file); + } + + Console.WriteLine(" done!"); + } } -} - +} diff --git a/class/OpenTF.Common/Makefile b/class/OpenTF.Common/Makefile dissimilarity index 89% index e6945db..6ff88f1 100644 --- a/class/OpenTF.Common/Makefile +++ b/class/OpenTF.Common/Makefile @@ -1,24 +1,17 @@ -thisdir = tools/Gtk.TeamFoundation -include ../../build/rules.make - -LIBRARY = Gtk.TeamFoundation.dll -RESOURCES = $(wildcard icons/*.png) - -LIB_MCS_FLAGS = /unsafe /pkg:gtk-sharp-2.0 /r:Microsoft.TeamFoundation.dll /r:Microsoft.TeamFoundation.Common.dll /r:Microsoft.TeamFoundation.Client.dll /r:Microsoft.TeamFoundation.VersionControl.Client.dll /r:Microsoft.TeamFoundation.VersionControl.Common.dll - -ifeq ($(HAVE_SYNTAX_HIGHLIGHTING),no) -EXTRA_SOURCES += NoSourceView.cs -else -EXTRA_SOURCES += SourceView.cs -LOCAL_MCS_FLAGS += -pkg:gtksourceview-sharp-2.0 -pkg:gnome-vfs-sharp-2.0 -d:HAVE_SYNTAX_HIGHLIGHTING -endif - -res: - echo $(RESOURCES) - -LOCAL_MCS_FLAGS += $(RESOURCES:%=/resource:%) - -TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) - -include ../../build/library.make - +thisdir = tools/OpenTF.Common +include ../../build/rules.make + +LIBRARY = OpenTF.Common.dll + +ifeq ($(HAVE_MAGIC),no) +EXTRA_SOURCES += NoFileType.cs +else +EXTRA_SOURCES += FileType.cs +LOCAL_MCS_FLAGS += /unsafe -d:HAVE_MAGIC -r:Mono.Posix.dll + +endif + +TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) + +include ../../build/library.make + diff --git a/class/OpenTF.Common/NoFileType.cs b/class/OpenTF.Common/NoFileType.cs index 063e065..ec305f2 100644 --- a/class/OpenTF.Common/NoFileType.cs +++ b/class/OpenTF.Common/NoFileType.cs @@ -29,10 +29,17 @@ using System; using System.Collections.Generic; -class FileTypeDatabase +namespace OpenTF.Common { - public static void SetPermissions(List x) + class FileTypeDatabase { - } + public static bool ShouldBeExecutable(string filename) + { + return false; + } + + public static void MakeExecutable(string filename) + { + } + } } - diff --git a/class/OpenTF.Common/OpenTF.Common.csproj b/class/OpenTF.Common/OpenTF.Common.csproj dissimilarity index 71% index a87fe17..b7b47cb 100644 --- a/class/OpenTF.Common/OpenTF.Common.csproj +++ b/class/OpenTF.Common/OpenTF.Common.csproj @@ -1,88 +1,34 @@ - - - Debug - AnyCPU - {B0953653-A461-4338-BDAE-91DA9C3583AA} - Library - false - Gtk.TeamFoundation - Gtk.TeamFoundation - - - true - full - false - ..\lib\net_2_0\ - DEBUG;TRACE - - - pdbonly - true - ..\lib\net_2_0\ - TRACE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {E0953653-D640-4338-BDAE-91DA9C3583F8} - Microsoft.TeamFoundation.Common - - - {B0953653-D640-4338-BDAE-91DA9C3583F8} - Microsoft.TeamFoundation.Client - - - {B0953653-D640-4338-BDAE-91DA9C3583F8} - Microsoft.TeamFoundation - - - {A0953653-D640-4338-BDAE-91DA9C3583F8} - Microsoft.TeamFoundation.VersionControl.Common - - - {F0953653-D640-4338-BDAE-91DA9C3583F8} - Microsoft.TeamFoundation.VersionControl.Client - - - - - - - + + + Debug + AnyCPU + {B0953653-A461-4338-BDAE-91DA9C35BBAA} + Library + false + OpenTF.Common + OpenTF.Common + + + true + full + false + ..\lib\net_2_0\ + DEBUG;TRACE + + + pdbonly + true + ..\lib\net_2_0\ + TRACE + + + + + + + + + + + + -- 2.11.4.GIT