diff mbox series

[OpenWrt-Devel] build: Introduce building of artifacts

Message ID 1542966817-1311-1-git-send-email-ynezz@true.cz
State Accepted
Delegated to: John Crispin
Headers show
Series [OpenWrt-Devel] build: Introduce building of artifacts | expand

Commit Message

Petr Štetiar Nov. 23, 2018, 9:53 a.m. UTC
We currently could (ab)use IMAGES for this task, but the downside is,
that the filenames has filesystem tied to the filename, which might be
confusing as the artifact itself don't has to be used with that specific
filesystem. Another downside is, that the artifacts built with IMAGES
target are build for every FILESYSTEMS filesystem.

Consider following use case:

 define Device/apalis
   ...
   FILESYSTEMS := ext4 squashfs
   IMAGES := spl-uboot.bin recovery.scr
   IMAGE/spl-uboot.bin := append-uboot-spl | pad-to 68k | append-uboot
   IMAGE/recovery.scr := recovery-scr
 endef

Where we would get target binaries with following filenames:

 openwrt-imx6-apalis-squashfs.recovery.scr
 openwrt-imx6-apalis-squashfs.spl-uboot.bin
 openwrt-imx6-apalis-ext4.recovery.scr
 openwrt-imx6-apalis-ext4.spl-uboot.bin

With proposed patch, we could now just do:

 define Device/apalis
   ...
   ARTIFACTS := spl-uboot.bin recovery.scr
   ARTIFACT/spl-uboot.bin := append-uboot-spl | pad-to 68k | append-uboot
   ARTIFACT/recovery.scr := recovery-scr
 endef

Which would produce target binaries with following filenames:

 openwrt-imx6-apalis-recovery.scr
 openwrt-imx6-apalis-spl-uboot.bin

Signed-off-by: Petr Štetiar <ynezz@true.cz>
---
 include/image.mk | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Comments

Hauke Mehrtens Nov. 24, 2018, 5:48 p.m. UTC | #1
On 11/23/18 10:53 AM, Petr Štetiar wrote:
> We currently could (ab)use IMAGES for this task, but the downside is,
> that the filenames has filesystem tied to the filename, which might be
> confusing as the artifact itself don't has to be used with that specific
> filesystem. Another downside is, that the artifacts built with IMAGES
> target are build for every FILESYSTEMS filesystem.
> 
> Consider following use case:
> 
>  define Device/apalis
>    ...
>    FILESYSTEMS := ext4 squashfs
>    IMAGES := spl-uboot.bin recovery.scr
>    IMAGE/spl-uboot.bin := append-uboot-spl | pad-to 68k | append-uboot
>    IMAGE/recovery.scr := recovery-scr
>  endef
> 
> Where we would get target binaries with following filenames:
> 
>  openwrt-imx6-apalis-squashfs.recovery.scr
>  openwrt-imx6-apalis-squashfs.spl-uboot.bin
>  openwrt-imx6-apalis-ext4.recovery.scr
>  openwrt-imx6-apalis-ext4.spl-uboot.bin
> 
> With proposed patch, we could now just do:
> 
>  define Device/apalis
>    ...
>    ARTIFACTS := spl-uboot.bin recovery.scr
>    ARTIFACT/spl-uboot.bin := append-uboot-spl | pad-to 68k | append-uboot
>    ARTIFACT/recovery.scr := recovery-scr
>  endef
> 
> Which would produce target binaries with following filenames:
> 
>  openwrt-imx6-apalis-recovery.scr
>  openwrt-imx6-apalis-spl-uboot.bin
> 
> Signed-off-by: Petr Štetiar <ynezz@true.cz>

Acked-by: Hauke Mehrtens <hauke@hauke-m.de>

I think this feature is useful.

> ---
>  include/image.mk | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/include/image.mk b/include/image.mk
> index f2a85f6..a2b106d 100644
> --- a/include/image.mk
> +++ b/include/image.mk
> @@ -321,6 +321,7 @@ define Device/Init
>    CMDLINE:=
>  
>    IMAGES :=
> +  ARTIFACTS :=
>    IMAGE_PREFIX := $(IMG_PREFIX)-$(1)
>    IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1)-$$(2)
>    KERNEL_PREFIX = $$(IMAGE_PREFIX)
> @@ -498,6 +499,19 @@ define Device/Build/image
>  
>  endef
>  
> +define Device/Build/artifact
> +  $$(_TARGET): $(BIN_DIR)/$(IMAGE_PREFIX)-$(1)
> +  $(KDIR)/tmp/$(IMAGE_PREFIX)-$(1): $$(KDIR_KERNEL_IMAGE)
> +	@rm -f $$@
> +	$$(call concat_cmd,$(ARTIFACT/$(1)))
> +
> +  .IGNORE: $(BIN_DIR)/$(IMAGE_PREFIX)-$(1)
> +
> +  $(BIN_DIR)/$(IMAGE_PREFIX)-$(1): $(KDIR)/tmp/$(IMAGE_PREFIX)-$(1)
> +	cp $$^ $$@
> +
> +endef
> +
>  define Device/Build
>    $(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),$(call Device/Build/initramfs,$(1)))
>    $(call Device/Build/kernel,$(1))
> @@ -508,6 +522,10 @@ define Device/Build
>    $$(eval $$(foreach image,$$(IMAGES), \
>      $$(foreach fs,$$(filter $(TARGET_FILESYSTEMS),$$(FILESYSTEMS)), \
>        $$(call Device/Build/image,$$(fs),$$(image),$(1)))))
> +
> +  $$(eval $$(foreach artifact,$$(ARTIFACTS), \
> +    $$(call Device/Build/artifact,$$(artifact))))
> +
>  endef
>  
>  define Device/DumpInfo
>
diff mbox series

Patch

diff --git a/include/image.mk b/include/image.mk
index f2a85f6..a2b106d 100644
--- a/include/image.mk
+++ b/include/image.mk
@@ -321,6 +321,7 @@  define Device/Init
   CMDLINE:=
 
   IMAGES :=
+  ARTIFACTS :=
   IMAGE_PREFIX := $(IMG_PREFIX)-$(1)
   IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1)-$$(2)
   KERNEL_PREFIX = $$(IMAGE_PREFIX)
@@ -498,6 +499,19 @@  define Device/Build/image
 
 endef
 
+define Device/Build/artifact
+  $$(_TARGET): $(BIN_DIR)/$(IMAGE_PREFIX)-$(1)
+  $(KDIR)/tmp/$(IMAGE_PREFIX)-$(1): $$(KDIR_KERNEL_IMAGE)
+	@rm -f $$@
+	$$(call concat_cmd,$(ARTIFACT/$(1)))
+
+  .IGNORE: $(BIN_DIR)/$(IMAGE_PREFIX)-$(1)
+
+  $(BIN_DIR)/$(IMAGE_PREFIX)-$(1): $(KDIR)/tmp/$(IMAGE_PREFIX)-$(1)
+	cp $$^ $$@
+
+endef
+
 define Device/Build
   $(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),$(call Device/Build/initramfs,$(1)))
   $(call Device/Build/kernel,$(1))
@@ -508,6 +522,10 @@  define Device/Build
   $$(eval $$(foreach image,$$(IMAGES), \
     $$(foreach fs,$$(filter $(TARGET_FILESYSTEMS),$$(FILESYSTEMS)), \
       $$(call Device/Build/image,$$(fs),$$(image),$(1)))))
+
+  $$(eval $$(foreach artifact,$$(ARTIFACTS), \
+    $$(call Device/Build/artifact,$$(artifact))))
+
 endef
 
 define Device/DumpInfo