[pacman-dev] [PATCH v3 2/2] Split prepare_buildenv() to libmakepkg

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

Thank you for the assistance, and the merges.

I triple checked these patches before sending them.

I might have extremely early onset Alzheimer's. ¯\_(ツ)_/¯


Re: [pacman-dev] [PATCH v3 2/2] Split prepare_buildenv() to libmakepkg

2018-11-27 Thread Allan McRae
On 27/11/18 7:23 pm, Que Quotion wrote:
> From: Que Quotion 
> 
> This opens the door for third parties to provide libmakepkg
> extentions for the purpose of altering the build environment.
> 
> See makepkg-optimize in the AUR for examples.
> 
> Signed-off-by: Que Quotion 
> ---

OK.

Caught a couple of typos.  Also, some of these options have been around
forever...  I see some of them originating in 2007 at the latest.   I
suspect they may go back further, but just started the copyright year on
the split files from then.

Allan


[pacman-dev] [PATCH v3 2/2] Split prepare_buildenv() to libmakepkg

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

This opens the door for third parties to provide libmakepkg
extentions for the purpose of altering the build environment.

See makepkg-optimize in the AUR for examples.

Signed-off-by: Que Quotion 
---
 scripts/Makefile.am  |  6 +++
 scripts/libmakepkg/buildenv.sh.in| 47 +
 scripts/libmakepkg/buildenv/buildflags.sh.in | 35 +
 scripts/libmakepkg/buildenv/compiler.sh.in   | 55 
 scripts/libmakepkg/buildenv/debugflags.sh.in | 38 ++
 scripts/libmakepkg/buildenv/makeflags.sh.in  | 35 +
 scripts/libmakepkg/buildenv/meson.build  | 20 +++
 scripts/libmakepkg/meson.build   |  1 +
 scripts/makepkg.sh.in| 44 +---
 9 files changed, 238 insertions(+), 43 deletions(-)
 create mode 100644 scripts/libmakepkg/buildenv.sh.in
 create mode 100644 scripts/libmakepkg/buildenv/buildflags.sh.in
 create mode 100644 scripts/libmakepkg/buildenv/compiler.sh.in
 create mode 100644 scripts/libmakepkg/buildenv/debugflags.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 739aeb36..6e47c1a1 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -41,6 +41,7 @@ LIBRARY = \
 libmakepkgdir = $(datarootdir)/makepkg

 LIBMAKEPKGDIRS = \
+   buildenv \
executable \
integrity \
lint_config \
@@ -62,6 +63,11 @@ LIBMAKEPKG_IN = \
libmakepkg/executable/strip.sh \
libmakepkg/executable/sudo.sh \
libmakepkg/executable/vcs.sh \
+   libmakepkg/buildenv.sh \
+   libmakepkg/buildenv/buildflags.sh \
+   libmakepkg/buildenv/compiler.sh \
+   libmakepkg/buildenv/debugflags.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 ..3126e94c
--- /dev/null
+++ b/scripts/libmakepkg/buildenv.sh.in
@@ -0,0 +1,45 @@
+#!/bin/bash
+#
+#   buildenv.sh - functions for altering the build environment before
+#   compiliation
+#
+#   Copyright (c) 2016-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"
+
+
+declare -a buildenv_functions build_options
+
+for lib in "$LIBRARY/buildenv/"*.sh; do
+   source "$lib"
+done
+
+readonly -a buildenv_functions build_options
+
+prepare_buildenv() {
+   for func in ${buildenv_functions[@]}; do
+   $func
+   done
+
+   # 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 ..ac207fd3
--- /dev/null
+++ b/scripts/libmakepkg/buildenv/buildflags.sh.in
@@ -0,0 +1,35 @@
+#!/usr/bin/bash
+#
+#   buildflags.sh - Clear user-specified buildflags if requested
+#
+#   Copyright (c) 2016-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_BUILDFLAGS_SH" ]] && return
+LIBMAKEPKG_BUILDENV_BUILDFLAGS_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/option.sh"
+
+build_options+=('buildflags')
+buildenv_functions+=('buildenv_buildflags')
+
+buildenv_buildflags() {
+   if check_option "buildflags" "n"; then