Merge branch 'develop' into 8.2.0-Dev

This commit is contained in:
Joseph Cloutier
2024-02-05 14:46:33 -05:00
11 changed files with 162 additions and 72 deletions

File diff suppressed because one or more lines are too long

View File

@@ -10,6 +10,9 @@ import flash.desktop.Clipboard as FlashClipboard;
import lime._internal.backend.html5.HTML5Window; import lime._internal.backend.html5.HTML5Window;
#end #end
/**
Reads and writes text on the system clipboard.
**/
#if !lime_debug #if !lime_debug
@:fileXml('tags="haxe,release"') @:fileXml('tags="haxe,release"')
@:noDebug @:noDebug
@@ -18,8 +21,16 @@ import lime._internal.backend.html5.HTML5Window;
@:access(lime.ui.Window) @:access(lime.ui.Window)
class Clipboard class Clipboard
{ {
/**
Dispatched when the clipboard text changes.
**/
public static var onUpdate = new Event<Void->Void>(); public static var onUpdate = new Event<Void->Void>();
/**
The text currently stored in the clipboard.
**/
public static var text(get, set):String; public static var text(get, set):String;
private static var _text:String; private static var _text:String;
@:noCompletion private static var __updated = false; @:noCompletion private static var __updated = false;

View File

@@ -25,6 +25,9 @@ import js.Browser;
import sys.io.Process; import sys.io.Process;
#end #end
/**
Access operating system level settings and operations.
**/
#if !lime_debug #if !lime_debug
@:fileXml('tags="haxe,release"') @:fileXml('tags="haxe,release"')
@:noDebug @:noDebug
@@ -44,21 +47,68 @@ extern "C" {
#end #end
class System class System
{ {
/**
Determines if the screen saver is allowed to start or not.
**/
public static var allowScreenTimeout(get, set):Bool; public static var allowScreenTimeout(get, set):Bool;
/**
The path to the directory where the application is installed, along with
its supporting files. In many cases, this directory is read-only, and
attempts to write to files, create new files, or delete files in this
directory are likely fail.
**/
public static var applicationDirectory(get, never):String; public static var applicationDirectory(get, never):String;
/**
The application's dedicated storage directory, which unique to each
application and user. Useful for storing settings on a user-specific
and application-specific basis.
This directory may or may not be removed when the application is
uninstalled, and it depends on the platform and installer technology
that is used.
**/
public static var applicationStorageDirectory(get, never):String; public static var applicationStorageDirectory(get, never):String;
/**
The path to the directory containing the user's desktop.
**/
public static var desktopDirectory(get, never):String; public static var desktopDirectory(get, never):String;
public static var deviceModel(get, never):String; public static var deviceModel(get, never):String;
public static var deviceVendor(get, never):String; public static var deviceVendor(get, never):String;
public static var disableCFFI:Bool; public static var disableCFFI:Bool;
/**
The path to the directory containing the user's documents.
**/
public static var documentsDirectory(get, never):String; public static var documentsDirectory(get, never):String;
/**
The platform's default endianness for bytes.
**/
public static var endianness(get, never):Endian; public static var endianness(get, never):Endian;
/**
The path to the directory where fonts are installed.
**/
public static var fontsDirectory(get, never):String; public static var fontsDirectory(get, never):String;
/**
The number of available video displays.
**/
public static var numDisplays(get, never):Int; public static var numDisplays(get, never):Int;
public static var platformLabel(get, never):String; public static var platformLabel(get, never):String;
public static var platformName(get, never):String; public static var platformName(get, never):String;
public static var platformVersion(get, never):String; public static var platformVersion(get, never):String;
/**
The path to the user's home directory.
**/
public static var userDirectory(get, never):String; public static var userDirectory(get, never):String;
@:noCompletion private static var __applicationDirectory:String; @:noCompletion private static var __applicationDirectory:String;
@:noCompletion private static var __applicationEntryPoint:Map<String, Function>; @:noCompletion private static var __applicationEntryPoint:Map<String, Function>;
@:noCompletion private static var __applicationStorageDirectory:String; @:noCompletion private static var __applicationStorageDirectory:String;
@@ -139,6 +189,10 @@ class System
#end #end
#if (!lime_doc_gen || sys) #if (!lime_doc_gen || sys)
/**
Attempts to exit the application. Dispatches `onExit`, and will not
exit if the event is canceled.
**/
public static function exit(code:Int):Void public static function exit(code:Int):Void
{ {
var currentApp = Application.current; var currentApp = Application.current;
@@ -167,6 +221,9 @@ class System
} }
#end #end
/**
Returns information about the video display with the specified ID.
**/
public static function getDisplay(id:Int):Display public static function getDisplay(id:Int):Display
{ {
#if (lime_cffi && !macro) #if (lime_cffi && !macro)
@@ -261,6 +318,9 @@ class System
return null; return null;
} }
/**
The number of milliseconds since the application was initialized.
**/
public static function getTimer():Int public static function getTimer():Int
{ {
#if flash #if flash
@@ -289,6 +349,11 @@ class System
} }
#end #end
/**
Opens a file with the suste, default application.
In a web browser, opens a URL with target `_blank`.
**/
public static function openFile(path:String):Void public static function openFile(path:String):Void
{ {
if (path != null) if (path != null)
@@ -312,6 +377,9 @@ class System
} }
} }
/**
Opens a URL with the specified target web browser window.
**/
public static function openURL(url:String, target:String = "_blank"):Void public static function openURL(url:String, target:String = "_blank"):Void
{ {
if (url != null) if (url != null)

View File

@@ -190,7 +190,9 @@ class Font
{ {
#if (lime_cffi && !macro) #if (lime_cffi && !macro)
var glyphs:Dynamic = NativeCFFI.lime_font_get_glyph_indices(src, characters); var glyphs:Dynamic = NativeCFFI.lime_font_get_glyph_indices(src, characters);
return glyphs; // lime_font_get_glyph_indices returns Array<Int>
// cast it to Array<Glyph> instead (Glyph is an abstract)
return cast glyphs;
#else #else
return null; return null;
#end #end

View File

@@ -1250,17 +1250,10 @@ class HXProject extends Script
{ {
var cache = Log.verbose; var cache = Log.verbose;
Log.verbose = Haxelib.debug; Log.verbose = Haxelib.debug;
var output = ""; var output = Haxelib.runProcess("", ["path", name], true, true, true);
try
{
output = Haxelib.runProcess("", ["path", name], true, true, true);
}
catch (e:Dynamic) {}
Log.verbose = cache; Log.verbose = cache;
var split = output.split("\n"); var split = output != null ? output.split("\n") : [];
var haxelibName = null; var haxelibName = null;
for (arg in split) for (arg in split)

View File

@@ -60,10 +60,10 @@ class HashlinkHelper
{ {
System.copyFile(msvcrPath, Path.combine(applicationDirectory, "msvcr120.dll")); System.copyFile(msvcrPath, Path.combine(applicationDirectory, "msvcr120.dll"));
} }
var vcruntimePath = Path.combine(hlPath, "vcruntime.dll.dll"); var vcruntimePath = Path.combine(hlPath, "vcruntime140.dll");
if (FileSystem.exists(vcruntimePath)) if (FileSystem.exists(vcruntimePath))
{ {
System.copyFile(vcruntimePath, Path.combine(applicationDirectory, "vcruntime.dll")); System.copyFile(vcruntimePath, Path.combine(applicationDirectory, "vcruntime140.dll"));
} }
} }
else if (platform == MAC || platform == IOS) else if (platform == MAC || platform == IOS)

View File

@@ -200,7 +200,7 @@ class AssetLibrary
} }
else else
{ {
return AudioBuffer.fromFile(paths.get(id)); return AudioBuffer.fromFile(getPath(id));
} }
} }
@@ -239,7 +239,7 @@ class AssetLibrary
} }
else else
{ {
return Bytes.fromFile(paths.get(id)); return Bytes.fromFile(getPath(id));
} }
} }
@@ -263,7 +263,7 @@ class AssetLibrary
} }
else else
{ {
return Font.fromFile(paths.get(id)); return Font.fromFile(getPath(id));
} }
} }
@@ -283,7 +283,7 @@ class AssetLibrary
} }
else else
{ {
return Image.fromFile(paths.get(id)); return Image.fromFile(getPath(id));
} }
} }
@@ -498,7 +498,7 @@ class AssetLibrary
} }
else else
{ {
return Bytes.loadFromFile(paths.get(id)); return Bytes.loadFromFile(getPath(id));
} }
} }
@@ -521,9 +521,9 @@ class AssetLibrary
else else
{ {
#if (js && html5) #if (js && html5)
return Font.loadFromName(paths.get(id)); return Font.loadFromName(getPath(id));
#else #else
return Font.loadFromFile(paths.get(id)); return Font.loadFromFile(getPath(id));
#end #end
} }
} }
@@ -579,7 +579,7 @@ class AssetLibrary
} }
else else
{ {
return Image.loadFromFile(paths.get(id)); return Image.loadFromFile(getPath(id));
} }
} }
@@ -607,7 +607,7 @@ class AssetLibrary
else else
{ {
var request = new HTTPRequest<String>(); var request = new HTTPRequest<String>();
return request.load(paths.get(id)); return request.load(getPath(id));
} }
} }

