tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

generate_aom_config_templates.cmake (3898B)


      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 #
     11 cmake_minimum_required(VERSION 3.16)
     12 
     13 string(TIMESTAMP year "%Y")
     14 set(asm_file_header_block "\;
     15 \; Copyright (c) ${year}, Alliance for Open Media. All rights reserved.
     16 \;
     17 \; This source code is subject to the terms of the BSD 2 Clause License and
     18 \; the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
     19 \; was not distributed with this source code in the LICENSE file, you can
     20 \; obtain it at www.aomedia.org/license/software. If the Alliance for Open
     21 \; Media Patent License 1.0 was not distributed with this source code in the
     22 \; PATENTS file, you can obtain it at www.aomedia.org/license/patent.
     23 \;
     24 ")
     25 set(h_file_header_block "/*
     26 * Copyright (c) ${year}, Alliance for Open Media. All rights reserved.
     27 *
     28 * This source code is subject to the terms of the BSD 2 Clause License and
     29 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
     30 * was not distributed with this source code in the LICENSE file, you can
     31 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
     32 * Media Patent License 1.0 was not distributed with this source code in the
     33 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
     34 */
     35 \#ifndef AOM_CONFIG_H_
     36 \#define AOM_CONFIG_H_
     37 ")
     38 set(cmake_file_header_block "##
     39 ## Copyright (c) ${year}, Alliance for Open Media. All rights reserved.
     40 ##
     41 ## This source code is subject to the terms of the BSD 2 Clause License and
     42 ## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
     43 ## was not distributed with this source code in the LICENSE file, you can
     44 ## obtain it at www.aomedia.org/license/software. If the Alliance for Open
     45 ## Media Patent License 1.0 was not distributed with this source code in the
     46 ## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
     47 ##
     48 ")
     49 
     50 # Terminates cmake execution when $var_name is an empty string, or the variable
     51 # name it contains does not expand to an existing directory.
     52 function(check_directory_var var_name)
     53  if("${var_name}" STREQUAL "")
     54    message(FATAL_ERROR "The CMake variable ${var_name} must be defined.")
     55  endif()
     56 
     57  if(NOT EXISTS "${${var_name}}")
     58    message(FATAL_ERROR "${${var_name}} (${var_name}) missing.")
     59  endif()
     60 endfunction()
     61 
     62 check_directory_var(AOM_CONFIG_DIR)
     63 check_directory_var(AOM_ROOT)
     64 
     65 set(AOM_DEFAULTS "${AOM_ROOT}/build/cmake/aom_config_defaults.cmake")
     66 if(NOT EXISTS "${AOM_DEFAULTS}")
     67  message(
     68    FATAL_ERROR "Configuration default values file (${AOM_DEFAULTS}) missing.")
     69 endif()
     70 
     71 include("${AOM_ROOT}/build/cmake/aom_config_defaults.cmake")
     72 list(APPEND aom_build_vars ${AOM_DETECT_VARS} ${AOM_CONFIG_VARS})
     73 list(SORT aom_build_vars)
     74 
     75 set(aom_config_h_template "${AOM_CONFIG_DIR}/config/aom_config.h.cmake")
     76 file(WRITE "${aom_config_h_template}" ${h_file_header_block})
     77 foreach(aom_var ${aom_build_vars})
     78  if(NOT "${aom_var}" STREQUAL "AOM_RTCD_FLAGS")
     79    file(APPEND "${aom_config_h_template}"
     80         "\#define ${aom_var} \${${aom_var}}\n")
     81  endif()
     82 endforeach()
     83 file(APPEND "${aom_config_h_template}" "\#endif  // AOM_CONFIG_H_")
     84 
     85 set(aom_asm_config_template "${AOM_CONFIG_DIR}/config/aom_config.asm.cmake")
     86 file(WRITE "${aom_asm_config_template}" ${asm_file_header_block})
     87 foreach(aom_var ${aom_build_vars})
     88  if(NOT "${aom_var}" STREQUAL "AOM_RTCD_FLAGS")
     89    file(APPEND "${aom_asm_config_template}" "${aom_var} equ \${${aom_var}}\n")
     90  endif()
     91 endforeach()