diff mbox

[PATCHv2,4/4] Makefile: implement a size-stats target

Message ID 1417470100-32657-5-git-send-email-thomas.petazzoni@free-electrons.com
State Changes Requested
Headers show

Commit Message

Thomas Petazzoni Dec. 1, 2014, 9:41 p.m. UTC
This commit implements a size-stats target that calls the script of
the same name to generate the graph and CSV files related to package
and file sizes.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 Makefile | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Romain Naour Jan. 12, 2015, 10:47 p.m. UTC | #1
Hi Thomas,

Le 01/12/2014 22:41, Thomas Petazzoni a écrit :
> This commit implements a size-stats target that calls the script of
> the same name to generate the graph and CSV files related to package
> and file sizes.
> 
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> ---
>  Makefile | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/Makefile b/Makefile
> index ad018c8..56b2b93 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -677,6 +677,16 @@ graph-depends: graph-depends-requirements
>  	|tee $(BASE_DIR)/graphs/$(@).dot \
>  	|dot $(BR2_GRAPH_DOT_OPTS) -T$(BR_GRAPH_OUT) -o $(BASE_DIR)/graphs/$(@).$(BR_GRAPH_OUT)
>  
> +size-stats:
> +	@[ -f $(O)/build/packages-file-list.txt ] || \
> +		{ echo "ERROR: No package size information available, please rebuild with BR2_COLLECT_FILE_SIZE_STATS" ; exit 1; }
> +	@$(INSTALL) -d $(O)/graphs
> +	@cd "$(CONFIG_DIR)"; \
> +	$(TOPDIR)/support/scripts/graph-size --builddir $(O) \

graph-size -> size-stats ?

> +		--graph $(O)/graphs/graph-size.$(BR_GRAPH_OUT) \
> +		--file-size-csv $(O)/build/file-size-stats.csv \
> +		--package-size-csv $(O)/build/package-size-stats.csv
> +
>  else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
>  
>  all: menuconfig
> @@ -889,6 +899,7 @@ endif
>  	@echo '  manual-epub            - build manual in ePub'
>  	@echo '  graph-build            - generate graphs of the build times'
>  	@echo '  graph-depends          - generate graph of the dependency tree'
> +	@echo '  size-stats             - generate stats of the filesystem size'
>  	@echo
>  	@echo 'Miscellaneous:'
>  	@echo '  source                 - download all sources needed for offline-build'
> 

But with that fixed I get:
$ make O=test/xfsprogs/ size-stats
Traceback (most recent call last):
  File "/home/naourr/git/buildroot/support/scripts/size-stats", line 217, in <module>
    pkgdict = build_package_dict(args.builddir)
  File "/home/naourr/git/buildroot/support/scripts/size-stats", line 68, in build_package_dict
    with open(os.path.join(builddir, "build", "packages-file-list.txt")) as filelistf:
IOError: [Errno 2] No such file or directory: 'test/xfsprogs/build/packages-file-list.txt'

But this file exist:
$ ls test/xfsprogs/build/packages-file-list.txt
test/xfsprogs/build/packages-file-list.txt

Also I noticed that the man pages (and headers) 
are taken into account in packages-file-list.txt:
[...]
tmux,./usr/bin/tmux
tmux,./usr/share/man/man1/tmux.1

Since they are removed at the end, I think we want to 
remove them from packages-file-list.txt during
TARGET_DIR cleanup ?

Best regards,
Romain
Thomas Petazzoni Jan. 13, 2015, 8:12 a.m. UTC | #2
Dear Romain Naour,

On Mon, 12 Jan 2015 23:47:28 +0100, Romain Naour wrote:

> > +size-stats:
> > +	@[ -f $(O)/build/packages-file-list.txt ] || \
> > +		{ echo "ERROR: No package size information available, please rebuild with BR2_COLLECT_FILE_SIZE_STATS" ; exit 1; }
> > +	@$(INSTALL) -d $(O)/graphs
> > +	@cd "$(CONFIG_DIR)"; \
> > +	$(TOPDIR)/support/scripts/graph-size --builddir $(O) \
> 
> graph-size -> size-stats ?

Will fix, thanks for noticing (I renamed the script late in my
development).

> But with that fixed I get:
> $ make O=test/xfsprogs/ size-stats
> Traceback (most recent call last):
>   File "/home/naourr/git/buildroot/support/scripts/size-stats", line 217, in <module>
>     pkgdict = build_package_dict(args.builddir)
>   File "/home/naourr/git/buildroot/support/scripts/size-stats", line 68, in build_package_dict
>     with open(os.path.join(builddir, "build", "packages-file-list.txt")) as filelistf:
> IOError: [Errno 2] No such file or directory: 'test/xfsprogs/build/packages-file-list.txt'
> 
> But this file exist:
> $ ls test/xfsprogs/build/packages-file-list.txt
> test/xfsprogs/build/packages-file-list.txt

Might be that I didn't properly take into account out-of-tree build. My
bad, I'll have a look.

