Skip to content

Commit 031e770

Browse files
committed
Backporting relevant changes from v3
2 parents 83ca112 + 9b2a9f8 commit 031e770

File tree

9 files changed

+165
-46
lines changed

9 files changed

+165
-46
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.h linguist-language=cpp
2+
unicode/data/* -linguist-detectable
3+
doc/* linguist-documentation

.github/workflows/test.yml

Lines changed: 93 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414
- 'tools/**'
1515

1616
env:
17-
BUILD_TYPE: Release
17+
BUILD_TYPE: MinSizeRel
1818
NDK_VER: 21.3.6528147
1919
NDK_ARCH: x86_64
2020
NDK_API: 29
@@ -26,19 +26,25 @@ jobs:
2626
fail-fast: false
2727
matrix:
2828
include:
29-
- os: macos-latest
29+
- {os: macos-15, version: 16 }
30+
- {os: macos-14, version: "15.4" }
31+
3032
- os: windows-latest
33+
3134
- {os: ubuntu-22.04, compiler: gcc, version: 11 }
3235
- {os: ubuntu-22.04, compiler: gcc, version: 12 }
3336
- {os: ubuntu-22.04, compiler: gcc, version: 13 }
3437
- {os: ubuntu-24.04, compiler: gcc, version: 14 }
35-
38+
#- {os: ubuntu-24.04, compiler: gcc, version: 15 }
39+
3640
- {os: ubuntu-22.04, compiler: clang, version: 13 }
3741
- {os: ubuntu-22.04, compiler: clang, version: 14 }
3842
- {os: ubuntu-22.04, compiler: clang, version: 15 }
3943
- {os: ubuntu-22.04, compiler: clang, version: 16 }
40-
- {os: ubuntu-24.04, compiler: clang, version: 17 }
41-
- {os: ubuntu-24.04, compiler: clang, version: 18 }
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 }
4248

4349
steps:
4450
- name: Checkout
@@ -47,23 +53,30 @@ jobs:
4753
- name: System Setup
4854
shell: bash
4955
run: |
50-
if [[ '${{ matrix.os }}' == 'ubuntu-latest' ]]; then
56+
if [[ '${{ matrix.os }}' == ubuntu-* ]]; then
5157
if [[ '${{ matrix.compiler }}' == 'clang' ]]; then
5258
wget https://apt.llvm.org/llvm.sh
5359
chmod u+x llvm.sh
54-
sudo ./llvm.sh ${{ matrix.version }}
60+
sudo ./llvm.sh ${{ matrix.version }}
5561
sudo apt-get install -y clang-tools-${{ matrix.version }} libc++-${{ matrix.version }}-dev libc++abi-${{ matrix.version }}-dev
5662
echo "CC=clang-${{ matrix.version }}" >> $GITHUB_ENV
5763
echo "CXX=clang++-${{ matrix.version }}" >> $GITHUB_ENV
5864
echo "CXXFLAGS=-stdlib=libc++" >> $GITHUB_ENV
5965
fi
6066
6167
if [[ '${{ matrix.compiler }}' == 'gcc' ]]; then
68+
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
6269
sudo apt-get update
6370
sudo apt-get install -y gcc-${{ matrix.version }} g++-${{ matrix.version }}
6471
echo "CC=gcc-${{ matrix.version }}" >> $GITHUB_ENV
6572
echo "CXX=g++-${{ matrix.version }}" >> $GITHUB_ENV
6673
fi
74+
75+
fi
76+
if [[ '${{ matrix.os }}' == macos-* ]]; then
77+
brew install icu4c
78+
echo "DEVELOPER_DIR=/Applications/Xcode_${{ matrix.version }}.app" >> $GITHUB_ENV
79+
echo "ICU_ROOT=$(brew --cellar icu4c)/$(brew info --json icu4c | jq -r '.[0].installed[0].version')" >> $GITHUB_ENV
6780
fi
6881
6982
- name: Configure
@@ -75,6 +88,33 @@ jobs:
7588
shell: bash
7689
run: cmake --build out --config $BUILD_TYPE --target run-test
7790

91+
container:
92+
runs-on: ubuntu-latest
93+
container: ${{ matrix.container }}
94+
strategy:
95+
fail-fast: false
96+
matrix:
97+
container: [gcc:15.1]
98+
99+
steps:
100+
- name: Checkout
101+
uses: actions/checkout@v4
102+
103+
- name: Install pre-requisites
104+
run: |
105+
apt-get update
106+
apt-get install -y ninja-build cmake
107+
apt-get install -y python3-dev
108+
109+
- name: Configure
110+
shell: bash
111+
run: |
112+
cmake -S . -B out -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
113+
114+
- name: Build and Test
115+
shell: bash
116+
run: cmake --build out --config ${{env.BUILD_TYPE}} --target run-test
117+
78118
android:
79119
runs-on: ubuntu-latest
80120

@@ -129,24 +169,63 @@ jobs:
129169
130170
emscripten:
131171
runs-on: ubuntu-latest
172+
container: emscripten/emsdk:3.1.70
132173

133174
steps:
134175
- name: Checkout
135176
uses: actions/checkout@v4
136177

137-
- name: Set Up Emscripten
138-
uses: mymindstorm/setup-emsdk@v14
139-
with:
140-
version: 3.1.26
141-
actions-cache-folder: 'emsdk-cache'
178+
- name: Install pre-requisites
179+
run: |
180+
apt-get update
181+
apt-get install -y ninja-build
182+
apt-get install -y python3-dev
183+
184+
export CMAKE_VERSION=3.27.1
185+
wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-Linux-x86_64.sh \
186+
-q -O /tmp/cmake-install.sh \
187+
&& chmod u+x /tmp/cmake-install.sh \
188+
&& /tmp/cmake-install.sh --skip-license --prefix=/usr \
189+
rm -f /tmp/cmake-install.sh
142190
143191
- name: Configure
144192
shell: bash
145-
run: cmake -S . -B out -DCMAKE_TOOLCHAIN_FILE=$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE
193+
run: cmake -S . -B out -DCMAKE_TOOLCHAIN_FILE=$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
146194

147195

148196
- name: Build and Test
149197
shell: bash
150-
run: cmake --build out --config $BUILD_TYPE --target run-test
198+
run: cmake --build out --config ${{env.BUILD_TYPE}} --target run-test
151199

200+
pythons:
201+
runs-on: ubuntu-latest
202+
strategy:
203+
fail-fast: false
204+
matrix:
205+
python-version: [
206+
"3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.13t",
207+
"pypy-3.9", "pypy-3.10", "pypy-3.11"
208+
]
209+
steps:
210+
- name: Checkout
211+
uses: actions/checkout@v4
212+
213+
- name: Set up Python
214+
uses: actions/setup-python@v5
215+
id: setup-python
216+
with:
217+
python-version: ${{matrix.python-version}}
152218

219+
- name: Configure
220+
shell: bash
221+
run: |
222+
cmake -S . -B out -DCMAKE_BUILD_TYPE=$BUILD_TYPE
223+
224+
- name: Build and Test
225+
shell: bash
226+
run: |
227+
cmake --build out --config $BUILD_TYPE --target test-17python test-20python
228+
echo Running test-17python
229+
out/test/test-17python
230+
echo Running test-20python
231+
out/test/test-20python

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ out/
88

99
*.pyc
1010

11-
11+
CMakeSettings.json
1212
test/android
File renamed without changes.

CMakeLists.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,19 @@ project(sys_string VERSION ${SYSSTR_VERSION} LANGUAGES CXX)
1818

1919
find_package (Python3 COMPONENTS Interpreter Development)
2020

21+
if (PROJECT_IS_TOP_LEVEL)
22+
23+
set(SYS_STRING_CONFIGURE_INSTALL ON)
24+
25+
else()
26+
27+
set(SYS_STRING_CONFIGURE_INSTALL ON)
28+
29+
endif()
2130

2231
add_subdirectory(lib)
2332

24-
if(${Python3_Interpreter_FOUND})
33+
if(${Python3_Interpreter_FOUND} AND ${Python3_VERSION} VERSION_GREATER_EQUAL "3.9")
2534

2635
file(GLOB UNICODE_DATA ${CMAKE_CURRENT_LIST_DIR}/unicode/data/*.txt)
2736
file(GLOB UNICODE_SCRIPTS ${CMAKE_CURRENT_LIST_DIR}/unicode/scripts/*.py)
@@ -55,7 +64,6 @@ endif()
5564

5665
if (PROJECT_IS_TOP_LEVEL)
5766

58-
include(lib/cmake/install.cmake)
5967
add_subdirectory(test)
6068

6169
endif()

lib/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ PRIVATE
128128
add_library(${LIBNAME}::${LIBNAME} ALIAS ${LIBNAME})
129129

130130

131-
if (PROJECT_IS_TOP_LEVEL)
131+
if (PROJECT_IS_TOP_LEVEL OR SYS_STRING_CONFIGURE_INSTALL)
132132

133133
include(cmake/install.cmake)
134134

test/CMakeSettings.json

Lines changed: 0 additions & 26 deletions
This file was deleted.

test/test_main.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,38 @@ JNIEnv * g_env;
7070

7171
#endif
7272

73+
#if defined(SYS_STRING_USE_PYTHON) && defined(PYPY_VERSION)
74+
75+
extern "C" {
76+
void rpython_startup_code(void);
77+
int pypy_setup_home(char *home, int verbose);
78+
}
79+
80+
#endif
81+
7382
int main(int argc, char** argv)
7483
{
7584
#if defined(__ANDROID__)
7685
auto [vm, env] = load_jvm();
7786
g_vm = vm;
7887
g_env = env;
7988
#endif
80-
89+
8190
#if defined (_WIN32)
8291
SetConsoleOutputCP(CP_UTF8);
8392
#endif
8493

8594
#if defined(SYS_STRING_USE_PYTHON)
86-
Py_Initialize();
95+
#if !defined(PYPY_VERSION)
96+
Py_Initialize();
97+
#else
98+
rpython_startup_code();
99+
pypy_setup_home(nullptr, 1);
100+
#endif
87101
#endif
88102

103+
104+
89105
return Catch::Session().run( argc, argv );
90106
}
91107

unicode/data/LICENSE.txt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
UNICODE LICENSE V3
2+
3+
COPYRIGHT AND PERMISSION NOTICE
4+
5+
Copyright © 1991-2024 Unicode, Inc.
6+
7+
NOTICE TO USER: Carefully read the following legal agreement. BY
8+
DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING DATA FILES, AND/OR
9+
SOFTWARE, YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
10+
TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT
11+
DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE.
12+
13+
Permission is hereby granted, free of charge, to any person obtaining a
14+
copy of data files and any associated documentation (the "Data Files") or
15+
software and any associated documentation (the "Software") to deal in the
16+
Data Files or Software without restriction, including without limitation
17+
the rights to use, copy, modify, merge, publish, distribute, and/or sell
18+
copies of the Data Files or Software, and to permit persons to whom the
19+
Data Files or Software are furnished to do so, provided that either (a)
20+
this copyright and permission notice appear with all copies of the Data
21+
Files or Software, or (b) this copyright and permission notice appear in
22+
associated Documentation.
23+
24+
THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
25+
KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
27+
THIRD PARTY RIGHTS.
28+
29+
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE
30+
BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES,
31+
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
32+
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
33+
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA
34+
FILES OR SOFTWARE.
35+
36+
Except as contained in this notice, the name of a copyright holder shall
37+
not be used in advertising or otherwise to promote the sale, use or other
38+
dealings in these Data Files or Software without prior written
39+
authorization of the copyright holder.

0 commit comments

Comments
 (0)