Skip to content

Commit

Permalink
Build: Add build scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
libobjc committed Aug 20, 2019
1 parent 9fe2dcb commit 73f702f
Show file tree
Hide file tree
Showing 19 changed files with 1,663 additions and 243 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Expand Up @@ -15,6 +15,4 @@ DerivedData
*.ipa
*.xcuserstate
.DS_Store
framework/
SGPlayer/Classes/Core/SGFFmpeg/include
SGPlayer/Classes/Core/SGFFmpeg/lib-*
framework/
443 changes: 301 additions & 142 deletions SGPlayer.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions build.sh
@@ -0,0 +1,30 @@
#!/bin/sh

set -e

PLATFORM=$1
ACTION=$2

FFMPEG_VERSION=n4.2
OPENSSL_VERSION=OpenSSL_1_0_2s

if [ "$ACTION" = "build" ]; then
sh scripts/init-openssl.sh $PLATFORM $OPENSSL_VERSION
sh scripts/init-ffmpeg.sh $PLATFORM $FFMPEG_VERSION
sh scripts/compile-openssl.sh $PLATFORM "build"
sh scripts/compile-ffmpeg.sh $PLATFORM "build"
elif [ "$ACTION" = "clean" ]; then
sh scripts/compile-openssl.sh $PLATFORM "clean"
sh scripts/compile-ffmpeg.sh $PLATFORM "clean"
else
echo "Usage:"
echo " build.sh iOS build"
echo " build.sh iOS clean"
echo " ---"
echo " build.sh tvOS build"
echo " build.sh tvOS clean"
echo " ---"
echo " build.sh macOS build"
echo " build.sh macOS clean"
exit 1
fi
80 changes: 0 additions & 80 deletions compile-build.sh

This file was deleted.

12 changes: 0 additions & 12 deletions compile-clean.sh

This file was deleted.

4 changes: 0 additions & 4 deletions compile-rebuild.sh

This file was deleted.

