core/graphs: add (near) real-time build status to graph-depends (branch yem/graphs)
cover core/graphs: add (near) real-time build status to graph-depends (branch yem/graphs)
Hello All!
This series introduces a new type of graphs: a (near) real-time status of the build is overlayed over the existing graph-depends.
It allows one to see at a glance what packages have been built, what dependency chains are not yet finished (and thus are blocking a specific package)...
The new graphs are available globally as well as for each package, like graph-depends is.
The new graphs are best viewed with a viewer that auto-reloads the file whenever it changes (e.g. evince for PDF or geeqie for images).
Here's a simple way to see the result:
$ make defconfig
$ make rt-graph-depends
[wait for it to generate the initial data...]
Realtime graph is at: [...]/output/graphs/rt-graph-depends.pdf
Now rendering realtime status... (Ctrl-C to interrupt)From another terminal, run:
$ evince output/graphs/rt-graph-depends.pdf &
$ makeAnd switch to the evince full-screen mode and enjoy the result! :-)
Thanks to Thomas for suggesting the feature! ;-)
Regards,
Yann E. MORIN.
The following changes since commit 4a5f878946c37deb8c1785fb8363cd1d322f7436:
toolchain/external: better check for gcc-5 (2015-08-09 16:58:55 +0200)
are available in the git repository at:
git://git.busybox.net/~ymorin/git/buildroot yem/graphs
for you to fetch changes up to fbaad2935f74aebe3ab32466f404238afd1c0dc6:
docs/manual: document rt-graph-depends and <pkg>-rt-graph-depends (2015-08-10 00:26:29 +0200)
----------------------------------------------------------------
Yann E. MORIN (5):
instrumentation: explicitly pass the package name
fs: add instrumentation steps
instrumentation: add step-{start,end} to target-finalize support/graphs: real-time build status on graph-depends docs/manual: document rt-graph-depends and <pkg>-rt-graph-depends
Makefile | 10 +++ docs/manual/common-usage.txt | 26 ++++++ docs/manual/debugging-buildroot.txt | 19 ++-- fs/common.mk | 2 + package/pkg-generic.mk | 45 ++++++---- support/scripts/rt-graph-depends | 175 ++++++++++++++++++++++++++++++++++++ 6 files changed, 253 insertions(+), 24 deletions(-) create mode 100755 support/scripts/rt-graph-depends
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 1/5 instrumentation: explicitly pass the package name
Currently, the global instrumentation hooks automatically determine the current package name, and they can do so because they are only called from package-related rules.
However, we're soon gonna call those hooks from other part of the build process, that are not related to a package (e.g. the rootfs steps).
So, change the API so that the caller must explicitly pass the name of the entity being processed (only packages for now, more to come in a followup patch).
--- package/pkg-generic.mk | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-)
package/pkg-generic.mk +20 -18
@@ -34,14 +34,16 @@ # Start step # $1: step name +# $2: entity name (package...) define step_start - $(foreach hook,$(GLOBAL_INSTRUMENTATION_HOOKS),$(call $(hook),start,$(1),$($(PKG)_NAME))$(sep)) + $(foreach hook,$(GLOBAL_INSTRUMENTATION_HOOKS),$(call $(hook),start,$(1),$(2))$(sep)) endef # End step # $1: step name +# $2: entity name (package...) define step_end - $(foreach hook,$(GLOBAL_INSTRUMENTATION_HOOKS),$(call $(hook),end,$(1),$($(PKG)_NAME))$(sep)) + $(foreach hook,$(GLOBAL_INSTRUMENTATION_HOOKS),$(call $(hook),end,$(1),$(2))$(sep)) endef #######################################
@@ -85,7 +87,7 @@ $(BUILD_DIR)/%/.stamp_downloaded: # Unpack the archive $(BUILD_DIR)/%/.stamp_extracted: - @$(call step_start,extract) + @$(call step_start,extract,$($(PKG)_NAME)) @$(call MESSAGE,"Extracting") $(foreach hook,$($(PKG)_PRE_EXTRACT_HOOKS),$(call $(hook))$(sep)) $(Q)mkdir -p $(@D)
@@ -94,7 +96,7 @@ $(BUILD_DIR)/%/.stamp_extracted: $(Q)chmod -R +rw $(@D) $(foreach hook,$($(PKG)_POST_EXTRACT_HOOKS),$(call $(hook))$(sep)) $(Q)touch $@ - @$(call step_end,extract) + @$(call step_end,extract,$($(PKG)_NAME)) # Rsync the source directory if the <pkg>_OVERRIDE_SRCDIR feature is # used.
@@ -117,7 +119,7 @@ $(BUILD_DIR)/%/.stamp_patched: NAMEVER = $(RAWNAME)-$($(PKG)_VERSION) $(BUILD_DIR)/%/.stamp_patched: PATCH_BASE_DIRS = $(PKGDIR) $(BUILD_DIR)/%/.stamp_patched: PATCH_BASE_DIRS += $(addsuffix /$(RAWNAME),$(call qstrip,$(BR2_GLOBAL_PATCH_DIR))) $(BUILD_DIR)/%/.stamp_patched: - @$(call step_start,patch) + @$(call step_start,patch,$($(PKG)_NAME)) @$(call MESSAGE,"Patching") $(foreach hook,$($(PKG)_PRE_PATCH_HOOKS),$(call $(hook))$(sep)) $(foreach p,$($(PKG)_PATCH),$(APPLY_PATCHES) $(@D) $(DL_DIR) $(notdir $(p))$(sep))
@@ -134,7 +136,7 @@ $(BUILD_DIR)/%/.stamp_patched: ) $(foreach hook,$($(PKG)_POST_PATCH_HOOKS),$(call $(hook))$(sep)) $(Q)touch $@ - @$(call step_end,patch) + @$(call step_end,patch,$($(PKG)_NAME)) # Check that all directories specified in BR2_GLOBAL_PATCH_DIR exist. $(foreach dir,$(call qstrip,$(BR2_GLOBAL_PATCH_DIR)),\
@@ -143,33 +145,33 @@ $(foreach dir,$(call qstrip,$(BR2_GLOBAL_PATCH_DIR)),\ # Configure $(BUILD_DIR)/%/.stamp_configured: - @$(call step_start,configure) + @$(call step_start,configure,$($(PKG)_NAME)) @$(call MESSAGE,"Configuring") $(foreach hook,$($(PKG)_PRE_CONFIGURE_HOOKS),$(call $(hook))$(sep)) $($(PKG)_CONFIGURE_CMDS) $(foreach hook,$($(PKG)_POST_CONFIGURE_HOOKS),$(call $(hook))$(sep)) $(Q)touch $@ - @$(call step_end,configure) + @$(call step_end,configure,$($(PKG)_NAME)) # Build $(BUILD_DIR)/%/.stamp_built:: - @$(call step_start,build) + @$(call step_start,build,$($(PKG)_NAME)) @$(call MESSAGE,"Building") $(foreach hook,$($(PKG)_PRE_BUILD_HOOKS),$(call $(hook))$(sep)) +$($(PKG)_BUILD_CMDS) $(foreach hook,$($(PKG)_POST_BUILD_HOOKS),$(call $(hook))$(sep)) $(Q)touch $@ - @$(call step_end,build) + @$(call step_end,build,$($(PKG)_NAME)) # Install to host dir $(BUILD_DIR)/%/.stamp_host_installed: - @$(call step_start,install-host) + @$(call step_start,install-host,$($(PKG)_NAME)) @$(call MESSAGE,"Installing to host directory") $(foreach hook,$($(PKG)_PRE_INSTALL_HOOKS),$(call $(hook))$(sep)) +$($(PKG)_INSTALL_CMDS) $(foreach hook,$($(PKG)_POST_INSTALL_HOOKS),$(call $(hook))$(sep)) $(Q)touch $@ - @$(call step_end,install-host) + @$(call step_end,install-host,$($(PKG)_NAME)) # Install to staging dir #
@@ -192,7 +194,7 @@ $(BUILD_DIR)/%/.stamp_host_installed: # empty when we use an internal toolchain. # $(BUILD_DIR)/%/.stamp_staging_installed: - @$(call step_start,install-staging) + @$(call step_start,install-staging,$($(PKG)_NAME)) @$(call MESSAGE,"Installing to staging directory") $(foreach hook,$($(PKG)_PRE_INSTALL_STAGING_HOOKS),$(call $(hook))$(sep)) +$($(PKG)_INSTALL_STAGING_CMDS)
@@ -220,21 +222,21 @@ $(BUILD_DIR)/%/.stamp_staging_installed: -e "s:@STAGING_DIR@:$(STAGING_DIR):g" \ -e "s:@BASE_DIR@:$(BASE_DIR):g" $(Q)touch $@ - @$(call step_end,install-staging) + @$(call step_end,install-staging,$($(PKG)_NAME)) # Install to images dir $(BUILD_DIR)/%/.stamp_images_installed: - @$(call step_start,install-image) + @$(call step_start,install-image,$($(PKG)_NAME)) $(foreach hook,$($(PKG)_PRE_INSTALL_IMAGES_HOOKS),$(call $(hook))$(sep)) @$(call MESSAGE,"Installing to images directory") +$($(PKG)_INSTALL_IMAGES_CMDS) $(foreach hook,$($(PKG)_POST_INSTALL_IMAGES_HOOKS),$(call $(hook))$(sep)) $(Q)touch $@ - @$(call step_end,install-image) + @$(call step_end,install-image,$($(PKG)_NAME)) # Install to target dir $(BUILD_DIR)/%/.stamp_target_installed: - @$(call step_start,install-target) + @$(call step_start,install-target,$($(PKG)_NAME)) @$(call MESSAGE,"Installing to target") $(foreach hook,$($(PKG)_PRE_INSTALL_TARGET_HOOKS),$(call $(hook))$(sep)) +$($(PKG)_INSTALL_TARGET_CMDS)
@@ -247,7 +249,7 @@ $(BUILD_DIR)/%/.stamp_target_installed: $(RM) -f $(addprefix $(TARGET_DIR)/usr/bin/,$($(PKG)_CONFIG_SCRIPTS)) ; \ fi $(Q)touch $@ - @$(call step_end,install-target) + @$(call step_end,install-target,$($(PKG)_NAME)) # Remove package sources $(BUILD_DIR)/%/.stamp_dircleaned:
Signature · 1 line
1.9.1
PATCH 2/5 fs: add instrumentation steps
In reply to Yann E. MORIN--- docs/manual/debugging-buildroot.txt | 17 +++++++++++------ fs/common.mk | 2 ++ 2 files changed, 13 insertions(+), 6 deletions(-)
docs/manual/debugging-buildroot.txt +11 -6
@@ -6,14 +6,15 @@ == Debugging Buildroot It is possible to instrument the steps +Buildroot+ does when building -packages. Define the variable +BR2_INSTRUMENTATION_SCRIPTS+ to contain -the path of one or more scripts (or other executables), in a -space-separated list, you want called before and after each step. The -scripts are called in sequence, with three parameters: +packages or assembling rootfs images. Define the variable ++BR2_INSTRUMENTATION_SCRIPTS+ to contain the path of one or more scripts +(or other executables), in a space-separated list, you want called +before and after each step. The scripts are called in sequence, with +three parameters: - +start+ or +end+ to denote the start (resp. the end) of a step; - the name of the step about to be started, or which just ended; - - the name of the package. + - the name of the package or rootfs image. For example :
@@ -21,7 +22,7 @@ For example : make BR2_INSTRUMENTATION_SCRIPTS="/path/to/my/script1 /path/to/my/script2" ---- -The list of steps is: +The list of package-related steps is: - +extract+ - +patch+
@@ -32,6 +33,10 @@ The list of steps is: - +install-staging+, when a target-package is installed in +$(STAGING_DIR)+ - +install-image+, when a target-package installs files in +$(BINARIES_DIR)+ +For rootfs images, there is a single step: + + - +assemble+ + The script has access to the following variables: - +BR2_CONFIG+: the path to the Buildroot .config file
fs/common.mk +2 -0
@@ -68,6 +68,7 @@ ROOTFS_$(2)_COMPRESS_CMD = xz -9 -C crc32 -c endif $$(BINARIES_DIR)/rootfs.$(1): target-finalize $$(ROOTFS_$(2)_DEPENDENCIES) + @$$(call step_start,assemble,rootfs-$(1)) @$$(call MESSAGE,"Generating root filesystem image rootfs.$(1)") $$(foreach hook,$$(ROOTFS_$(2)_PRE_GEN_HOOKS),$$(call $$(hook))$$(sep)) rm -f $$(FAKEROOT_SCRIPT)
@@ -96,6 +97,7 @@ endif ifneq ($$(ROOTFS_$(2)_COMPRESS_CMD),) PATH=$$(BR_PATH) $$(ROOTFS_$(2)_COMPRESS_CMD) $$@ > $$@$$(ROOTFS_$(2)_COMPRESS_EXT) endif + @$$(call step_end,assemble,rootfs-$(1)) rootfs-$(1)-show-depends: @echo $$(ROOTFS_$(2)_DEPENDENCIES)
Signature · 1 line
1.9.1
PATCH 3/5 instrumentation: add step-{start, end} to target-finalize
In reply to Yann E. MORINCall the global instrumentation hooks at the start and end of the target-finalize. This will allow users to run their own instrumentation hooks (via BR2_INSTRUMENTATION_SCRIPTS) on a completely populated target/ directory.
Since there is no package involved in target-finalise, we pass the literal 'target' instead.
--- Makefile | 3 +++ docs/manual/debugging-buildroot.txt | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-)
Makefile +3 -0
@@ -557,6 +557,7 @@ endif $(TARGETS_ROOTFS): target-finalize target-finalize: $(PACKAGES) + @$(call step_start,finalize,target) @$(call MESSAGE,"Finalizing target directory") $(foreach hook,$(TARGET_FINALIZE_HOOKS),$($(hook))$(sep)) rm -rf $(TARGET_DIR)/usr/include $(TARGET_DIR)/usr/share/aclocal \
@@ -623,6 +624,8 @@ endif $(call MESSAGE,"Executing post-build script $(s)"); \ $(EXTRA_ENV) $(s) $(TARGET_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep)) + @$(call step_end,finalize,target) + target-post-image: $(TARGETS_ROOTFS) target-finalize @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT)), \ $(call MESSAGE,"Executing post-image script $(s)"); \
docs/manual/debugging-buildroot.txt +10 -8
@@ -6,15 +6,16 @@ == Debugging Buildroot It is possible to instrument the steps +Buildroot+ does when building -packages or assembling rootfs images. Define the variable -+BR2_INSTRUMENTATION_SCRIPTS+ to contain the path of one or more scripts -(or other executables), in a space-separated list, you want called -before and after each step. The scripts are called in sequence, with -three parameters: +packages, finalizing the target directory, or assembling rootfs images. +Define the variable +BR2_INSTRUMENTATION_SCRIPTS+ to contain the path +of one or more scripts (or other executables), in a space-separated +list, you want called before and after each step. The scripts are called +in sequence, with three parameters: - +start+ or +end+ to denote the start (resp. the end) of a step; - the name of the step about to be started, or which just ended; - - the name of the package or rootfs image. + - the name of the package or rootfs image, or +target+ when finalizing + the target directory. For example :
@@ -33,9 +34,10 @@ The list of package-related steps is: - +install-staging+, when a target-package is installed in +$(STAGING_DIR)+ - +install-image+, when a target-package installs files in +$(BINARIES_DIR)+ -For rootfs images, there is a single step: +The list of steps not related to packages is: - - +assemble+ + - +finalize+, when finalizing the target directory + - +assemble+, when assembling a rootfs image The script has access to the following variables:
Signature · 1 line
1.9.1
PATCH 4/5 support/graphs: real-time build status on graph-depends
In reply to Yann E. MORINCurrently, following the state of the build is not easily done. One may want to see at a glance where the build has progressed so far, which package are built, what dependency chains are finished, why a certain package is not yet built.
We add a new make target, rt-graph-depends, that takes the exisiting dependency graph (graph-depends) and overlays the build status for each package, with colors and the current action being done on the package.
The new scritps loops forever, each time parsing the build-time.log file to extract the status for each package; it then uses that to replace the color and label in the .dot script and eventually re-renders the graph.
Also add the <pkg>-rt-graph-depends to limit tracking the build to that specific package's dependencies.
---
Note: the script should be able to handle the full-parallel build once it lands in the tree.
--- Makefile | 7 ++ package/pkg-generic.mk | 7 ++ support/scripts/rt-graph-depends | 175 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 189 insertions(+) create mode 100755 support/scripts/rt-graph-depends
Makefile +7 -0
@@ -688,6 +688,13 @@ graph-depends: graph-depends-requirements |tee $(GRAPHS_DIR)/$(@).dot \ |dot $(BR2_GRAPH_DOT_OPTS) -T$(BR_GRAPH_OUT) -o $(GRAPHS_DIR)/$(@).$(BR_GRAPH_OUT) +rt-graph-depends: + @cd "$(CONFIG_DIR)"; \ + $(TOPDIR)/support/scripts/rt-graph-depends \ + -l $(BUILD_DIR)/build-time.log -d $(GRAPHS_DIR) \ + -g graph-depends -T$(BR_GRAPH_OUT) -- \ + $(BR2_GRAPH_DOT_OPTS) + else # ifeq ($(BR2_HAVE_DOT_CONFIG),y) all: menuconfig
package/pkg-generic.mk +7 -0
@@ -623,6 +623,13 @@ $(1)-graph-depends: graph-depends-requirements |tee $$(GRAPHS_DIR)/$$(@).dot \ |dot $$(BR2_GRAPH_DOT_OPTS) -T$$(BR_GRAPH_OUT) -o $$(GRAPHS_DIR)/$$(@).$$(BR_GRAPH_OUT) +$(1)-rt-graph-depends: + @cd "$(CONFIG_DIR)"; \ + $(TOPDIR)/support/scripts/rt-graph-depends \ + -l $(BUILD_DIR)/build-time.log -d $(GRAPHS_DIR) \ + -g $(1)-graph-depends -T$(BR_GRAPH_OUT) -- \ + $(BR2_GRAPH_DOT_OPTS) + $(1)-all-source: $(1)-source $(1)-all-source: $$(foreach p,$$($(2)_FINAL_ALL_DEPENDENCIES),$$(p)-all-source)
support/scripts/rt-graph-depends new file +175 -0
175 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 5/5 docs/manual: document rt-graph-depends and <pkg>-rt-graph-depends
In reply to Yann E. MORIN--- docs/manual/common-usage.txt | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
docs/manual/common-usage.txt +26 -0
@@ -227,6 +227,32 @@ The +graph-depends+ behaviour can be controlled by setting options in the BR2_GRAPH_DEPS_OPTS='-d 3 --no-transitive --colours=red,green,blue' make graph-depends -------------------------------- +Finally, there is a special dependency graph which displays the +status of the build, coloring packages as they are extracted, +patched, configured, built and installed. Once your build is +on-going in a console, you can run, from another console: + +--------------------- +make rt-graph-depends +--------------------- + +And open the resulting graph with your favourite viewer. The graph +is updated in near-realtime, so you can reload it from time to time +to see the progress. Some viewers (e.g. `evince` for PDF, `geeqie` +for images) will auto-reload the file as soon as it changes, so you +get to see the progress automatically! + +As for `graph-depends`, you can limit the graph to a specific package's +dependencies with `<pkg>-rt-graph-depends`, like so: + +--------------------------- +make <pkg>-rt-graph-depends +--------------------------- + +.Note +`make rt-graph-depends` and `make <pkg>-rt-graph-depends` never +terminate. You have to terminate them manually, with `Ctrl-C`. + === Graphing the build duration [[graph-duration]]
Signature · 1 line
1.9.1