From ff23cb58a8aeb2c83bf4da14e72eea131dd5862b Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Sat, 3 Sep 2016 15:43:26 -0400 Subject: [PATCH] build: support pre-built host tools Right now the build system builds the host tools over and over again, in some environments especially when running in an IDE on windows for example, this is not desired and a set of pre-built host tools should be used. Provide an option to use pre-built tools instead of building them from source. To use, set PREBUILT_HOST_TOOLS to the path where all pre-built host tools are hosted. To get a prebuilt version of the host tools, build without the variable set and copy the generated host binaries from outdir. The following tools are supported: * conf * fixdep * gen_idt * gen_offset_header Jira: ZEP-237 Change-Id: Iea505bfd0b50f851ee2781b5117bb6085ab20157 Signed-off-by: Anas Nashif --- Makefile | 13 ++++++++++- scripts/Kbuild.include | 2 +- scripts/Makefile.build | 4 ++-- scripts/kconfig/Makefile | 50 ++++++++++++++++++++++------------------ 4 files changed, 43 insertions(+), 26 deletions(-) diff --git a/Makefile b/Makefile index 35ae41edbe5..158f3f1d4be 100644 --- a/Makefile +++ b/Makefile @@ -316,8 +316,15 @@ OBJDUMP = $(CROSS_COMPILE)objdump GDB = $(CROSS_COMPILE)gdb READELF = $(CROSS_COMPILE)readelf AWK = awk +ifeq ($(PREBUILT_HOST_TOOLS),) GENIDT = scripts/gen_idt/gen_idt GENOFFSET_H = scripts/gen_offset_header/gen_offset_header +FIXDEP = scripts/basic/fixdep +else +GENIDT = $(PREBUILT_HOST_TOOLS)/gen_idt +GENOFFSET_H = $(PREBUILT_HOST_TOOLS)/gen_offset_header +FIXDEP = $(PREBUILT_HOST_TOOLS)/fixdep +endif PERL = perl PYTHON = python CHECK = sparse @@ -406,7 +413,7 @@ exports += HOSTCXX HOSTCXXFLAGS CHECK CHECKFLAGS exports += KBUILD_CPPFLAGS NOSTDINC_FLAGS ZEPHYRINCLUDE OBJCOPYFLAGS LDFLAGS exports += KBUILD_CFLAGS KBUILD_CXXFLAGS CFLAGS_GCOV KBUILD_AFLAGS AFLAGS_KERNEL -exports += KBUILD_ARFLAGS +exports += KBUILD_ARFLAGS FIXDEP # Push the exports to sub-processes export $(exports) @@ -438,10 +445,14 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \ # Basic helpers built in scripts/ PHONY += scripts_basic +ifeq ($(PREBUILT_HOST_TOOLS),) scripts_basic: $(Q)$(MAKE) $(build)=scripts/basic $(Q)$(MAKE) $(build)=scripts/gen_idt $(Q)$(MAKE) $(build)=scripts/gen_offset_header +else +scripts_basic: +endif # To avoid any implicit rule to kick in, define an empty command. scripts/basic/%: scripts_basic ; diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 6924cb17ede..3e588b98f76 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -255,7 +255,7 @@ if_changed = $(if $(strip $(any-prereq) $(arg-check)), \ if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \ @set -e; \ $(echo-cmd) $(cmd_$(1)); \ - scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\ + $(FIXDEP) $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\ rm -f $(depfile); \ mv -f $(dot-target).tmp $(dot-target).cmd) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 3518241e598..98ee4cbd6ac 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -172,7 +172,7 @@ define rule_cc_o_c $(cmd_modversions) \ $(call echo-cmd,record_mcount) \ $(cmd_record_mcount) \ - scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > \ + $(FIXDEP) $(depfile) $@ '$(call make-cmd,cc_o_c)' > \ $(dot-target).tmp; \ rm -f $(depfile); \ mv -f $(dot-target).tmp $(dot-target).cmd @@ -212,7 +212,7 @@ $(call echo-cmd,cc_o_cxx) $(cmd_cc_o_cxx); \ $(cmd_modversions) \ $(call echo-cmd,record_mcount) \ $(cmd_record_mcount) \ - scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_cxx)' > \ + $(FIXDEP) $(depfile) $@ '$(call make-cmd,cc_o_cxx)' > \ $(dot-target).tmp; \ rm -f $(depfile); \ mv -f $(dot-target).tmp $(dot-target).cmd diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 59aea244e08..5e0230444cb 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -19,40 +19,46 @@ endif # We need this, in case the user has it in its environment unexport CONFIG_ -xconfig: $(obj)/qconf +ifneq ($(PREBUILT_HOST_TOOLS),) +KCONFIG_BIN_PATH = $(PREBUILT_HOST_TOOLS) +else +KCONFIG_BIN_PATH = $(obj) +endif + +xconfig: $(KCONFIG_BIN_PATH)/qconf $< $(Kconfig) -gconfig: $(obj)/gconf +gconfig: $(KCONFIG_BIN_PATH)/gconf $< $(Kconfig) -menuconfig: $(obj)/mconf +menuconfig: $(KCONFIG_BIN_PATH)/mconf $< $(Kconfig) -config: $(obj)/conf +config: $(KCONFIG_BIN_PATH)/conf $< --oldaskconfig $(Kconfig) -nconfig: $(obj)/nconf +nconfig: $(KCONFIG_BIN_PATH)/nconf $< $(Kconfig) -oldconfig: $(obj)/conf +oldconfig: $(KCONFIG_BIN_PATH)/conf $< --$@ $(Kconfig) -silentoldconfig: $(obj)/conf +silentoldconfig: $(KCONFIG_BIN_PATH)/conf $(Q)mkdir -p include/config include/generated $< --$@ $(Kconfig) -localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf +localyesconfig localmodconfig: $(KCONFIG_BIN_PATH)/streamline_config.pl $(KCONFIG_BIN_PATH)/conf $(Q)mkdir -p include/config include/generated $(Q)perl $< --$@ $(srctree) $(Kconfig) > .tmp.config $(Q)if [ -f .config ]; then \ cmp -s .tmp.config .config || \ (mv -f .config .config.old.1; \ mv -f .tmp.config .config; \ - $(obj)/conf --silentoldconfig $(Kconfig); \ + $(KCONFIG_BIN_PATH)/conf --silentoldconfig $(Kconfig); \ mv -f .config.old.1 .config.old) \ else \ mv -f .tmp.config .config; \ - $(obj)/conf --silentoldconfig $(Kconfig); \ + $(KCONFIG_BIN_PATH)/conf --silentoldconfig $(Kconfig); \ fi $(Q)rm -f .tmp.config @@ -65,40 +71,40 @@ update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h --from-code=UTF-8 \ --files-from=$(srctree)/scripts/kconfig/POTFILES.in \ --directory=$(srctree) --directory=$(objtree) \ - --output $(obj)/config.pot - $(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot + --output $(KCONFIG_BIN_PATH)/config.pot + $(Q)sed -i s/CHARSET/UTF-8/ $(KCONFIG_BIN_PATH)/config.pot $(Q)(for i in `ls $(srctree)/arch/*/Kconfig \ $(srctree)/arch/*/um/Kconfig`; \ do \ echo " GEN $$i"; \ $(obj)/kxgettext $$i \ - >> $(obj)/config.pot; \ + >> $(KCONFIG_BIN_PATH)/config.pot; \ done ) $(Q)echo " GEN linux.pot" - $(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \ + $(Q)msguniq --sort-by-file --to-code=UTF-8 $(KCONFIG_BIN_PATH)/config.pot \ --output $(obj)/linux.pot - $(Q)rm -f $(obj)/config.pot + $(Q)rm -f $(KCONFIG_BIN_PATH)/config.pot PHONY += allnoconfig allyesconfig allmodconfig alldefconfig randconfig -allnoconfig allyesconfig allmodconfig alldefconfig randconfig: $(obj)/conf +allnoconfig allyesconfig allmodconfig alldefconfig randconfig: $(KCONFIG_BIN_PATH)/conf $< --$@ $(Kconfig) PHONY += listnewconfig olddefconfig oldnoconfig savedefconfig defconfig -listnewconfig olddefconfig: $(obj)/conf +listnewconfig olddefconfig: $(KCONFIG_BIN_PATH)/conf $< --$@ $(Kconfig) # oldnoconfig is an alias of olddefconfig, because people already are dependent # on its behavior(sets new symbols to their default value but not 'n') with the # counter-intuitive name. -oldnoconfig: $(obj)/conf +oldnoconfig: $(KCONFIG_BIN_PATH)/conf $< --olddefconfig $(Kconfig) -savedefconfig: $(obj)/conf +savedefconfig: $(KCONFIG_BIN_PATH)/conf $< --$@=defconfig $(Kconfig) -defconfig: $(obj)/conf +defconfig: $(KCONFIG_BIN_PATH)/conf ifeq ($(KBUILD_DEFCONFIG),) $< --defconfig $(Kconfig) else @@ -107,13 +113,13 @@ else endif defconfigfiles=$(wildcard $(srctree)/boards/*/$@) -%_defconfig: $(obj)/conf +%_defconfig: $(KCONFIG_BIN_PATH)/conf $(if $(call defconfigfiles),, $(error No configuration exists for this board)) $(Q)$< --defconfig=$(defconfigfiles) $(Kconfig) configfiles=$(wildcard $(PROJECT_BASE)/$@ $(srctree)/kernel/configs/$@ $(srctree)/configs/$@) -%.config: $(obj)/conf +%.config: $(KCONFIG_BIN_PATH)/conf $(if $(call configfiles),, $(error No configuration exists for this target on this architecture)) $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m .config $(configfiles) +$(Q)yes "" | $(MAKE) -f $(srctree)/Makefile oldconfig