diff mbox series

[v1,06/24] docker: extend "cc" command to accept compiler

Message ID 20180410193919.28026-7-alex.bennee@linaro.org
State New
Headers show
Series fix building of tests/tcg | expand

Commit Message

Alex Bennée April 10, 2018, 7:39 p.m. UTC
When calling our cross-compilation images we want to call something
other than the default cc.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

---
 tests/docker/docker.py | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

-- 
2.16.2

Comments

Fam Zheng April 12, 2018, 8:07 a.m. UTC | #1
On Tue, 04/10 20:39, Alex Bennée wrote:
> When calling our cross-compilation images we want to call something

> other than the default cc.


Makes sense to me!

> 

> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

> ---

>  tests/docker/docker.py | 18 +++++++++++++++---

>  1 file changed, 15 insertions(+), 3 deletions(-)

> 

> diff --git a/tests/docker/docker.py b/tests/docker/docker.py

> index 8733266153..9444f4bea4 100755

> --- a/tests/docker/docker.py

> +++ b/tests/docker/docker.py

> @@ -397,6 +397,8 @@ class CcCommand(SubCommand):

>      def args(self, parser):

>          parser.add_argument("--image", "-i", required=True,

>                              help="The docker image in which to run cc")

> +        parser.add_argument("--cc",

> +                            help="The compiler executable to call")


If add "default='cc'" to this call, we don't need the 'if args.cc' check below.

>          parser.add_argument("--source-path", "-s", nargs="*", dest="paths",

>                              help="""Extra paths to (ro) mount into container for

>                              reading sources""")

> @@ -407,9 +409,19 @@ class CcCommand(SubCommand):

>          cwd = os.getcwd()

>          cmd = ["--rm", "-w", cwd,

>                 "-v", "%s:%s:rw" % (cwd, cwd)]

> -        for p in args.paths:

> -           cmd += ["-v", "%s:%s:ro,z" % (p, p)]

> -        cmd += [args.image, "cc"]

> +

> +        if args.paths:

> +            for p in args.paths:

> +                cmd += ["-v", "%s:%s:ro,z" % (p, p)]


I'm not sure the introduction of this if condition belongs to this patch, or is
necessary at all. Could you confirm?

Thanks.

Fam

> +

> +        cmd += [args.image]

> +

> +        # The compile command we are running

> +        if args.cc:

> +            cmd += [args.cc]

> +        else:

> +            cmd += ["cc"]

> +

>          cmd += argv

>          return Docker().command("run", cmd, True)

>  

> -- 

> 2.16.2

>
diff mbox series

Patch

diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index 8733266153..9444f4bea4 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -397,6 +397,8 @@  class CcCommand(SubCommand):
     def args(self, parser):
         parser.add_argument("--image", "-i", required=True,
                             help="The docker image in which to run cc")
+        parser.add_argument("--cc",
+                            help="The compiler executable to call")
         parser.add_argument("--source-path", "-s", nargs="*", dest="paths",
                             help="""Extra paths to (ro) mount into container for
                             reading sources""")
@@ -407,9 +409,19 @@  class CcCommand(SubCommand):
         cwd = os.getcwd()
         cmd = ["--rm", "-w", cwd,
                "-v", "%s:%s:rw" % (cwd, cwd)]
-        for p in args.paths:
-           cmd += ["-v", "%s:%s:ro,z" % (p, p)]
-        cmd += [args.image, "cc"]
+
+        if args.paths:
+            for p in args.paths:
+                cmd += ["-v", "%s:%s:ro,z" % (p, p)]
+
+        cmd += [args.image]
+
+        # The compile command we are running
+        if args.cc:
+            cmd += [args.cc]
+        else:
+            cmd += ["cc"]
+
         cmd += argv
         return Docker().command("run", cmd, True)