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 <anas.nashif@intel.com>
This commit is contained in:
Anas Nashif 2016-09-03 15:43:26 -04:00 committed by Anas Nashif
commit ff23cb58a8
4 changed files with 43 additions and 26 deletions

View file

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

View file

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

View file

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

View file

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