-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathbuild
More file actions
executable file
·90 lines (81 loc) · 3.45 KB
/
Copy pathbuild
File metadata and controls
executable file
·90 lines (81 loc) · 3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env bash
# Portions Copyright 2021-2025 Technology Concepts & Design, Inc.
#
# All rights reserved.
#
# Use of this source code is governed by the PostgreSQL license that can be
# found in the LICENSE.md file.
set -xe
if [ -z "$STD_TARGETS" ]; then
# if none specified, always build for these two targets
if [ `uname` == "Darwin" ]; then
STD_TARGETS="x86_64-apple-darwin-postgres aarch64-apple-darwin-postgres"
else
STD_TARGETS="x86_64-postgres-linux-gnu aarch64-postgres-linux-gnu"
fi
fi
# and depending on the platform we're building on, we need to set a linker flag for the other
# this'll get hairy when we support more platforms and we should port this script to Rust
if [ `uname` == "Darwin" ]; then
if [ `uname -m` == "arm64" ]; then
if [[ -z "$CARGO_TARGET_AARCH64_APPLE_DARWIN_LINKER" ]] && [[ -z "$CARGO_TARGET_AARCH64_APPLE_DARWIN_POSTGRES_LINKER" ]]; then
export CARGO_TARGET_AARCH64_APPLE_DARWIN_LINKER=cc
export CARGO_TARGET_AARCH64_APPLE_DARWIN_POSTGRES_LINKER=cc
fi
elif [ `uname -m` == "x86_64" ]; then
if [[ -z "$CARGO_TARGET_X86_64_APPLE_DARWIN_LINKER" ]] && [[ -z "$CARGO_TARGET_X86_64_APPLE_DARWIN_POSTGRES_LINKER" ]]; then
export CARGO_TARGET_X86_64_APPLE_DARWIN_LINKER=cc
export CARGO_TARGET_X86_64_APPLE_DARWIN_POSTGRES_LINKER=cc
fi
else
echo unsupported macos build platform: $(uname -m)
exit 1
fi
else
if [ `uname -m` == "x86_64" ]; then
if [[ -z "$CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER" ]] && [[ -z "$CARGO_TARGET_AARCH64_POSTGRES_LINUX_GNU_LINKER" ]]; then
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
export CARGO_TARGET_AARCH64_POSTGRES_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
fi
elif [ `uname -m` == "aarch64" ]; then
if [[ -z "$CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER" ]] && [[ -z "$CARGO_TARGET_X86_64_POSTGRES_LINUX_GNU_LINKER" ]]; then
export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=x86_64-linux-gnu-gcc
export CARGO_TARGET_X86_64_POSTGRES_LINUX_GNU_LINKER=x86_64-linux-gnu-gcc
fi
else
echo unsupported build platform: $(uname -m)
exit 1
fi
fi
# Make sure the tip of pgrx's develop branch is used,
# until a release that has all the necessary features is cut.
cargo update -p pgrx
cargo fetch
if [ "$CI" != true ]; then
# Attempt to get pgrx version from cargo tree. Looking for a pattern such as "pgrx v0.10.0"
PGRX_VERSION=$(cargo tree --depth 1 --package plrust | grep -E "\s*pgrx\s+v[0-9]+\.[0-9]+\.[0-9]+" | head -n 1 | cut -f2- -dv)
if [ -z "$PGRX_VERSION" ]; then
echo "Could not determine pgrx version from 'cargo tree'!"
exit 1
else
echo "Installing cargo-pgrx version $PGRX_VERSION"
cargo install cargo-pgrx \
--version "$PGRX_VERSION" \
--locked # use the Cargo.lock in the pgrx repo
fi
fi
# Don't need to run cargo pgrx init: user might already have set it up,
# and doing so risks clobbering their configuration.
# If they get an error, it's fairly self-explanatory.
(
if cd postgrestd; then
git pull
git submodule update --init --recursive
else
git clone https://github.com/tcdi/postgrestd.git --branch "rust-1.72.0" --recurse-submodules
cd ./postgrestd
fi
rm -f rust-toolchain.toml
STD_TARGETS="$STD_TARGETS" ./run clean
STD_TARGETS="$STD_TARGETS" ./run install
)