Skip to content

Commit 1950b1d

Browse files
committed
new version, new functions
- Added support for the “Jansson” library. - Integrated UDP Listener to view Wii U logs natively from HxCompileU using “--udpServer” command (EXPERIMENTAL) - Now you can send the generated RPX to the Wii U using the command “--sendRPX” using the DevKitPro program “wiiload”.
1 parent 38779c5 commit 1950b1d

File tree

6 files changed

+98
-3
lines changed

6 files changed

+98
-3
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Currently supported libraries to be used in conjunction with HxCompileU:
1111
- [SlushiUtilsU](https://github.com/Slushi-Github/slushiUtilsU): a library to facilitate the use of certain Wii U libraries.
1212
- [hxSDL2](https://github.com/Slushi-Github/hxSDL2): SDL2 (SDL2, SDL2_Image, SDL2_mixer...) @:native bindings for Haxe, for use SDL2 on the Wii U.
1313
- [hxSDL_FontCache](https://github.com/Slushi-Github/hxSDL_FontCache): SDL_FontCache @:native bindings for Haxe to do homebrew on Wii U.
14+
- [hxJansson](https://github.com/Slushi-Github/hxJansson): Jansson @:native bindings for Haxe to do homebrew on Wii U.
1415

1516
## How?
1617
The magic really comes from [reflaxe.CPP](https://github.com/SomeRanDev/reflaxe.CPP), being an alternative to [HXCPP](https://github.com/HaxeFoundation/hxcpp) when you want to compile Haxe to C++.
@@ -73,4 +74,9 @@ You can also use the following command search a line of code in the ``.elf`` fil
7374
``{haxeCompileUProgram} --searchProblem [lineAddress]``
7475

7576

76-
and that's it! if your compilation was successful on both Haxe and Wii U side, your ``.rpx`` and ``.elf`` will be in ``yourOuputFolder/wiiuFiles``.
77+
You can also use the following command send the ``.rpx`` file to the Wii U using DevKitPro's ``wiiload`` program:
78+
79+
``{haxeCompileUProgram} --sendRPX``
80+
81+
82+
and that's it! if your compilation was successful on both Haxe and Wii U side, your ``.rpx`` and ``.elf`` will be in ``yourOuputFolder/wiiuFiles``.

src/JsonFile.hx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ typedef HaxeConfig = {
2323

2424
typedef WiiUConfig = {
2525
projectName:String,
26+
consoleIP:String,
2627
}
2728

2829
typedef ConsoleSettings = {
@@ -67,6 +68,7 @@ class JsonFile {
6768
},
6869
wiiuConfig: {
6970
projectName: jsonContent.wiiuConfig.projectName,
71+
consoleIP: jsonContent.wiiuConfig.consoleIP,
7072
},
7173
deleteTempFiles: jsonContent.deleteTempFiles,
7274
extraLibs: jsonContent.extraLibs,
@@ -99,6 +101,7 @@ class JsonFile {
99101
},
100102
wiiuConfig: {
101103
projectName: "project",
104+
consoleIP: "0.0.0.0",
102105
},
103106
deleteTempFiles: true,
104107
extraLibs: [],

src/Main.hx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ package src;
33
import src.SlushiUtils;
44
import src.compilers.MainCompiler;
55
import src.utils.DevKitProUtils;
6+
import src.utils.UDPListener;
67

78
class Main {
89
public static var hxcompileuString = "\x1b[38;5;214mHx\033[0mCompile\x1b[38;5;74mU\033[0m";
9-
public static var version:String = "1.3.2";
10+
public static var version:String = "1.3.4";
1011
static var stdin = Sys.stdin();
1112
static var stdout = Sys.stdout();
1213
static var args = Sys.args();
@@ -33,8 +34,12 @@ class Main {
3334
MainCompiler.start(args[1]);
3435
case "--searchProblem":
3536
DevKitProUtils.searchProblem(args[1]);
37+
case "--udpServer":
38+
UDPListener.start();
39+
case "--sendRPX":
40+
DevKitProUtils.sendRPX();
3641
case "--version":
37-
SlushiUtils.printMsg('$hxcompileuString v$version -- Created by \033[96mSlushi\033[0m', NONE);
42+
// No need to print the version here, it's already printed at the start of the program
3843
case "--help":
3944
SlushiUtils.printMsg("Usage: hxCompileU [command]\nCommands:\n\t--prepare: Creates hxCompileUConfig.json\n\t--compile: Compiles the project (use \"--compile --onlyHaxe\" for compiling only the Haxe part)\n\t--searchProblem: search for a line of code in the [.elf] file from a line address of some log using DevKitPro's powerpc-eabi-addr2line \n\t--version: Shows the version of the compiler\n\t--help: Shows this message",
4045
NONE);

src/utils/DevKitProUtils.hx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package src.utils;
22

3+
import haxe.io.Path;
4+
35
/**
46
* The DevKitProUtils class is used to use the DevKitPro tools
57
* For now, only the powerpc-eabi-addr2line tool is used.
@@ -35,4 +37,35 @@ class DevKitProUtils {
3537
Sys.command(addr2lineProgram, ["-e", elfPath, address]);
3638
SlushiUtils.printMsg("----------------------", NONE);
3739
}
40+
41+
public static function sendRPX():Void {
42+
var rpxPath:String = SlushiUtils.getPathFromCurrentTerminal() + "/" + jsonFile.haxeConfig.outDir + "/wiiuFiles/" + jsonFile.wiiuConfig.projectName
43+
+ ".rpx";
44+
if (!FileSystem.exists(rpxPath)) {
45+
SlushiUtils.printMsg("[.rpx] file not found", ERROR);
46+
return;
47+
}
48+
49+
// remove path from the file name
50+
var rpxFileName:String = Path.withoutDirectory(rpxPath);
51+
52+
SlushiUtils.printMsg("Sending RPX file: [" + rpxFileName + "]", PROCESSING);
53+
54+
var devKitProToolsEnv = Sys.getEnv("DEVKITPRO");
55+
56+
var wiiloadProgram = devKitProToolsEnv + "/tools/bin/wiiload";
57+
58+
if (Sys.getEnv("WIILOAD") == null) {
59+
Sys.putEnv("WIILOAD", jsonFile.wiiuConfig.consoleIP);
60+
} else {
61+
SlushiUtils.printMsg("WIILOAD environment variable already set, using that...", WARN);
62+
}
63+
64+
if (devKitProToolsEnv == null) {
65+
SlushiUtils.printMsg("DEVKITPRO environment variable not found", ERROR);
66+
return;
67+
}
68+
69+
Sys.command(wiiloadProgram, [rpxPath]);
70+
}
3871
}

src/utils/Libs.hx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ class Libs {
7070
haxeLibraries: {libName: "hxsdl_fontcache", requirePreparation: true, skip: false},
7171
cafeLibraries: {libsArray: [], skip: true}
7272
},
73+
"jansson" => {
74+
haxeLibraries: {libName: "hxjansson", requirePreparation: false, skip: false},
75+
cafeLibraries: {libsArray: ["jansson"], skip: false}
76+
},
7377
// EXPERIMENTAL:
7478
"leafyEngine" => {
7579
haxeLibraries: {libName: "leafyengine", requirePreparation: false, skip: false},

src/utils/UDPListener.hx

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package src.utils;
2+
3+
import sys.net.Host;
4+
import sys.net.Address;
5+
import sys.net.UdpSocket;
6+
import haxe.io.Bytes;
7+
8+
class UDPListener {
9+
public static function start() {
10+
var udpIp = "0.0.0.0";
11+
var udpPort = 4405;
12+
var address:Address = new Address();
13+
var host = new Host(udpIp);
14+
15+
address.host = host.ip;
16+
address.port = udpPort;
17+
18+
var socket = new UdpSocket();
19+
20+
try {
21+
socket.bind(host, udpPort);
22+
SlushiUtils.printMsg('Listening in [$host:$udpPort] by UDP...', INFO);
23+
24+
while (true) {
25+
var arrayData = new Array<cpp.UInt8>();
26+
var data:Bytes = Bytes.alloc(1024);
27+
var address = socket.readFrom(data, 0, 1024, address);
28+
29+
if (address != 0) {
30+
var clientIp = host;
31+
var clientPort = udpPort;
32+
33+
var receivedString = data.toString();
34+
SlushiUtils.printMsg('[$clientIp:$clientPort]: $receivedString', NONE);
35+
}
36+
}
37+
} catch (e:Dynamic) {
38+
SlushiUtils.printMsg('\nUnknown error: $e', ERROR);
39+
}
40+
41+
socket.close();
42+
SlushiUtils.printMsg('Socket closed', INFO);
43+
}
44+
}

0 commit comments

Comments
 (0)