Commit All Changes and Start cleanup

This commit is contained in:
tobid7 2024-03-09 12:46:20 +01:00
parent 9d6f367c8d
commit 1e3674ecfa
6 changed files with 113 additions and 37 deletions

15
.vscode/c_cpp_properties.json vendored Normal file
View File

@ -0,0 +1,15 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"cStandard": "c17",
"cppStandard": "c++20",
"intelliSenseMode": "linux-clang-x64"
}
],
"version": 4
}

7
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,7 @@
{
"files.associations": {
"utility": "cpp",
"ostream": "cpp",
"xstring": "cpp"
}
}

View File

@ -4,4 +4,6 @@ extern const char *default_title;
extern const char *default_code;
extern const char *default_unique_id;
extern const char *default_romfs_path;
extern const char *sample_header;
extern const char *sample_code;
extern const char *ciaRSF;

View File

@ -33,24 +33,13 @@ void updateProgressBar(float progress)
<< CCRESET;
}
std::string catch_str(nlohmann::json js, std::string at)
template <typename T>
std::pair<T, bool> js_catch(const nlohmann::json &js, const std::string &at)
{
bool exists = true;
if (!js.contains(at) || js[at].is_null())
{
throw std::invalid_argument("required_key is null or missing: " + at);
}
return js[at].get<std::string>();
}
int catch_int(nlohmann::json js, std::string at)
{
if (!js.contains(at) || js[at].is_null())
{
throw std::invalid_argument("required_key is null or missing: " + at);
}
return js[at].get<int>();
exists = false;
return std::make_pair(js[at].get<T>(), exists);
}
std::vector<std::filesystem::path>
@ -684,24 +673,48 @@ namespace helper
<< CCRESET;
NpiProject prj;
prj.name = catch_str(js, "project_name");
prj.author = catch_str(js, "author");
prj.vmajor = catch_int(js, "vmajor");
prj.vminor = catch_int(js, "vminor");
prj.vbuild = catch_int(js, "vbuild");
prj.description = catch_str(js, "description");
prj.unique_id = catch_str(js, "unique_id");
prj.prod = catch_str(js, "prod_code");
prj.platform = catch_str(js, "platform");
auto __name = js_catch<std::string>(js, "project_name");
auto __author = js_catch<std::string>(js, "author");
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");
prj.icon_path = catch_str(js, "icon_path");
prj.banner_path = catch_str(js, "banner_path");
prj.banner_a_path = catch_str(js, "banner_a_path");
prj.rsf_path = catch_str(js, "rsf_path");
prj.logo_lz11_path = catch_str(js, "logo_lz11_path");
prj.dir_gfx = catch_str(js, "dir_gfx");
prj.dir_gfxbuild = catch_str(js, "dir_gfxbuild");
prj.dir_romfs = catch_str(js, "dir_romfs");
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");
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");
auto __cxx_compiler = js_catch<std::string>(js, "cxx_compiler");
auto __c_compiler = js_catch<std::string>(js, "c_compiler");
auto __asm_compiler = js_catch<std::string>(js, "asm_compiler");
auto __linker = js_catch<std::string>(js, "linker");
prj.name = __name.first;
prj.author = __author.first;
prj.vmajor = __vmajor.first;
prj.vminor = __vminor.first;
prj.vbuild = __vbuild.first;
prj.description = __description.first;
prj.unique_id = __unique_id.first;
prj.prod = __prod.first;
prj.platform = __platform.first;
prj.icon_path = __icon_path.first;
prj.banner_path = __banner_path.first;
prj.banner_a_path = __banner_a_path.first;
prj.rsf_path = __rsf_path.first;
prj.logo_lz11_path = __logo_lz11_path.first;
prj.dir_gfx = __dir_gfx.first;
prj.dir_gfxbuild = __dir_gfxbuild.first;
prj.dir_romfs = __dir_romfs.first;
Js2Vec(prj.arch_flags, js["arch_flags"]);
Js2Vec(prj.linker_flags, js["linker_flags"]);
@ -712,10 +725,10 @@ namespace helper
Js2Vec(prj.include_dirs, js["include_dirs"]);
Js2Vec(prj.lib_dirs, js["lib_dirs"]);
Js2Vec(prj.libraries, js["libraries"]);
prj.cxx_compiler = catch_str(js, "cxx_compiler");
prj.c_compiler = catch_str(js, "c_compiler");
prj.asm_compiler = catch_str(js, "asm_compiler");
prj.linker = catch_str(js, "linker");
prj.cxx_compiler = __cxx_compiler.first;
prj.c_compiler = __c_compiler.first;
prj.asm_compiler = __asm_compiler.first;
prj.linker = __linker.first;
NpiProject _2build = prj;
ProcessPrj2Cmp(&_2build, prj);
CompileProject(_2build, path);

