Author: abock
Date: 2008-01-25 22:12:12 -0500 (Fri, 25 Jan 2008)
New Revision: 93974

Added:
   trunk/bake/src/Bake/Lang.boo
   trunk/bake/src/Bake/PkgConfig.boo
Modified:
   trunk/bake/ChangeLog
   trunk/bake/src/Bake/Exec.boo
   trunk/bake/src/Bake/Files.boo
   trunk/bake/src/Bake/Paths.boo
   trunk/bake/src/Bake/Target.boo
Log:
2008-01-25  Aaron Bockover  <[EMAIL PROTECTED]>

    * 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



Modified: trunk/bake/ChangeLog
===================================================================
--- trunk/bake/ChangeLog        2008-01-26 02:59:53 UTC (rev 93973)
+++ trunk/bake/ChangeLog        2008-01-26 03:12:12 UTC (rev 93974)
@@ -1,3 +1,21 @@
+2008-01-25  Aaron Bockover  <[EMAIL PROTECTED]>
+
+       * 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  <[EMAIL PROTECTED]>
 
        * Bake: initial project checkin

Modified: trunk/bake/src/Bake/Exec.boo
===================================================================
--- trunk/bake/src/Bake/Exec.boo        2008-01-26 02:59:53 UTC (rev 93973)
+++ trunk/bake/src/Bake/Exec.boo        2008-01-26 03:12:12 UTC (rev 93974)
@@ -30,16 +30,36 @@
 
 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):
-    exec (command, null as string)
+    return exec (command, null as string, true)
 
 def exec (command as string, args as List):
-    exec (command, join (args))
+    return exec (command, join (args), true)
 
 def exec (command as string, args as string):
-    log_action ("${command} ${args}")
-    proc = System.Diagnostics.Process.Start (command, args)
+    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 ()
 

Modified: trunk/bake/src/Bake/Files.boo
===================================================================
--- trunk/bake/src/Bake/Files.boo       2008-01-26 02:59:53 UTC (rev 93973)
+++ trunk/bake/src/Bake/Files.boo       2008-01-26 03:12:12 UTC (rev 93974)
@@ -41,11 +41,21 @@
     for file as string in files:
         delete (file)
 
-def delete (*files as (string)):
-    for file in files:
-        log_action ("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
+

Added: trunk/bake/src/Bake/Lang.boo
===================================================================
--- trunk/bake/src/Bake/Lang.boo        2008-01-26 02:59:53 UTC (rev 93973)
+++ trunk/bake/src/Bake/Lang.boo        2008-01-26 03:12:12 UTC (rev 93974)
@@ -0,0 +1,43 @@
+//
+// Lang.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
+
+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
+

Modified: trunk/bake/src/Bake/Paths.boo
===================================================================
--- trunk/bake/src/Bake/Paths.boo       2008-01-26 02:59:53 UTC (rev 93973)
+++ trunk/bake/src/Bake/Paths.boo       2008-01-26 03:12:12 UTC (rev 93974)
@@ -91,7 +91,9 @@
 
 def wildcard (path as string, mask as string) as List:
     mask = mask[2:] if mask.StartsWith ("./")
-    mask = mask.Replace ("*", ".*").Replace ("/", "\\/")
+    mask = mask.Replace (".", "\\.")
+    mask = mask.Replace ("*", ".*")
+    mask = mask.Replace ("/", "\\/")
     return wildcard (path, Regex ("^${mask}$"))
 
 def wildcard (path as string, mask as Regex) as List:

Added: trunk/bake/src/Bake/PkgConfig.boo
===================================================================
--- trunk/bake/src/Bake/PkgConfig.boo   2008-01-26 02:59:53 UTC (rev 93973)
+++ trunk/bake/src/Bake/PkgConfig.boo   2008-01-26 03:12:12 UTC (rev 93974)
@@ -0,0 +1,43 @@
+//
+// PkgConfig.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 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}") + " "
+

Modified: trunk/bake/src/Bake/Target.boo
===================================================================
--- trunk/bake/src/Bake/Target.boo      2008-01-26 02:59:53 UTC (rev 93973)
+++ trunk/bake/src/Bake/Target.boo      2008-01-26 03:12:12 UTC (rev 93974)
@@ -42,6 +42,9 @@
     [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
@@ -122,17 +125,30 @@
                 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):
-    Target.Add (name, dependencies, action)
+    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):
-    Target.Add (name, [dependency], action)
+    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.Add (name, [dependency], null)
+    target (name, dependency, null as callable)
 
 def target (name as string, action as callable):
     Target.Add (name, null, action)

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

Reply via email to