Skip to content

Commit

Permalink
Use cmake to make bz2 on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
dixyes committed Oct 3, 2024
1 parent d6e31e6 commit 614606f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
},
"bzip2": {
"type": "url",
"url": "https://gitlab.com/bzip2/bzip2/-/archive/master/bzip2-master.zip",
"url": "https://gitlab.com/bzip2/bzip2/-/archive/master/bzip2-master.tar.bz2",
"license": {
"type": "text",
"text": "This program, \"bzip2\", the associated library \"libbzip2\", and all documentation, are copyright (C) 1996-2010 Julian R Seward. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n 2. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.\n 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.\n 4. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nJulian Seward, jseward@bzip.org bzip2\/libbzip2 version 1.0.6 of 6 September 2010\n\nPATENTS: To the best of my knowledge, bzip2 and libbzip2 do not use any patented algorithms. However, I do not have the resources to carry out a patent search. Therefore I cannot give any guarantee of the above statement."
Expand Down
22 changes: 14 additions & 8 deletions windows/libraries/bzip2.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,29 @@ class Libbzip2 extends Library
protected function build(): void
{
Log::i("building {$this->name}");

file_put_contents('src/bzip2/nmake_wrapper.bat', 'nmake /nologo /f Makefile.msc CFLAGS="-DWIN32 -MT -Ox -D_FILE_OFFSET_BITS=64 -nologo" %*');

$ret = 0;
passthru(
"cd {$this->sourceDir} && " .
"{$this->config->phpBinarySDKCmd} -t nmake_wrapper.bat --task-args clean && " .
"{$this->config->phpBinarySDKCmd} -t nmake_wrapper.bat --task-args lib"
,
'cmake -B builddir ' .
"-A \"{$this->config->cmakeArch}\" " .
"-G \"{$this->config->cmakeGeneratorName}\" " .
"-D ENABLE_LIB_ONLY=ON " .
"-D ENABLE_TESTS=OFF " .
"-D ENABLE_DOCS=OFF " .
"-D ENABLE_SHARED_LIB=OFF " .
"-D ENABLE_STATIC_LIB=ON " .
'-DCMAKE_INSTALL_PREFIX="' . realpath('deps') . '" ' .
"-DCMAKE_TOOLCHAIN_FILE={$this->config->cmakeToolchainFile} " .
'&& ' .
"cmake --build builddir --config RelWithDebInfo --target install -j {$this->config->concurrency}",
$ret
);
if ($ret !== 0) {
throw new Exception("failed to build {$this->name}");
}

copy('src/bzip2/libbz2.lib', 'deps/lib/libbz2.lib');
copy('src/bzip2/libbz2.lib', 'deps/lib/libbz2_a.lib');
copy('src/bzip2/bzlib.h', 'deps/include/bzlib.h');
copy('deps/lib/bz2_static.lib', 'deps/lib/libbz2.lib');
copy('deps/lib/bz2_static.lib', 'deps/lib/libbz2_a.lib');
}
}

0 comments on commit 614606f

Please sign in to comment.