forked from pion/mediadevices
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance cross-platform build system (pion#266)
With this new build system, it'll make it easier to compile third-party libraries statically to multiple platforms.
- Loading branch information
1 parent
f472618
commit 1b5203d
Showing
35 changed files
with
226 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,5 @@ | |
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
scripts/cross |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +0,0 @@ | ||
[submodule "cvendor/src/openh264"] | ||
path = cvendor/src/openh264 | ||
url = https://github.com/cisco/openh264.git | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/bin/bash | ||
|
||
MEDIADEVICES_TOOLCHAIN_OWNER=lherman | ||
MEDIADEVICES_TOOLCHAIN_PREFIX=cross | ||
MEDIADEVICES_SCRIPT_PATH=$(realpath ./scripts) | ||
MEDIADEVICES_TOOLCHAIN_PATH=${MEDIADEVICES_SCRIPT_PATH}/${MEDIADEVICES_TOOLCHAIN_PREFIX} | ||
MEDIADEVICES_DOCKERFILES_PATH=dockerfiles | ||
|
||
# Reference: https://github.com/dockcross/dockcross#cross-compilers | ||
MEDIADEVICES_TARGET_PLATFORMS=( | ||
linux-armv7 | ||
linux-arm64 | ||
linux-x64 | ||
windows-x64 | ||
darwin-x64 | ||
) | ||
|
||
if [[ -z ${VERBOSE} ]]; then | ||
MEDIADEVICES_OUTPUT=/dev/null | ||
else | ||
MEDIADEVICES_OUTPUT=/dev/stdout | ||
fi | ||
|
||
install_toolchains() { | ||
bash ${MEDIADEVICES_DOCKERFILES_PATH}/build.sh &> ${MEDIADEVICES_OUTPUT} | ||
for platform in ${MEDIADEVICES_TARGET_PLATFORMS[@]} | ||
do | ||
mkdir -p ${MEDIADEVICES_TOOLCHAIN_PATH} | ||
image=${MEDIADEVICES_TOOLCHAIN_OWNER}/${MEDIADEVICES_TOOLCHAIN_PREFIX}-${platform} | ||
bin_path=${MEDIADEVICES_TOOLCHAIN_PATH}/${MEDIADEVICES_TOOLCHAIN_PREFIX}-${platform} | ||
docker run ${image} > ${bin_path} | ||
chmod +x ${bin_path} | ||
done | ||
} | ||
|
||
build() { | ||
sub_builds=$(find pkg -type f -name "build.sh") | ||
for sub_build in ${sub_builds[@]} | ||
do | ||
sub_build=$(realpath ${sub_build}) | ||
sub_build_dir=$(dirname ${sub_build}) | ||
current_dir=${PWD} | ||
cd $sub_build_dir | ||
for platform in ${MEDIADEVICES_TARGET_PLATFORMS[@]} | ||
do | ||
export MEDIADEVICES_TOOLCHAIN_BIN=${MEDIADEVICES_TOOLCHAIN_PATH}/${MEDIADEVICES_TOOLCHAIN_PREFIX}-${platform} | ||
# convert '-' to '_' since '_' is more common in library names | ||
export MEDIADEVICES_TARGET_PLATFORM=${platform//-/_} | ||
export MEDIADEVICES_TARGET_OS=$(echo $MEDIADEVICES_TARGET_PLATFORM | cut -d'_' -f1) | ||
export MEDIADEVICES_TARGET_ARCH=${platform//${MEDIADEVICES_TARGET_OS}-/} | ||
|
||
echo "Building ${sub_build_dir}:" | ||
echo " PLATFORM : ${MEDIADEVICES_TARGET_PLATFORM}" | ||
echo " OS : ${MEDIADEVICES_TARGET_OS}" | ||
echo " ARCH : ${MEDIADEVICES_TARGET_ARCH}" | ||
echo " TOOLCHAIN_BIN : ${MEDIADEVICES_TOOLCHAIN_BIN}" | ||
echo "" | ||
|
||
${sub_build} &> ${MEDIADEVICES_OUTPUT} | ||
done | ||
cd ${current_dir} | ||
done | ||
} | ||
|
||
if [[ $# > 0 && $1 != "all" ]]; then | ||
MEDIADEVICES_TARGET_PLATFORMS=($1) | ||
fi | ||
|
||
install_toolchains | ||
build |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Submodule openh264
deleted from
713740
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
cd $(dirname $0) | ||
|
||
OWNER=lherman | ||
PREFIX=cross | ||
IMAGES=$(ls *.Dockerfile) | ||
|
||
for image in ${IMAGES[@]} | ||
do | ||
tag=${OWNER}/cross-${image//.Dockerfile/} | ||
docker build -t "${tag}" -f "$image" . | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM dockcross/base | ||
|
||
ENV OSX_CROSS_PATH=/osxcross | ||
|
||
COPY --from=dockercore/golang-cross "${OSX_CROSS_PATH}/." "${OSX_CROSS_PATH}/" | ||
ENV PATH=${OSX_CROSS_PATH}/target/bin:$PATH | ||
|
||
COPY init.sh /tmp/init.sh | ||
RUN bash /tmp/init.sh | ||
|
||
ENV CC=x86_64-apple-darwin14-clang \ | ||
CXX=x86_64-apple-darwin14-clang++ \ | ||
CPP=x86_64-apple-darwin14-clang++ \ | ||
AR=x86_64-apple-darwin14-ar \ | ||
AS=x86_64-apple-darwin14-as \ | ||
LD=x86_64-apple-darwin14-ld | ||
|
||
ARG IMAGE=lherman/cross-darwin-x64 | ||
ARG VERSION=latest | ||
ENV DEFAULT_DOCKCROSS_IMAGE ${IMAGE}:${VERSION} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
apt-get update | ||
apt-get install -y nasm clang llvm | ||
|
||
curl -L https://golang.org/dl/go1.15.6.linux-amd64.tar.gz | tar -C /usr/local -xzf - | ||
ln -s /usr/local/go/bin/go /usr/local/bin/go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM dockcross/linux-arm64 | ||
|
||
ARG IMAGE=lherman/cross-linux-arm64 | ||
ARG VERSION=latest | ||
ENV DEFAULT_DOCKCROSS_IMAGE ${IMAGE}:${VERSION} | ||
|
||
COPY init.sh /tmp/init.sh | ||
RUN bash /tmp/init.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM dockcross/linux-armv7 | ||
|
||
ARG IMAGE=lherman/cross-linux-armv7 | ||
ARG VERSION=latest | ||
ENV DEFAULT_DOCKCROSS_IMAGE ${IMAGE}:${VERSION} | ||
|
||
COPY init.sh /tmp/init.sh | ||
RUN bash /tmp/init.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM dockcross/linux-x64 | ||
|
||
ARG IMAGE=lherman/cross-linux-x64 | ||
ARG VERSION=latest | ||
ENV DEFAULT_DOCKCROSS_IMAGE ${IMAGE}:${VERSION} | ||
|
||
COPY init.sh /tmp/init.sh | ||
RUN bash /tmp/init.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM dockcross/windows-static-x64-posix | ||
|
||
ARG IMAGE=lherman/cross-windows-x64 | ||
ARG VERSION=latest | ||
ENV DEFAULT_DOCKCROSS_IMAGE ${IMAGE}:${VERSION} | ||
|
||
COPY init.sh /tmp/init.sh | ||
RUN bash /tmp/init.sh | ||
RUN ln -s /usr/src/mxe/usr/bin/x86_64-w64-mingw32.static.posix-gcc /usr/bin/x86_64-w64-mingw32-gcc && \ | ||
ln -s /usr/src/mxe/usr/bin/x86_64-w64-mingw32.static.posix-g++ /usr/bin/x86_64-w64-mingw32-g++ && \ | ||
ln -s /usr/src/mxe/usr/bin/x86_64-w64-mingw32.static.posix-ar /usr/bin/x86_64-w64-mingw32-ar |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Copyright (c) 2013, Cisco Systems | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, | ||
are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, this | ||
list of conditions and the following disclaimer in the documentation and/or | ||
other materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR | ||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
GIT_URL=https://github.com/cisco/openh264.git | ||
VERSION=v2.1.1 | ||
SRC_DIR=src | ||
LIB_DIR=lib | ||
INCLUDE_DIR=include/openh264 | ||
ROOT_DIR=${PWD} | ||
LIB_PREFIX=libopenh264 | ||
|
||
OS=${MEDIADEVICES_TARGET_OS} | ||
ARCH=${MEDIADEVICES_TARGET_ARCH} | ||
|
||
case ${MEDIADEVICES_TARGET_OS} in | ||
windows) | ||
OS=mingw_nt | ||
;; | ||
esac | ||
|
||
case ${MEDIADEVICES_TARGET_ARCH} in | ||
armv6 | armv7 | armv8) | ||
ARCH=arm | ||
;; | ||
x64) | ||
ARCH=x86_64 | ||
;; | ||
esac | ||
|
||
mkdir -p ${LIB_DIR} ${INCLUDE_DIR} | ||
|
||
git clone --depth=1 --branch=${VERSION} ${GIT_URL} ${SRC_DIR} | ||
cd ${SRC_DIR} | ||
${MEDIADEVICES_TOOLCHAIN_BIN} make -j2 ${LIB_PREFIX}.a OS=${OS} ARCH=${ARCH} | ||
${MEDIADEVICES_TOOLCHAIN_BIN} echo $PATH | ||
mv ${LIB_PREFIX}.a ${ROOT_DIR}/${LIB_DIR}/${LIB_PREFIX}_${MEDIADEVICES_TARGET_PLATFORM}.a | ||
mkdir -p ${ROOT_DIR}/${INCLUDE_DIR} | ||
cp codec/api/svc/*.h ${ROOT_DIR}/${INCLUDE_DIR} | ||
make clean |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// +build !dynamic | ||
|
||
package openh264 | ||
|
||
//#cgo CFLAGS: -I${SRCDIR}/include | ||
//#cgo CXXFLAGS: -I${SRCDIR}/include | ||
//#cgo linux,arm LDFLAGS: ${SRCDIR}/lib/libopenh264_linux_armv7.a | ||
//#cgo linux,arm64 LDFLAGS: ${SRCDIR}/lib/libopenh264_linux_arm64.a | ||
//#cgo linux,amd64 LDFLAGS: ${SRCDIR}/lib/libopenh264_linux_x64.a | ||
//#cgo darwin,amd64 LDFLAGS: ${SRCDIR}/lib/libopenh264_darwin_x64.a | ||
//#cgo windows,amd64 LDFLAGS: ${SRCDIR}/lib/libopenh264_windows_x64.a -lssp | ||
import "C" |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.