4 changes: 2 additions & 2 deletions demo/demo-tvos/demo-tvos.xcodeproj/project.pbxproj
Expand Up @@ -329,7 +329,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.libobjc.SGPlayer.demo-tvos";
PRODUCT_NAME = SGPlayer;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.0;
TVOS_DEPLOYMENT_TARGET = 10.2;
};
name = Debug;
};
Expand All @@ -347,7 +347,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.libobjc.SGPlayer.demo-tvos";
PRODUCT_NAME = SGPlayer;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.0;
TVOS_DEPLOYMENT_TARGET = 10.2;
};
name = Release;
};
Expand Down
46 changes: 46 additions & 0 deletions scripts/avconfig.h
@@ -0,0 +1,46 @@
/*
* avconfig.h
*
* Copyright (c) 2013 Bilibili
* Copyright (c) 2013 Zhang Rui <bbcallen@gmail.com>
*
* This file is part of ijkPlayer.
*
* ijkPlayer is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* ijkPlayer 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with ijkPlayer; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#if defined(__aarch64__)
# include "arm64/avconfig.h"
#elif defined(__x86_64__)
# include "x86_64/avconfig.h"
#elif defined(__arm__)

# if defined(__ARM_ARCH_7S__)
# include "armv7s/avconfig.h"
# elif defined(__ARM_ARCH)
# if __ARM_ARCH == 7
# include "armv7/avconfig.h"
# else
# error Unsupport ARM architecture
# endif
# else
# error Unsupport ARM architecture
# endif

#elif defined(__i386__)
# include "i386/avconfig.h"
#else
# error Unsupport architecture
#endif
170 changes: 170 additions & 0 deletions scripts/compile-ffmpeg.sh
@@ -0,0 +1,170 @@
#! /usr/bin/env bash
#
# Copyright (C) 2013-2014 Bilibili
# Copyright (C) 2013-2014 Zhang Rui <bbcallen@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

#----------
# modify for your build tool

set -e

FF_ALL_ARCHS=
FF_ALL_ARCHS_IOS="armv7 arm64 i386 x86_64"
FF_ALL_ARCHS_TVOS="arm64 x86_64"
FF_ALL_ARCHS_MACOS="x86_64"

FF_PLATFORM=$1
FF_ACTION=$2

#----------
UNI_BUILD_ROOT=`pwd`/build
UNI_TMP="$UNI_BUILD_ROOT/build/tmp"
UNI_TMP_LLVM_VER_FILE="$UNI_TMP/llvm.ver.txt"

#----------
SSL_LIBS="libcrypto libssl"
FF_LIBS="libavcodec libavfilter libavformat libavutil libswscale libswresample"

#----------
echo_archs() {
echo "===================="
echo "[*] check xcode version"
echo "===================="
echo "FF_PLATFORM = $FF_PLATFORM"
echo "FF_ALL_ARCHS = $FF_ALL_ARCHS"
}

do_lipo_ffmpeg () {
LIB_FILE=$1
LIPO_FLAGS=
for ARCH in $FF_ALL_ARCHS
do
ARCH_LIB_FILE="$UNI_BUILD_ROOT/build/$FF_PLATFORM/ffmpeg-$ARCH/output/lib/$LIB_FILE"
if [ -f "$ARCH_LIB_FILE" ]; then
LIPO_FLAGS="$LIPO_FLAGS $ARCH_LIB_FILE"
else
echo "skip $LIB_FILE of $ARCH";
fi
done

xcrun lipo -create $LIPO_FLAGS -output $UNI_BUILD_ROOT/build/$FF_PLATFORM/universal/lib/$LIB_FILE
xcrun lipo -info $UNI_BUILD_ROOT/build/$FF_PLATFORM/universal/lib/$LIB_FILE
}

do_lipo_ssl () {
LIB_FILE=$1
LIPO_FLAGS=
for ARCH in $FF_ALL_ARCHS
do
ARCH_LIB_FILE="$UNI_BUILD_ROOT/build/$FF_PLATFORM/openssl-$ARCH/output/lib/$LIB_FILE"
if [ -f "$ARCH_LIB_FILE" ]; then
LIPO_FLAGS="$LIPO_FLAGS $ARCH_LIB_FILE"
else
echo "skip $LIB_FILE of $ARCH";
fi
done

if [ "$LIPO_FLAGS" != "" ]; then
xcrun lipo -create $LIPO_FLAGS -output $UNI_BUILD_ROOT/build/$FF_PLATFORM/universal/lib/$LIB_FILE
xcrun lipo -info $UNI_BUILD_ROOT/build/$FF_PLATFORM/universal/lib/$LIB_FILE
fi
}

do_lipo_all () {
mkdir -p $UNI_BUILD_ROOT/build/$FF_PLATFORM/universal/lib
echo "lipo archs: $FF_ALL_ARCHS"
for FF_LIB in $FF_LIBS
do
do_lipo_ffmpeg "$FF_LIB.a";
done

ANY_ARCH=
for ARCH in $FF_ALL_ARCHS
do
ARCH_INC_DIR="$UNI_BUILD_ROOT/build/$FF_PLATFORM/ffmpeg-$ARCH/output/include"
if [ -d "$ARCH_INC_DIR" ]; then
if [ -z "$ANY_ARCH" ]; then
ANY_ARCH=$ARCH
cp -R "$ARCH_INC_DIR" "$UNI_BUILD_ROOT/build/$FF_PLATFORM/universal/"
fi

UNI_INC_DIR="$UNI_BUILD_ROOT/build/$FF_PLATFORM/universal/include"

mkdir -p "$UNI_INC_DIR/libavutil/$ARCH"
cp -f "$ARCH_INC_DIR/libavutil/avconfig.h" "$UNI_INC_DIR/libavutil/$ARCH/avconfig.h"
cp -f scripts/avconfig.h "$UNI_INC_DIR/libavutil/avconfig.h"
cp -f "$ARCH_INC_DIR/libavutil/ffversion.h" "$UNI_INC_DIR/libavutil/$ARCH/ffversion.h"
cp -f scripts/ffversion.h "$UNI_INC_DIR/libavutil/ffversion.h"
mkdir -p "$UNI_INC_DIR/libffmpeg/$ARCH"
cp -f "$ARCH_INC_DIR/libffmpeg/config.h" "$UNI_INC_DIR/libffmpeg/$ARCH/config.h"
cp -f scripts/config.h "$UNI_INC_DIR/libffmpeg/config.h"
fi
done

for SSL_LIB in $SSL_LIBS
do
do_lipo_ssl "$SSL_LIB.a";
done
}

#----------
if [ "$FF_PLATFORM" = "iOS" ]; then
FF_ALL_ARCHS=$FF_ALL_ARCHS_IOS
elif [ "$FF_PLATFORM" = "tvOS" ]; then
FF_ALL_ARCHS=$FF_ALL_ARCHS_TVOS
elif [ "$FF_PLATFORM" = "macOS" ]; then
FF_ALL_ARCHS=$FF_ALL_ARCHS_MACOS
else
echo "You must specific an platform 'iOS, tvOS, macOS'.\n"
exit 1
fi

if [ "$FF_ACTION" = "build" ]; then
echo_archs
for ARCH in $FF_ALL_ARCHS
do
sh scripts/do-compile-ffmpeg.sh $FF_PLATFORM $ARCH
done
do_lipo_all
elif [ "$FF_ACTION" = "clean" ]; then
echo_archs
echo "=================="
for ARCH in $FF_ALL_ARCHS
do
echo "clean ffmpeg-$ARCH"
echo "=================="
cd $UNI_BUILD_ROOT/source/$FF_PLATFORM/ffmpeg-$ARCH && git clean -xdf && cd -
done
echo "clean build cache"
echo "================="
rm -rf $UNI_BUILD_ROOT/build/$FF_PLATFORM/ffmpeg-*
rm -rf $UNI_BUILD_ROOT/build/$FF_PLATFORM/openssl-*
rm -rf $UNI_BUILD_ROOT/build/$FF_PLATFORM/universal/include
rm -rf $UNI_BUILD_ROOT/build/$FF_PLATFORM/universal/lib
echo "clean success"
else
echo "Usage:"
echo " compile-ffmpeg.sh iOS build"
echo " compile-ffmpeg.sh iOS clean"
echo " ---"
echo " compile-ffmpeg.sh tvOS build"
echo " compile-ffmpeg.sh tvOS clean"
echo " ---"
echo " compile-ffmpeg.sh macOS build"
echo " compile-ffmpeg.sh macOS clean"
exit 1
fi

0 comments on commit 73f702f

Please sign in to comment.