[make][buildall] add ability to filter buildall by architecture
Clean up make targets list-arch and list-toolchain to be much faster and work without needing to invoke the archtecture's arch rules.mk. This should make it work on machines that do not have that particular toolchain in the path. This is setting up for using it in the github action script.
This commit is contained in:
@@ -332,7 +332,6 @@ endif
|
||||
# try to find toolchain
|
||||
include $(LOCAL_DIR)/toolchain.mk
|
||||
TOOLCHAIN_PREFIX := $(ARCH_$(ARCH)_TOOLCHAIN_PREFIX)
|
||||
$(info TOOLCHAIN_PREFIX = $(TOOLCHAIN_PREFIX))
|
||||
|
||||
ARCH_COMPILEFLAGS += $(ARCH_$(ARCH)_COMPILEFLAGS)
|
||||
ARCH_COMPILEFLAGS_NOFLOAT :=
|
||||
|
||||
@@ -4,7 +4,6 @@ ARCH_arm_TOOLCHAIN_INCLUDED := 1
|
||||
# try to find the toolchain
|
||||
ifndef ARCH_arm_TOOLCHAIN_PREFIX
|
||||
|
||||
$(info $(TOOLCHAIN_PREFIX))
|
||||
# if TOOLCHAIN_PREFIX is not empty, try to use it first
|
||||
ifneq ($(TOOLCHAIN_PREFIX),)
|
||||
ARCH_arm_TOOLCHAIN_PREFIX := $(TOOLCHAIN_PREFIX)
|
||||
|
||||
@@ -89,7 +89,6 @@ GLOBAL_DEFINES += \
|
||||
# try to find the toolchain
|
||||
include $(LOCAL_DIR)/toolchain.mk
|
||||
TOOLCHAIN_PREFIX := $(ARCH_$(ARCH)_TOOLCHAIN_PREFIX)
|
||||
$(info TOOLCHAIN_PREFIX = $(TOOLCHAIN_PREFIX))
|
||||
|
||||
ARCH_COMPILEFLAGS += $(ARCH_$(ARCH)_COMPILEFLAGS)
|
||||
ARCH_COMPILEFLAGS += -fno-omit-frame-pointer
|
||||
|
||||
@@ -106,9 +106,9 @@ TOOLCHAIN_PREFIX := $(ARCH_x86_64_TOOLCHAIN_PREFIX)
|
||||
endif
|
||||
endif # SUBARCH x86-64
|
||||
|
||||
$(warning ARCH_x86_TOOLCHAIN_PREFIX = $(ARCH_x86_TOOLCHAIN_PREFIX))
|
||||
$(warning ARCH_x86_64_TOOLCHAIN_PREFIX = $(ARCH_x86_64_TOOLCHAIN_PREFIX))
|
||||
$(warning TOOLCHAIN_PREFIX = $(TOOLCHAIN_PREFIX))
|
||||
$(info ARCH_x86_TOOLCHAIN_PREFIX = $(ARCH_x86_TOOLCHAIN_PREFIX))
|
||||
$(info ARCH_x86_64_TOOLCHAIN_PREFIX = $(ARCH_x86_64_TOOLCHAIN_PREFIX))
|
||||
$(info TOOLCHAIN_PREFIX = $(TOOLCHAIN_PREFIX))
|
||||
|
||||
cc-option = $(shell if test -z "`$(1) $(2) -S -o /dev/null -xc /dev/null 2>&1`"; \
|
||||
then echo "$(2)"; else echo "$(3)"; fi ;)
|
||||
@@ -148,8 +148,6 @@ GLOBAL_DEFINES += X86_LEGACY=0
|
||||
endif
|
||||
|
||||
LIBGCC := $(shell $(TOOLCHAIN_PREFIX)gcc $(GLOBAL_COMPILEFLAGS) $(ARCH_COMPILEFLAGS) -print-libgcc-file-name)
|
||||
$(warning LIBGCC = $(LIBGCC))
|
||||
|
||||
LINKER_SCRIPT += $(SUBARCH_BUILDDIR)/kernel.ld
|
||||
|
||||
# potentially generated files that should be cleaned out with clean make rule
|
||||
|
||||
24
engine.mk
24
engine.mk
@@ -183,11 +183,25 @@ include platform/$(PLATFORM)/rules.mk
|
||||
ifndef ARCH
|
||||
$(error couldn't find arch or platform doesn't define arch)
|
||||
endif
|
||||
|
||||
# list the architecture specified in the project/target/platform rules.mk and early terminate.
|
||||
ifeq ($(MAKECMDGOALS), list-arch)
|
||||
$(info ARCH = $(ARCH))
|
||||
.PHONY: list-arch
|
||||
list-arch:
|
||||
else
|
||||
|
||||
include arch/$(ARCH)/rules.mk
|
||||
ifndef TOOLCHAIN_PREFIX
|
||||
$(error TOOLCHAIN_PREFIX not set in the arch rules.mk)
|
||||
endif
|
||||
|
||||
ifeq ($(MAKECMDGOALS), list-toolchain)
|
||||
$(info TOOLCHAIN_PREFIX = $(TOOLCHAIN_PREFIX))
|
||||
.PHONY: list-toolchain
|
||||
list-toolchain:
|
||||
else
|
||||
|
||||
# default to no ccache
|
||||
CCACHE ?=
|
||||
CC ?= $(CCACHE) $(TOOLCHAIN_PREFIX)gcc
|
||||
@@ -354,12 +368,6 @@ clean: $(EXTRA_CLEANDEPS)
|
||||
install: all
|
||||
scp $(OUTBIN) 192.168.0.4:/tftpboot
|
||||
|
||||
list-arch:
|
||||
@echo ARCH = ${ARCH}
|
||||
|
||||
list-toolchain:
|
||||
@echo TOOLCHAIN_PREFIX = ${TOOLCHAIN_PREFIX}
|
||||
|
||||
tags: $(BUILDDIR)/srcfiles.txt $(BUILDDIR)/include_paths.txt
|
||||
$(info generating tags)
|
||||
@ctags -L $<
|
||||
@@ -382,6 +390,10 @@ ifeq ($(filter $(MAKECMDGOALS), clean), )
|
||||
-include $(DEPS)
|
||||
endif
|
||||
|
||||
endif # ifeq ($(filter $(MAKECMDGOALS), list-toolchain))
|
||||
|
||||
endif # ifeq ($(filter $(MAKECMDGOALS), list-arch))
|
||||
|
||||
endif # do-nothing = 1
|
||||
|
||||
endif # make spotless
|
||||
|
||||
@@ -12,9 +12,14 @@ help:
|
||||
@echo "LK build system quick help"
|
||||
@echo "Individual projects are built into a build-<project> directory"
|
||||
@echo "Output binary is located at build-<project>/lk.bin"
|
||||
@echo ""
|
||||
@echo "Environment or command line variables controlling build:"
|
||||
@echo "PROJECT = <project name>"
|
||||
@echo "TOOLCHAIN_PREFIX = <absolute path to toolchain or relative path with prefix>"
|
||||
@echo "WERROR = 1 : treat warnings as errors"
|
||||
@echo "DEBUG = 0,1,2 : set debug level (0=NONE, 1=INFO, 2=DEBUG), default is 2"
|
||||
@echo "BUILDDIR = <path to build directory> (default is build-<project>)"
|
||||
@echo "BUILDDIR_SUFFIX = <suffix to add to build directory> (default is empty)"
|
||||
@echo ""
|
||||
@echo "Special make targets:"
|
||||
@echo "make help: This help"
|
||||
@@ -34,6 +39,9 @@ help:
|
||||
@echo "make testproject clean"
|
||||
@echo ""
|
||||
@echo "output will be in build-testproject/"
|
||||
@echo ""
|
||||
@echo "Check the project/ directory for available projects"
|
||||
@echo "and their rules.mk files for more information."
|
||||
|
||||
endif
|
||||
|
||||
|
||||
@@ -13,19 +13,22 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
function HELP {
|
||||
echo "help:"
|
||||
echo "-e build with WERROR=1"
|
||||
echo "-r also build DEBUG=0"
|
||||
echo "-q hide output of build"
|
||||
echo "-h for help"
|
||||
echo "-a <arch> : build for <arch> (default: all)"
|
||||
echo "-e : build with WERROR=1"
|
||||
echo "-r : also build DEBUG=0"
|
||||
echo "-q : hide output of build"
|
||||
echo "-h : for help"
|
||||
exit 1
|
||||
}
|
||||
|
||||
RELEASE=0
|
||||
WERROR=0
|
||||
QUIET=0
|
||||
ARCH="all"
|
||||
|
||||
while getopts ehrq FLAG; do
|
||||
while getopts a:ehrq FLAG; do
|
||||
case $FLAG in
|
||||
a) ARCH="$OPTARG";;
|
||||
e) WERROR=1;;
|
||||
h) HELP;;
|
||||
r) RELEASE=1;;
|
||||
@@ -48,10 +51,30 @@ function log()
|
||||
fi
|
||||
}
|
||||
|
||||
# build everything in the projects directory
|
||||
PROJECTS=$(echo project/*.mk | xargs -n1 basename | sed 's/\.mk//')
|
||||
# find all the projects in the project directory
|
||||
_PROJECTS=$(echo project/*.mk | xargs -n1 basename | sed 's/\.mk//')
|
||||
FAILED=""
|
||||
|
||||
# If ARCH is set to all, we build for all architectures, otherwise we
|
||||
# filter projects based on the ARCH variable.
|
||||
if [ "$ARCH" != "all" ]; then
|
||||
for p in $_PROJECTS; do
|
||||
# Look for ARCH = <arch> in the output of make list-arch
|
||||
PROJECT_ARCH="$(PROJECT=$p make list-arch | grep 'ARCH' | tail -1 | cut -d ' ' -f 3)"
|
||||
if [ "$PROJECT_ARCH" == "$ARCH" ]; then
|
||||
PROJECTS+="$p "
|
||||
else
|
||||
if (( !QUIET )); then
|
||||
echo "Skipping $p, not compatible with architecture $ARCH"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
else
|
||||
PROJECTS+="$_PROJECTS"
|
||||
fi
|
||||
|
||||
echo projects to build: "$PROJECTS"
|
||||
|
||||
if (( WERROR )); then
|
||||
WERROR_MSG="with WERROR"
|
||||
fi
|
||||
@@ -73,4 +96,5 @@ if [ "$FAILED" != "" ]; then
|
||||
echo
|
||||
echo some projects have failed to build:
|
||||
echo "$FAILED"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user