Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/2] graph-depends: display virtual package with italic style
@ 2015-01-02  8:49 Francois Perrad
  2015-01-02  8:49 ` [Buildroot] [PATCH 2/2] graph-depends: add an option --stop-on-virtual Francois Perrad
  2015-01-02 11:37 ` [Buildroot] [PATCH 1/2] graph-depends: display virtual package with italic style Thomas Petazzoni
  0 siblings, 2 replies; 6+ messages in thread
From: Francois Perrad @ 2015-01-02  8:49 UTC (permalink / raw)
  To: buildroot

virtual packages are found by their version,
so we retrieve the version of all packages

Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
---
 package/pkg-generic.mk        |  3 +++
 support/scripts/graph-depends | 34 +++++++++++++++++++++++++++++++++-
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
index 9643a30..87d8dd8 100644
--- a/package/pkg-generic.mk
+++ b/package/pkg-generic.mk
@@ -565,6 +565,9 @@ $(1)-rsync:		$$($(2)_TARGET_RSYNC)
 $(1)-source:		$$($(2)_TARGET_RSYNC_SOURCE)
 endif
 
+$(1)-show-version:
+			@echo $$($(2)_VERSION)
+
 $(1)-show-depends:
 			@echo $$($(2)_FINAL_DEPENDENCIES)
 
diff --git a/support/scripts/graph-depends b/support/scripts/graph-depends
index 1ecfeda..fd94a3c 100755
--- a/support/scripts/graph-depends
+++ b/support/scripts/graph-depends
@@ -76,6 +76,28 @@ host_colour = colours[2]
 
 allpkgs = []
 
+# Execute the "make <pkg>-show-version" command to get the version of a given
+# list of packages, and return the version formatted as a Python dictionary.
+def get_version(pkgs):
+    sys.stderr.write("Getting version for %s\n" % pkgs)
+    cmd = ["make", "-s", "--no-print-directory" ]
+    for pkg in pkgs:
+        cmd.append("%s-show-version" % pkg)
+    p = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True)
+    output = p.communicate()[0]
+    if p.returncode != 0:
+        sys.stderr.write("Error getting version %s\n" % pkgs)
+        sys.exit(1)
+    output = output.split("\n")
+    if len(output) != len(pkgs) + 1:
+        sys.stderr.write("Error getting version\n")
+        sys.exit(1)
+    version = {}
+    for i in range(0, len(pkgs)):
+        pkg = pkgs[i]
+        version[pkg] = output[i]
+    return version
+
 # Execute the "make show-targets" command to get the list of the main
 # Buildroot TARGETS and return it formatted as a Python list. This
 # list is used as the starting point for full dependency graphs
@@ -256,6 +278,13 @@ def remove_extra_deps(deps):
             deps[pkg] = remove_transitive_deps(pkg,deps)
     return deps
 
+all_pkgs = {}
+for deps in dict_deps.values():
+    for dep in deps:
+        all_pkgs[dep] = True
+for dep in dict_deps.keys():
+    all_pkgs[dep] = True
+dict_version = get_version(all_pkgs.keys())
 dict_deps = remove_extra_deps(dict_deps)
 
 # Print the attributes of a node: label and fill-color
@@ -274,7 +303,10 @@ def print_attrs(pkg):
             color = host_colour
         else:
             color = target_colour
-    print("%s [label = \"%s\"]" % (name, label))
+    if dict_version[pkg] == "virtual":
+        print("%s [label = <<I>%s</I>>]" % (name, label))
+    else:
+        print("%s [label = \"%s\"]" % (name, label))
     print("%s [color=%s,style=filled]" % (name, color))
 
 # Print the dependency graph of a package
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH 2/2] graph-depends: add an option --stop-on-virtual
  2015-01-02  8:49 [Buildroot] [PATCH 1/2] graph-depends: display virtual package with italic style Francois Perrad
