xref: /aosp_15_r20/external/libaom/build/cmake/generate_exports.cmake (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
1*77c1e3ccSAndroid Build Coastguard Worker#
2*77c1e3ccSAndroid Build Coastguard Worker# Copyright (c) 2017, Alliance for Open Media. All rights reserved.
3*77c1e3ccSAndroid Build Coastguard Worker#
4*77c1e3ccSAndroid Build Coastguard Worker# This source code is subject to the terms of the BSD 2 Clause License and the
5*77c1e3ccSAndroid Build Coastguard Worker# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
6*77c1e3ccSAndroid Build Coastguard Worker# not distributed with this source code in the LICENSE file, you can obtain it
7*77c1e3ccSAndroid Build Coastguard Worker# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
8*77c1e3ccSAndroid Build Coastguard Worker# License 1.0 was not distributed with this source code in the PATENTS file, you
9*77c1e3ccSAndroid Build Coastguard Worker# can obtain it at www.aomedia.org/license/patent.
10*77c1e3ccSAndroid Build Coastguard Worker#
11*77c1e3ccSAndroid Build Coastguard Workercmake_minimum_required(VERSION 3.5)
12*77c1e3ccSAndroid Build Coastguard Worker
13*77c1e3ccSAndroid Build Coastguard Worker# CMAKE_SHARED_LIBRARY_PREFIX can be empty
14*77c1e3ccSAndroid Build Coastguard Workerset(REQUIRED_ARGS "AOM_ROOT" "AOM_CONFIG_DIR" "AOM_TARGET_SYSTEM" "AOM_SYM_FILE"
15*77c1e3ccSAndroid Build Coastguard Worker                  "CONFIG_AV1_DECODER" "CONFIG_AV1_ENCODER")
16*77c1e3ccSAndroid Build Coastguard Worker
17*77c1e3ccSAndroid Build Coastguard Workerforeach(arg ${REQUIRED_ARGS})
18*77c1e3ccSAndroid Build Coastguard Worker  if("${${arg}}" STREQUAL "")
19*77c1e3ccSAndroid Build Coastguard Worker    message(FATAL_ERROR "${arg} must not be empty.")
20*77c1e3ccSAndroid Build Coastguard Worker  endif()
21*77c1e3ccSAndroid Build Coastguard Workerendforeach()
22*77c1e3ccSAndroid Build Coastguard Worker
23*77c1e3ccSAndroid Build Coastguard Workerinclude("${AOM_ROOT}/build/cmake/exports_sources.cmake")
24*77c1e3ccSAndroid Build Coastguard Worker
25*77c1e3ccSAndroid Build Coastguard Workerif("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin")
26*77c1e3ccSAndroid Build Coastguard Worker  set(symbol_prefix "_")
27*77c1e3ccSAndroid Build Coastguard Workerelseif("${AOM_TARGET_SYSTEM}" MATCHES "Windows\|MSYS")
28*77c1e3ccSAndroid Build Coastguard Worker  file(WRITE "${AOM_SYM_FILE}" "LIBRARY ${CMAKE_SHARED_LIBRARY_PREFIX}aom\n"
29*77c1e3ccSAndroid Build Coastguard Worker                               "EXPORTS\n")
30*77c1e3ccSAndroid Build Coastguard Workerelse()
31*77c1e3ccSAndroid Build Coastguard Worker  set(symbol_suffix ";")
32*77c1e3ccSAndroid Build Coastguard Workerendif()
33*77c1e3ccSAndroid Build Coastguard Worker
34*77c1e3ccSAndroid Build Coastguard Workerset(aom_sym_file "${AOM_SYM_FILE}")
35*77c1e3ccSAndroid Build Coastguard Worker
36*77c1e3ccSAndroid Build Coastguard Workerif("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin")
37*77c1e3ccSAndroid Build Coastguard Worker  file(REMOVE "${aom_sym_file}")
38*77c1e3ccSAndroid Build Coastguard Workerelseif("${AOM_TARGET_SYSTEM}" MATCHES "Windows\|MSYS")
39*77c1e3ccSAndroid Build Coastguard Worker  file(WRITE "${aom_sym_file}" "LIBRARY ${CMAKE_SHARED_LIBRARY_PREFIX}aom\n"
40*77c1e3ccSAndroid Build Coastguard Worker                               "EXPORTS\n")
41*77c1e3ccSAndroid Build Coastguard Workerelse()
42*77c1e3ccSAndroid Build Coastguard Worker  file(WRITE "${aom_sym_file}" "{\nglobal:\n")
43*77c1e3ccSAndroid Build Coastguard Workerendif()
44*77c1e3ccSAndroid Build Coastguard Worker
45*77c1e3ccSAndroid Build Coastguard Workerforeach(export_file ${AOM_EXPORTS_SOURCES})
46*77c1e3ccSAndroid Build Coastguard Worker  file(STRINGS "${export_file}" exported_file_data)
47*77c1e3ccSAndroid Build Coastguard Worker  set(exported_symbols "${exported_symbols} ${exported_file_data};")
48*77c1e3ccSAndroid Build Coastguard Worker  string(STRIP "${exported_symbols}" exported_symbols)
49*77c1e3ccSAndroid Build Coastguard Workerendforeach()
50*77c1e3ccSAndroid Build Coastguard Worker
51*77c1e3ccSAndroid Build Coastguard Workerforeach(exported_symbol ${exported_symbols})
52*77c1e3ccSAndroid Build Coastguard Worker  string(STRIP "${exported_symbol}" exported_symbol)
53*77c1e3ccSAndroid Build Coastguard Worker  if("${AOM_TARGET_SYSTEM}" MATCHES "Windows\|MSYS")
54*77c1e3ccSAndroid Build Coastguard Worker    string(SUBSTRING ${exported_symbol} 0 4 export_type)
55*77c1e3ccSAndroid Build Coastguard Worker    string(COMPARE EQUAL "${export_type}" "data" is_data)
56*77c1e3ccSAndroid Build Coastguard Worker    if(is_data)
57*77c1e3ccSAndroid Build Coastguard Worker      set(symbol_suffix " DATA")
58*77c1e3ccSAndroid Build Coastguard Worker    else()
59*77c1e3ccSAndroid Build Coastguard Worker      set(symbol_suffix "")
60*77c1e3ccSAndroid Build Coastguard Worker    endif()
61*77c1e3ccSAndroid Build Coastguard Worker  endif()
62*77c1e3ccSAndroid Build Coastguard Worker  string(REGEX REPLACE "text \|data " "" "exported_symbol" "${exported_symbol}")
63*77c1e3ccSAndroid Build Coastguard Worker  set(exported_symbol "  ${symbol_prefix}${exported_symbol}${symbol_suffix}")
64*77c1e3ccSAndroid Build Coastguard Worker  file(APPEND "${aom_sym_file}" "${exported_symbol}\n")
65*77c1e3ccSAndroid Build Coastguard Workerendforeach()
66*77c1e3ccSAndroid Build Coastguard Worker
67*77c1e3ccSAndroid Build Coastguard Workerif("${aom_sym_file}" MATCHES "ver$")
68*77c1e3ccSAndroid Build Coastguard Worker  file(APPEND "${aom_sym_file}" " \nlocal:\n  *;\n};")
69*77c1e3ccSAndroid Build Coastguard Workerendif()
70