2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 # Usage: ./update.sh <opus_src_directory>
9 # Copies the needed files from a directory containing the original
10 # libopus source, and applies any local patches we're carrying.
14 STATIC_FILES
="COPYING celt/arm/arm2gnu.pl"
15 MK_FILES
="opus_sources.mk celt_sources.mk silk_sources.mk \
16 opus_headers.mk celt_headers.mk silk_headers.mk"
18 # Make sure we have a source directory
19 if test -z $1 ||
! test -r $1/include
/opus.h
; then
20 echo "Update the current directory from a source checkout"
21 echo "usage: $0 ../opus"
25 # "parse" the makefile fragments to get the list of source files
26 # requires GNU sed extensions
27 SRC_FILES
=$
(sed -e ':a;N;$!ba;s/#[^\n]*\(\n\)/\1/g;s/\\\n//g;s/[A-Z0-9_]*[ \t]*=[ \t]*//g' \
28 $
(for file in ${MK_FILES}; do echo "$1/${file}"; done))
30 # pre-release versions of the code don't list opus_custom.h
31 # in celt_headers.mk, so we must include it manually
32 HDR_FILES
="include/opus_custom.h"
34 # make sure the necessary subdirectories exist
35 for file in ${SRC_FILES}; do
37 dir
="${file%"${base}"}"
38 if test ! -d "${TARGET}/${dir}"; then
39 cmd
="mkdir -p ${TARGET}/${dir}"
45 # copy files into the target directory
46 for file in ${STATIC_FILES} ${SRC_FILES} ${HDR_FILES}; do
47 cmd
="cp $1/${file} ${TARGET}/${file}"
53 -e s
/@OPUS_ARM_MAY_HAVE_EDSP@
/1/g \
54 -e s
/@OPUS_ARM_MAY_HAVE_MEDIA@
/1/g \
55 -e s
/@OPUS_ARM_MAY_HAVE_NEON@
/1/g \
56 $1/celt
/arm
/armopts.s.
in > ${TARGET}/celt
/arm
/armopts.s
58 # query git for the revision we're copying from
59 if test -d $1/.git
; then
60 version
=$
(cd $1 && git describe
--tags --match 'v*' --dirty)
64 echo "copied from revision ${version}"
65 # update README revision
66 sed -e "s/^The git tag\/revision used was .*/The git tag\/revision used was ${version}./" \
67 ${TARGET}/README_MOZILLA
> ${TARGET}/README_MOZILLA
+ && \
68 mv ${TARGET}/README_MOZILLA
+ ${TARGET}/README_MOZILLA
69 # update compiled-in version string
70 sed -e "s/DEFINES\['OPUS_VERSION'\][ \t]*=[ \t]*'\".*\"'/DEFINES['OPUS_VERSION'] = '\"${version}-mozilla\"'/" \
71 ${TARGET}/moz.build
> ${TARGET}/moz.build
+ && \
72 mv ${TARGET}/moz.build
+ ${TARGET}/moz.build
74 python gen-sources.py
$1
76 # apply outstanding local patches
77 patch -p3 < nonunified.
patch
78 patch -p3 < nonunified2.
patch