michael@0: #!/bin/sh michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: # michael@0: # Usage: ./update.sh michael@0: # michael@0: # Copies the needed files from a directory containing the original michael@0: # libopus source, and applies any local patches we're carrying. michael@0: michael@0: TARGET='.' michael@0: michael@0: STATIC_FILES="COPYING celt/arm/arm2gnu.pl" michael@0: MK_FILES="opus_sources.mk celt_sources.mk silk_sources.mk \ michael@0: opus_headers.mk celt_headers.mk silk_headers.mk" michael@0: michael@0: # Make sure we have a source directory michael@0: if test -z $1 || ! test -r $1/include/opus.h; then michael@0: echo "Update the current directory from a source checkout" michael@0: echo "usage: $0 ../opus" michael@0: exit 1 michael@0: fi michael@0: michael@0: # "parse" the makefile fragments to get the list of source files michael@0: # requires GNU sed extensions michael@0: SRC_FILES=$(sed -e ':a;N;$!ba;s/#[^\n]*\(\n\)/\1/g;s/\\\n//g;s/[A-Z_]* = //g' \ michael@0: $(for file in ${MK_FILES}; do echo "$1/${file}"; done)) michael@0: michael@0: # pre-release versions of the code don't list opus_custom.h michael@0: # in celt_headers.mk, so we must include it manually michael@0: HDR_FILES="include/opus_custom.h" michael@0: michael@0: # make sure the necessary subdirectories exist michael@0: for file in ${SRC_FILES}; do michael@0: base=${file##*/} michael@0: dir="${file%"${base}"}" michael@0: if test ! -d "${TARGET}/${dir}"; then michael@0: cmd="mkdir -p ${TARGET}/${dir}" michael@0: echo ${cmd} michael@0: ${cmd} michael@0: fi michael@0: done michael@0: michael@0: # copy files into the target directory michael@0: for file in ${STATIC_FILES} ${SRC_FILES} ${HDR_FILES}; do michael@0: cmd="cp $1/${file} ${TARGET}/${file}" michael@0: echo ${cmd} michael@0: ${cmd} michael@0: done michael@0: michael@0: sed \ michael@0: -e s/@OPUS_ARM_MAY_HAVE_EDSP@/1/g \ michael@0: -e s/@OPUS_ARM_MAY_HAVE_MEDIA@/1/g \ michael@0: -e s/@OPUS_ARM_MAY_HAVE_NEON@/1/g \ michael@0: $1/celt/arm/armopts.s.in > ${TARGET}/celt/arm/armopts.s michael@0: michael@0: # query git for the revision we're copying from michael@0: if test -d $1/.git; then michael@0: version=$(cd $1 && git describe --tags --match 'v*' --dirty) michael@0: else michael@0: version="UNKNOWN" michael@0: fi michael@0: echo "copied from revision ${version}" michael@0: # update README revision michael@0: sed -e "s/^The git tag\/revision used was .*/The git tag\/revision used was ${version}./" \ michael@0: ${TARGET}/README_MOZILLA > ${TARGET}/README_MOZILLA+ && \ michael@0: mv ${TARGET}/README_MOZILLA+ ${TARGET}/README_MOZILLA michael@0: # update compiled-in version string michael@0: sed -e "s/DEFINES\['OPUS_VERSION'\][ \t]*=[ \t]*'\".*\"'/DEFINES['OPUS_VERSION'] = '\"${version}-mozilla\"'/" \ michael@0: ${TARGET}/moz.build > ${TARGET}/moz.build+ && \ michael@0: mv ${TARGET}/moz.build+ ${TARGET}/moz.build michael@0: michael@0: python gen-sources.py $1 michael@0: michael@0: # apply outstanding local patches michael@0: # ... no patches to apply ...