Message ID | 20180829053036.17669-1-sam@mendozajonas.com |
---|---|
State | Accepted |
Headers | show |
Series | docker: Allow CC and make command to be customised | expand |
On Wed, 2018-08-29 at 15:30 +1000, Samuel Mendoza-Jonas wrote: > Allow CC to be passed through to change the default compiler, and also > allow the invocation of 'make' to be customised. An example use case of > this is to set CC=/usr/bin/clang and use > --make-command 'scan-build make' to build Petitboot with the clang > static analyzer. > > Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com> Merged as 3d408f0 > --- > docker/Dockerfile.builder | 2 ++ > docker/build-pb | 19 +++++++++++++++---- > docker/builder-include | 2 +- > 3 files changed, 18 insertions(+), 5 deletions(-) > > diff --git a/docker/Dockerfile.builder b/docker/Dockerfile.builder > index 4bf89d34..321629fd 100644 > --- a/docker/Dockerfile.builder > +++ b/docker/Dockerfile.builder > @@ -12,6 +12,8 @@ RUN apt-get update && apt-get install -y \ > autoconf \ > autopoint \ > bison \ > + clang \ > + clang-tools \ > flex \ > gettext \ > gcc \ > diff --git a/docker/build-pb b/docker/build-pb > index 1d87fb42..62295509 100755 > --- a/docker/build-pb > +++ b/docker/build-pb > @@ -16,6 +16,7 @@ usage () { > echo " -d --dry-run - Do not run docker commands." >&2 > echo " -h --help - Show this help and exit." >&2 > echo " -i --interactive - Run an interactive pb-builder container." >&2 > + echo " -m --make-command - Set a specific command to be called for 'make'.">&2 > echo " -o --configure-opts - Extra arguments for configure." >&2 > echo " -t --tag - Print Docker tag to stdout and exit." >&2 > echo " -v --verbose - Verbose execution." >&2 > @@ -23,13 +24,14 @@ usage () { > echo " DOCKER_TAG - Default: '${DOCKER_TAG}'" >&2 > echo " CFLAGS - Default: '${CFLAGS}'" >&2 > echo " LDFLAGS - Default: '${LDFLAGS}'" >&2 > + echo " CC - Default: '${CC}'" >&2 > echo "Examples:" >&2 > echo " ${name} -vc" > echo " ${name} -v" > } > > -short_opts="cdhio:tv" > -long_opts="check,dry-run,help,interactive,configure-opts:,tag,verbose" > +short_opts="cdhim:o:tv" > +long_opts="check,dry-run,help,interactive,make-command:,configure-opts:,tag,verbose" > > opts=$(getopt --options ${short_opts} --long ${long_opts} -n "${name}" -- "$@") > > @@ -58,6 +60,11 @@ while true ; do > interactive=1 > shift > ;; > + -m | --make-command) > + shift > + makecmd=${1} > + shift > + ;; > -o | --configure-opts) > shift > configure_opts=${1} > @@ -120,10 +127,14 @@ else > docker_extra="true" > fi > > -flags="CFLAGS=${CFLAGS} LDFLAGS=${LDFLAGS}" > +if [[ -z "${makecmd}" ]]; then > + makecmd="make" > +fi > + > +flags="CFLAGS=${CFLAGS} LDFLAGS=${LDFLAGS} CC=${CC}" > > cd "${TOP_DIR}" > docker_args="${docker_base_args} ${docker_user_args}" > run_cmd "docker run ${docker_args} ${DOCKER_TAG} /bin/bash \ > -e ${bash_debug} \ > - -c './bootstrap && ${flags} ./configure ${configure_opts[@]} && make && ${docker_extra}'" > + -c './bootstrap && ${flags} ./configure ${configure_opts[@]} && ${makecmd} && ${docker_extra}'" > diff --git a/docker/builder-include b/docker/builder-include > index fe88e900..7f56dc25 100644 > --- a/docker/builder-include > +++ b/docker/builder-include > @@ -51,7 +51,7 @@ show_tag () { > echo "${DOCKER_TAG}" > } > > -: ${VERSION:="4"} > +: ${VERSION:="5"} > : ${ARCH_TAG:="$(arch_tag)"} > : ${DOCKER_NAME:="pb-builder"} > : ${DOCKER_TAG:="${DOCKER_NAME}:${VERSION}${ARCH_TAG}"}
diff --git a/docker/Dockerfile.builder b/docker/Dockerfile.builder index 4bf89d34..321629fd 100644 --- a/docker/Dockerfile.builder +++ b/docker/Dockerfile.builder @@ -12,6 +12,8 @@ RUN apt-get update && apt-get install -y \ autoconf \ autopoint \ bison \ + clang \ + clang-tools \ flex \ gettext \ gcc \ diff --git a/docker/build-pb b/docker/build-pb index 1d87fb42..62295509 100755 --- a/docker/build-pb +++ b/docker/build-pb @@ -16,6 +16,7 @@ usage () { echo " -d --dry-run - Do not run docker commands." >&2 echo " -h --help - Show this help and exit." >&2 echo " -i --interactive - Run an interactive pb-builder container." >&2 + echo " -m --make-command - Set a specific command to be called for 'make'.">&2 echo " -o --configure-opts - Extra arguments for configure." >&2 echo " -t --tag - Print Docker tag to stdout and exit." >&2 echo " -v --verbose - Verbose execution." >&2 @@ -23,13 +24,14 @@ usage () { echo " DOCKER_TAG - Default: '${DOCKER_TAG}'" >&2 echo " CFLAGS - Default: '${CFLAGS}'" >&2 echo " LDFLAGS - Default: '${LDFLAGS}'" >&2 + echo " CC - Default: '${CC}'" >&2 echo "Examples:" >&2 echo " ${name} -vc" echo " ${name} -v" } -short_opts="cdhio:tv" -long_opts="check,dry-run,help,interactive,configure-opts:,tag,verbose" +short_opts="cdhim:o:tv" +long_opts="check,dry-run,help,interactive,make-command:,configure-opts:,tag,verbose" opts=$(getopt --options ${short_opts} --long ${long_opts} -n "${name}" -- "$@") @@ -58,6 +60,11 @@ while true ; do interactive=1 shift ;; + -m | --make-command) + shift + makecmd=${1} + shift + ;; -o | --configure-opts) shift configure_opts=${1} @@ -120,10 +127,14 @@ else docker_extra="true" fi -flags="CFLAGS=${CFLAGS} LDFLAGS=${LDFLAGS}" +if [[ -z "${makecmd}" ]]; then + makecmd="make" +fi + +flags="CFLAGS=${CFLAGS} LDFLAGS=${LDFLAGS} CC=${CC}" cd "${TOP_DIR}" docker_args="${docker_base_args} ${docker_user_args}" run_cmd "docker run ${docker_args} ${DOCKER_TAG} /bin/bash \ -e ${bash_debug} \ - -c './bootstrap && ${flags} ./configure ${configure_opts[@]} && make && ${docker_extra}'" + -c './bootstrap && ${flags} ./configure ${configure_opts[@]} && ${makecmd} && ${docker_extra}'" diff --git a/docker/builder-include b/docker/builder-include index fe88e900..7f56dc25 100644 --- a/docker/builder-include +++ b/docker/builder-include @@ -51,7 +51,7 @@ show_tag () { echo "${DOCKER_TAG}" } -: ${VERSION:="4"} +: ${VERSION:="5"} : ${ARCH_TAG:="$(arch_tag)"} : ${DOCKER_NAME:="pb-builder"} : ${DOCKER_TAG:="${DOCKER_NAME}:${VERSION}${ARCH_TAG}"}
Allow CC to be passed through to change the default compiler, and also allow the invocation of 'make' to be customised. An example use case of this is to set CC=/usr/bin/clang and use --make-command 'scan-build make' to build Petitboot with the clang static analyzer. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com> --- docker/Dockerfile.builder | 2 ++ docker/build-pb | 19 +++++++++++++++---- docker/builder-include | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-)