Преглед на файлове

REXM: ADDED: More detailed log info

pull/5310/head
Ray преди 1 седмица
родител
ревизия
fdc500756d
променени са 1 файла, в които са добавени 78 реда и са изтрити 17 реда
  1. +78
    -17
      tools/rexm/rexm.c

+ 78
- 17
tools/rexm/rexm.c Целия файл

@ -464,12 +464,14 @@ int main(int argc, char *argv[])
// Create: raylib/examples/<category>/<category>_example_name.png
if (FileExists(TextFormat("%s/%s.png", GetDirectoryPath(inFileName), exName)))
{
LOG("INFO: [%s] Copying file screenshot...\n", GetFileName(inFileName));
FileCopy(TextFormat("%s/%s.png", GetDirectoryPath(inFileName), exName),
TextFormat("%s/%s/%s.png", exBasePath, exCategory, exName));
}
else // No screenshot available next to source file
{
// Copy screenshot template
LOG("WARNING: [%s] No screenshot found, using placeholder screenshot\n", GetFileName(inFileName));
FileCopy(exTemplateScreenshot, TextFormat("%s/%s/%s.png", exBasePath, exCategory, exName));
}
@ -478,10 +480,13 @@ int main(int argc, char *argv[])
// Scan resources used in example to copy
// NOTE: resources path will be relative to example source file directory
int resPathCount = 0;
LOG("INFO: [%s] Scanning file for resources...\n", GetFileName(inFileName));
char **resPaths = ScanExampleResources(TextFormat("%s/%s.c", GetDirectoryPath(inFileName), exName), &resPathCount);
if (resPathCount > 0)
{
LOG("INFO: [%s] Required resources found: %i\n", GetFileName(inFileName), resPathCount);
for (int r = 0; r < resPathCount; r++)
{
// WARNING: Special case to consider: shaders, resource paths could use conditions: "glsl%i"
@ -494,7 +499,7 @@ int main(int argc, char *argv[])
{
char *resPathUpdated = TextReplace(resPaths[r], "glsl%i", TextFormat("glsl%i", glslVer[v]));
LOG("INFO: Example resource required: %s\n", resPathUpdated);
LOG("INFO: [%s] Resource required [%i/%i]: %s\n", GetFileName(inFileName), r, resPathCount, resPathUpdated);
if (FileExists(TextFormat("%s/%s", GetDirectoryPath(inFileName), resPathUpdated)))
{
@ -515,7 +520,7 @@ int main(int argc, char *argv[])
}
else
{
LOG("INFO: Example resource required: %s\n", resPaths[r]);
LOG("INFO: [%s] Resource required [%i/%i]: %s\n", GetFileName(inFileName), r, resPathCount, resPaths[r]);
if (FileExists(TextFormat("%s/%s", GetDirectoryPath(inFileName), resPaths[r])))
{
@ -543,6 +548,8 @@ int main(int argc, char *argv[])
char *exCollectionList = LoadFileText(exCollectionFilePath);
if (TextFindIndex(exCollectionList, exName) == -1) // Example not found
{
LOG("INFO: [%s] Adding example to collection list (%s)\n", GetFileName(inFileName), exCategory);
char *exCollectionListUpdated = (char *)RL_CALLOC(REXM_MAX_BUFFER_SIZE, 1); // Updated list copy, 2MB
// Add example to the main list, by category
@ -560,9 +567,15 @@ int main(int argc, char *argv[])
// Get required example info from example file header (if provided)
// NOTE: If no example info is provided (other than category/name), just using some default values
// NOTE: Load example info from provided example header
rlExampleInfo *exInfo = LoadExampleInfo(TextFormat("%s/%s/%s.c", exBasePath, exCategory, exName));
LOG("INFO: [%s] Example info: \n", GetFileName(inFileName));
LOG(" > Author: %s (@%s)\n", exInfo->author, exInfo->authorGitHub);
LOG(" > Stars: %i\n", exInfo->stars);
LOG(" > Version-Update: %s-%s\n", exInfo->verCreated, exInfo->verUpdated);
LOG(" > Created-Reviewed: %i-%i\n", exInfo->yearCreated, exInfo->yearReviewed);
// Get example difficulty stars text
char starsText[16] = { 0 };
for (int i = 0; i < 4; i++)
@ -599,13 +612,14 @@ int main(int argc, char *argv[])
UnloadFileText(exCollectionList);
//------------------------------------------------------------------------------------------------
// Update: Makefile, Makefile.Web, README.md, examples.js
// Update: Metadata, Makefile, Makefile.Web, README.md, examples.js
//------------------------------------------------------------------------------------------------
UpdateRequiredFiles();
//------------------------------------------------------------------------------------------------
// Create: raylib/projects/VS2022/examples/<category>_example_name.vcxproj
//------------------------------------------------------------------------------------------------
LOG("INFO: [%s] Creating example project\n", TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exName));
// WARNING: When adding new project a unique UUID should be assigned!
FileCopy(TextFormat("%s/../projects/VS2022/examples/core_basic_window.vcxproj", exBasePath),
TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exName));
@ -619,6 +633,7 @@ int main(int argc, char *argv[])
// we must store provided file paths because pointers will be overwriten
// TODO: It seems projects are added to solution BUT not to required solution folder,
// that process still requires to be done manually
LOG("INFO: [%s] Adding project to raylib solution (.sln)\n", TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exName));
AddVSProjectToSolution(exVSProjectSolutionFile,
TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exName), exCategory);
//------------------------------------------------------------------------------------------------
@ -633,17 +648,21 @@ int main(int argc, char *argv[])
// WARNING 1: EMSDK_PATH must be set to proper location when calling from GitHub Actions
// WARNING 2: raylib.a and raylib.web.a must be available when compiling locally
#if defined(_WIN32)
LOG("INFO: [%s] Building example for PLATFORM_WEB (Host: Win32)\n", GetFileNameWithoutExt(inFileName));
//putenv("RAYLIB_DIR=C:\\GitHub\\raylib");
putenv("PATH=%PATH%;C:\\raylib\\w64devkit\\bin");
_putenv("PATH=%PATH%;C:\\raylib\\w64devkit\\bin");
system(TextFormat("mingw32-make -C %s -f Makefile.Web %s/%s PLATFORM=PLATFORM_WEB -B", exBasePath, exCategory, exName));
#else
LOG("INFO: [%s] Building example for PLATFORM_WEB (Host: POSIX)\n", GetFileNameWithoutExt(inFileName));
system(TextFormat("make -C %s -f Makefile.Web %s/%s PLATFORM=PLATFORM_WEB -B", exBasePath, exCategory, exName));
#endif
// Update generated .html metadata
LOG("INFO: [%s] Updating HTML Metadata...\n", TextFormat("%s.html", exName));
UpdateWebMetadata(TextFormat("%s/%s/%s.html", exBasePath, exCategory, exName),
TextFormat("%s/%s/%s.c", exBasePath, exCategory, exName));
// Copy results to web side
LOG("INFO: [%s] Copy example build to raylib.com\n", exName);
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),
@ -732,7 +751,7 @@ int main(int argc, char *argv[])
// Recompile example (on raylib side)
// WARNING: EMSDK_PATH must be set to proper location when calling from GitHub Actions
#if defined(_WIN32)
putenv("PATH=%PATH%;C:\\raylib\\w64devkit\\bin");
_putenv("PATH=%PATH%;C:\\raylib\\w64devkit\\bin");
system(TextFormat("mingw32-make -C %s -f Makefile.Web %s/%s PLATFORM=PLATFORM_WEB -B", exBasePath, exRecategory, exRename));
#else
system(TextFormat("make -C %s -f Makefile.Web %s/%s PLATFORM=PLATFORM_WEB -B", exBasePath, exRecategory, exRename));
@ -776,6 +795,7 @@ int main(int argc, char *argv[])
// Remove example from collection for files update
//------------------------------------------------------------------------------------------------
LOG("INFO: [%s] Removing example from collection\n", exName);
char *exCollectionList = LoadFileText(exCollectionFilePath);
int exIndex = TextFindIndex(exCollectionList, TextFormat("%s;%s", exCategory, exName));
if (exIndex > 0) // Example found
@ -831,22 +851,33 @@ int main(int argc, char *argv[])
// Remove: raylib/examples/<category>/<category>_example_name.c
// Remove: raylib/examples/<category>/<category>_example_name.png
LOG("INFO: [%s] Removing example code file\n", TextFormat("%s.c", exName));
FileRemove(TextFormat("%s/%s/%s.c", exBasePath, exCategory, exName));
LOG("INFO: [%s] Removing example screenshot file\n", TextFormat("%s.png", exName));
FileRemove(TextFormat("%s/%s/%s.png", exBasePath, exCategory, exName));
// Edit: Update required files: Makefile, Makefile.Web, README.md, examples.js
UpdateRequiredFiles();
// Remove: raylib/projects/VS2022/examples/<category>_example_name.vcxproj
LOG("INFO: [%s] Removing example project file\n", TextFormat("%s.vcxproj", exName));
FileRemove(TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exName));
// Edit: raylib/projects/VS2022/raylib.sln --> Remove example project
LOG("INFO: [%s] Removing example from raylib solution (.sln)\n", exName);
RemoveVSProjectFromSolution(TextFormat("%s/../projects/VS2022/raylib.sln", exBasePath), exName);
// Remove: Delete example build from local copy (if exists)
FileRemove(TextFormat("%s/%s/%s.html", exBasePath, exCategory, exName));
FileRemove(TextFormat("%s/%s/%s.data", exBasePath, exCategory, exName));
FileRemove(TextFormat("%s/%s/%s.wasm", exBasePath, exCategory, exName));
FileRemove(TextFormat("%s/%s/%s.js", exBasePath, exCategory, exName));
// 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
LOG("INFO: [%s] Deleting example from raylib.com\n", exName);
FileRemove(TextFormat("%s/%s/%s.html", exWebPath, exCategory, exName));
FileRemove(TextFormat("%s/%s/%s.data", exWebPath, exCategory, exName));
FileRemove(TextFormat("%s/%s/%s.wasm", exWebPath, exCategory, exName));
@ -868,11 +899,10 @@ int main(int argc, char *argv[])
// Build: raylib.com/examples/<category>/<category>_example_name.data
// Build: raylib.com/examples/<category>/<category>_example_name.wasm
// Build: raylib.com/examples/<category>/<category>_example_name.js
#if defined(_WIN32)
// Set required environment variables
//putenv(TextFormat("RAYLIB_DIR=%s\\..", exBasePath));
putenv("PATH=%PATH%;C:\\raylib\\w64devkit\\bin");
_putenv("PATH=%PATH%;C:\\raylib\\w64devkit\\bin");
//putenv("MAKE=mingw32-make");
//ChangeDirectory(exBasePath);
#endif
@ -880,22 +910,28 @@ int main(int argc, char *argv[])
{
// Build example for PLATFORM_DESKTOP
#if defined(_WIN32)
LOG("INFO: [%s] Building example for PLATFORM_DESKTOP (Host: Win32)\n", exName);
system(TextFormat("mingw32-make -C %s %s/%s PLATFORM=PLATFORM_DESKTOP -B", exBasePath, exRebuildList[i].category, exRebuildList[i].name));
#else
LOG("INFO: [%s] Building example for PLATFORM_DESKTOP (Host: POSIX)\n", exName);
system(TextFormat("make -C %s %s/%s PLATFORM=PLATFORM_DESKTOP -B", exBasePath, exRebuildList[i].category, exRebuildList[i].name));
#endif
// Build example for PLATFORM_WEB
#if defined(_WIN32)
LOG("INFO: [%s] Building example for PLATFORM_WEB (Host: Win32)\n", exName);
system(TextFormat("mingw32-make -C %s -f Makefile.Web %s/%s PLATFORM=PLATFORM_WEB -B", exBasePath, exRebuildList[i].category, exRebuildList[i].name));
#else
LOG("INFO: [%s] Building example for PLATFORM_WEB (Host: POSIX)\n", exName);
system(TextFormat("make -C %s -f Makefile.Web %s/%s PLATFORM=PLATFORM_WEB -B", exBasePath, exRebuildList[i].category, exRebuildList[i].name));
#endif
// Update generated .html metadata
LOG("INFO: [%s] Updating HTML Metadata...\n", TextFormat("%s.html", exRebuildList[i].name)),
UpdateWebMetadata(TextFormat("%s/%s/%s.html", exBasePath, exRebuildList[i].category, exRebuildList[i].name),
TextFormat("%s/%s/%s.c", exBasePath, exRebuildList[i].category, exRebuildList[i].name));
// Copy results to web side
LOG("INFO: [%s] Copy example build to raylib.com\n", exRebuildList[i].name),
FileCopy(TextFormat("%s/%s/%s.html", exBasePath, exRebuildList[i].category, exRebuildList[i].name),
TextFormat("%s/%s/%s.html", exWebPath, exRebuildList[i].category, exRebuildList[i].name));
FileCopy(TextFormat("%s/%s/%s.data", exBasePath, exRebuildList[i].category, exRebuildList[i].name),
@ -933,10 +969,9 @@ int main(int argc, char *argv[])
VALID_INVALID_CATEGORY
*/
// TODO: Log more details about the validation process
// Scan available example .c files and add to collection missing ones
// NOTE: Source of truth is what we have in the examples directories (on validation/update)
LOG("INFO: Scanning available example (.c) files to be added to collection...\n");
FilePathList clist = LoadDirectoryFilesEx(exBasePath, ".c", true);
char *exList = LoadFileText(exCollectionFilePath);
@ -1007,6 +1042,7 @@ int main(int argc, char *argv[])
UnloadDirectoryFiles(clist);
// Check all examples in collection [examples_list.txt] -> Source of truth!
LOG("INFO: Validating examples in collection...\n");
int exCollectionCount = 0;
rlExampleInfo *exCollection = LoadExamplesData(exCollectionFilePath, "ALL", false, &exCollectionCount);
@ -1016,6 +1052,8 @@ int main(int argc, char *argv[])
rlExampleInfo *exInfo = &exCollection[i];
exInfo->status = 0;
LOG("INFO: [%s] Validating example...\n", exInfo->name);
// Validate: raylib/examples/<category>/<category>_example_name.c -> File exists?
if (!FileExists(TextFormat("%s/%s/%s.c", exBasePath, exInfo->category, exInfo->name))) exInfo->status |= VALID_MISSING_C;
@ -1138,11 +1176,16 @@ int main(int argc, char *argv[])
exInfo->status |= VALID_INCONSISTENT_INFO;
}
if (exInfo->status == 0) LOG("INFO: [%s] Validation result: OK", exInfo->name);
else LOG("WARNING: [%s] Validation result: ISSUES FOUND", exInfo->name);
UnloadExampleInfo(exInfoHeader);
}
if (opCode == OP_UPDATE)
{
LOG("INFO: Updating examples with issues in collection...\n");
// Actions to fix/review anything possible from validation results
//------------------------------------------------------------------------------------------------
// Check examples "status" information
@ -1162,16 +1205,16 @@ int main(int argc, char *argv[])
// NOTE: Some examples should be excluded from VS2022 solution because
// they have specific platform/linkage requirements:
if ((strcmp(exInfo->name, "core_basic_window_web") == 0) ||
(strcmp(exInfo->name, "core_input_gestures_web") == 0) ||
(strcmp(exInfo->name, "raylib_opengl_interop") == 0) ||
(strcmp(exInfo->name, "raymath_vector_angle") == 0)) continue;
if ((strcmp(exInfo->name, "web_basic_window") == 0) ||
(strcmp(exInfo->name, "raylib_opengl_interop") == 0)) continue;
// Review: Add: raylib/projects/VS2022/examples/<category>_example_name.vcxproj
// Review: Add: raylib/projects/VS2022/raylib.sln
// Solves: VALID_MISSING_VCXPROJ, VALID_NOT_IN_VCXSOL
if (exInfo->status & VALID_MISSING_VCXPROJ)
{
LOG("WARNING: [%s] Missing VS2022 project file\n", exInfo->name);
LOG("INFO: [%s.vcxproj] Creating VS2022 project file\n", exInfo->name);
FileCopy(TextFormat("%s/../projects/VS2022/examples/core_basic_window.vcxproj", exBasePath),
TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exInfo->name));
FileTextReplace(TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exInfo->name),
@ -1185,6 +1228,8 @@ int main(int argc, char *argv[])
// Add project (.vcxproj) to raylib solution (.sln)
if (exInfo->status & VALID_NOT_IN_VCXSOL)
{
LOG("WARNING: [%s.vcxproj] Project not included in raylib solution (.sln)\n", exInfo->name);
LOG("INFO: [%s.vcxproj] Adding project to raylib solution (.sln)\n", exInfo->name);
AddVSProjectToSolution(exVSProjectSolutionFile,
TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exInfo->name), exInfo->category);
@ -1199,19 +1244,25 @@ int main(int argc, char *argv[])
if ((strcmp(exInfo->category, "others") != 0) && // Skipping "others" category
((exInfo->status & VALID_MISSING_WEB_OUTPUT) || (exInfo->status & VALID_MISSING_WEB_METADATA)))
{
LOG("WARNING: [%s] Example not available on raylib web\n", exInfo->name);
// Build example for PLATFORM_WEB
#if defined(_WIN32)
putenv("PATH=%PATH%;C:\\raylib\\w64devkit\\bin");
LOG("INFO: [%s] Building example for PLATFORM_WEB (Host: Win32)\n", exInfo->name);
_putenv("PATH=%PATH%;C:\\raylib\\w64devkit\\bin");
system(TextFormat("mingw32-make -C %s -f Makefile.Web %s/%s PLATFORM=PLATFORM_WEB -B", exBasePath, exInfo->category, exInfo->name));
#else
LOG("INFO: [%s] Building example for PLATFORM_WEB (Host: POSIX)\n", exInfo->name);
system(TextFormat("make -C %s -f Makefile.Web %s/%s PLATFORM=PLATFORM_WEB -B", exBasePath, exInfo->category, exInfo->name));
#endif
// Update generated .html metadata
LOG("INFO: [%s.html] Updating HTML Metadata...\n", exInfo->name);
UpdateWebMetadata(TextFormat("%s/%s/%s.html", exBasePath, exInfo->category, exInfo->name),
TextFormat("%s/%s/%s.c", exBasePath, exInfo->category, exInfo->name));
// Copy results to web side
LOG("INFO: [%s] Copy example build to raylib.com\n", exInfo->name);
FileCopy(TextFormat("%s/%s/%s.html", exBasePath, exInfo->category, exInfo->name),
TextFormat("%s/%s/%s.html", exWebPath, exInfo->category, exInfo->name));
FileCopy(TextFormat("%s/%s/%s.data", exBasePath, exInfo->category, exInfo->name),
@ -1228,6 +1279,8 @@ int main(int argc, char *argv[])
if (exInfo->status & VALID_INCONSISTENT_INFO)
{
// Update source code header info
LOG("WARNING: [%s.c] Inconsistent source code metadata\n", exInfo->name);
LOG("INFO: [%s.c] Updating source code metadata...\n", exInfo->name);
UpdateSourceMetadata(TextFormat("%s/%s/%s.c", exBasePath, exInfo->category, exInfo->name), exInfo);
exInfo->status &= ~VALID_INCONSISTENT_INFO;
@ -1273,6 +1326,7 @@ int main(int argc, char *argv[])
| shapes_colors_palette | | | | | | | | | | | | | | |
| text_format_text | | | | | | | | | | | | | | |
*/
LOG("INFO: [examples_report.md] Generating examples validation report...\n");
char *report = (char *)RL_CALLOC(REXM_MAX_BUFFER_SIZE, 1);
@ -1324,6 +1378,8 @@ int main(int argc, char *argv[])
// Generate a report with only the examples missing some elements
//-----------------------------------------------------------------------------------------------------
LOG("INFO: [examples_report_issues.md] Generating examples issues report...\n");
char *reportIssues = (char *)RL_CALLOC(REXM_MAX_BUFFER_SIZE, 1);
repIndex = 0;
@ -1437,6 +1493,7 @@ static int UpdateRequiredFiles(void)
// Edit: Example source code metadata for consistency
//------------------------------------------------------------------------------------------------
LOG("INFO: Updating all examples metadata...\n");
int exListCount = 0;
rlExampleInfo *exList = LoadExamplesData(exCollectionFilePath, "ALL", true, &exListCount);
for (int i = 0; i < exListCount; i++)
@ -1449,6 +1506,7 @@ static int UpdateRequiredFiles(void)
// Edit: raylib/examples/Makefile --> Update from collection
//------------------------------------------------------------------------------------------------
LOG("INFO: Updating raylib/examples/Makefile\n");
char *mkText = LoadFileText(TextFormat("%s/Makefile", exBasePath));
char *mkTextUpdated = (char *)RL_CALLOC(REXM_MAX_BUFFER_SIZE, 1); // Updated Makefile copy, 2MB
@ -1484,6 +1542,7 @@ static int UpdateRequiredFiles(void)
// Edit: raylib/examples/Makefile.Web --> Update from collection
// NOTE: We avoid the "others" category on web building
//------------------------------------------------------------------------------------------------
LOG("INFO: Updating raylib/examples/Makefile.Web\n");
char *mkwText = LoadFileText(TextFormat("%s/Makefile.Web", exBasePath));
char *mkwTextUpdated = (char *)RL_CALLOC(REXM_MAX_BUFFER_SIZE, 1); // Updated Makefile copy, 2MB
@ -1602,6 +1661,7 @@ static int UpdateRequiredFiles(void)
// Edit: raylib/examples/README.md --> Update from collection
//------------------------------------------------------------------------------------------------
LOG("INFO: Updating raylib/examples/README.md\n");
// 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) |
char *mdText = LoadFileText(TextFormat("%s/README.md", exBasePath));
@ -1710,6 +1770,7 @@ static int UpdateRequiredFiles(void)
// Edit: raylib.com/common/examples.js --> Update from collection
// NOTE: Entries format: exampleEntry('' , 'core' , 'basic_window'),
//------------------------------------------------------------------------------------------------
LOG("INFO: Updating raylib.com/common/examples.js\n");
char *jsText = LoadFileText(TextFormat("%s/../common/examples.js", exWebPath));
if (!jsText)
{
@ -2233,7 +2294,7 @@ static int RemoveVSProjectFromSolution(const char *slnFile, const char *exName)
char uuid[38] = { 0 };
strcpy(uuid, "ABCDEF00-0123-4567-89AB-000000000012"); // Temp value
int textUpdatedOfsset = 0;
int exNameLen = strlen(exName);
int exNameLen = p">(int)strlen(exName);
for (int i = 0, index = 0; i < lineCount; i++)
{
@ -2304,7 +2365,7 @@ static void UpdateSourceMetadata(const char *exSrcPath, const rlExampleInfo *inf
char exNameFormated[256] = { 0 }; // Example name without category and using spaces
int exNameIndex = TextFindIndex(info->name, "_");
strcpy(exNameFormated, info->name + exNameIndex + 1);
int exNameLen = strlen(exNameFormated);
int exNameLen = p">(int)strlen(exNameFormated);
for (int i = 0; i < exNameLen; i++) { if (exNameFormated[i] == '_') exNameFormated[i] = ' '; }
// Update example header title (line #3 - ALWAYS)

Зареждане…
Отказ
Запис