mirror of
https://github.com/falk-werner/webfuse
synced 2024-10-27 20:34:10 +00:00
removes old build scripts
This commit is contained in:
parent
76a0469f40
commit
3bf3ea21d8
@ -1,57 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
export LANG=C
|
||||
export LC_ALL=C
|
||||
|
||||
cleanup() {
|
||||
rm -rf "$INCLUDE_DIRS_TMPFILE"
|
||||
}
|
||||
|
||||
trap cleanup TERM INT EXIT
|
||||
|
||||
DEST="${DEST:-$PWD}"
|
||||
|
||||
CMAKE_CACHE_FILE="${1:-CMakeCache.txt}"
|
||||
CMAKE_CXX_COMPILER="$(sed -n -e 's/CMAKE_CXX_COMPILER:FILEPATH=\(.*\)$/\1/p' "$CMAKE_CACHE_FILE")"
|
||||
CMAKE_C_COMPILER="$(sed -n -e 's/CMAKE_C_COMPILER:FILEPATH=\(.*\)$/\1/p' "$CMAKE_CACHE_FILE")"
|
||||
|
||||
INCLUDE_DIRS_PREFIX="${2:-$DEST}"
|
||||
INCLUDE_DIRS_TMPFILE="$(mktemp -p "$DEST" include_dirs_XXXXXXXXXX.txt)"
|
||||
INCLUDE_DIRS_FILE="${INCLUDE_DIRS_FILE:-$DEST/include_dirs.txt}"
|
||||
|
||||
C_BUILTIN_FILE="${C_BUILTIN_FILE:-$DEST/builtins.h}"
|
||||
CXX_BUILTIN_FILE="${CXX_BUILTIN_FILE:-$DEST/builtins.hpp}"
|
||||
|
||||
if [ -z "${RSYNC+x}" ]; then
|
||||
RSYNC=rsync
|
||||
fi
|
||||
|
||||
{
|
||||
{
|
||||
echo | "$CMAKE_CXX_COMPILER" -xc++ -E -Wp,-v - 2>&1;
|
||||
echo | "$CMAKE_C_COMPILER" -xc -E -Wp,-v - 2>&1;
|
||||
} \
|
||||
| sed -n -e 's/\s\+\(\/.*$\).*/\1/p';
|
||||
|
||||
sed -n -e 's/.*_INCLUDE_DIRS:INTERNAL=\(.*\)$/\1/p' "$CMAKE_CACHE_FILE";
|
||||
} \
|
||||
| sed 's/;/\n/g' | sed '/^$/d' | sort -u 2>/dev/null 1> "$INCLUDE_DIRS_TMPFILE"
|
||||
|
||||
{
|
||||
echo '#include <...> search starts here:'
|
||||
# shellcheck disable=SC1117
|
||||
sed -n -e "s@\(.*\)@$INCLUDE_DIRS_PREFIX\1@p" "$INCLUDE_DIRS_TMPFILE"
|
||||
echo 'End of search list.'
|
||||
} > "$INCLUDE_DIRS_FILE"
|
||||
|
||||
if [ -n "$RSYNC" ]; then
|
||||
"$RSYNC" -arR --files-from="$INCLUDE_DIRS_TMPFILE" / "$DEST"
|
||||
echo "Include folders copied to $DEST" >&2
|
||||
fi
|
||||
|
||||
"$CMAKE_C_COMPILER" -xc -dM -E - < /dev/null > "$C_BUILTIN_FILE"
|
||||
echo "C Compiler built-ins written to $C_BUILTIN_FILE" >&2
|
||||
"$CMAKE_CXX_COMPILER" -xc++ -dM -E - < /dev/null > "$CXX_BUILTIN_FILE"
|
||||
echo "C++ Compiler built-ins written to $CXX_BUILTIN_FILE" >&2
|
@ -1,56 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
DOCKER="${DOCKER:-docker}"
|
||||
DOCKER_HOST="${DOCKER_HOST:-/var/run/docker.sock}"
|
||||
VERSION="${VERSION:-1.24.0}"
|
||||
IMAGE="${IMAGE:-${REGISTRY_PREFIX}docker/compose:${VERSION}}"
|
||||
NETWORK="${NETWORK:-host}"
|
||||
USERID="${USERID:-$(id -u)}"
|
||||
SCRIPTDIR="${SCRIPTDIR:-"$(cd "$(dirname "$0")" && echo "$PWD")"}"
|
||||
PROJECTDIR="${PROJECTDIR:-"$PWD"}"
|
||||
ENTRYPOINT="${ENTRYPOINT:-docker-compose}"
|
||||
HOST_ENVFILTER="${HOST_ENVFILTER:-^DOCKER_\|^COMPOSE_}"
|
||||
PATH="${SCRIPTDIR}:$PATH"
|
||||
|
||||
set -- --entrypoint "$ENTRYPOINT" "$IMAGE" "$@"
|
||||
set -- --user "$USERID:$USERID" --network "$NETWORK" --workdir "$PWD" "$@"
|
||||
|
||||
ENVFLAGS="$(printenv | grep -e "$HOST_ENVFILTER" | sed -n -e 's/\([^=]*\)=.*/-e \1/p')" || true
|
||||
#shellcheck disable=SC2086
|
||||
set -- $ENVFLAGS "$@"
|
||||
|
||||
if [ -n "$CONTAINER_CGROUP_PARENT" ]; then
|
||||
set -- --cgroup-parent "$CONTAINER_CGROUP_PARENT" "$@"
|
||||
fi
|
||||
|
||||
HOST_CONTAINER="${HOST_CONTAINER:-"$(get_container_id.sh)"}" || true
|
||||
if [ -n "$HOST_CONTAINER" ]; then
|
||||
set -- --volumes-from "$HOST_CONTAINER" "$@"
|
||||
else
|
||||
set -- --volume "$PROJECTDIR:$PROJECTDIR:cached" "$@"
|
||||
fi
|
||||
|
||||
# setup options for connection to docker host
|
||||
if [ -S "$DOCKER_HOST" ]; then
|
||||
DOCKER_SOCK_GROUP="$(stat -c '%g' "$DOCKER_HOST")"
|
||||
set -- -e DOCKER_SOCK_GROUP="$DOCKER_SOCK_GROUP" --group-add "$DOCKER_SOCK_GROUP" "$@"
|
||||
else
|
||||
set -- -e DOCKER_HOST -e DOCKER_TLS_VERIFY -e DOCKER_CERT_PATH "$@"
|
||||
fi
|
||||
|
||||
if [ -t 0 ] && ! is_running_in_bg.sh $$; then
|
||||
set -- --interactive "$@"
|
||||
fi
|
||||
|
||||
# if STDIN piped or redirected
|
||||
if [ -p /dev/stdin ] || { [ ! -t 0 ] && [ ! -p /dev/stdin ]; }; then
|
||||
set -- --interactive "$@"
|
||||
elif [ -t 1 ]; then
|
||||
set -- --tty "$@"
|
||||
fi
|
||||
|
||||
set -- --rm "$@"
|
||||
|
||||
exec "$DOCKER" run "$@"
|
@ -1,39 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
container_id() {
|
||||
if [ "$#" -le 0 ]; then
|
||||
# shellcheck disable=SC2119
|
||||
container_id_by_cgroup
|
||||
else
|
||||
"$DOCKER" inspect --format='{{.Id}}' "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
# shellcheck disable=SC2120
|
||||
container_id_by_cgroup() {
|
||||
impl_container_id_by_cgroup "$@" || return "$?"
|
||||
}
|
||||
|
||||
impl_container_id_by_cgroup() {
|
||||
file="${1:-/proc/self/cgroup}"
|
||||
|
||||
while IFS= read -r cmd; do
|
||||
id="$(echo "$cmd" | sed -n -e 's/[^:]*:[^:]*:.*\/\([0-9a-fA-F]\+\)$/\1/p')"
|
||||
if container_id "$id" >/dev/null 2>&1; then
|
||||
echo "$id"
|
||||
return 0
|
||||
fi
|
||||
done < "$file"
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
DOCKER="${DOCKER:-docker}"
|
||||
|
||||
if [ -z "${CONTAINER+x}" ] && [ -n "$DOCKER" ]; then
|
||||
CONTAINER="$(container_id "$@")"
|
||||
fi
|
||||
|
||||
echo "$CONTAINER"
|
@ -1,34 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
export LANG=C
|
||||
export LC_ALL=C
|
||||
|
||||
[ -n "$TOPDIR" ] && cd "$TOPDIR"
|
||||
|
||||
try_git() {
|
||||
[ -e .git ] || return 1
|
||||
SOURCE_DATE_EPOCH="$(git log -1 --format=format:%ct)"
|
||||
[ -n "$SOURCE_DATE_EPOCH" ]
|
||||
}
|
||||
|
||||
try_svn() {
|
||||
[ -d .svn ] || return 1
|
||||
SOURCE_DATE_EPOCH="$(date -d "$(svn info | sed -n -e 's/^Last Changed Date: //p')" +%s)"
|
||||
[ -n "$SOURCE_DATE_EPOCH" ]
|
||||
}
|
||||
|
||||
try_hg() {
|
||||
[ -d .hg ] || return 1
|
||||
SOURCE_DATE_EPOCH="$(hg log --template '{date}' -l 1 | cut -d. -f1)"
|
||||
[ -n "$SOURCE_DATE_EPOCH" ]
|
||||
}
|
||||
|
||||
try_mtime() {
|
||||
perl -e 'print((stat $ARGV[0])[9])' "$0"
|
||||
[ -n "$SOURCE_DATE_EPOCH" ]
|
||||
}
|
||||
|
||||
try_git || try_svn || try_hg || try_mtime || SOURCE_DATE_EPOCH=""
|
||||
echo "$SOURCE_DATE_EPOCH"
|
@ -1,18 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
running_in_background() {
|
||||
pid="$1"
|
||||
|
||||
case "$("$PS" -o stat= -p "$pid" 2>/dev/null || echo '+')" in
|
||||
*+*) ;;
|
||||
*) return 0 ;;
|
||||
esac
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
PS="${PS:-ps}"
|
||||
|
||||
running_in_background "$@"
|
@ -1,113 +0,0 @@
|
||||
CURRENT_MAKEFILE := $(lastword $(MAKEFILE_LIST)))
|
||||
|
||||
#######################################################################################################################
|
||||
# Overridable CMake defaults
|
||||
|
||||
filter_targets ?= $2
|
||||
|
||||
CMAKE_BUILD_TYPE ?= $(BUILDTYPE)
|
||||
CMAKE_MEMCHECK_FILTER ?= $(MEMCHECK_FILTER)
|
||||
CMAKE_PROJECTDIR ?= $(CONTAINER_PROJECTDIR)
|
||||
CMAKE_SCRIPTDIR ?= $(CONTAINER_SCRIPTDIR)
|
||||
|
||||
ifndef _INCLUDE_DEFAULTS
|
||||
include $(patsubst %/,%,$(dir $(CURRENT_MAKEFILE)))/defaults.mk
|
||||
endif
|
||||
|
||||
#######################################################################################################################
|
||||
# CMake macros
|
||||
|
||||
cmake_configure_rule = \
|
||||
$$(OUTDIR)/$1/$$(CMAKE_BUILD_TYPE)/CMakeCache.txt: $$(PROJECTDIR)/CMakeLists.txt $$(OUTDIR)/docker/$1 | $$(OUTDIR)/$1/$$(CMAKE_BUILD_TYPE)/gdbserver; \
|
||||
$$(SILENT)$$(call cmake_configure,$1)
|
||||
cmake_configure = \
|
||||
$(call run,$1,sh -c 'cmake $(CMAKEFLAGS) $(CMAKE_PROJECTDIR) && $(CMAKE_SCRIPTDIR)/bin/cmake_discover_cc_settings.sh $(notdir $@) "$(realpath $(dir $@))"') \
|
||||
&& touch $(addprefix $(dir $@)/,include_dirs.txt) $@
|
||||
|
||||
cmake_discover_cc_settings_rule = \
|
||||
$$(OUTDIR)/$1/$$(CMAKE_BUILD_TYPE)/include_dirs.txt: $$(OUTDIR)/$1/$$(CMAKE_BUILD_TYPE)/CMakeCache.txt; \
|
||||
$$(SILENT)$$(call cmake_discover_cc_settings,$1)
|
||||
cmake_discover_cc_settings = \
|
||||
$(call run,$1,$(CMAKE_SCRIPTDIR)/bin/cmake_discover_cc_settings.sh $(notdir $<) '$(realpath $(dir $<))')
|
||||
|
||||
ninja_build_rule = \
|
||||
build-$1: $$(OUTDIR)/$1/$$(CMAKE_BUILD_TYPE)/CMakeCache.txt; \
|
||||
$$(SILENT)$$(call ninja_build,$1)
|
||||
ninja_build = $(call run,$1,ninja $(_PARALLELMFLAGS) $(NINJAFLAGS) $(GOALS))
|
||||
|
||||
ctest_memcheck_rule = \
|
||||
memcheck-$1: build-$1; \
|
||||
$$(SILENT)$$(call ctest_memcheck,$1)
|
||||
ctest_memcheck = $(call run,$1,ctest -T memcheck $(CTESTFLAGS))
|
||||
|
||||
#######################################################################################################################
|
||||
# CMake rule target configuration
|
||||
|
||||
$(BUILDSILENT)NINJAFLAGS += -v
|
||||
|
||||
DOCKER_RUNFLAGS += --env NINJA_STATUS
|
||||
|
||||
CMAKEFLAGS += '-GNinja'
|
||||
CMAKEFLAGS += '-DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE)'
|
||||
|
||||
CMAKE_TARGETS := $(CMAKE_TARGETS)
|
||||
CMAKE_TARGET := $(filter $(BUILDTARGET),$(CMAKE_TARGETS))
|
||||
$(CMAKE_TARGET)CMAKE_ACTIVE_TARGETS += $(CMAKE_TARGETS)
|
||||
CMAKE_ACTIVE_TARGETS += $(CMAKE_TARGET)
|
||||
CMAKE_ACTIVE_TARGETS := $(call filter_targets,$(FILTER),$(CMAKE_ACTIVE_TARGETS))
|
||||
|
||||
CMAKE_BUILD_TARGETS += $(addprefix build-,$(CMAKE_ACTIVE_TARGETS))
|
||||
CMAKE_CLEAN_TARGETS += $(addprefix clean-,$(CMAKE_ACTIVE_TARGETS))
|
||||
CMAKE_CHECK_TARGETS += $(addprefix check-,$(CMAKE_ACTIVE_TARGETS))
|
||||
CMAKE_MEMCHECK_TARGETS += $(addprefix memcheck-,$(call filter_targets,$(CMAKE_MEMCHECK_FILTER),$(CMAKE_ACTIVE_TARGETS)))
|
||||
CMAKE_RUN_TARGETS += $(addprefix run-,$(firstword $(CMAKE_ACTIVE_TARGETS)))
|
||||
CMAKE_DISCOVER_CC_TARGETS += $(addprefix discover-cc-,$(firstword $(CMAKE_ACTIVE_TARGETS)))
|
||||
CMAKE_OUTDIRS += $(addsuffix /$(CMAKE_BUILD_TYPE),$(addprefix $(OUTDIR)/,$(CMAKE_ACTIVE_TARGETS)))
|
||||
CMAKE_RULE_TARGETS += $(addsuffix /cmakerules.mk,$(OUTDIR))
|
||||
|
||||
BUILD_TARGETS += $(CMAKE_BUILD_TARGETS)
|
||||
CHECK_TARGETS += $(CMAKE_CHECK_TARGETS)
|
||||
MEMCHECK_TARGETS += $(CMAKE_MEMCHECK_TARGETS)
|
||||
CLEAN_TARGETS += $(CMAKE_CLEAN_TARGETS)
|
||||
RUN_TARGETS += $(CMAKE_RUN_TARGETS)
|
||||
DISCOVER_CC_TARGETS += $(CMAKE_DISCOVER_CC_TARGETS)
|
||||
RULE_TARGETS += $(CMAKE_RULE_TARGETS)
|
||||
TARGETS += $(CMAKE_ACTIVE_TARGETS)
|
||||
OUTDIRS += $(CMAKE_OUTDIRS)
|
||||
|
||||
#######################################################################################################################
|
||||
# Makefile dependencies
|
||||
|
||||
MAKEFILE_DEPS += touch
|
||||
MAKEFILE_DEPS += echo
|
||||
|
||||
#######################################################################################################################
|
||||
# CMake rules
|
||||
|
||||
$(CMAKE_RULE_TARGETS):
|
||||
$(SILENT) \
|
||||
{ \
|
||||
$(foreach TARGET,$(CMAKE_TARGETS),\
|
||||
echo; \
|
||||
echo '$(call image_rule,$(TARGET))'; \
|
||||
echo; \
|
||||
echo '$(call cmake_configure_rule,$(TARGET))'; \
|
||||
echo; \
|
||||
echo '$(call ninja_build_rule,$(TARGET))'; \
|
||||
echo; \
|
||||
echo '$(call check_rule,$(TARGET))'; \
|
||||
echo; \
|
||||
echo '$(call ctest_memcheck_rule,$(TARGET))'; \
|
||||
echo; \
|
||||
echo '$(call run_rule,$(TARGET))'; \
|
||||
echo; \
|
||||
echo '$(call clean_rule,$(TARGET))'; \
|
||||
echo; \
|
||||
echo '$(call cmake_discover_cc_settings_rule,$(TARGET))'; \
|
||||
echo; \
|
||||
echo '$(call discover_cc_rule,$(TARGET))'; \
|
||||
echo; \
|
||||
echo '$(call wrapper_rule,$(TARGET))'; \
|
||||
) \
|
||||
} > $@
|
||||
|
@ -1,57 +0,0 @@
|
||||
CURRENT_MAKEFILE := $(lastword $(MAKEFILE_LIST)))
|
||||
_INCLUDE_DEFAULTS := T
|
||||
|
||||
#######################################################################################################################
|
||||
# Overridable common defaults
|
||||
|
||||
# NOTE: default assumes first loaded makefile is located in root directory of project
|
||||
MAKEFILE ?= $(firstword $(MAKEFILE_LIST))
|
||||
MAKEFILE := $(MAKEFILE)
|
||||
|
||||
PROJECTDIR ?= $(patsubst %/,%,$(dir $(MAKEFILE)))
|
||||
SCRIPTDIR ?= $(patsubst %/,%,$(dir $(CURRENT_MAKEFILE)))
|
||||
OUTDIR ?= $(PROJECTDIR)/.build
|
||||
|
||||
BUILDTYPE ?= Debug
|
||||
|
||||
BUILDVERBOSE ?=
|
||||
BUILDSILENT := $(if $(BUILDVERBOSE),,1)
|
||||
|
||||
VERSION ?= $(shell cat $(PROJECTDIR)/VERSION)
|
||||
VERSION := $(VERSION)
|
||||
|
||||
USERID ?= $(shell id -u)
|
||||
USERID := $(USERID)
|
||||
|
||||
HOST_MARCH ?= $(shell dpkg --print-architecture 2>/dev/null)
|
||||
HOST_CONTAINER ?= $(shell $(SCRIPTDIR)/bin/get_container_id.sh)
|
||||
HOST_CONTAINER := $(HOST_CONTAINER)
|
||||
|
||||
$(HOST_CONTAINER)PORTABLE_WORSPACE ?=
|
||||
CONTAINER_PROJECTDIR ?= /workspace/src
|
||||
CONTAINER_SCRIPTDIR ?= /workspace/bin
|
||||
CONTAINER_OUTDIR ?= /workspace/out
|
||||
$(PORTABLE_WORSPACE)CONTAINER_PROJECTDIR = $(abspath $(PROJECTDIR))
|
||||
$(PORTABLE_WORSPACE)CONTAINER_SCRIPTDIR = $(abspath $(SCRIPTDIR))
|
||||
$(PORTABLE_WORSPACE)CONTAINER_OUTDIR = $(abspath $(OUTDIR))
|
||||
|
||||
SOURCE_DATE_EPOCH ?= $(shell $(SCRIPTDIR)/bin/get_source_date_epoch.sh)
|
||||
SOURCE_DATE_EPOCH := $(SOURCE_DATE_EPOCH)
|
||||
export SOURCE_DATE_EPOCH
|
||||
|
||||
BUILDTIME ?= $(shell date -u -d '@$(SOURCE_DATE_EPOCH)' --rfc-3339 ns 2>/dev/null | sed -e 's/ /T/')
|
||||
BUILDTIME := $(BUILDTIME)
|
||||
export BUILDTIME
|
||||
|
||||
VERBOSE ?=
|
||||
PARALLELMFLAGS ?=
|
||||
NPROC ?= $(shell echo '$(PARALLELMFLAGS)' | sed -n -e 's@.*-j.*\([0-9]\+\)@\1@p')
|
||||
|
||||
#######################################################################################################################
|
||||
# Makefile dependencies
|
||||
|
||||
MAKEFILE_DEPS += cat
|
||||
MAKEFILE_DEPS += id
|
||||
MAKEFILE_DEPS += echo
|
||||
MAKEFILE_DEPS += sed
|
||||
|
@ -1,87 +0,0 @@
|
||||
CURRENT_MAKEFILE := $(lastword $(MAKEFILE_LIST))
|
||||
|
||||
#######################################################################################################################
|
||||
# Overridable docker defaults
|
||||
|
||||
DOCKER ?= docker
|
||||
DOCKER_BUILDKIT ?=
|
||||
|
||||
CONTAINER_CGROUP_PARENT ?=
|
||||
CONTAINER_USER ?= $(USERID)
|
||||
CONTAINER_GROUP ?= $(USERID)
|
||||
|
||||
ifndef _INCLUDE_DEFAULTS
|
||||
include $(patsubst %/,%,$(dir $(CURRENT_MAKEFILE)))/defaults.mk
|
||||
endif
|
||||
|
||||
#######################################################################################################################
|
||||
# Docker macros
|
||||
|
||||
image_run_volumes += $(addprefix --volumes-from ,$2)
|
||||
|
||||
image_name = $(REGISTRY_PREFIX)$(subst -,/,$1)/$(PROJECTNAME)$(addprefix :,$(VERSION))
|
||||
|
||||
image_run = $(DOCKER) run --rm --interactive $(DOCKER_RUNFLAGS) \
|
||||
$(call image_run_volumes,$1,$(HOST_CONTAINER)) \
|
||||
$(addprefix --cgroup-parent ,$(CONTAINER_CGROUP_PARENT)) \
|
||||
--workdir '$(CONTAINER_OUTDIR)/$1/$(BUILDTYPE)' \
|
||||
$3 \
|
||||
$(call image_name,$1) \
|
||||
$2
|
||||
|
||||
image_rule = \
|
||||
$$(OUTDIR)/docker/$1: $$(OUTDIR)/docker/$1.dockerfile $$(EXTRACT_TARGETS) $$(MAKEFILE_LIST); \
|
||||
$$(SILENT)$$(call image,$1)
|
||||
image = \
|
||||
$(call echo_if_silent,TARGET=$1 docker build --file $< --tag $(call image_name,$1) $(OUTDIR)) \
|
||||
&& $(DOCKER) build --rm $(DOCKER_BUILDFLAGS) --iidfile $@ --file $< --tag $(call image_name,$1) $(OUTDIR)
|
||||
|
||||
run_rule = \
|
||||
run-$1: $$(OUTDIR)/docker/$1; \
|
||||
$$(SILENT)$$(call run,$1,bash,--tty) || true
|
||||
run = $(call echo_if_silent,TARGET=$1 $(addprefix BUILDTYPE=,$(BUILDTYPE)) $2) && $(call image_run,$1,$2,$3)
|
||||
|
||||
wrapper_rule = \
|
||||
$$(OUTDIR)/$1/$$(BUILDTYPE)/gdbserver: $$(SCRIPTDIR)/resources/run_image.sh.template $$(OUTDIR)/docker/$1; \
|
||||
$$(SILENT)$$(call wrapper,$1)
|
||||
wrapper = \
|
||||
$(call echo_if_silent,generating $@) \
|
||||
&& sed \
|
||||
-e 's@%PROJECTDIR%@$(abspath $(PROJECTDIR))@g' \
|
||||
-e 's@%SCRIPTDIR%@$(abspath $(SCRIPTDIR))@g' \
|
||||
-e 's@%DOCKER%@$(DOCKER)@g' \
|
||||
-e 's@%RUNFLAGS%@$(DOCKER_RUNFLAGS) $(call image_run_volumes,$1)@g' \
|
||||
-e 's@%IMAGE%@$(call image_name,$1)@g' \
|
||||
-e 's@%RUNCMD%@$(notdir $@)@g' \
|
||||
$< > $@ \
|
||||
&& chmod +x $@
|
||||
|
||||
#######################################################################################################################
|
||||
# Docker rule target configuration
|
||||
|
||||
DOCKER_RUNFLAGS += --env SOURCE_DATE_EPOCH
|
||||
DOCKER_RUNFLAGS += --env BUILDTIME
|
||||
DOCKER_RUNFLAGS += --user '$(CONTAINER_USER):$(CONTAINER_GROUP)'
|
||||
|
||||
DOCKER_BUILDARGS += 'USERID=$(USERID)'
|
||||
DOCKER_BUILDARGS += 'PARALLELMFLAGS=$(_PARALLELMFLAGS)'
|
||||
DOCKER_BUILDARGS += 'PROJECTDIR=$(CONTAINER_PROJECTDIR)'
|
||||
DOCKER_BUILDARGS += 'SCRIPTDIR=$(CONTAINER_SCRIPTDIR)'
|
||||
DOCKER_BUILDARGS += 'OUTDIR=$(CONTAINER_OUTDIR)'
|
||||
DOCKER_BUILDARGS += 'REGISTRY_PREFIX=$(REGISTRY_PREFIX)'
|
||||
|
||||
DOCKER_BUILDFLAGS += $(addprefix --build-arg ,$(DOCKER_BUILDARGS))
|
||||
|
||||
OUTDIRS += $(OUTDIR)/docker
|
||||
|
||||
$(HOST_CONTAINER)image_run_volumes += --volume '$(realpath $(PROJECTDIR)):$(CONTAINER_PROJECTDIR):cached'
|
||||
$(HOST_CONTAINER)image_run_volumes += --volume '$(realpath $(SCRIPTDIR)):$(CONTAINER_SCRIPTDIR):cached'
|
||||
$(HOST_CONTAINER)image_run_volumes += --volume '$(realpath $(OUTDIR)/$1):$(CONTAINER_OUTDIR)/$1:delegated'
|
||||
|
||||
#######################################################################################################################
|
||||
# Makefile dependencies
|
||||
|
||||
MAKEFILE_DEPS += $(DOCKER)
|
||||
MAKEFILE_DEPS += sed
|
||||
MAKEFILE_DEPS += chmod
|
||||
|
@ -1 +0,0 @@
|
||||
%MD5% %FILE%
|
@ -1,50 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
DOCKER="${DOCKER:-%DOCKER%}"
|
||||
IMAGE="${IMAGE:-%IMAGE%}"
|
||||
NETWORK="${NETWORK:-host}"
|
||||
PROJECTDIR="${PROJECTDIR:-%PROJECTDIR%}"
|
||||
SCRIPTDIR="${SCRIPTDIR:-%SCRIPTDIR%/bin}"
|
||||
ENTRYPOINT="${ENTRYPOINT:-%RUNCMD%}"
|
||||
PATH="${SCRIPTDIR}:$PATH"
|
||||
|
||||
set -- --entrypoint "$ENTRYPOINT" "$IMAGE" "$@"
|
||||
set -- --network "$NETWORK" --workdir "$PWD" "$@"
|
||||
|
||||
if [ -n "$USERID" ]; then
|
||||
set -- --user "$USERID:$USERID" "$@"
|
||||
fi
|
||||
|
||||
if [ -n "$PID" ]; then
|
||||
set -- --pid "$PID" "$@"
|
||||
fi
|
||||
|
||||
if [ -n "$CONTAINER_CGROUP_PARENT" ]; then
|
||||
set -- --cgroup-parent "$CONTAINER_CGROUP_PARENT" "$@"
|
||||
fi
|
||||
|
||||
HOST_CONTAINER="${HOST_CONTAINER:-"$(get_container_id.sh)"}" || true
|
||||
if [ -n "$HOST_CONTAINER" ]; then
|
||||
set -- --volumes-from "$HOST_CONTAINER" "$@"
|
||||
else
|
||||
set -- --volume "$PROJECTDIR:$PROJECTDIR:cached" "$@"
|
||||
fi
|
||||
|
||||
set -- %RUNFLAGS% "$@"
|
||||
|
||||
if [ -t 0 ] && ! is_running_in_bg.sh $$; then
|
||||
set -- --interactive "$@"
|
||||
fi
|
||||
|
||||
# if STDIN piped or redirected
|
||||
if [ -p /dev/stdin ] || { [ ! -t 0 ] && [ ! -p /dev/stdin ]; }; then
|
||||
set -- --interactive "$@"
|
||||
elif [ -t 1 ]; then
|
||||
set -- --tty "$@"
|
||||
fi
|
||||
|
||||
set -- --rm "$@"
|
||||
|
||||
exec "$DOCKER" run "$@"
|
@ -1,124 +0,0 @@
|
||||
|
||||
#######################################################################################################################
|
||||
# Overridable defaults
|
||||
|
||||
ifndef _INCLUDE_DEFAULTS
|
||||
include $(patsubst %/,%,$(dir $(CURRENT_MAKEFILE)))/defaults.mk
|
||||
endif
|
||||
|
||||
#######################################################################################################################
|
||||
# Standard macros
|
||||
|
||||
echo_if_silent = VERBOSE=1
|
||||
$(VERBOSE)echo_if_silent = echo $1
|
||||
$(VERBOSE)SILENT := @
|
||||
|
||||
filter_out_command ?= $(filter $1,$(foreach CMD,$1,$(shell command -v $(CMD) 2>&1 1>/dev/null || echo $(CMD))))
|
||||
|
||||
md5sum = { \
|
||||
if [ -n "$2" ]; then \
|
||||
sed -e 's@%MD5%@$2@g' -e 's@%FILE%@$1@g' $(SCRIPTDIR)/resources/md5sum.txt.template > $1.md5; \
|
||||
md5sum -c $1.md5; \
|
||||
else \
|
||||
echo 'warning:$1: no md5 skipping verification' 1>&2; \
|
||||
fi; \
|
||||
}
|
||||
|
||||
$(SKIP_FETCH)curl = $(call echo_if_silent,curl -fSL $(CURLFLAGS) -o $1 $2) \
|
||||
&& curl -fSL $(CURLFLAGS) -o $1 $2 \
|
||||
&& $(call md5sum,$1,$3)
|
||||
|
||||
curl ?= echo 'warning:$1: download skipped (SKIP_FETCH=$(SKIP_FETCH))'
|
||||
|
||||
check_rule = \
|
||||
check-$1: build-$1;
|
||||
|
||||
clean_rule = \
|
||||
clean-$1: ; \
|
||||
$$(SILENT)-$$(call clean,$1)
|
||||
clean = rm -rf $(OUTDIR)/$1
|
||||
|
||||
discover_cc_rule = \
|
||||
discover-cc-$1: $$(OUTDIR)/$1/$$(BUILDTYPE)/include_dirs.txt; \
|
||||
$$(SILENT)$$(call discover_cc,$1)
|
||||
discover_cc = cat $<
|
||||
|
||||
#######################################################################################################################
|
||||
# Standard rule target configuration
|
||||
|
||||
OUTDIRS += $(OUTDIR)
|
||||
|
||||
OUTDIRS := $(sort $(OUTDIRS))
|
||||
TARGETS := $(sort $(TARGETS))
|
||||
|
||||
TASKS := $(words $(if $(TARGETS),$(TARGETS),_))
|
||||
|
||||
DISBALE_OSYNC ?= $(filter 1,$(TASKS))
|
||||
$(DISBALE_OSYNC)GNUMAKEFLAGS += --output-sync
|
||||
|
||||
_NPROC = $(NPROC)
|
||||
ifeq ($(strip $(_NPROC)),)
|
||||
_NPROC = $(shell nproc)
|
||||
endif
|
||||
_PARALLELMFLAGS := $(addprefix -j,$(shell echo "$$(($(_NPROC)/$(TASKS)))"))
|
||||
|
||||
#######################################################################################################################
|
||||
# Makefile dependencies
|
||||
|
||||
MAKEFILE_DEPS += cp
|
||||
MAKEFILE_DEPS += rm
|
||||
MAKEFILE_DEPS += mkdir
|
||||
MAKEFILE_DEPS += echo
|
||||
|
||||
MAKEFILE_DEPS := $(sort $(MAKEFILE_DEPS))
|
||||
|
||||
UNSATISFIED_MAKEFILE_DEPS := $(call filter_out_command,$(MAKEFILE_DEPS))
|
||||
|
||||
RULE_TARGETS_DEPS := $(filter-out $(RULE_TARGETS) $(addprefix $(PROJECTDIR),$(RULE_TARGETS)),$(MAKEFILE_LIST))
|
||||
|
||||
#######################################################################################################################
|
||||
# Standard rules
|
||||
|
||||
ifneq ($(MAKECMDGOALS),distclean)
|
||||
-include $(RULE_TARGETS)
|
||||
endif
|
||||
|
||||
.PHONY: all build-%
|
||||
all: $(BUILD_TARGETS);
|
||||
|
||||
.PHONY: check check-%
|
||||
check: $(CHECK_TARGETS);
|
||||
|
||||
.PHONY: memcheck memcheck-%
|
||||
memcheck: $(MEMCHECK_TARGETS);
|
||||
|
||||
.PHONY: lint lint-%
|
||||
lint: $(LINT_TARGETS);
|
||||
|
||||
.PHONY: run run-%
|
||||
run: $(RUN_TARGETS);
|
||||
|
||||
.PHONY: clean clean-%
|
||||
clean: $(CLEAN_TARGETS);
|
||||
|
||||
.PHONY: get-deps get-deps-%
|
||||
get-deps: $(EXTRACT_TARGETS);
|
||||
|
||||
.PHONY: discover-cc discover-cc-%
|
||||
discover-cc: $(DISCOVER_CC_TARGETS);
|
||||
|
||||
.PHONY: distclean
|
||||
distclean:
|
||||
$(SILENT)-rm -rf $(OUTDIRS)
|
||||
|
||||
.PHONY: debug-print-%
|
||||
debug-print-%:
|
||||
@printf '%s\n' '$*:' $($*)
|
||||
|
||||
$(RULE_TARGETS): $(RULE_TARGETS_DEPS) | $(UNSATISFIED_MAKEFILE_DEPS) $(OUTDIRS)
|
||||
|
||||
$(OUTDIRS):
|
||||
$(SILENT)mkdir -p $@
|
||||
|
||||
$(UNSATISFIED_MAKEFILE_DEPS):
|
||||
$(error 'required commands $(UNSATISFIED_MAKEFILE_DEPS) not found; install appropriate packages e.g. docker-ce, busybox and curl')
|
Loading…
Reference in New Issue
Block a user