Skip to content

Commit

Permalink
Fix build for desktop and test projects, update github workflow
Browse files Browse the repository at this point in the history
This removes support for 32-bit Linux x86
  • Loading branch information
dasisdormax committed Aug 18, 2023
1 parent acbc013 commit adebc52
Show file tree
Hide file tree
Showing 10 changed files with 219 additions and 171 deletions.
219 changes: 142 additions & 77 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,109 +5,174 @@ on:
branches: [ master ]

jobs:
macos:
natives-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: 'recursive'
- name: Gradle cache
uses: actions/cache@v2

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Natives cache
uses: actions/cache@v2
distribution: 'zulu'
java-version: '11'


- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Install additional build dependencies
run: brew install nasm

- name: Build with Gradle
run: ./gradlew buildFFmpegMacos64 buildFFmpegMacosARM64 jnigen jnigenBuild

- name: Pack artifacts
run: |
find . -name "*.a" -o -name "*.dll" -o -name "*.dylib" -o -name "*.so" | grep "libs" > native-files-list
zip -r natives-macos -@ < native-files-list
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
path: ~/.ccache
key: ${{ runner.os }}-ccache-${{ github.sha }}
restore-keys: |
${{ runner.os }}-ccache
- name: Set up JDK 1.8
uses: actions/setup-java@v1
name: natives-macos.zip
path: natives-macos.zip

natives-linux:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
java-version: 1.8
fetch-depth: 0
submodules: 'recursive'

- run: brew install yasm ccache
- name: Setup ccache
run: echo "/usr/local/opt/ccache/libexec" >> $GITHUB_PATH
- name: Build with Gradle
run: ./gradlew buildFFmpegMacos64 jnigen jnigenBuild
- name: Upload macOS natives
uses: actions/[email protected]
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Install build dependencies and cross-compilation toolchains
run: |
sudo apt update
sudo apt install -y --force-yes gcc g++
sudo apt install -y --force-yes nasm
sudo apt install -y --force-yes gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libc6-dev-arm64-cross
sudo apt install -y --force-yes gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf libc6-dev-armhf-cross
- name: Build natives with Gradle
run: ./gradlew buildFFmpegLinux64 buildFFmpegLinuxARM32 buildFFmpegLinuxARM64 jnigen jnigenBuildLinux64 jnigenBuildLinuxARM jnigenBuildLinuxARM64 --info

- name: Pack artifacts
run: |
find . -name "*.a" -o -name "*.dll" -o -name "*.dylib" -o -name "*.so" | grep "libs" > native-files-list
zip -r natives-linux -@ < native-files-list
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: natives-linux.zip
path: natives-linux.zip

natives-windows:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: 'recursive'

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Install build dependencies and cross-compilation toolchains
run: |
sudo apt update
sudo apt install -y --force-yes nasm
sudo apt install -y --force-yes mingw-w64 lib32z1
- name: Build natives with Gradle
run: ./gradlew buildFFmpegWindows32 buildFFmpegWindows64 jnigen jnigenBuildWindows jnigenBuildWindows64 jnigenJarNativesDesktop --info

- name: Pack artifacts
run: |
find . -name "*.a" -o -name "*.dll" -o -name "*.dylib" -o -name "*.so" | grep "libs" > native-files-list
zip -r natives-windows -@ < native-files-list
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: macos-natives
path: gdx-video-desktop/libs
name: natives-windows.zip
path: natives-windows.zip

linux:
needs: macos
runs-on: ubuntu-18.04
pack-natives:
needs:
- natives-macos
- natives-linux
- natives-windows
runs-on: ubuntu-20.04
env:
ORG_GRADLE_PROJECT_GITHUB_USERNAME: ""
ORG_GRADLE_PROJECT_GITHUB_API_TOKEN: ""
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: 'recursive'
- name: Gradle cache
uses: actions/cache@v2

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Natives cache
uses: actions/cache@v2
distribution: 'zulu'
java-version: '11'

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Download natives-macos artifact
uses: actions/download-artifact@v3
with:
path: ~/.ccache
key: ${{ runner.os }}-ccache-${{ github.sha }}
restore-keys: |
${{ runner.os }}-ccache
- name: Set up JDK 1.8
uses: actions/setup-java@v1
name: natives-macos.zip

- name: Download natives-linux artifact
uses: actions/download-artifact@v3
with:
java-version: 1.8

