Skip to content

Commit f1068ce

Browse files
committed
Full libzip support with zstd
1 parent 85a62d2 commit f1068ce

File tree

7 files changed

+280
-19
lines changed

7 files changed

+280
-19
lines changed

config.full.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ wcli = Yes ; Windows CLI native support
172172
; mongodb
173173
; nsq
174174
; oauth
175+
; opencensus
175176
; parle
176177
; phalcon (need session extension)
177178
; propro

libraries/install_cmark.php

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
/**
4+
* ██████╗███╗ ███╗ █████╗ ██████╗ ██╗ ██╗
5+
* ██╔════╝████╗ ████║██╔══██╗██╔══██╗██║ ██╔╝
6+
* ██║ ██╔████╔██║███████║██████╔╝█████╔╝
7+
* ██║ ██║╚██╔╝██║██╔══██║██╔══██╗██╔═██╗
8+
* ╚██████╗██║ ╚═╝ ██║██║ ██║██║ ██║██║ ██╗
9+
* ╚═════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝
10+
*/
11+
12+
13+
$path = ARCH_PATH . $lib->name . '-' . $lib->version . '\\';
14+
$cmarklog = LOG . 'cmark.log';
15+
16+
17+
// Verify if cmark is installed
18+
if (is_dir($path) && is_file($path . 'build\src\cmark.lib') && is_file(DEPS_PATH . 'lib\cmark.lib')) {
19+
draw_status($lib->name . '-' . $lib->version, "installed", Green);
20+
return;
21+
}
22+
23+
24+
// Download and unzip cmark
25+
$tmpfile = TMP.pathinfo($lib->download_url, PATHINFO_BASENAME);
26+
if(!download_file($lib->download_url, $tmpfile, pathinfo($tmpfile, PATHINFO_BASENAME))) exit_error();
27+
if(!unzip($tmpfile, ARCH_PATH)) exit_error();
28+
if(!is_dir($path)) exit_error("Library folder not found");
29+
30+
31+
// Compile cmark
32+
$label = "Compile " . $lib->name . '-' . $lib->version;
33+
draw_line($label, "running", Yellow);
34+
$bat = '@echo off'.RN;
35+
$bat .= 'cd ' . escapeshellarg($path).RN;
36+
$bat .= 'nmake /f Makefile.nmake'.RN;
37+
$batfile = TMP . 'build_cmark.bat';
38+
file_put_contents($batfile, $bat);
39+
$ret = shell_exec_vs16($batfile, true);
40+
file_put_contents($cmarklog, $ret);
41+
42+
43+
// Verify if the build works
44+
if(!is_file($path . 'build\src\cmark.lib')) draw_status($label, "failed", Red, true, 'SEE: ' . $direntlog);
45+
else draw_status($label, "complete", Green);
46+
47+
48+
// Install cmark
49+
$label = "Install " . $lib->name . '-' . $lib->version;
50+
draw_line($label, "running", Yellow);
51+
$builddir = $path . 'build-win\\';
52+
53+
$files[$path . 'build\src\cmark.lib'] = 'lib\cmark.lib';
54+
$files[$path . 'build\src\cmark_export.h'] = 'include\cmark_export.h';
55+
$files[$path . 'build\src\cmark_version.h'] = 'include\cmark_version.h';
56+
$files[$path . 'src\cmark.h'] = 'include\cmark.h';
57+
58+
if(!create_build($builddir, $files)) draw_status($label, "failed", Red, true);
59+
if(!install_deps($builddir)) draw_status($label, "failed", Red, true);
60+
else draw_status($label, "complete", Green);
61+
62+
delete_parent_deps($lib->name);

