cmake: Add BZip2 support

This commit is contained in:
Corentin Le Molgat
2025-04-07 13:22:15 +02:00
parent d3cf912277
commit 1f27694ab8
18 changed files with 829 additions and 595 deletions

View File

@@ -176,6 +176,10 @@ CMAKE_DEPENDENT_OPTION(BUILD_ZLIB "Build the ZLIB dependency Library" OFF
"NOT BUILD_DEPS" ON)
message(STATUS "Build ZLIB: ${BUILD_ZLIB}")
CMAKE_DEPENDENT_OPTION(BUILD_BZip2 "Build the BZip2 dependency Library" OFF
"NOT BUILD_DEPS" ON)
message(STATUS "Build BZip2: ${BUILD_BZip2}")
CMAKE_DEPENDENT_OPTION(BUILD_absl "Build the abseil-cpp dependency Library" OFF
"NOT BUILD_DEPS" ON)
message(STATUS "Build abseil-cpp: ${BUILD_absl}")

View File

@@ -114,6 +114,7 @@ the option `-DBUILD_DEPS=ON` (`OFF` by default) or compile some of them using
the options below (see [CMake Options](#cmake-options) below).
* zlib (`BUILD_ZLIB`),
* bzip2 (`BUILD_BZip2`),
* Google Abseil-cpp (`BUILD_absl`),
* Google Protobuf (`BUILD_Protobuf`),
* COIN-OR solvers:
@@ -196,6 +197,7 @@ cmake -S. -Bbuild -LH
| | | |
| `BUILD_DEPS` | OFF* | Default to ON if `BUILD_JAVA=ON` or `BUILD_PYTHON=ON` or `BUILD_DOTNET=ON` |
| `BUILD_ZLIB` | OFF* | Build the zlib dynamic library<br>**Forced** to ON if `BUILD_DEPS=ON` |
| `BUILD_BZip2` | OFF* | Build the bzip2 dynamic library<br>**Forced** to ON if `BUILD_DEPS=ON` |
| `BUILD_absl` | OFF* | Build the abseil-cpp dynamic libraries<br>**Forced** to ON if `BUILD_DEPS=ON` |
| `BUILD_Protobuf` | OFF* | Build the protobuf dynamic libraries<br>**Forced** to ON if `BUILD_DEPS=ON` |
| `BUILD_re2` | OFF* | Build the re2 dynamic libraries<br>**Forced** to ON if `BUILD_DEPS=ON` |

View File

@@ -16,6 +16,10 @@ if(NOT TARGET ZLIB::ZLIB)
message(FATAL_ERROR "Target ZLIB::ZLIB not available.")
endif()
if(NOT TARGET BZip2::BZip2)
message(FATAL_ERROR "Target BZip2::BZip2 not available.")
endif()
if(NOT TARGET absl::base)
message(FATAL_ERROR "Target absl::base not available.")
endif()

View File

@@ -578,6 +578,7 @@ endif()
target_link_libraries(${PROJECT_NAME} PUBLIC
${CMAKE_DL_LIBS}
ZLIB::ZLIB
BZip2::BZip2
${ABSL_DEPS}
protobuf::libprotobuf
${RE2_DEPS}

View File

@@ -73,6 +73,27 @@ if(BUILD_ZLIB)
message(CHECK_PASS "fetched")
endif()
# ##############################################################################
# BZip2
# ##############################################################################
if(BUILD_BZip2)
message(CHECK_START "Fetching BZip2")
list(APPEND CMAKE_MESSAGE_INDENT " ")
set(ENABLE_LIB_ONLY ON)
FetchContent_Declare(
BZip2
GIT_REPOSITORY "https://gitlab.com/bzip2/bzip2.git"
GIT_TAG "master"
# GIT_TAG "bzip2-1.0.8" # CMake support not available
GIT_SHALLOW TRUE
PATCH_COMMAND git apply --ignore-whitespace
"${CMAKE_CURRENT_LIST_DIR}/../../patches/bzip2.patch"
)
FetchContent_MakeAvailable(BZip2)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
endif()
# ##############################################################################
# ABSEIL-CPP
# ##############################################################################

View File

@@ -34,6 +34,13 @@ digraph CMake {
label = "madler/zlib.git + cmake patch";
}
subgraph clusterBZIP2 {
BZip2 [label="BZip2::BZip2", color=royalblue];
color=royalblue;
label = "bzip2/bzip2.git + cmake patch";
}
subgraph clusterAbsl {
Absl [label="absl::absl_*", color=royalblue];
@@ -195,6 +202,7 @@ digraph CMake {
PKG_CPP -> EX_CPP;
ZLIB -> OR_SRC;
BZip2 -> OR_SRC;
Absl -> OR_SRC;
Protobuf -> OR_SRC;
Re2 -> OR_SRC;

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 52 KiB

View File

@@ -11,6 +11,13 @@ digraph CMakeDeps {
label = "madler/zlib.git + cmake patch";
}
subgraph clusterBZip2 {
BZip2 [label="BZip2::BZip2"];
color=royalblue;
label = "bzip2/bzip2.git + cmake patch";
}
subgraph clusterAbsl {
Absl [label="absl::absl_*"];

View File

@@ -4,137 +4,142 @@
<!-- Generated by graphviz version 2.42.4 (0)
-->
<!-- Title: CMakeDeps Pages: 1 -->
<svg width="2430pt" height="641pt"
viewBox="0.00 0.00 2430.00 641.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<svg width="2621pt" height="641pt"
viewBox="0.00 0.00 2621.00 641.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 637)">
<title>CMakeDeps</title>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-637 2426,-637 2426,4 -4,4"/>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-637 2617,-637 2617,4 -4,4"/>
<g id="clust1" class="cluster">
<title>clusterZLIB</title>
<polygon fill="none" stroke="royalblue" points="465,-221 465,-296 647,-296 647,-221 465,-221"/>
<text text-anchor="middle" x="556" y="-228.8" font-family="Times,serif" font-size="14.00">madler/zlib.git + cmake patch</text>
</g>
<g id="clust2" class="cluster">
<title>clusterBZip2</title>
<polygon fill="none" stroke="royalblue" points="1701,-39 1701,-114 1884,-114 1884,-39 1701,-39"/>
<text text-anchor="middle" x="1792.5" y="-46.8" font-family="Times,serif" font-size="14.00">bzip2/bzip2.git + cmake patch</text>
</g>
<g id="clust3" class="cluster">
<title>clusterAbsl</title>
<polygon fill="none" stroke="royalblue" points="1119,-304 1119,-379 1244,-379 1244,-304 1119,-304"/>
<text text-anchor="middle" x="1181.5" y="-311.8" font-family="Times,serif" font-size="14.00">abseil/abseil&#45;cpp.git</text>
</g>
<g id="clust3" class="cluster">
<g id="clust4" class="cluster">
<title>clusterProtobuf</title>
<polygon fill="none" stroke="royalblue" points="984,-130 984,-205 1255,-205 1255,-130 984,-130"/>
<text text-anchor="middle" x="1119.5" y="-137.8" font-family="Times,serif" font-size="14.00">protocolbuffers/protobuf.git</text>
</g>
<g id="clust4" class="cluster">
<g id="clust5" class="cluster">
<title>clusterRe2</title>
<polygon fill="none" stroke="royalblue" points="998,-221 998,-296 1090,-296 1090,-221 998,-221"/>
<text text-anchor="middle" x="1044" y="-228.8" font-family="Times,serif" font-size="14.00">google/re2.git</text>
</g>
<g id="clust5" class="cluster">
<title>clusterEigen3</title>
<polygon fill="none" stroke="royalblue" points="1701,-39 1701,-114 1812,-114 1812,-39 1701,-39"/>
<text text-anchor="middle" x="1756.5" y="-46.8" font-family="Times,serif" font-size="14.00">libeigen/eigen.git</text>
</g>
<g id="clust6" class="cluster">
<title>clusterEigen3</title>
<polygon fill="none" stroke="royalblue" points="1892,-39 1892,-114 2003,-114 2003,-39 1892,-39"/>
<text text-anchor="middle" x="1947.5" y="-46.8" font-family="Times,serif" font-size="14.00">libeigen/eigen.git</text>
</g>
<g id="clust7" class="cluster">
<title>clusterCoinOR</title>
<polygon fill="none" stroke="royalblue" points="8,-8 8,-625 376,-625 376,-8 8,-8"/>
<text text-anchor="middle" x="192" y="-15.8" font-family="Times,serif" font-size="14.00">&#45;DUSE_COINOR=ON AND &#45;DBUILD_DEPS=ON</text>
</g>
<g id="clust7" class="cluster">
<g id="clust8" class="cluster">
<title>clusterCoinUtils</title>
<polygon fill="none" stroke="royalblue" points="219,-542 219,-617 346,-617 346,-542 219,-542"/>
<text text-anchor="middle" x="282.5" y="-549.8" font-family="Times,serif" font-size="14.00">Mizux/CoinUtils.git</text>
</g>
<g id="clust8" class="cluster">
<g id="clust9" class="cluster">
<title>clusterOsi</title>
<polygon fill="none" stroke="royalblue" points="36,-459 36,-534 129,-534 129,-459 36,-459"/>
<text text-anchor="middle" x="82.5" y="-466.8" font-family="Times,serif" font-size="14.00">Mizux/Osi.git</text>
</g>
<g id="clust9" class="cluster">
<g id="clust10" class="cluster">
<title>clusterClp</title>
<polygon fill="none" stroke="royalblue" points="68,-304 68,-451 296,-451 296,-304 68,-304"/>
<text text-anchor="middle" x="182" y="-311.8" font-family="Times,serif" font-size="14.00">Mizux/Clp.git</text>
</g>
<g id="clust10" class="cluster">
<g id="clust11" class="cluster">
<title>clusterCgl</title>
<polygon fill="none" stroke="royalblue" points="149,-221 149,-296 243,-296 243,-221 149,-221"/>
<text text-anchor="middle" x="196" y="-228.8" font-family="Times,serif" font-size="14.00">Mizux/Cgl.git</text>
</g>
<g id="clust11" class="cluster">
<g id="clust12" class="cluster">
<title>clusterCbc</title>
<polygon fill="none" stroke="royalblue" points="135,-39 135,-205 367,-205 367,-39 135,-39"/>
<text text-anchor="middle" x="251" y="-46.8" font-family="Times,serif" font-size="14.00">Mizux/Cbc.git</text>
</g>
<g id="clust12" class="cluster">
<title>clusterGLPKSolver</title>
<polygon fill="none" stroke="royalblue" points="1820,-8 1820,-122 2107,-122 2107,-8 1820,-8"/>
<text text-anchor="middle" x="1963.5" y="-15.8" font-family="Times,serif" font-size="14.00">&#45;DUSE_GLPK=ON AND &#45;DBUILD_GLPK=ON</text>
</g>
<g id="clust13" class="cluster">
<title>clusterGLPK</title>
<polygon fill="none" stroke="royalblue" points="1908,-39 1908,-114 2018,-114 2018,-39 1908,-39"/>
<text text-anchor="middle" x="1963" y="-46.8" font-family="Times,serif" font-size="14.00">Mizux/GLPK.git</text>
<title>clusterGLPKSolver</title>
<polygon fill="none" stroke="royalblue" points="2011,-8 2011,-122 2298,-122 2298,-8 2011,-8"/>
<text text-anchor="middle" x="2154.5" y="-15.8" font-family="Times,serif" font-size="14.00">&#45;DUSE_GLPK=ON AND &#45;DBUILD_GLPK=ON</text>
</g>
<g id="clust14" class="cluster">
<title>clusterHIGHSSolver</title>
<polygon fill="none" stroke="royalblue" points="2115,-8 2115,-122 2414,-122 2414,-8 2115,-8"/>
<text text-anchor="middle" x="2264.5" y="-15.8" font-family="Times,serif" font-size="14.00">&#45;DUSE_HIGHS=ON AND &#45;DBUILD_HIGHS=ON</text>
<title>clusterGLPK</title>
<polygon fill="none" stroke="royalblue" points="2099,-39 2099,-114 2209,-114 2209,-39 2099,-39"/>
<text text-anchor="middle" x="2154" y="-46.8" font-family="Times,serif" font-size="14.00">Mizux/GLPK.git</text>
</g>
<g id="clust15" class="cluster">
<title>clusterHIGHS</title>
<polygon fill="none" stroke="royalblue" points="2190,-39 2190,-114 2339,-114 2339,-39 2190,-39"/>
<text text-anchor="middle" x="2264.5" y="-46.8" font-family="Times,serif" font-size="14.00">ERGO&#45;Code/HIGHS.git</text>
<title>clusterHIGHSSolver</title>
<polygon fill="none" stroke="royalblue" points="2306,-8 2306,-122 2605,-122 2605,-8 2306,-8"/>
<text text-anchor="middle" x="2455.5" y="-15.8" font-family="Times,serif" font-size="14.00">&#45;DUSE_HIGHS=ON AND &#45;DBUILD_HIGHS=ON</text>
</g>
<g id="clust16" class="cluster">
<title>clusterHIGHS</title>
<polygon fill="none" stroke="royalblue" points="2381,-39 2381,-114 2530,-114 2530,-39 2381,-39"/>
<text text-anchor="middle" x="2455.5" y="-46.8" font-family="Times,serif" font-size="14.00">ERGO&#45;Code/HIGHS.git</text>
</g>
<g id="clust17" class="cluster">
<title>clusterSCIPSolver</title>
<polygon fill="none" stroke="royalblue" points="384,-8 384,-213 658,-213 658,-8 384,-8"/>
<text text-anchor="middle" x="521" y="-15.8" font-family="Times,serif" font-size="14.00">&#45;DUSE_SCIP=ON AND &#45;DBUILD_SCIP=ON</text>
</g>
<g id="clust17" class="cluster">
<g id="clust18" class="cluster">
<title>clusterSoplex</title>
<polygon fill="none" stroke="royalblue" points="454,-130 454,-205 567,-205 567,-130 454,-130"/>
<text text-anchor="middle" x="510.5" y="-137.8" font-family="Times,serif" font-size="14.00">scipopt/soplex.git</text>
</g>
<g id="clust18" class="cluster">
<g id="clust19" class="cluster">
<title>clusterSCIP</title>
<polygon fill="none" stroke="royalblue" points="478,-39 478,-114 582,-114 582,-39 478,-39"/>
<text text-anchor="middle" x="530" y="-46.8" font-family="Times,serif" font-size="14.00">scipopt/scip.git</text>
</g>
<g id="clust19" class="cluster">
<g id="clust20" class="cluster">
<title>clusterTesting</title>
<polygon fill="none" stroke="royalblue" points="666,-8 666,-213 976,-213 976,-8 666,-8"/>
<text text-anchor="middle" x="821" y="-15.8" font-family="Times,serif" font-size="14.00">&#45;DBUILD_TESTING=ON</text>
</g>
<g id="clust20" class="cluster">
<g id="clust21" class="cluster">
<title>clusterGTest</title>
<polygon fill="none" stroke="royalblue" points="814,-130 814,-205 945,-205 945,-130 814,-130"/>
<text text-anchor="middle" x="879.5" y="-137.8" font-family="Times,serif" font-size="14.00">google/googletest.git</text>
</g>
<g id="clust21" class="cluster">
<g id="clust22" class="cluster">
<title>clusterBenchmark</title>
<polygon fill="none" stroke="royalblue" points="674,-39 674,-114 836,-114 836,-39 674,-39"/>
<text text-anchor="middle" x="755" y="-46.8" font-family="Times,serif" font-size="14.00">google/benchmark.git</text>
</g>
<g id="clust22" class="cluster">
<g id="clust23" class="cluster">
<title>clusterFuzzTest</title>
<polygon fill="none" stroke="royalblue" points="844,-39 844,-114 968,-114 968,-39 844,-39"/>
<text text-anchor="middle" x="906" y="-46.8" font-family="Times,serif" font-size="14.00">google/fuzztest.git</text>
</g>
<g id="clust23" class="cluster">
<g id="clust24" class="cluster">
<title>clusterPython</title>
<polygon fill="none" stroke="gold" points="1293,-8 1293,-213 1693,-213 1693,-8 1293,-8"/>
<text text-anchor="middle" x="1493" y="-15.8" font-family="Times,serif" font-size="14.00">&#45;DBUILD_PYTHON=ON</text>
</g>
<g id="clust24" class="cluster">
<g id="clust25" class="cluster">
<title>clusterPybind11</title>
<polygon fill="none" stroke="gold" points="1476,-130 1476,-205 1618,-205 1618,-130 1476,-130"/>
<text text-anchor="middle" x="1547" y="-137.8" font-family="Times,serif" font-size="14.00">pybind/pybind11.git</text>
</g>
<g id="clust25" class="cluster">
<g id="clust26" class="cluster">
<title>clusterPybind11Absl</title>
<polygon fill="none" stroke="gold" points="1505,-39 1505,-114 1685,-114 1685,-39 1505,-39"/>
<text text-anchor="middle" x="1595" y="-46.8" font-family="Times,serif" font-size="14.00">pybind/pybind11_abseil.git</text>
</g>
<g id="clust26" class="cluster">
<g id="clust27" class="cluster">
<title>clusterPybind11Protobuf</title>
<polygon fill="none" stroke="gold" points="1301,-39 1301,-114 1497,-114 1497,-39 1301,-39"/>
<text text-anchor="middle" x="1399" y="-46.8" font-family="Times,serif" font-size="14.00">pybind/pybind11_protobuf.git</text>
@@ -145,14 +150,20 @@
<path fill="royalblue" stroke="royalblue" d="M586,-288C586,-288 526,-288 526,-288 520,-288 514,-282 514,-276 514,-276 514,-264 514,-264 514,-258 520,-252 526,-252 526,-252 586,-252 586,-252 592,-252 598,-258 598,-264 598,-264 598,-276 598,-276 598,-282 592,-288 586,-288"/>
<text text-anchor="middle" x="556" y="-266.3" font-family="Times,serif" font-size="14.00">ZLIB::ZLIB</text>
</g>
<!-- Absl -->
<!-- BZip2 -->
<g id="node2" class="node">
<title>BZip2</title>
<path fill="royalblue" stroke="royalblue" d="M1826.5,-106C1826.5,-106 1757.5,-106 1757.5,-106 1751.5,-106 1745.5,-100 1745.5,-94 1745.5,-94 1745.5,-82 1745.5,-82 1745.5,-76 1751.5,-70 1757.5,-70 1757.5,-70 1826.5,-70 1826.5,-70 1832.5,-70 1838.5,-76 1838.5,-82 1838.5,-82 1838.5,-94 1838.5,-94 1838.5,-100 1832.5,-106 1826.5,-106"/>
<text text-anchor="middle" x="1792" y="-84.3" font-family="Times,serif" font-size="14.00">BZip2::BZip2</text>
</g>
<!-- Absl -->
<g id="node3" class="node">
<title>Absl</title>
<path fill="royalblue" stroke="royalblue" d="M1209.5,-371C1209.5,-371 1152.5,-371 1152.5,-371 1146.5,-371 1140.5,-365 1140.5,-359 1140.5,-359 1140.5,-347 1140.5,-347 1140.5,-341 1146.5,-335 1152.5,-335 1152.5,-335 1209.5,-335 1209.5,-335 1215.5,-335 1221.5,-341 1221.5,-347 1221.5,-347 1221.5,-359 1221.5,-359 1221.5,-365 1215.5,-371 1209.5,-371"/>
<text text-anchor="middle" x="1181" y="-349.3" font-family="Times,serif" font-size="14.00">absl::absl_*</text>
</g>
<!-- Protobuf -->
<g id="node3" class="node">
<g id="node4" class="node">
<title>Protobuf</title>
<path fill="royalblue" stroke="royalblue" d="M1234.5,-197C1234.5,-197 1127.5,-197 1127.5,-197 1121.5,-197 1115.5,-191 1115.5,-185 1115.5,-185 1115.5,-173 1115.5,-173 1115.5,-167 1121.5,-161 1127.5,-161 1127.5,-161 1234.5,-161 1234.5,-161 1240.5,-161 1246.5,-167 1246.5,-173 1246.5,-173 1246.5,-185 1246.5,-185 1246.5,-191 1240.5,-197 1234.5,-197"/>
<text text-anchor="middle" x="1181" y="-175.3" font-family="Times,serif" font-size="14.00">protobuf::libprotobuf</text>
@@ -170,7 +181,7 @@
<polygon fill="black" stroke="black" points="1177.5,-324.95 1181,-334.95 1184.5,-324.95 1177.5,-324.95"/>
</g>
<!-- Re2 -->
<g id="node5" class="node">
<g id="node6" class="node">
<title>Re2</title>
<path fill="royalblue" stroke="royalblue" d="M1054.5,-288C1054.5,-288 1019.5,-288 1019.5,-288 1013.5,-288 1007.5,-282 1007.5,-276 1007.5,-276 1007.5,-264 1007.5,-264 1007.5,-258 1013.5,-252 1019.5,-252 1019.5,-252 1054.5,-252 1054.5,-252 1060.5,-252 1066.5,-258 1066.5,-264 1066.5,-264 1066.5,-276 1066.5,-276 1066.5,-282 1060.5,-288 1054.5,-288"/>
<text text-anchor="middle" x="1037" y="-266.3" font-family="Times,serif" font-size="14.00">re2::re2</text>
@@ -182,7 +193,7 @@
<polygon fill="black" stroke="black" points="1071.35,-243.66 1064.68,-251.89 1075.03,-249.61 1071.35,-243.66"/>
</g>
<!-- Protoc -->
<g id="node4" class="node">
<g id="node5" class="node">
<title>Protoc</title>
<polygon fill="royalblue" stroke="royalblue" points="1097.5,-197 992.5,-197 992.5,-193 988.5,-193 988.5,-189 992.5,-189 992.5,-169 988.5,-169 988.5,-165 992.5,-165 992.5,-161 1097.5,-161 1097.5,-197"/>
<polyline fill="none" stroke="royalblue" points="992.5,-193 996.5,-193 996.5,-189 992.5,-189 "/>
@@ -196,19 +207,19 @@
<polygon fill="black" stroke="black" points="1140.27,-333.11 1150.71,-334.96 1143.71,-327.01 1140.27,-333.11"/>
</g>
<!-- Eigen3 -->
<g id="node6" class="node">
<g id="node7" class="node">
<title>Eigen3</title>
<path fill="royalblue" stroke="royalblue" d="M1790,-106C1790,-106 1722,-106 1722,-106 1716,-106 1710,-100 1710,-94 1710,-94 1710,-82 1710,-82 1710,-76 1716,-70 1722,-70 1722,-70 1790,-70 1790,-70 1796,-70 1802,-76 1802,-82 1802,-82 1802,-94 1802,-94 1802,-100 1796,-106 1790,-106"/>
<text text-anchor="middle" x="1756" y="-84.3" font-family="Times,serif" font-size="14.00">Eigen3::eigen</text>
<path fill="royalblue" stroke="royalblue" d="M1981,-106C1981,-106 1913,-106 1913,-106 1907,-106 1901,-100 1901,-94 1901,-94 1901,-82 1901,-82 1901,-76 1907,-70 1913,-70 1913,-70 1981,-70 1981,-70 1987,-70 1993,-76 1993,-82 1993,-82 1993,-94 1993,-94 1993,-100 1987,-106 1981,-106"/>
<text text-anchor="middle" x="1947" y="-84.3" font-family="Times,serif" font-size="14.00">Eigen3::eigen</text>
</g>
<!-- CoinUtils -->
<g id="node7" class="node">
<g id="node8" class="node">
<title>CoinUtils</title>
<path fill="royalblue" stroke="royalblue" d="M321.5,-609C321.5,-609 242.5,-609 242.5,-609 236.5,-609 230.5,-603 230.5,-597 230.5,-597 230.5,-585 230.5,-585 230.5,-579 236.5,-573 242.5,-573 242.5,-573 321.5,-573 321.5,-573 327.5,-573 333.5,-579 333.5,-585 333.5,-585 333.5,-597 333.5,-597 333.5,-603 327.5,-609 321.5,-609"/>
<text text-anchor="middle" x="282" y="-587.3" font-family="Times,serif" font-size="14.00">Coin::CoinUtils</text>
</g>
<!-- Osi -->
<g id="node8" class="node">
<g id="node9" class="node">
<title>Osi</title>
<path fill="royalblue" stroke="royalblue" d="M104.5,-526C104.5,-526 59.5,-526 59.5,-526 53.5,-526 47.5,-520 47.5,-514 47.5,-514 47.5,-502 47.5,-502 47.5,-496 53.5,-490 59.5,-490 59.5,-490 104.5,-490 104.5,-490 110.5,-490 116.5,-496 116.5,-502 116.5,-502 116.5,-514 116.5,-514 116.5,-520 110.5,-526 104.5,-526"/>
<text text-anchor="middle" x="82" y="-504.3" font-family="Times,serif" font-size="14.00">Coin::Osi</text>
@@ -220,7 +231,7 @@
<polygon fill="black" stroke="black" points="228.8,-572.43 239.39,-572.91 231.42,-565.93 228.8,-572.43"/>
</g>
<!-- Clp -->
<g id="node9" class="node">
<g id="node10" class="node">
<title>Clp</title>
<path fill="royalblue" stroke="royalblue" d="M258,-443C258,-443 212,-443 212,-443 206,-443 200,-437 200,-431 200,-431 200,-419 200,-419 200,-413 206,-407 212,-407 212,-407 258,-407 258,-407 264,-407 270,-413 270,-419 270,-419 270,-431 270,-431 270,-437 264,-443 258,-443"/>
<text text-anchor="middle" x="235" y="-421.3" font-family="Times,serif" font-size="14.00">Coin::Clp</text>
@@ -238,7 +249,7 @@
<polygon fill="black" stroke="black" points="121.34,-482.21 114.14,-489.99 124.61,-488.4 121.34,-482.21"/>
</g>
<!-- OsiClp -->
<g id="node10" class="node">
<g id="node11" class="node">
<title>OsiClp</title>
<path fill="royalblue" stroke="royalblue" d="M152.5,-371C152.5,-371 87.5,-371 87.5,-371 81.5,-371 75.5,-365 75.5,-359 75.5,-359 75.5,-347 75.5,-347 75.5,-341 81.5,-335 87.5,-335 87.5,-335 152.5,-335 152.5,-335 158.5,-335 164.5,-341 164.5,-347 164.5,-347 164.5,-359 164.5,-359 164.5,-365 158.5,-371 152.5,-371"/>
<text text-anchor="middle" x="120" y="-349.3" font-family="Times,serif" font-size="14.00">Coin::OsiClp</text>
@@ -262,7 +273,7 @@
<polygon fill="black" stroke="black" points="196.4,-404.6 206.76,-406.81 200.04,-398.62 196.4,-404.6"/>
</g>
<!-- ClpSolver -->
<g id="node11" class="node">
<g id="node12" class="node">
<title>ClpSolver</title>
<path fill="royalblue" stroke="royalblue" d="M275.5,-371C275.5,-371 194.5,-371 194.5,-371 188.5,-371 182.5,-365 182.5,-359 182.5,-359 182.5,-347 182.5,-347 182.5,-341 188.5,-335 194.5,-335 194.5,-335 275.5,-335 275.5,-335 281.5,-335 287.5,-341 287.5,-347 287.5,-347 287.5,-359 287.5,-359 287.5,-365 281.5,-371 275.5,-371"/>
<text text-anchor="middle" x="235" y="-349.3" font-family="Times,serif" font-size="14.00">Coin::ClpSolver</text>
@@ -274,7 +285,7 @@
<polygon fill="black" stroke="black" points="231.5,-396.9 235,-406.9 238.5,-396.9 231.5,-396.9"/>
</g>
<!-- Cgl -->
<g id="node12" class="node">
<g id="node13" class="node">
<title>Cgl</title>
<path fill="royalblue" stroke="royalblue" d="M218,-288C218,-288 172,-288 172,-288 166,-288 160,-282 160,-276 160,-276 160,-264 160,-264 160,-258 166,-252 172,-252 172,-252 218,-252 218,-252 224,-252 230,-258 230,-264 230,-264 230,-276 230,-276 230,-282 224,-288 218,-288"/>
<text text-anchor="middle" x="195" y="-266.3" font-family="Times,serif" font-size="14.00">Coin::Cgl</text>
@@ -298,7 +309,7 @@
<polygon fill="black" stroke="black" points="140.11,-325.13 135.88,-334.85 145.24,-329.89 140.11,-325.13"/>
</g>
<!-- Cbc -->
<g id="node13" class="node">
<g id="node14" class="node">
<title>Cbc</title>
<path fill="royalblue" stroke="royalblue" d="M336,-197C336,-197 288,-197 288,-197 282,-197 276,-191 276,-185 276,-185 276,-173 276,-173 276,-167 282,-161 288,-161 288,-161 336,-161 336,-161 342,-161 348,-167 348,-173 348,-173 348,-185 348,-185 348,-191 342,-197 336,-197"/>
<text text-anchor="middle" x="312" y="-175.3" font-family="Times,serif" font-size="14.00">Coin::Cbc</text>
@@ -334,7 +345,7 @@
<polygon fill="black" stroke="black" points="223.33,-243.05 217.49,-251.89 227.57,-248.62 223.33,-243.05"/>
</g>
<!-- OsiCbc -->
<g id="node14" class="node">
<g id="node15" class="node">
<title>OsiCbc</title>
<path fill="royalblue" stroke="royalblue" d="M346.5,-106C346.5,-106 279.5,-106 279.5,-106 273.5,-106 267.5,-100 267.5,-94 267.5,-94 267.5,-82 267.5,-82 267.5,-76 273.5,-70 279.5,-70 279.5,-70 346.5,-70 346.5,-70 352.5,-70 358.5,-76 358.5,-82 358.5,-82 358.5,-94 358.5,-94 358.5,-100 352.5,-106 346.5,-106"/>
<text text-anchor="middle" x="313" y="-84.3" font-family="Times,serif" font-size="14.00">Coin::OsiCbc</text>
@@ -358,7 +369,7 @@
<polygon fill="black" stroke="black" points="308.8,-150.85 312.19,-160.89 315.8,-150.93 308.8,-150.85"/>
</g>
<!-- CbcSolver -->
<g id="node15" class="node">
<g id="node16" class="node">
<title>CbcSolver</title>
<path fill="royalblue" stroke="royalblue" d="M237.5,-106C237.5,-106 154.5,-106 154.5,-106 148.5,-106 142.5,-100 142.5,-94 142.5,-94 142.5,-82 142.5,-82 142.5,-76 148.5,-70 154.5,-70 154.5,-70 237.5,-70 237.5,-70 243.5,-70 249.5,-76 249.5,-82 249.5,-82 249.5,-94 249.5,-94 249.5,-100 243.5,-106 237.5,-106"/>
<text text-anchor="middle" x="196" y="-84.3" font-family="Times,serif" font-size="14.00">Coin::CbcSolver</text>
@@ -370,19 +381,19 @@
<polygon fill="black" stroke="black" points="279.64,-157.58 289.7,-160.89 283.9,-152.03 279.64,-157.58"/>
</g>
<!-- GLPK -->
<g id="node16" class="node">
<g id="node17" class="node">
<title>GLPK</title>
<path fill="royalblue" stroke="royalblue" d="M1987,-106C1987,-106 1939,-106 1939,-106 1933,-106 1927,-100 1927,-94 1927,-94 1927,-82 1927,-82 1927,-76 1933,-70 1939,-70 1939,-70 1987,-70 1987,-70 1993,-70 1999,-76 1999,-82 1999,-82 1999,-94 1999,-94 1999,-100 1993,-106 1987,-106"/>
<text text-anchor="middle" x="1963" y="-84.3" font-family="Times,serif" font-size="14.00">glpk::glpk</text>
<path fill="royalblue" stroke="royalblue" d="M2178,-106C2178,-106 2130,-106 2130,-106 2124,-106 2118,-100 2118,-94 2118,-94 2118,-82 2118,-82 2118,-76 2124,-70 2130,-70 2130,-70 2178,-70 2178,-70 2184,-70 2190,-76 2190,-82 2190,-82 2190,-94 2190,-94 2190,-100 2184,-106 2178,-106"/>
<text text-anchor="middle" x="2154" y="-84.3" font-family="Times,serif" font-size="14.00">glpk::glpk</text>
</g>
<!-- HIGHS -->
<g id="node17" class="node">
<g id="node18" class="node">
<title>HIGHS</title>
<path fill="royalblue" stroke="royalblue" d="M2293.5,-106C2293.5,-106 2234.5,-106 2234.5,-106 2228.5,-106 2222.5,-100 2222.5,-94 2222.5,-94 2222.5,-82 2222.5,-82 2222.5,-76 2228.5,-70 2234.5,-70 2234.5,-70 2293.5,-70 2293.5,-70 2299.5,-70 2305.5,-76 2305.5,-82 2305.5,-82 2305.5,-94 2305.5,-94 2305.5,-100 2299.5,-106 2293.5,-106"/>
<text text-anchor="middle" x="2264" y="-84.3" font-family="Times,serif" font-size="14.00">highs::highs</text>
<path fill="royalblue" stroke="royalblue" d="M2484.5,-106C2484.5,-106 2425.5,-106 2425.5,-106 2419.5,-106 2413.5,-100 2413.5,-94 2413.5,-94 2413.5,-82 2413.5,-82 2413.5,-76 2419.5,-70 2425.5,-70 2425.5,-70 2484.5,-70 2484.5,-70 2490.5,-70 2496.5,-76 2496.5,-82 2496.5,-82 2496.5,-94 2496.5,-94 2496.5,-100 2490.5,-106 2484.5,-106"/>
<text text-anchor="middle" x="2455" y="-84.3" font-family="Times,serif" font-size="14.00">highs::highs</text>
</g>
<!-- SPX -->
<g id="node18" class="node">
<g id="node19" class="node">
<title>SPX</title>
<path fill="royalblue" stroke="royalblue" d="M546,-197C546,-197 504,-197 504,-197 498,-197 492,-191 492,-185 492,-185 492,-173 492,-173 492,-167 498,-161 504,-161 504,-161 546,-161 546,-161 552,-161 558,-167 558,-173 558,-173 558,-185 558,-185 558,-191 552,-197 546,-197"/>
<text text-anchor="middle" x="525" y="-175.3" font-family="Times,serif" font-size="14.00">libsoplex</text>
@@ -394,7 +405,7 @@
<polygon fill="black" stroke="black" points="543.45,-243.6 550.04,-251.89 550.06,-241.3 543.45,-243.6"/>
</g>
<!-- SCIP -->
<g id="node19" class="node">
<g id="node20" class="node">
<title>SCIP</title>
<path fill="royalblue" stroke="royalblue" d="M562.5,-106C562.5,-106 497.5,-106 497.5,-106 491.5,-106 485.5,-100 485.5,-94 485.5,-94 485.5,-82 485.5,-82 485.5,-76 491.5,-70 497.5,-70 497.5,-70 562.5,-70 562.5,-70 568.5,-70 574.5,-76 574.5,-82 574.5,-82 574.5,-94 574.5,-94 574.5,-100 568.5,-106 562.5,-106"/>
<text text-anchor="middle" x="530" y="-84.3" font-family="Times,serif" font-size="14.00">SCIP::libscip</text>
@@ -412,7 +423,7 @@
<polygon fill="black" stroke="black" points="523.03,-150.71 525.96,-160.89 530.02,-151.1 523.03,-150.71"/>
</g>
<!-- gtest -->
<g id="node20" class="node">
<g id="node21" class="node">
<title>gtest</title>
<path fill="royalblue" stroke="royalblue" d="M923.5,-197C923.5,-197 864.5,-197 864.5,-197 858.5,-197 852.5,-191 852.5,-185 852.5,-185 852.5,-173 852.5,-173 852.5,-167 858.5,-161 864.5,-161 864.5,-161 923.5,-161 923.5,-161 929.5,-161 935.5,-167 935.5,-173 935.5,-173 935.5,-185 935.5,-185 935.5,-191 929.5,-197 923.5,-197"/>
<text text-anchor="middle" x="894" y="-175.3" font-family="Times,serif" font-size="14.00">GTest::gtest</text>
@@ -430,7 +441,7 @@
<polygon fill="black" stroke="black" points="1014.11,-246.86 1023.46,-251.85 1019.26,-242.12 1014.11,-246.86"/>
</g>
<!-- bench -->
<g id="node21" class="node">
<g id="node22" class="node">
<title>bench</title>
<path fill="royalblue" stroke="royalblue" d="M816,-106C816,-106 694,-106 694,-106 688,-106 682,-100 682,-94 682,-94 682,-82 682,-82 682,-76 688,-70 694,-70 694,-70 816,-70 816,-70 822,-70 828,-76 828,-82 828,-82 828,-94 828,-94 828,-100 822,-106 816,-106"/>
<text text-anchor="middle" x="755" y="-84.3" font-family="Times,serif" font-size="14.00">benchmark::benchmark</text>
@@ -442,7 +453,7 @@
<polygon fill="black" stroke="black" points="856.97,-158.45 867.28,-160.89 860.75,-152.55 856.97,-158.45"/>
</g>
<!-- fuzz -->
<g id="node22" class="node">
<g id="node23" class="node">
<title>fuzz</title>
<path fill="royalblue" stroke="royalblue" d="M948,-106C948,-106 864,-106 864,-106 858,-106 852,-100 852,-94 852,-94 852,-82 852,-82 852,-76 858,-70 864,-70 864,-70 948,-70 948,-70 954,-70 960,-76 960,-82 960,-82 960,-94 960,-94 960,-100 954,-106 948,-106"/>
<text text-anchor="middle" x="906" y="-84.3" font-family="Times,serif" font-size="14.00">fuzztest::fuzztest</text>
@@ -472,13 +483,13 @@
<polygon fill="black" stroke="black" points="894.17,-150.51 896.31,-160.89 901.11,-151.45 894.17,-150.51"/>
</g>
<!-- Pybind11 -->
<g id="node23" class="node">
<g id="node24" class="node">
<title>Pybind11</title>
<path fill="royalblue" stroke="royalblue" d="M1598,-197C1598,-197 1496,-197 1496,-197 1490,-197 1484,-191 1484,-185 1484,-185 1484,-173 1484,-173 1484,-167 1490,-161 1496,-161 1496,-161 1598,-161 1598,-161 1604,-161 1610,-167 1610,-173 1610,-173 1610,-185 1610,-185 1610,-191 1604,-197 1598,-197"/>
<text text-anchor="middle" x="1547" y="-175.3" font-family="Times,serif" font-size="14.00">pybind11::pybind11</text>
</g>
<!-- Pybind11Absl -->
<g id="node24" class="node">
<g id="node25" class="node">
<title>Pybind11Absl</title>
<path fill="royalblue" stroke="royalblue" d="M1665,-106C1665,-106 1525,-106 1525,-106 1519,-106 1513,-100 1513,-94 1513,-94 1513,-82 1513,-82 1513,-76 1519,-70 1525,-70 1525,-70 1665,-70 1665,-70 1671,-70 1677,-76 1677,-82 1677,-82 1677,-94 1677,-94 1677,-100 1671,-106 1665,-106"/>
<text text-anchor="middle" x="1595" y="-84.3" font-family="Times,serif" font-size="14.00">pybind11::pybind11_abseil</text>
@@ -496,7 +507,7 @@
<polygon fill="black" stroke="black" points="1557.89,-150.43 1556.23,-160.89 1564.05,-153.75 1557.89,-150.43"/>
</g>
<!-- Pybind11Protobuf -->
<g id="node25" class="node">
<g id="node26" class="node">
<title>Pybind11Protobuf</title>
<path fill="royalblue" stroke="royalblue" d="M1476.5,-106C1476.5,-106 1321.5,-106 1321.5,-106 1315.5,-106 1309.5,-100 1309.5,-94 1309.5,-94 1309.5,-82 1309.5,-82 1309.5,-76 1315.5,-70 1321.5,-70 1321.5,-70 1476.5,-70 1476.5,-70 1482.5,-70 1488.5,-76 1488.5,-82 1488.5,-82 1488.5,-94 1488.5,-94 1488.5,-100 1482.5,-106 1476.5,-106"/>
<text text-anchor="middle" x="1399" y="-84.3" font-family="Times,serif" font-size="14.00">pybind11::pybind11_protobuf</text>

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 33 KiB

View File

@@ -11,6 +11,10 @@ if(NOT TARGET ZLIB::ZLIB)
find_dependency(ZLIB REQUIRED)
endif()
if(NOT TARGET BZip2::BZip2)
find_dependency(BZip2 REQUIRED)
endif()
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.9.6")
set(CONFIG_FLAG CONFIG)
endif()

View File

@@ -26,6 +26,10 @@ if(NOT BUILD_ZLIB AND NOT TARGET ZLIB::ZLIB)
find_package(ZLIB REQUIRED)
endif()
if(NOT BUILD_BZip2 AND NOT TARGET BZip2::BZip2)
find_package(BZip2 REQUIRED)
endif()
if(NOT BUILD_absl AND NOT TARGET absl::base)
find_package(absl REQUIRED)
endif()

View File

@@ -246,7 +246,6 @@ cc_library(
"helpers.h",
"options.h",
],
defines = ["USE_BZIP2"],
deps = [
":status_macros",
"@abseil-cpp//absl/log",

View File

@@ -35,6 +35,7 @@ target_include_directories(${NAME} PRIVATE
${PROJECT_BINARY_DIR})
target_link_libraries(${NAME} PRIVATE
ZLIB::ZLIB
BZip2::BZip2
absl::base
absl::strings
absl::str_format

View File

@@ -16,12 +16,9 @@
#include <sys/stat.h>
#include <sys/types.h>
#if defined(USE_BZIP2)
#include <bzlib.h>
#endif
#include <zlib.h>
#include <cerrno>
#include <cstdint>
#if defined(_MSC_VER)
#include <io.h>
#define access _access
@@ -33,7 +30,6 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream> // NOLINT
#include <memory>
#include <string>
@@ -42,16 +38,14 @@
#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
#include "bzlib.h"
#include "google/protobuf/io/tokenizer.h"
#include "google/protobuf/message.h"
#include "google/protobuf/text_format.h"
#include "zlib.h"
namespace {
enum class Format {
NORMAL_FILE,
GZIP_FILE,
BZIP2_FILE
};
enum class Format { NORMAL_FILE, GZIP_FILE, BZIP2_FILE };
static Format GetFormatFromName(absl::string_view name) {
const int size = name.size();
@@ -67,7 +61,7 @@ static Format GetFormatFromName(absl::string_view name) {
class CFile : public File {
public:
CFile(FILE* c_file, absl::string_view name) : File(name), f_(c_file) {}
virtual ~CFile() = default;
~CFile() override = default;
// Reads "size" bytes to buf from file, buf should be pre-allocated.
size_t Read(void* buf, size_t size) override {
@@ -80,7 +74,7 @@ class CFile : public File {
}
// Closes the file and delete the underlying FILE* descriptor.
absl::Status Close(int flags) override {
absl::Status Close(int /*flags*/) override {
absl::Status status;
if (f_ == nullptr) {
return status;
@@ -113,50 +107,48 @@ class CFile : public File {
};
class GzFile : public File {
public:
public:
GzFile(gzFile gz_file, absl::string_view name) : File(name), f_(gz_file) {}
virtual ~GzFile() = default;
~GzFile() override = default;
// Reads "size" bytes to buf from file, buf should be pre-allocated.
size_t Read(void* buf, size_t size) override {
return gzread(f_, buf, size);
}
// Reads "size" bytes to buf from file, buf should be pre-allocated.
size_t Read(void* buf, size_t size) override { return gzread(f_, buf, size); }
// Writes "size" bytes of buf to file, buf should be pre-allocated.
size_t Write(const void* buf, size_t size) override {
return gzwrite(f_, buf, size);
}
// Writes "size" bytes of buf to file, buf should be pre-allocated.
size_t Write(const void* buf, size_t size) override {
return gzwrite(f_, buf, size);
}
// Closes the file and delete the underlying FILE* descriptor.
absl::Status Close(int flags) override {
absl::Status status;
if (f_ == nullptr) {
return status;
}
if (gzclose(f_) == 0) {
f_ = nullptr;
} else {
status.Update(
absl::Status(absl::StatusCode::kInvalidArgument,
absl::StrCat("Could not close file '", name_, "'")));
}
delete this;
return status;
}
// Flushes buffer.
bool Flush() override { return gzflush(f_, Z_FINISH) == Z_OK; }
// Returns file size.
size_t Size() override {
// Closes the file and delete the underlying FILE* descriptor.
absl::Status Close(int /*flags*/) override {
absl::Status status;
if (f_ == nullptr) {
return status;
}
if (gzclose(f_) == 0) {
f_ = nullptr;
} else {
status.Update(
absl::Status(absl::StatusCode::kInvalidArgument,
absl::StrCat("Could not close file '", name_, "'")));
}
delete this;
return status;
}
// Flushes buffer.
bool Flush() override { return gzflush(f_, Z_FINISH) == Z_OK; }
// Returns file size.
size_t Size() override {
gzFile file;
std::string null_terminated_name = std::string(name_);
#if defined(_MSC_VER)
file = gzopen (null_terminated_name.c_str(), "rb");
#else
file = gzopen (null_terminated_name.c_str(), "r");
#endif
if (! file) {
#if defined(_MSC_VER)
file = gzopen(null_terminated_name.c_str(), "rb");
#else
file = gzopen(null_terminated_name.c_str(), "r");
#endif
if (!file) {
LOG(FATAL) << "Cannot get the size of '" << name_
<< "': " << strerror(errno);
}
@@ -164,7 +156,7 @@ class GzFile : public File {
const int kLength = 5 * 1024;
unsigned char buffer[kLength];
size_t uncompressed_size = 0;
while (1) {
while (true) {
int err;
int bytes_read;
bytes_read = gzread(file, buffer, kLength - 1);
@@ -183,54 +175,53 @@ class GzFile : public File {
}
gzclose(file);
return uncompressed_size;
}
}
bool Open() const override { return f_ != nullptr; }
private:
gzFile f_;
};
bool Open() const override { return f_ != nullptr; }
#if defined(USE_BZIP2)
class Bz2File : public File {
public:
private:
gzFile f_;
};
class Bz2File : public File {
public:
Bz2File(BZFILE* bz_file, absl::string_view name) : File(name), f_(bz_file) {}
virtual ~Bz2File() = default;
// Reads "size" bytes to buf from file, buf should be pre-allocated.
size_t Read(void* buf, size_t size) override {
return BZ2_bzread(f_, buf, size);
}
// Writes "size" bytes of buf to file, buf should be pre-allocated.
size_t Write(const void* buf, size_t size) override {
return BZ2_bzwrite(f_, const_cast<void*>(buf), size);
}
// Closes the file and delete the underlying FILE* descriptor.
absl::Status Close(int flags) override {
absl::Status status;
if (f_ == nullptr) {
return absl::OkStatus();
}
BZ2_bzclose(f_);
f_ = nullptr;
delete this;
return absl::OkStatus();
}
// Flushes buffer.
bool Flush() override { return BZ2_bzflush(f_) == 0; }
// Returns file size.
size_t Size() override {
~Bz2File() override = default;
// Reads "size" bytes to buf from file, buf should be pre-allocated.
size_t Read(void* buf, size_t size) override {
return BZ2_bzread(f_, buf, size);
}
// Writes "size" bytes of buf to file, buf should be pre-allocated.
size_t Write(const void* buf, size_t size) override {
return BZ2_bzwrite(f_, const_cast<void*>(buf), size);
}
// Closes the file and delete the underlying FILE* descriptor.
absl::Status Close(int /*flags*/) override {
absl::Status status;
if (f_ == nullptr) {
return absl::OkStatus();
}
BZ2_bzclose(f_);
f_ = nullptr;
delete this;
return absl::OkStatus();
}
// Flushes buffer.
bool Flush() override { return BZ2_bzflush(f_) == 0; }
// Returns file size.
size_t Size() override {
BZFILE* file;
std::string null_terminated_name = std::string(name_);
#if defined(_MSC_VER)
file = BZ2_bzopen (null_terminated_name.c_str(), "rb");
#else
file = BZ2_bzopen (null_terminated_name.c_str(), "r");
#endif
#if defined(_MSC_VER)
file = BZ2_bzopen(null_terminated_name.c_str(), "rb");
#else
file = BZ2_bzopen(null_terminated_name.c_str(), "r");
#endif
if (!file) {
LOG(FATAL) << "Cannot get the size of '" << name_
<< "': " << strerror(errno);
@@ -239,8 +230,7 @@ class GzFile : public File {
const int kLength = 5 * 1024;
unsigned char buffer[kLength];
size_t uncompressed_size = 0;
while (1) {
int err;
while (true) {
int bytes_read;
bytes_read = BZ2_bzread(file, buffer, kLength - 1);
uncompressed_size += bytes_read;
@@ -248,15 +238,14 @@ class GzFile : public File {
}
BZ2_bzclose(file);
return uncompressed_size;
}
bool Open() const override { return f_ != nullptr; }
private:
BZFILE* f_;
};
#endif // USE_BZIP2
}
bool Open() const override { return f_ != nullptr; }
private:
BZFILE* f_;
};
} // namespace
File::File(absl::string_view name) : name_(name) {}
@@ -292,17 +281,14 @@ File* File::Open(absl::string_view file_name, absl::string_view mode) {
return new GzFile(gz_file, file_name);
}
case Format::BZIP2_FILE: {
#if defined(USE_BZIP2)
BZFILE* bz_file =
BZ2_bzopen(null_terminated_name.c_str(), null_terminated_mode.c_str());
BZFILE* bz_file = BZ2_bzopen(null_terminated_name.c_str(),
null_terminated_mode.c_str());
if (!bz_file) return nullptr;
return new Bz2File(bz_file, file_name);
#else
LOG(ERROR) << "Using bzip2 files is not supported";
return nullptr;
#endif
}
}
// never reach
return nullptr;
}
int64_t File::ReadToString(std::string* line, uint64_t max_length) {
@@ -399,8 +385,8 @@ absl::Status WriteString(File* file, absl::string_view contents,
absl::StrCat("Could not write ", contents.size(), " bytes"));
}
absl::Status SetContents(absl::string_view file_name, absl::string_view contents,
Options options) {
absl::Status SetContents(absl::string_view file_name,
absl::string_view contents, Options options) {
File* file;
// For windows, the "b" is added in file::Open.
auto status = file::Open(file_name, "w", &file, options);
@@ -430,12 +416,12 @@ absl::Status GetTextProto(absl::string_view file_name,
absl::StrCat("Could not read proto from '", file_name, "'."));
}
// Attempt to decode ASCII before deciding binary. Do it in this order because
// it is much harder for a binary encoding to happen to be a valid ASCII
// encoding than the other way around. For instance "index: 1\n" is a valid
// (but nonsensical) binary encoding. We want to avoid printing errors for
// valid binary encodings if the ASCII parsing fails, and so specify a no-op
// error collector.
// Attempt to decode ASCII before deciding binary. Do it in this order
// because it is much harder for a binary encoding to happen to be a valid
// ASCII encoding than the other way around. For instance "index: 1\n" is a
// valid (but nonsensical) binary encoding. We want to avoid printing errors
// for valid binary encodings if the ASCII parsing fails, and so specify a
// no-op error collector.
NoOpErrorCollector error_collector;
google::protobuf::TextFormat::Parser parser;
parser.RecordErrorsTo(&error_collector);

View File

@@ -14,6 +14,7 @@
#ifndef OR_TOOLS_BASE_FILE_H_
#define OR_TOOLS_BASE_FILE_H_
#include <cstddef>
#include <cstdint>
#include <string>
@@ -39,7 +40,7 @@ class File {
static File* OpenOrDie(absl::string_view file_name, absl::string_view mode);
#endif // SWIG
File(absl::string_view name);
explicit File(absl::string_view name);
virtual ~File() = default;
// Reads "size" bytes to buf from file, buff should be pre-allocated.
@@ -57,7 +58,7 @@ class File {
// Returns file size.
virtual size_t Size() = 0;
// Returns wether the file is currently open.
// Returns whether the file is currently open.
virtual bool Open() const = 0;
// Reads the whole file to a string, with a maximum length of 'max_length'.
@@ -106,8 +107,8 @@ absl::StatusOr<std::string> GetContents(absl::string_view path,
absl::Status GetContents(absl::string_view file_name, std::string* output,
Options options);
absl::Status SetContents(absl::string_view file_name, absl::string_view contents,
Options options);
absl::Status SetContents(absl::string_view file_name,
absl::string_view contents, Options options);
absl::Status WriteString(File* file, absl::string_view contents,
Options options);

View File

@@ -516,8 +516,6 @@ bool AbslParseFlag(absl::string_view text,
value = static_cast<ValueType>(larger_value);
}
// TODO(user): We shouldn't crash in flag parsing.
// Validator should be re-tooled to return meaningful values.
*out = StrongInt<TagType, ValueType, ValidatorType>(value);
return true;
}
@@ -693,6 +691,7 @@ StrongIntRange<IntType> MakeStrongIntRange(IntType begin, IntType end) {
// Numeric_limits override for strong int.
namespace std {
// Allow StrongInt to be used as a key to hashable containers.
// NOLINTNEXTLINE(google3-runtime-std-hash-specialization)
template <typename Tag, typename Value, typename Validator>
struct hash<util_intops::StrongInt<Tag, Value, Validator>>
: ::util_intops::StrongInt<Tag, Value, Validator>::Hasher {};

View File

@@ -181,7 +181,7 @@ TYPED_TEST(StrongIntTest, TestCtors) {
EXPECT_EQ(V(93), x.value());
// It is undefined to init an unsigned int from a negative float.
if (std::numeric_limits<V>::is_signed) {
if constexpr (std::numeric_limits<V>::is_signed) {
float j = -76.1;
T y(j);
EXPECT_EQ(V(-76.1), y.value());
@@ -194,7 +194,7 @@ TYPED_TEST(StrongIntTest, TestCtors) {
EXPECT_EQ(V(93), x.value());
// It is undefined to init an unsigned int from a negative double.
if (std::numeric_limits<V>::is_signed) {
if constexpr (std::numeric_limits<V>::is_signed) {
double j = -76.1;
T y(j);
EXPECT_EQ(V(-76.1), y.value());
@@ -207,7 +207,7 @@ TYPED_TEST(StrongIntTest, TestCtors) {
EXPECT_EQ(V(93), x.value());
// It is undefined to init an unsigned int from a negative long double.
if (std::numeric_limits<V>::is_signed) {
if constexpr (std::numeric_limits<V>::is_signed) {
long double j = -76.1;
T y(j);
EXPECT_EQ(V(-76.1), y.value());
@@ -312,7 +312,7 @@ TYPED_TEST(StrongIntTest, TestAbslParseFlagInvalid) {
T t;
std::string error;
if (std::numeric_limits<V>::is_signed) {
if constexpr (std::numeric_limits<V>::is_signed) {
EXPECT_DEATH(absl::ParseFlag("-123", &t, &error), "PositiveValidator");
} else {
EXPECT_FALSE(absl::ParseFlag("-123", &t, &error));
@@ -323,7 +323,7 @@ TYPED_TEST(StrongIntTest, TestAbslParseFlagInvalid) {
TYPED_TEST(StrongIntTest, TestCtorDeath) {
using V = typename TestFixture::V;
if (std::numeric_limits<V>::is_signed) {
if constexpr (std::numeric_limits<V>::is_signed) {
struct CustomTag {};
using T = StrongInt<CustomTag, V, PositiveValidator>;
EXPECT_DEATH(T(static_cast<V>(-123)), "PositiveValidator");
@@ -509,7 +509,7 @@ TYPED_TEST(StrongIntTest, TestMultiplyOperators) {
// Test positive vs. positive multiplication.
TEST_T_OP_NUM(9, *, V, 3);
TEST_NUM_OP_T(V, 9, *, 3);
if (std::is_signed<V>::value) {
if constexpr (std::is_signed<V>::value) {
// Test negative vs. positive multiplication.
TEST_T_OP_NUM(-9, *, V, 3);
TEST_NUM_OP_T(V, -9, *, 3);
@@ -526,7 +526,7 @@ TYPED_TEST(StrongIntTest, TestMultiplyOperators) {
// Test multiplication by zero.
TEST_T_OP_NUM(93, *, V, 0);
TEST_NUM_OP_T(V, 93, *, 0);
if (std::is_signed<V>::value) {
if constexpr (std::is_signed<V>::value) {
// Test multiplication by a negative.
TEST_T_OP_NUM(93, *, V, -1);
TEST_NUM_OP_T(V, 93, *, -1);
@@ -574,16 +574,20 @@ TYPED_TEST(StrongIntTest, TestDivideOperators) {
// Test positive vs. positive division.
TEST_T_OP_NUM(9, /, V, 3);
// Test negative vs. positive division.
TEST_T_OP_NUM(-9, /, V, 3);
// Test positive vs. negative division.
TEST_T_OP_NUM(9, /, V, -3);
// Test negative vs. negative division.
TEST_T_OP_NUM(-9, /, V, -3);
if constexpr (std::is_signed<V>::value) {
// Test negative vs. positive division.
TEST_T_OP_NUM(-9, /, V, 3);
// Test positive vs. negative division.
TEST_T_OP_NUM(9, /, V, -3);
// Test negative vs. negative division.
TEST_T_OP_NUM(-9, /, V, -3);
}
// Test division by one.
TEST_T_OP_NUM(93, /, V, 1);
// Test division by a negative.
TEST_T_OP_NUM(93, /, V, -1);
if constexpr (std::is_signed<V>::value) {
// Test division by a negative.
TEST_T_OP_NUM(93, /, V, -1);
}
// Test division by int8_t.
TEST_T_OP_NUM(93, /, int8_t, 2);
// Test division by uint8_t.

161
patches/bzip2.patch Normal file
View File

@@ -0,0 +1,161 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c4b0b6e..bd3aca3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,10 @@
cmake_minimum_required(VERSION 3.12)
+# option() honors normal variables.
+if (POLICY CMP0077)
+ cmake_policy(SET CMP0077 NEW)
+endif()
+
project(bzip2
VERSION 1.1.0
DESCRIPTION "This Bzip2/libbz2 a program and library for lossless block-sorting data compression."
@@ -283,8 +288,8 @@ set(BZ2_SOURCES
add_library(bz2_ObjLib OBJECT)
target_sources(bz2_ObjLib
PRIVATE ${BZ2_SOURCES}
- PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/bzlib_private.h
- INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/bzlib.h)
+ bzlib_private.h
+ bzlib.h)
# Windows resource file
set(BZ2_RES "")
@@ -301,10 +306,14 @@ if(ENABLE_SHARED_LIB)
# The libbz2 shared library.
add_library(bz2 SHARED ${BZ2_RES})
target_sources(bz2
- PRIVATE ${BZ2_SOURCES}
- ${CMAKE_CURRENT_SOURCE_DIR}/libbz2.def
- PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/bzlib_private.h
- INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/bzlib.h)
+ PRIVATE ${BZ2_SOURCES}
+ libbz2.def
+ bzlib_private.h
+ bzlib.h)
+ target_include_directories(bz2 PUBLIC
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
+ $<INSTALL_INTERFACE:include>
+ )
# Always use '-fPIC'/'-fPIE' option for shared libraries.
set_property(TARGET bz2 PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -312,8 +321,11 @@ if(ENABLE_SHARED_LIB)
set_target_properties(bz2 PROPERTIES
COMPILE_FLAGS "${WARNCFLAGS}"
VERSION ${LT_VERSION} SOVERSION ${LT_SOVERSION})
- install(TARGETS bz2 DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ install(TARGETS bz2
+ EXPORT ${PROJECT_NAME}Targets
+ DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES bzlib.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+ add_library(BZip2::BZip2 ALIAS bz2)
if(USE_OLD_SONAME)
# Hack to support the old libbz2.so.1.0 version by including an extra copy.
@@ -323,16 +335,22 @@ if(ENABLE_SHARED_LIB)
add_library(bz2_old_soname SHARED ${BZ2_RES})
target_sources(bz2_old_soname
PRIVATE ${BZ2_SOURCES}
- ${CMAKE_CURRENT_SOURCE_DIR}/libbz2.def
- PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/bzlib_private.h
- INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/bzlib.h
+ libbz2.def
+ bzlib_private.h
+ bzlib.h
+ )
+ target_include_directories(bz2_old_soname PUBLIC
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
+ $<INSTALL_INTERFACE:include>
)
set_target_properties(bz2_old_soname PROPERTIES
COMPILE_FLAGS "${WARNCFLAGS}"
VERSION ${LT_SOVERSION}.${LT_AGE} SOVERSION ${LT_SOVERSION}.${LT_AGE}
OUTPUT_NAME bz2
)
- install(TARGETS bz2_old_soname DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ install(TARGETS bz2_old_soname
+ EXPORT ${PROJECT_NAME}Targets
+ DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
endif()
endif()
@@ -341,9 +359,13 @@ if(ENABLE_STATIC_LIB)
# The libbz2 static library.
add_library(bz2_static STATIC)
target_sources(bz2_static
- PRIVATE ${BZ2_SOURCES}
- PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/bzlib_private.h
- INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/bzlib.h)
+ PRIVATE ${BZ2_SOURCES}
+ bzlib_private.h
+ bzlib.h)
+ target_include_directories(bz2_static PUBLIC
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
+ $<INSTALL_INTERFACE:include>
+ )
# Use '-fPIC'/'-fPIE' option for static libraries by default.
# You may build with ENABLE_STATIC_LIB_IS_PIC=OFF to disable PIC for the static library.
@@ -357,8 +379,13 @@ if(ENABLE_STATIC_LIB)
SOVERSION ${LT_SOVERSION}
ARCHIVE_OUTPUT_NAME bz2_static)
target_compile_definitions(bz2_static PUBLIC BZ2_STATICLIB)
- install(TARGETS bz2_static DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ install(TARGETS bz2_static
+ EXPORT ${PROJECT_NAME}Targets
+ DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES bzlib.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+ if(NOT TARGET bz2)
+ add_library(BZip2::BZip2 ALIAS bz2_static)
+ endif()
endif()
if(ENABLE_APP)
@@ -373,7 +400,9 @@ if(ENABLE_APP)
else()
target_compile_definitions(bzip2 PUBLIC BZ_LCCWIN32=0 BZ_UNIX)
endif()
- install(TARGETS bzip2 DESTINATION ${CMAKE_INSTALL_BINDIR})
+ install(TARGETS bzip2
+ EXPORT ${PROJECT_NAME}Targets
+ DESTINATION ${CMAKE_INSTALL_BINDIR})
# Create bzip2 copies bzcat and bunzip.
# The default behavior is altered in bzip2.c code by checking the program name.
@@ -391,7 +420,9 @@ if(ENABLE_APP)
else()
target_compile_definitions(bzip2recover PUBLIC BZ_LCCWIN32=0 BZ_UNIX)
endif()
- install(TARGETS bzip2recover DESTINATION ${CMAKE_INSTALL_BINDIR})
+ install(TARGETS bzip2recover
+ EXPORT ${PROJECT_NAME}Targets
+ DESTINATION ${CMAKE_INSTALL_BINDIR})
if(ENABLE_EXAMPLES)
if(ENABLE_SHARED_LIB)
@@ -400,7 +431,9 @@ if(ENABLE_APP)
target_sources(dlltest
PRIVATE dlltest.c)
target_link_libraries(dlltest bz2)
- install(TARGETS dlltest DESTINATION ${CMAKE_INSTALL_BINDIR})
+ install(TARGETS dlltest
+ EXPORT ${PROJECT_NAME}Targets
+ DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
endif()
@@ -419,6 +452,10 @@ if(ENABLE_APP)
endif()
+install(EXPORT ${PROJECT_NAME}Targets
+ NAMESPACE BZip2::
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
+
if(ENABLE_APP AND Python3_FOUND)
enable_testing()
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})