Author: abock
Date: 2008-01-21 23:34:17 -0500 (Mon, 21 Jan 2008)
New Revision: 93475
Added:
trunk/bake/Bakefile
trunk/bake/COPYING
trunk/bake/ChangeLog
trunk/bake/Makefile
trunk/bake/README
trunk/bake/bakestrap
trunk/bake/src/
trunk/bake/src/Bake/
trunk/bake/src/Bake/AutoBake.boo
trunk/bake/src/Bake/Bake.boo
trunk/bake/src/Bake/Booc.boo
trunk/bake/src/Bake/Context.boo
trunk/bake/src/Bake/Exec.boo
trunk/bake/src/Bake/Files.boo
trunk/bake/src/Bake/Globals.boo
trunk/bake/src/Bake/Gmcs.boo
trunk/bake/src/Bake/NetCompiler.boo
trunk/bake/src/Bake/Paths.boo
trunk/bake/src/Bake/Target.boo
Log:
Initial import of bake
Added: trunk/bake/Bakefile
===================================================================
--- trunk/bake/Bakefile 2008-01-22 04:18:01 UTC (rev 93474)
+++ trunk/bake/Bakefile 2008-01-22 04:34:17 UTC (rev 93475)
@@ -0,0 +1,8 @@
+assembly = "bake.exe"
+sources = wildcard ("src/Bake/*.boo")
+
+booc_target (assembly, sources, { "debug" : true })
+
+target ("clean") do:
+ delete (wildcard ("*.exe*"))
+
Added: trunk/bake/COPYING
===================================================================
--- trunk/bake/COPYING 2008-01-22 04:18:01 UTC (rev 93474)
+++ trunk/bake/COPYING 2008-01-22 04:34:17 UTC (rev 93475)
@@ -0,0 +1,7 @@
+Copyright (C) 2008 Novell, Inc.
+
+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.
Added: trunk/bake/ChangeLog
===================================================================
--- trunk/bake/ChangeLog 2008-01-22 04:18:01 UTC (rev 93474)
+++ trunk/bake/ChangeLog 2008-01-22 04:34:17 UTC (rev 93475)
@@ -0,0 +1,4 @@
+2008-01-22 Aaron Bockover <[EMAIL PROTECTED]>
+
+ * Bake: initial project checkin
+
Added: trunk/bake/Makefile
===================================================================
--- trunk/bake/Makefile 2008-01-22 04:18:01 UTC (rev 93474)
+++ trunk/bake/Makefile 2008-01-22 04:34:17 UTC (rev 93475)
@@ -0,0 +1,8 @@
+BAKE = bake.exe
+SOURCES = $(wildcard src/Bake/*.boo)
+
+$(BAKE): $(SOURCES)
+ booc -nologo -o:$@ $(SOURCES)
+
+clean:
+ rm -f *.exe*
Added: trunk/bake/README
===================================================================
--- trunk/bake/README 2008-01-22 04:18:01 UTC (rev 93474)
+++ trunk/bake/README 2008-01-22 04:34:17 UTC (rev 93475)
@@ -0,0 +1,23 @@
+Bake is a make replacement written in Boo. Bakefiles replace Makefiles, and
+are also written in Boo. The concept of targets, dependencies, and actions
+make up the core of Bake, just like make.
+
+Bake has a full function library including many helper functions and targets
+for building Mono/.NET projects.
+
+
+Building Bake
+=============
+
+Bake is able to build itself, but Bake is simple enough that typically we
+just build it with make to avoid bootstrap overhead. Therefore, to build
+Bake, just type "make".
+
+To bootstrap Bake however, run "make", and then source in the bakestrap file
+into BASH:
+
+$ make
+$ . bakestrap
+$ touch src/Bake/Bake.boo
+$ bake
+
Added: trunk/bake/bakestrap
===================================================================
--- trunk/bake/bakestrap 2008-01-22 04:18:01 UTC (rev 93474)
+++ trunk/bake/bakestrap 2008-01-22 04:34:17 UTC (rev 93475)
@@ -0,0 +1,7 @@
+# Source this file into your BASH environment
+# $ . bakestrap
+# Then you will be able to run "bake"
+
+bakedir=$PWD
+alias bake='mono --debug $bakedir/bake.exe'
+
Added: trunk/bake/src/Bake/AutoBake.boo
===================================================================
--- trunk/bake/src/Bake/AutoBake.boo 2008-01-22 04:18:01 UTC (rev 93474)
+++ trunk/bake/src/Bake/AutoBake.boo 2008-01-22 04:34:17 UTC (rev 93475)
@@ -0,0 +1,41 @@
+//
+// AutoBake.boo
+//
+// Author:
+// Aaron Bockover <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2008 Novell, Inc.
+//
+// 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.
+//
+
+namespace Bake
+
+class AutoBakeInst:
+
+ [property (SUBDIRS)]
+ subdirs = []
+
+static class AutoBake:
+
+ static SUBDIRS as List:
+ get: return Context.Current.AutoBake.SUBDIRS
+ set: Context.Current.AutoBake.SUBDIRS = value
+
Added: trunk/bake/src/Bake/Bake.boo
===================================================================
--- trunk/bake/src/Bake/Bake.boo 2008-01-22 04:18:01 UTC (rev 93474)
+++ trunk/bake/src/Bake/Bake.boo 2008-01-22 04:34:17 UTC (rev 93475)
@@ -0,0 +1,61 @@
+//
+// Bake.boo
+//
+// Author:
+// Aaron Bockover <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2008 Novell, Inc.
+//
+// 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.
+//
+
+namespace Bake
+
+import System
+
+def die (message as string):
+ log (message)
+ Environment.Exit (1)
+
+def log (message as string):
+ print "bake: ${message}"
+
+def log_action (message as string):
+ print message if Globals.LogActions
+
+def bake ():
+ for subdir as string in AutoBake.SUBDIRS:
+ pushd (subdir)
+ Context (array (string, Globals.TargetArgs))
+ popd ()
+
+ if Globals.TargetArgs.Count > 0:
+ for target_name in Globals.TargetArgs:
+ target as Target = Target.Find (target_name)
+ if not target:
+ die ("No rule to bake target `${target_name}'.")
+ target.Update ()
+ elif Target.First:
+ Target.First.Update ()
+ elif not AutoBake.SUBDIRS or AutoBake.SUBDIRS.Count == 0:
+ die ("No targets.")
+
+Context (argv)
+
Added: trunk/bake/src/Bake/Booc.boo
===================================================================
--- trunk/bake/src/Bake/Booc.boo 2008-01-22 04:18:01 UTC (rev 93474)
+++ trunk/bake/src/Bake/Booc.boo 2008-01-22 04:34:17 UTC (rev 93475)
@@ -0,0 +1,71 @@
+//
+// Booc.boo
+//
+// Author:
+// Aaron Bockover <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2008 Novell, Inc.
+//
+// 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.
+//
+
+namespace Bake
+
+class Booc (NetCompiler):
+
+ def constructor ():
+ pass
+
+ def constructor (args as Hash):
+ PopulateFromHash (args)
+
+ override Compiler as string:
+ get: return "booc"
+
+ protected override def GenerateCustomArgs () as string:
+ return "-nologo "
+
+ protected override def GenerateDebugArg () as string:
+ if Debug:
+ return "-debug+ "
+ return "-debug- "
+
+def booc_target (output as string, sources as List):
+ booc_target (output, sources, null)
+
+def booc_target (output as string, sources as List, action as callable):
+ booc_target (output, sources, null, action)
+
+def booc_target (output as string, sources as List, extra_args as Hash):
+ booc_target (output, sources, extra_args, null)
+
+def booc_target (output as string, sources as List, extra_args as Hash, action
as callable):
+ if not extra_args:
+ extra_args = Hash ()
+ extra_args["out"] = output
+ extra_args["sources"] = sources
+ booc_target (extra_args, action)
+
+def booc_target (args as Hash):
+ booc_target (args, null)
+
+def booc_target (args as Hash, action as callable):
+ net_compile_target (typeof (Booc), args, action)
+
Added: trunk/bake/src/Bake/Context.boo
===================================================================
--- trunk/bake/src/Bake/Context.boo 2008-01-22 04:18:01 UTC (rev 93474)
+++ trunk/bake/src/Bake/Context.boo 2008-01-22 04:34:17 UTC (rev 93475)
@@ -0,0 +1,120 @@
+//
+// Context.boo
+//
+// Author:
+// Aaron Bockover <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2008 Novell, Inc.
+//
+// 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.
+//
+
+namespace Bake
+
+import System
+import System.IO
+import System.Text
+import System.Reflection
+import System.Collections
+
+import Boo.Lang.Compiler
+import Boo.Lang.Compiler.IO
+import Boo.Lang.Compiler.Pipelines
+
+class Context:
+
+ bakefile as string
+ args = []
+
+ [getter (AutoBake)]
+ autobake = AutoBakeInst ()
+
+ [getter (Targets)]
+ targets = []
+
+ [property (CurrentTarget)]
+ current_target as Target
+
+ [property (Stack)]
+ public static stack = Stack ()
+
+ public static Current as Context:
+ get:
+ if Stack.Count > 0:
+ return Stack.Peek () as Context
+ return null
+
+ def constructor (argv as (string)):
+ args = List (argv)
+ bf_index = args.IndexOf ("-f")
+
+ if bf_index >= 0 and args.Count > bf_index + 1:
+ bakefile = args[bf_index + 1]
+ args.RemoveAt (bf_index)
+ args.RemoveAt (bf_index)
+ elif bf_index >= 0:
+ die ("No bakefile specified for -f.")
+ elif File.Exists ("Bakefile"):
+ bakefile = "Bakefile"
+ elif File.Exists ("bakefile"):
+ bakefile = "bakefile"
+
+ if not bakefile or not File.Exists (bakefile):
+ die ("No targets specified and no Bakefile found.")
+
+ booc_input as duck
+
+ if "-pure" in args:
+ booc_input = FileInput (bakefile)
+ else:
+ builder = StringBuilder ()
+ builder.Append ("import Bake\n\n")
+ using file = File.OpenText (bakefile):
+ line as string
+ while true:
+ line = file.ReadLine ()
+ if not line:
+ break
+ builder.Append (line)
+ builder.Append ("\n")
+
+ builder.Append ("\nbake ()")
+ booc_input = StringInput (bakefile, builder.ToString ())
+
+ _booc = BooCompiler ()
+ _booc.Parameters.Input.Add (booc_input)
+ _booc.Parameters.Pipeline = CompileToMemory ()
+ _booc.Parameters.Ducky = true
+
+ for assembly as Assembly in AppDomain.CurrentDomain.GetAssemblies ():
+ _booc.Parameters.References.Add (assembly)
+
+ context = _booc.Run ()
+
+ if context.GeneratedAssembly is null:
+ print join (e for e in context.Errors, "\n")
+ else:
+ if not Globals.CommandLineArgs:
+ Globals.CommandLineArgs = array (string, args)
+
+ Stack.Push (self)
+ entry = context.GeneratedAssembly.EntryPoint
+ entry.Invoke (null, array (object, entry.GetParameters ().Length))
+ Stack.Pop ()
Added: trunk/bake/src/Bake/Exec.boo
===================================================================
--- trunk/bake/src/Bake/Exec.boo 2008-01-22 04:18:01 UTC (rev 93474)
+++ trunk/bake/src/Bake/Exec.boo 2008-01-22 04:34:17 UTC (rev 93475)
@@ -0,0 +1,45 @@
+//
+// Exec.boo
+//
+// Author:
+// Aaron Bockover <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2008 Novell, Inc.
+//
+// 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.
+//
+
+namespace Bake
+
+import System
+
+def exec (command as string):
+ exec (command, null as string)
+
+def exec (command as string, args as List):
+ exec (command, join (args))
+
+def exec (command as string, args as string):
+ log_action ("${command} ${args}")
+ proc = System.Diagnostics.Process.Start (command, args)
+ proc.WaitForExit ()
+ if proc.ExitCode != 0:
+ die ("*** [${Target.Current}] Error ${proc.ExitCode}")
+
Added: trunk/bake/src/Bake/Files.boo
===================================================================
--- trunk/bake/src/Bake/Files.boo 2008-01-22 04:18:01 UTC (rev 93474)
+++ trunk/bake/src/Bake/Files.boo 2008-01-22 04:34:17 UTC (rev 93475)
@@ -0,0 +1,51 @@
+//
+// Files.boo
+//
+// Author:
+// Aaron Bockover <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2008 Novell, Inc.
+//
+// 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.
+//
+
+namespace Bake
+
+import System
+import System.IO
+
+def touch (file as string):
+ if File.Exists (file):
+ File.SetLastWriteTime (file, DateTime.Now)
+ else:
+ using File.OpenWrite (file)
+
+def delete (files as List):
+ for file as string in files:
+ delete (file)
+
+def delete (*files as (string)):
+ for file in files:
+ log_action ("delete (${file})")
+ File.Delete (file)
+
+def exists (file as string):
+ return File.Exists (file)
+
Added: trunk/bake/src/Bake/Globals.boo
===================================================================
--- trunk/bake/src/Bake/Globals.boo 2008-01-22 04:18:01 UTC (rev 93474)
+++ trunk/bake/src/Bake/Globals.boo 2008-01-22 04:34:17 UTC (rev 93475)
@@ -0,0 +1,40 @@
+//
+// Globals.boo
+//
+// Author:
+// Aaron Bockover <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2008 Novell, Inc.
+//
+// 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.
+//
+
+namespace Bake
+
+static class Globals:
+
+ public static CommandLineArgs as (string) = null
+ public static TargetArgs:
+ get: return [a for a in CommandLineArgs if not a.StartsWith ("-")]
+
+ public static LogActions = true
+
+ internal static PathStack = []
+
Added: trunk/bake/src/Bake/Gmcs.boo
===================================================================
--- trunk/bake/src/Bake/Gmcs.boo 2008-01-22 04:18:01 UTC (rev 93474)
+++ trunk/bake/src/Bake/Gmcs.boo 2008-01-22 04:34:17 UTC (rev 93475)
@@ -0,0 +1,35 @@
+//
+// Gmcs.boo
+//
+// Author:
+// Aaron Bockover <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2008 Novell, Inc.
+//
+// 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.
+//
+
+namespace Bake
+
+class Gmcs (NetCompiler):
+
+ override Compiler as string:
+ get: return "gmcs"
+
Added: trunk/bake/src/Bake/NetCompiler.boo
===================================================================
--- trunk/bake/src/Bake/NetCompiler.boo 2008-01-22 04:18:01 UTC (rev 93474)
+++ trunk/bake/src/Bake/NetCompiler.boo 2008-01-22 04:34:17 UTC (rev 93475)
@@ -0,0 +1,157 @@
+//
+// NetCompiler.boo
+//
+// Author:
+// Aaron Bockover <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2008 Novell, Inc.
+//
+// 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.
+//
+
+namespace Bake
+
+import System
+import System.Collections
+
+enum OutputTarget:
+ Exe
+ Library
+
+abstract class NetCompiler:
+
+ abstract Compiler as string:
+ get: pass
+
+ [Property (OutputFile)]
+ output_file as string
+
+ [Property (Sources)]
+ sources as List
+
+ [Property (References)]
+ references as List
+
+ [Property (Resources)]
+ resources as object
+
+ [Property (Debug)]
+ debug as bool = false
+
+ [Property (Unsafe)]
+ unsafe as bool = false
+
+ [Property (Target)]
+ target as OutputTarget = OutputTarget.Exe
+
+ def constructor ():
+ pass
+
+ def constructor (args as Hash):
+ PopulateFromHash (args)
+
+ public virtual def PopulateFromHash (args as Hash):
+ OutputFile = args["out"] if args["out"]
+ Sources = args["sources"] if args["sources"]
+ References = args["references"] if args["references"]
+ Resources = args["resources"] if args["resources"]
+ Debug = args["debug"] if args["debug"]
+ Unsafe = args["unsafe"] if args["unsafe"]
+ Target = args["target"] if args["target"]
+
+ protected virtual def GenerateCustomArgs () as string:
+ return null
+
+ protected virtual def GenerateOutputFileArg () as string:
+ return "-out:${OutputFile} "
+
+ protected virtual def GenerateDebugArg () as string:
+ if Debug:
+ return "-debug "
+ return null
+
+ protected virtual def GenerateUnsafeArg () as string:
+ if Unsafe:
+ return "-unsafe "
+ return null
+
+ protected virtual def GenerateTargetArg () as string:
+ return "-target:${Target.ToString ().ToLower ()} "
+
+ protected virtual def GenerateSourcesArgs () as string:
+ return join (Sources).Trim ()
+
+ protected virtual def GenerateReferencesArgs () as string:
+ if not References:
+ return null
+
+ output = []
+ for reference as string in References:
+ if reference.StartsWith ('-'):
+ output.Add (reference)
+ else:
+ output.Add ("-r:${reference}")
+
+ return join (output).Trim () + " "
+
+ protected virtual def GenerateResourcesArgs () as string:
+ if not Resources:
+ return null
+
+ if not Resources isa Hash and not Resources isa List:
+ raise ArgumentException ("Resources must be a Hash or a List")
+
+ output = []
+ for resource in Resources:
+ if resource isa DictionaryEntry:
+ res = cast (DictionaryEntry, resource)
+ output.Add ("-resource:${res.Value},${res.Key}")
+ else:
+ output.Add ("-resource:${resource}")
+
+ return join (output).Trim () + " "
+
+ virtual def Compile ():
+ command = GenerateCustomArgs ()
+ command += GenerateDebugArg ()
+ command += GenerateUnsafeArg ()
+ command += GenerateOutputFileArg ()
+ command += GenerateTargetArg ()
+
+ refs = GenerateReferencesArgs ()
+ if refs:
+ command += refs
+
+ res = GenerateResourcesArgs ()
+ if res:
+ command += res
+
+ command += GenerateSourcesArgs ()
+
+ exec (Compiler, command.Trim ())
+
+def net_compile_target (type as Type, args as Hash, action as callable):
+ target (args["out"] as string, args["sources"] as List) do:
+ compiler = cast (NetCompiler, Activator.CreateInstance (type))
+ compiler.PopulateFromHash (args)
+ compiler.Compile ()
+ if action:
+ action ()
+
Added: trunk/bake/src/Bake/Paths.boo
===================================================================
--- trunk/bake/src/Bake/Paths.boo 2008-01-22 04:18:01 UTC (rev 93474)
+++ trunk/bake/src/Bake/Paths.boo 2008-01-22 04:34:17 UTC (rev 93475)
@@ -0,0 +1,100 @@
+//
+// Paths.boo
+//
+// Author:
+// Aaron Bockover <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2008 Novell, Inc.
+//
+// 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.
+//
+
+namespace Bake
+
+import System
+import System.IO
+import System.Text.RegularExpressions
+
+def combine (path1 as string, path2 as string):
+ return Path.Combine (path1, path2)
+
+def fullpath (path as string):
+ return Path.GetFullPath (path)
+
+def filename (path as string):
+ return Path.GetFileName (path)
+
+def pwd ():
+ return Directory.GetCurrentDirectory ()
+
+def cd (directory as string):
+ Directory.SetCurrentDirectory (directory)
+
+def pushd (path1 as string, path2 as string):
+ pushd (Path.Combine (path1, path2))
+
+def pushd (directory as string):
+ Globals.PathStack.Push (pwd ())
+ try:
+ directory = fullpath (directory)
+ cd (directory)
+ print "bake[${Globals.PathStack.Count}]: Entering directory
`${directory}'"
+ except:
+ die ("Directory `${directory}' does not exist.")
+
+def popd ():
+ if Globals.PathStack.Count > 0:
+ print "bake[${Globals.PathStack.Count}]: Leaving directory `${pwd ()}'"
+ cd (Globals.PathStack.Pop ())
+
+def find () as List:
+ return find (".")
+
+def find (path as string) as List:
+ return find (path, null)
+
+def find (path as string, filter as callable) as List:
+ paths = []
+ try:
+ for dir in Directory.GetDirectories (path):
+ paths.Extend (find (dir, filter))
+ for file in Directory.GetFiles (path):
+ file = file[2:] if file.StartsWith ("./")
+ if not filter or (filter and filter (file)):
+ paths.Add (file)
+ return paths
+ except:
+ return paths
+
+def wildcard (mask as string) as List:
+ return wildcard (".", mask)
+
+def wildcard (mask as Regex) as List:
+ return wildcard (".", mask)
+
+def wildcard (path as string, mask as string) as List:
+ mask = mask[2:] if mask.StartsWith ("./")
+ mask = mask.Replace ("*", ".*").Replace ("/", "\\/")
+ return wildcard (path, Regex ("^${mask}$"))
+
+def wildcard (path as string, mask as Regex) as List:
+ return find (path) do (file as string):
+ return file =~ mask
+
Added: trunk/bake/src/Bake/Target.boo
===================================================================
--- trunk/bake/src/Bake/Target.boo 2008-01-22 04:18:01 UTC (rev 93474)
+++ trunk/bake/src/Bake/Target.boo 2008-01-22 04:34:17 UTC (rev 93475)
@@ -0,0 +1,142 @@
+//
+// Target.boo
+//
+// Author:
+// Aaron Bockover <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2008 Novell, Inc.
+//
+// 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.
+//
+
+namespace Bake
+
+import System
+import System.IO
+
+class Target:
+
+ [getter (Name)]
+ name as string
+
+ [getter (Dependencies)]
+ dependencies = []
+
+ [getter (Action)]
+ action as callable
+
+ static Current as Target:
+ get: return Context.Current.CurrentTarget
+ set: Context.Current.CurrentTarget = value
+
+ private static targets:
+ get: return Context.Current.Targets
+
+ static First as Target:
+ get:
+ if targets.Count > 0:
+ return targets[0] as Target
+ return null
+
+ static TargetCount:
+ get: return targets.Count
+
+ def constructor (name as string, dependencies as List, action as callable):
+ self.dependencies = dependencies
+ self.name = name
+ self.action = action
+
+ override def ToString () as string:
+ return name
+
+ def InvokeAction ():
+ action ()
+
+ def Update () as bool:
+ if not dependencies and action:
+ InvokeAction ()
+ return true
+ elif not dependencies and not action:
+ return false
+
+ for dep in dependencies:
+ dep_target = Target.Find (dep)
+ if dep_target:
+ UpdateDependency (dep_target)
+ elif not File.Exists (dep):
+ die ("No rule to bake target `${dep}', needed by `${self}'.")
+
+ if action and (not File.Exists (name) or TargetOlderThan
(dependencies)):
+ Current = self
+ InvokeAction ()
+ UpdateDependencies ()
+ return true
+
+ UpdateDependencies ()
+ return false
+
+ def UpdateDependencies ():
+ for target as Target in targets:
+ continue if target != self
+ if target.Dependencies.Contains (name):
+ UpdateDependency (target)
+
+ def UpdateDependency (target as Target):
+ if not target.Update () and File.Exists (target.Name) and
target.Dependencies:
+ log ("`${target}' is up to date.")
+
+ def TargetOlderThan (file as string):
+ time_1 = File.GetLastWriteTime (file)
+ time_2 = File.GetLastWriteTime (name)
+ return time_1 > time_2
+
+ def TargetOlderThan (files as List):
+ for file as string in files:
+ if TargetOlderThan (file):
+ return true
+ return false
+
+ static def Add (name as string, dependencies as List, action as callable):
+ targets.Add (Target (name, dependencies, action))
+
+ static def Find (name as string):
+ for target as Target in targets:
+ if target.Name == name:
+ return target
+ return null
+
+def target (name as string, dependencies as List, action as callable):
+ Target.Add (name, dependencies, action)
+
+def target (name as string, dependency as string, action as callable):
+ Target.Add (name, [dependency], action)
+
+def target (name as string, dependencies as List):
+ Target.Add (name, dependencies, null)
+
+def target (name as string, dependency as string):
+ Target.Add (name, [dependency], null)
+
+def target (name as string, action as callable):
+ Target.Add (name, null, action)
+
+def target (name as string):
+ Target.Add (name, null, null)
+
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches