Add support for HL libraries

This commit is contained in:
Joshua Granick
2018-04-26 13:55:28 -07:00
parent 94bb8e9ff3
commit 55a640c48b
9 changed files with 56 additions and 21 deletions

View File

@@ -5,7 +5,7 @@
<set name="lime" /> <set name="lime" />
<define name="native" if="cpp || neko || nodejs || cs || java" /> <define name="native" if="cpp || neko || nodejs || cs || java || hl" />
<define name="howlerjs" if="html5" /> <define name="howlerjs" if="html5" />
<define name="lime-html5" if="html5" /> <define name="lime-html5" if="html5" />
@@ -52,7 +52,7 @@
<ndll name="zlib" haxelib="hxcpp" unless="emscripten || ios || tvos" /> <ndll name="zlib" haxelib="hxcpp" unless="emscripten || ios || tvos" />
</section> </section>
<ndll name="lime" if="cpp || neko || nodejs || java" unless="lime-console static_link || lime-switch static_link" /> <ndll name="lime" if="native" unless="lime-console static_link || lime-switch static_link" />
<dependency name="extension-api" path="dependencies/extension-api" if="android" /> <dependency name="extension-api" path="dependencies/extension-api" if="android" />
<dependency path="dependencies/howler.min.js" if="html5 howlerjs" /> <dependency path="dependencies/howler.min.js" if="html5 howlerjs" />

View File

