#!/usr/bin/env bash

#
# install-gwt
#
# Copyright (C) 2025 by Posit Software, PBC
#
# Unless you have received this program directly from Posit Software pursuant
# to the terms of a commercial license agreement with Posit Software, then
# this program is licensed to you under the terms of version 3 of the
# GNU Affero General Public License. This program is distributed WITHOUT
# ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
# AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
#
#

set -e

# The version of Boost to be downloaded and built.
GWT_VERSION=2.12.2-apple-blossom

source "$(dirname "${BASH_SOURCE[0]}")/../tools/rstudio-tools.sh"
section "Installing GWT ${GWT_VERSION}"

mkdir -p gwtproject
cd gwtproject
if [ -e "gwt-${GWT_VERSION}" ]; then
	echo "GWT ${GWT_VERSION} is already installed."
	exit 0
fi

download "https://rstudio-buildtools.s3.us-east-1.amazonaws.com/gwt/gwt-${GWT_VERSION}.tar.gz"
extract "gwt-${GWT_VERSION}.tar.gz"
rm "gwt-${GWT_VERSION}.tar.gz"
touch "gwt-${GWT_VERSION}"
yay "GWT ${GWT_VERSION} installed to $(pwd)"
cd ..
