Skip to content

Commit 36d56c3

Browse files
committed
FINALLY! VERSION 3.0.0!!
1 parent 97f509f commit 36d56c3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+3026
-1902
lines changed

.github/workflows/linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
with:
1515
haxe-version: 4.3.5
1616

17-
- name: Install Haxe libraries
17+
- name: Installing/Updating hxcpp
1818
run: |
1919
haxelib --always install hxcpp
2020

.github/workflows/macos.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name: MacOS Build
22
on:
33
push:
4-
54
jobs:
65
build:
76
runs-on: macos-latest
@@ -14,7 +13,7 @@ jobs:
1413
with:
1514
haxe-version: 4.3.5
1615

17-
- name: Install Haxe libraries
16+
- name: Installing/Updating hxcpp
1817
run: |
1918
haxelib --always install hxcpp
2019

.github/workflows/windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
uses: krdlab/setup-haxe@master
1515
with:
1616
haxe-version: 4.3.5
17-
- name: Installing/Updating libraries
17+
- name: Installing/Updating hxcpp
1818
run: |
1919
haxelib --always install hxcpp
2020
shell: cmd

README.md

Lines changed: 30 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1,158 +1,60 @@
11
<h1 align="center">HaxeNXCompiler</h1>
2-
<h2 align="center">A tool for creating homebrew for the Nintendo Switch using Haxe</h2>
2+
<h2 align="center">A tool for creating homebrew for the Nintendo Switch using Haxe!</h2>
33

