From 0c168178e04cbdf5dc9e4955d03422c4c9f4ca1e Mon Sep 17 00:00:00 2001 From: Ryan Fox Date: Sat, 7 Nov 2020 02:10:34 +0000 Subject: [PATCH] Add projucer.eclass This eclass provides functions to resave Projucer projects. --- eclass/projucer.eclass | 73 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 eclass/projucer.eclass diff --git a/eclass/projucer.eclass b/eclass/projucer.eclass new file mode 100644 index 0000000..9c8f4ed --- /dev/null +++ b/eclass/projucer.eclass @@ -0,0 +1,73 @@ +# Copyright 2020 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# @ECLASS: projucer.eclass +# @MAINTAINER: +# Ryan Fox +# @AUTHOR: +# Ryan Fox +# @BLURB: Resave Projucer projects +# @DESCRIPTION: +# Provides a function to resave Projucer projects, and automatically sets the +# paths for JUCE and it's modules. + +# @ECLASS-VARIABLE: JUCE_VERSION +# @REQUIRED +# @DEFAULT_UNSET +# @DESCRIPTION: +# Choose a specific version of JUCE to use. A project may only build with older +# versions of JUCE. +# +# Example: +# @CODE +# JUCE_VERSION=6.0.4 +# @CODE + +# @ECLASS-VARIABLE: PROJUCER_VERSION +# @DESCRIPTION: +# Choose a specific version of JUCE to use. A project may only build with older +# versions of JUCE. +: ${PROJUCER_VERSION="${JUCE_VERSION}"} + +# @ECLASS-VARIABLE: JUCE_PATH +# @DESCRIPTION: +# The path to JUCE +: ${JUCE_PATH:="/opt/juce-${JUCE_VERSION}"} + +# @ECLASS-VARIABLE: JUCE_MODULES_PATH +# @DESCRIPTION: +# The path to JUCE modules +: ${JUCE_MODULES_PATH:="${JUCE_PATH}/modules"} + +# @ECLASS-VARIABLE: PROJUCER +# @DESCRIPTION: +# Provided in case someone wants to use a different binary +: ${PROJUCER:="/opt/juce-${PROJUCER_VERSION}/Projucer"} + +# @ECLASS-VARIABLE: PROJUCER_CONF +# @INTERNAL +# @DESCRIPTION: +# Config file affected by the eclass. Projucer itself doesn't care +: ${PROJUCER_CONF:="${HOME}/.config/Projucer/Projucer.settings"} + +# @FUNCTION: _projucer_update_paths +# @USAGE: +# @INTERNAL +# @DESCRIPTION: +# Sets the proper paths in the project and Projucer +_projucer_update_paths() { + # Update project + sed -i "s/path=\".*\"\/>/path=\"${JUCE_MODULES_PATH//\//\\/}\"\/>/g" "${1}" + # Generate config (This is fine since ebuilds have a temporary homedir) + ${PROJUCER} --help > /dev/null + sed -i "s///g" "${PROJUCER_CONF}" +} + +# @FUNCTION: projucer_resave +# @USAGE: +# @DESCRIPTION: +# Resave all project files and resources +projucer_resave() { + _projucer_update_paths "${1}" + ${PROJUCER} --resave "${1}" +}