libraries/install_liblzma.php

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
/**
4+
* ██╗ ██╗██████╗ ██╗ ███████╗███╗ ███╗ █████╗
5+
* ██║ ██║██╔══██╗██║ ╚══███╔╝████╗ ████║██╔══██╗
6+
* ██║ ██║██████╔╝██║ ███╔╝ ██╔████╔██║███████║
7+
* ██║ ██║██╔══██╗██║ ███╔╝ ██║╚██╔╝██║██╔══██║
8+
* ███████╗██║██████╔╝███████╗███████╗██║ ╚═╝ ██║██║ ██║
9+
* ╚══════╝╚═╝╚═════╝ ╚══════╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝
10+
*/
11+
12+
13+
$path = ARCH_PATH . $lib->name . '-' . $lib->version . '\\';
14+
$lzmalog = LOG . 'liblzma.log';
15+
16+
17+
// Verify if freetype is installed
18+
if (is_dir($path) && is_file($path . 'build\lib\liblzma_a.lib') && is_file(DEPS_PATH . 'lib\liblzma_a.lib')) {
19+
draw_status($lib->name . '-' . $lib->version, "installed", Green);
20+
return;
21+
}
22+
23+
24+
// Download and unzip liblzma
25+
$tmpfile = TMP.pathinfo($lib->download_url, PATHINFO_BASENAME);
26+
if(!download_file($lib->download_url, $tmpfile, pathinfo($tmpfile, PATHINFO_BASENAME))) exit_error();
27+
if(!$firstdir = zip_first_dir($tmpfile)) exit_error("Invalid zip archive");
28+
if(!unzip($tmpfile, ARCH_PATH)) exit_error();
29+
if(!rename_wait(ARCH_PATH . $firstdir, $path)) exit_error("Can't rename library path");
30+
31+
32+
// Compile liblzma
33+
$label = "Compile " . $lib->name . '-' . $lib->version;
34+
draw_line($label, "running", Yellow);
35+
$bat = '@echo off'.RN;
36+
$bat .= 'cd ' . escapeshellarg($path . 'windows\vs2019').RN;
37+
$bat .= 'devenv xz_win.sln /rebuild "Release|x64" /project liblzma'.RN;
38+
$batfile = TMP . 'build_liblzma.bat';
39+
file_put_contents($batfile, $bat);
40+
$ret = shell_exec_vs16($batfile);
41+
file_put_contents($lzmalog, $ret);
42+
43+
44+
// Verify if the build works
45+
if(!is_file($path . 'windows\vs2019\Release\x64\liblzma\liblzma.lib')) draw_status($label, "failed", Red, true, 'SEE: ' . $lzmalog);
46+
else draw_status($label, "complete", Green);
47+
48+
49+
// Install liblzma
50+
$label = "Install " . $lib->name . '-' . $lib->version;
51+
draw_line($label, "running", Yellow);
52+
$builddir = $path . 'build\\';
53+
54+
$files[$path . 'windows\vs2019\Release\x64\liblzma\liblzma.lib'] = 'lib\liblzma_a.lib';
55+
$files[$path . 'src\liblzma\api\lzma.h'] = 'include\lzma.h';
56+
57+
foreach(glob($path . 'src\liblzma\api\lzma\*.h') as $file)
58+
$files[$file] = 'include\lzma\\' . basename($file);
59+
60+
if(!create_build($builddir, $files)) draw_status($label, "failed", Red, true);
61+
if(!install_deps($builddir)) draw_status($label, "failed", Red, true);
62+
else draw_status($label, "complete", Green);
63+
64+
delete_parent_deps($lib->name);