@ 2015-01-02  8:49 ` Francois Perrad
  2015-01-02 10:21   ` Thomas Petazzoni
  2015-01-02 11:37 ` [Buildroot] [PATCH 1/2] graph-depends: display virtual package with italic style Thomas Petazzoni
  1 sibling, 1 reply; 6+ messages in thread
From: Francois Perrad @ 2015-01-02  8:49 UTC (permalink / raw)
  To: buildroot

Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
---
 docs/manual/common-usage.txt  |  3 +++
 support/scripts/graph-depends | 11 +++++++++++
 2 files changed, 14 insertions(+)

diff --git a/docs/manual/common-usage.txt b/docs/manual/common-usage.txt
index 89cd9fe..966c694 100644
--- a/docs/manual/common-usage.txt
+++ b/docs/manual/common-usage.txt
@@ -215,6 +215,9 @@ The +graph-depends+ behaviour can be controlled by setting options in the
   root package (+R+), the target packages (+T+) and the host packages
   (+H+). Defaults to: +lightblue,grey,gainsboro+
 
+* +--stop-on-virtual+, +--dont-stop-on-virtual+, to follow (or not)
+  the dependencies of virtual package
+
 --------------------------------
 BR2_GRAPH_DEPS_OPTS='-d 3 --no-transitive --colours=red,green,blue' make graph-depends
 --------------------------------
diff --git a/support/scripts/graph-depends b/support/scripts/graph-depends
index fd94a3c..3a72e26 100755
--- a/support/scripts/graph-depends
+++ b/support/scripts/graph-depends
@@ -36,6 +36,9 @@ max_depth = 0
 # Whether to draw the transitive dependencies
 transitive = True
 
+# Stop dependency on virtual package
+stop_on_virtual = False
+
 parser = argparse.ArgumentParser(description="Graph pacakges dependencies")
 parser.add_argument("--package", '-p', metavar="PACKAGE",
                     help="Graph the dependencies of PACKAGE")
@@ -51,6 +54,10 @@ parser.add_argument("--transitive", dest="transitive", action='store_true',
                     default=False)
 parser.add_argument("--no-transitive", dest="transitive", action='store_false',
                     help="Draw (do not draw) transitive dependencies")
+parser.add_argument("--stop-on-virtual", dest="stop_on_virtual", action='store_true',
+                    default=False)
+parser.add_argument("--dont-stop-on-virtual", dest="stop_on_virtual", action='store_false',
+                    help="Stop (or do not stop) on virtual package")
 args = parser.parse_args()
 
 if args.package is None:
@@ -63,6 +70,8 @@ max_depth = args.depth
 
 transitive = args.transitive
 
+stop_on_virtual = args.stop_on_virtual
+
 # Get the colours: we need exactly three colours,
 # so no need not split more than 4
 # We'll let 'dot' validate the colours...
@@ -317,6 +326,8 @@ def print_pkg_deps(depth, pkg):
     print_attrs(pkg)
     if pkg not in dict_deps:
         return
+    if stop_on_virtual and dict_version[pkg] == "virtual":
+        return
     if max_depth == 0 or depth < max_depth:
         for d in dict_deps[pkg]:
             print("%s -> %s" % (pkg_node_name(pkg), pkg_node_name(d)))
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH 2/2] graph-depends: add an option --stop-on-virtual
  2015-01-02  8:49 ` [Buildroot] [PATCH 2/2] graph-depends: add an option --stop-on-virtual Francois Perrad
@ 2015-01-02 10:21   ` Thomas Petazzoni
  2015-01-03 13:49     ` François Perrad
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Petazzoni @ 2015-01-02 10:21 UTC (permalink / raw)
  To: buildroot

Dear Francois Perrad,

On Fri,  2 Jan 2015 09:49:33 +0100, Francois Perrad wrote:
> Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
> ---
>  docs/manual/common-usage.txt  |  3 +++
>  support/scripts/graph-depends | 11 +++++++++++
>  2 files changed, 14 insertions(+)

Why would we want to stop on virtual packages? I don't really see the
use case for this additional option.

Thanks,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH 1/2] graph-depends: display virtual package with italic style
  2015-01-02  8:49 [Buildroot] [PATCH 1/2] graph-depends: display virtual package with italic style Francois Perrad
  2015-01-02  8:49 ` [Buildroot] [PATCH 2/2] graph-depends: add an option --stop-on-virtual Francois Perrad
@ 2015-01-02 11:37 ` Thomas Petazzoni
  2015-01-03 13:25   ` François Perrad
  1 sibling, 1 reply; 6+ messages in thread
From: Thomas Petazzoni @ 2015-01-02 11:37 UTC (permalink / raw)
  To: buildroot

Dear Francois Perrad,

On Fri,  2 Jan 2015 09:49:32 +0100, Francois Perrad wrote:
> virtual packages are found by their version,
> so we retrieve the version of all packages
> 
> Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
> ---
>  package/pkg-generic.mk        |  3 +++
>  support/scripts/graph-depends | 34 +++++++++++++++++++++++++++++++++-
>  2 files changed, 36 insertions(+), 1 deletion(-)
> 
> diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
> index 9643a30..87d8dd8 100644
> --- a/package/pkg-generic.mk
> +++ b/package/pkg-generic.mk
> @@ -565,6 +565,9 @@ $(1)-rsync:		$$($(2)_TARGET_RSYNC)
>  $(1)-source:		$$($(2)_TARGET_RSYNC_SOURCE)
>  endif
>  
> +$(1)-show-version:
> +			@echo $$($(2)_VERSION)
> +

This could be a separate patch, maybe?

> +# Execute the "make <pkg>-show-version" command to get the version of a given
> +# list of packages, and return the version formatted as a Python dictionary.
> +def get_version(pkgs):
> +    sys.stderr.write("Getting version for %s\n" % pkgs)
> +    cmd = ["make", "-s", "--no-print-directory" ]
> +    for pkg in pkgs:
> +        cmd.append("%s-show-version" % pkg)

Good, I like the fact that we're doing only one make invocation.

> +all_pkgs = {}
> +for deps in dict_deps.values():
> +    for dep in deps:
> +        all_pkgs[dep] = True
> +for dep in dict_deps.keys():
> +    all_pkgs[dep] = True
> +dict_version = get_version(all_pkgs.keys())

I'm not sure what is going on here. Why aren't you using the existing
'allpkgs' list? It contains the list of all packages, you would just
have to filter the fake 'all' entry in your "for pkg in pkgs:" loop in
the get_version() function.

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH 1/2] graph-depends: display virtual package with italic style
  2015-01-02 11:37 ` [Buildroot] [PATCH 1/2] graph-depends: display virtual package with italic style Thomas Petazzoni
