Skip to content

Commit c984766

Browse files
committed
remove windows workflow and update extension to use new memory management
1 parent 60c5947 commit c984766

File tree

5 files changed

+30
-215
lines changed

5 files changed

+30
-215
lines changed

.github/workflows/release.yml

Lines changed: 6 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,6 @@ permissions:
1111
issues: write
1212

1313
jobs:
14-
get-extension-matrix:
15-
runs-on: ubuntu-latest
16-
outputs:
17-
matrix: ${{ steps.extension-matrix.outputs.matrix }}
18-
steps:
19-
- name: Checkout
20-
uses: actions/checkout@v4
21-
- name: Get the extension matrix
22-
id: extension-matrix
23-
uses: php/php-windows-builder/extension-matrix@v1
24-
with:
25-
php-version-list: '8.2, 8.3, 8.4'
26-
2714
build-linux:
2815
runs-on: ubuntu-latest
2916
strategy:
@@ -101,92 +88,14 @@ jobs:
10188
compression-level: 6
10289
overwrite: true
10390
include-hidden-files: false
104-
105-
build-windows:
106-
needs: get-extension-matrix
107-
runs-on: ${{ matrix.os }}
108-
strategy:
109-
fail-fast: false
110-
matrix: ${{fromJson(needs.get-extension-matrix.outputs.matrix)}}
111-
steps:
112-
- name: Checkout
113-
uses: actions/checkout@v4
114-
with:
115-
submodules: true
116-
117-
- name: Initialize and update submodules
118-
run: |
119-
git submodule update --init --recursive
120-
121-
- name: Verify submodule files
122-
run: |
123-
echo "Checking if lib directory and files exist:"
124-
dir lib
125-
echo "Checking specific source files:"
126-
if (Test-Path "lib\arena.c") { echo "arena.c exists" } else { echo "arena.c missing" }
127-
if (Test-Path "lib\csv_config.c") { echo "csv_config.c exists" } else { echo "csv_config.c missing" }
128-
if (Test-Path "lib\csv_reader.c") { echo "csv_reader.c exists" } else { echo "csv_reader.c missing" }
129-
if (Test-Path "lib\csv_writer.c") { echo "csv_writer.c exists" } else { echo "csv_writer.c missing" }
130-
if (Test-Path "lib\csv_parser.c") { echo "csv_parser.c exists" } else { echo "csv_parser.c missing" }
131-
if (Test-Path "lib\csv_utils.c") { echo "csv_utils.c exists" } else { echo "csv_utils.c missing" }
132-
shell: pwsh
133-
134-
- name: Build The Extension
135-
uses: php/php-windows-builder/extension@v1
136-
with:
137-
php-version: ${{ matrix.php-version }}
138-
arch: ${{ matrix.arch }}
139-
ts: ${{ matrix.ts }}
140-
141-
- name: Create dist directory
142-
run: mkdir -p dist/releases/${{ github.ref_name }}/windows/php${{ matrix.php-version }}-${{ matrix.arch }}
143-
144-
- name: Copy extension
145-
shell: pwsh
146-
run: |
147-
$dllPaths = @(
148-
"Release_TS\php_fastcsv.dll",
149-
"x64\Release_TS\php_fastcsv.dll",
150-
"Release\php_fastcsv.dll",
151-
"x64\Release\php_fastcsv.dll",
152-
"modules\php_fastcsv.dll"
153-
)
154-
155-
$found = $false
156-
foreach ($path in $dllPaths) {
157-
if (Test-Path $path) {
158-
Write-Host "Found extension at: $path"
159-
Copy-Item "$path" "dist/releases/${{ github.ref_name }}/windows/php${{ matrix.php-version }}-${{ matrix.arch }}/fastcsv.dll"
160-
$found = $true
161-
break
162-
}
163-
}
164-
165-
if (-not $found) {
166-
Write-Host "ERROR: Could not find php_fastcsv.dll in any expected locations:"
167-
$dllPaths | ForEach-Object { Write-Host " Checked: $_" }
168-
Write-Host "Available DLL files:"
169-
Get-ChildItem -Recurse -Filter "*.dll" | Select-Object FullName
170-
exit 1
171-
}
172-
173-
- name: Upload artifact
174-
uses: actions/upload-artifact@v4
175-
with:
176-
name: windows-builds-php${{ matrix.php-version }}-${{ matrix.arch }}-${{ matrix.ts }}
177-
path: dist/releases/${{ github.ref_name }}/windows/php${{ matrix.php-version }}-${{ matrix.arch }}
178-
if-no-files-found: warn
179-
compression-level: 6
180-
overwrite: true
181-
include-hidden-files: false
18291

