#!/bin/bash # # Copyright (c) 2018 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. # This script is used to generate .gni files and files in the # config/platform directories needed to build libaom. # # Every time the upstream source code is updated this script must be run. # # Usage: # $ ./cmake_update.sh # Requirements: # Install the following Debian packages. # - cmake3 # - yasm or nasm # Toolchain for armv7: # - gcc-arm-linux-gnueabihf # - g++-arm-linux-gnueabihf # Toolchain for arm64: # - gcc-aarch64-linux-gnu # - g++-aarch64-linux-gnu # 32bit build environment for cmake. Including but potentially not limited to: # - lib32gcc-7-dev # - lib32stdc++-7-dev # Alternatively: treat 32bit builds like Windows and manually tweak aom_config.h set -eE # sort() consistently. export LC_ALL=C BASE=$(pwd) SRC="${BASE}/source/libaom" CFG="${BASE}/source/config" function clean { rm -rf "${TMP}" } # Create empty temp and config directories. # $1 - Header file directory. function reset_dirs { cd .. rm -rf "${TMP}" mkdir "${TMP}" cd "${TMP}" echo "Generate ${1} config files." rm -fr "${CFG}/${1}" mkdir -p "${CFG}/${1}/config" } if [ $# -ne 0 ]; then echo "Unknown option(s): ${@}" exit 1 fi # Missing function: # find_duplicates # We may have enough targets to avoid re-implementing this. # Generate Config files. # $1 - Header file directory. # $2 - cmake options. function gen_config_files { cmake "${SRC}" ${2} &> cmake.txt case "${1}" in *x64*|*ia32*) egrep "#define [A-Z0-9_]+ [01]" config/aom_config.h | \ awk '{print "%define " $2 " " $3}' > config/aom_config.asm ;; esac cp config/aom_config.{h,c,asm} "${CFG}/${1}/config/" cp config/*_rtcd.h "${CFG}/${1}/config/" } function update_readme { local IFS=$'\n' # Split git log output '\n' on the newline to produce 2 # array entries. local vals=($(git -C "${SRC}" --no-pager log -1 --format="%cd%n%H" \ --date=format:"%A %B %d %Y")) sed -E -i.bak \ -e "s/^(Date:)[[:space:]]+.*$/\1 ${vals[0]}/" \ -e "s/^(Commit:)[[:space:]]+[a-f0-9]{40}/\1 ${vals[1]}/" \ ${BASE}/README.chromium rm ${BASE}/README.chromium.bak cat < "${CFG}/win/ia32/config/aom_config.asm" # Copy linux configurations and modify for Windows. reset_dirs win/x64 cp "${CFG}/linux/x64/config"/* "${CFG}/win/x64/config/" convert_to_windows "${CFG}/win/x64/config/aom_config.h" egrep "#define [A-Z0-9_]+[[:space:]]+[01]" "${CFG}/win/x64/config/aom_config.h" \ | awk '{print "%define " $2 " " $3}' > "${CFG}/win/x64/config/aom_config.asm" reset_dirs linux/arm gen_config_files linux/arm \ "${toolchain}/armv7-linux-gcc.cmake -DENABLE_NEON=0 ${all_platforms}" reset_dirs linux/arm-neon gen_config_files linux/arm-neon "${toolchain}/armv7-linux-gcc.cmake ${all_platforms}" reset_dirs linux/arm-neon-cpu-detect gen_config_files linux/arm-neon-cpu-detect \ "${toolchain}/armv7-linux-gcc.cmake -DCONFIG_RUNTIME_CPU_DETECT=1 ${all_platforms}" reset_dirs linux/arm64 gen_config_files linux/arm64 "${toolchain}/arm64-linux-gcc.cmake ${all_platforms}" reset_dirs ios/arm-neon gen_config_files ios/arm-neon "${toolchain}/armv7-ios.cmake ${all_platforms}" reset_dirs ios/arm64 gen_config_files ios/arm64 "${toolchain}/arm64-ios.cmake ${all_platforms}" # Copy linux configurations and modify for Windows. reset_dirs win/arm64 cp "${CFG}/linux/arm64/config"/* "${CFG}/win/arm64/config/" convert_to_windows "${CFG}/win/arm64/config/aom_config.h" ) update_readme git cl format > /dev/null \ || echo "ERROR: 'git cl format' failed. Please run 'git cl format' manually." clean