Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion natives/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.12)
project(lpnatives C)

add_subdirectory(samplerate)
add_subdirectory(fdk-aac)
Expand Down
87 changes: 34 additions & 53 deletions natives/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'de.undercouch.download'
id "de.undercouch.download" version "5.4.0"
}

import org.apache.tools.ant.taskdefs.condition.Os
Expand All @@ -8,26 +8,30 @@ import java.util.regex.Pattern

apply from: 'natives.gradle'

ext.opusVersion = '1.3'
ext.mpg123Version = '1.25.10'
ext.oggVersion = '1.3.3'
ext.vorbisVersion = '1.3.6'
ext.sampleRateVersion = '0.1.9'
ext.fdkAacVersion = '2.0.0'
ext.opusVersion = '1.4'
ext.mpg123Version = '1.31.3'
ext.oggVersion = '1.3.5'
ext.vorbisVersion = '1.3.7'
ext.sampleRateVersion = '0.2.2'
ext.fdkAacVersion = '2.0.2'

task load {
doLast {
if (!file("$projectDir/samplerate/src").exists()) {
def downloadPath = "$buildDir/tmp/libsamplerate.tar.gz"
def tarPath = "$buildDir/tmp/libsamplerate.tar"
def downloadPath = "${tarPath}.xz"
def unpackPath = "$buildDir/tmp"

download.run {
src "https://www.mega-nerd.com/SRC/libsamplerate-${sampleRateVersion}.tar.gz"
src "https://github.com/libsndfile/libsamplerate/releases/download/${sampleRateVersion}/libsamplerate-${sampleRateVersion}.tar.xz"
dest downloadPath
}

exec {
commandLine('xz', '-d', downloadPath)
}

copy {
from tarTree(resources.gzip(downloadPath))
from tarTree(file(tarPath))
into unpackPath
}

Expand All @@ -38,53 +42,47 @@ task load {
}

if (!file("$projectDir/fdk-aac/libAACdec").exists()) {
def downloadPath = "$buildDir/tmp/fdk-aac-v${fdkAacVersion}.zip"
def unpackPath = "$buildDir"

def downloadPath = "$buildDir/tmp/fdk-aac-v${fdkAacVersion}.tar.gz"
def unpackPath = "$projectDir/fdk-aac"
download.run {
src "https://github.com/mstorsjo/fdk-aac/archive/v${fdkAacVersion}.zip"
src "https://github.com/mstorsjo/fdk-aac/archive/v${fdkAacVersion}.tar.gz"
dest downloadPath
}

copy {
from zipTree(file(downloadPath))
from tarTree(file(downloadPath))
into unpackPath
}

copy {
from "$unpackPath/fdk-aac-${fdkAacVersion}"
into "$projectDir/fdk-aac"
}
}

if (!file("$projectDir/vorbis/libogg-${oggVersion}").exists()) {
def downloadPath = "$buildDir/tmp/temp.zip"
def unpackPath = "$buildDir"

def downloadPath = "$buildDir/tmp/libogg.tar.gz"
def unpackPath = "$projectDir/vorbis"
download.run {
src "https://downloads.xiph.org/releases/ogg/libogg-${oggVersion}.zip"
src "https://downloads.xiph.org/releases/ogg/libogg-${oggVersion}.tar.gz"
dest downloadPath
}

copy {
from zipTree(file(downloadPath))
into "$projectDir/vorbis"
from tarTree(file(downloadPath))
into unpackPath
}

downloadPath = "$buildDir/tmp/libvorbis.tar.gz"
download.run {
src "https://downloads.xiph.org/releases/vorbis/libvorbis-${vorbisVersion}.zip"
src "https://downloads.xiph.org/releases/vorbis/libvorbis-${vorbisVersion}.tar.gz"
dest downloadPath
}

copy {
from zipTree(file(downloadPath))
into "$projectDir/vorbis"
from tarTree(file(downloadPath))
into unpackPath
}
}

if (!file("$projectDir/opus/opus-${opusVersion}").exists()) {
def downloadPath = "$buildDir/tmp/temp.tar.gz"
def unpackPath = "$buildDir"
def downloadPath = "$buildDir/tmp/libopus.tar.gz"
def unpackPath = "$projectDir/opus"

download.run {
src "https://downloads.xiph.org/releases/opus/opus-${opusVersion}.tar.gz"
Expand All @@ -93,13 +91,13 @@ task load {

copy {
from tarTree(file(downloadPath))
into "$projectDir/opus"
into unpackPath
}
}

if (!Os.isFamily(Os.FAMILY_WINDOWS) && !file("$projectDir/mp3/mpg123-${mpg123Version}").exists()) {
def downloadPath = "$buildDir/tmp/temp.tar.bz2"
def unpackPath = "$buildDir"
def downloadPath = "$buildDir/tmp/libmpg123.tar.bz2"
def unpackPath = "$projectDir/mp3"

download.run {
src "https://www.mpg123.de/download/mpg123-${mpg123Version}.tar.bz2"
Expand All @@ -108,7 +106,7 @@ task load {

copy {
from tarTree(file(downloadPath))
into "$projectDir/mp3"
into unpackPath
}
}
}
Expand Down Expand Up @@ -198,27 +196,10 @@ def buildOpusOnLinux(force) {
}
}

def extractVersionPrefix(fullVersion, partCount) {
def parts = fullVersion.split('\\.').toList()
return parts.subList(0, Math.min(partCount, parts.size())).join('.')
}

def replaceAutotoolsVersion(directory, originalVersion) {
def localVersion = (['automake', '--version'].execute().text =~ /\(GNU automake\) ([0-9.]+)/)[0][1]
def localMajorVersion = extractVersionPrefix(localVersion, 2)
def originalMajorVersion = extractVersionPrefix(originalVersion, 2)

[file("$directory/aclocal.m4"), file("$directory/configure")].each {
it.text = it.text.replace("am__api_version='$originalMajorVersion'", "am__api_version='$localMajorVersion'").replace(originalVersion, localVersion)
}
}

def buildMpg123OnLinux(force) {
def present = file("${projectDir}/libs/64/libmpg123.a").exists()

if (force || !present) {
replaceAutotoolsVersion("$projectDir/mp3/mpg123-${mpg123Version}", '1.15.1')

def flags = "-fPIC -O3 -fdata-sections -ffunction-sections"
def process = ['./configure', '--enable-static', '--with-cpu=x86-64', '--with-pic', "CFLAGS=$flags", "CXXFLAGS=$flags"].
execute(null as String[], file("$projectDir/mp3/mpg123-${mpg123Version}"))
Expand Down
10 changes: 5 additions & 5 deletions natives/connector/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ set(CMAKE_CXX_FLAGS_RELEASE "${COMPILER_FLAGS} ${COMPILER_FLAGS_RELEASE}")
include_directories("$ENV{JAVA_HOME}/include/")

include_directories("${samplerate_SOURCE_DIR}/src")
include_directories("../opus/opus-1.3/include")
include_directories("../fdk-aac/libAACdec/include")
include_directories("../fdk-aac/libSYS/include")
include_directories("../vorbis/libvorbis-1.3.6/include")
include_directories("../vorbis/libogg-1.3.3/include")
include_directories("../opus/opus-1.4/include")
include_directories("../fdk-aac/fdk-aac-2.0.2/libAACdec/include")
include_directories("../fdk-aac/fdk-aac-2.0.2/libSYS/include")
include_directories("../vorbis/libvorbis-1.3.7/include")
include_directories("../vorbis/libogg-1.3.5/include")
link_directories("../libs/64")

if (DEFINED ENV{DIST_DIR})
Expand Down
8 changes: 5 additions & 3 deletions natives/fdk-aac/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ project(fdk-aac CXX)

get_filename_component(ROOT_DIR "." ABSOLUTE)

set(MAIN_DIRS "${ROOT_DIR}/libAACdec" "${ROOT_DIR}/libFDK" "${ROOT_DIR}/libSYS" "${ROOT_DIR}/libMpegTPDec" "${ROOT_DIR}/libSBRdec" "${ROOT_DIR}/libPCMutils" "${ROOT_DIR}/libArithCoding" "${ROOT_DIR}/libDRCdec" "${ROOT_DIR}/libSACdec")
set(FDK_SOURCE "${ROOT_DIR}/fdk-aac-2.0.2")

set(FDK_DIRS "${FDK_SOURCE}/libAACdec" "${FDK_SOURCE}/libFDK" "${FDK_SOURCE}/libSYS" "${FDK_SOURCE}/libMpegTPDec" "${FDK_SOURCE}/libSBRdec" "${FDK_SOURCE}/libPCMutils" "${FDK_SOURCE}/libArithCoding" "${FDK_SOURCE}/libDRCdec" "${FDK_SOURCE}/libSACdec")
set(MAIN_SOURCES "")

message(STATUS "${MAIN_DIRS}")
message(STATUS "${FDK_DIRS}")

foreach(subdir ${MAIN_DIRS})
foreach(subdir ${FDK_DIRS})
file (GLOB dir_sources "${subdir}/src/*.cpp" "${subdir}/src/*.h" "${subdir}/include/*.h")
set (MAIN_SOURCES ${MAIN_SOURCES} ${dir_sources})

Expand Down
4 changes: 2 additions & 2 deletions natives/samplerate/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ cmake_minimum_required(VERSION 3.0)
project(samplerate C)

if(NOT ${CMAKE_C_COMPILER_ID} STREQUAL "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -fdata-sections -ffunction-sections")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -fdata-sections -ffunction-sections -DHAVE_CONFIG_H")
else()
set(CMAKE_C_FLAGS_RELEASE "/MT")
set(CMAKE_C_FLAGS_RELEASE "/MT /DHAVE_CONFIG_H")
endif()

include_directories(.)
Expand Down
3 changes: 2 additions & 1 deletion natives/samplerate/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
#define HAVE_LRINT 1
#define HAVE_LRINTF 1
#define HAVE_STDINT_H 1
#define HAVE_STDBOOL_H 1

#define PACKAGE "libsamplerate"
#define VERSION "0.1.9"
#define VERSION "0.2.2"

#ifdef _MSC_VER
#define inline __inline
Expand Down
10 changes: 5 additions & 5 deletions natives/vorbis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ cmake_minimum_required(VERSION 3.0)
project(vorbis C)

get_filename_component(ROOT_DIR "." ABSOLUTE)
set(VORBIS_SOURCE "${ROOT_DIR}/libvorbis-1.3.6/lib")
set(OGG_SOURCE "${ROOT_DIR}/libogg-1.3.3/src")
set(VORBIS_SOURCE "${ROOT_DIR}/libvorbis-1.3.7/lib")
set(OGG_SOURCE "${ROOT_DIR}/libogg-1.3.5/src")

if ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
set(CMAKE_C_FLAGS_RELEASE "/MT")
Expand All @@ -17,8 +17,8 @@ file(GLOB MAIN_SOURCES "${VORBIS_SOURCE}/*.c" "${OGG_SOURCE}/*.c")
list(REMOVE_ITEM MAIN_SOURCES "${VORBIS_SOURCE}/psytune.c")
list(REMOVE_ITEM MAIN_SOURCES "${VORBIS_SOURCE}/tone.c")

include_directories("${ROOT_DIR}/libogg-1.3.3/include")
include_directories("${ROOT_DIR}/libvorbis-1.3.6/include")
include_directories("${ROOT_DIR}/libvorbis-1.3.6/lib")
include_directories("${ROOT_DIR}/libogg-1.3.5/include")
include_directories("${ROOT_DIR}/libvorbis-1.3.7/include")
include_directories("${ROOT_DIR}/libvorbis-1.3.7/lib")

add_library(vorbis STATIC ${MAIN_SOURCES})