~aleteoryx/muditaos

ref: sign_test muditaos/in_docker.sh -rwxr-xr-x 2.2 KiB
a217eeb3 — Dawid Wojtas [BH-2024] Fix lack of alarm directory after updating software 1 year, 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env bash
# Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

CONTAINER_NAME="wearemudita/mudita_os_builder"
CONTAINER_TAG="latest"
CONTAINER=${CONTAINER_NAME}:${CONTAINER_TAG}
PURE_HOME=`pwd`
STANDARD_OPTIONS="-v `pwd`:${PURE_HOME} --user \"$(id -u):$(id -g)\" --env HOME=${PURE_HOME} -t"

RCFILE="/home/docker/.bashrc"

if [[ $BASH_VERSINFO -lt 4 ]]; then
    echo "Please update your bash to at least version 4"
	echo "your is: ${BASH_VERSINFO}"
    exit 4
fi

function help() {
    cat <<- MSGEND
		This script runs configuration and builds in docker container.
		You don't have to setup entire build environment, just use container.
		 
		Usage:
		${0} login|config|make [additional options]
		 
		    login                                   - login to build container - usually not needed
		    config <target> <build_type> [OPTIONS]  - run ./configure.sh in container
		                                              <target> and <build_type> are required
		                                              OPTIONS are passed to cmake as is
		                                              run '${0} config' without params to see details
		    make|ninja <build_directory> [OPTIONS]        - run 'make' in container. You have to pass directory
		                                              created by '${0} config' command.
		                                              you can pass additional arguments for make linke '-j' or 'VERBOSE=1'
		MSGEND
    exit 0
}

TARGET=$1
shift 
case ${TARGET} in
    "login") 
        CMD="docker run ${STANDARD_OPTIONS} -w ${PURE_HOME} -it --entrypoint /bin/bash ${CONTAINER} --rcfile ${RCFILE}"
        ;;
    "config")
        CMD="docker run ${STANDARD_OPTIONS} -w ${PURE_HOME} --entrypoint ./configure.sh ${CONTAINER}  $@"
        ;;
    "make")
        BUILD_DIR=$1
        shift
        JOBS=$(nproc)
        CMD="docker run ${STANDARD_OPTIONS} -w ${PURE_HOME}/${BUILD_DIR} --entrypoint make ${CONTAINER} -j ${JOBS} $@"
        ;;
    "ninja")
        BUILD_DIR=$1
        shift
        CMD="docker run ${STANDARD_OPTIONS} -w ${PURE_HOME}/${BUILD_DIR} --entrypoint ninja ${CONTAINER} $@"
        ;;
    *)
        help
        ;;
esac

echo ${CMD}
eval ${CMD}