18392
create-release:
184-
needs: [build-linux, build-macos, build-windows]
93+
needs: [build-linux, build-macos]
18594
runs-on: ubuntu-latest
18695
steps:
18796
- name: Create release directories
18897
run: |
189-
mkdir -p dist/releases/${{ github.ref_name }}/{linux,macos,windows,final}
98+
mkdir -p dist/releases/${{ github.ref_name }}/{linux,macos,final}
19099
191100
- name: Download all artifacts
192101
uses: actions/download-artifact@v4
@@ -203,8 +112,8 @@ jobs:
203112
run: |
204113
echo "=== Starting file preparation ==="
205114
206-
echo "Looking for .so and .dll files..."
207-
find dist/releases/${{ github.ref_name }} -name "*.so" -o -name "*.dll"
115+
echo "Looking for .so files..."
116+
find dist/releases/${{ github.ref_name }} -name "*.so"
208117
209118
echo "=== Processing Linux builds ==="
210119
for artifact_dir in dist/releases/${{ github.ref_name }}/linux-builds-php*; do
@@ -229,21 +138,6 @@ jobs:
229138
done
230139
fi
231140
done
232-
233-
echo "=== Processing Windows builds ==="
234-
for artifact_dir in dist/releases/${{ github.ref_name }}/windows-builds-php*; do
235-
if [ -d "$artifact_dir" ]; then
236-
artifact_name=$(basename "$artifact_dir")
237-
php_ver=$(echo "$artifact_name" | grep -o 'php[0-9]\.[0-9]' | sed 's/php//')
238-
arch=$(echo "$artifact_name" | grep -o 'x64')
239-
ts=$(echo "$artifact_name" | grep -o '\(ts\|nts\)$')
240-
echo "Processing Windows artifact directory: $artifact_dir for PHP $php_ver ($arch-$ts)"
241-
for file in $(find "$artifact_dir" -name "*.dll"); do
242-
echo "Found Windows build: $file"
243-
cp -v "$file" "dist/releases/${{ github.ref_name }}/final/fastcsv-windows-php${php_ver}-${arch}-${ts}.dll"
244-
done
245-
fi
246-
done
247141
248142
echo "=== Files ready for release ==="
249143
ls -la dist/releases/${{ github.ref_name }}/final/ || echo "No files in final directory"
@@ -257,7 +151,6 @@ jobs:
257151
files: |
258152
dist/releases/${{ github.ref_name }}/final/fastcsv-linux-php*.so
259153
dist/releases/${{ github.ref_name }}/final/fastcsv-macos-php*.so
260-
dist/releases/${{ github.ref_name }}/final/fastcsv-windows-php*.dll
261154
name: Release ${{ github.ref_name }}
262155
body: |
263156
## FastCSV Extension ${{ github.ref_name }}
@@ -273,18 +166,10 @@ jobs:
273166
- PHP 8.2: `fastcsv-macos-php8.2.so`
274167
- PHP 8.3: `fastcsv-macos-php8.3.so`
275168
- PHP 8.4: `fastcsv-macos-php8.4.so`
276-
277-
#### Windows:
278-
- PHP 8.2 (x64-TS): `fastcsv-windows-php8.2-x64-ts.dll`
279-
- PHP 8.2 (x64-NTS): `fastcsv-windows-php8.2-x64-nts.dll`
280-
- PHP 8.3 (x64-TS): `fastcsv-windows-php8.3-x64-ts.dll`
281-
- PHP 8.3 (x64-NTS): `fastcsv-windows-php8.3-x64-nts.dll`
282-
- PHP 8.4 (x64-TS): `fastcsv-windows-php8.4-x64-ts.dll`
283-
- PHP 8.4 (x64-NTS): `fastcsv-windows-php8.4-x64-nts.dll`
284169
285170
### Installation
286171
1. Download the appropriate file for your platform and PHP version
287-
2. Rename the downloaded file to `fastcsv.so` (Linux/macOS) or `fastcsv.dll` (Windows)
172+
2. Rename the downloaded file to `fastcsv.so`
288173
3. Copy the renamed file to your PHP extensions directory:
289174
```bash
290175
# Find your PHP extension directory
@@ -295,8 +180,7 @@ jobs:
295180
```
296181
4. Add to your php.ini:
297182
```ini
298-
extension=fastcsv.so # Linux/macOS
299-
extension=fastcsv.dll # Windows
183+
extension=fastcsv.so
300184
```
301185
5. Restart your PHP service/server
302186