libraries/install_libzip.php

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<?php
2+
3+
/**
4+
* ██╗ ██╗██████╗ ███████╗██╗██████╗
5+
* ██║ ██║██╔══██╗╚══███╔╝██║██╔══██╗
6+
* ██║ ██║██████╔╝ ███╔╝ ██║██████╔╝
7+
* ██║ ██║██╔══██╗ ███╔╝ ██║██╔═══╝
8+
* ███████╗██║██████╔╝███████╗██║██║
9+
* ╚══════╝╚═╝╚═════╝ ╚══════╝╚═╝╚═╝
10+
*/
11+
12+
13+
$path = ARCH_PATH . $lib->name . '-' . $lib->version . '\\';
14+
$ziplog = LOG . 'libzip.log';
15+
16+
17+
// Verify if libzip is installed
18+
if (is_dir($path) && is_file($path . 'build\lib\libzip_a.lib') && is_file(DEPS_PATH . 'lib\libzip_a.lib')) {
19+
draw_status($lib->name . '-' . $lib->version, "installed", Green);
20+
return;
21+
}
22+
23+
24+
// Download and unzip libzip
25+
$tmpfile = TMP.pathinfo($lib->download_url, PATHINFO_BASENAME);
26+
if(!download_file($lib->download_url, $tmpfile, pathinfo($tmpfile, PATHINFO_BASENAME))) exit_error();
27+
if(!unzip($tmpfile, ARCH_PATH)) exit_error();
28+
if(!is_dir($path)) exit_error("Can't find unzip results");
29+
30+
31+
// Copy libraries
32+
if(!@copy(DEPS_PATH . 'lib\zlib_a.lib', DEPS_PATH . 'lib\zlib.lib')) exit_error("Can't copy zlib.lib");
33+
if(!@copy(DEPS_PATH . 'lib\libbz2_a.lib', DEPS_PATH . 'lib\libbz2.lib')) exit_error("Can't copy libbz2.lib");
34+
if(!@copy(DEPS_PATH . 'lib\liblzma_a.lib', DEPS_PATH . 'lib\liblzma.lib')) exit_error("Can't copy liblzma.lib");
35+
if(!@copy(DEPS_PATH . 'lib\libzstd.lib', DEPS_PATH . 'lib\zstd.lib')) exit_error("Can't copy zstd.lib");
36+
37+
38+
// Patch CMakeLists
39+
$cmakelists = $path . 'lib\CMakeLists.txt';
40+
$contents = file_get_contents($cmakelists);
41+
$contents = str_replace('if(HAVE_LIBBZ2)', 'if(HAVE_LIBBZ2)' . RN . ' add_compile_definitions(LZMA_API_STATIC)', $contents);
42+
file_put_contents($cmakelists, $contents);
43+
44+
45+
// Configure libzip
46+
$label = "Configure " . $lib->name . '-' . $lib->version;
47+
draw_line($label, "running", Yellow);
48+
$bat = '@echo off'.RN;
49+
$bat .= 'cd ' . escapeshellarg($path).RN;
50+
$bat .= 'mkdir build-win'.RN;
51+
$bat .= 'cd build-win'.RN;
52+
$bat .= 'set PATH=%PATH%;' . ARCH_PATH . 'deps'.RN;
53+
$bat .= 'cmake -G "Visual Studio 16 2019" BUILD_SHARED_LIBS=OFF ..'.RN;
54+
$batfile = TMP . 'build_libzip.bat';
55+
file_put_contents($batfile, $bat);
56+
$ret = shell_exec_vs16($batfile);
57+
file_put_contents($ziplog, $ret);
58+
59+
60+
// Verify if the solution works
61+
if(!is_file($path . 'build-win\libzip.sln')) draw_status($label, "failed", Red, true, 'SEE: ' . $ziplog);
62+
else draw_status($label, "complete", Green);
63+
64+
65+
// Patch solution file to enable full static library
66+
$prjfile = $path . 'build-win\lib\zip.vcxproj';
67+
$contents = file_get_contents($prjfile);
68+
$contents = str_replace('<ConfigurationType>DynamicLibrary</ConfigurationType>', '<ConfigurationType>StaticLibrary</ConfigurationType>', $contents);
69+
$contents = str_replace('>.dll<', '>.lib<', $contents);
70+
$addlibs = '<Lib><AdditionalDependencies>' . DEPS_PATH . 'lib\liblzma.lib;' . DEPS_PATH . 'lib\zstd.lib' . ';%(AdditionalDependencies)</AdditionalDependencies></Lib>';
71+
$contents = preg_replace('#<ProjectReference>\s+<LinkLibraryDependencies>false</LinkLibraryDependencies>\s+</ProjectReference>#msi', '<ProjectReference><LinkLibraryDependencies>true</LinkLibraryDependencies></ProjectReference>'. $addlibs, $contents);
72+
file_put_contents($prjfile, $contents);
73+
74+
75+
// Compile libzip
76+
$label = "Compile " . $lib->name . '-' . $lib->version;
77+
draw_line($label, "running", Yellow);
78+
$bat = '@echo off'.RN;
79+
$bat .= 'cd ' . escapeshellarg($path . 'build-win').RN;
80+
$bat .= 'DEVENV libzip.sln /rebuild "Release|x64" /project zip'.RN;
81+
$batfile = TMP . 'build_libzip.bat';
82+
file_put_contents($batfile, $bat);
83+
$ret = shell_exec_vs16($batfile);
84+
file_put_contents($ziplog, $ret, FILE_APPEND);
85+
86+
87+
// Verify if the build works
88+
if(!is_file($path . 'build-win\lib\Release\zip.lib')) draw_status($label, "failed", Red, true, 'SEE: ' . $ziplog);
89+
else draw_status($label, "complete", Green);
90+
91+
92+
// Install libzip
93+
$label = "Install " . $lib->name . '-' . $lib->version;
94+
draw_line($label, "running", Yellow);
95+
$builddir = $path . 'build\\';
96+
97+
$files[$path . 'build-win\lib\Release\zip.lib'] = 'lib\libzip_a.lib';
98+
$files[$path . 'build-win\zipconf.h'] = 'include\zipconf.h';
99+
$files[$path . 'lib\zip.h'] = 'include\zip.h';
100+
101+
if(!create_build($builddir, $files)) draw_status($label, "failed", Red, true);
102+
if(!install_deps($builddir)) draw_status($label, "failed", Red, true);
103+
else draw_status($label, "complete", Green);
104+
105+
delete_parent_deps($lib->name);
106+
107+
108+
// Delete temp libraries
109+
unlink(DEPS_PATH . 'lib\zlib.lib');
110+
unlink(DEPS_PATH . 'lib\libbz2.lib');
111+
unlink(DEPS_PATH . 'lib\liblzma.lib');
112+
unlink(DEPS_PATH . 'lib\zstd.lib');

matrix.json

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,14 @@
10821082
],
10831083