- run: sudo sed -i 's/deb http/deb [arch=amd64,i386] http/' /etc/apt/sources.list
- run: sudo grep "ubuntu.com/ubuntu" /etc/apt/sources.list | sudo tee /etc/apt/sources.list.d/ports.list
- run: sudo sed -i 's/amd64,i386/armhf,arm64/' /etc/apt/sources.list.d/ports.list
- run: sudo sed -i 's#http://.*/ubuntu#http://ports.ubuntu.com/ubuntu-ports#' /etc/apt/sources.list.d/ports.list
- name: Add extra platform architectures
run: sudo dpkg --add-architecture i386; sudo dpkg --add-architecture armhf; sudo dpkg --add-architecture arm64
- run: sudo apt-get update || true
- name: Install Windows compilers
run: sudo apt-get -yq install g++-mingw-w64-i686 g++-mingw-w64-x86-64
- name: Install Linux x86 compilers/libraries
run: sudo apt-get -yq install gcc-multilib g++-multilib linux-libc-dev:i386 libstdc++-5-dev:i386 ccache
- name: Install Linux arm32 compilers/libraries
run: sudo apt-get -yq install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf binutils-arm-linux-gnueabihf
- name: Install Linux arm64 compilers/libraries
run: sudo apt-get -yq install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu
- name: Install yasm for ffmpeg
run: sudo apt-get -yq install yasm
- name: Setup ccache
run: echo "/usr/lib/ccache" >> $GITHUB_PATH
- name: Download macOS natives
uses: actions/[email protected]
name: natives-linux.zip

- name: Download natives-windows artifact
uses: actions/download-artifact@v3
with:
name: macos-natives
path: gdx-video-desktop/libs
name: natives-windows.zip

- name: Unpack natives
run: |
unzip -o natives-macos.zip
unzip -o natives-linux.zip
unzip -o natives-windows.zip
- name: Create JAR with natives for desktop
run: ./gradlew jnigenJarNativesDesktop --info

- name: Build natives with Gradle
run: ./gradlew buildFFmpeg jnigen jnigenBuild jnigenJarNativesDesktop --info
- name: Create debug keystore for android
run: keytool -genkey -v -keystore $HOME/.android/debug.keystore -storetype PKCS12 -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000 -noprompt -dname "CN=GdxVideo, OU=libGDX, O=libGDX, L=Unknown, ST=Unknown, C=US"

- name: Build whole project with gradle
run: ./gradlew build

