2011-11-24 13:49:22 +01:00
|
|
|
#!/bin/bash -e
|
|
|
|
#
|
2012-03-21 17:52:03 +01:00
|
|
|
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
2011-11-24 13:49:22 +01:00
|
|
|
# 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 .gypi files needed to build libvpx.
|
|
|
|
# Every time libvpx source code is updated just run this script.
|
|
|
|
#
|
|
|
|
# For example:
|
|
|
|
# $ ./generate_gypi.sh
|
|
|
|
#
|
|
|
|
# And this will update all the .gypi files needed.
|
2012-08-17 08:57:58 +02:00
|
|
|
#
|
|
|
|
# Configuration for building on each platform is taken from the
|
|
|
|
# corresponding vpx_config.h
|
|
|
|
#
|
2011-11-24 13:49:22 +01:00
|
|
|
|
2012-08-17 08:57:58 +02:00
|
|
|
BASE_DIR=`pwd`
|
2011-11-24 13:49:22 +01:00
|
|
|
LIBVPX_SRC_DIR="source/libvpx"
|
2012-08-17 08:57:58 +02:00
|
|
|
LIBVPX_CONFIG_DIR="source/config"
|
2011-11-24 13:49:22 +01:00
|
|
|
|
2012-08-17 08:57:58 +02:00
|
|
|
# Convert a list of source files into gypi file.
|
|
|
|
# $1 - Input file.
|
|
|
|
# $2 - Output gypi file.
|
2011-11-24 13:49:22 +01:00
|
|
|
function convert_srcs_to_gypi {
|
|
|
|
# Do the following here:
|
|
|
|
# 1. Filter .c, .h, .s, .S and .asm files.
|
|
|
|
# 2. Exclude *_offsets.c.
|
|
|
|
# 3. Exclude vpx_config.c.
|
|
|
|
# 4. Repelace .asm.s to .asm because gyp will do the conversion.
|
2012-08-22 22:14:33 +02:00
|
|
|
local source_list=`grep -E '(\.c|\.h|\.S|\.s|\.asm)$' $1 | grep -v '_offsets\.c' | grep -v 'vpx_config\.c' | sed s/\.asm\.s$/.asm/ | sort`
|
2011-11-24 13:49:22 +01:00
|
|
|
|
|
|
|
# Build the gypi file.
|
|
|
|
echo "# This file is generated. Do not edit." > $2
|
2012-08-17 08:57:58 +02:00
|
|
|
echo "# Copyright (c) 2012 The Chromium Authors. All rights reserved." >> $2
|
2011-11-24 13:49:22 +01:00
|
|
|
echo "# Use of this source code is governed by a BSD-style license that can be" >> $2
|
|
|
|
echo "# found in the LICENSE file." >> $2
|
|
|
|
echo "" >> $2
|
|
|
|
echo "{" >> $2
|
|
|
|
echo " 'sources': [" >> $2
|
|
|
|
for f in $source_list
|
|
|
|
do
|
2012-11-16 18:32:00 +01:00
|
|
|
echo " '<(libvpx_src_dir)/$f'," >> $2
|
2011-11-24 13:49:22 +01:00
|
|
|
done
|
|
|
|
echo " ]," >> $2
|
|
|
|
echo "}" >> $2
|
|
|
|
}
|
|
|
|
|
2012-08-17 08:57:58 +02:00
|
|
|
# Clean files from previous make.
|
|
|
|
function make_clean {
|
|
|
|
make clean > /dev/null
|
|
|
|
rm -f libvpx_srcs.txt
|
|
|
|
}
|
|
|
|
|
|
|
|
# Lint a pair of vpx_config.h and vpx_config.asm to make sure they match.
|
|
|
|
# $1 - Header file directory.
|
|
|
|
function lint_config {
|
|
|
|
$BASE_DIR/lint_config.sh \
|
|
|
|
-h $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.h \
|
|
|
|
-a $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.asm
|
|
|
|
}
|
|
|
|
|
|
|
|
# Print the configuration.
|
|
|
|
# $1 - Header file directory.
|
|
|
|
function print_config {
|
|
|
|
$BASE_DIR/lint_config.sh -p \
|
|
|
|
-h $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.h \
|
|
|
|
-a $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.asm
|
|
|
|
}
|
|
|
|
|
|
|
|
# Generate vpx_rtcd.h.
|
|
|
|
# $1 - Header file directory.
|
|
|
|
# $2 - Architecture.
|
|
|
|
function gen_rtcd_header {
|
|
|
|
echo "Generate $LIBVPX_CONFIG_DIR/$1/vpx_rtcd.h."
|
|
|
|
|
|
|
|
rm -rf $BASE_DIR/$TEMP_DIR/libvpx.config
|
|
|
|
$BASE_DIR/lint_config.sh -p \
|
|
|
|
-h $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.h \
|
|
|
|
-a $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.asm \
|
|
|
|
-o $BASE_DIR/$TEMP_DIR/libvpx.config
|
|
|
|
|
|
|
|
$BASE_DIR/$LIBVPX_SRC_DIR/build/make/rtcd.sh \
|
|
|
|
--arch=$2 \
|
|
|
|
--sym=vpx_rtcd \
|
|
|
|
--config=$BASE_DIR/$TEMP_DIR/libvpx.config \
|
|
|
|
$BASE_DIR/$LIBVPX_SRC_DIR/vp8/common/rtcd_defs.sh \
|
|
|
|
> $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_rtcd.h
|
|
|
|
|
|
|
|
rm -rf $BASE_DIR/$TEMP_DIR/libvpx.config
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "Lint libvpx configuration."
|
|
|
|
lint_config linux/ia32
|
|
|
|
lint_config linux/x64
|
|
|
|
lint_config linux/arm
|
|
|
|
lint_config linux/arm-neon
|
|
|
|
lint_config win/ia32
|
|
|
|
lint_config mac/ia32
|
|
|
|
|
2011-11-24 13:49:22 +01:00
|
|
|
echo "Create temporary directory."
|
|
|
|
TEMP_DIR="$LIBVPX_SRC_DIR.temp"
|
2012-08-17 08:57:58 +02:00
|
|
|
rm -rf $TEMP_DIR
|
2011-11-24 13:49:22 +01:00
|
|
|
cp -R $LIBVPX_SRC_DIR $TEMP_DIR
|
|
|
|
cd $TEMP_DIR
|
|
|
|
|
2012-08-17 08:57:58 +02:00
|
|
|
gen_rtcd_header linux/ia32 x86
|
|
|
|
gen_rtcd_header linux/x64 x86_64
|
2012-08-17 13:44:49 +02:00
|
|
|
gen_rtcd_header linux/arm armv5te
|
2012-08-17 08:57:58 +02:00
|
|
|
gen_rtcd_header linux/arm-neon armv7
|
|
|
|
gen_rtcd_header win/ia32 x86
|
|
|
|
gen_rtcd_header mac/ia32 x86
|
|
|
|
|
2011-11-24 13:49:22 +01:00
|
|
|
echo "Prepare Makefile."
|
|
|
|
./configure --target=generic-gnu > /dev/null
|
2012-08-17 08:57:58 +02:00
|
|
|
make_clean
|
2011-11-24 13:49:22 +01:00
|
|
|
|
|
|
|
echo "Generate X86 source list."
|
2012-08-17 08:57:58 +02:00
|
|
|
config=$(print_config linux/ia32)
|
|
|
|
make_clean
|
|
|
|
make libvpx_srcs.txt target=libs $config > /dev/null
|
|
|
|
convert_srcs_to_gypi libvpx_srcs.txt $BASE_DIR/libvpx_srcs_x86.gypi
|
2011-11-24 13:49:22 +01:00
|
|
|
|
|
|
|
echo "Generate X86_64 source list."
|
2012-08-17 08:57:58 +02:00
|
|
|
config=$(print_config linux/x64)
|
|
|
|
make_clean
|
|
|
|
make libvpx_srcs.txt target=libs $config > /dev/null
|
|
|
|
convert_srcs_to_gypi libvpx_srcs.txt $BASE_DIR/libvpx_srcs_x86_64.gypi
|
2011-11-24 13:49:22 +01:00
|
|
|
|
|
|
|
echo "Generate ARM source list."
|
2012-08-17 08:57:58 +02:00
|
|
|
config=$(print_config linux/arm)
|
|
|
|
make_clean
|
|
|
|
make libvpx_srcs.txt target=libs $config > /dev/null
|
|
|
|
convert_srcs_to_gypi libvpx_srcs.txt $BASE_DIR/libvpx_srcs_arm.gypi
|
2011-11-24 13:49:22 +01:00
|
|
|
|
|
|
|
echo "Generate ARM NEON source list."
|
2012-08-17 08:57:58 +02:00
|
|
|
config=$(print_config linux/arm-neon)
|
|
|
|
make_clean
|
|
|
|
make libvpx_srcs.txt target=libs $config > /dev/null
|
|
|
|
convert_srcs_to_gypi libvpx_srcs.txt $BASE_DIR/libvpx_srcs_arm_neon.gypi
|
2011-11-24 13:49:22 +01:00
|
|
|
|
|
|
|
echo "Remove temporary directory."
|
|
|
|
cd $BASE_DIR
|
|
|
|
rm -rf $TEMP_DIR
|