10841084
"libraries": [
1085+
{
1086+
"name": "openssl",
1087+
"version": "3.0.13",
1088+
"download_url": "https://www.openssl.org/source/openssl-3.0.13.tar.gz",
1089+
"install_script": "install_openssl.php",
1090+
"mandatory": false,
1091+
"dependancies": []
1092+
},
10851093
{
10861094
"name": "zlib",
10871095
"version": "1.3.1",
@@ -1101,10 +1109,9 @@
11011109
},
11021110
{
11031111
"name": "liblzma",
1104-
"version": "5.2.5",
1105-
"download_url": "https://downloads.php.net/~windows/php-sdk/deps/vs16/x64/liblzma-5.2.5-vs16-x64.zip",
1106-
"install_script": "install_library.php",
1107-
"install_check": "lib\\liblzma_a.lib",
1112+
"version": "5.4.6",
1113+
"download_url": "https://github.com/tukaani-project/xz/archive/refs/tags/v5.4.6.zip",
1114+
"install_script": "install_liblzma.php",
11081115
"mandatory": false,
11091116
"dependancies": []
11101117
},
@@ -1127,20 +1134,11 @@
11271134
},
11281135
{
11291136
"name": "libzip",
1130-
"version": "1.7.1-1",
1131-
"download_url": "https://downloads.php.net/~windows/php-sdk/deps/vs16/x64/libzip-1.7.1-1-vs16-x64.zip",
1132-
"install_script": "install_library.php",
1133-
"install_check": "lib\\libzip_a.lib",
1137+
"version": "1.10.1",
1138+
"download_url": "https://github.com/nih-at/libzip/archive/refs/tags/v1.10.1.zip",
1139+
"install_script": "install_libzip.php",
11341140
"mandatory": false,
1135-
"dependancies": []
1136-
},
1137-
{
1138-
"name": "openssl",
1139-
"version": "3.0.13",
1140-
"download_url": "https://www.openssl.org/source/openssl-3.0.13.tar.gz",
1141-
"install_script": "install_openssl.php",
1142-
"mandatory": false,
1143-
"dependancies": []
1141+
"dependancies": ["openssl", "zlib", "liblzma", "libbzip2", "libzstd"]
11441142
},
11451143
{
11461144
"name": "nghttp2",
@@ -1542,6 +1540,14 @@
15421540
"install_check": "lib\\xdiff_a.lib",
15431541
"mandatory": false,
15441542
"dependancies": []
1543+
},
1544+
{
1545+
"name": "cmark",
1546+
"version": "0.31.0",
1547+
"download_url": "https://github.com/commonmark/cmark/archive/refs/tags/0.31.0.zip",
1548+
"install_script": "install_cmark.php",
1549+
"mandatory": false,
1550+
"dependancies": []
15451551
}
15461552
]
15471553
}

php/ext_opencensus.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
4+
// Movies extension files
5+
foreach(glob($path . '*', GLOB_ONLYDIR) as $file)
6+
if(basename($file) != 'ext')
7+
rm_dir($file);
8+
foreach(glob($path . 'ext\*') as $file)
9+
rename($file, $path . pathinfo($file, PATHINFO_BASENAME));
10+
11+
12+

php/install_extension.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737
if (!download_file($ext->url, $tmpfile, pathinfo($tmpfile, PATHINFO_BASENAME))) exit_error();
3838
if (!untar($tmpfile, EXT_PATH)) exit_error();
3939

40-
$tmpdir = EXT_PATH . $ext->name . '-' . $ext->version;
40+
if(!empty($ext->archive)) $tmpdir = EXT_PATH . $ext->archive;
41+
else $tmpdir = EXT_PATH . $ext->name . '-' . $ext->version;
42+
4143
if (!is_dir($tmpdir)) exit_error("Can't find extension folder");
4244
if (!rename_wait($tmpdir, $path)) exit_error("Can't rename extension folder");
4345
file_put_contents($path . 'version-static.txt', $ext->version);
@@ -58,7 +60,9 @@
5860
if (!download_file($ext->url, $tmpfile, pathinfo($tmpfile, PATHINFO_BASENAME))) exit_error();
5961
if (!untar($tmpfile, EXT_PATH)) exit_error();
6062

61-
$tmpdir = EXT_PATH . $ext->name . '-' . $ext->version;
63+
if(!empty($ext->archive)) $tmpdir = EXT_PATH . $ext->archive;
64+
else $tmpdir = EXT_PATH . $ext->name . '-' . $ext->version;
65+
6266
if (!is_dir($tmpdir)) exit_error("Can't find extension folder");
6367
if (!rename_wait($tmpdir, $path)) exit_error("Can't rename extension folder");
6468
file_put_contents($path . 'version-static.txt', $ext->version);

0 commit comments

Comments
 (0)