diff --git a/CMakeLists.txt b/CMakeLists.txt index fa37d30..0d450f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,4 +12,6 @@ source/helper.cpp source/icon.cpp source/logo_lz11.cpp source/samplefiles.cpp) -target_include_directories(npi-build PUBLIC include) \ No newline at end of file +target_include_directories(npi-build PUBLIC include) + +install(TARGETS npi-build DESTINATION bin) \ No newline at end of file diff --git a/build.sh b/build.sh deleted file mode 100644 index 8f8ca70..0000000 --- a/build.sh +++ /dev/null @@ -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/ \ No newline at end of file diff --git a/include/prj_def.hpp b/include/prj_def.hpp index f4ee4e1..9f127b3 100644 --- a/include/prj_def.hpp +++ b/include/prj_def.hpp @@ -3,7 +3,8 @@ #include #include -struct NpiProject { +struct NpiProject +{ std::string name; std::string author; std::string description; @@ -16,18 +17,19 @@ struct NpiProject { std::vector 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 arch_flags; std::vector 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; } \ No newline at end of file diff --git a/source/helper.cpp b/source/helper.cpp index af5b797..4392177 100644 --- a/source/helper.cpp +++ b/source/helper.cpp @@ -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(js, "vmajor"); auto __vminor = js_catch(js, "vminor"); auto __vbuild = js_catch(js, "vbuild"); - auto __description = js_catch(js, "description"); - auto __unique_id = js_catch(js, "unique_id"); - auto __prod = js_catch(js, "prod_code"); auto __platform = js_catch(js, "platform"); + auto __ctr_type = js_catch(js, "cia"); + auto __description = js_catch(js, "description"); + + std::pair __unique_id; + std::pair __prod; + if (__ctr_type.first) + { + __unique_id = js_catch(js, "unique_id"); + __prod = js_catch(js, "prod_code"); + } + + std::pair __banner_path; + std::pair __banner_a_path; + std::pair __rsf_path; + std::pair __logo_lz11_path; auto __icon_path = js_catch(js, "icon_path"); - auto __banner_path = js_catch(js, "banner_path"); - auto __banner_a_path = js_catch(js, "banner_a_path"); - auto __rsf_path = js_catch(js, "rsf_path"); - auto __logo_lz11_path = js_catch(js, "logo_lz11_path"); + if (__ctr_type.first) + { + __banner_path = js_catch(js, "banner_path"); + __banner_a_path = js_catch(js, "banner_a_path"); + __rsf_path = js_catch(js, "rsf_path"); + __logo_lz11_path = js_catch(js, "logo_lz11_path"); + } auto __dir_gfx = js_catch(js, "dir_gfx"); auto __dir_gfxbuild = js_catch(js, "dir_gfxbuild"); auto __dir_romfs = js_catch(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; diff --git a/source/main.cpp b/source/main.cpp index 2bb5a24..871ee4c 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -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); }