mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-11-04 22:04:29 +00:00
Implement haxelib versions into crash logs
This commit is contained in:
parent
e507cbd327
commit
14df32d908
|
@ -111,6 +111,7 @@
|
|||
<haxelib name="tink_json" /> <!-- JSON parsing (DEPRECATED) -->
|
||||
<haxelib name="thx.semver" /> <!-- Version string handling -->
|
||||
|
||||
<haxelib name="hmm" if="debug" /> <!-- Read library version data at compile time -->
|
||||
<haxelib name="hxcpp-debug-server" if="desktop debug" /> <!-- VSCode debug support -->
|
||||
|
||||
<!--Disable the Flixel core focus lost screen-->
|
||||
|
|
|
@ -70,7 +70,7 @@ class Constants
|
|||
public static final URL_KICKSTARTER:String = 'https://www.kickstarter.com/projects/funkin/friday-night-funkin-the-full-ass-game/';
|
||||
|
||||
/**
|
||||
* GIT REPO DATA
|
||||
* REPOSITORY DATA
|
||||
*/
|
||||
// ==============================
|
||||
|
||||
|
@ -86,6 +86,11 @@ class Constants
|
|||
public static final GIT_HASH:String = funkin.util.macro.GitCommit.getGitCommitHash();
|
||||
#end
|
||||
|
||||
/**
|
||||
* The current library versions, as provided by hmm.
|
||||
*/
|
||||
public static final LIBRARY_VERSIONS:Array<String> = funkin.util.macro.HaxelibVersions.getLibraryVersions();
|
||||
|
||||
/**
|
||||
* COLORS
|
||||
*/
|
||||
|
|
|
@ -123,6 +123,17 @@ class CrashHandler
|
|||
|
||||
fullContents += '=====================\n';
|
||||
|
||||
fullContents += 'Haxelibs: \n';
|
||||
|
||||
for (lib in Constants.LIBRARY_VERSIONS)
|
||||
{
|
||||
fullContents += '- ${lib}\n';
|
||||
}
|
||||
|
||||
fullContents += '\n';
|
||||
|
||||
fullContents += '=====================\n';
|
||||
|
||||
fullContents += '\n';
|
||||
|
||||
fullContents += message;
|
||||
|
|
67
source/funkin/util/macro/HaxelibVersions.hx
Normal file
67
source/funkin/util/macro/HaxelibVersions.hx
Normal file
|
@ -0,0 +1,67 @@
|
|||
package funkin.util.macro;
|
||||
|
||||
import haxe.io.Path;
|
||||
|
||||
class HaxelibVersions
|
||||
{
|
||||
public static macro function getLibraryVersions():haxe.macro.Expr.ExprOf<Array<String>>
|
||||
{
|
||||
#if !display
|
||||
return macro $v{formatHmmData(readHmmData())};
|
||||
#else
|
||||
// `#if display` is used for code completion. In this case returning an
|
||||
// empty string is good enough; We don't want to call functions on every hint.
|
||||
var commitHash:String = "";
|
||||
return macro $v{commitHashSplice};
|
||||
#end
|
||||
}
|
||||
|
||||
#if (debug && macro)
|
||||
static function readHmmData():hmm.HmmConfig
|
||||
{
|
||||
return hmm.HmmConfig.HmmConfigs.readHmmJsonOrThrow();
|
||||
}
|
||||
|
||||
static function formatHmmData(hmmData:hmm.HmmConfig):Array<String>
|
||||
{
|
||||
var result:Array<String> = [];
|
||||
|
||||
for (library in hmmData.dependencies)
|
||||
{
|
||||
switch (library)
|
||||
{
|
||||
case Haxelib(name, version):
|
||||
result.push('${name} haxelib(${o(version)})');
|
||||
case Git(name, url, ref, dir):
|
||||
result.push('${name} git(${url}/${o(dir, '')}:${o(ref)})');
|
||||
case Mercurial(name, url, ref, dir):
|
||||
result.push('${name} mercurial(${url}/${o(dir, '')}:${o(ref)})');
|
||||
case Dev(name, path):
|
||||
result.push('${name} dev(${path})');
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static function o(option:haxe.ds.Option<String>, defaultValue:String = 'None'):String
|
||||
{
|
||||
switch (option)
|
||||
{
|
||||
case Some(value):
|
||||
return value;
|
||||
case None:
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
static function readLibraryCurrentVersion(libraryName:String):String
|
||||
{
|
||||
var path = Path.join([Path.addTrailingSlash(Sys.getCwd()), '.haxelib', libraryName, '.current']);
|
||||
// This is compile time so we should always have Sys available.
|
||||
var result = sys.io.File.getContent(path);
|
||||
|
||||
return result;
|
||||
}
|
||||
#end
|
||||
}
|
Loading…
Reference in a new issue