All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/5] instrumentation: explicitly pass the package name
  2015-08-09 22:38 [Buildroot] [PATCH 0/5] core/graphs: add (near) real-time build status to graph-depends (branch yem/graphs) Yann E. MORIN
@ 2015-08-09 22:38 ` Yann E. MORIN
  2015-08-09 22:38 ` [Buildroot] [PATCH 2/5] fs: add instrumentation steps Yann E. MORIN
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Yann E. MORIN @ 2015-08-09 22:38 UTC (permalink / raw)
  To: buildroot

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).

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
 package/pkg-generic.mk | 38 ++++++++++++++++++++------------------
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
index 6a7d97e..d0d580a 100644
--- a/package/pkg-generic.mk
+++ b/package/pkg-generic.mk
@@ -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:
-- 
1.9.1

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

* [Buildroot] [PATCH 0/5] core/graphs: add (near) real-time build status to graph-depends (branch yem/graphs)
@ 2015-08-09 22:38 Yann E. MORIN
  2015-08-09 22:38 ` [Buildroot] [PATCH 1/5] instrumentation: explicitly pass the package name Yann E. MORIN
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Yann E. MORIN @ 2015-08-09 22:38 UTC (permalink / raw)
  To: buildroot

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 &
    $ make

And 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

-- 
.-----------------.--------------------.------------------.--------------------.
|  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.  |
'------------------------------^-------^------------------^--------------------'

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

* [Buildroot] [PATCH 2/5] fs: add instrumentation steps
  2015-08-09 22:38 [Buildroot] [PATCH 0/5] core/graphs: add (near) real-time build status to graph-depends (branch yem/graphs) Yann E. MORIN
  2015-08-09 22:38 ` [Buildroot] [PATCH 1/5] instrumentation: explicitly pass the package name Yann E. MORIN
@ 2015-08-09 22:38 ` Yann E. MORIN
  2015-08-09 22:38 ` [Buildroot] [PATCH 3/5] instrumentation: add step-{start, end} to target-finalize Yann E. MORIN
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Yann E. MORIN @ 2015-08-09 22:38 UTC (permalink / raw)
  To: buildroot

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
 docs/manual/debugging-buildroot.txt | 17 +++++++++++------
 fs/common.mk                        |  2 ++
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/docs/manual/debugging-buildroot.txt b/docs/manual/debugging-buildroot.txt
index f575fc4..66ccfd1 100644
--- a/docs/manual/debugging-buildroot.txt
+++ b/docs/manual/debugging-buildroot.txt
@@ -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
diff --git a/fs/common.mk b/fs/common.mk
index ad1bcf3..4e9427e 100644
--- a/fs/common.mk
+++ b/fs/common.mk
@@ -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)
-- 
1.9.1

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

* [Buildroot] [PATCH 3/5] instrumentation: add step-{start, end} to target-finalize
  2015-08-09 22:38 [Buildroot] [PATCH 0/5] core/graphs: add (near) real-time build status to graph-depends (branch yem/graphs) Yann E. MORIN
  2015-08-09 22:38 ` [Buildroot] [PATCH 1/5] instrumentation: explicitly pass the package name Yann E. MORIN
  2015-08-09 22:38 ` [Buildroot] [PATCH 2/5] fs: add instrumentation steps Yann E. MORIN
