wafsamba: remove tru64cc.py as it's not compatible with waf 2
[samba.git] / buildtools / wafsamba / samba_cross.py
index 9ca2f8d4610d8c7def48a3bb919bccc207d4b323..eee31179fed110eaf366de92e9d84a6f7bfde93b 100644 (file)
@@ -1,12 +1,13 @@
 # functions for handling cross-compilation
 
 # functions for handling cross-compilation
 
-import Utils, Logs, sys, os, Options, re
-from Configure import conf
+import os, sys, re, shlex
+from waflib import Utils, Logs, Options, Errors, Context
+from waflib.Configure import conf
 
 real_Popen = None
 
 ANSWER_UNKNOWN = (254, "")
 
 real_Popen = None
 
 ANSWER_UNKNOWN = (254, "")
-ANSWER_FAIL    = (255, "")
+ANSWER_NO      = (1, "")
 ANSWER_OK      = (0, "")
 
 cross_answers_incomplete = False
 ANSWER_OK      = (0, "")
 
 cross_answers_incomplete = False
@@ -33,10 +34,13 @@ def add_answer(ca_file, msg, answer):
         f.write('%s: OK\n' % msg)
     elif answer == ANSWER_UNKNOWN:
         f.write('%s: UNKNOWN\n' % msg)
         f.write('%s: OK\n' % msg)
     elif answer == ANSWER_UNKNOWN:
         f.write('%s: UNKNOWN\n' % msg)
-    elif answer == ANSWER_FAIL:
-        f.write('%s: FAIL\n' % msg)
+    elif answer == ANSWER_NO:
+        f.write('%s: NO\n' % msg)
     else:
     else:
-        f.write('%s: (%d, "%s")\n' % (msg, retcode, retstring))
+        if retcode == 0:
+            f.write('%s: "%s"\n' % (msg, retstring))
+        else:
+            f.write('%s: (%d, "%s")\n' % (msg, retcode, retstring))
     f.close()
 
 
     f.close()
 
 
@@ -51,7 +55,7 @@ def cross_answer(ca_file, msg):
         if line == '' or line[0] == '#':
             continue
         if line.find(':') != -1:
         if line == '' or line[0] == '#':
             continue
         if line.find(':') != -1:
-            a = line.split(':')
+            a = line.split(':', 1)
             thismsg = a[0].strip()
             if thismsg != msg:
                 continue
             thismsg = a[0].strip()
             if thismsg != msg:
                 continue
@@ -64,7 +68,7 @@ def cross_answer(ca_file, msg):
                 return ANSWER_UNKNOWN
             elif ans == "FAIL" or ans == "NO":
                 f.close()
                 return ANSWER_UNKNOWN
             elif ans == "FAIL" or ans == "NO":
                 f.close()
-                return ANSWER_FAIL
+                return ANSWER_NO
             elif ans[0] == '"':
                 f.close()
                 return (0, ans.strip('"'))
             elif ans[0] == '"':
                 f.close()
                 return (0, ans.strip('"'))
@@ -77,12 +81,12 @@ def cross_answer(ca_file, msg):
                     f.close()
                     return (int(m.group(1)), m.group(2))
                 else:
                     f.close()
                     return (int(m.group(1)), m.group(2))
                 else:
-                    raise Utils.WafError("Bad answer format '%s' in %s" % (line, ca_file))
+                    raise Errors.WafError("Bad answer format '%s' in %s" % (line, ca_file))
     f.close()
     return ANSWER_UNKNOWN
 
 
     f.close()
     return ANSWER_UNKNOWN
 
 
-class cross_Popen(Utils.pproc.Popen):
+class cross_Popen(Utils.subprocess.Popen):
     '''cross-compilation wrapper for Popen'''
     def __init__(*k, **kw):
         (obj, args) = k
     '''cross-compilation wrapper for Popen'''
     def __init__(*k, **kw):
         (obj, args) = k
@@ -110,12 +114,12 @@ class cross_Popen(Utils.pproc.Popen):
             # when --cross-execute is set, then change the arguments
             # to use the cross emulator
             i = args.index('--cross-execute')
             # when --cross-execute is set, then change the arguments
             # to use the cross emulator
             i = args.index('--cross-execute')
-            newargs = args[i+1].split()
+            newargs = shlex.split(args[i+1])
             newargs.extend(args[0:i])
             if use_answers:
                 p = real_Popen(newargs,
             newargs.extend(args[0:i])
             if use_answers:
                 p = real_Popen(newargs,
-                               stdout=Utils.pproc.PIPE,
-                               stderr=Utils.pproc.PIPE)
+                               stdout=Utils.subprocess.PIPE,
+                               stderr=Utils.subprocess.PIPE)
                 ce_out, ce_err = p.communicate()
                 ans = (p.returncode, ce_out)
                 add_answer(ca_file, msg, ans)
                 ce_out, ce_err = p.communicate()
                 ans = (p.returncode, ce_out)
                 add_answer(ca_file, msg, ans)
@@ -140,8 +144,8 @@ def SAMBA_CROSS_ARGS(conf, msg=None):
 
     global real_Popen
     if real_Popen is None:
 
     global real_Popen
     if real_Popen is None:
-        real_Popen  = Utils.pproc.Popen
-        Utils.pproc.Popen = cross_Popen
+        real_Popen  = Utils.subprocess.Popen
+        Utils.subprocess.Popen = cross_Popen
 
     ret = []
 
 
     ret = []
 
@@ -150,11 +154,11 @@ def SAMBA_CROSS_ARGS(conf, msg=None):
 
     if conf.env.CROSS_ANSWERS:
         if msg is None:
 
     if conf.env.CROSS_ANSWERS:
         if msg is None:
-            raise Utils.WafError("Cannot have NULL msg in cross-answers")
-        ret.extend(['--cross-answers', os.path.join(Options.launch_dir, conf.env.CROSS_ANSWERS), msg])
+            raise Errors.WafError("Cannot have NULL msg in cross-answers")
+        ret.extend(['--cross-answers', os.path.join(Context.launch_dir, conf.env.CROSS_ANSWERS), msg])
 
     if ret == []:
 
     if ret == []:
-        raise Utils.WafError("Cannot cross-compile without either --cross-execute or --cross-answers")
+        raise Errors.WafError("Cannot cross-compile without either --cross-execute or --cross-answers")
 
     return ret
 
 
     return ret
 
@@ -163,5 +167,5 @@ def SAMBA_CROSS_CHECK_COMPLETE(conf):
     '''check if we have some unanswered questions'''
     global cross_answers_incomplete
     if conf.env.CROSS_COMPILE and cross_answers_incomplete:
     '''check if we have some unanswered questions'''
     global cross_answers_incomplete
     if conf.env.CROSS_COMPILE and cross_answers_incomplete:
-        raise Utils.WafError("Cross answers file %s is incomplete" % conf.env.CROSS_ANSWERS)
+        raise Errors.WafError("Cross answers file %s is incomplete" % conf.env.CROSS_ANSWERS)
     return True
     return True