- name: Upload all output libs
if: ${{ always() }}
uses: actions/upload-artifact@v2.1.4
uses: actions/upload-artifact@v3
with:
name: output-libs
path: '**/build/libs/'
path: '**/build/libs/'
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ subprojects {
java {
target 'src/**/*.java'
licenseHeader '/*******************************************************************************\n' +
' * Copyright 2014 See AUTHORS file.\n' +
' * Copyright $YEAR See AUTHORS file.\n' +
' *\n' +
' * Licensed under the Apache License, Version 2.0 (the "License");\n' +
' * you may not use this file except in compliance with the License.\n' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,8 @@ public class VideoPlayerAndroid implements VideoPlayer, OnFrameAvailableListener
private boolean prepared = false;
/** Whether the video was requested to stay paused after loading
*
* To achieve this and still load the first video frame properly,
* we play the video muted until the first frame is available, and
* then pause.
*/
* To achieve this and still load the first video frame properly, we play the video muted until the first frame is available,
* and then pause. */
private boolean pauseRequested = false;
private boolean frameAvailable = false;
/** If the external should be drawn to the fbo and make it available thru {@link #getTexture()} */
Expand Down Expand Up @@ -155,7 +153,7 @@ public void onPrepared (MediaPlayer mp) {
fbo.dispose();
fbo = null;
}
if(pauseRequested) {
if (pauseRequested) {
mp.setVolume(0f, 0f);
}
mp.start();
Expand Down Expand Up @@ -272,7 +270,7 @@ private void setupRenderTexture () {
@Override
public void onFrameAvailable (SurfaceTexture surfaceTexture) {
synchronized (this) {
if(pauseRequested) {
if (pauseRequested) {
player.pause();
pauseRequested = false;
}
Expand Down
34 changes: 12 additions & 22 deletions gdx-video-desktop/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ clean.configure {
dependsOn 'cleanFFmpeg'
}

tasks.register('patchFFmpeg') {
doFirst {
println(System.getenv("PATH"))
}
}

String checkCrossPrefix(String crossToolchain) {
if (crossToolchain == null) return ""
def result = project.exec {
Expand All @@ -56,7 +50,6 @@ void registerBuild(String buildName, String crossToolchain, String... extraArgs)
dependsOn "cleanFFmpeg$buildName"
}
tasks.register("buildFFmpeg$buildName") {
dependsOn patchFFmpeg
doFirst {
mkdir buildDir
String[] crossArgs = []
Expand All @@ -79,30 +72,29 @@ void registerBuild(String buildName, String crossToolchain, String... extraArgs)
}
project.exec {
workingDir buildDir
commandLine 'make', '-j'
commandLine 'make', '-j16'
}
}
outputs.upToDateWhen { file("$buildDir/libavformat/libavformat.a").exists() }
}
}

registerBuild 'Windows32', 'i686-w64-mingw32', '--arch=x86', '--target-os=mingw32', '--pkg-config=pkg-config'
registerBuild 'Windows64', 'x86_64-w64-mingw32', '--arch=x86_64', '--target-os=mingw32', '--pkg-config=pkg-config'
registerBuild 'Windows32', 'i686-w64-mingw32', '--arch=x86', '--target-os=mingw32'
registerBuild 'Windows64', 'x86_64-w64-mingw32', '--arch=x86_64', '--target-os=mingw32'

registerBuild 'Linux32', 'i686-linux-gnu', '--arch=i686', '--target-os=linux', '--extra-cflags="-m32"', '--extra-cxxflags="-m32"', '--extra-ldflags="-m32"'
registerBuild 'Linux64', 'x86_64-linux-gnu', '--arch=x86_64', '--target-os=linux', '--disable-cuda', '--disable-cuvid', '--disable-asm'
registerBuild 'Linux64', 'x86_64-linux-gnu', '--arch=x86_64', '--target-os=linux', '--disable-cuda', '--disable-cuvid'

registerBuild 'LinuxARM32', 'arm-linux-gnueabihf', '--arch=arm', '--target-os=linux'
registerBuild 'LinuxARM64', 'aarch64-linux-gnu', '--arch=aarch64', '--target-os=linux'

registerBuild 'Macos64', null, '--arch=x86_64', '--target-os=darwin', '--cc=clang', '--cxx=clang++', '--dep-cc=clang', '--disable-asm',
registerBuild 'Macos64', null, '--enable-cross-compile', '--arch=x86_64', '--target-os=darwin', '--cc=clang', '--cxx=clang++', '--dep-cc=clang',
'--extra-cflags=-mmacosx-version-min=10.11 -arch x86_64', '--extra-cxxflags=-mmacosx-version-min=10.11 -arch x86_64', '--extra-ldflags=-mmacosx-version-min=10.11 -arch x86_64'
registerBuild 'MacosARM64', null, '--arch=arm64', '--target-os=darwin', '--cc=clang', '--cxx=clang++', '--dep-cc=clang',
registerBuild 'MacosARM64', null, '--enable-cross-compile', '--arch=arm64', '--target-os=darwin', '--cc=clang', '--cxx=clang++', '--dep-cc=clang',
'--extra-cflags=-mmacosx-version-min=10.11 -arch arm64', '--extra-cxxflags=-mmacosx-version-min=10.11 -arch arm64', '--extra-ldflags=-mmacosx-version-min=10.11 -arch arm64'


tasks.register('buildFFmpeg') {
dependsOn buildFFmpegWindows32, buildFFmpegWindows64, buildFFmpegLinux32, buildFFmpegLinux64, buildFFmpegLinuxARM32, buildFFmpegLinuxARM64
dependsOn buildFFmpegWindows32, buildFFmpegWindows64, buildFFmpegLinux64, buildFFmpegLinuxARM32, buildFFmpegLinuxARM64
}

jnigen {
Expand All @@ -128,30 +120,28 @@ jnigen {
add(Windows, x32) {
headerDirs += "../FFmpeg/build-windows32/"
cppFlags += " -DWIN32 "
libraries += genLibs("windows32")
libraries += genLibs("windows32") + " -lbcrypt -lws2_32"
}
add(Windows, x64) {
headerDirs += "../FFmpeg/build-windows64/"
cppFlags += " -DWIN32 "
libraries += genLibs("windows64")
}
add(Linux, x32) {
headerDirs += "../FFmpeg/build-linux32/"
libraries += genLibs("linux32")
compilerPrefix = checkCrossPrefix('i686-linux-gnu')
libraries += genLibs("windows64") + " -lbcrypt -lws2_32"
}
add(Linux, x64) {
headerDirs += "../FFmpeg/build-linux64/"
libraries += genLibs("linux64")
compilerPrefix = checkCrossPrefix('x86_64-linux-gnu')
linkerFlags += " -Wl,-Bsymbolic "
}
add(Linux, x32, ARM) {
headerDirs += "../FFmpeg/build-linuxarm32/"
libraries += genLibs("linuxarm32")
linkerFlags += " -Wl,-Bsymbolic "
}
add(Linux, x64, ARM) {
headerDirs += "../FFmpeg/build-linuxarm64/"
libraries += genLibs("linuxarm64")
linkerFlags += " -Wl,-Bsymbolic "
}
add(MacOsX, x64) {
headerDirs += "../FFmpeg/build-macos64/"
Expand Down
Loading

0 comments on commit adebc52

Please sign in to comment.