Platform lib fixes and improvements (#925)

* Build platform klibs with `-nodefaultlibs`

* Improve android platform libs:

* Add dependencies
* Add header filters
* Add glescommon
* Do minor cleanup

* Add minor code improvements
This commit is contained in:
SvyatoslavScherbina
2017-10-10 11:41:52 +03:00
committed by Nikolay Igotti
parent 5eed839f91
commit 8bc552632d
14 changed files with 47 additions and 20 deletions
@@ -43,7 +43,7 @@ fun SearchPathResolver.resolveImmediateLibraries(libraryNames: List<String>,
noDefaultLibs: Boolean = false,
removeDuplicates: Boolean = true): List<LibraryReaderImpl> {
val defaultLibraries = defaultLinks(noStdLib, noDefaultLibs).map {
val defaultLibraries = defaultLinks(nostdlib = noStdLib, noDefaultLibs = noDefaultLibs).map {
LibraryReaderImpl(it, abiVersion, target, isDefaultLink = true)
}
@@ -82,7 +82,14 @@ fun SearchPathResolver.resolveLibrariesRecursive(libraryNames: List<String>,
noStdLib: Boolean = false,
noDefaultLibs: Boolean = false): List<LibraryReaderImpl> {
return resolveLibrariesRecursive(
resolveImmediateLibraries(libraryNames, target, abiVersion, noStdLib, noDefaultLibs, true),
resolveImmediateLibraries(
libraryNames = libraryNames,
target = target,
abiVersion = abiVersion,
noStdLib = noStdLib,
noDefaultLibs = noDefaultLibs,
removeDuplicates = true
),
target, abiVersion
)
}
+3
View File
@@ -1,3 +1,4 @@
depends = posix
package = platform.android
headers = jni.h android/api-level.h android/asset_manager.h android/asset_manager_jni.h android/bitmap.h \
android/configuration.h android/dlext.h android/input.h android/keycodes.h android/log.h \
@@ -5,6 +6,8 @@ headers = jni.h android/api-level.h android/asset_manager.h android/asset_manage
android/obb.h android/rect.h android/sensor.h android/storage_manager.h android/tts.h \
android/window.h
headerFilter = **
linkerOpts = -landroid -llog -ljnigraphics
---
+2
View File
@@ -1,3 +1,5 @@
depends = glesCommon posix
package = platform.egl
headers = EGL/egl.h EGL/eglext.h EGL/eglplatform.h
headerFilter = EGL/**
linkerOpts = -lEGL
+2
View File
@@ -1,3 +1,5 @@
depends = glesCommon posix
package = platform.gles
headers = GLES/gl.h GLES/glext.h GLES/glplatform.h
headerFilter = GLES/**
linkerOpts = -lGLESv1_CM
+2
View File
@@ -1,3 +1,5 @@
depends = glesCommon posix
package = platform.gles2
headers = GLES2/gl2.h GLES2/gl2ext.h GLES2/gl2platform.h
headerFilter = GLES2/**
linkerOpts = -lGLESv2
+2
View File
@@ -1,3 +1,5 @@
depends = glesCommon posix
package = platform.gles3
headers = GLES3/gl3.h GLES3/gl3ext.h GLES3/gl3platform.h
headerFilter = GLES3/**
linkerOpts = -lGLESv3
+4
View File
@@ -0,0 +1,4 @@
depends = posix
package = platform.glescommon
headers = KHR/khrplatform.h
headerFilter = KHR/**
+6 -14
View File
@@ -1,22 +1,14 @@
depends = posix
package = platform.linux
headers = byteswap.h elf.h endian.h features.h lastlog.h link.h \
malloc.h mntent.h nsswitch.h pathconf.h termio.h thread_db.h time64.h \
malloc.h mntent.h nsswitch.h pathconf.h termio.h thread_db.h \
uchar.h util.h \
sys/epoll.h sys/inotify.h sys/klog.h sys/sendfile.h \
sys/sysconf.h sys/sysinfo.h sys/utime.h \
net/if_ether.h net/if_packet.h netinet/ether.h netinet/in6.h netpacket/packet.h
headers.android_arm32 = time64.h
headerFilter = **
linkerOpts = -ldl
---
// cinterop -target android_arm32 -def klib/src/platform/android/posix.def -o platform.posix.klib
// Wrapper to access errno variable.
static int posix_errno() {
return errno;
}
// Wrapper to access h_errno variable.
static int posix_h_errno() {
return h_errno;
}
+2
View File
@@ -1,4 +1,6 @@
depends = android posix
package = platform.media
headers = media/NdkMediaCodec.h media/NdkMediaCrypto.h media/NdkMediaDrm.h media/NdkMediaError.h \
media/NdkMediaExtractor.h media/NdkMediaFormat.h media/NdkMediaMuxer.h
headerFilter = media/**
linkerOpts = -lmediandk
+2
View File
@@ -1,3 +1,5 @@
depends = posix
package = platform.omxal
headers = OMXAL/OpenMAXAL.h OMXAL/OpenMAXAL_Android.h OMXAL/OpenMAXAL_Platform.h
headerFilter = OMXAL/**
linkerOpts = -lOpenMAXAL
+1
View File
@@ -1,3 +1,4 @@
depends =
package = platform.posix
headers = alloca.h ar.h assert.h complex.h dirent.h dlfcn.h err.h errno.h fcntl.h \
fenv.h fnmatch.h fts.h ftw.h getopt.h grp.h inttypes.h libgen.h limits.h \
+3 -1
View File
@@ -1,4 +1,6 @@
depends = posix
package = platform.sles
headers = SLES//OpenSLES.h SLES/OpenSLES_Android.h SLES/OpenSLES_AndroidConfiguration.h \
SLES/OpenSLES_AndroidMetadata.h SLES/OpenSLES_Platform.h
linkerOpts = -lOpenSLES
headerFilter = SLES/**
linkerOpts = -lOpenSLES
+2
View File
@@ -1,3 +1,5 @@
depends = posix
package = platform.zlib
headers = zconf.h zlib.h
headerFilter = **
linkerOpts = -lz
@@ -27,8 +27,10 @@ import org.jetbrains.kotlin.cli.bc.main as konancMain
import org.jetbrains.kotlin.native.interop.gen.jvm.interop
import org.jetbrains.kotlin.cli.klib.main as klibMain
private val NODEFAULTLIBS = "-nodefaultlibs"
fun invokeCinterop(args: Array<String>) {
val cinteropArgFilter = listOf("-nodefaultlibs")
val cinteropArgFilter = listOf(NODEFAULTLIBS)
var outputFileName = "nativelib"
var target = "host"
@@ -46,7 +48,7 @@ fun invokeCinterop(args: Array<String>) {
libraries.addIfNotNull(nextArg)
if (arg == "-r" || arg == "-repo")
repos.addIfNotNull(nextArg)
if (arg == "-nodefaultlibs")
if (arg == NODEFAULTLIBS)
noDefaultLibs = true
}
@@ -94,7 +96,9 @@ fun invokeCinterop(args: Array<String>) {
"-o", outputFileName,
"-target", target,
"-manifest", manifest.path
) + cinteropArgsToCompiler + libraries.flatMap { listOf("-library", it) } + repos.flatMap { listOf("-repo", it) }
) + cinteropArgsToCompiler + libraries.flatMap { listOf("-library", it) } + repos.flatMap { listOf("-repo", it) } +
if (noDefaultLibs) arrayOf(NODEFAULTLIBS) else emptyArray()
konancMain(konancArgs)
}