.github/workflows/windows.yml

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

fastcsv.c

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,12 @@ static zend_object *fastcsv_reader_create_object(zend_class_entry *class_type) {
3737

3838
intern = zend_object_alloc(sizeof(php_fastcsv_reader_object), class_type);
3939
intern->reader = NULL;
40-
intern->arena = emalloc(sizeof(Arena));
41-
arena_create(intern->arena, 1024 * 1024);
40+
41+
intern->persistent_arena = emalloc(sizeof(Arena));
42+
arena_create(intern->persistent_arena, 1024 * 1024);
43+
44+
intern->temp_arena = emalloc(sizeof(Arena));
45+
arena_create(intern->temp_arena, 1024 * 1024);
4246

4347
zend_object_std_init(&intern->std, class_type);
4448
object_properties_init(&intern->std, class_type);
@@ -88,10 +92,16 @@ static void fastcsv_reader_free_object(zend_object *object) {
8892
intern->reader = NULL;
8993
}
9094

91-
if (intern->arena) {
92-
arena_destroy(intern->arena);
93-
efree(intern->arena);
94-
intern->arena = NULL;
95+
if (intern->persistent_arena) {
96+
arena_destroy(intern->persistent_arena);
97+
efree(intern->persistent_arena);
98+
intern->persistent_arena = NULL;
99+
}
100+
101+
if (intern->temp_arena) {
102+
arena_destroy(intern->temp_arena);
103+
efree(intern->temp_arena);
104+
intern->temp_arena = NULL;
95105
}
96106

97107
zend_object_std_dtor(&intern->std);
@@ -144,15 +154,15 @@ PHP_METHOD(FastCSVReader, __construct) {
144154
intern = Z_FASTCSV_READER_P(getThis());
145155

146156
if (Z_TYPE_P(param_zval) == IS_STRING) {
147-
config = csv_config_create(intern->arena);
157+
config = csv_config_create(intern->persistent_arena);
148158
if (!config) {
149159
zend_throw_exception(zend_ce_exception, "Failed to create default config", 0);
150160
RETURN_THROWS();
151161
}
152162

153163
csv_config_set_path(config, Z_STRVAL_P(param_zval));
154164

155-
intern->reader = csv_reader_init_with_config(intern->arena, config);
165+
intern->reader = csv_reader_init_with_config(intern->persistent_arena, intern->temp_arena, config);
156166
if (!intern->reader) {
157167
zend_throw_exception(zend_ce_exception, "Failed to open CSV file", 0);
158168
RETURN_THROWS();
@@ -165,7 +175,7 @@ PHP_METHOD(FastCSVReader, __construct) {
165175
RETURN_THROWS();
166176
}
167177

168-
intern->reader = csv_reader_init_with_config(intern->arena, config_obj->config);
178+
intern->reader = csv_reader_init_with_config(intern->persistent_arena, intern->temp_arena, config_obj->config);
169179
if (!intern->reader) {
170180
zend_throw_exception(zend_ce_exception, "Failed to open CSV file", 0);
171181
RETURN_THROWS();
@@ -288,10 +298,10 @@ PHP_METHOD(FastCSVReader, setConfig) {
288298
}
289299

290300
if (intern->reader) {
291-
int result = csv_reader_set_config(intern->reader, intern->arena, config_obj->config);
301+
int result = csv_reader_set_config(intern->reader, intern->persistent_arena, intern->temp_arena, config_obj->config);
292302
RETURN_BOOL(result == 1);
293303
} else {
294-
intern->reader = csv_reader_init_with_config(intern->arena, config_obj->config);
304+
intern->reader = csv_reader_init_with_config(intern->persistent_arena, intern->temp_arena, config_obj->config);
295305
if (!intern->reader) {
296306
zend_throw_exception(zend_ce_exception, "Failed to initialize reader with config", 0);
297307
RETURN_THROWS();

php_fastcsv.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ extern zend_class_entry *fastcsv_config_ce;
3030

3131
typedef struct _php_fastcsv_reader_object {
3232
CSVReader *reader;
33-
Arena *arena;
33+
Arena *persistent_arena;
34+
Arena *temp_arena;
3435
zend_object std;
3536
} php_fastcsv_reader_object;
3637

0 commit comments

Comments
 (0)