@ 2015-08-09 22:38 ` Yann E. MORIN
  2015-08-09 22:38 ` [Buildroot] [PATCH 4/5] support/graphs: real-time build status on graph-depends Yann E. MORIN
  2015-08-09 22:38 ` [Buildroot] [PATCH 5/5] docs/manual: document rt-graph-depends and <pkg>-rt-graph-depends Yann E. MORIN
  4 siblings, 0 replies; 6+ messages in thread
From: Yann E. MORIN @ 2015-08-09 22:38 UTC (permalink / raw)
  To: buildroot

Call 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.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
 Makefile                            |  3 +++
 docs/manual/debugging-buildroot.txt | 18 ++++++++++--------
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/Makefile b/Makefile
index b4cef3f..e70bbd6 100644
--- a/Makefile
+++ b/Makefile
@@ -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)"); \
diff --git a/docs/manual/debugging-buildroot.txt b/docs/manual/debugging-buildroot.txt
index 66ccfd1..7d05cd3 100644
--- a/docs/manual/debugging-buildroot.txt
+++ b/docs/manual/debugging-buildroot.txt
@@ -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:
 
-- 
1.9.1

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

* [Buildroot] [PATCH 4/5] support/graphs: real-time build status on graph-depends
  2015-08-09 22:38 [Buildroot] [PATCH 0/5] core/graphs: add (near) real-time build status to graph-depends (branch yem/graphs) Yann E. MORIN
                   ` (2 preceding siblings ...)
  2015-08-09 22:38 ` [Buildroot] [PATCH 3/5] instrumentation: add step-{start, end} to target-finalize Yann E. MORIN
@ 2015-08-09 22:38 ` Yann E. MORIN
  2015-08-09 22:38 ` [Buildroot] [PATCH 5/5] docs/manual: document rt-graph-depends and <pkg>-rt-graph-depends Yann E. MORIN
  4 siblings, 0 replies; 6+ messages in thread
From: Yann E. MORIN @ 2015-08-09 22:38 UTC (permalink / raw)
  To: buildroot

Currently, 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.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

---
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

diff --git a/Makefile b/Makefile
index e70bbd6..014e95a 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
index d0d580a..fe752b2 100644
--- a/package/pkg-generic.mk
+++ b/package/pkg-generic.mk
@@ -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)
 
diff --git a/support/scripts/rt-graph-depends b/support/scripts/rt-graph-depends
new file mode 100755
index 0000000..752f56b
--- /dev/null
+++ b/support/scripts/rt-graph-depends
@@ -0,0 +1,175 @@
+#!/bin/bash
+
+declare -A COLORS
+COLORS=(
+    ["start:extract"]="coral"
+    ["end:extract"]="coral"
+    ["start:patch"]="coral"
+    ["end:patch"]="coral"
+    ["start:configure"]="orange"
+    ["end:configure"]="orange"
+    ["start:build"]="orange"
+    ["end:build"]="orange"
+    ["start:install-staging"]="green"
+    ["end:install-staging"]="green"
+    ["start:install-target"]="green"
+    ["end:install-target"]="green"
+    ["start:install-image"]="green"
+    ["end:install-image"]="green"
+    ["start:install-host"]="green"
+    ["end:install-host"]="green"
+    ["start:assemble"]="green"
+    ["end:assemble"]="green"
+)
+
+# The label to print under the package name when there is an action
+# being done on that package. Empty means to not add an action label,
+# and is used when the package reaches a terminal state (e.g. installed
+# for packages, assembled for rootfs images).
+#
+# Note: some packages have only one of the target/staging/image install
+# commands, so we don't know which will be the last to be done. So, we
+# just consider each to be terminal.
+declare -A TRANSLATE
+TRANSLATE=(
+    ["start:extract"]="extracting"
+    ["end:extract"]="extracted"
+    ["start:patch"]="patching"
+    ["end:patch"]="patched"
+    ["start:configure"]="configuring"
+    ["end:configure"]="configured"
+    ["start:build"]="building"
+    ["end:build"]="built"
+    ["start:install-staging"]="installing staging"
+    ["end:install-staging"]=""
+    ["start:install-target"]="installing target"
+    ["end:install-target"]=""
+    ["start:install-image"]="installing image"
+    ["end:install-image"]=""
+    ["start:install-host"]="installing host"
+    ["end:install-host"]=""
+    ["start:assemble"]="assembling"
+    ["end:assemble"]=""
+)
+
+main() {
+    local OPT OPTARG
+    local log gdir gname dot_type
+    local infile outfile outgraph
+    local -A pkg_status
+    local -a sed_expr
+    local _ step stat pkg last_pkg color h _h _r _s _t
+
+    while getopts :hl:d:g:T: OPT; do
+        case "${OPT}" in
+        h)  help; exit 0;;
+        l)  log="${OPTARG}";;
+        d)  gdir="${OPTARG}";;
+        g)  gname="${OPTARG}";;
+        T)  dot_type="${OPTARG}";;
+        :)  error "option '%s' expects a mandatory argument\n" "${OPTARG}";;
+        \?) error "unknown option '%s'\n" "${OPTARG}";;
+        esac
+    done
+    # Forget our options, and keep only the ones for 'dot'
+    shift $((OPTIND-1))
+
+    if [ -z "${log}" ]; then
+        error "no build-time.log file specified\n"
+    fi
+
+    if [ -z "${gdir}" ]; then
+        error "no graph directory specified\n"
+    fi
+
+    if [ -z "${gname}" ]; then
+        error "no graph name specified\n"
+    fi
+
+    if [ -z "${dot_type}" ]; then
+        error "no output type specified\n"
+    fi
+
+    if [ ! -f "${gdir}/${gname}.${dot_type}" ]; then
+        make ${gname} || exit $?
+    fi
+
+    infile="${gdir}/${gname}.dot"
+    outfile="$(sed -r -e 's/(graph-depends)/rt-\1/' <<<${gname})"
+    outgraph="${gdir}/${outfile}.${dot_type}"
+    cp "${gdir}/${gname}.${dot_type}" "${outgraph}"
+
+    printf "Realtime graph is at: %s\n" "${outgraph}"
+    printf "Now rendering realtime status... (Ctrl-C to interrupt)"
+
+    _h=""
+    while true; do
+        pkg_status=()
+        sed_expr=()
+        while read _ step stat pkg; do
+            pkg_status["${pkg}"]="${step}:${stat}"
+        done < <( sed -r -e 's/:/ /g; s/ +/ /g;' "${log}" 2>/dev/null )
+        h="$( printf "%s\n" "${pkg_status[@]}" |sort |md5sum )"
+        if [ "${h}" = "${_h}" ]; then
+            inotifywait -t 1 -e modify -qq "${log}" >/dev/null 2>&1
+            [ -f "${log}" ] || sleep 0.1
+            continue
+        fi
+        _h="${h}"
+        for pkg in "${!pkg_status[@]}"; do
+            stat="${pkg_status["${pkg}"]}"
+            color="${COLORS["${stat}"]}"
+            [ -n "${color}" ] || continue
+            _s="^(${pkg//-/}\>.*color=)[^,]+(.*)\$"
+            _r="\\1${color}\\2"
+            sed_expr+=( "s/${_s}/${_r}/;" )
+            _t="${TRANSLATE["${stat}"]}"
+            if [ -n "${_t}" ]; then
+                _s="^(${pkg//-/}\>.*label = \"[^\"]+)(.*)\$"
+                _r="\\1\n[${_t}]\\2"
+                sed_expr+=( "s/${_s}/${_r}/;" )
+            fi
+        done
+        sed -r -e "${sed_expr[*]}" "${infile}"  \
+        |dot "${@}" -T${dot_type} -o"${outgraph}.tmp"
+        mv -f "${outgraph}.tmp" "${outgraph}"
+    done
+}
+
+help() {
+cat <<_EOF_
+NAME
+    ${my_name} - draw the dependency graph with packages status
+
+SYNOPSIS
+    ${my_name} [OPTION...]
+
+DESCRIPTION
+    ${my_name} displays the dependency graph and colors each package
+    depending on their build status. The graph is refreshed every time
+    the status of a package changes, so that it is possible to follow
+    the status of the build in near-realtime.
+
+    -l  full-path to the build-time.log file
+
+    -d  base directory with the existing dependency graph, in 'dot'
+        format.
+
+    -g  base name of the dependency graph
+
+    -T  output type, anything acepted by the 'dot' program (which uses
+        the same option)
+
+EXIT STATUS
+    Unless there is an error, ${my_name} never exits on its own, you
+    must interrupt it (Ctrl-C).
+_EOF_
+}
+
+trace()  { local msg="${1}"; shift; printf "%s: ${msg}" "${my_name}" "${@}"; }
+warn()   { trace "${@}" >&2; }
+errorN() { local ret="${1}"; shift; warn "${@}"; exit ${ret}; }
+error()  { errorN 1 "${@}"; }
+
+my_name="${0##*/}"
+main "${@}"
-- 
1.9.1

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

* [Buildroot] [PATCH 5/5] docs/manual: document rt-graph-depends and <pkg>-rt-graph-depends
  2015-08-09 22:38 [Buildroot] [PATCH 0/5] core/graphs: add (near) real-time build status to graph-depends (branch yem/graphs) Yann E. MORIN
                   ` (3 preceding siblings ...)
  2015-08-09 22:38 ` [Buildroot] [PATCH 4/5] support/graphs: real-time build status on graph-depends Yann E. MORIN
@ 2015-08-09 22:38 ` Yann E. MORIN
  4 siblings, 0 replies; 6+ messages in thread