View File

@@ -242,7 +242,8 @@ import flash.media.Sound;
else else
{ {
var basePath = rootPath == null || rootPath == "" ? "" : Path.addTrailingSlash(rootPath); var basePath = rootPath == null || rootPath == "" ? "" : Path.addTrailingSlash(rootPath);
var libPath = paths.exists(id) ? paths.get(id) : id; var libPath = getPath(id);
if (libPath == null) libPath = id;
var path = Path.join([basePath, libPath]); var path = Path.join([basePath, libPath]);
path = __cacheBreak(path); path = __cacheBreak(path);

View File

@@ -145,11 +145,20 @@ class AndroidPlatform extends PlatformTarget
var architectures = []; var architectures = [];
if (hasARMV5) architectures.push(Architecture.ARMV5); if (hasARMV5) architectures.push(Architecture.ARMV5);
if (hasARMV7 || (!hasARMV5 && !hasX86)) architectures.push(Architecture.ARMV7); if (hasARMV7) architectures.push(Architecture.ARMV7);
if (hasARM64) architectures.push(Architecture.ARM64); if (hasARM64) architectures.push(Architecture.ARM64);
if (hasX86) architectures.push(Architecture.X86); if (hasX86) architectures.push(Architecture.X86);
if (hasX64) architectures.push(Architecture.X64); if (hasX64) architectures.push(Architecture.X64);
if (architectures.length == 0)
{
Log.warn("No architecture selected, defaulting to ARM64.");
hasARM64 = true;
architectures.push(Architecture.ARM64);
}
for (architecture in architectures) for (architecture in architectures)
{ {
var haxeParams = [hxml, "-D", "android", "-D", "PLATFORM=android-21"]; var haxeParams = [hxml, "-D", "android", "-D", "PLATFORM=android-21"];

View File

@@ -480,8 +480,7 @@ class IOSPlatform extends PlatformTarget
public override function rebuild():Void public override function rebuild():Void
{ {
var armv6 = (project.architectures.indexOf(Architecture.ARMV6) > -1 && !project.targetFlags.exists("simulator")); var armv6 = (project.architectures.indexOf(Architecture.ARMV6) > -1 && !project.targetFlags.exists("simulator"));
var armv7 = (command == "rebuild" var armv7 = (project.architectures.indexOf(Architecture.ARMV7) > -1 && !project.targetFlags.exists("simulator"));
|| (project.architectures.indexOf(Architecture.ARMV7) > -1 && !project.targetFlags.exists("simulator")));
var armv7s = (project.architectures.indexOf(Architecture.ARMV7S) > -1 && !project.targetFlags.exists("simulator")); var armv7s = (project.architectures.indexOf(Architecture.ARMV7S) > -1 && !project.targetFlags.exists("simulator"));
var arm64 = (command == "rebuild" var arm64 = (command == "rebuild"
|| (project.architectures.indexOf(Architecture.ARM64) > -1 && !project.targetFlags.exists("simulator"))); || (project.architectures.indexOf(Architecture.ARM64) > -1 && !project.targetFlags.exists("simulator")));

View File

@@ -33,9 +33,11 @@ class MacPlatform extends PlatformTarget
private var contentDirectory:String; private var contentDirectory:String;
private var executableDirectory:String; private var executableDirectory:String;
private var executablePath:String; private var executablePath:String;
private var is64:Bool; private var targetArchitecture:Architecture;
private var targetType:String; private var targetType:String;
private var dirSuffix(get, never):String;
public function new(command:String, _project:HXProject, targetFlags:Map<String, String>) public function new(command:String, _project:HXProject, targetFlags:Map<String, String>)
{ {
super(command, _project, targetFlags); super(command, _project, targetFlags);
@@ -93,20 +95,6 @@ class MacPlatform extends PlatformTarget
title: "" title: ""
}; };
switch (System.hostArchitecture)
{
case ARMV6:
defaults.architectures = [ARMV6];
case ARMV7:
defaults.architectures = [ARMV7];
case X86:
defaults.architectures = [X86];
case X64:
defaults.architectures = [X64];
default:
defaults.architectures = [];
}
defaults.window.allowHighDPI = false; defaults.window.allowHighDPI = false;
for (i in 1...project.windows.length) for (i in 1...project.windows.length)
@@ -122,11 +110,13 @@ class MacPlatform extends PlatformTarget
project.architectures.remove(excludeArchitecture); project.architectures.remove(excludeArchitecture);
} }
targetArchitecture = Type.createEnum(Architecture, Type.enumConstructor(System.hostArchitecture));
for (architecture in project.architectures) for (architecture in project.architectures)
{ {
if (architecture == Architecture.X64) if (architecture.match(X86 | X64 | ARMV6 | ARMV7 | ARM64))
{ {
is64 = true; targetArchitecture = architecture;
break;
} }
} }
@@ -137,7 +127,6 @@ class MacPlatform extends PlatformTarget
else if (project.targetFlags.exists("hl") || project.targetFlags.exists("hlc")) else if (project.targetFlags.exists("hl") || project.targetFlags.exists("hlc"))
{ {
targetType = "hl"; targetType = "hl";
is64 = true;
} }
else if (project.targetFlags.exists("java")) else if (project.targetFlags.exists("java"))
{ {
@@ -157,7 +146,7 @@ class MacPlatform extends PlatformTarget
} }
targetDirectory = Path.combine(project.app.path, project.config.getString("mac.output-directory", targetType == "cpp" ? "macos" : targetType)); targetDirectory = Path.combine(project.app.path, project.config.getString("mac.output-directory", targetType == "cpp" ? "macos" : targetType));
targetDirectory = StringTools.replace(targetDirectory, "arch64", is64 ? "64" : ""); targetDirectory = StringTools.replace(targetDirectory, "arch64", dirSuffix);
applicationDirectory = targetDirectory + "/bin/" + project.app.file + ".app"; applicationDirectory = targetDirectory + "/bin/" + project.app.file + ".app";
contentDirectory = applicationDirectory + "/Contents/Resources"; contentDirectory = applicationDirectory + "/Contents/Resources";
executableDirectory = applicationDirectory + "/Contents/MacOS"; executableDirectory = applicationDirectory + "/Contents/MacOS";
@@ -179,11 +168,11 @@ class MacPlatform extends PlatformTarget
// TODO: Support single binary for HashLink // TODO: Support single binary for HashLink
if (targetType == "hl") if (targetType == "hl")
{ {
ProjectHelper.copyLibrary(project, ndll, "Mac" + (is64 ? "64" : ""), "", ".hdll", executableDirectory, project.debug, targetSuffix); ProjectHelper.copyLibrary(project, ndll, "Mac" + dirSuffix, "", ".hdll", executableDirectory, project.debug, targetSuffix);
} }
else else
{ {
ProjectHelper.copyLibrary(project, ndll, "Mac" + (is64 ? "64" : ""), "", ProjectHelper.copyLibrary(project, ndll, "Mac" + dirSuffix, "",
(ndll.haxelib != null (ndll.haxelib != null
&& (ndll.haxelib.name == "hxcpp" || ndll.haxelib.name == "hxlibc")) ? ".dll" : ".ndll", executableDirectory, && (ndll.haxelib.name == "hxcpp" || ndll.haxelib.name == "hxlibc")) ? ".dll" : ".ndll", executableDirectory,
project.debug, targetSuffix); project.debug, targetSuffix);
@@ -197,8 +186,8 @@ 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" + dirSuffix.toLowerCase(), targetDirectory + "/obj/ApplicationMain.n", executablePath);
NekoHelper.copyLibraries(project.templatePaths, "mac" + (is64 ? "64" : ""), executableDirectory); NekoHelper.copyLibraries(project.templatePaths, "mac" + dirSuffix.toLowerCase(), executableDirectory);
} }
else if (targetType == "hl") else if (targetType == "hl")
{ {
@@ -206,7 +195,7 @@ class MacPlatform extends PlatformTarget
if (noOutput) return; if (noOutput) return;
HashlinkHelper.copyHashlink(project, targetDirectory, executableDirectory, executablePath, is64); HashlinkHelper.copyHashlink(project, targetDirectory, executableDirectory, executablePath, true);
if (project.targetFlags.exists("hlc")) if (project.targetFlags.exists("hlc"))
{ {
@@ -275,7 +264,7 @@ class MacPlatform extends PlatformTarget
System.recursiveCopy(targetDirectory + "/obj/lib", Path.combine(executableDirectory, "lib")); System.recursiveCopy(targetDirectory + "/obj/lib", Path.combine(executableDirectory, "lib"));
System.copyFile(targetDirectory + "/obj/ApplicationMain" + (project.debug ? "-Debug" : "") + ".jar", System.copyFile(targetDirectory + "/obj/ApplicationMain" + (project.debug ? "-Debug" : "") + ".jar",
Path.combine(executableDirectory, project.app.file + ".jar")); Path.combine(executableDirectory, project.app.file + ".jar"));
JavaHelper.copyLibraries(project.templatePaths, "Mac" + (is64 ? "64" : ""), executableDirectory); JavaHelper.copyLibraries(project.templatePaths, "Mac" + dirSuffix, executableDirectory);
} }
else if (targetType == "nodejs") else if (targetType == "nodejs")
{ {
@@ -283,8 +272,8 @@ 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" + dirSuffix, targetDirectory + "/obj/ApplicationMain.n", executablePath);
// NekoHelper.copyLibraries (project.templatePaths, "Mac" + (is64 ? "64" : ""), executableDirectory); // NekoHelper.copyLibraries (project.templatePaths, "Mac" + dirSuffix, executableDirectory);
} }
else if (targetType == "cs") else if (targetType == "cs")
{ {
@@ -305,12 +294,18 @@ class MacPlatform extends PlatformTarget
var haxeArgs = [hxml, "-D", "HXCPP_CLANG"]; var haxeArgs = [hxml, "-D", "HXCPP_CLANG"];
var flags = ["-DHXCPP_CLANG"]; var flags = ["-DHXCPP_CLANG"];
if (is64) if (targetArchitecture == X64)
{ {
haxeArgs.push("-D"); haxeArgs.push("-D");
haxeArgs.push("HXCPP_M64"); haxeArgs.push("HXCPP_M64");
flags.push("-DHXCPP_M64"); flags.push("-DHXCPP_M64");
} }
else if (targetArchitecture == ARM64)
{
haxeArgs.push("-D");
haxeArgs.push("HXCPP_ARM64");
flags.push("-DHXCPP_ARM64");
}
if (!project.targetFlags.exists("static")) if (!project.targetFlags.exists("static"))
{ {
@@ -373,7 +368,7 @@ class MacPlatform extends PlatformTarget
context.NODE_FILE = executableDirectory + "/ApplicationMain.js"; context.NODE_FILE = executableDirectory + "/ApplicationMain.js";
context.HL_FILE = targetDirectory + "/obj/ApplicationMain" + (project.defines.exists("hlc") ? ".c" : ".hl"); context.HL_FILE = targetDirectory + "/obj/ApplicationMain" + (project.defines.exists("hlc") ? ".c" : ".hl");
context.CPP_DIR = targetDirectory + "/obj/"; context.CPP_DIR = targetDirectory + "/obj/";
context.BUILD_DIR = project.app.path + "/mac" + (is64 ? "64" : ""); context.BUILD_DIR = project.app.path + "/mac" + dirSuffix.toLowerCase();
return context; return context;
} }
@@ -418,22 +413,27 @@ class MacPlatform extends PlatformTarget
{ {
var commands = []; var commands = [];
if (targetFlags.exists("hl") && System.hostArchitecture == X64) switch (System.hostArchitecture)
{ {
// TODO: Support single binary case X64:
commands.push(["-Dmac", "-DHXCPP_CLANG", "-DHXCPP_M64", "-Dhashlink"]); if (targetFlags.exists("hl"))
} {
else // TODO: Support single binary
{ commands.push(["-Dmac", "-DHXCPP_CLANG", "-DHXCPP_M64", "-Dhashlink"]);
if (!targetFlags.exists("32") && (command == "rebuild" || System.hostArchitecture == X64)) }
{ else if (!targetFlags.exists("32"))
commands.push(["-Dmac", "-DHXCPP_CLANG", "-DHXCPP_M64"]); {
} commands.push(["-Dmac", "-DHXCPP_CLANG", "-DHXCPP_M64"]);
}
if (!targetFlags.exists("64") && (targetFlags.exists("32") || System.hostArchitecture == X86)) else
{ {
commands.push(["-Dmac", "-DHXCPP_CLANG", "-DHXCPP_M32"]);
}
case X86:
commands.push(["-Dmac", "-DHXCPP_CLANG", "-DHXCPP_M32"]); commands.push(["-Dmac", "-DHXCPP_CLANG", "-DHXCPP_M32"]);
} case ARM64:
commands.push(["-Dmac", "-DHXCPP_CLANG", "-DHXCPP_ARM64"]);
default:
} }
if (targetFlags.exists("hl")) if (targetFlags.exists("hl"))
@@ -501,7 +501,7 @@ class MacPlatform extends PlatformTarget
if (ndll.path == null || ndll.path == "") if (ndll.path == null || ndll.path == "")
{ {
context.ndlls[i].path = NDLL.getLibraryPath(ndll, "Mac" + (is64 ? "64" : ""), "lib", ".a", project.debug); context.ndlls[i].path = NDLL.getLibraryPath(ndll, "Mac" + dirSuffix, "lib", ".a", project.debug);
} }
} }
} }
@@ -576,4 +576,11 @@ class MacPlatform extends PlatformTarget
@ignore public override function trace():Void {} @ignore public override function trace():Void {}
@ignore public override function uninstall():Void {} @ignore public override function uninstall():Void {}
// Getters & Setters
private inline function get_dirSuffix():String
{
return targetArchitecture == X64 ? "64" : "";
}
} }