Skip to content
Browse files

Move to old-code

svn path=/old-code/; revision=156216
  • Loading branch information...
1 parent 0a6b999 commit 795f1c965f53d07ef54bf6340d37bcb7ee12af06 @migueldeicaza migueldeicaza committed
View
8 bake/Bakefile
@@ -0,0 +1,8 @@
+assembly = "bake.exe"
+sources = wildcard ("src/Bake/*.boo")
+
+booc_target (assembly, sources, { "debug" : true })
+
+target ("clean") do:
+ delete (wildcard ("*.exe*"))
+
View
7 bake/COPYING
@@ -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.
View
22 bake/ChangeLog
@@ -0,0 +1,22 @@
+2008-01-25 Aaron Bockover <abockover@novell.com>
+
+ * src/Bake/Exec.boo: Define a sweet _ exec command that munges everything
+ together; make exec return stdout
+
+ * src/Bake/Files.boo: Allow delete to take params of object, convert
+ to a list and flatten; added ch_ext, changes an extension on a list
+ of files
+
+ * src/Bake/Lang.boo: Added each and flatten methods
+
+ * src/Bake/Paths.boo: Properly escape '.' as '\.'
+
+ * src/Bake/PkgConfig.boo: Added basic pkg-config support
+
+ * src/Bake/Target.boo: Added make % style rule support for expanding
+ to multiple targets based on dependency input
+
+2008-01-22 Aaron Bockover <abockover@novell.com>
+
+ * Bake: initial project checkin
+
View
8 bake/Makefile
@@ -0,0 +1,8 @@
+BAKE = bake.exe
+SOURCES = $(wildcard src/Bake/*.boo)
+
+$(BAKE): $(SOURCES)
+ booc -nologo -o:$@ $(SOURCES)
+
+clean:
+ rm -f *.exe*
View
23 bake/README
@@ -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
+
View
7 bake/bakestrap
@@ -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'
+
View
41 bake/src/Bake/AutoBake.boo
@@ -0,0 +1,41 @@
+//
+// AutoBake.boo
+//
+// Author:
+// Aaron Bockover <abockover@novell.com>
+//
+// 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
+
View
61 bake/src/Bake/Bake.boo
@@ -0,0 +1,61 @@
+//
+// Bake.boo
+//
+// Author:
+// Aaron Bockover <abockover@novell.com>
+//
+// 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)
+
View
71 bake/src/Bake/Booc.boo
@@ -0,0 +1,71 @@
+//
+// Booc.boo
+//
+// Author:
+// Aaron Bockover <abockover@novell.com>
+//
+// 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)
+
View
120 bake/src/Bake/Context.boo
@@ -0,0 +1,120 @@
+//
+// Context.boo
+//
+// Author:
+// Aaron Bockover <abockover@novell.com>
+//
+// 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 ()
View
65 bake/src/Bake/Exec.boo
@@ -0,0 +1,65 @@
+//
+// Exec.boo
+//
+// Author:
+// Aaron Bockover <abockover@novell.com>
+//
+// 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 _ (command as string):
+ return _ (command, true)
+
+def __ (command as string):
+ return _ (command, false)
+
+def _ (command as string, echo as bool):
+ ofs = command.IndexOf (" ")
+ if ofs < 0:
+ return exec (command)
+ return exec (command[:ofs], command[ofs + 1:], echo)
+
+def exec (command as string):
+ return exec (command, null as string, true)
+
+def exec (command as string, args as List):
+ return exec (command, join (args), true)
+
+def exec (command as string, args as string):
+ return exec (command, args, true)
+
+def exec (command as string, args as string, echo as bool) as string:
+ if echo:
+ print "${command} ${args}"
+ proc = shellp (command, args)
+ proc.WaitForExit ()
+ stderr = proc.StandardError.ReadToEnd ()
+ if not String.IsNullOrEmpty (stderr):
+ Console.Error.Write (stderr)
+ if proc.ExitCode != 0:
+ die ("*** [${Target.Current}] Error ${proc.ExitCode}")
+ return proc.StandardOutput.ReadToEnd ().Trim ()
+
View
61 bake/src/Bake/Files.boo
@@ -0,0 +1,61 @@
+//
+// Files.boo
+//
+// Author:
+// Aaron Bockover <abockover@novell.com>
+//
+// 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 (object)):
+ list = flatten (List (files))
+ log_action ("delete (${list})")
+ for file in list:
+ File.Delete (file)
+
+def exists (file as string):
+ return File.Exists (file)
+
+def ch_ext (file as string, new_ext as string) as string:
+ return Path.ChangeExtension (file, new_ext)
+
+def ch_ext (files as List, new_ext as string) as List:
+ list = []
+ for file as string in files:
+ list.Add (ch_ext (file, new_ext))
+ return list
+
View
40 bake/src/Bake/Globals.boo
@@ -0,0 +1,40 @@
+//
+// Globals.boo
+//
+// Author:
+// Aaron Bockover <abockover@novell.com>
+//
+// 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 = []
+
View
35 bake/src/Bake/Gmcs.boo
@@ -0,0 +1,35 @@
+//
+// Gmcs.boo
+//
+// Author:
+// Aaron Bockover <abockover@novell.com>
+//
+// 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"
+
View
43 bake/src/Bake/Lang.boo
@@ -0,0 +1,43 @@
+//
+// Lang.boo
+//
+// Author:
+// Aaron Bockover <abockover@novell.com>
+//
+// 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
+
+def each (items as List, action as callable):
+ for item in items:
+ action (item)
+
+def flatten (item) as List:
+ list = []
+ if item isa List:
+ for sub_item in item:
+ list += flatten (sub_item)
+ else:
+ list.Add (item)
+ return list
+
View
157 bake/src/Bake/NetCompiler.boo
@@ -0,0 +1,157 @@
+//
+// NetCompiler.boo
+//
+// Author:
+// Aaron Bockover <abockover@novell.com>
+//
+// 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 ()
+
View
102 bake/src/Bake/Paths.boo
@@ -0,0 +1,102 @@
+//
+// Paths.boo
+//
+// Author:
+// Aaron Bockover <abockover@novell.com>
+//
+// 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 (".", "\\.")
+ mask = mask.Replace ("*", ".*")
+ mask = mask.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
+
View
43 bake/src/Bake/PkgConfig.boo
@@ -0,0 +1,43 @@
+//
+// PkgConfig.boo
+//
+// Author:
+// Aaron Bockover <abockover@novell.com>
+//
+// 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 PkgConfig:
+
+ [Getter (Libs)]
+ libs as string
+
+ [Getter (Cflags)]
+ cflags as string
+
+ def constructor (packages as List):
+ for package as string in packages:
+ libs += __ ("pkg-config --libs ${package}") + " "
+ cflags += __ ("pkg-config --cflags ${package}") + " "
+
View
158 bake/src/Bake/Target.boo
@@ -0,0 +1,158 @@
+//
+// Target.boo
+//
+// Author:
+// Aaron Bockover <abockover@novell.com>
+//
+// 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
+
+ Dependency as string:
+ get: return Dependencies[0]
+
+ 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
+
+private def NameIsRule (name as string):
+ return name and len (name) > 2 and name[:2] == "%."
+
+def target (name as string, dependencies as List, action as callable):
+ deps = flatten (dependencies)
+ if NameIsRule (name):
+ for dep as string in deps:
+ Target.Add (ch_ext (dep, name[2:]), [dep], action)
+ else:
+ Target.Add (name, deps, action)
+
+def target (name as string, dependency as string, action as callable):
+ if NameIsRule (name) and NameIsRule (dependency):
+ output_ext = name[2:]
+ for input_file as string in wildcard ("*.${dependency[2:]}"):
+ Target.Add (ch_ext (input_file, output_ext), [input_file], action)
+ else:
+ 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 (name, dependency, null as callable)
+
+def target (name as string, action as callable):
+ Target.Add (name, null, action)
+
+def target (name as string):
+ Target.Add (name, null, null)
+

0 comments on commit 795f1c9

Please sign in to comment.
Something went wrong with that request. Please try again.