Skip to content

Commit f8c91d6

Browse files
committed
Backporting from v3
2 parents 6f49bc0 + ebc664e commit f8c91d6

File tree

10 files changed

+256
-79
lines changed

10 files changed

+256
-79
lines changed

.github/workflows/test.yml

Lines changed: 164 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -13,38 +13,90 @@ on:
1313
- 'doc/**'
1414
- 'tools/**'
1515

16-
env:
17-
BUILD_TYPE: MinSizeRel
18-
NDK_VER: 21.3.6528147
19-
NDK_ARCH: x86_64
20-
NDK_API: 29
21-
2216
jobs:
17+
define-matrix:
18+
runs-on: ubuntu-latest
19+
20+
outputs:
21+
hosts: ${{ steps.matrix.outputs.hosts }}
22+
containers: ${{ steps.matrix.outputs.containers }}
23+
24+
steps:
25+
- name: Define Matrix
26+
id: matrix
27+
shell: python
28+
run: |
29+
import json
30+
import os
31+
32+
macos_map = {
33+
'macos-14': "15.4",
34+
'macos-15': "16.2"
35+
}
36+
37+
win_paltforms = ["x64", "Win32"]
38+
win_clang_archs = ["x64", "x86"]
39+
40+
gcc_map = {
41+
11: 'ubuntu-22.04',
42+
12: 'ubuntu-latest',
43+
13: 'ubuntu-latest',
44+
14: 'ubuntu-24.04'
45+
}
46+
gcc_cont_map = {
47+
15: 'gcc:15.1'
48+
}
49+
clang_map = {
50+
13: 'ubuntu-22.04',
51+
14: 'ubuntu-22.04',
52+
15: 'ubuntu-22.04',
53+
16: 'ubuntu-22.04',
54+
17: 'ubuntu-latest',
55+
18: 'ubuntu-latest',
56+
19: 'ubuntu-latest',
57+
20: 'ubuntu-latest',
58+
21: 'ubuntu-latest'
59+
}
60+
61+
hosts = []
62+
containers=[]
63+
64+
#macOS
65+
for runon, xcode in macos_map.items():
66+
hosts.append({'os': runon, 'version': xcode, 'jobname': f'macOS - Xcode{xcode}'})
67+
68+
#windows
69+
for platform in win_paltforms:
70+
hosts.append({'os': 'windows-latest', 'platform': platform, 'nopython': platform == "Win32", 'jobname': f'Windows - {platform}'})
71+
72+
for arch in win_clang_archs:
73+
hosts.append({'os': 'windows-latest', 'arch': arch, 'compiler': 'clang-cl', 'nopython': arch == "x86", 'jobname': f'Windows - clang - {arch}'})
74+
75+
#gcc hosts
76+
for gcc, runon in gcc_map.items():
77+
hosts.append({'os': runon, 'compiler': 'gcc', 'version': gcc, 'jobname': f'Linux - GCC{gcc}'})
78+
79+
#gcc containers
80+
for gcc, container in gcc_cont_map.items():
81+
containers.append({'container': container, 'jobname': f'Linux - GCC{gcc}'})
82+
83+
84+
#clang
85+
for clang, runon in clang_map.items():
86+
hosts.append({'os': runon, 'compiler': 'clang', 'version': clang, 'jobname': f'Linux - Clang{clang}'})
87+
88+
with open(os.environ['GITHUB_OUTPUT'], 'w') as env:
89+
print('hosts=' + json.dumps(hosts), file=env)
90+
print('containers=' + json.dumps(containers), file=env)
91+
2392
desktop:
93+
needs: define-matrix
94+
name: ${{ matrix.jobname }}
2495
runs-on: ${{ matrix.os }}
2596
strategy:
2697
fail-fast: false
2798
matrix:
28-
include:
29-
- {os: macos-15, version: 16 }
30-
- {os: macos-14, version: "15.4" }
31-
32-
- os: windows-latest
33-
34-
- {os: ubuntu-22.04, compiler: gcc, version: 11 }
35-
- {os: ubuntu-22.04, compiler: gcc, version: 12 }
36-
- {os: ubuntu-22.04, compiler: gcc, version: 13 }
37-
- {os: ubuntu-24.04, compiler: gcc, version: 14 }
38-
#- {os: ubuntu-24.04, compiler: gcc, version: 15 }
39-
40-
- {os: ubuntu-22.04, compiler: clang, version: 13 }
41-
- {os: ubuntu-22.04, compiler: clang, version: 14 }
42-
- {os: ubuntu-22.04, compiler: clang, version: 15 }
43-
- {os: ubuntu-22.04, compiler: clang, version: 16 }
44-
- {os: ubuntu-latest, compiler: clang, version: 17 }
45-
- {os: ubuntu-latest, compiler: clang, version: 18 }
46-
- {os: ubuntu-latest, compiler: clang, version: 19 }
47-
- {os: ubuntu-latest, compiler: clang, version: 20 }
99+
include: ${{ fromJSON(needs.define-matrix.outputs.hosts) }}
48100