@ 2015-01-03 13:25   ` François Perrad
  0 siblings, 0 replies; 6+ messages in thread
From: François Perrad @ 2015-01-03 13:25 UTC (permalink / raw)
  To: buildroot

2015-01-02 12:37 GMT+01:00 Thomas Petazzoni
<thomas.petazzoni@free-electrons.com>:
> Dear Francois Perrad,
>
> On Fri,  2 Jan 2015 09:49:32 +0100, Francois Perrad wrote:
>> virtual packages are found by their version,
>> so we retrieve the version of all packages
>>
>> Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
>> ---
>>  package/pkg-generic.mk        |  3 +++
>>  support/scripts/graph-depends | 34 +++++++++++++++++++++++++++++++++-
>>  2 files changed, 36 insertions(+), 1 deletion(-)
>>
>> diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
>> index 9643a30..87d8dd8 100644
>> --- a/package/pkg-generic.mk
>> +++ b/package/pkg-generic.mk
>> @@ -565,6 +565,9 @@ $(1)-rsync:               $$($(2)_TARGET_RSYNC)
>>  $(1)-source:         $$($(2)_TARGET_RSYNC_SOURCE)
>>  endif
>>
>> +$(1)-show-version:
>> +                     @echo $$($(2)_VERSION)
>> +
>
> This could be a separate patch, maybe?
>
>> +# Execute the "make <pkg>-show-version" command to get the version of a given
>> +# list of packages, and return the version formatted as a Python dictionary.
>> +def get_version(pkgs):
>> +    sys.stderr.write("Getting version for %s\n" % pkgs)
>> +    cmd = ["make", "-s", "--no-print-directory" ]
>> +    for pkg in pkgs:
>> +        cmd.append("%s-show-version" % pkg)
>
> Good, I like the fact that we're doing only one make invocation.
>
>> +all_pkgs = {}
>> +for deps in dict_deps.values():
>> +    for dep in deps:
>> +        all_pkgs[dep] = True
>> +for dep in dict_deps.keys():
>> +    all_pkgs[dep] = True
>> +dict_version = get_version(all_pkgs.keys())
>
> I'm not sure what is going on here. Why aren't you using the existing
> 'allpkgs' list? It contains the list of all packages, you would just
> have to filter the fake 'all' entry in your "for pkg in pkgs:" loop in
> the get_version() function.
>

You are right. The list 'allpkgs' could be reused (with small adjustment).
I will post a V2.

Fran?ois

> Thanks!
>
> Thomas
> --
> Thomas Petazzoni, CTO, Free Electrons
> Embedded Linux, Kernel and Android engineering
> http://free-electrons.com
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH 2/2] graph-depends: add an option --stop-on-virtual
  2015-01-02 10:21   ` Thomas Petazzoni
@ 2015-01-03 13:49     ` François Perrad
  0 siblings, 0 replies; 6+ messages in thread
From: François Perrad @ 2015-01-03 13:49 UTC (permalink / raw)
  To: buildroot

2015-01-02 11:21 GMT+01:00 Thomas Petazzoni
<thomas.petazzoni@free-electrons.com>:
> Dear Francois Perrad,
>
> On Fri,  2 Jan 2015 09:49:33 +0100, Francois Perrad wrote:
>> Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
>> ---
>>  docs/manual/common-usage.txt  |  3 +++
>>  support/scripts/graph-depends | 11 +++++++++++
>>  2 files changed, 14 insertions(+)
>
> Why would we want to stop on virtual packages? I don't really see the
> use case for this additional option.
>

On package point of view (not for a whole configuration),
for example, with a package which depends on OpenGL, it is not useful
to see the dependencies of a specific implementation of OpenGL,
because they depend on hardware and not on the package.

The graph of dependencies becomes quickly too large,
I think to another option which doesn't display host dependencies
but just target dependencies.

Fran?ois

> Thanks,
>
> Thomas
> --
> Thomas Petazzoni, CTO, Free Electrons
> Embedded Linux, Kernel and Android engineering
> http://free-electrons.com
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-01-03 13:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-02  8:49 [Buildroot] [PATCH 1/2] graph-depends: display virtual package with italic style Francois Perrad
2015-01-02  8:49 ` [Buildroot] [PATCH 2/2] graph-depends: add an option --stop-on-virtual Francois Perrad
2015-01-02 10:21   ` Thomas Petazzoni
2015-01-03 13:49     ` François Perrad
2015-01-02 11:37 ` [Buildroot] [PATCH 1/2] graph-depends: display virtual package with italic style Thomas Petazzoni
2015-01-03 13:25   ` François Perrad

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox