#!/usr/bin/env python############################################################################# prepare.py# Copyright (C) 2016 Belledonne Communications, Grenoble France############################################################################### This program is free software; you can redistribute it and/or# modify it under the terms of the GNU General Public License# as published by the Free Software Foundation; either version 2# of the License, or (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.#############################################################################importfnmatchimportosimportreimportsysfromdistutils.spawnimportfind_executablefromloggingimporterror,warning,infofromsubprocessimportPopensys.dont_write_bytecode=Truesys.path.insert(0,'submodules/cmake-builder')try:importprepareexceptExceptionase:error("Could not find prepare module: {}, probably missing submodules/cmake-builder? Try running:\n""git submodule sync && git submodule update --init --recursive".format(e))exit(1)classAndroidTarget(prepare.Target):def__init__(self,arch):

self.release_with_debug_info=Trueself.veryclean=Trueself.show_gpl_disclaimer=Trueself.argparser.add_argument('-ac','--all-codecs',help="Enable all codecs, including the non-free ones",action='store_true')defparse_args(self):prepare.Preparator.parse_args(self)ifself.args.all_codecs:self.additional_args+=["-DENABLE_GPL_THIRD_PARTIES=YES"]self.additional_args+=["-DENABLE_NON_FREE_CODECS=YES"]self.additional_args+=["-DENABLE_AMRNB=YES"]self.additional_args+=["-DENABLE_AMRWB=YES"]self.additional_args+=["-DENABLE_BV16=YES"]self.additional_args+=["-DENABLE_CODEC2=YES"]self.additional_args+=["-DENABLE_G729=YES"]self.additional_args+=["-DENABLE_GSM=YES"]self.additional_args+=["-DENABLE_ILBC=YES"]self.additional_args+=["-DENABLE_ISAC=YES"]self.additional_args+=["-DENABLE_OPUS=YES"]self.additional_args+=["-DENABLE_SILK=YES"]self.additional_args+=["-DENABLE_SPEEX=YES"]

deflist_feature_target(self):returnandroid_targets['armv7']defcheck_ndk_version(self):retval=Truendk_build=find_executable('ndk-build')ndk_path=os.path.dirname(ndk_build)# NDK prior to r11 had a RELEASE.TXT file holding the version numberrelease_file=os.path.join(ndk_path,'RELEASE.TXT')ifos.path.isfile(release_file):version=open(release_file).read().strip()res=re.match('^r(\d+)(.*)$',version)version=int(res.group(1))retval=Falseelse:# Hack to find the NDK version since the RELEASE.TXT file is no longer therepython_config_files=[]forroot,dirnames,filenamesinos.walk(ndk_path):forfilenameinfnmatch.filter(filenames,'python-config'):python_config_files.append(os.path.join(root,filename))iflen(python_config_files)>0:version=open(python_config_files[0]).readlines()[0]res=re.match('^.*/(aosp-)?ndk-r(\d+).*$',version)

ifresisnotNone:# Will be if NDK < 16version=int(res.group(2))retval=Falseelse:release_file=os.path.join(ndk_path,'source.properties')# Since NDK 16ifos.path.isfile(release_file):version=open(release_file).read().strip()res=re.findall(r'(?:(\d+))',version)version=int(res[0])retval=Falseelse:error("Could not get Android NDK version!")sys.exit(-1)