Skip to content

Commit ca0dd70

Browse files
[CDRIVER-4637] A config settings command (mongodb#1289)
* New config settings code and defaults. Almost all setting values have remained the same, and most setting handling logic has remained unmodified, but this will serve as a basis for better configuration settings handling in the future tasks for CDRIVER-4637. * Aside: message() cleanup Using `message()` without a mode argument will write the message as a NOTICE to stderr. We want to use STATUS as the default, which goes to stdout. Systems which colorize stderr output would seemingly-randomly color certain lines where the mode argument was missing. * Use new CMake in more build tasks Several build tasks still relied on older find-cmake logic. With the new CMake changes, a more recent CMake version is required. These tasks and scripts have been updated to use the same logic to find the same CMake version as is used in the main build tasks. * Don't use Batch scripts to compile for MinGW Batch scripting is fraught with peril and will almost never do what one expects. Any other scripting language is preferable. Since we have Bash available and the tools to properly convert paths, just use Bash to do this work. * Redundant ENABLE_SHM_COUNTERS logic * Update the "Ask for Help" section * No longer applicable SASL checks * Remove ENABLE_BSON, as its purpose is confusing. - ENABLE_BSON=ON did the same as ENABLE_BSON=AUTO - There is no "ENABLE_BSON=OFF" since then there would be nothing to build. - USE_SYSTEM_LIBBSON=ON replaces ENABLE_BSON=SYSTEM. - To alleviate downstreams from needing to check versions before configuring, allow ENABLE_BSON=SYSTEM to be specified if USE_SYSTEM_LIBBSON=ON is also set, thus allowing one option pair to build both before and after this revision. - If ENABLE_BSON=SYSTEM is set but USE_SYSTEM_LIBBSON is not TRUE, then downstream will want to update their scripts to build with the new option rather than miscompile without being noticed. * New toolchain for the build * Don't inject the toolchain SSL into LD_LIBRARY_PATH The toolchain CMake is incompatible with OpenSSL 1.1.0, so having it on the library path breaks CMake. We don't need to modify LD_LIBRARY_PATH to cause CMake to use the OpenSSL that we want. It is sufficient to prepend the SSL root to the CMAKE_PREFIX_PATH. * Coverage link options are usage requirements * More Bash, less Sh * Don't depend on distro_id
1 parent e0e9395 commit ca0dd70

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed

platform.sh

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,111 @@ declare -r IS_WSL=$_is_wsl
5656
declare -r IS_BSD=$_is_bsd
5757
declare -r OS_FAMILY=$_os_family
5858

59+
_is_redhat_based=false
60+
_is_debian_based=false
61+
if $IS_LINUX; then
62+
if is-file /etc/redhat-release; then
63+
_is_redhat_based=true
64+
_dist_version=$(sed 's|.*release \([^ ]\+\).*|\1|' < /etc/redhat-release)
65+
elif is-file /etc/debian_version; then
66+
_is_debian_based=true
67+
_dist_version=$(grep VERSION_ID /etc/os-release | sed 's|VERSION_ID="\(.*\)"|\1|')
68+
elif is-file /etc/alpine-release; then
69+
_is_alpine=true
70+
_dist_version=$(cat /etc/alpine-release)
71+
fi
72+
_dist_version=${_dist_version:-0}
73+
_major_version=${_dist_version/.*/}
74+
declare -r DIST_VERSION=$_dist_version
75+
declare -r DIST_MAJOR_VERSION=$_major_version
76+
77+
if is-file /etc/redhat-release; then
78+
_dist_id=$(cut -d ' ' -f1 < /etc/redhat-release)
79+
declare -r DIST_ID=${_dist_id}
80+
elif is-file /etc/os-release; then
81+
_dist_id=$(grep '^ID=' /etc/os-release | sed 's|ID=||')
82+
declare -r DIST_ID=${_dist_id}
83+
fi
84+
elif $IS_DARWIN; then
85+
_version=$(sw_vers | grep ProductVersion | sed 's|ProductVersion: \(.*\)|\1|')
86+
_major_version=${_version/.*/}
87+
declare -r MACOS_VERSION=${_version}
88+
declare -r MACOS_MAJOR_VERSION=${_major_version}
89+
fi
90+
91+
declare -r IS_REDHAT_BASED=${_is_redhat_based}
92+
declare -r IS_DEBIAN_BASED=${_is_debian_based}
93+
94+
_is_x86=false
95+
_is_x64=false
96+
_is_arm=false
97+
_is_ppc=false
98+
_is_zseries=false
99+
_archname=""
100+
case "$HOSTTYPE" in
101+
x86_64)
102+
_is_x86=true
103+
_is_x64=true
104+
_archname=x64
105+
;;
106+
x86*)
107+
_is_x86=true
108+
_archname="x86"
109+
;;
110+
aarch64|arm64)
111+
_is_arm=true
112+
_archname="arm64"
113+
;;
114+
powerpc*)
115+
_is_ppc=true
116+
_archname="ppc"
117+
;;
118+
s390x)
119+
_is_zseries=true
120+
_archname="s390x"
121+
;;
122+
*)
123+
log "Unknown host architecture in HOSTTYPE '$HOSTTYPE'";;
124+
esac
125+
declare -r IS_X86=$_is_x86
126+
declare -r IS_X64=$_is_x64
127+
declare -r IS_ARM=$_is_arm
128+
declare -r IS_POWERPC=$_is_ppc
129+
declare -r IS_ZSERIES=$_is_zseries
130+
declare -r ARCHNAME=$_archname
131+
132+
if is-set DIST_ID; then
133+
_os_shortname="${DIST_ID}${DIST_MAJOR_VERSION}"
134+
elif $IS_WINDOWS; then
135+
_os_shortname=win
136+
elif $IS_DARWIN; then
137+
_os_shortname=macos$MACOS_VERSION
138+
else
139+
_os_shortname=unknown
140+
fi
141+
declare OS_SHORTNAME=$_os_shortname
142+
59143
if is-main; then
60144
log "Operating system detection:"
145+
log " • OS_SHORTNAME: $OS_SHORTNAME"
61146
log " • OS_FAMILY: $OS_FAMILY"
62147
log " • IS_WINDOWS: $IS_WINDOWS"
63148
log " • IS_DARWIN: $IS_DARWIN"
64149
log " • IS_LINUX: $IS_LINUX"
65150
log " • IS_BSD: $IS_BSD"
66151
log " • IS_WSL: $IS_WSL"
67152
log " • IS_UNIX_LIKE: $IS_UNIX_LIKE"
153+
log " • IS_REDHAT_BASED: $IS_REDHAT_BASED"
154+
log " • IS_DEBIAN_BASED: $IS_DEBIAN_BASED"
155+
log " • DIST_ID: ${DIST_ID:-⟨unset⟩}"
156+
log " • DIST_VERSION: ${DIST_VERSION:-⟨unset⟩}"
157+
log " • DIST_MAJOR_VERSION: ${DIST_MAJOR_VERSION:-⟨unset⟩}"
158+
log " • MACOS_VERSION: ${MACOS_VERSION:-⟨unset⟩}"
159+
log " • MACOS_MAJOR_VERSION: ${MACOS_MAJOR_VERSION:-⟨unset⟩}"
160+
log " • IS_X86: $IS_X86"
161+
log " • IS_X64: $IS_X64"
162+
log " • IS_ARM: $IS_ARM"
163+
log " • IS_POWERPC: $IS_POWERPC"
164+
log " • IS_ZSERIES: $IS_ZSERIES"
165+
log " • ARCHNAME: $ARCHNAME"
68166
fi

0 commit comments

Comments
 (0)