Move to Google format
This commit is contained in:
@ -8,26 +8,21 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
inline std::string fix_path(const std::string &path)
|
||||
{
|
||||
if (path.find('\\') == path.npos)
|
||||
return path;
|
||||
inline std::string fix_path(const std::string &path) {
|
||||
if (path.find('\\') == path.npos) return path;
|
||||
std::string ret = path;
|
||||
std::replace(ret.begin(), ret.end(), '\\', '/');
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline std::string stupid_hash(const std::string &file)
|
||||
{
|
||||
inline std::string stupid_hash(const std::string &file) {
|
||||
std::ifstream iff(file);
|
||||
if (!iff.is_open())
|
||||
{
|
||||
if (!iff.is_open()) {
|
||||
return std::to_string(rand());
|
||||
}
|
||||
unsigned long long check_sum = 0x0ULL;
|
||||
char tmp;
|
||||
while (iff.get(tmp))
|
||||
{
|
||||
while (iff.get(tmp)) {
|
||||
check_sum += (unsigned long long)tmp;
|
||||
}
|
||||
iff.close();
|
||||
@ -36,20 +31,14 @@ inline std::string stupid_hash(const std::string &file)
|
||||
return ret.str();
|
||||
}
|
||||
|
||||
inline std::map<std::string, std::string>
|
||||
createHashes(const std::vector<std::string> &dirs,
|
||||
const std::string &extension)
|
||||
{
|
||||
inline std::map<std::string, std::string> createHashes(
|
||||
const std::vector<std::string> &dirs, const std::string &extension) {
|
||||
std::map<std::string, std::string> hashes;
|
||||
for (auto const &it : dirs)
|
||||
{
|
||||
for (const auto &file : std::filesystem::directory_iterator(it))
|
||||
{
|
||||
if (file.is_regular_file())
|
||||
{
|
||||
for (auto const &it : dirs) {
|
||||
for (const auto &file : std::filesystem::directory_iterator(it)) {
|
||||
if (file.is_regular_file()) {
|
||||
std::string path = fix_path(file.path().string());
|
||||
if (path.length() > extension.length() && path.ends_with(extension))
|
||||
{
|
||||
if (path.length() > extension.length() && path.ends_with(extension)) {
|
||||
hashes[path] = stupid_hash(path);
|
||||
}
|
||||
}
|
||||
@ -58,15 +47,12 @@ createHashes(const std::vector<std::string> &dirs,
|
||||
return hashes;
|
||||
}
|
||||
|
||||
inline std::vector<std::filesystem::path>
|
||||
getChangedFiles(const std::map<std::string, std::string> &oldHashes)
|
||||
{
|
||||
inline std::vector<std::filesystem::path> getChangedFiles(
|
||||
const std::map<std::string, std::string> &oldHashes) {
|
||||
std::vector<std::filesystem::path> changedFiles;
|
||||
for (const auto &file : oldHashes)
|
||||
{
|
||||
for (const auto &file : oldHashes) {
|
||||
std::string newHash = stupid_hash(file.first);
|
||||
if (newHash != file.second)
|
||||
{
|
||||
if (newHash != file.second) {
|
||||
changedFiles.push_back(std::filesystem::path(file.first));
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,6 @@ namespace helper {
|
||||
std::string GenerateUniqueId();
|
||||
void ArrayToFile(unsigned char *array_, size_t size_, std::string filename);
|
||||
void GenerateTemplateFile(std::string path, NpiProject prj);
|
||||
void CompileProject(std::string path);
|
||||
void CompileProject(std::string path, bool async = false);
|
||||
void CleanProject(std::string path);
|
||||
} // namespace helper
|
||||
} // namespace helper
|
@ -3,8 +3,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
struct NpiProject
|
||||
{
|
||||
struct NpiProject {
|
||||
std::string name;
|
||||
std::string author;
|
||||
std::string description;
|
||||
@ -17,19 +16,19 @@ struct NpiProject
|
||||
std::vector<std::string> lib_dirs;
|
||||
|
||||
std::string icon_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 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; // depends ctr_type
|
||||
std::string prod; // depends ctr_type
|
||||
std::string platform; // Platforms: 3ds, desktop
|
||||
bool ctr_type; // depends platform
|
||||
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;
|
||||
@ -43,8 +42,7 @@ struct NpiProject
|
||||
std::string asm_compiler;
|
||||
};
|
||||
|
||||
inline void Prj_InitDefault(NpiProject &project, bool cia)
|
||||
{
|
||||
inline void Prj_InitDefault(NpiProject &project, bool cia) {
|
||||
project.name = "Sample";
|
||||
project.author = "Sample";
|
||||
project.description = "Description";
|
||||
@ -99,8 +97,7 @@ inline void Prj_InitDefault(NpiProject &project, bool cia)
|
||||
project.asm_compiler = "{DEVKITPRO}/devkitARM/bin/arm-none-eabi-gcc";
|
||||
|
||||
project.icon_path = "app/icon.png";
|
||||
if (cia)
|
||||
{
|
||||
if (cia) {
|
||||
project.banner_path = "app/banner.png";
|
||||
project.banner_a_path = "app/banner_audio.wav";
|
||||
project.rsf_path = "app/build-cia.rsf";
|
||||
@ -110,8 +107,7 @@ inline void Prj_InitDefault(NpiProject &project, bool cia)
|
||||
project.dir_gfxbuild = "romfs/gfx/";
|
||||
project.dir_romfs = "romfs/";
|
||||
|
||||
if (cia)
|
||||
{
|
||||
if (cia) {
|
||||
project.unique_id = "0xff3ff";
|
||||
project.prod = "NPI7";
|
||||
}
|
||||
|
Reference in New Issue
Block a user