Skip to content

Commit

Permalink
Merge pull request #3 from theseus-rs/windows-utf8-support
Browse files Browse the repository at this point in the history
feat: add windows UTF-8 support
  • Loading branch information
brianheineman authored Feb 13, 2024
2 parents 47e85d4 + a70da95 commit 9964e50
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 61 deletions.
68 changes: 8 additions & 60 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ jobs:
# MacOS
#

# Update to use macos-latest-large when available: https://github.com/github/roadmap/issues/819
- id: macos-arm64
target: aarch64-apple-darwin
os: macos-14
Expand Down Expand Up @@ -210,7 +209,7 @@ jobs:
if [ -z "$version" ]; then
# Set default version for non-release builds
version="16.1.0"
version="16.2.0"
fi
root_directory="$(pwd)"
Expand Down Expand Up @@ -332,69 +331,18 @@ jobs:
# Windows
#

- name: Checkout postgresql source code (Windows)
- name: Download binaries (Windows)
if: ${{ startsWith(matrix.id, 'windows-') }}
run: |
source_directory="$ROOT_DIRECTORY/postgresql-src"
branch=$(echo "$VERSION" | awk -F. '{print "REL_"$1"_"$2}')
git clone --depth 1 --branch $branch -c advice.detachedHead=false https://git.postgresql.org/git/postgresql.git "$source_directory"
echo "SOURCE_DIRECTORY=$source_directory" | tee -a $GITHUB_ENV
- name: Install Perl (Windows)
if: ${{ startsWith(matrix.id, 'windows-') }}
uses: shogo82148/actions-setup-perl@v1

- name: Install Python (Windows)
if: ${{ startsWith(matrix.id, 'windows-') }}
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install meson and ninja (Windows)
if: ${{ startsWith(matrix.id, 'windows-') }}
run: |
pip install meson ninja
postgresql_version=$(echo "$VERSION" | awk -F. '{print $1"."$2}')
curl https://get.enterprisedb.com/postgresql/postgresql-${postgresql_version}-1-windows-x64-binaries.zip > postgresql.zip
- name: Configure MSVC (Windows)
if: ${{ startsWith(matrix.id, 'windows-') }}
uses: ilammy/[email protected]

- name: Install dependencies (Windows)
if: ${{ startsWith(matrix.id, 'windows-') }}
run: |
export CYGWIN_INSTALL_DIR="/c/cygwin"
export PACKAGES="bison,core-utils,flex,python3,python3-devel"
curl -O https://cygwin.com/setup-x86_64.exe
./setup-x86_64.exe \
--quiet-mode \
--no-desktop \
--no-shortcuts \
--local-package-dir "${CYGWIN_INSTALL_DIR}/packages" \
--packages "${PACKAGES}" \
--root "${CYGWIN_INSTALL_DIR}" \
--site https://mirrors.kernel.org/sourceware/cygwin/
echo "PATH=${PATH}:${CYGWIN_INSTALL_DIR}/bin" | tee -a $GITHUB_ENV
- name: Build (Windows)
- name: Extract binaries (Windows)
if: ${{ startsWith(matrix.id, 'windows-') }}
run: |
echo "PATH (before)=$PATH"
# Move /mingw/bin and /usr/bin to the end of PATH to build with MSVC
export PATH=$(echo $PATH | awk -F: '{print substr($0, index($0, $3))":"$1":"$2}')
echo "PATH (after)=$PATH"
cd "$SOURCE_DIRECTORY"
./configure \
--prefix "$INSTALL_DIRECTORY" \
--with-readline \
--with-template=win32 \
--without-icu
make
make install
cp "$SOURCE_DIRECTORY/COPYRIGHT" "$INSTALL_DIRECTORY"
cd "$ROOT_DIRECTORY"
unzip postgresql.zip
rm -rf pgsql/doc pgsql/pgAdmin*
mv pgsql "$INSTALL_DIRECTORY"
#
# Package
Expand Down
3 changes: 2 additions & 1 deletion scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ echo "data_directory=$data_directory"
mkdir -p "$data_directory"

cd "$test_directory/bin"
./initdb -A trust -U postgres -D "$data_directory" -E UTF-8
./initdb -A trust -U postgres -D "$data_directory" -E UTF8
./pg_ctl -w -D "$data_directory" -o "-p $port -F" start

trap "./pg_ctl -w -D $data_directory stop &>/dev/null" EXIT
Expand All @@ -19,6 +19,7 @@ echo "Running tests..."
set -x

test "$(./psql -qtAX -h localhost -p $port -U postgres -d postgres -c 'SHOW SERVER_VERSION')" = "$postgresql_version"
test "$(./psql -qtAX -h localhost -p $port -U postgres -d postgres -c 'SHOW SERVER_ENCODING')" = "UTF8"
test $(./psql -tA -h localhost -p $port -U postgres -d postgres -c "SELECT extname FROM pg_extension WHERE extname = 'plpgsql'") = "plpgsql"

set +x
Expand Down

0 comments on commit 9964e50

Please sign in to comment.