mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-06 03:18:14 +00:00
UPDATED: Implementing file rename requirements
Moved files update from collection to separate function
This commit is contained in:
407
examples/rexm.c
407
examples/rexm.c
@@ -86,6 +86,14 @@ typedef enum {
|
|||||||
|
|
||||||
static const char *exCategories[MAX_EXAMPLE_CATEGORIES] = { "core", "shapes", "textures", "text", "models", "shaders", "audio", "others" };
|
static const char *exCategories[MAX_EXAMPLE_CATEGORIES] = { "core", "shapes", "textures", "text", "models", "shaders", "audio", "others" };
|
||||||
|
|
||||||
|
// Paths required for examples management
|
||||||
|
// TODO: Avoid hardcoding path values...
|
||||||
|
static const char *exBasePath = "C:/GitHub/raylib/examples";
|
||||||
|
static const char *exWebPath = "C:/GitHub/raylib.com/examples";
|
||||||
|
static const char *exTemplateFilePath = "C:/GitHub/raylib/examples/examples_template.c";
|
||||||
|
static const char *exTemplateScreenshot = "C:/GitHub/raylib/examples/examples_template.png";
|
||||||
|
static const char *exCollectionListPath = "C:/GitHub/raylib/examples/examples_list.txt";
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Module specific functions declaration
|
// Module specific functions declaration
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
@@ -94,6 +102,10 @@ static int FileCopy(const char *srcPath, const char *dstPath);
|
|||||||
static int FileRename(const char *fileName, const char *fileRename);
|
static int FileRename(const char *fileName, const char *fileRename);
|
||||||
static int FileRemove(const char *fileName);
|
static int FileRemove(const char *fileName);
|
||||||
|
|
||||||
|
// Update required files from examples collection
|
||||||
|
// UPDATES: Makefile, Makefile.Web, README.md, examples.js
|
||||||
|
static int UpdateRequiredFiles(void);
|
||||||
|
|
||||||
// Load examples collection information
|
// Load examples collection information
|
||||||
// NOTE 1: Load by category: "ALL", "core", "shapes", "textures", "text", "models", "shaders", others"
|
// NOTE 1: Load by category: "ALL", "core", "shapes", "textures", "text", "models", "shaders", others"
|
||||||
// NOTE 2: Sort examples list on request flag
|
// NOTE 2: Sort examples list on request flag
|
||||||
@@ -118,18 +130,11 @@ static void SortExampleByName(rlExampleInfo *items, int count);
|
|||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// Paths required for examples management
|
|
||||||
// TODO: Avoid hardcoding path values...
|
|
||||||
char *exBasePath = "C:/GitHub/raylib/examples";
|
|
||||||
char *exWebPath = "C:/GitHub/raylib.com/examples";
|
|
||||||
char *exTemplateFilePath = "C:/GitHub/raylib/examples/examples_template.c";
|
|
||||||
char *exTemplateScreenshot = "C:/GitHub/raylib/examples/examples_template.png";
|
|
||||||
char *exCollectionListPath = "C:/GitHub/raylib/examples/examples_list.txt";
|
|
||||||
|
|
||||||
char inFileName[1024] = { 0 }; // Example input filename (to be added)
|
char inFileName[1024] = { 0 }; // Example input filename (to be added)
|
||||||
|
|
||||||
char exName[64] = { 0 }; // Example name, without extension: core_basic_window
|
char exName[64] = { 0 }; // Example name, without extension: core_basic_window
|
||||||
char exCategory[32] = { 0 }; // Example category: core
|
char exCategory[32] = { 0 }; // Example category: core
|
||||||
|
char exRecategory[32] = { 0 }; // Example re-name category: shapes
|
||||||
char exRename[64] = { 0 }; // Example re-name, without extension
|
char exRename[64] = { 0 }; // Example re-name, without extension
|
||||||
|
|
||||||
int opCode = OP_NONE; // Operation code: 0-None(Help), 1-Create, 2-Add, 3-Rename, 4-Remove
|
int opCode = OP_NONE; // Operation code: 0-None(Help), 1-Create, 2-Add, 3-Rename, 4-Remove
|
||||||
@@ -227,16 +232,7 @@ int main(int argc, char *argv[])
|
|||||||
strcpy(exName, argv[2]); // Register example name
|
strcpy(exName, argv[2]); // Register example name
|
||||||
strncpy(exCategory, exName, TextFindIndex(exName, "_"));
|
strncpy(exCategory, exName, TextFindIndex(exName, "_"));
|
||||||
strcpy(exRename, argv[3]);
|
strcpy(exRename, argv[3]);
|
||||||
char exReCategory[32] = { 0 };
|
strncpy(exRecategory, exRename, TextFindIndex(exRename, "_"));
|
||||||
strncpy(exReCategory, exRename, TextFindIndex(exRename, "_"));
|
|
||||||
|
|
||||||
if (strcmp(exCategory, exReCategory) != 0)
|
|
||||||
{
|
|
||||||
// TODO: Consider rename with change of category
|
|
||||||
// Remove previous one from collection
|
|
||||||
// Add new one (copy) to collection
|
|
||||||
}
|
|
||||||
|
|
||||||
opCode = OP_RENAME;
|
opCode = OP_RENAME;
|
||||||
}
|
}
|
||||||
else LOG("WARNING: RENAME: Example not available in the collection\n");
|
else LOG("WARNING: RENAME: Example not available in the collection\n");
|
||||||
@@ -358,7 +354,237 @@ int main(int argc, char *argv[])
|
|||||||
UnloadFileText(exColInfo);
|
UnloadFileText(exColInfo);
|
||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Edit: raylib/examples/Makefile --> Add new example
|
// Update: Makefile, Makefile.Web, README.md, examples.js
|
||||||
|
//------------------------------------------------------------------------------------------------
|
||||||
|
UpdateRequiredFiles();
|
||||||
|
//------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Create: raylib/projects/VS2022/examples/<category>_example_name.vcxproj
|
||||||
|
//------------------------------------------------------------------------------------------------
|
||||||
|
FileCopy(TextFormat("%s/../projects/VS2022/examples/core_basic_window.vcxproj", exBasePath),
|
||||||
|
TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exName));
|
||||||
|
FileTextReplace(TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exName),
|
||||||
|
"core_basic_window", exName);
|
||||||
|
FileTextReplace(TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exName),
|
||||||
|
"..\\..\\examples\\core", TextFormat("..\\..\\examples\\%s", exCategory));
|
||||||
|
|
||||||
|
// Edit: raylib/projects/VS2022/raylib.sln --> Add new example project
|
||||||
|
system(TextFormat("dotnet solution %s/../projects/VS2022/raylib.sln add %s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exBasePath, exName));
|
||||||
|
//------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Recompile example (on raylib side)
|
||||||
|
// NOTE: Tools requirements: emscripten, w64devkit
|
||||||
|
// Compile to: raylib.com/examples/<category>/<category>_example_name.html
|
||||||
|
// Compile to: raylib.com/examples/<category>/<category>_example_name.data
|
||||||
|
// Compile to: raylib.com/examples/<category>/<category>_example_name.wasm
|
||||||
|
// Compile to: raylib.com/examples/<category>/<category>_example_name.js
|
||||||
|
//------------------------------------------------------------------------------------------------
|
||||||
|
// TODO: WARNING: This .BAT is not portable and it does not consider RESOURCES for Web properly,
|
||||||
|
// Makefile.Web should be used... but it requires proper editing first!
|
||||||
|
system(TextFormat("%s/build_example_web.bat %s/%s", exBasePath, exCategory, exName));
|
||||||
|
|
||||||
|
// Copy results to web side
|
||||||
|
FileCopy(TextFormat("%s/%s/%s.html", exBasePath, exCategory, exName),
|
||||||
|
TextFormat("%s/%s/%s.html", exWebPath, exCategory, exName));
|
||||||
|
FileCopy(TextFormat("%s/%s/%s.data", exBasePath, exCategory, exName),
|
||||||
|
TextFormat("%s/%s/%s.data", exWebPath, exCategory, exName));
|
||||||
|
FileCopy(TextFormat("%s/%s/%s.wasm", exBasePath, exCategory, exName),
|
||||||
|
TextFormat("%s/%s/%s.wasm", exWebPath, exCategory, exName));
|
||||||
|
FileCopy(TextFormat("%s/%s/%s.js", exBasePath, exCategory, exName),
|
||||||
|
TextFormat("%s/%s/%s.js", exWebPath, exCategory, exName));
|
||||||
|
//------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
} break;
|
||||||
|
case 3: // Rename
|
||||||
|
{
|
||||||
|
// NOTE: At this point provided values have been validated:
|
||||||
|
// exName, exCategory, exRename, exRecategory
|
||||||
|
if (strcmp(exCategory, exRecategory) == 0)
|
||||||
|
{
|
||||||
|
// Rename example on collection
|
||||||
|
FileTextReplace(exCollectionListPath, TextFormat("%s;%s", exCategory, exName),
|
||||||
|
TextFormat("%s;%s", exRecategory, exRename));
|
||||||
|
|
||||||
|
// Rename all required files
|
||||||
|
rename(TextFormat("%s/%s/%s.c", exBasePath, exCategory, exName),
|
||||||
|
TextFormat("%s/%s/%s.c", exBasePath, exCategory, exRename));
|
||||||
|
rename(TextFormat("%s/%s/%s.png", exBasePath, exCategory, exName),
|
||||||
|
TextFormat("%s/%s/%s.png", exBasePath, exCategory, exRename));
|
||||||
|
|
||||||
|
// Rename example on required files
|
||||||
|
FileTextReplace(TextFormat("%s/Makefile", exBasePath), exName, exRename);
|
||||||
|
FileTextReplace(TextFormat("%s/Makefile.Web", exBasePath), exName, exRename);
|
||||||
|
FileTextReplace(TextFormat("%s/README.md", exBasePath), exName, exRename);
|
||||||
|
FileTextReplace(TextFormat("%s/../common/examples.js", exWebPath), exName, exRename);
|
||||||
|
|
||||||
|
// Rename example project and solution
|
||||||
|
rename(TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exName),
|
||||||
|
TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exRename));
|
||||||
|
FileTextReplace(TextFormat("%s/../projects/VS2022/raylib.sln", exBasePath), exName, exRename);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Rename with change of category
|
||||||
|
// TODO: Reorder collection as required
|
||||||
|
FileTextReplace(exCollectionListPath, TextFormat("%s;%s", exCategory, exName),
|
||||||
|
TextFormat("%s;%s", exRecategory, exRename));
|
||||||
|
|
||||||
|
// Rename all required files
|
||||||
|
FileCopy(TextFormat("%s/%s/%s.c", exBasePath, exCategory, exName),
|
||||||
|
TextFormat("%s/%s/%s.c", exBasePath, exCategory, exRename));
|
||||||
|
remove(TextFormat("%s/%s/%s.c", exBasePath, exCategory, exName));
|
||||||
|
|
||||||
|
FileCopy(TextFormat("%s/%s/%s.png", exBasePath, exCategory, exName),
|
||||||
|
TextFormat("%s/%s/%s.png", exBasePath, exCategory, exRename));
|
||||||
|
remove(TextFormat("%s/%s/%s.png", exBasePath, exCategory, exName));
|
||||||
|
|
||||||
|
UpdateRequiredFiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove old web compilation
|
||||||
|
remove(TextFormat("%s/%s/%s.html", exWebPath, exCategory, exName));
|
||||||
|
remove(TextFormat("%s/%s/%s.data", exWebPath, exCategory, exName));
|
||||||
|
remove(TextFormat("%s/%s/%s.wasm", exWebPath, exCategory, exName));
|
||||||
|
remove(TextFormat("%s/%s/%s.js", exWebPath, exCategory, exName));
|
||||||
|
|
||||||
|
// Recompile example (on raylib side)
|
||||||
|
// NOTE: Tools requirements: emscripten, w64devkit
|
||||||
|
// TODO: Avoid platform-specific .BAT file
|
||||||
|
system(TextFormat("%s/build_example_web.bat %s/%s", exBasePath, exRecategory, exRename));
|
||||||
|
|
||||||
|
// Copy results to web side
|
||||||
|
FileCopy(TextFormat("%s/%s/%s.html", exBasePath, exRecategory, exRename),
|
||||||
|
TextFormat("%s/%s/%s.html", exWebPath, exRecategory, exRename));
|
||||||
|
FileCopy(TextFormat("%s/%s/%s.data", exBasePath, exRecategory, exRename),
|
||||||
|
TextFormat("%s/%s/%s.data", exWebPath, exRecategory, exRename));
|
||||||
|
FileCopy(TextFormat("%s/%s/%s.wasm", exBasePath, exRecategory, exRename),
|
||||||
|
TextFormat("%s/%s/%s.wasm", exWebPath, exRecategory, exRename));
|
||||||
|
FileCopy(TextFormat("%s/%s/%s.js", exBasePath, exRecategory, exRename),
|
||||||
|
TextFormat("%s/%s/%s.js", exWebPath, exRecategory, exRename));
|
||||||
|
|
||||||
|
} break;
|
||||||
|
case 4: // Remove
|
||||||
|
{
|
||||||
|
// TODO: Remove and update all required files...
|
||||||
|
|
||||||
|
// Remove: raylib/examples/<category>/<category>_example_name.c
|
||||||
|
// Remove: raylib/examples/<category>/<category>_example_name.png
|
||||||
|
remove(TextFormat("%s/%s/%s.c", exBasePath, exCategory, exName));
|
||||||
|
remove(TextFormat("%s/%s/%s.png", exBasePath, exCategory, exName));
|
||||||
|
|
||||||
|
// TODO: Remove: raylib/examples/<category>/resources/..
|
||||||
|
|
||||||
|
// Edit: raylib/examples/Makefile
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Edit: raylib/examples/Makefile.Web
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Edit: raylib/examples/README.md
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Remove: raylib/projects/VS2022/examples/<category>_example_name.vcxproj
|
||||||
|
remove(TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exName));
|
||||||
|
|
||||||
|
// Edit: raylib/projects/VS2022/raylib.sln
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Edit: raylib.com/common/examples.js
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Remove: raylib.com/examples/<category>/<category>_example_name.html
|
||||||
|
// Remove: raylib.com/examples/<category>/<category>_example_name.data
|
||||||
|
// Remove: raylib.com/examples/<category>/<category>_example_name.wasm
|
||||||
|
// Remove: raylib.com/examples/<category>/<category>_example_name.js
|
||||||
|
remove(TextFormat("%s/%s/%s.html", exWebPath, exCategory, exName));
|
||||||
|
remove(TextFormat("%s/%s/%s.data", exWebPath, exCategory, exName));
|
||||||
|
remove(TextFormat("%s/%s/%s.wasm", exWebPath, exCategory, exName));
|
||||||
|
remove(TextFormat("%s/%s/%s.js", exWebPath, exCategory, exName));
|
||||||
|
|
||||||
|
} break;
|
||||||
|
case 5: // Validate
|
||||||
|
{
|
||||||
|
// TODO: Validate examples collection against [examples_list.txt]
|
||||||
|
|
||||||
|
// Validate: raylib/examples/<category>/<category>_example_name.c
|
||||||
|
// Validate: raylib/examples/<category>/<category>_example_name.png
|
||||||
|
// Validate: raylib/examples/<category>/resources/.. -> Not possible for now...
|
||||||
|
// Validate: raylib/examples/Makefile
|
||||||
|
// Validate: raylib/examples/Makefile.Web
|
||||||
|
// Validate: raylib/examples/README.md
|
||||||
|
// Validate: raylib/projects/VS2022/examples/<category>_example_name.vcxproj
|
||||||
|
// Validate: raylib/projects/VS2022/raylib.sln
|
||||||
|
// Validate: raylib.com/common/examples.js
|
||||||
|
// Validate: raylib.com/examples/<category>/<category>_example_name.html
|
||||||
|
// Validate: raylib.com/examples/<category>/<category>_example_name.data
|
||||||
|
// Validate: raylib.com/examples/<category>/<category>_example_name.wasm
|
||||||
|
// Validate: raylib.com/examples/<category>/<category>_example_name.js
|
||||||
|
|
||||||
|
} break;
|
||||||
|
default: // Help
|
||||||
|
{
|
||||||
|
// Supported commands:
|
||||||
|
// help : Provides command-line usage information
|
||||||
|
// create <new_example_name> : Creates an empty example, from internal template
|
||||||
|
// add <example_name> : Add existing example, category extracted from name
|
||||||
|
// rename <old_examples_name> <new_example_name> : Rename an existing example
|
||||||
|
// remove <example_name> : Remove an existing example
|
||||||
|
|
||||||
|
printf("\n////////////////////////////////////////////////////////////////////////////////////////////\n");
|
||||||
|
printf("// //\n");
|
||||||
|
printf("// rexm [raylib examples manager] - A simple command-line tool to manage raylib examples //\n");
|
||||||
|
printf("// powered by raylib v5.6-dev //\n");
|
||||||
|
printf("// //\n");
|
||||||
|
printf("// Copyright (c) 2025 Ramon Santamaria (@raysan5) //\n");
|
||||||
|
printf("// //\n");
|
||||||
|
printf("////////////////////////////////////////////////////////////////////////////////////////////\n\n");
|
||||||
|
|
||||||
|
printf("USAGE:\n\n");
|
||||||
|
printf(" > rexm help|create|add|rename|remove <example_name> [<example_rename>]\n");
|
||||||
|
|
||||||
|
printf("\nOPTIONS:\n\n");
|
||||||
|
printf(" help : Provides command-line usage information\n");
|
||||||
|
printf(" create <new_example_name> : Creates an empty example, from internal template\n");
|
||||||
|
printf(" add <example_name> : Add existing example, category extracted from name\n");
|
||||||
|
printf(" Supported categories: core, shapes, textures, text, models\n");
|
||||||
|
printf(" rename <old_examples_name> <new_example_name> : Rename an existing example\n");
|
||||||
|
printf(" remove <example_name> : Remove an existing example\n\n");
|
||||||
|
printf("\nEXAMPLES:\n\n");
|
||||||
|
printf(" > rexm add shapes_custom_stars\n");
|
||||||
|
printf(" Add and updates new example provided <shapes_custom_stars>\n\n");
|
||||||
|
printf(" > rexm rename core_basic_window core_cool_window\n");
|
||||||
|
printf(" Renames and updates example <core_basic_window> to <core_cool_window>\n\n");
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Module specific functions definition
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Update required files from examples collection
|
||||||
|
static int UpdateRequiredFiles(void)
|
||||||
|
{
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
// Edit: raylib/examples/Makefile --> Update from collection
|
||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
char *mkText = LoadFileText(TextFormat("%s/Makefile", exBasePath));
|
char *mkText = LoadFileText(TextFormat("%s/Makefile", exBasePath));
|
||||||
char *mkTextUpdated = (char *)RL_CALLOC(2*1024*1024, 1); // Updated Makefile copy, 2MB
|
char *mkTextUpdated = (char *)RL_CALLOC(2*1024*1024, 1); // Updated Makefile copy, 2MB
|
||||||
@@ -392,7 +618,7 @@ int main(int argc, char *argv[])
|
|||||||
RL_FREE(mkTextUpdated);
|
RL_FREE(mkTextUpdated);
|
||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Edit: raylib/examples/Makefile.Web --> Add new example
|
// Edit: raylib/examples/Makefile.Web --> Update from collection
|
||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
char *mkwText = LoadFileText(TextFormat("%s/Makefile.Web", exBasePath));
|
char *mkwText = LoadFileText(TextFormat("%s/Makefile.Web", exBasePath));
|
||||||
char *mkwTextUpdated = (char *)RL_CALLOC(2*1024*1024, 1); // Updated Makefile copy, 2MB
|
char *mkwTextUpdated = (char *)RL_CALLOC(2*1024*1024, 1); // Updated Makefile copy, 2MB
|
||||||
@@ -428,7 +654,7 @@ int main(int argc, char *argv[])
|
|||||||
RL_FREE(mkwTextUpdated);
|
RL_FREE(mkwTextUpdated);
|
||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Edit: raylib/examples/README.md --> Add new example
|
// Edit: raylib/examples/README.md --> Update from collection
|
||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
// NOTE: Using [examples_list.txt] to update/regen README.md
|
// NOTE: Using [examples_list.txt] to update/regen README.md
|
||||||
// Lines format: | 01 | [core_basic_window](core/core_basic_window.c) | <img src="core/core_basic_window.png" alt="core_basic_window" width="80"> | ⭐️☆☆☆ | 1.0 | 1.0 | [Ray](https://github.com/raysan5) |
|
// Lines format: | 01 | [core_basic_window](core/core_basic_window.c) | <img src="core/core_basic_window.png" alt="core_basic_window" width="80"> | ⭐️☆☆☆ | 1.0 | 1.0 | [Ray](https://github.com/raysan5) |
|
||||||
@@ -522,20 +748,7 @@ int main(int argc, char *argv[])
|
|||||||
RL_FREE(mdTextUpdated);
|
RL_FREE(mdTextUpdated);
|
||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Create: raylib/projects/VS2022/examples/<category>_example_name.vcxproj
|
// Edit: raylib.com/common/examples.js --> Update from collection
|
||||||
//------------------------------------------------------------------------------------------------
|
|
||||||
FileCopy(TextFormat("%s/../projects/VS2022/examples/core_basic_window.vcxproj", exBasePath),
|
|
||||||
TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exName));
|
|
||||||
FileTextReplace(TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exName),
|
|
||||||
"core_basic_window", exName);
|
|
||||||
FileTextReplace(TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exName),
|
|
||||||
"..\\..\\examples\\core", TextFormat("..\\..\\examples\\%s", exCategory));
|
|
||||||
|
|
||||||
// Edit: raylib/projects/VS2022/raylib.sln --> Add new example project
|
|
||||||
system(TextFormat("dotnet solution %s/../projects/VS2022/raylib.sln add %s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exBasePath, exName));
|
|
||||||
//------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Edit: raylib.com/common/examples.js --> Add new example
|
|
||||||
// NOTE: Entries format: exampleEntry('⭐️☆☆☆' , 'core' , 'basic_window'),
|
// NOTE: Entries format: exampleEntry('⭐️☆☆☆' , 'core' , 'basic_window'),
|
||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
char *jsText = LoadFileText(TextFormat("%s/../common/examples.js", exWebPath));
|
char *jsText = LoadFileText(TextFormat("%s/../common/examples.js", exWebPath));
|
||||||
@@ -587,130 +800,10 @@ int main(int argc, char *argv[])
|
|||||||
RL_FREE(jsTextUpdated);
|
RL_FREE(jsTextUpdated);
|
||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Recompile example (on raylib side)
|
return result;
|
||||||
// NOTE: Tools requirements: emscripten, w64devkit
|
|
||||||
// Compile to: raylib.com/examples/<category>/<category>_example_name.html
|
|
||||||
// Compile to: raylib.com/examples/<category>/<category>_example_name.data
|
|
||||||
// Compile to: raylib.com/examples/<category>/<category>_example_name.wasm
|
|
||||||
// Compile to: raylib.com/examples/<category>/<category>_example_name.js
|
|
||||||
// TODO: WARNING: This .BAT is not portable and it does not consider RESOURCES for Web properly,
|
|
||||||
// Makefile.Web should be used... but it requires proper editing first!
|
|
||||||
system(TextFormat("%s/build_example_web.bat %s/%s", exBasePath, exCategory, exName));
|
|
||||||
|
|
||||||
// Copy results to web side
|
|
||||||
FileCopy(TextFormat("%s/%s/%s.html", exBasePath, exCategory, exName),
|
|
||||||
TextFormat("%s/%s/%s.html", exWebPath, exCategory, exName));
|
|
||||||
FileCopy(TextFormat("%s/%s/%s.data", exBasePath, exCategory, exName),
|
|
||||||
TextFormat("%s/%s/%s.data", exWebPath, exCategory, exName));
|
|
||||||
FileCopy(TextFormat("%s/%s/%s.wasm", exBasePath, exCategory, exName),
|
|
||||||
TextFormat("%s/%s/%s.wasm", exWebPath, exCategory, exName));
|
|
||||||
FileCopy(TextFormat("%s/%s/%s.js", exBasePath, exCategory, exName),
|
|
||||||
TextFormat("%s/%s/%s.js", exWebPath, exCategory, exName));
|
|
||||||
} break;
|
|
||||||
case 3: // Rename
|
|
||||||
{
|
|
||||||
// Rename all required files
|
|
||||||
rename(TextFormat("%s/%s/%s.c", exBasePath, exCategory, exName),
|
|
||||||
TextFormat("%s/%s/%s.c", exBasePath, exCategory, exRename));
|
|
||||||
rename(TextFormat("%s/%s/%s.png", exBasePath, exCategory, exName),
|
|
||||||
TextFormat("%s/%s/%s.png", exBasePath, exCategory, exRename));
|
|
||||||
|
|
||||||
FileTextReplace(TextFormat("%s/Makefile", exBasePath), exName, exRename);
|
|
||||||
FileTextReplace(TextFormat("%s/Makefile.Web", exBasePath), exName, exRename);
|
|
||||||
FileTextReplace(TextFormat("%s/README.md", exBasePath), exName, exRename);
|
|
||||||
|
|
||||||
rename(TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exName),
|
|
||||||
TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exRename));
|
|
||||||
FileTextReplace(TextFormat("%s/../projects/VS2022/raylib.sln", exBasePath), exName, exRename);
|
|
||||||
|
|
||||||
// Remove old web compilation
|
|
||||||
FileTextReplace(TextFormat("%s/../common/examples.js", exWebPath), exName, exRename);
|
|
||||||
remove(TextFormat("%s/%s/%s.html", exWebPath, exCategory, exName));
|
|
||||||
remove(TextFormat("%s/%s/%s.data", exWebPath, exCategory, exName));
|
|
||||||
remove(TextFormat("%s/%s/%s.wasm", exWebPath, exCategory, exName));
|
|
||||||
remove(TextFormat("%s/%s/%s.js", exWebPath, exCategory, exName));
|
|
||||||
|
|
||||||
// Recompile example (on raylib side)
|
|
||||||
// NOTE: Tools requirements: emscripten, w64devkit
|
|
||||||
// TODO: Avoid platform-specific .BAT file
|
|
||||||
system(TextFormat("%s/build_example_web.bat %s/%s", exBasePath, exCategory, exName));
|
|
||||||
|
|
||||||
// Copy results to web side
|
|
||||||
FileCopy(TextFormat("%s/%s/%s.html", exBasePath, exCategory, exName),
|
|
||||||
TextFormat("%s/%s/%s.html", exWebPath, exCategory, exName));
|
|
||||||
FileCopy(TextFormat("%s/%s/%s.data", exBasePath, exCategory, exName),
|
|
||||||
TextFormat("%s/%s/%s.data", exWebPath, exCategory, exName));
|
|
||||||
FileCopy(TextFormat("%s/%s/%s.wasm", exBasePath, exCategory, exName),
|
|
||||||
TextFormat("%s/%s/%s.wasm", exWebPath, exCategory, exName));
|
|
||||||
FileCopy(TextFormat("%s/%s/%s.js", exBasePath, exCategory, exName),
|
|
||||||
TextFormat("%s/%s/%s.js", exWebPath, exCategory, exName));
|
|
||||||
} break;
|
|
||||||
case 4: // Remove
|
|
||||||
{
|
|
||||||
// TODO: Remove and update all required files...
|
|
||||||
|
|
||||||
} break;
|
|
||||||
case 5: // Validate
|
|
||||||
{
|
|
||||||
// TODO: Validate examples collection against [examples_list.txt]
|
|
||||||
|
|
||||||
// Validate: raylib/examples/<category>/<category>_example_name.c
|
|
||||||
// Validate: raylib/examples/<category>/<category>_example_name.png
|
|
||||||
// Validate: raylib/examples/<category>/resources/.. -> Not possible for now...
|
|
||||||
// Validate: raylib/examples/Makefile
|
|
||||||
// Validate: raylib/examples/Makefile.Web
|
|
||||||
// Validate: raylib/examples/README.md
|
|
||||||
// Validate: raylib/projects/VS2022/examples/<category>_example_name.vcxproj
|
|
||||||
// Validate: raylib/projects/VS2022/raylib.sln
|
|
||||||
// Validate: raylib.com/common/examples.js
|
|
||||||
// Validate: raylib.com/examples/<category>/<category>_example_name.html
|
|
||||||
// Validate: raylib.com/examples/<category>/<category>_example_name.data
|
|
||||||
// Validate: raylib.com/examples/<category>/<category>_example_name.wasm
|
|
||||||
// Validate: raylib.com/examples/<category>/<category>_example_name.js
|
|
||||||
|
|
||||||
} break;
|
|
||||||
default: // Help
|
|
||||||
{
|
|
||||||
// Supported commands:
|
|
||||||
// help : Provides command-line usage information
|
|
||||||
// create <new_example_name> : Creates an empty example, from internal template
|
|
||||||
// add <example_name> : Add existing example, category extracted from name
|
|
||||||
// rename <old_examples_name> <new_example_name> : Rename an existing example
|
|
||||||
// remove <example_name> : Remove an existing example
|
|
||||||
|
|
||||||
printf("\n////////////////////////////////////////////////////////////////////////////////////////////\n");
|
|
||||||
printf("// //\n");
|
|
||||||
printf("// rexm [raylib examples manager] - A simple command-line tool to manage raylib examples //\n");
|
|
||||||
printf("// powered by raylib v5.6-dev //\n");
|
|
||||||
printf("// //\n");
|
|
||||||
printf("// Copyright (c) 2025 Ramon Santamaria (@raysan5) //\n");
|
|
||||||
printf("// //\n");
|
|
||||||
printf("////////////////////////////////////////////////////////////////////////////////////////////\n\n");
|
|
||||||
|
|
||||||
printf("USAGE:\n\n");
|
|
||||||
printf(" > rexm help|create|add|rename|remove <example_name> [<example_rename>]\n");
|
|
||||||
|
|
||||||
printf("\nOPTIONS:\n\n");
|
|
||||||
printf(" help : Provides command-line usage information\n");
|
|
||||||
printf(" create <new_example_name> : Creates an empty example, from internal template\n");
|
|
||||||
printf(" add <example_name> : Add existing example, category extracted from name\n");
|
|
||||||
printf(" Supported categories: core, shapes, textures, text, models\n");
|
|
||||||
printf(" rename <old_examples_name> <new_example_name> : Rename an existing example\n");
|
|
||||||
printf(" remove <example_name> : Remove an existing example\n\n");
|
|
||||||
printf("\nEXAMPLES:\n\n");
|
|
||||||
printf(" > rexm add shapes_custom_stars\n");
|
|
||||||
printf(" Add and updates new example provided <shapes_custom_stars>\n\n");
|
|
||||||
printf(" > rexm rename core_basic_window core_cool_window\n");
|
|
||||||
printf(" Renames and updates example <core_basic_window> to <core_cool_window>\n\n");
|
|
||||||
} break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
// Module specific functions definition
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
// Load examples collection information
|
// Load examples collection information
|
||||||
static rlExampleInfo *LoadExamplesData(const char *fileName, const char *category, bool sort, int *exCount)
|
static rlExampleInfo *LoadExamplesData(const char *fileName, const char *category, bool sort, int *exCount)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user