Skip to content

Commit

Permalink
Merge pull request #10860 from rouault/vrt_optional
Browse files Browse the repository at this point in the history
Allow to partially disable VRT driver with GDAL_ENABLE_VRT_DRIVER=OFF ; GTI driver as optional
  • Loading branch information
rouault authored Sep 30, 2024
2 parents aef927b + 3a5c02e commit 1eedc9b
Show file tree
Hide file tree
Showing 90 changed files with 859 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmake_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ jobs:
shell: bash -l {0}
run: |
rm -f build/CMakeCache.txt
cmake -A ${architecture} -G "${generator}" "-DCMAKE_PREFIX_PATH=${CONDA}/envs/gdalenv" -Werror=dev "-DCMAKE_CXX_COMPILER_LAUNCHER=clcache" -DCMAKE_UNITY_BUILD=${CMAKE_UNITY_BUILD} -S "$GITHUB_WORKSPACE" -B "$GITHUB_WORKSPACE/build" -DCMAKE_C_FLAGS=" /WX" -DCMAKE_CXX_FLAGS=" /WX" -DGDAL_USE_EXTERNAL_LIBS:BOOL=OFF -DGDAL_USE_PNG_INTERNAL=OFF -DGDAL_USE_JPEG_INTERNAL=OFF -DGDAL_USE_JPEG12_INTERNAL=OFF -DGDAL_USE_GIF_INTERNAL=OFF -DGDAL_USE_LERC_INTERNAL=OFF -DGDAL_USE_LERCV1_INTERNAL=OFF -DGDAL_USE_QHULL_INTERNAL=OFF -DGDAL_USE_OPENCAD_INTERNAL=OFF -DGDAL_BUILD_OPTIONAL_DRIVERS=OFF -DOGR_BUILD_OPTIONAL_DRIVERS=OFF -DWERROR_DEV_FLAG="-Werror=dev"
cmake -A ${architecture} -G "${generator}" "-DCMAKE_PREFIX_PATH=${CONDA}/envs/gdalenv" -Werror=dev "-DCMAKE_CXX_COMPILER_LAUNCHER=clcache" -DCMAKE_UNITY_BUILD=${CMAKE_UNITY_BUILD} -S "$GITHUB_WORKSPACE" -B "$GITHUB_WORKSPACE/build" -DCMAKE_C_FLAGS=" /WX" -DCMAKE_CXX_FLAGS=" /WX" -DGDAL_USE_EXTERNAL_LIBS:BOOL=OFF -DGDAL_USE_PNG_INTERNAL=OFF -DGDAL_USE_JPEG_INTERNAL=OFF -DGDAL_USE_JPEG12_INTERNAL=OFF -DGDAL_USE_GIF_INTERNAL=OFF -DGDAL_USE_LERC_INTERNAL=OFF -DGDAL_USE_LERCV1_INTERNAL=OFF -DGDAL_USE_QHULL_INTERNAL=OFF -DGDAL_USE_OPENCAD_INTERNAL=OFF -DGDAL_BUILD_OPTIONAL_DRIVERS=OFF -DOGR_BUILD_OPTIONAL_DRIVERS=OFF -DGDAL_ENABLE_DRIVER_DERIVED=ON -DWERROR_DEV_FLAG="-Werror=dev"
- name: Build
shell: bash -l {0}
run: cmake --build $GITHUB_WORKSPACE/build --config RelWithDebInfo -j 2
Expand Down
5 changes: 5 additions & 0 deletions apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ if (BUILD_APPS)
target_compile_definitions(${UTILCMD} PRIVATE -DSUPPORTS_WMAIN)
endif ()
target_link_libraries(${UTILCMD} PRIVATE $<TARGET_NAME:${GDAL_LIB_TARGET_NAME}> utils_common)

if (NOT GDAL_ENABLE_DRIVER_GTI OR GDAL_ENABLE_DRIVER_GTI_PLUGIN)
target_compile_definitions(${UTILCMD} PRIVATE -DGTI_DRIVER_DISABLED_OR_PLUGIN)
endif()

