xref: /aosp_15_r20/external/libaom/test/test_data_download_worker.cmake (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
1#
2# Copyright (c) 2017, Alliance for Open Media. All rights reserved.
3#
4# This source code is subject to the terms of the BSD 2 Clause License and the
5# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
6# not distributed with this source code in the LICENSE file, you can obtain it
7# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
8# License 1.0 was not distributed with this source code in the PATENTS file, you
9# can obtain it at www.aomedia.org/license/patent.
10#
11include("${AOM_ROOT}/test/test_data_util.cmake")
12
13# https://github.com/cheshirekow/cmake_format/issues/34
14# cmake-format: off
15if (NOT AOM_ROOT OR NOT AOM_CONFIG_DIR OR NOT AOM_TEST_FILE
16    OR NOT AOM_TEST_CHECKSUM)
17  message(FATAL_ERROR
18          "AOM_ROOT, AOM_CONFIG_DIR, AOM_TEST_FILE and AOM_TEST_CHECKSUM must be
19          defined.")
20endif ()
21# cmake-format: on
22
23set(AOM_TEST_DATA_URL "https://storage.googleapis.com/aom-test-data")
24
25if(NOT AOM_TEST_DATA_PATH)
26  set(AOM_TEST_DATA_PATH "$ENV{LIBAOM_TEST_DATA_PATH}")
27endif()
28
29if("${AOM_TEST_DATA_PATH}" STREQUAL "")
30  message(
31    WARNING "Writing test data to ${AOM_CONFIG_DIR}, set "
32            "$LIBAOM_TEST_DATA_PATH in your environment to avoid this warning.")
33  set(AOM_TEST_DATA_PATH "${AOM_CONFIG_DIR}")
34endif()
35
36if(NOT EXISTS "${AOM_TEST_DATA_PATH}")
37  file(MAKE_DIRECTORY "${AOM_TEST_DATA_PATH}")
38endif()
39
40expand_test_file_paths("AOM_TEST_FILE" "${AOM_TEST_DATA_PATH}" "filepath")
41expand_test_file_paths("AOM_TEST_FILE" "${AOM_TEST_DATA_URL}" "url")
42
43check_file("${filepath}" "${AOM_TEST_CHECKSUM}" "needs_download")
44if(needs_download)
45  download_test_file("${url}" "${AOM_TEST_CHECKSUM}" "${filepath}")
46endif()
47