> Also I noticed that the man pages (and headers) 
> are taken into account in packages-file-list.txt:
> [...]
> tmux,./usr/bin/tmux
> tmux,./usr/share/man/man1/tmux.1
> 
> Since they are removed at the end, I think we want to 
> remove them from packages-file-list.txt during
> TARGET_DIR cleanup ?

It does not really matter if there are more files in
packages-file-list.txt that there really are in TARGET_DIR, because the
logic of the size-stats script is to travel through TARGET_DIR, and for
each file in TARGET_DIR, lookup in packages-file-list.txt which package
was the last one to install this file. So all files that are in
packages-file-list.txt but not in TARGET_DIR are purely and simply
ignored.

Thanks for your review and testing!

Thomas
Romain Naour Jan. 13, 2015, 11:06 p.m. UTC | #3
Hi Thomas,

Le 13/01/2015 09:12, Thomas Petazzoni a écrit :
> Dear Romain Naour,
> 
> On Mon, 12 Jan 2015 23:47:28 +0100, Romain Naour wrote:
> 
>>> +size-stats:
>>> +	@[ -f $(O)/build/packages-file-list.txt ] || \
>>> +		{ echo "ERROR: No package size information available, please rebuild with BR2_COLLECT_FILE_SIZE_STATS" ; exit 1; }
>>> +	@$(INSTALL) -d $(O)/graphs
>>> +	@cd "$(CONFIG_DIR)"; \
>>> +	$(TOPDIR)/support/scripts/graph-size --builddir $(O) \
>>
>> graph-size -> size-stats ?
> 
> Will fix, thanks for noticing (I renamed the script late in my
> development).
> 
>> But with that fixed I get:
>> $ make O=test/xfsprogs/ size-stats
>> Traceback (most recent call last):
>>   File "/home/naourr/git/buildroot/support/scripts/size-stats", line 217, in <module>
>>     pkgdict = build_package_dict(args.builddir)
>>   File "/home/naourr/git/buildroot/support/scripts/size-stats", line 68, in build_package_dict
>>     with open(os.path.join(builddir, "build", "packages-file-list.txt")) as filelistf:
>> IOError: [Errno 2] No such file or directory: 'test/xfsprogs/build/packages-file-list.txt'
>>
>> But this file exist:
>> $ ls test/xfsprogs/build/packages-file-list.txt
>> test/xfsprogs/build/packages-file-list.txt
> 
> Might be that I didn't properly take into account out-of-tree build. My
> bad, I'll have a look.

The problem is that the size-stats script is called from CONFIG_DIR
I removed this line "@cd "$(CONFIG_DIR)"; \" and I get this graph (see attached
file).

> 
>> Also I noticed that the man pages (and headers) 
>> are taken into account in packages-file-list.txt:
>> [...]
>> tmux,./usr/bin/tmux
>> tmux,./usr/share/man/man1/tmux.1
>>
>> Since they are removed at the end, I think we want to 
>> remove them from packages-file-list.txt during
>> TARGET_DIR cleanup ?
> 
> It does not really matter if there are more files in
> packages-file-list.txt that there really are in TARGET_DIR, because the
> logic of the size-stats script is to travel through TARGET_DIR, and for
> each file in TARGET_DIR, lookup in packages-file-list.txt which package
> was the last one to install this file. So all files that are in
> packages-file-list.txt but not in TARGET_DIR are purely and simply
> ignored.

Ok, I haven't reviewed the size-stats script yet.
Thank for the explanation.

Best regards,
Romain
> 
> Thanks for your review and testing!
> 
> Thomas
>
diff mbox

Patch

diff --git a/Makefile b/Makefile
index ad018c8..56b2b93 100644
--- a/Makefile
+++ b/Makefile
@@ -677,6 +677,16 @@  graph-depends: graph-depends-requirements
 	|tee $(BASE_DIR)/graphs/$(@).dot \
 	|dot $(BR2_GRAPH_DOT_OPTS) -T$(BR_GRAPH_OUT) -o $(BASE_DIR)/graphs/$(@).$(BR_GRAPH_OUT)
 
+size-stats:
+	@[ -f $(O)/build/packages-file-list.txt ] || \
+		{ echo "ERROR: No package size information available, please rebuild with BR2_COLLECT_FILE_SIZE_STATS" ; exit 1; }
+	@$(INSTALL) -d $(O)/graphs
+	@cd "$(CONFIG_DIR)"; \
+	$(TOPDIR)/support/scripts/graph-size --builddir $(O) \
+		--graph $(O)/graphs/graph-size.$(BR_GRAPH_OUT) \
+		--file-size-csv $(O)/build/file-size-stats.csv \
+		--package-size-csv $(O)/build/package-size-stats.csv
+
 else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
 
 all: menuconfig
@@ -889,6 +899,7 @@  endif
 	@echo '  manual-epub            - build manual in ePub'
 	@echo '  graph-build            - generate graphs of the build times'
 	@echo '  graph-depends          - generate graph of the dependency tree'
+	@echo '  size-stats             - generate stats of the filesystem size'
 	@echo
 	@echo 'Miscellaneous:'
 	@echo '  source                 - download all sources needed for offline-build'