endforeach ()
install(TARGETS ${APPS_TARGETS} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

Expand Down
12 changes: 12 additions & 0 deletions apps/gdaladdo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,17 @@ static bool PartialRefreshFromSourceTimestamp(
}
}
}
#ifdef GTI_DRIVER_DISABLED_OR_PLUGIN
else if (poDS->GetDriver() &&
EQUAL(poDS->GetDriver()->GetDescription(), "GTI"))
{
CPLError(CE_Failure, CPLE_NotSupported,
"--partial-refresh-from-source-timestamp only works on a GTI "
"dataset if the GTI driver is not built as a plugin, "
"but in core library");
return false;
}
#else
else if (auto poGTIDS = GDALDatasetCastToGTIDataset(poDS))
{
regions = GTIGetSourcesMoreRecentThan(poGTIDS, sStatVRTOvr.st_mtime);
Expand All @@ -320,6 +331,7 @@ static bool PartialRefreshFromSourceTimestamp(
static_cast<double>(region.nDstXSize) * region.nDstYSize;
}
}
#endif
else
{
CPLError(CE_Failure, CPLE_AppDefined,
Expand Down
5 changes: 5 additions & 0 deletions autotest/alg/cutline.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@

from osgeo import gdal

pytestmark = pytest.mark.skipif(
not gdaltest.vrt_has_open_support(),
reason="VRT driver open missing",
)

###############################################################################


Expand Down
5 changes: 5 additions & 0 deletions autotest/alg/warp.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
import gdaltest
import pytest

pytestmark = pytest.mark.skipif(
not gdaltest.vrt_has_open_support(),
reason="VRT driver open missing",
)

from osgeo import gdal, osr

###############################################################################
Expand Down
6 changes: 6 additions & 0 deletions autotest/cpp/test_gdal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3114,6 +3114,12 @@ TEST_F(test_gdal, GDALCachedPixelAccessor)
// (https://github.com/OSGeo/gdal/issues/5989)
TEST_F(test_gdal, VRTCachingOpenOptions)
{
if (GDALGetMetadataItem(GDALGetDriverByName("VRT"), GDAL_DMD_OPENOPTIONLIST,
nullptr) == nullptr)
{
GTEST_SKIP() << "VRT driver Open() missing";
}

class TestRasterBand : public GDALRasterBand
{
protected:
Expand Down
9 changes: 9 additions & 0 deletions autotest/cpp/test_gdal_pixelfn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,15 @@ struct test_gdal_pixelfn : public ::testing::Test
src_ += SEP;
src_ += "pixelfn.vrt";
}

void SetUp() override
{
if (GDALGetMetadataItem(GDALGetDriverByName("VRT"),
GDAL_DMD_OPENOPTIONLIST, nullptr) == nullptr)
{
GTEST_SKIP() << "VRT driver Open() missing";
}
}
};

// Test constant parameters in a custom pixel function
Expand Down
20 changes: 20 additions & 0 deletions autotest/gcore/gdal_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ def test_stats_nan_3():
# and complex source nodata (#3576)


@pytest.mark.skipif(
not gdaltest.vrt_has_open_support(),
reason="VRT driver open missing",
)
def test_stats_nan_4():

ds = gdal.Open("data/nan32_nodata.vrt")
Expand All @@ -197,6 +201,10 @@ def test_stats_nan_4():
# and complex source nodata (nan must be translated to 0 then) (#3576)


@pytest.mark.skipif(
not gdaltest.vrt_has_open_support(),
reason="VRT driver open missing",
)
def test_stats_nan_5():

ds = gdal.Open("data/nan32_nodata_nan_to_zero.vrt")
Expand All @@ -213,6 +221,10 @@ def test_stats_nan_5():
# Test reading a warped VRT with nan as src nodata and dest nodata (#3576)


@pytest.mark.skipif(
not gdaltest.vrt_has_open_support(),
reason="VRT driver open missing",
)
def test_stats_nan_6():

ds = gdal.Open("data/nan32_nodata_warp.vrt")
Expand All @@ -229,6 +241,10 @@ def test_stats_nan_6():
# Test reading a warped VRT with nan as src nodata and 0 as dest nodata (#3576)


@pytest.mark.skipif(
not gdaltest.vrt_has_open_support(),
reason="VRT driver open missing",
)
def test_stats_nan_7():

ds = gdal.Open("data/nan32_nodata_warp_nan_to_zero.vrt")
Expand All @@ -245,6 +261,10 @@ def test_stats_nan_7():
# Test reading a warped VRT with zero as src nodata and nan as dest nodata (#3576)


@pytest.mark.skipif(
not gdaltest.vrt_has_open_support(),
reason="VRT driver open missing",
)
def test_stats_nan_8():

ds = gdal.Open("data/nan32_nodata_warp_zero_to_nan.vrt")
Expand Down
4 changes: 4 additions & 0 deletions autotest/gcore/geoloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
# Verify warped result.


@pytest.mark.skipif(
not gdaltest.vrt_has_open_support(),
reason="VRT driver open missing",
)
def test_geoloc_1():

tst = gdaltest.GDALTest("VRT", "warpsst.vrt", 1, 63034)
Expand Down
4 changes: 4 additions & 0 deletions autotest/gcore/interpolateatpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,10 @@ def test_interpolateatpoint_complex_float():
assert res == pytest.approx((34.433130 - 36.741504j), 1e-4)


@pytest.mark.skipif(
not gdaltest.vrt_has_open_support(),
reason="VRT driver open missing",
)
def test_interpolateatpoint_big_complex():
# The purpose of this test is to check that the algorithm implementation
# works for bigger values above the first block of 64x64 pixels.
Expand Down
4 changes: 4 additions & 0 deletions autotest/gcore/mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ def test_mask_1():
# Verify the checksum and flags for "nodata" case.


@pytest.mark.skipif(
not gdaltest.vrt_has_open_support(),
reason="VRT driver open missing",
)
def test_mask_2():

ds = gdal.Open("data/byte.vrt")
Expand Down
8 changes: 8 additions & 0 deletions autotest/gcore/numpy_rw.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,10 @@ def test_numpy_rw_18():
# The VRT references a non existing TIF file, but using the proxy pool dataset API (#2837)


@pytest.mark.skipif(
not gdaltest.vrt_has_open_support(),
reason="VRT driver open missing",
)
def test_numpy_rw_failure_in_readasarray():

ds = gdal.Open("data/idontexist2.vrt")
Expand Down Expand Up @@ -964,6 +968,10 @@ def test_numpy_rw_band_read_as_array_error_cases():
# Test that we can get an error (#5374)


@pytest.mark.skipif(
not gdaltest.vrt_has_open_support(),
reason="VRT driver open missing",
)
def test_numpy_rw_band_read_as_array_getlasterrormsg():

ds = gdal.Open(
Expand Down
9 changes: 9 additions & 0 deletions autotest/gcore/overviewds.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import shutil
import struct

import gdaltest
import pytest

from osgeo import gdal
Expand Down Expand Up @@ -250,6 +251,10 @@ def test_overviewds_4(tmp_path):
# Test GEOLOCATION


@pytest.mark.skipif(
not gdaltest.vrt_has_open_support(),
reason="VRT driver open missing",
)
def test_overviewds_5(tmp_path):

shutil.copy("data/sstgeo.tif", tmp_path)
Expand Down Expand Up @@ -296,6 +301,10 @@ def test_overviewds_5(tmp_path):
# Test VRT


@pytest.mark.skipif(
not gdaltest.vrt_has_open_support(),
reason="VRT driver open missing",
)
def test_overviewds_6(tmp_path):

shutil.copy("data/byte.tif", tmp_path)
Expand Down
5 changes: 5 additions & 0 deletions autotest/gcore/pixfun.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@

from osgeo import gdal

pytestmark = pytest.mark.skipif(
not gdaltest.vrt_has_open_support(),
reason="VRT driver open missing",
)

# All tests will be skipped if numpy is unavailable.
numpy = pytest.importorskip("numpy")

Expand Down
4 changes: 4 additions & 0 deletions autotest/gcore/testnonboundtoswig.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ def my_pyDerivedPixelFunc(
return 0


@pytest.mark.skipif(
not gdaltest.vrt_has_open_support(),
reason="VRT driver open missing",
)
def test_testnonboundtoswig_VRTDerivedBands():

DerivedPixelFuncType = ctypes.CFUNCTYPE(
Expand Down
16 changes: 16 additions & 0 deletions autotest/gcore/tiff_ovr.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ def mfloat32_tif(tmp_path):
yield dst_fname


@pytest.mark.skipif(
not gdaltest.vrt_has_open_support(),
reason="VRT driver open missing",
)
def test_tiff_ovr_1(mfloat32_tif, both_endian):

ds = gdal.Open(mfloat32_tif)
Expand Down Expand Up @@ -151,6 +155,10 @@ def test_tiff_ovr_1(mfloat32_tif, both_endian):
# Open target file in update mode, and create internal overviews.


@pytest.mark.skipif(
not gdaltest.vrt_has_open_support(),
reason="VRT driver open missing",
)
def test_tiff_ovr_3(mfloat32_tif, both_endian):

src_ds = gdal.Open(mfloat32_tif, gdal.GA_Update)
Expand Down Expand Up @@ -531,6 +539,10 @@ def test_tiff_ovr_12(tmp_path, both_endian):
# Test gaussian resampling


@pytest.mark.skipif(
not gdaltest.vrt_has_open_support(),
reason="VRT driver open missing",
)
def test_tiff_ovr_13(mfloat32_tif, both_endian):

ds = gdal.Open(mfloat32_tif)
Expand Down Expand Up @@ -608,6 +620,10 @@ def test_tiff_ovr_15(tmp_path, both_endian):
# Test mode resampling on non-byte dataset


@pytest.mark.skipif(
not gdaltest.vrt_has_open_support(),
reason="VRT driver open missing",
)
def test_tiff_ovr_16(tmp_path, both_endian):

tif_fname = str(tmp_path / "ovr16.tif")
Expand Down
4 changes: 4 additions & 0 deletions autotest/gcore/tiff_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -5192,6 +5192,10 @@ def test_tiff_read_webp_lossless_rgba_alpha_fully_opaque():
# Test complex scenario of https://github.com/OSGeo/gdal/issues/9563


@pytest.mark.skipif(
not gdaltest.vrt_has_open_support(),
reason="VRT driver open missing",
)
@pytest.mark.require_creation_option("GTiff", "JPEG")
def test_tiff_read_jpeg_cached_multi_range_issue_9563(tmp_vsimem):

Expand Down
Loading

0 comments on commit 1eedc9b

Please sign in to comment.