# New Features #

- Installable via cmake
- Dont run makerom and makebanner in 3dsx mode
This commit is contained in:
tobid7 2024-03-09 13:44:22 +01:00
parent c7083ac77e
commit d464128d78
5 changed files with 100 additions and 59 deletions

View File

@ -13,3 +13,5 @@ source/icon.cpp
source/logo_lz11.cpp
source/samplefiles.cpp)
target_include_directories(npi-build PUBLIC include)
install(TARGETS npi-build DESTINATION bin)

View File

@ -1,5 +0,0 @@
#Script to build
echo "Building with g++..."
g++ -g -o npi-build source/main.cpp source/samplefiles.cpp source/helper.cpp source/banner_audio.cpp source/logo_lz11.cpp source/icon.cpp source/banner.cpp -I include
echo "installing..."
sudo cp npi-build /usr/local/bin/

View File

@ -3,7 +3,8 @@
#include <string>
#include <vector>
struct NpiProject {
struct NpiProject
{
std::string name;
std::string author;
std::string description;
@ -16,18 +17,19 @@ struct NpiProject {
std::vector<std::string> lib_dirs;
std::string icon_path;
std::string banner_path;
std::string banner_a_path;
std::string rsf_path;
std::string logo_lz11_path;
std::string banner_path; // depends ctr_type
std::string banner_a_path; // depends ctr_type
std::string rsf_path; // depends ctr_type
std::string logo_lz11_path; // depends ctr_type
std::string dir_gfx;
std::string dir_gfxbuild;
std::string dir_romfs;
std::string unique_id;
std::string prod;
std::string platform; // Platforms: 3ds, desktop
std::string unique_id; // depends ctr_type
std::string prod; // depends ctr_type
std::string platform; // Platforms: 3ds, desktop
bool ctr_type; // depends platform
std::vector<std::string> arch_flags;
std::vector<std::string> c_flags;
@ -41,7 +43,8 @@ struct NpiProject {
std::string asm_compiler;
};
inline void Prj_InitDefault(NpiProject &project) {
inline void Prj_InitDefault(NpiProject &project, bool cia)
{
project.name = "Sample";
project.author = "Sample";
project.description = "Description";
@ -96,16 +99,22 @@ inline void Prj_InitDefault(NpiProject &project) {
project.asm_compiler = "{DEVKITPRO}/devkitARM/bin/arm-none-eabi-gcc";
project.icon_path = "app/icon.png";
project.banner_path = "app/banner.png";
project.banner_a_path = "app/banner_audio.wav";
project.rsf_path = "app/build-cia.rsf";
project.logo_lz11_path = "app/logo.lz11";
if (cia)
{
project.banner_path = "app/banner.png";
project.banner_a_path = "app/banner_audio.wav";
project.rsf_path = "app/build-cia.rsf";
project.logo_lz11_path = "app/logo.lz11";
}
project.dir_gfx = "gfx/";
project.dir_gfxbuild = "romfs/gfx/";
project.dir_romfs = "romfs/";
project.unique_id = "0xff3ff";
project.prod = "NPI7";
if (cia)
{
project.unique_id = "0xff3ff";
project.prod = "NPI7";
}
project.platform = "3ds";
project.ctr_type = cia;
}

View File

@ -494,12 +494,15 @@ void CompileProject(NpiProject &prj, std::string dir_)
int reqres = system(command.c_str());
if (reqres != 0)
any_errors = true;
command = "bannertool makebanner -i \"app/banner.png\" -a "
"\"app/BannerAudio.wav\" -o \"build/banner.bin\"";
std::cout << CCBLUE << "[+] Creating Banner..." << CCRESET << std::endl;
reqres = system(command.c_str());
std::cout << (reqres == 0 ? CCGREEN : CCRED)
<< (reqres == 0 ? "[+] " : "[-] ") << "Banner" << std::endl;
if (prj.ctr_type)
{
command = "bannertool makebanner -i \"app/banner.png\" -a "
"\"app/BannerAudio.wav\" -o \"build/banner.bin\"";
std::cout << CCBLUE << "[+] Creating Banner..." << CCRESET << std::endl;
reqres = system(command.c_str());
std::cout << (reqres == 0 ? CCGREEN : CCRED)
<< (reqres == 0 ? "[+] " : "[-] ") << "Banner" << std::endl;
}
command = "bannertool makesmdh -i \"app/icon.png\" -s \"" + prj.name +
"\" -l \"Description\" -p \"" + prj.author +
"\" -o \"build/icon.bin\"";
@ -516,20 +519,23 @@ void CompileProject(NpiProject &prj, std::string dir_)
std::cout << (reqres == 0 ? CCGREEN : CCRED)
<< (reqres == 0 ? "[+] " : "[-] ") << prj.name + ".3dsx "
<< std::endl;
command =
"makerom -f cia -target t -exefslogo -o " + dir_ + "/" + prj.name +
".cia -elf " + dir_ + "/" + prj.name + ".elf " + " -rsf " + dir_ + "/" +
prj.rsf_path + " -banner " + dir_ + "/build/banner.bin" + " -icon " +
dir_ + "/build/icon.bin" + " -logo " + dir_ + "/" + prj.logo_lz11_path +
" -DAPP_ROMFS=" + dir_ + "/" + prj.dir_romfs + " -major " +
std::to_string(prj.vmajor) + " -minor " + std::to_string(prj.vminor) +
" -micro " + std::to_string(prj.vbuild) +
" -DAPP_VERSION_MAJOR=" + std::to_string(prj.vmajor);
std::cout << CCBLUE << "[+] Creating Cia..." << CCRESET << std::endl;
reqres = system(command.c_str());
std::cout << (reqres == 0 ? CCGREEN : CCRED)
<< (reqres == 0 ? "[+] " : "[-] ") << prj.name + ".cia "
<< std::endl;
if (prj.ctr_type)
{
command =
"makerom -f cia -target t -exefslogo -o " + dir_ + "/" + prj.name +
".cia -elf " + dir_ + "/" + prj.name + ".elf " + " -rsf " + dir_ + "/" +
prj.rsf_path + " -banner " + dir_ + "/build/banner.bin" + " -icon " +
dir_ + "/build/icon.bin" + " -logo " + dir_ + "/" + prj.logo_lz11_path +
" -DAPP_ROMFS=" + dir_ + "/" + prj.dir_romfs + " -major " +
std::to_string(prj.vmajor) + " -minor " + std::to_string(prj.vminor) +
" -micro " + std::to_string(prj.vbuild) +
" -DAPP_VERSION_MAJOR=" + std::to_string(prj.vmajor);
std::cout << CCBLUE << "[+] Creating Cia..." << CCRESET << std::endl;
reqres = system(command.c_str());
std::cout << (reqres == 0 ? CCGREEN : CCRED)
<< (reqres == 0 ? "[+] " : "[-] ") << prj.name + ".cia "
<< std::endl;
}
}
if (any_errors)
@ -588,9 +594,16 @@ namespace helper
js["vmajor"] = prj.vmajor;
js["vminor"] = prj.vminor;
js["vbuild"] = prj.vbuild;
js["unique_id"] = prj.unique_id;
js["prod_code"] = prj.prod;
if (prj.ctr_type)
{
js["unique_id"] = prj.unique_id;
js["prod_code"] = prj.prod;
}
js["platform"] = prj.platform;
if (prj.platform == "3ds")
{
js["cia"] = prj.ctr_type;
}
nlohmann::json source_dirs;
Vec2Json(prj.source_dirs, source_dirs, prj);
@ -609,10 +622,13 @@ namespace helper
js["lib_dirs"] = lib_dirs;
js["icon_path"] = prj.icon_path;
js["banner_path"] = prj.banner_path;
js["banner_a_path"] = prj.banner_a_path;
js["rsf_path"] = prj.rsf_path;
js["logo_lz11_path"] = prj.logo_lz11_path;
if (prj.ctr_type)
{
js["banner_path"] = prj.banner_path;
js["banner_a_path"] = prj.banner_a_path;
js["rsf_path"] = prj.rsf_path;
js["logo_lz11_path"] = prj.logo_lz11_path;
}
js["dir_gfx"] = prj.dir_gfx;
js["dir_gfxbuild"] = prj.dir_gfxbuild;
@ -678,16 +694,31 @@ namespace helper
auto __vmajor = js_catch<int>(js, "vmajor");
auto __vminor = js_catch<int>(js, "vminor");
auto __vbuild = js_catch<int>(js, "vbuild");
auto __description = js_catch<std::string>(js, "description");
auto __unique_id = js_catch<std::string>(js, "unique_id");
auto __prod = js_catch<std::string>(js, "prod_code");
auto __platform = js_catch<std::string>(js, "platform");
auto __ctr_type = js_catch<bool>(js, "cia");
auto __description = js_catch<std::string>(js, "description");
std::pair<std::string, bool> __unique_id;
std::pair<std::string, bool> __prod;
if (__ctr_type.first)
{
__unique_id = js_catch<std::string>(js, "unique_id");
__prod = js_catch<std::string>(js, "prod_code");
}
std::pair<std::string, bool> __banner_path;
std::pair<std::string, bool> __banner_a_path;
std::pair<std::string, bool> __rsf_path;
std::pair<std::string, bool> __logo_lz11_path;
auto __icon_path = js_catch<std::string>(js, "icon_path");
auto __banner_path = js_catch<std::string>(js, "banner_path");
auto __banner_a_path = js_catch<std::string>(js, "banner_a_path");
auto __rsf_path = js_catch<std::string>(js, "rsf_path");
auto __logo_lz11_path = js_catch<std::string>(js, "logo_lz11_path");
if (__ctr_type.first)
{
__banner_path = js_catch<std::string>(js, "banner_path");
__banner_a_path = js_catch<std::string>(js, "banner_a_path");
__rsf_path = js_catch<std::string>(js, "rsf_path");
__logo_lz11_path = js_catch<std::string>(js, "logo_lz11_path");
}
auto __dir_gfx = js_catch<std::string>(js, "dir_gfx");
auto __dir_gfxbuild = js_catch<std::string>(js, "dir_gfxbuild");
auto __dir_romfs = js_catch<std::string>(js, "dir_romfs");
@ -706,6 +737,7 @@ namespace helper
prj.unique_id = __unique_id.first;
prj.prod = __prod.first;
prj.platform = __platform.first;
prj.ctr_type = __ctr_type.first;
prj.icon_path = __icon_path.first;
prj.banner_path = __banner_path.first;

View File

@ -188,7 +188,7 @@ void ProcessArgs(int argc, char *argv[])
}
// Generate Default build.json
NpiProject npr;
Prj_InitDefault(npr);
Prj_InitDefault(npr, (type_ == 1));
helper::GenerateTemplateFile(dst_dir + "/build.json", npr);
}
else if (std::string(argv[1]) == "generate-assist")
@ -276,10 +276,13 @@ void ProcessArgs(int argc, char *argv[])
}
// Create build.json
NpiProject npr;
Prj_InitDefault(npr);
Prj_InitDefault(npr, (type_ == 1));
npr.name = prj_name;
npr.prod = prodcode;
npr.unique_id = unique_id;
if (npr.ctr_type)
{
npr.prod = prodcode;
npr.unique_id = unique_id;
}
helper::GenerateTemplateFile(dst_dir + "/build.json", npr);
}