Hi, > -----Original Message----- > From: openwrt-devel [mailto:openwrt-devel-boun...@lists.openwrt.org] > On Behalf Of Linus Walleij > Sent: Freitag, 29. Mai 2020 14:21 > To: openwrt-devel@lists.openwrt.org > Cc: Linus Walleij <linus.wall...@linaro.org> > Subject: [OpenWrt-Devel] [PATCH] build: reflect DEVICE_TYPE to top level > config > > I made a patch to select a tool inside busybox by default on NAS type boxes, > but this does not properly work because the package and image build > processes are cleanly separate entities. > > I also noticed that this becomes a problem if you build multiple profiles: > maybe one of them is NAS and one of them is a router. You still want the > least common denominator to decide: if you selected both NAS:es and > routers, build packages that will be suitable for both NAS and routers. > > To achieve this I reflect the DEVICE_TYPE up to the Kconfig level and define > two Kconfig symbols: > > config DEVICE_TYPE_ROUTER > bool > > config DEVICE_TYPE_NAS > bool
I just had a look at this again, and had a different idea: You could exploit the "FEATURES" at the target/subtarget level, as e.g. done for small_flash: E.g. at ath79/tiny "small_flash" is added to FEATURES: https://github.com/openwrt/openwrt/blob/80c61c161ac5943137ade233d62cf89d746de5a2/target/linux/ath79/tiny/target.mk#L2 Then a config symbol SMALL_FLASH is defined: https://github.com/openwrt/openwrt/blob/4a0f426ba5044af2fe45be8cc553f1580484883c/target/Config.in#L79 This CONFIG would be selected based on FEATURES in target_metadata.pl: https://github.com/openwrt/openwrt/blob/e9f7923a1d4b327ef4b9ac25fbe197f2b4ea61d7/scripts/target-metadata.pl#L40 And then you could make other config symbols dependent on the config symbol, e.g. https://github.com/openwrt/openwrt/blob/7f2b230b3b9d0a7fb758db3a9b1958845506a5a3/package/libs/openssl/Config.in#L19 This could essentially work the same way for a feature "nas". You could then either use CONFIG_NAS directly or, as in the last example, via dependencies. I think this would actually be the easiest way to get this working for switching stuff in packages. Best Adrian > > These will be set from the DEVICE_TYPE of each profile and it is possible to > select both. > > I then modify the busybox config to take this into account and conditionally > build hdparm for CONFIG_DEVICE_TYPE_NAS. > > Signed-off-by: Linus Walleij <linus.wall...@linaro.org> > --- > include/image.mk | 1 + > include/target.mk | 1 + > package/utils/busybox/Makefile | 2 +- > scripts/metadata.pm | 2 ++ > scripts/target-metadata.pl | 12 ++++++++++++ > 5 files changed, 17 insertions(+), 1 deletion(-) > > diff --git a/include/image.mk b/include/image.mk index > 984b64fb9c73..8104c040a1f7 100644 > --- a/include/image.mk > +++ b/include/image.mk > @@ -634,6 +634,7 @@ endef > define Device/DumpInfo > Target-Profile: DEVICE_$(1) > Target-Profile-Name: $(DEVICE_DISPLAY) > +Target-Profile-Devicetype: $(DEVICE_TYPE) > Target-Profile-Packages: $(DEVICE_PACKAGES) > Target-Profile-hasImageMetadata: $(if $(foreach > image,$(IMAGES),$(findstring append-metadata,$(IMAGE/$(image)))),1,0) > Target-Profile-SupportedDevices: $(SUPPORTED_DEVICES) diff --git > a/include/target.mk b/include/target.mk index 9bd4c14936c1..e6f26cbfdf3d > 100644 > --- a/include/target.mk > +++ b/include/target.mk > @@ -73,6 +73,7 @@ define Profile > echo "Target-Profile: $(1)"; \ > $(if $(PRIORITY), echo "Target-Profile-Priority: $(PRIORITY)"; ) \ > echo "Target-Profile-Name: $(NAME)"; \ > + echo "Target-Profile-Devicetype: $(DEVICE_TYPE)"; \ > echo "Target-Profile-Packages: $(PACKAGES) $(call > extra_packages,$(DEFAULT_PACKAGES) $(PACKAGES))"; \ > echo "Target-Profile-Description:"; \ > echo "$$$$$$$$$(call shvar,Profile/$(1)/Description)"; \ diff --git > a/package/utils/busybox/Makefile b/package/utils/busybox/Makefile index > 01441d1e87d1..f504117f60f3 100644 > --- a/package/utils/busybox/Makefile > +++ b/package/utils/busybox/Makefile > @@ -94,7 +94,7 @@ endif > define Build/Configure > rm -f $(PKG_BUILD_DIR)/.config > touch $(PKG_BUILD_DIR)/.config > -ifeq ($(DEVICE_TYPE),nas) > +ifeq ($(CONFIG_DEVICE_TYPE_NAS),y) > echo "CONFIG_HDPARM=y" >> $(PKG_BUILD_DIR)/.config endif > grep 'CONFIG_BUSYBOX_$(BUSYBOX_SYM)' $(TOPDIR)/.config | sed > -e "s,\\(# > \)\\?CONFIG_BUSYBOX_$(BUSYBOX_SYM)_\\(.*\\),\\1CONFIG_\\2,g" >> > $(PKG_BUILD_DIR)/.config diff --git a/scripts/metadata.pm > b/scripts/metadata.pm index 1826a040a116..5062dba37ec0 100644 > --- a/scripts/metadata.pm > +++ b/scripts/metadata.pm > @@ -140,6 +140,7 @@ sub parse_target_metadata($) { > $profile = { > id => $1, > name => $1, > + device_type => "router", > has_image_metadata => 0, > supported_devices => [], > priority => 999, > @@ -150,6 +151,7 @@ sub parse_target_metadata($) { > push @{$target->{profiles}}, $profile; > }; > /^Target-Profile-Name:\s*(.+)\s*$/ and $profile->{name} = > $1; > + /^Target-Profile-Devicetype:\s*(.+)\s*$/ and $profile- > >{device_type} > += $1; > /^Target-Profile-hasImageMetadata:\s*(\d+)\s*$/ and > $profile->{has_image_metadata} = $1; > /^Target-Profile-SupportedDevices:\s*(.+)\s*$/ and $profile- > >{supported_devices} = [ split(/\s+/, $1) ]; > /^Target-Profile-Priority:\s*(\d+)\s*$/ and do { diff --git > a/scripts/target-metadata.pl b/scripts/target-metadata.pl index > ee0ab5a71811..fbd9fa70c08b 100755 > --- a/scripts/target-metadata.pl > +++ b/scripts/target-metadata.pl > @@ -244,6 +244,12 @@ EOF > print "\tselect DEFAULT_$pkg\n"; > $defaults{$pkg} = 1; > } > + if ($profile->{device_type} =~ "router") { > + print "\tselect DEVICE_TYPE_ROUTER\n"; > + } > + if ($profile->{device_type} =~ "nas") { > + print "\tselect DEVICE_TYPE_NAS\n"; > + } > my $help = $profile->{desc}; > if ($help =~ /\w+/) { > $help =~ s/^\s*/\t /mg; > @@ -328,6 +334,12 @@ config HAS_SUBTARGETS config HAS_DEVICES > bool > > +config DEVICE_TYPE_ROUTER > + bool > + > +config DEVICE_TYPE_NAS > + bool > + > config TARGET_BOARD > string > > -- > 2.26.2 > > > _______________________________________________ > openwrt-devel mailing list > openwrt-devel@lists.openwrt.org > https://lists.openwrt.org/mailman/listinfo/openwrt-devel
openpgp-digital-signature.asc
Description: PGP signature
_______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel