Re: [pacman-dev] [PATCH 1/1] Split prepare_buildenv() to libmakepkg scripts

2018-11-03 Thread Eli Schwartz
On 11/3/18 12:54 PM, Que Quotion wrote:
> From: Que Quotion 
> 
> As Eli Schwartz has pointed out:
> https://lists.archlinux.org/pipermail/pacman-dev/2018-May/022501.html
> 
> It would be beneficial to makepkg to have this function ported
> to libmakepkg and split into individual scripts.
> 
> Supersedes: https://patchwork.archlinux.org/patch/540/

Thanks for putting in the work to (re)do this.

> Signed-off-by: Que Quotion 
> ---
>  scripts/Makefile.am  |  6 ++
>  scripts/libmakepkg/buildenv.sh.in| 55 ++
>  scripts/libmakepkg/buildenv/buildflags.sh.in | 34 +++
>  scripts/libmakepkg/buildenv/ccache.sh.in | 45 +++
>  scripts/libmakepkg/buildenv/distcc.sh.in | 47 +++
>  scripts/libmakepkg/buildenv/makeflags.sh.in  | 34 +++
>  scripts/libmakepkg/buildenv/meson.build  | 20 +++
>  scripts/libmakepkg/meson.build   |  1 +
>  scripts/makepkg.sh.in| 60 +---
>  9 files changed, 243 insertions(+), 59 deletions(-)
>  create mode 100644 scripts/libmakepkg/buildenv.sh.in
>  create mode 100644 scripts/libmakepkg/buildenv/buildflags.sh.in
>  create mode 100644 scripts/libmakepkg/buildenv/ccache.sh.in
>  create mode 100644 scripts/libmakepkg/buildenv/distcc.sh.in
>  create mode 100644 scripts/libmakepkg/buildenv/makeflags.sh.in
>  create mode 100644 scripts/libmakepkg/buildenv/meson.build
> 
> diff --git a/scripts/Makefile.am b/scripts/Makefile.am
> index c6b6220e..8e669f71 100644
> --- a/scripts/Makefile.am
> +++ b/scripts/Makefile.am
> @@ -41,6 +41,7 @@ LIBRARY = \
>  libmakepkgdir = $(datarootdir)/makepkg
>  
>  LIBMAKEPKGDIRS = \
> + buildenv \
>   integrity \
>   lint_config \
>   lint_package \
> @@ -50,6 +51,11 @@ LIBMAKEPKGDIRS = \
>   util
>  
>  LIBMAKEPKG_IN = \
> + libmakepkg/buildenv.sh \
> + libmakepkg/buildenv/buildflags.sh \
> + libmakepkg/buildenv/ccache.sh \
> + libmakepkg/buildenv/distcc.sh \
> + libmakepkg/buildenv/makeflags.sh \
>   libmakepkg/integrity.sh \
>   libmakepkg/integrity/generate_checksum.sh \
>   libmakepkg/integrity/generate_signature.sh \
> diff --git a/scripts/libmakepkg/buildenv.sh.in 
> b/scripts/libmakepkg/buildenv.sh.in
> new file mode 100644
> index ..a14a3a9a
> --- /dev/null
> +++ b/scripts/libmakepkg/buildenv.sh.in
> @@ -0,0 +1,55 @@
> +#!/bin/bash
> +#
> +#   buildenv.sh - functions for altering the build environment before
> +#   compiliation
> +#
> +#   Copyright (c) 2018 Pacman Development Team 
> +#
> +#   This program is free software; you can redistribute it and/or modify
> +#   it under the terms of the GNU General Public License as published by
> +#   the Free Software Foundation; either version 2 of the License, or
> +#   (at your option) any later version.
> +#
> +#   This program is distributed in the hope that it will be useful,
> +#   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +#   GNU General Public License for more details.
> +#
> +#   You should have received a copy of the GNU General Public License
> +#   along with this program.  If not, see .
> +#
> +
> +[[ -n "$LIBMAKEPKG_BUILDENV_SH" ]] && return
> +LIBMAKEPKG_BUILDENV_SH=1
> +
> +LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
> +
> +source "$LIBRARY/util/message.sh"
> +source "$LIBRARY/util/option.sh"
> +
> +
> +declare -a build_options
> +
> +for lib in "$LIBRARY/buildenv/"*.sh; do
> + source "$lib"
> +done
> +
> +readonly -a build_options
> +
> +prepare_buildenv() {
> + msg "$(gettext "Preparing build environment...")"
> +
> + for func in ${build_options[@]}; do
> + $func
> + done
> +
> + if check_option "debug" "y"; then
> + DEBUG_CFLAGS+=" 
> -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}"
> + DEBUG_CXXFLAGS+=" 
> -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}"
> + CFLAGS+=" $DEBUG_CFLAGS"
> + CXXFLAGS+=" $DEBUG_CXXFLAGS"
> + fi
> +
> + # ensure all necessary build variables are exported
> + export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS MAKEFLAGS CHOST
> +}

Why is this on its own, not in a dropin?

> diff --git a/scripts/libmakepkg/buildenv/buildflags.sh.in 
> b/scripts/libmakepkg/buildenv/buildflags.sh.in
> new file mode 100644
> index ..fb49a85c
> --- /dev/null
> +++ b/scripts/libmakepkg/buildenv/buildflags.sh.in
> @@ -0,0 +1,34 @@
> +#!/usr/bin/bash
> +#
> +#   buildflags.sh - Clear user-specified buildflags if requested
> +#
> +#   Copyright (c) 2018 Pacman Development Team 
> +#
> +#   This program is free software; you can redistribute it and/or modify
> +#   it under the terms of the GNU General Public License as published by
> +#   the Free Software Foundation; either version 2 of the License, or
> +#   (at your option) any later version.
> +#
> +#   This pro

[pacman-dev] [PATCH 1/1] Split prepare_buildenv() to libmakepkg scripts

2018-11-03 Thread Que Quotion
From: Que Quotion 

As Eli Schwartz has pointed out:
https://lists.archlinux.org/pipermail/pacman-dev/2018-May/022501.html

It would be beneficial to makepkg to have this function ported
to libmakepkg and split into individual scripts.

Supersedes: https://patchwork.archlinux.org/patch/540/

Signed-off-by: Que Quotion 
---
 scripts/Makefile.am  |  6 ++
 scripts/libmakepkg/buildenv.sh.in| 55 ++
 scripts/libmakepkg/buildenv/buildflags.sh.in | 34 +++
 scripts/libmakepkg/buildenv/ccache.sh.in | 45 +++
 scripts/libmakepkg/buildenv/distcc.sh.in | 47 +++
 scripts/libmakepkg/buildenv/makeflags.sh.in  | 34 +++
 scripts/libmakepkg/buildenv/meson.build  | 20 +++
 scripts/libmakepkg/meson.build   |  1 +
 scripts/makepkg.sh.in| 60 +---
 9 files changed, 243 insertions(+), 59 deletions(-)
 create mode 100644 scripts/libmakepkg/buildenv.sh.in
 create mode 100644 scripts/libmakepkg/buildenv/buildflags.sh.in
 create mode 100644 scripts/libmakepkg/buildenv/ccache.sh.in
 create mode 100644 scripts/libmakepkg/buildenv/distcc.sh.in
 create mode 100644 scripts/libmakepkg/buildenv/makeflags.sh.in
 create mode 100644 scripts/libmakepkg/buildenv/meson.build

diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index c6b6220e..8e669f71 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -41,6 +41,7 @@ LIBRARY = \
 libmakepkgdir = $(datarootdir)/makepkg
 
 LIBMAKEPKGDIRS = \
+   buildenv \
integrity \
lint_config \
lint_package \
@@ -50,6 +51,11 @@ LIBMAKEPKGDIRS = \
util
 
 LIBMAKEPKG_IN = \
+   libmakepkg/buildenv.sh \
+   libmakepkg/buildenv/buildflags.sh \
+   libmakepkg/buildenv/ccache.sh \
+   libmakepkg/buildenv/distcc.sh \
+   libmakepkg/buildenv/makeflags.sh \
libmakepkg/integrity.sh \
libmakepkg/integrity/generate_checksum.sh \
libmakepkg/integrity/generate_signature.sh \
diff --git a/scripts/libmakepkg/buildenv.sh.in 
b/scripts/libmakepkg/buildenv.sh.in
new file mode 100644
index ..a14a3a9a
--- /dev/null
+++ b/scripts/libmakepkg/buildenv.sh.in
@@ -0,0 +1,55 @@
+#!/bin/bash
+#
+#   buildenv.sh - functions for altering the build environment before
+#   compiliation
+#
+#   Copyright (c) 2018 Pacman Development Team 
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program.  If not, see .
+#
+
+[[ -n "$LIBMAKEPKG_BUILDENV_SH" ]] && return
+LIBMAKEPKG_BUILDENV_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/option.sh"
+
+
+declare -a build_options
+
+for lib in "$LIBRARY/buildenv/"*.sh; do
+   source "$lib"
+done
+
+readonly -a build_options
+
+prepare_buildenv() {
+   msg "$(gettext "Preparing build environment...")"
+
+   for func in ${build_options[@]}; do
+   $func
+   done
+
+   if check_option "debug" "y"; then
+   DEBUG_CFLAGS+=" 
-fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}"
+   DEBUG_CXXFLAGS+=" 
-fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}"
+   CFLAGS+=" $DEBUG_CFLAGS"
+   CXXFLAGS+=" $DEBUG_CXXFLAGS"
+   fi
+
+   # ensure all necessary build variables are exported
+   export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS MAKEFLAGS CHOST
+}
diff --git a/scripts/libmakepkg/buildenv/buildflags.sh.in 
b/scripts/libmakepkg/buildenv/buildflags.sh.in
new file mode 100644
index ..fb49a85c
--- /dev/null
+++ b/scripts/libmakepkg/buildenv/buildflags.sh.in
@@ -0,0 +1,34 @@
+#!/usr/bin/bash
+#
+#   buildflags.sh - Clear user-specified buildflags if requested
+#
+#   Copyright (c) 2018 Pacman Development Team 
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program.  If