4-
![mainImage](https://github.com/Slushi-Github/HaxeNXCompiler/blob/main/docs/readme/MainImage.png)
4+
![mainImage](docs/readme/MainImage.png)
55

6-
Using this utility (Inspired by [HxCompileU](https://github.com/Slushi-Github/hxCompileU)) you can compile code from Haxe to the Nintendo Switch using [DevKitPro](https://devkitpro.org) and [custom hxcpp fork](https://github.com/Slushi-Github/hxcpp-nx), for creating homebrew for the Nintendo Switch using Haxe.
6+
---------
77

8-
This is inspired by an attempt by the [RetroNX Team](https://github.com/retronx-team) to use Haxe on the Nintendo Switch. I used part of the [original project](https://github.com/retronx-team/switch-haxe) for this, so credit goes to them for achieving this in the first place!
8+
A tool designed so that, together with a [custom hxcpp fork](https://github.com/Slushi-Github/hxcpp-nx) and the DevKita64 tools, you can compile a [Haxe](https://haxe.org) program for the Nintendo Switch and even for other platforms!
99

10-
**This project is being tested with Haxe 4.3.6 and a Nintendo Switch V2 with firmware 20.4.0 and Atmosphère 1.9.5.**
10+
This is inspired by an attempt by the [RetroNX Team](https://github.com/retronx-team) to use Haxe on the Nintendo Switch. I used part of the [original project](https://github.com/retronx-team/switch-haxe) for this so credit goes to them for achieving this in the first place!
1111

12-
Officially there are supported libraries to be used in conjunction with HaxeNXCompiler:
12+
**This project is being tested with Haxe 4.3.6 and a Nintendo Switch V2 with firmware 20.4.0 and Atmosphère 1.9.4.**
1313

14-
- [hx_libnx](https://github.com/Slushi-Github/hx_libnx): Haxe/hxcpp @:native bindings for libnx, the Nintendo Switch's homebrew library.
14+
---------
1515

16-
-----
16+
**Officially** there are supported libraries to be used in conjunction with HaxeNXCompiler:
1717

18-
## Current problems:
18+
- [hx_libnx](https://github.com/Slushi-Github/hx_libnx): Haxe/hxcpp ``@:native`` bindings for libnx, the Nintendo Switch's homebrew library.
1919

20-
- Apparently there is no full support for `sys.net.Socket`.
21-
- Critical issue related to hxcpp and its garbage collector when the program ends, causing Atmosphère to crash sometimes.
20+
- SDL2 (And SDL2_Image, SDL2_Mixer): Haxe/hxcpp ``@:native`` bindings for SDL 2.28 libraries (PRIVATE LIBRARY).
2221

23-
-----
22+
- OpenGL 4.3 ES: Haxe/hxcpp ``@:native`` bindings for the OpenGL 4.3 ES, a 3D graphics library (PRIVATE LIBRARY).
2423

25-
## How?
24+
- libVorbis: Haxe/hxcpp ``@:native`` bindings for libvorbis, a decoder for the OGG Vorbis audio format (PRIVATE LIBRARY).
2625

27-
Well... Unlike the Wii U, where using hxcpp causes many problems, and to achieve that I had to use [Reflaxe/C++ (Amazing library!)](https://github.com/SomeRanDev/reflaxe.CPP) to be able to use Haxe on that console. With the Nintendo Switch, hxcpp compiles perfectly!
26+
- OpenAL Soft: Haxe/hxcpp ``@:native`` bindings for OpenAL Soft, a 3D audio library (PRIVATE LIBRARY AND NOT FINISHED).
2827

29-
I knew even before I had a Wii U that the [RetroNX Team](https://github.com/retronx-team) had attempted to [use Haxe on the Nintendo Switch](https://github.com/retronx-team/switch-haxe), but that project is now more than five years old and I don't know if it still works. This program rescues what they did and does so using something more recent with respect to Haxe and hxcpp, and it uses inspiration from [HxCompileU](https://github.com/Slushi-Github/hxCompileU) to be able to easily compile Haxe code for the Nintendo Switch, in this case without the limitations that [HxCompileU](https://github.com/Slushi-Github/hxCompileU) may have because it uses [Reflaxe/C++ (And I'm not saying it's a bad library!)](https://github.com/SomeRanDev/reflaxe.CPP).
28+
- FontStash: Haxe/hxcpp ``@:native`` bindings for FontStash, a font rendering library compatible with OpenGL and OpenGL ES (PRIVATE LIBRARY AND NOT FINISHED).
3029

31-
This does not work the same as [HxCompileU](https://github.com/Slushi-Github/hxCompileU). Haxe and hxcpp handle all possible compilation, and then only the link and creation of the program made for use on the Nintendo Switch are done.
30+
The term *"**officially**"* does not mean that only these libraries will work with this tool; they are simply the libraries that I have created specifically for this project and for the Nintendo Switch. However, you can try any libraries you want that are in [Haxelib](https://lib.haxe.org)! (with certain limitations; remember that this is a separate target from the normal ones and is experimental; libraries that depend on C++ libraries will generally not work without changes. And no, don't try to use HaxeFlixel on this target... for now?).
3231

33-
This program what it does, is that by means of some data stored in a JSON file (``haxeNXConfig.json``), it generates a MakeFile and a [HXML](https://haxe.org/manual/compiler-usage-hxml.html) file with those data of the JSON, of normal first it will try to execute the [HXML](https://haxe.org/manual/compiler-usage-hxml.html) with Haxe, [hxcpp](https://github.com/Slushi-Github/hxcpp-nx) is in charge of compiling the C++ code, if the compilation with Haxe is successful, it executes the MakeFile with Make and starts the link of that C++ code to the Nintendo Switch, if this is also successful, that's it, you have your homebrew for the Nintendo Switch made with Haxe!
32+
## How is this possible?
3433

35-
## Why?
34+
Well, let's start at the beginning.
3635

37-
Well, I've been having fun using the Nintendo Wii U with Haxe through my [HxCompileU](https://github.com/Slushi-Github/hxCompileU) project, and I was able to get a Nintendo Switch. I already knew that Haxe could work there without as many problems as on the Wii U, and it's even officially supported, but obviously under the terms of the Nintendo Developer Portal. This project aims to do the same thing without being part of that Nintendo program and to do everything through the homebrew that exists for the Nintendo Switch.
36+
Haxe on Nintendo Switch can be used officially through the Nintendo Developer program, giving access to modified versions of certain Haxe libraries, but as far as I know, these are old libraries alongside an old version of Haxe and an old version of hxcpp.
3837

39-
-----
38+
When I started wanting a Wii U, I found out about a very old case of bringing Haxe, or rather [OpenFL](https://www.openfl.org), to consoles, called ["OpenFL for Home Game Consoles."](https://www.fortressofdoors.com/openfl-for-home-game-consoles). Among the “targets” was the Wii U. I don't know what came of that, but I don't think it was anything important or interesting. I currently understand that the only console where Haxe is supported is the Nintendo Switch.
4039

41-
# Usage
40+
To which I had found a project that modified hxcpp to make it functional with the Nintendo Switch, but it was a very basic attempt at just a "hello world.", that project was [switch-haxe](https://github.com/retronx-team/switch-haxe).
4241

43-
The basic usage of HaxeNXCompiler is as follows:
42+
Although with the Wii U I had to choose to use [Reflaxe/C++](https://github.com/SomeRanDev/reflaxe.CPP) to use Haxe there, which resulted in [HxCompileU](https://github.com/Slushi-Github/hxCompileU), when I got a Nintendo Switch, I already knew that I could use Haxe with hxcpp on this console. And that's what this project is about:
4443

45-
You need:
46-
- [DevKitPro](https://devkitpro.org/wiki/Getting_Started)
44+
Providing the ability to use Haxe on a Nintendo Switch freely and with what the homebrew of this console allows!
4745

48-
- ``libnx`` (Install the ``libnx`` library from DevKitPro repository)
46+
## What does this tool do?
4947

50-
- [Haxe](https://haxe.org/)
48+
This tool helps you compile a Haxe project more easily and obtain executable files for a Nintendo Switch.
5149

52-
- [hxcpp (fork)](https://github.com/Slushi-Github/hxcpp-nx)
50+
An XML project file is used, based on the XML file of Haxe projects made with [Lime](https://lime.openfl.org)/[OpenFL](https://www.openfl.org).
5351

54-
- [hx_libnx](https://github.com/Slushi-Github/hx_libnx)
52+
Want to start a new project? Then go to the guide on [how to get started](docs/guides/GetStarted.md).
5553

56-
First, you need compilate this project, or you can use the precompiled version that is in the [releases](https://github.com/Slushi-Github/HaxeNXCompiler/releases), or you can download it from the [GitHub Actions](https://github.com/Slushi-Github/HaxeNXCompiler/actions). I recommend using the [GitHub Actions](https://github.com/Slushi-Github/HaxeNXCompiler/actions) option.
54+
Want create a library for this tool? Then go to the guide on [how to create a library](docs/guides/LibrariesGuide.md).
5755

58-
```bash
59-
# Just clone the repository
60-
git clone https://github.com/Slushi-Github/HaxeNXCompiler.git
61-
62-
# Install hxcpp
63-
haxelib git hxcpp https://github.com/Slushi-Github/hxcpp-nx.git
64-
65-
# Install hx_libnx
66-
haxelib git hx_libnx https://github.com/Slushi-Github/hx_libnx.git
67-
68-
# Compile the project
69-
cd HaxeNXCompiler
70-
haxe build.hxml
71-
```
72-
73-
After that, you will get your executable ``HaxeNXCompiler`` in the "export" folder, for the moment, copy it to the root of the project folder you need it.
74-
75-
-----
76-
77-
## How to use
78-
79-
#### First, initialize your project, that is, create the configuration JSON file that HaxeNXCompiler will use, you can create it using this command:
80-
``{haxeNXCompilerProgram} --prepare`` or ``{haxeNXCompilerProgram} --p``
81-
82-
- Or you can import an existing JSON file from a Haxe library with the following command:
83-
``{haxeNXCompilerProgram} --import HAXE_LIB`` or ``{haxeNXCompilerProgram} --i HAXE_LIB``
84-
85-
-----
86-
87-
#### Once you have configured your JSON file to what your project needs, you can use the following command to compile it:
88-
``{haxeNXCompilerProgram} --compile`` or ``{haxeNXCompilerProgram} --c``
89-
90-
- If you want enable the Haxe debug mode, you can use the following command:
91-
92-
``{haxeNXCompilerProgram} --compile --debug``
93-
94-
-----
95-
96-
#### You can also use the following command search a line of code in the ``.elf`` file from a line address of some log using devkitA64's ``aarch64-none-elf-addr2line`` program:
97-
98-
``{haxeNXCompilerProgram} --searchProblem [lineAddress]`` or ``{haxeNXCompilerProgram} --sp [lineAddress]``
99-
100-
-----
101-
102-
#### You can also use the following command send the ``.nro`` file to the Nintendo Switch using DevKitPro's ``nxlink`` program:
103-
104-
``{haxeNXCompilerProgram} --send`` or ``{haxeNXCompilerProgram} --s``
105-
106-
- If you want start a server, you can use the following command:
107-
108-
``{haxeNXCompilerProgram} --send --server`` or ``{haxeNXCompilerProgram} --s --s``
109-
110-
-----
111-
112-
#### You can get errors from a log file using the following command:
113-
114-
``{haxeNXCompilerProgram} --crashAnalyzer`` or ``{haxeNXCompilerProgram} --ca``
115-
116-
**THIS IS TOO EXPERIMENTAL!**
117-
118-
-----
119-
120-
and that's it! if your compilation was successful on both Haxe and Nintendo Switch side, your ``.nro``, ``.ncap`` and ``.elf`` files will be in ``yourOutputFolder/switchFiles``.
121-
122-
123-
## libraries JSON file
124-
125-
When you create a library that will be compatible with HaxeNXCompiler and you need it to import important things such as more Haxe libraries, or libraries and parameters for the MakeFile, add a file called ``HxNX_Meta.json`` to your library, which should have the following structure:
126-
127-
(This is just an example; comments do not work in JSON (at least not in ``haxe.Json``))
128-
129-
```json
130-
{
131-
"libVersion": "0.0.0", // Library version
132-
"haxeLibs": [], // more Haxe libraries
133-
"switchLibs": [], // C/C++ Libraries for the Nintendo Switch (from DevKitPro)
134-
"mainDefines": [], // Defines for Haxe and C/C++
135-
"hxDefines": [], // Haxe defines
136-
"cDefines": [], // C defines
137-
"cppDefines": [] // C++ defines
138-
}
139-
```
140-
141-
If HaxeNXCompiler cannot find a library with that file, it will import it only for Haxe.
142-
143-
## About aseets
144-
145-
### About RomFS
146-
147-
The ``romfs`` folder is a folder that contains files that will be added to the ``.nro`` file.
148-
149-
To use this, create a folder in the main folder directory (Who is ``yourOutputFolder``), or a library compatible with HaxeNXCompiler, called "assets" Inside that folder, there should be another folder called "ROMFS" From there, you can copy everything you want, and a folder named "romfs" into a other folder called "SWITCH_ASSETS" will be copied to ``yourOutputFolder``. The MakeFile will then copy those files to the ``.nro`` file, which can be accessed by searching the path "romfs:/" (you must first mount that path with [hx_libnx](https://github.com/Slushi-Github/hx_libnx)!).
150-
151-
### About the metadata for the ``.nro`` file
152-
153-
Inside the JSON file ``haxeNXConfig.json`` you will find the parameters ``appTitle``, ``appVersion``, and ``appAuthor``. You can fill in these fields with whatever information you want to be displayed in the Homebrew menu.
154-
155-
In addition, if there is a file named "icon.jpg" or one named "YOUR_PROJECT_NAME.jpg" in your project's assets folder or in a folder, they will be copied to the "SWITCH_ASSETS" folder so that the ``.nro`` file can use them. If that ".jpg" file is not found in any library or in the main project, HaxeNXCompiler will automatically provide one in the "SWITCH_ASSETS" folder.
56+
Want to use assets with this tool? Then go to the guide on [how to use assets](docs/guides/AssetsGuide.md).
15657

15758
## License
158-
This project is released under the [MIT license](https://github.com/Slushi-Github/HaxeNXCompiler/blob/main/LICENSE.md).
59+
60+
This project is released under the [MIT License](LICENSE.md).

assets/CommandsInfo

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Usage: HaxeNXCompiler [command] [options]
2+
3+
Commands:
4+
--prepare, -p
5+
Creates the necessary project XML file template.
6+
7+
--import, -i [haxe_library_name]
8+
Imports a project XML file template from a haxe library.
9+
10+
--compile, -c
11+
Compiles the project from Haxe/C++ to Nintendo Switch.
12+
Add "--debug" to the command to enable Haxe debug mode.
13+
Add "--clean" to the command to clean the project before compiling.
14+
Add "--send" to the command to send the .nro file to the Nintendo Switch after compilation only if compilation is successful (this starts a nxlink server directly on the port \033[3m28771\033[0m), alternative to set the "sendaftercompile" parameter to true in the project XML file.
15+
16+
--searchProblem, -sp [LineAddress]
17+
Search for a line of code in the [.elf] file from a line address of some log using devkitA64's aarch64-none-elf-addr2line program.
18+
19+
--send, -s
20+
Sends the .nro file to the Nintendo Switch using DevKitPro's nxlink program.
21+
Add "--server" or "-s" to the command to start the nxlink server (on the port \033[3m28771\033[0m), you should define "ENABLE_NXLINK" as C define (with cflag in the project XML file for example).
22+
23+
--crashAnalyzer, -ca
24+
Analyzes the crash log from a .nro file (VERY EXPERIMENTAL).
25+
26+
--version, -v
27+
Shows the version of the compiler.
28+
29+
--help, -h
30+
Shows this message.

assets/HaxeHXML

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# File generated by HaxeNXCompiler v[PROGRAM_VERSION]
2+
# Main parameters ##########
3+
-cp [HAXE_SOURCE_PATH]
4+
-main [HAXE_MAIN_CLASS_NAME]
5+
-D message.reporting=[HAXE_REPORTING_STYLE]
6+
# Default and required libraries #########
7+
-lib hxcpp
8+
-lib hx_libnx
9+
# HXCPP parameters #########
10+
-cpp [CPP_OUTPUT_PATH]
11+
-D HAXE_OUTPUT_PART=HAXE_NX_PROGRAM
12+
-D nx
13+
-D HX_NX
14+
-D static_link
15+
# Default defines ##########
16+
-D HAXENXCOMPILER_VERSION="[PROGRAM_VERSION]"
17+
-D HAXENXCOMPILER_XML_SWITCH_PROJECTNAME="[SWITCH_PROJECT_NAME]"
18+
############################
19+
# Haxe libraries ###########
20+
[HAXE_LIBS]
21+
# Haxe defines #############
22+
[HAXE_DEFINES]
23+
# Haxe flags ###############
24+
[HAXE_FLAGS]
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# File generated by HaxeNXCompiler v[PROGRAM_VERSION]
2+
# MakefileNRO version: 2.5.0
3+
14
#---------------------------------------------------------------------------------
25
.SUFFIXES:
36
#---------------------------------------------------------------------------------
@@ -37,14 +40,14 @@ include $(DEVKITPRO)/libnx/switch_rules
3740
# of a homebrew executable (.nro). This is intended to be used for sysmodules.
3841
# NACP building is skipped as well.
3942
#---------------------------------------------------------------------------------
40-
TARGET := [PROJECT_NAME]
43+
TARGET := [SWITCH_PROJECT_NAME]
4144
BUILD := build
4245
SOURCES := [CPP_WRAPPER_DIR]
4346
DATA := data
4447
INCLUDES := [SOURCE_DIR]/include
4548
[ROMFS_ARG]
4649

47-
APP_TITLE := [APP_NAME]
50+
APP_TITLE := [APP_TITLE]
4851
APP_AUTHOR := [APP_AUTHOR]
4952
APP_VERSION := [APP_VERSION]
5053

@@ -74,7 +77,6 @@ LIBS := [LIBS] -lnx
7477
#---------------------------------------------------------------------------------
7578
LIBDIRS := $(PORTLIBS) $(LIBNX)
7679

77-
7880
#---------------------------------------------------------------------------------
7981
# no real need to edit anything past this point unless you need to add additional
8082
# rules for different file extensions
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// File generated by HaxeNXCompiler v[PROGRAM_VERSION]
2-
// WrapperCPP version: 1.2.0
2+
// WrapperCPP version: 1.2.1
33

44
#include <switch.h>
55

@@ -48,7 +48,7 @@ int main(int argc, char **argv)
4848
consoleUpdate(NULL);
4949

5050
std::string hxnxcDefinedVersion = HAXENXCOMPILER_VERSION;
51-
std::string hxnxcDefinedProjectName = HAXENXCOMPILER_JSON_SWITCH_PROJECTNAME;
51+
std::string hxnxcDefinedProjectName = HAXENXCOMPILER_SWITCH_PROJECTNAME;
5252

5353
printf("HaxeNXCompiler v%s -- Project: %s\nHAXE HXCPP CRITICAL ERROR!\n\nError: %s\n\n================\nPress + to return to hbmenu\n",
5454
hxnxcDefinedVersion.c_str(),
@@ -69,9 +69,8 @@ int main(int argc, char **argv)
6969
return -1;
7070
}
7171

72-
7372
printf("HaxeNXCompiler v%s -- Project: %s\nProgram Finished!\n\n",
7473
HAXENXCOMPILER_VERSION,
75-
HAXENXCOMPILER_JSON_SWITCH_PROJECTNAME);
74+
HAXENXCOMPILER_SWITCH_PROJECTNAME);
7675
return 0;
7776
}

0 commit comments

Comments
 (0)