49101
steps:
50102
- name: Checkout
@@ -72,29 +124,61 @@ jobs:
72124
echo "CXX=g++-${{ matrix.version }}" >> $GITHUB_ENV
73125
fi
74126
127+
mkdir bin
128+
wget -qO- https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-linux.zip | \
129+
gunzip > bin/ninja
130+
chmod a+x bin/ninja
131+
echo PATH=`pwd`/bin:$PATH >> $GITHUB_ENV
132+
echo "CMAKE_GENERATOR=-GNinja" >> $GITHUB_ENV
75133
fi
134+
76135
if [[ '${{ matrix.os }}' == macos-* ]]; then
77136
brew install icu4c
78137
echo "DEVELOPER_DIR=/Applications/Xcode_${{ matrix.version }}.app" >> $GITHUB_ENV
79138
echo "ICU_ROOT=$(brew --cellar icu4c)/$(brew info --json icu4c | jq -r '.[0].installed[0].version')" >> $GITHUB_ENV
80139
fi
81140
141+
if [[ '${{ matrix.os }}' == windows-* ]]; then
142+
if [[ '${{ matrix.compiler }}' != '' ]]; then
143+
if [[ '${{ matrix.arch }}' == "x64" ]]; then
144+
VCPREFIX="C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\Llvm\\x64\\bin"
145+
else
146+
VCPREFIX="C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\Llvm\\bin"
147+
fi
148+
echo "CC=$VCPREFIX\\${{ matrix.compiler }}" >> $GITHUB_ENV
149+
echo "CXX=$VCPREFIX\\${{ matrix.compiler }}" >> $GITHUB_ENV
150+
echo "CMAKE_GENERATOR=Ninja" >> $GITHUB_ENV
151+
fi
152+
fi
153+
154+
CMAKE_ARGS=( )
155+
156+
if [[ '${{ matrix.platform }}' != "" ]]; then
157+
CMAKE_ARGS+=(-DCMAKE_GENERATOR_PLATFORM=${{ matrix.platform }})
158+
fi
159+
160+
if [[ ${#CMAKE_ARGS[@]} != 0 ]]; then
161+
echo "CMAKE_ARGS=${CMAKE_ARGS[@]}" >> $GITHUB_ENV
162+
fi
163+
82164
- name: Configure
83165
shell: bash
84166
run: |
85-
cmake -S . -B out -DCMAKE_BUILD_TYPE=$BUILD_TYPE
167+
cmake $CMAKE_GENERATOR -S . -B out $CMAKE_ARGS -DCMAKE_BUILD_TYPE=MinSizeRel
86168
87169
- name: Build and Test
88170
shell: bash
89-
run: cmake --build out --config $BUILD_TYPE --target run-test
171+
run: cmake --build out --config MinSizeRel --target run-test
90172

91173
container:
174+
needs: define-matrix
175+
name: ${{ matrix.jobname }}
92176
runs-on: ubuntu-latest
93177
container: ${{ matrix.container }}
94178
strategy:
95179
fail-fast: false
96180
matrix:
97-
container: [gcc:15.1]
181+
include: ${{ fromJSON(needs.define-matrix.outputs.containers) }}
98182

99183
steps:
100184
- name: Checkout
@@ -109,14 +193,46 @@ jobs:
109193
- name: Configure
110194
shell: bash
111195
run: |
112-
cmake -S . -B out -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
196+
cmake -S . -B out -DCMAKE_BUILD_TYPE=MinSizeRel
197+
198+
- name: Build and Test
199+
shell: bash
200+
run: cmake --build out --config MinSizeRel --target run-test
201+
202+
203+
big-endian:
204+
runs-on: ubuntu-latest
205+
206+
steps:
207+
- name: Checkout
208+
uses: actions/checkout@v4
209+
210+
- name: Setup
211+
run: |
212+
sudo apt-get update
213+
sudo apt-get install -y gcc-powerpc-linux-gnu g++-powerpc-linux-gnu qemu-user-binfmt
214+
215+
- name: Configure
216+
run: |
217+
export CC=powerpc-linux-gnu-gcc
218+
export CXX=powerpc-linux-gnu-g++
219+
export QEMU_LD_PREFIX=/usr/powerpc-linux-gnu/
220+
cmake -S . -B out -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_SYSTEM_PROCESSOR=powerpc
113221
114222
- name: Build and Test
115223
shell: bash
116-
run: cmake --build out --config ${{env.BUILD_TYPE}} --target run-test
224+
run: |
225+
export QEMU_LD_PREFIX=/usr/powerpc-linux-gnu/
226+
cmake --build out --config MinSizeRel --target run-test
117227
118228
android:
119229
runs-on: ubuntu-latest
230+
strategy:
231+
fail-fast: false
232+
matrix:
233+
version: [27.2.12479018]
234+
api: [29, 30]
235+
arch: [x86_64]
120236

121237
steps:
122238
- name: Checkout
@@ -135,36 +251,36 @@ jobs:
135251
path: |
136252
~/.android/avd/*
137253
~/.android/adb*
138-
key: avd-${{env.NDK_VER}}-${{env.NDK_ARCH}}-${{env.NDK_API}}
254+
key: avd-${{ matrix.version }}-${{ matrix.arch }}-${{ matrix.api }}
139255

140256
- name: Create AVD and generate snapshot for caching
141257
if: steps.avd-cache.outputs.cache-hit != 'true'
142258
uses: reactivecircus/android-emulator-runner@v2
143259
with:
144-
api-level: ${{env.NDK_API}}
145-
arch: ${{env.NDK_ARCH}}
260+
api-level: ${{ matrix.api }}
261+
arch: ${{ matrix.arch }}
146262
target: google_apis
147-
ndk: ${{env.NDK_VER}}
263+
ndk: ${{ matrix.version }}
148264
force-avd-creation: false
149-
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
265+
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-metrics
150266
disable-animations: false
151267
script: echo "Generated AVD snapshot for caching."
152268

153269
- name: Configure, Build and Test
154270
uses: reactivecircus/android-emulator-runner@v2
155271
with:
156-
api-level: ${{env.NDK_API}}
157-
arch: ${{env.NDK_ARCH}}
272+
api-level: ${{ matrix.api }}
273+
arch: ${{ matrix.arch }}
158274
target: google_apis
159-
ndk: ${{env.NDK_VER}}
160-
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
275+
ndk: ${{ matrix.version }}
276+
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-metrics
161277
disable-animations: true
162278
script: |
163279
echo "::group::Configure"
164-
cmake -S . -B out -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE -DCMAKE_TOOLCHAIN_FILE:FILEPATH=$ANDROID_SDK_ROOT/ndk/$NDK_VER/build/cmake/android.toolchain.cmake -DANDROID_ABI:STRING=$NDK_ARCH -DANDROID_PLATFORM:STRING=19 -DANDROID_STL:STRING=c++_static
280+
cmake -S . -B out -DCMAKE_BUILD_TYPE:STRING=MinSizeRel -DCMAKE_TOOLCHAIN_FILE:FILEPATH=$ANDROID_SDK_ROOT/ndk/${{ matrix.version }}/build/cmake/android.toolchain.cmake -DANDROID_ABI:STRING=${{ matrix.arch }} -DANDROID_PLATFORM:STRING=${{ matrix.version }} -DANDROID_STL:STRING=c++_static
165281
echo "::endgroup::"
166282
echo "::group::Build and Test"
167-
cmake --build out --config $BUILD_TYPE --target run-test
283+
cmake --build out --config MinSizeRel --target run-test
168284
echo "::endgroup::"
169285
170286
emscripten:
@@ -190,12 +306,12 @@ jobs:
190306
191307
- name: Configure
192308
shell: bash
193-
run: cmake -S . -B out -DCMAKE_TOOLCHAIN_FILE=$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
309+
run: cmake -S . -B out -DCMAKE_TOOLCHAIN_FILE=$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_BUILD_TYPE=MinSizeRel
194310

195311

196312
- name: Build and Test
197313
shell: bash
198-
run: cmake --build out --config ${{env.BUILD_TYPE}} --target run-test
314+
run: cmake --build out --config MinSizeRel --target run-test
199315

200316
pythons:
201317
runs-on: ubuntu-latest
@@ -219,13 +335,13 @@ jobs:
219335
- name: Configure
220336
shell: bash
221337
run: |
222-
cmake -S . -B out -DCMAKE_BUILD_TYPE=$BUILD_TYPE
338+
cmake -S . -B out -DCMAKE_BUILD_TYPE=MinSizeRel
223339
224340
- name: Build and Test
225341
shell: bash
226342
run: |
227-
cmake --build out --config $BUILD_TYPE --target test-17python test-20python
343+
cmake --build out --config MinSizeRel --target test-17python test-20python
228344
echo Running test-17python
229-
out/test/test-17python
345+
out/test/test-17python -ni -fc
230346
echo Running test-20python
231-
out/test/test-20python
347+
out/test/test-20python -ni -fc

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,17 @@ if(${Python3_Interpreter_FOUND} AND "${Python3_VERSION}" VERSION_GREATER_EQUAL "
5757
${UNICODE_GENERATED_FILES}
5858
)
5959

60+
target_sources(generate_unicode_mappings
61+
PRIVATE
62+
${UNICODE_SCRIPTS}
63+
)
64+
65+
set_source_files_properties(${UNICODE_SCRIPTS} PROPERTIES XCODE_EXPLICIT_FILE_TYPE text.script.python)
66+
6067
add_dependencies(sys_string generate_unicode_mappings)
6168

6269
endif()
6370

64-
6571
if (PROJECT_IS_TOP_LEVEL)
6672

6773
add_subdirectory(test)

lib/CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,22 @@ PUBLIC
3636
target_compile_options(${LIBNAME}
3737
PRIVATE
3838
$<$<CXX_COMPILER_ID:MSVC>:/W4;/WX>
39-
$<$<CXX_COMPILER_ID:Clang>:-Wall;-Wextra;-pedantic>
4039
$<$<CXX_COMPILER_ID:AppleClang>:-Wall;-Wextra;-pedantic>
4140
$<$<CXX_COMPILER_ID:GNU>:-Wall;-Wextra;-pedantic>
4241
)
4342

43+
if ("${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC")
44+
target_compile_options(${LIBNAME}
45+
PRIVATE
46+
$<$<CXX_COMPILER_ID:Clang>:/W4;/WX;-Wno-self-assign-overloaded;-Wno-self-move>
47+
)
48+
else()
49+
target_compile_options(${LIBNAME}
50+
PRIVATE
51+
$<$<CXX_COMPILER_ID:Clang>:-Wall;-Wextra;-pedantic;-Wno-self-assign-overloaded;-Wno-self-move>
52+
)
53+
endif()
54+
4455
target_link_libraries(${LIBNAME}
4556
PUBLIC
4657
"$<$<PLATFORM_ID:Darwin>:-framework CoreFoundation>"

lib/inc/sys_string/impl/platforms/python_any.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ namespace sysstr::util
472472
template<PyUnicode_Kind Kind>
473473
struct PyUnicodeObject_wrapper : PyUnicodeObject
474474
{
475-
#ifdef __GNUC__
475+
#if defined(__GNUC__) || defined(__clang__)
476476
#pragma GCC diagnostic push
477477
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
478478
#endif
@@ -491,7 +491,7 @@ namespace sysstr::util
491491
this->_base.utf8_length = size;
492492
}
493493
}
494-
#ifdef __GNUC__
494+
#if defined(__GNUC__) || defined(__clang__)
495495
#pragma GCC diagnostic pop
496496
#endif
497497

0 commit comments

Comments
 (0)