@@ -450,20 +450,22 @@ class NativeCFFI {
@:cffi private static function lime_alc_resume_device (device:CFFIPointer):Void; @:cffi private static function lime_alc_resume_device (device:CFFIPointer):Void;
@:cffi private static function lime_alc_suspend_context (context:CFFIPointer):Void; @:cffi private static function lime_alc_suspend_context (context:CFFIPointer):Void;
#if hl
@:hlNative("lime", "hl_lime_alc_open_device") private static function hl_lime_alc_open_device (devicename:hl.Bytes):lime.media.openal.ALDevice { return null; };
#end
@:cffi private static function lime_al_gen_filter():CFFIPointer; @:cffi private static function lime_al_gen_filter():CFFIPointer;
@:cffi private static function lime_al_filteri(filter:CFFIPointer, param:Int, value:Dynamic):Void; @:cffi private static function lime_al_filteri(filter:CFFIPointer, param:Int, value:Dynamic):Void;
@:cffi private static function lime_al_filterf(filter:CFFIPointer, param:Int, value:Float32):Void; @:cffi private static function lime_al_filterf(filter:CFFIPointer, param:Int, value:Float32):Void;
@:cffi private static function lime_al_remove_direct_filter(source:CFFIPointer):Void; @:cffi private static function lime_al_remove_direct_filter(source:CFFIPointer):Void;
@:cffi private static function lime_al_is_filter (filter:CFFIPointer):Bool; @:cffi private static function lime_al_is_filter (filter:CFFIPointer):Bool;
@:cffi private static function lime_al_get_filteri(filter:CFFIPointer, param:Int):Int; @:cffi private static function lime_al_get_filteri(filter:CFFIPointer, param:Int):Int;
@:cffi private static function lime_al_gen_effect():CFFIPointer; @:cffi private static function lime_al_gen_effect():CFFIPointer;
@:cffi private static function lime_al_effectf(effect:CFFIPointer, param:Int, value:Float32):Void; @:cffi private static function lime_al_effectf(effect:CFFIPointer, param:Int, value:Float32):Void;
@:cffi private static function lime_al_effectfv(effect:CFFIPointer, param:Int, values:Array<Float>):Void; @:cffi private static function lime_al_effectfv(effect:CFFIPointer, param:Int, values:Array<Float>):Void;
@:cffi private static function lime_al_effecti(effect:CFFIPointer, param:Int, value:Int):Void; @:cffi private static function lime_al_effecti(effect:CFFIPointer, param:Int, value:Int):Void;
@:cffi private static function lime_al_effectiv(effect:CFFIPointer, param:Int, values:Array<Int>):Void; @:cffi private static function lime_al_effectiv(effect:CFFIPointer, param:Int, values:Array<Int>):Void;
@:cffi private static function lime_al_is_effect(effect:CFFIPointer):Bool; @:cffi private static function lime_al_is_effect(effect:CFFIPointer):Bool;
@:cffi private static function lime_al_gen_aux():CFFIPointer; @:cffi private static function lime_al_gen_aux():CFFIPointer;
@:cffi private static function lime_al_auxf(aux:CFFIPointer, param:Int, value:Float32):Void; @:cffi private static function lime_al_auxf(aux:CFFIPointer, param:Int, value:Float32):Void;
@:cffi private static function lime_al_auxfv(aux:CFFIPointer, param:Int, values:Array<Float>):Void; @:cffi private static function lime_al_auxfv(aux:CFFIPointer, param:Int, values:Array<Float>):Void;

View File

@@ -77,7 +77,7 @@ class ALC {
public static function getContextsDevice (context:ALContext):ALDevice { public static function getContextsDevice (context:ALContext):ALDevice {
#if (lime_cffi && lime_openal && !macro) #if (lime_cffi && lime_openal && !macro) #if !hl
var handle:Dynamic = NativeCFFI.lime_alc_get_contexts_device (context); var handle:Dynamic = NativeCFFI.lime_alc_get_contexts_device (context);
if (handle != null) { if (handle != null) {
@@ -85,6 +85,9 @@ class ALC {
return new ALDevice (handle); return new ALDevice (handle);
} }
#else
#end
#end #end
return null; return null;
@@ -171,7 +174,7 @@ class ALC {
public static function openDevice (deviceName:String = null):ALDevice { public static function openDevice (deviceName:String = null):ALDevice {
#if (lime_cffi && lime_openal && !macro) #if (lime_cffi && lime_openal && !macro) #if !hl
var handle:Dynamic = NativeCFFI.lime_alc_open_device (deviceName); var handle:Dynamic = NativeCFFI.lime_alc_open_device (deviceName);
if (handle != null) { if (handle != null) {
@@ -179,7 +182,10 @@ class ALC {
return new ALDevice (handle); return new ALDevice (handle);
} }
#end #else
var deviceName = (deviceName != null ? hl.Bytes.fromValue (deviceName, null) : null);
return NativeCFFI.hl_lime_alc_open_device (deviceName);
#end #end
return null; return null;

View File

@@ -1,4 +1,4 @@
package lime.media.openal; package lime.media.openal; #if !hl
import lime.system.CFFIPointer; import lime.system.CFFIPointer;
@@ -18,3 +18,8 @@ abstract ALDevice(CFFIPointer) from CFFIPointer to CFFIPointer {
} }
#else
typedef ALDevice = hl.Abstract<"alc_device">;
#end

View File

@@ -98,15 +98,17 @@ class LinuxPlatform extends PlatformTarget {
if (!project.targetFlags.exists ("static") || targetType != "cpp") { if (!project.targetFlags.exists ("static") || targetType != "cpp") {
var targetSuffix = (targetType == "hl") ? ".hdll" : null;
for (ndll in project.ndlls) { for (ndll in project.ndlls) {
if (isRaspberryPi) { if (isRaspberryPi) {
FileHelper.copyLibrary (project, ndll, "RPi", "", (ndll.haxelib != null && (ndll.haxelib.name == "hxcpp" || ndll.haxelib.name == "hxlibc")) ? ".dso" : ".ndll", applicationDirectory, project.debug); FileHelper.copyLibrary (project, ndll, "RPi", "", (ndll.haxelib != null && (ndll.haxelib.name == "hxcpp" || ndll.haxelib.name == "hxlibc")) ? ".dso" : ".ndll", applicationDirectory, project.debug, targetSuffix);
} else { } else {
FileHelper.copyLibrary (project, ndll, "Linux" + (is64 ? "64" : ""), "", (ndll.haxelib != null && (ndll.haxelib.name == "hxcpp" || ndll.haxelib.name == "hxlibc")) ? ".dso" : ".ndll", applicationDirectory, project.debug); FileHelper.copyLibrary (project, ndll, "Linux" + (is64 ? "64" : ""), "", (ndll.haxelib != null && (ndll.haxelib.name == "hxcpp" || ndll.haxelib.name == "hxlibc")) ? ".dso" : ".ndll", applicationDirectory, project.debug, targetSuffix);
} }
@@ -139,13 +141,12 @@ class LinuxPlatform extends PlatformTarget {
if (noOutput) return; if (noOutput) return;
FileHelper.copyFile (targetDirectory + "/obj/ApplicationMain" + (project.debug ? "-Debug" : "") + ".hl", PathHelper.combine (applicationDirectory, project.app.file + ".hl")); FileHelper.copyFile (targetDirectory + "/obj/ApplicationMain" + (project.debug ? "-Debug" : "") + ".hl", PathHelper.combine (applicationDirectory, project.app.file + ".hl"));
NekoHelper.copyLibraries (project.templatePaths, "linux" + (is64 ? "64" : ""), applicationDirectory);
} else if (targetType == "nodejs") { } else if (targetType == "nodejs") {
ProcessHelper.runCommand ("", "haxe", [ hxml ]); ProcessHelper.runCommand ("", "haxe", [ hxml ]);
//NekoHelper.createExecutable (project.templatePaths, "linux" + (is64 ? "64" : ""), targetDirectory + "/obj/ApplicationMain.n", executablePath); //NekoHelper.createExecutable (project.templatePaths, "linux" + (is64 ? "64" : ""), targetDirectory + "/obj/ApplicationMain.n", executablePath);
NekoHelper.copyLibraries (project.templatePaths, "linux" + (is64 ? "64" : ""), applicationDirectory); //NekoHelper.copyLibraries (project.templatePaths, "linux" + (is64 ? "64" : ""), applicationDirectory);
} else if (targetType == "java") { } else if (targetType == "java") {

View File

@@ -98,9 +98,11 @@ class MacPlatform extends PlatformTarget {
if (!project.targetFlags.exists ("static") || targetType != "cpp") { if (!project.targetFlags.exists ("static") || targetType != "cpp") {
var targetSuffix = (targetType == "hl") ? ".hdll" : null;
for (ndll in project.ndlls) { for (ndll in project.ndlls) {
FileHelper.copyLibrary (project, ndll, "Mac" + (is64 ? "64" : ""), "", (ndll.haxelib != null && (ndll.haxelib.name == "hxcpp" || ndll.haxelib.name == "hxlibc")) ? ".dylib" : ".ndll", executableDirectory, project.debug); FileHelper.copyLibrary (project, ndll, "Mac" + (is64 ? "64" : ""), "", (ndll.haxelib != null && (ndll.haxelib.name == "hxcpp" || ndll.haxelib.name == "hxlibc")) ? ".dylib" : ".ndll", executableDirectory, project.debug, targetSuffix);
} }
@@ -122,7 +124,6 @@ class MacPlatform extends PlatformTarget {
if (noOutput) return; if (noOutput) return;
FileHelper.copyFile (targetDirectory + "/obj/ApplicationMain" + (project.debug ? "-Debug" : "") + ".hl", PathHelper.combine (executableDirectory, project.app.file + ".hl")); FileHelper.copyFile (targetDirectory + "/obj/ApplicationMain" + (project.debug ? "-Debug" : "") + ".hl", PathHelper.combine (executableDirectory, project.app.file + ".hl"));
NekoHelper.copyLibraries (project.templatePaths, "mac" + (is64 ? "64" : ""), executableDirectory);
} else if (targetType == "java") { } else if (targetType == "java") {
@@ -144,7 +145,7 @@ class MacPlatform extends PlatformTarget {
if (noOutput) return; if (noOutput) return;
//NekoHelper.createExecutable (project.templatePaths, "Mac" + (is64 ? "64" : ""), targetDirectory + "/obj/ApplicationMain.n", executablePath); //NekoHelper.createExecutable (project.templatePaths, "Mac" + (is64 ? "64" : ""), targetDirectory + "/obj/ApplicationMain.n", executablePath);
NekoHelper.copyLibraries (project.templatePaths, "Mac" + (is64 ? "64" : ""), executableDirectory); //NekoHelper.copyLibraries (project.templatePaths, "Mac" + (is64 ? "64" : ""), executableDirectory);
} else if (targetType == "cs") { } else if (targetType == "cs") {

View File

@@ -165,9 +165,11 @@ class WindowsPlatform extends PlatformTarget {
if (!project.targetFlags.exists ("static") || targetType != "cpp") { if (!project.targetFlags.exists ("static") || targetType != "cpp") {
var targetSuffix = (targetType == "hl") ? ".hdll" : null;
for (ndll in project.ndlls) { for (ndll in project.ndlls) {
FileHelper.copyLibrary (project, ndll, "Windows" + (is64 ? "64" : ""), "", (ndll.haxelib != null && (ndll.haxelib.name == "hxcpp" || ndll.haxelib.name == "hxlibc")) ? ".dll" : ".ndll", applicationDirectory, project.debug); FileHelper.copyLibrary (project, ndll, "Windows" + (is64 ? "64" : ""), "", (ndll.haxelib != null && (ndll.haxelib.name == "hxcpp" || ndll.haxelib.name == "hxlibc")) ? ".dll" : ".ndll", applicationDirectory, project.debug, targetSuffix);
} }
@@ -199,7 +201,6 @@ class WindowsPlatform extends PlatformTarget {
if (noOutput) return; if (noOutput) return;
FileHelper.copyFile (targetDirectory + "/obj/ApplicationMain" + (project.debug ? "-Debug" : "") + ".hl", PathHelper.combine (applicationDirectory, project.app.file + ".hl")); FileHelper.copyFile (targetDirectory + "/obj/ApplicationMain" + (project.debug ? "-Debug" : "") + ".hl", PathHelper.combine (applicationDirectory, project.app.file + ".hl"));
NekoHelper.copyLibraries (project.templatePaths, "windows" + (is64 ? "64" : ""), applicationDirectory);
} else if (targetType == "nodejs") { } else if (targetType == "nodejs") {
@@ -208,7 +209,7 @@ class WindowsPlatform extends PlatformTarget {
if (noOutput) return; if (noOutput) return;
//NekoHelper.createExecutable (project.templatePaths, "windows" + (is64 ? "64" : ""), targetDirectory + "/obj/ApplicationMain.n", executablePath); //NekoHelper.createExecutable (project.templatePaths, "windows" + (is64 ? "64" : ""), targetDirectory + "/obj/ApplicationMain.n", executablePath);
NekoHelper.copyLibraries (project.templatePaths, "windows" + (is64 ? "64" : ""), applicationDirectory); //NekoHelper.copyLibraries (project.templatePaths, "windows" + (is64 ? "64" : ""), applicationDirectory);
} else if (targetType == "cs") { } else if (targetType == "cs") {

View File

@@ -56,6 +56,7 @@
<files id="lime"> <files id="lime">
<compilerflag value="-Iinclude" /> <compilerflag value="-Iinclude" />
<compilerflag value="-DLIBHL_EXPORTS" />
<file name="src/ExternalInterface.cpp" /> <file name="src/ExternalInterface.cpp" />

View File

@@ -1889,6 +1889,18 @@ namespace lime {
} }
HL_PRIM ALCdevice* HL_NAME (alc_open_device) (vbyte *devicename) {
ALCdevice* alcDevice = alcOpenDevice ((char*)devicename);
atexit (lime_al_atexit);
// TODO: GC
return alcDevice;
}
void lime_alc_pause_device (value device) { void lime_alc_pause_device (value device) {
#ifdef LIME_OPENALSOFT #ifdef LIME_OPENALSOFT
@@ -2041,6 +2053,12 @@ namespace lime {
DEFINE_PRIME1v (lime_alc_resume_device); DEFINE_PRIME1v (lime_alc_resume_device);
DEFINE_PRIME1v (lime_alc_suspend_context); DEFINE_PRIME1v (lime_alc_suspend_context);
#define TDEVICE _ABSTRACT (alc_device)
#define TCONTEXT _ABSTRACT (alc_context)
DEFINE_HL_PRIM (TDEVICE, hl_lime_alc_open_device, _BYTES);
} }