View File

@ -102,6 +102,8 @@ void ProcessArgs(int argc, char *argv[]) {
std::filesystem::path(dst_dir + "/app"));
std::filesystem::create_directories(
std::filesystem::path(dst_dir + "/gfx"));
std::filesystem::create_directories(dst_dir + "/source");
std::filesystem::create_directories(dst_dir + "/include");
std::ofstream gfx_keep(dst_dir + "/gfx/.gitkeep");
gfx_keep.close();
std::filesystem::create_directories(
@ -117,6 +119,12 @@ void ProcessArgs(int argc, char *argv[]) {
test << ret;
test.close();
delete[] ret;
std::ofstream sample_source(dst_dir + "/source/main.cpp");
sample_source << sample_code;
sample_source.close();
std::ofstream sample_hdr(dst_dir + "/include/common.hpp");
sample_hdr << sample_header;
sample_hdr.close();
helper::ArrayToFile(banner_audio, banner_audio_size,
dst_dir + "/app/banner_audio.wav");
helper::ArrayToFile(logo_lz11, logo_lz11_size,
@ -182,6 +190,8 @@ void ProcessArgs(int argc, char *argv[]) {
std::filesystem::path(dst_dir + "/app"));
std::filesystem::create_directories(
std::filesystem::path(dst_dir + "/gfx"));
std::filesystem::create_directories(dst_dir + "/source");
std::filesystem::create_directories(dst_dir + "/include");
std::ofstream gfx_keep(dst_dir + "/gfx/.gitkeep");
gfx_keep.close();
std::filesystem::create_directories(
@ -197,6 +207,12 @@ void ProcessArgs(int argc, char *argv[]) {
test << ret;
test.close();
delete[] ret;
std::ofstream sample_source(dst_dir + "/source/main.cpp");
sample_source << sample_code;
sample_source.close();
std::ofstream sample_hdr(dst_dir + "/include/common.hpp");
sample_hdr << sample_header;
sample_hdr.close();
helper::ArrayToFile(banner_audio, banner_audio_size,
dst_dir + "/app/banner_audio.wav");
helper::ArrayToFile(logo_lz11, logo_lz11_size,
@ -224,6 +240,9 @@ void ProcessArgs(int argc, char *argv[]) {
}
int main(int argc, char *argv[]) {
//Lapi::Init();
//Lapi::Exit();
//return 0;
// std::cout << std::filesystem::current_path() << std::endl;
ProcessArgs(argc, argv);

View File

@ -4,6 +4,26 @@ const char *default_title = "Sample";
const char *default_code = "NPI7";
const char *default_unique_id = "0xff3ff";
const char *default_romfs_path = "romfs";
const char *sample_header =
"// Sample Header File\n"
"#pragma once\n"
"#include <3ds.h>\n"
"#include <stdio.h>";
const char *sample_code =
"// Sample Source Code for Hello World\n\n"
"#include <common.hpp>\n\n"
"int main() {\n"
" gfxInitDefault();\n"
" consoleInit(GFX_TOP, NULL);\n"
" printf(\"Hello World!\\n\");\n"
" printf(\"Press START to exit!\\n\")"
" while(aptMainLoop()) {\n"
" hidScanInput();\n"
" if(hidKeysDown() & KEY_START) break;\n"
" gfxSwapBuffers();\n"
" }\n"
" gfxExit();\n"
"}";
const char *ciaRSF =
"#This File is generated by npi-build!\n"
"#Every Changes made will get overwritten\n"