Skip to content

Commit

Permalink
Simplify install steps (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlocati authored Oct 4, 2024
1 parent b132eec commit b1ad4a5
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 112 deletions.
107 changes: 46 additions & 61 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ on:
- test
- production
default: test

env:
CLDR_VERSION: 45
ICONV_VERSION: 1.17
Expand All @@ -33,7 +33,7 @@ env:

jobs:
exe:
name: Executables ${{ matrix.bits}}-bit ${{ matrix.link }}
name: ${{ matrix.bits}}-bit ${{ matrix.link }} executables
runs-on: windows-2022
strategy:
matrix:
Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:
name: Set variables
id: vars
shell: pwsh
run: ./build-exe/vars.ps1 -Bits ${{ matrix.bits }} -Link ${{ matrix.link }} -Sign '${{ github.event.inputs.sign }}'
run: ./build-exe/vars.ps1 -Bits ${{ matrix.bits }} -Link ${{ matrix.link }} -InstalledPath installed -Sign '${{ github.event.inputs.sign }}'
-
name: Download Cygwin installer
shell: pwsh
Expand All @@ -92,25 +92,27 @@ jobs:
-
name: Setup Cygwin environment
run: |
cd -- "$(/bin/cygpath -au '${{ github.workspace }}')"
/bin/printf 'Working directory: %s\n' "$(/bin/pwd)"
/bin/mkdir -p src/downloads
/bin/mkdir installed
/bin/mkdir files-unsigned
/bin/mkdir files-signed
/bin/mkdir installer-unsigned
/bin/mkdir installer-signed
/bin/perl -pe 's/\r\n|\n|\r/\r\n/g' < build-exe/license-for-distribution.txt > files-unsigned/license.txt
INSTALLED_PATH="$(/bin/cygpath -au ./installed)"
/bin/echo "INSTALLED_PATH=$INSTALLED_PATH" >> $GITHUB_ENV
/bin/mkdir -p "$HOME"
/bin/printf '\nPATH=%s/bin:${{ steps.vars.outputs.cygwin-path }}\nexport PATH\n' "$INSTALLED_PATH" >>$HOME/.bash_profile
-
name: Dump Cygwin PATH
PATH='${{ steps.vars.outputs.cygwin-path }}'
cd -- "$(cygpath -ua '${{ github.workspace }}')"
mkdir -p src/downloads
mkdir -p installed/bin
mkdir -p installed/include
mkdir -p installed/lib
mkdir files-unsigned
mkdir files-signed
mkdir installer-unsigned
mkdir installer-signed
cp build-exe/license-for-distribution.txt installed/license.txt
mkdir -p "$HOME"
printf '\nPATH=${{ steps.vars.outputs.cygwin-path }}\nexport PATH\n' >>$HOME/.bash_profile
-
name: Dump Cygwin environment
run: |
printf 'Current working directory: %s\n' "$(pwd)"
echo 'PATH contains:'
IFS=:
for p in $PATH; do
printf '%s\n' "$p"
printf -- '- %s\n' "$p"
done
-
name: Download CLDR
Expand All @@ -127,10 +129,10 @@ jobs:
-
name: Extract CLDR
if: env.BUILD_ONLY_ICONV != 'y'
working-directory: installed
run: |
unzip -p ../src/downloads/cldr-$CLDR_VERSION.zip LICENSE >cldr-license.txt
unzip -p ../src/downloads/cldr-$CLDR_VERSION.zip common/supplemental/plurals.xml >cldr-plurals.xml
unzip -p src/downloads/cldr-$CLDR_VERSION.zip LICENSE > installed/license-cldr.txt
mkdir -p installed/lib/gettext/common/supplemental
unzip -p src/downloads/cldr-$CLDR_VERSION.zip common/supplemental/plurals.xml >installed/lib/gettext/common/supplemental/plurals.xml
-
name: Download iconv
working-directory: src\downloads
Expand All @@ -144,21 +146,17 @@ jobs:
}
-
name: Extract iconv
working-directory: src
run: tar x -z -f downloads/libiconv-$ICONV_VERSION.tar.gz
run: |
tar x -C src -z -f src/downloads/libiconv-$ICONV_VERSION.tar.gz
cp src/libiconv-$ICONV_VERSION/COPYING installed/license-iconv.txt
-
name: Configure iconv (1st time)
id: iconv-configure
working-directory: src\libiconv-${{ env.ICONV_VERSION }}
run: |
mkdir build
cd build
../configure \
CPPFLAGS='${{ steps.vars.outputs.cpp-flags }}' \
LDFLAGS='${{ steps.vars.outputs.ld-flags }}' \
CXXFLAGS='${{ steps.vars.outputs.cxx-flags }}' \
${{ steps.vars.outputs.configure-args }} \
--prefix=$INSTALLED_PATH
../configure ${{ steps.vars.outputs.configure-args }}
-
name: Compile iconv (1st time)
working-directory: src\libiconv-${{ env.ICONV_VERSION }}\build
Expand All @@ -167,11 +165,11 @@ jobs:
name: Check iconv (1st time)
if: env.BUILD_ONLY_ICONV != 'y'
working-directory: src\libiconv-${{ env.ICONV_VERSION }}\build
run: make check --jobs=$(nproc)
run: make --jobs=$(nproc) check
-
name: Install iconv (1st time)
working-directory: src\libiconv-${{ env.ICONV_VERSION }}\build
run: make install && cp ../COPYING $INSTALLED_PATH/iconv-license.txt
run: make --jobs=$(nproc) install-strip
-
name: Download gettext
if: env.BUILD_ONLY_ICONV != 'y'
Expand All @@ -187,8 +185,9 @@ jobs:
-
name: Extract gettext
if: env.BUILD_ONLY_ICONV != 'y'
working-directory: src
run: tar x -z -f downloads/gettext-$GETTEXT_VERSION.tar.gz
run: |
tar x -C src -z -f src/downloads/gettext-$GETTEXT_VERSION.tar.gz
cp src/gettext-$GETTEXT_VERSION/COPYING installed/license-gettext.txt
-
name: Configure gettext
if: env.BUILD_ONLY_ICONV != 'y'
Expand All @@ -197,11 +196,7 @@ jobs:
run: |
mkdir build
cd build
../configure \
CPPFLAGS="-I$INSTALLED_PATH/include ${{ steps.vars.outputs.cpp-flags }}" \
LDFLAGS="-L$INSTALLED_PATH/lib ${{ steps.vars.outputs.ld-flags }}" \
CXXFLAGS='${{ steps.vars.outputs.cxx-flags }}' \
${{ steps.vars.outputs.configure-args }} \
../configure ${{ steps.vars.outputs.configure-args }} \
--disable-java \
--disable-native-java \
--disable-csharp \
Expand All @@ -210,18 +205,12 @@ jobs:
--without-emacs \
--with-included-libxml \
--without-bzip2 \
--without-xz \
--prefix=$INSTALLED_PATH
--without-xz
-
name: Ignore gettext C tests
if: env.BUILD_ONLY_ICONV != 'y' && steps.vars.outputs.gettext-ignore-tests-c
working-directory: src\gettext-${{ env.GETTEXT_VERSION }}
run: for f in ${{ steps.vars.outputs.gettext-ignore-tests-c }}; do echo 'int main() { return 0; }' >$f; done
-
name: Install gettext license
if: env.BUILD_ONLY_ICONV != 'y'
working-directory: src\gettext-${{ env.GETTEXT_VERSION }}
run: cp COPYING $INSTALLED_PATH/gettext-license.txt
-
name: Compile gettext/gnulib-local
if: env.BUILD_ONLY_ICONV != 'y'
Expand All @@ -236,7 +225,7 @@ jobs:
name: Install gettext/gnulib-local
if: env.BUILD_ONLY_ICONV != 'y'
working-directory: src\gettext-${{ env.GETTEXT_VERSION }}\build\gnulib-local
run: make --jobs=$(nproc) install
run: make --jobs=$(nproc) install-strip
-
name: Compile gettext/gettext-runtime
if: env.BUILD_ONLY_ICONV != 'y'
Expand All @@ -251,7 +240,7 @@ jobs:
name: Install gettext/gettext-runtime
if: env.BUILD_ONLY_ICONV != 'y'
working-directory: src\gettext-${{ env.GETTEXT_VERSION }}\build\gettext-runtime
run: make --jobs=$(nproc) install
run: make --jobs=$(nproc) install-strip
-
name: Compile gettext/libtextstyle
if: env.BUILD_ONLY_ICONV != 'y'
Expand All @@ -266,7 +255,7 @@ jobs:
name: Install gettext/libtextstyle
if: env.BUILD_ONLY_ICONV != 'y'
working-directory: src\gettext-${{ env.GETTEXT_VERSION }}\build\libtextstyle
run: make --jobs=$(nproc) install
run: make --jobs=$(nproc) install-strip
-
name: Compile gettext/gettext-tools
if: env.BUILD_ONLY_ICONV != 'y'
Expand All @@ -281,7 +270,7 @@ jobs:
name: Install gettext/gettext-tools
if: env.BUILD_ONLY_ICONV != 'y'
working-directory: src\gettext-${{ env.GETTEXT_VERSION }}\build\gettext-tools
run: make --jobs=$(nproc) install
run: make --jobs=$(nproc) install-strip
-
# We need to rebuild iconv because it depends on gettext's libintl in order to be localizable
name: Configure iconv (2nd time)
Expand All @@ -291,12 +280,8 @@ jobs:
rm -rf build
mkdir build
cd build
../configure \
CPPFLAGS='${{ steps.vars.outputs.cpp-flags }}' \
LDFLAGS='${{ steps.vars.outputs.ld-flags }}' \
${{ steps.vars.outputs.configure-args }} \
--enable-extra-encodings \
--prefix=$INSTALLED_PATH
../configure ${{ steps.vars.outputs.configure-args }} \
--enable-extra-encodings
-
name: Compile iconv (2nd time)
if: env.BUILD_ONLY_ICONV != 'y'
Expand All @@ -306,12 +291,12 @@ jobs:
name: Check iconv (2nd time)
if: env.BUILD_ONLY_ICONV != 'y'
working-directory: src\libiconv-${{ env.ICONV_VERSION }}\build
run: make check --jobs=$(nproc)
run: make --jobs=$(nproc) check
-
name: Install iconv (2nd time)
if: env.BUILD_ONLY_ICONV != 'y'
working-directory: src\libiconv-${{ env.ICONV_VERSION }}\build
run: make install
run: make --jobs=$(nproc) install-strip
-
name: Prepare build log
id: prepare-build-log
Expand All @@ -330,7 +315,7 @@ jobs:
ls -al build-log
-
name: Copy built assets
run: ./build-exe/create-output.sh installed files-unsigned '${{ steps.vars.outputs.mingw-host }}'
run: ./build-exe/create-output.sh installed files-unsigned ${{ steps.vars.outputs.mingw-host }}-strip
-
name: Delete install directory
run: rm -rf installed
Expand All @@ -341,7 +326,7 @@ jobs:
./build-exe/process-dependencies.ps1
-Bits ${{ matrix.bits }}
-Link ${{ matrix.link }}
-OutputPath files-unsigned
-Path files-unsigned
-MinGWPath C:\cygwin\usr\${{ steps.vars.outputs.mingw-host }}
-
name: Check bitness
Expand Down Expand Up @@ -476,7 +461,7 @@ jobs:
wait-for-completion: true
output-artifact-directory: installer-signed
-
name: Check signatures
name: Check signature
if: steps.vars.outputs.signpath-signing-policy
shell: pwsh
run: >
Expand Down
4 changes: 2 additions & 2 deletions build-exe/create-installer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ function New-IssFile()
"#define MyIs64bit false" | Out-File -FilePath $temporaryFile -Append -Encoding utf8
}
"#define MyGettextVer `"$env:GETTEXT_VERSION`"" | Out-File -FilePath $temporaryFile -Append -Encoding utf8
"#define MyIconvVer `"$env:ICONV_VERSION`"" | Out-File -FilePath $temporaryFile -Append -Encoding utf8
"#define MyCompiledFolderPath `"$SourceDirectory`"" | Out-File -FilePath $temporaryFile -Append -Encoding utf8
"#define MyIconvVer `"$env:ICONV_VERSION`"" | Out-File -FilePath $temporaryFile -Append -Encoding utf8
"#define MyCompiledFolderPath `"$SourceDirectory`"" | Out-File -FilePath $temporaryFile -Append -Encoding utf8
Get-Content -LiteralPath $templateFile -Encoding utf8 | Out-File -FilePath $temporaryFile -Append -Encoding utf8
$deleteTemporaryFile = $false
$temporaryFile
Expand Down
46 changes: 31 additions & 15 deletions build-exe/create-output.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
# "make install" calls
#
# Arguments:
# $1: the directory created by the "make install calls
# $1: the directory containing the files created by the "make install-strip" calls
# $2: the directory where the files should be copied to
# $3: the MinGW-w64 host (i686-w64-mingw32, x86_64-w64-mingw32)
# $3: the strip command
#

set -o errexit
Expand All @@ -18,7 +18,7 @@ set -o pipefail
#
# Arguments:
# $1: the full path to the source file
# $2: special type (binary, text, doc). If omitted, no special operation will be performed
# $2: special type (binary, text, doc). If omitted, no special handling will be performed
# $3: the relative path of the destination file (if omitted we'll calculate it)
#
copyFile () {
Expand All @@ -30,22 +30,38 @@ copyFile () {
fi
local destinationPath="$DESTINATION/$relativePath"
if [ "$fileType" = doc ]; then
local destinationPath2
destinationPath2="${destinationPath%.1.html}"
if test "$destinationPath" != "$destinationPath2"; then
local destinationPath2="${destinationPath%.1.html}"
if [ "$destinationPath" != "$destinationPath2" ]; then
destinationPath="$destinationPath2.html"
fi
fi
mkdir -p "$(dirname "$destinationPath")"
case "$fileType" in
binary)
"$MINGW_HOST-strip" --strip-unneeded "$sourcePath" -o "$destinationPath"
printf 'Copying binary file %s... ' "$relativePath"
local bytesPre=$(stat -c%s "$sourcePath")
"$STRIP_COMMAND" --strip-unneeded "$sourcePath" -o "$destinationPath"
local bytesPre=$(stat -c%s "$destinationPath")
bytesSaved=$((bytesPre - bytesPre))
if [ $bytesSaved -eq 0 ]; then
printf 'done (no bytes saved out of %s)\n' $bytesPre
else
printf 'done (%s bytes saved out of %s)\n' $bytesSaved $bytesPre
fi
;;
text)
perl -pe 's/\r\n|\n|\r/\r\n/g' <"$sourcePath" >"$destinationPath"
printf 'Copying text file %s (converting line endings)... ' "$relativePath"
local unix2dosOutput
if ! unix2dosOutput="$(unix2dos -n "$sourcePath" "$destinationPath" 2>&1)"; then
printf 'unix2dos failed!\n%s\n' "$unix2dosOutput"
return 1
fi
printf 'done.\n'
;;
* )
printf 'Copying file %s... ' "$relativePath"
cp "$sourcePath" "$destinationPath"
printf 'done.\n'
;;
esac
}
Expand All @@ -70,15 +86,17 @@ if [ ! -d "$DESTINATION" ]; then
printf 'Destination directory (%s) not found\n' "$DESTINATION"
exit 1
fi
MINGW_HOST="${3:-}"
if [ -z "$MINGW_HOST" ]; then
echo 'Missing 3nd argument (MinGW-w64 host)'
STRIP_COMMAND="${3:-}"
if [ -z "$STRIP_COMMAND" ]; then
echo 'Missing 3rd argument (strip command)'
exit 1
fi

mkdir -p "$DESTINATION/share/gettext"

copyFile "$SOURCE/iconv-license.txt" text
for i in $(find "$SOURCE" -maxdepth 1 -type f -name license*.txt); do
copyFile "$i" text
done
for i in $(find "$SOURCE/bin/" -name '*.exe' -o -name '*.dll'); do
copyFile "$i" binary
done
Expand All @@ -89,12 +107,10 @@ for i in $(find "$SOURCE/share/doc" -maxdepth 2 -type f ! -iname '*.3.html' ! -i
copyFile "$i" doc
done
if [ "${BUILD_ONLY_ICONV:-}" != y ]; then
copyFile "$SOURCE/cldr-license.txt" text
copyFile "$SOURCE/gettext-license.txt" text
copyFile "$SOURCE/lib/gettext/cldr-plurals.exe" binary bin/cldr-plurals.exe
cp -r "$SOURCE/share/locale" "$DESTINATION/share/"
cp -r "$SOURCE/share/gettext/styles" "$DESTINATION/share/gettext/"
cp -r $SOURCE/share/gettext-*/its "$DESTINATION/share/gettext"
copyFile "$SOURCE/share/gettext/msgunfmt.tcl"
copyFile "$SOURCE/cldr-plurals.xml" '' lib/gettext/common/supplemental/plurals.xml
copyFile "$SOURCE/lib/gettext/common/supplemental/plurals.xml"
fi
8 changes: 4 additions & 4 deletions build-exe/license-for-distribution.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


For the Unicode CLDR files: see cldr-license.txt
For the gettext files: see gettext-license.txt
For the iconv files: see iconv-license.txt
For the MinGW-w64 DLL files (if any): see mingw-w64-license.txt
For the Unicode CLDR files: see license-cldr.txt
For the iconv files: see license-iconv.txt
For the gettext files: see license-gettext.txt
For the MinGW-w64 DLL files (if any): see license-mingw-w64.txt
Loading

0 comments on commit b1ad4a5

Please sign in to comment.