aboutsummaryrefslogtreecommitdiffstats
path: root/meta-networking/recipes-connectivity/samba/samba-4.1.12/0002-Adds-a-new-mode-to-samba-cross-compiling.patch
blob: fce3abcaa623befda02ff2d91a3595470be468ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
From add52538b9a0ccf66ca87c7a691bf59901765849 Mon Sep 17 00:00:00 2001
From: Uri Simchoni <urisimchoni@gmail.com>
Date: Mon, 18 May 2015 21:15:19 +0300
Subject: [PATCH 2/7] Adds a new mode to samba cross-compiling.

When both --cross-answers and --cross-execute are set, this means:
- Use cross-answers
- If answer is unknown, then instead of adding UNKNOWN to the cross-answers
  file and failing configure, the new mode runs cross-execute to determine the
  answer and adds that to the cross-answers file.

Signed-off-by: Uri Simchoni <urisimchoni@gmail.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>

Upstream-Status: Backport

Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
---
 buildtools/wafsamba/samba_cross.py | 46 ++++++++++++++++++++++++++++----------
 1 file changed, 34 insertions(+), 12 deletions(-)

diff --git a/buildtools/wafsamba/samba_cross.py b/buildtools/wafsamba/samba_cross.py
index fc1d78e..3f1ef12 100644
--- a/buildtools/wafsamba/samba_cross.py
+++ b/buildtools/wafsamba/samba_cross.py
@@ -45,7 +45,6 @@ def cross_answer(ca_file, msg):
     try:
         f = open(ca_file, 'r')
     except:
-        add_answer(ca_file, msg, ANSWER_UNKNOWN)
         return ANSWER_UNKNOWN
     for line in f:
         line = line.strip()
@@ -78,7 +77,6 @@ def cross_answer(ca_file, msg):
                 else:
                     raise Utils.WafError("Bad answer format '%s' in %s" % (line, ca_file))
     f.close()
-    add_answer(ca_file, msg, ANSWER_UNKNOWN)
     return ANSWER_UNKNOWN
 
 
@@ -86,24 +84,47 @@ class cross_Popen(Utils.pproc.Popen):
     '''cross-compilation wrapper for Popen'''
     def __init__(*k, **kw):
         (obj, args) = k
-
-        if '--cross-execute' in args:
-            # 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.extend(args[0:i])
-            args = newargs
-        elif '--cross-answers' in args:
+        use_answers = False
+        ans = ANSWER_UNKNOWN
+
+        # Three possibilities:
+        #   1. Only cross-answers - try the cross-answers file, and if
+        #      there's no corresponding answer, add to the file and mark
+        #      the configure process as unfinished.
+        #   2. Only cross-execute - get the answer from cross-execute
+        #   3. Both - try the cross-answers file, and if there is no
+        #      corresponding answer - use cross-execute to get an answer,
+        #       and add that answer to the file.
+        if '--cross-answers' in args:
             # when --cross-answers is set, then change the arguments
             # to use the cross answers if available
+            use_answers = True
             i = args.index('--cross-answers')
             ca_file = args[i+1]
             msg     = args[i+2]
             ans = cross_answer(ca_file, msg)
+
+        if '--cross-execute' in args and ans == ANSWER_UNKNOWN:
+            # 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.extend(args[0:i])
+            if use_answers:
+                p = real_Popen(newargs,
+                               stdout=Utils.pproc.PIPE,
+                               stderr=Utils.pproc.PIPE)
+                ce_out, ce_err = p.communicate()
+                ans = (p.returncode, ce_out)
+                add_answer(ca_file, msg, ans)
+            else:
+                args = newargs
+
+        if use_answers:
             if ans == ANSWER_UNKNOWN:
                 global cross_answers_incomplete
                 cross_answers_incomplete = True
+                add_answer(ca_file, msg, ans)
             (retcode, retstring) = ans
             args = ['/bin/sh', '-c', "echo -n '%s'; exit %d" % (retstring, retcode)]
         real_Popen.__init__(*(obj, args), **kw)
@@ -124,7 +145,8 @@ def SAMBA_CROSS_ARGS(conf, msg=None):
 
     if conf.env.CROSS_EXECUTE:
         ret.extend(['--cross-execute', conf.env.CROSS_EXECUTE])
-    elif conf.env.CROSS_ANSWERS:
+
+    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])
-- 
1.9.1