From: Yann E. MORIN @ 2015-08-09 22:38 UTC (permalink / raw)
  To: buildroot

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 docs/manual/common-usage.txt | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/docs/manual/common-usage.txt b/docs/manual/common-usage.txt
index 5b27b1f..9a7c6f2 100644
--- a/docs/manual/common-usage.txt
+++ b/docs/manual/common-usage.txt
@@ -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]]
-- 
1.9.1

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

end of thread, other threads:[~2015-08-09 22:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-09 22:38 [Buildroot] [PATCH 0/5] core/graphs: add (near) real-time build status to graph-depends (branch yem/graphs) Yann E. MORIN
2015-08-09 22:38 ` [Buildroot] [PATCH 1/5] instrumentation: explicitly pass the package name Yann E. MORIN
2015-08-09 22:38 ` [Buildroot] [PATCH 2/5] fs: add instrumentation steps Yann E. MORIN
2015-08-09 22:38 ` [Buildroot] [PATCH 3/5] instrumentation: add step-{start, end} to target-finalize Yann E. MORIN
2015-08-09 22:38 ` [Buildroot] [PATCH 4/5] support/graphs: real-time build status on graph-depends Yann E. MORIN
2015-08-09 22:38 ` [Buildroot] [PATCH 5/5] docs/manual: document rt-graph-depends and <pkg>-rt-graph-depends Yann E. MORIN

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.