| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
#include "raylib.h" |
| 53 |
|
| 54 |
#include <stdio.h> |
| 55 |
#include <string.h> |
| 56 |
#include <stdlib.h> |
| 57 |
|
| 58 |
#define SUPPORT_LOG_INFO |
| 59 |
#if defined(SUPPORT_LOG_INFO) |
| 60 |
#define LOG(...) printf("REXM: "__VA_ARGS__) |
| 61 |
#else |
| 62 |
#define LOG(...) |
| 63 |
#endif |
| 64 |
|
| 65 |
#define REXM_MAX_EXAMPLES 512 |
| 66 |
#define REXM_MAX_EXAMPLE_CATEGORIES 7 |
| 67 |
|
| 68 |
#define REXM_MAX_BUFFER_SIZE (2*1024*1024) // 2MB |
| 69 |
|
| 70 |
#define REXM_MAX_RESOURCE_PATHS 256 |
| 71 |
#define REXM_MAX_RESOURCE_PATH_LENGTH 256 |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
#if defined(__GNUC__) |
| 77 |
#pragma GCC diagnostic push |
| 78 |
|
| 79 |
#pragma GCC diagnostic ignored "-Wformat-security" |
| 80 |
#endif |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
typedef struct { |
| 87 |
char category[16]; |
| 88 |
char name[128]; |
| 89 |
int stars; ☆☆☆ |
| 90 |
char verCreated[12]; |
| 91 |
char verUpdated[12]; |
| 92 |
int yearCreated; |
| 93 |
int yearReviewed; |
| 94 |
char author[64]; |
| 95 |
char authorGitHub[64]; |
| 96 |
|
| 97 |
int status; |
| 98 |
int resCount; |
| 99 |
char **resPaths; |
| 100 |
} rlExampleInfo; |
| 101 |
|
| 102 |
|
| 103 |
typedef struct { |
| 104 |
int buildwarns; |
| 105 |
int warnings; |
| 106 |
int status; |
| 107 |
} rlExampleTesting; |
| 108 |
|
| 109 |
|
| 110 |
typedef enum { |
| 111 |
VALID_OK = 0, |
| 112 |
VALID_MISSING_C = 1 << 0, |
| 113 |
VALID_MISSING_PNG = 1 << 1, |
| 114 |
VALID_INVALID_PNG = 1 << 2, |
| 115 |
VALID_MISSING_RESOURCES = 1 << 3, |
| 116 |
VALID_MISSING_VCXPROJ = 1 << 4, |
| 117 |
VALID_NOT_IN_VCXSOL = 1 << 5, |
| 118 |
VALID_NOT_IN_MAKEFILE = 1 << 6, |
| 119 |
VALID_NOT_IN_MAKEFILE_WEB = 1 << 7, |
| 120 |
VALID_NOT_IN_README = 1 << 8, |
| 121 |
VALID_NOT_IN_JS = 1 << 9, |
| 122 |
VALID_INCONSISTENT_INFO = 1 << 10, |
| 123 |
VALID_MISSING_WEB_OUTPUT = 1 << 11, |
| 124 |
VALID_MISSING_WEB_METADATA = 1 << 12, |
| 125 |
VALID_INVALID_CATEGORY = 1 << 13, |
| 126 |
VALID_UNKNOWN_ERROR = 1 << 14 |
| 127 |
} rlExampleValidationStatus; |
| 128 |
|
| 129 |
typedef enum { |
| 130 |
TESTING_OK = 0, |
| 131 |
TESTING_FAIL_INIT = 1 << 0, |
| 132 |
TESTING_FAIL_CLOSE = 1 << 1, |
| 133 |
TESTING_FAIL_ASSETS = 1 << 2, |
| 134 |
TESTING_FAIL_RLGL = 1 << 3, |
| 135 |
TESTING_FAIL_PLATFORM = 1 << 4, |
| 136 |
TESTING_FAIL_FONT = 1 << 5, |
| 137 |
TESTING_FAIL_TIMER = 1 << 6, |
| 138 |
TESTING_FAIL_OTHER = 1 << 7, |
| 139 |
} rlExampleTestingStatus; |
| 140 |
|
| 141 |
|
| 142 |
typedef enum { |
| 143 |
OP_NONE = 0, |
| 144 |
OP_CREATE = 1, |
| 145 |
OP_ADD = 2, |
| 146 |
OP_RENAME = 3, |
| 147 |
OP_REMOVE = 4, |
| 148 |
OP_VALIDATE = 5, |
| 149 |
OP_UPDATE = 6, |
| 150 |
OP_BUILD = 7, |
| 151 |
OP_TEST = 8, |
| 152 |
OP_TESTLOG = 9, |
| 153 |
} rlExampleOperation; |
| 154 |
|
| 155 |
static const char *exCategories[REXM_MAX_EXAMPLE_CATEGORIES] = { "core", "shapes", "textures", "text", "models", "shaders", "audio" }; |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
static const char *exBasePath = NULL; |
| 160 |
static const char *exWebPath = NULL; |
| 161 |
static const char *exTemplateFilePath = NULL; |
| 162 |
static const char *exTemplateScreenshot = NULL; |
| 163 |
static const char *exCollectionFilePath = NULL; |
| 164 |
static const char *exVSProjectSolutionFile = NULL; |
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
static int UpdateRequiredFiles(void); |
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
static rlExampleInfo *LoadExampleData(const char *filter, bool sort, int *exCount); |
| 177 |
static void UnloadExampleData(rlExampleInfo *exInfo); |
| 178 |
|
| 179 |
|
| 180 |
static rlExampleInfo *LoadExampleInfo(const char *exFileName); |
| 181 |
static void UnloadExampleInfo(rlExampleInfo *exInfo); |
| 182 |
|
| 183 |
|
| 184 |
@raysan5 |
| 185 |
static int ParseExampleInfoLine(const char *line, rlExampleInfo *entry); |
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
static void SortExampleByName(rlExampleInfo *items, int count); |
| 190 |
|
| 191 |
|
| 192 |
static char **LoadExampleResourcePaths(const char *filePath, int *resPathCount); |
| 193 |
|
| 194 |
|
| 195 |
static void UnloadExampleResourcePaths(char **resPaths); |
| 196 |
|
| 197 |
|
| 198 |
static int AddVSProjectToSolution(const char *slnFile, const char *projFile, const char *category); |
| 199 |
static int RemoveVSProjectFromSolution(const char *slnFile, const char *exName); |
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
static const char *GenerateUUIDv4(void); |
| 205 |
|
| 206 |
|
| 207 |
static void UpdateSourceMetadata(const char *exSrcPath, const rlExampleInfo *info); |
| 208 |
|
| 209 |
static void UpdateWebMetadata(const char *exHtmlPath, const char *exFilePath); |
| 210 |
|
| 211 |
|
| 212 |
static int GetTextListIndex(const char *text, const char **list, int listCount); |
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
int main(int argc, char *argv[]) |
| 218 |
{ |
| 219 |
SetTraceLogLevel(LOG_NONE); |
| 220 |
|
| 221 |
|
| 222 |
exBasePath = getenv("REXM_EXAMPLES_BASE_PATH"); |
| 223 |
exWebPath = getenv("REXM_EXAMPLES_WEB_PATH"); |
| 224 |
exTemplateFilePath = getenv("REXM_EXAMPLES_TEMPLATE_FILE_PATH"); |
| 225 |
exTemplateScreenshot = getenv("REXM_EXAMPLES_TEMPLATE_SCREENSHOT_PATH"); |
| 226 |
exCollectionFilePath = getenv("REXM_EXAMPLES_COLLECTION_FILE_PATH"); |
| 227 |
exVSProjectSolutionFile = getenv("REXM_EXAMPLES_VS2022_SLN_FILE"); |
| 228 |
|
| 229 |
#if defined(_WIN32) |
| 230 |
if (!exBasePath) exBasePath = "C:/GitHub/raylib/examples"; |
| 231 |
if (!exWebPath) exWebPath = "C:/GitHub/raylib.com/examples"; |
| 232 |
if (!exTemplateFilePath) exTemplateFilePath = "C:/GitHub/raylib/examples/examples_template.c"; |
| 233 |
if (!exTemplateScreenshot) exTemplateScreenshot = "C:/GitHub/raylib/examples/examples_template.png"; |
| 234 |
if (!exCollectionFilePath) exCollectionFilePath = "C:/GitHub/raylib/examples/examples_list.txt"; |
| 235 |
if (!exVSProjectSolutionFile) exVSProjectSolutionFile = "C:/GitHub/raylib/projects/VS2022/raylib.sln"; |
| 236 |
#else |
| 237 |
|
| 238 |
if (!exBasePath) exBasePath = "../../examples"; |
| 239 |
if (!exWebPath) exWebPath = "../../raylib.com/examples"; |
| 240 |
if (!exTemplateFilePath) exTemplateFilePath = "../../examples/examples_template.c"; |
| 241 |
if (!exTemplateScreenshot) exTemplateScreenshot = "../../examples/examples_template.png"; |
| 242 |
if (!exCollectionFilePath) exCollectionFilePath = "../../examples/examples_list.txt"; |
| 243 |
if (!exVSProjectSolutionFile) exVSProjectSolutionFile = "../../projects/VS2022/raylib.sln"; |
| 244 |
#endif |
| 245 |
|
| 246 |
char inFileName[1024] = { 0 }; |
| 247 |
|
| 248 |
char exName[64] = { 0 }; |
| 249 |
char exCategory[32] = { 0 }; |
| 250 |
char exRecategory[32] = { 0 }; |
| 251 |
char exRename[64] = { 0 }; |
| 252 |
|
| 253 |
char *exBuildList[256] = { 0 }; |
| 254 |
int exBuildListCount = 0; |
| 255 |
|
| 256 |
int opCode = OP_NONE; |
| 257 |
bool showUsage = false; |
| 258 |
bool verbose = false; |
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
if (argc > 1) |
| 263 |
{ |
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
if (strcmp(argv[1], "create") == 0) |
| 274 |
{ |
| 275 |
|
| 276 |
if (argc == 2) LOG("WARNING: No filename provided to create\n"); |
| 277 |
else if (argc > 3) LOG("WARNING: Too many arguments provided\n"); |
| 278 |
else |
| 279 |
{ |
| 280 |
|
| 281 |
int catIndex = TextFindIndex(argv[2], "_"); |
| 282 |
if (catIndex > 3) |
| 283 |
{ |
| 284 |
char cat[12] = { 0 }; |
| 285 |
strncpy(cat, argv[2], catIndex); |
| 286 |
bool catFound = false; |
| 287 |
for (int i = 0; i < REXM_MAX_EXAMPLE_CATEGORIES; i++) |
| 288 |
{ |
| 289 |
if (TextIsEqual(cat, exCategories[i])) { catFound = true; break; } |
| 290 |
} |
| 291 |
|
| 292 |
if (catFound) |
| 293 |
{ |
| 294 |
strcpy(exName, argv[2]); |
| 295 |
strncpy(exCategory, exName, TextFindIndex(exName, "_")); |
| 296 |
opCode = OP_CREATE; |
| 297 |
} |
| 298 |
else LOG("WARNING: Example category is not valid\n"); |
| 299 |
} |
| 300 |
else LOG("WARNING: Example name does not include category\n"); |
| 301 |
} |
| 302 |
} |
| 303 |
else if (strcmp(argv[1], "add") == 0) |
| 304 |
{ |
| 305 |
|
| 306 |
if (argc == 2) LOG("WARNING: No filename provided to create\n"); |
| 307 |
else if (argc > 3) LOG("WARNING: Too many arguments provided\n"); |
| 308 |
else |
| 309 |
{ |
| 310 |
if (IsFileExtension(argv[2], ".c")) |
| 311 |
{ |
| 312 |
if (FileExists(argv[2])) |
| 313 |
{ |
| 314 |
|
| 315 |
int catIndex = TextFindIndex(GetFileName(argv[2]), "_"); |
| 316 |
if (catIndex > 3) |
| 317 |
{ |
| 318 |
char cat[12] = { 0 }; |
| 319 |
strncpy(cat, GetFileName(argv[2]), catIndex); |
| 320 |
bool catFound = false; |
| 321 |
for (int i = 0; i < REXM_MAX_EXAMPLE_CATEGORIES; i++) |
| 322 |
{ |
| 323 |
if (TextIsEqual(cat, exCategories[i])) { catFound = true; break; } |
| 324 |
} |
| 325 |
|
| 326 |
if (catFound) |
| 327 |
{ |
| 328 |
strcpy(inFileName, argv[2]); |
| 329 |
strcpy(exName, GetFileNameWithoutExt(inFileName)); |
| 330 |
strncpy(exCategory, exName, TextFindIndex(exName, "_")); |
| 331 |
opCode = OP_ADD; |
| 332 |
} |
| 333 |
else LOG("WARNING: Example category is not valid\n"); |
| 334 |
} |
| 335 |
else LOG("WARNING: Example name does not include category\n"); |
| 336 |
} |
| 337 |
else LOG("WARNING: Input file not found, include path\n"); |
| 338 |
} |
| 339 |
else LOG("WARNING: Input file extension not recognized (.c)\n"); |
| 340 |
} |
| 341 |
} |
| 342 |
else if (strcmp(argv[1], "rename") == 0) |
| 343 |
{ |
| 344 |
if (argc == 2) LOG("WARNING: No filename provided to be renamed\n"); |
| 345 |
else if (argc == 3) LOG("WARNING: No new filename provided to be renamed\n"); |
| 346 |
else if (argc > 4) LOG("WARNING: Too many arguments provided\n"); |
| 347 |
else |
| 348 |
{ |
| 349 |
|
| 350 |
char *exColInfo = LoadFileText(exCollectionFilePath); |
| 351 |
if (TextFindIndex(exColInfo, argv[2]) != -1) |
| 352 |
{ |
| 353 |
|
| 354 |
int newCatIndex = TextFindIndex(argv[3], "_"); |
| 355 |
if (newCatIndex > 3) |
| 356 |
{ |
| 357 |
char cat[12] = { 0 }; |
| 358 |
strncpy(cat, argv[3], newCatIndex); |
| 359 |
bool newCatFound = false; |
| 360 |
for (int i = 0; i < REXM_MAX_EXAMPLE_CATEGORIES; i++) |
| 361 |
{ |
| 362 |
if (TextIsEqual(cat, exCategories[i])) { newCatFound = true; break; } |
| 363 |
} |
| 364 |
|
| 365 |
if (newCatFound) |
| 366 |
{ |
| 367 |
strcpy(exName, argv[2]); |
| 368 |
strncpy(exCategory, exName, TextFindIndex(exName, "_")); |
| 369 |
strcpy(exRename, argv[3]); |
| 370 |
strncpy(exRecategory, exRename, TextFindIndex(exRename, "_")); |
| 371 |
opCode = OP_RENAME; |
| 372 |
} |
| 373 |
else LOG("WARNING: Example new category is not valid\n"); |
| 374 |
} |
| 375 |
else LOG("WARNING: Example new name does not include category\n"); |
| 376 |
} |
| 377 |
else LOG("WARNING: RENAME: Example not available in the collection\n"); |
| 378 |
UnloadFileText(exColInfo); |
| 379 |
} |
| 380 |
} |
| 381 |
else if (strcmp(argv[1], "remove") == 0) |
| 382 |
{ |
| 383 |
|
| 384 |
if (argc == 2) LOG("WARNING: No filename provided to create\n"); |
| 385 |
else if (argc > 3) LOG("WARNING: Too many arguments provided\n"); |
| 386 |
else |
| 387 |
{ |
| 388 |
|
| 389 |
char *exColInfo = LoadFileText(exCollectionFilePath); |
| 390 |
if (TextFindIndex(exColInfo, argv[2]) != -1) |
| 391 |
{ |
| 392 |
strcpy(exName, argv[2]); |
| 393 |
strncpy(exCategory, exName, TextFindIndex(exName, "_")); |
| 394 |
opCode = OP_REMOVE; |
| 395 |
} |
| 396 |
else LOG("WARNING: REMOVE: Example not available in the collection\n"); |
| 397 |
UnloadFileText(exColInfo); |
| 398 |
} |
| 399 |
} |
| 400 |
else if (strcmp(argv[1], "validate") == 0) |
| 401 |
{ |
| 402 |
|
| 403 |
|
| 404 |
|
| 405 |
opCode = OP_VALIDATE; |
| 406 |
} |
| 407 |
else if (strcmp(argv[1], "update") == 0) |
| 408 |
{ |
| 409 |
|
| 410 |
|
| 411 |
|
| 412 |
opCode = OP_UPDATE; |
| 413 |
} |
| 414 |
else if ((strcmp(argv[1], "build") == 0) || (strcmp(argv[1], "test") == 0) || (strcmp(argv[1], "testlog") == 0)) |
| 415 |
{ |
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
if (argc == 2) LOG("WARNING: No example name/category provided\n"); |
| 422 |
else if (argc > 3) LOG("WARNING: Too many arguments provided\n"); |
| 423 |
else |
| 424 |
{ |
| 425 |
|
| 426 |
int exBuildListInfoCount = 0; |
| 427 |
rlExampleInfo *exBuildListInfo = LoadExampleData(argv[2], false, &exBuildListInfoCount); |
| 428 |
|
| 429 |
for (int i = 0; i < exBuildListInfoCount; i++) |
| 430 |
{ |
| 431 |
if (!TextIsEqual(exBuildListInfo[i].category, "others")) |
| 432 |
{ |
| 433 |
exBuildList[exBuildListCount] = (char *)RL_CALLOC(256, sizeof(char)); |
| 434 |
strcpy(exBuildList[exBuildListCount], exBuildListInfo[i].name); |
| 435 |
exBuildListCount++; |
| 436 |
} |
| 437 |
} |
| 438 |
|
| 439 |
UnloadExampleData(exBuildListInfo); |
| 440 |
|
| 441 |
if (exBuildListCount == 0) LOG("WARNING: BUILD: Example requested not available in the collection\n"); |
| 442 |
else |
| 443 |
{ |
| 444 |
if (strcmp(argv[1], "build") == 0) opCode = OP_BUILD; |
| 445 |
else if (strcmp(argv[1], "test") == 0) opCode = OP_TEST; |
| 446 |
else if (strcmp(argv[1], "testlog") == 0) opCode = OP_TESTLOG; |
| 447 |
} |
| 448 |
} |
| 449 |
} |
| 450 |
|
| 451 |
|
| 452 |
for (int i = 1; i < argc; i++) |
| 453 |
{ |
| 454 |
if ((strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "--help") == 0)) showUsage = true; |
| 455 |
else if ((strcmp(argv[i], "-v") == 0) || (strcmp(argv[i], "--verbose") == 0)) verbose = true; |
| 456 |
} |
| 457 |
} |
| 458 |
|
| 459 |
|
| 460 |
switch (opCode) |
| 461 |
{ |
| 462 |
case OP_CREATE: |
| 463 |
{ |
| 464 |
LOG("INFO: Command requested: CREATE\n"); |
| 465 |
LOG("INFO: Example to create: %s\n", exName); |
| 466 |
|
| 467 |
|
| 468 |
char *exText = LoadFileText(exTemplateFilePath); |
| 469 |
char *exTextUpdated[6] = { 0 }; |
| 470 |
int exIndex = TextFindIndex(exText, "/****************"); |
| 471 |
|
| 472 |
|
| 473 |
exTextUpdated[0] = TextReplaceAlloc(exText + exIndex, "<module>", exCategory); |
| 474 |
exTextUpdated[1] = TextReplaceAlloc(exTextUpdated[0], "<name>", exName + strlen(exCategory) + 1); |
| 475 |
|
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
SaveFileText(TextFormat("%s/%s/%s.c", exBasePath, exCategory, exName), exTextUpdated[1]); |
| 481 |
for (int i = 0; i < 6; i++) { MemFree(exTextUpdated[i]); exTextUpdated[i] = NULL; } |
| 482 |
UnloadFileText(exText); |
| 483 |
} |
| 484 |
case OP_ADD: |
| 485 |
{ |
| 486 |
if (opCode != OP_CREATE) LOG("INFO: Command requested: ADD\n"); |
| 487 |
LOG("INFO: Example file to be added: %s\n", inFileName); |
| 488 |
|
| 489 |
|
| 490 |
if (opCode != OP_CREATE) FileCopy(inFileName, TextFormat("%s/%s/%s.c", exBasePath, exCategory, exName)); |
| 491 |
|
| 492 |
|
| 493 |
if (FileExists(TextFormat("%s/%s.png", GetDirectoryPath(inFileName), exName))) |
| 494 |
{ |
| 495 |
LOG("INFO: [%s] Copying file screenshot...\n", GetFileName(inFileName)); |
| 496 |
FileCopy(TextFormat("%s/%s.png", GetDirectoryPath(inFileName), exName), |
| 497 |
TextFormat("%s/%s/%s.png", exBasePath, exCategory, exName)); |
| 498 |
} |
| 499 |
else |
| 500 |
{ |
| 501 |
|
| 502 |
LOG("WARNING: [%s] No screenshot found, using placeholder screenshot\n", GetFileName(inFileName)); |
| 503 |
FileCopy(exTemplateScreenshot, TextFormat("%s/%s/%s.png", exBasePath, exCategory, exName)); |
| 504 |
} |
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
|
| 509 |
|
| 510 |
int resPathCount = 0; |
| 511 |
LOG("INFO: [%s] Scanning file for resources...\n", GetFileName(inFileName)); |
| 512 |
char **resPaths = LoadExampleResourcePaths(TextFormat("%s/%s.c", GetDirectoryPath(inFileName), exName), &resPathCount); |
| 513 |
|
| 514 |
if (resPathCount > 0) |
| 515 |
{ |
| 516 |
LOG("INFO: [%s] Required resources found: %i\n", GetFileName(inFileName), resPathCount); |
| 517 |
|
| 518 |
for (int r = 0; r < resPathCount; r++) |
| 519 |
{ |
| 520 |
|
| 521 |
|
| 522 |
if (TextFindIndex(resPaths[r], "glsl%i") > -1) |
| 523 |
{ |
| 524 |
int glslVer[3] = { 100, 120, 330 }; |
| 525 |
|
| 526 |
for (int v = 0; v < 3; v++) |
| 527 |
{ |
| 528 |
char *resPathUpdated = TextReplace(resPaths[r], "glsl%i", TextFormat("glsl%i", glslVer[v])); |
| 529 |
|
| 530 |
LOG("INFO: [%s] Resource required [%i/%i]: %s\n", GetFileName(inFileName), r, resPathCount, resPathUpdated); |
| 531 |
|
| 532 |
if (FileExists(TextFormat("%s/%s", GetDirectoryPath(inFileName), resPathUpdated))) |
| 533 |
{ |
| 534 |
|
| 535 |
if (TextFindIndex(resPathUpdated, "resources/") > 0) |
| 536 |
{ |
| 537 |
|
| 538 |
|
| 539 |
FileCopy(TextFormat("%s/%s", GetDirectoryPath(inFileName), resPathUpdated), |
| 540 |
TextFormat("%s/%s/%s", exBasePath, exCategory, resPathUpdated)); |
| 541 |
} |
| 542 |
else LOG("WARNING: Example resource must be placed in 'resources' directory next to .c file\n"); |
| 543 |
} |
| 544 |
else LOG("WARNING: Example resource can not be found in: %s\n", TextFormat("%s/%s", GetDirectoryPath(inFileName), resPathUpdated)); |
| 545 |
} |
| 546 |
} |
| 547 |
else |
| 548 |
{ |
| 549 |
LOG("INFO: [%s] Resource required [%i/%i]: %s\n", GetFileName(inFileName), r, resPathCount, resPaths[r]); |
| 550 |
|
| 551 |
if (FileExists(TextFormat("%s/%s", GetDirectoryPath(inFileName), resPaths[r]))) |
| 552 |
{ |
| 553 |
|
| 554 |
if (TextFindIndex(resPaths[r], "resources/") > 0) |
| 555 |
{ |
| 556 |
|
| 557 |
|
| 558 |
FileCopy(TextFormat("%s/%s", GetDirectoryPath(inFileName), resPaths[r]), |
| 559 |
TextFormat("%s/%s/%s", exBasePath, exCategory, resPaths[r])); |
| 560 |
} |
| 561 |
else LOG("WARNING: Example resource must be placed in 'resources' directory next to .c file\n"); |
| 562 |
} |
| 563 |
else LOG("WARNING: Example resource can not be found in: %s\n", TextFormat("%s/%s", GetDirectoryPath(inFileName), resPaths[r])); |
| 564 |
} |
| 565 |
} |
| 566 |
} |
| 567 |
|
| 568 |
UnloadExampleResourcePaths(resPaths); |
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
@raysan5 |
| 573 |
|
| 574 |
char *exCollectionList = LoadFileText(exCollectionFilePath); |
| 575 |
if (TextFindIndex(exCollectionList, exName) == -1) |
| 576 |
{ |
| 577 |
LOG("INFO: [%s] Adding example to collection list (%s)\n", GetFileName(inFileName), exCategory); |
| 578 |
|
| 579 |
char *exCollectionListUpdated = (char *)RL_CALLOC(REXM_MAX_BUFFER_SIZE, 1); |
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
|
| 584 |
int nextCategoryIndex = 0; |
| 585 |
if (TextIsEqual(exCategory, "core")) nextCategoryIndex = 1; |
| 586 |
else if (TextIsEqual(exCategory, "shapes")) nextCategoryIndex = 2; |
| 587 |
else if (TextIsEqual(exCategory, "textures")) nextCategoryIndex = 3; |
| 588 |
else if (TextIsEqual(exCategory, "text")) nextCategoryIndex = 4; |
| 589 |
else if (TextIsEqual(exCategory, "models")) nextCategoryIndex = 5; |
| 590 |
else if (TextIsEqual(exCategory, "shaders")) nextCategoryIndex = 6; |
| 591 |
else if (TextIsEqual(exCategory, "audio")) nextCategoryIndex = 7; |
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
rlExampleInfo *exInfo = LoadExampleInfo(TextFormat("%s/%s/%s.c", exBasePath, exCategory, exName)); |
| 597 |
|
| 598 |
LOG("INFO: [%s] Example info: \n", GetFileName(inFileName)); |
| 599 |
LOG(" > Author: %s (@%s)\n", exInfo->author, exInfo->authorGitHub); |
| 600 |
LOG(" > Stars: %i\n", exInfo->stars); |
| 601 |
LOG(" > Version-Update: %s-%s\n", exInfo->verCreated, exInfo->verUpdated); |
| 602 |
LOG(" > Created-Reviewed: %i-%i\n", exInfo->yearCreated, exInfo->yearReviewed); |
| 603 |
|
| 604 |
|
| 605 |
char starsText[16] = { 0 }; |
| 606 |
for (int i = 0; i < 4; i++) |
| 607 |
{ |
| 608 |
|
| 609 |
if (i < exInfo->stars) strcpy(starsText + 3*i, "★"); |
| 610 |
else strcpy(starsText + 3*i, "☆"); |
| 611 |
} |
| 612 |
|
| 613 |
if (nextCategoryIndex == -1) |
| 614 |
{ |
| 615 |
|
| 616 |
int endIndex = (int)strlen(exCollectionList); |
| 617 |
memcpy(exCollectionListUpdated, exCollectionList, endIndex); |
| 618 |
sprintf(exCollectionListUpdated + endIndex, TextFormat("%s;%s;%s;%s;%s;%i;%i;\"%s\";@%s\n", |
| 619 |
exInfo->category, exInfo->name, starsText, exInfo->verCreated, exInfo->verUpdated, exInfo->yearCreated, exInfo->yearReviewed, exInfo->author, exInfo->authorGitHub)); |
| 620 |
} |
| 621 |
else |
| 622 |
{ |
| 623 |
|
| 624 |
int categoryIndex = TextFindIndex(exCollectionList, exCategories[nextCategoryIndex]); |
| 625 |
memcpy(exCollectionListUpdated, exCollectionList, categoryIndex); |
| 626 |
int textWritenSize = sprintf(exCollectionListUpdated + categoryIndex, TextFormat("%s;%s;%s;%s;%s;%i;%i;\"%s\";@%s\n", |
| 627 |
exInfo->category, exInfo->name, starsText, exInfo->verCreated, exInfo->verUpdated, exInfo->yearCreated, exInfo->yearReviewed, exInfo->author, exInfo->authorGitHub)); |
| 628 |
memcpy(exCollectionListUpdated + categoryIndex + textWritenSize, exCollectionList + categoryIndex, strlen(exCollectionList) - categoryIndex); |
| 629 |
} |
| 630 |
|
| 631 |
UnloadExampleInfo(exInfo); |
| 632 |
|
| 633 |
SaveFileText(exCollectionFilePath, exCollectionListUpdated); |
| 634 |
RL_FREE(exCollectionListUpdated); |
| 635 |
} |
| 636 |
else LOG("WARNING: ADD: Example is already on the collection\n"); |
| 637 |
UnloadFileText(exCollectionList); |
| 638 |
|
| 639 |
|
| 640 |
|
| 641 |
|
| 642 |
UpdateRequiredFiles(); |
| 643 |
|
| 644 |
|
| 645 |
|
| 646 |
|
| 647 |
LOG("INFO: [%s] Creating example project\n", TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exName)); |
| 648 |
|
| 649 |
FileCopy(TextFormat("%s/../projects/VS2022/examples/core_basic_window.vcxproj", exBasePath), |
| 650 |
TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exName)); |
| 651 |
FileTextReplace(TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exName), |
| 652 |
"core_basic_window", exName); |
| 653 |
FileTextReplace(TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exName), |
| 654 |
"..\\..\\examples\\core", TextFormat("..\\..\\examples\\%s", exCategory)); |
| 655 |
|
| 656 |
|
| 657 |
|
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
LOG("INFO: [%s] Adding project to raylib solution (.sln)\n", |
| 662 |
TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exName)); |
| 663 |
AddVSProjectToSolution(exVSProjectSolutionFile, |
| 664 |
TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exName), exCategory); |
| 665 |
|
| 666 |
|
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
|
| 671 |
|
| 672 |
|
| 673 |
|
| 674 |
|
| 675 |
|
| 676 |
#if defined(_WIN32) |
| 677 |
LOG("INFO: [%s] Building example for PLATFORM_WEB (Host: Win32)\n", GetFileNameWithoutExt(inFileName)); |
| 678 |
|
| 679 |
_putenv("PATH=%PATH%;C:\\raylib\\w64devkit\\bin"); |
| 680 |
system(TextFormat("mingw32-make -C %s -f Makefile.Web %s/%s PLATFORM=PLATFORM_WEB -B", exBasePath, exCategory, exName)); |
| 681 |
#else |
| 682 |
LOG("INFO: [%s] Building example for PLATFORM_WEB (Host: POSIX)\n", GetFileNameWithoutExt(inFileName)); |
| 683 |
system(TextFormat("make -C %s -f Makefile.Web %s/%s PLATFORM=PLATFORM_WEB -B", exBasePath, exCategory, exName)); |
| 684 |
#endif |
| 685 |
|
| 686 |
LOG("INFO: [%s] Updating HTML Metadata...\n", TextFormat("%s.html", exName)); |
| 687 |
UpdateWebMetadata(TextFormat("%s/%s/%s.html", exBasePath, exCategory, exName), |
| 688 |
TextFormat("%s/%s/%s.c", exBasePath, exCategory, exName)); |
| 689 |
|
| 690 |
|
| 691 |
LOG("INFO: [%s] Copy example build to raylib.com\n", exName); |
| 692 |
FileCopy(TextFormat("%s/%s/%s.html", exBasePath, exCategory, exName), |
| 693 |
TextFormat("%s/%s/%s.html", exWebPath, exCategory, exName)); |
| 694 |
FileCopy(TextFormat("%s/%s/%s.data", exBasePath, exCategory, exName), |
| 695 |
TextFormat("%s/%s/%s.data", exWebPath, exCategory, exName)); |
| 696 |
FileCopy(TextFormat("%s/%s/%s.wasm", exBasePath, exCategory, exName), |
| 697 |
TextFormat("%s/%s/%s.wasm", exWebPath, exCategory, exName)); |
| 698 |
FileCopy(TextFormat("%s/%s/%s.js", exBasePath, exCategory, exName), |
| 699 |
TextFormat("%s/%s/%s.js", exWebPath, exCategory, exName)); |
| 700 |
|
| 701 |
|
| 702 |
} break; |
| 703 |
case OP_RENAME: |
| 704 |
{ |
| 705 |
LOG("INFO: Command requested: RENAME\n"); |
| 706 |
LOG("INFO: Example to be renamed: %s --> %s\n", exName, exRename); |
| 707 |
|
| 708 |
|
| 709 |
|
| 710 |
if (strcmp(exCategory, exRecategory) == 0) |
| 711 |
{ |
| 712 |
|
| 713 |
FileTextReplace(exCollectionFilePath, TextFormat("%s;%s", exCategory, exName), |
| 714 |
TextFormat("%s;%s", exRecategory, exRename)); |
| 715 |
|
| 716 |
|
| 717 |
FileRename(TextFormat("%s/%s/%s.c", exBasePath, exCategory, exName), |
| 718 |
TextFormat("%s/%s/%s.c", exBasePath, exCategory, exRename)); |
| 719 |
FileRename(TextFormat("%s/%s/%s.png", exBasePath, exCategory, exName), |
| 720 |
TextFormat("%s/%s/%s.png", exBasePath, exCategory, exRename)); |
| 721 |
|
| 722 |
|
| 723 |
int exListCount = 0; |
| 724 |
rlExampleInfo *exList = LoadExampleData(exCategory, false, &exListCount); |
| 725 |
for (int i = 0; i < exListCount; i++) |
| 726 |
{ |
| 727 |
if (strcmp(exList[i].name, exRename) == 0) |
| 728 |
UpdateSourceMetadata(TextFormat("%s/%s/%s.c", exBasePath, exCategory, exRename), &exList[i]); |
| 729 |
} |
| 730 |
UnloadExampleData(exList); |
| 731 |
|
| 732 |
|
| 733 |
|
| 734 |
|
| 735 |
|
| 736 |
FileTextReplace(TextFormat("%s/Makefile", exBasePath), exName, exRename); |
| 737 |
FileTextReplace(TextFormat("%s/Makefile.Web", exBasePath), exName, exRename); |
| 738 |
FileTextReplace(TextFormat("%s/README.md", exBasePath), exName, exRename); |
| 739 |
FileTextReplace(TextFormat("%s/../common/examples.js", exWebPath), |
| 740 |
exName + strlen(exCategory) + 1, exRename + strlen(exRecategory) + 1); |
| 741 |
|
| 742 |
|
| 743 |
FileTextReplace(TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exName), exName, exRename); |
| 744 |
FileRename(TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exName), |
| 745 |
TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exRename)); |
| 746 |
FileTextReplace(TextFormat("%s/../projects/VS2022/raylib.sln", exBasePath), exName, exRename); |
| 747 |
} |
| 748 |
else |
| 749 |
{ |
| 750 |
|
| 751 |
|
| 752 |
FileTextReplace(exCollectionFilePath, TextFormat("%s;%s", exCategory, exName), |
| 753 |
TextFormat("%s;%s", exRecategory, exRename)); |
| 754 |
|
| 755 |
|
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
FileCopy(TextFormat("%s/%s/%s.c", exBasePath, exCategory, exName), |
| 760 |
TextFormat("%s/%s/%s.c", exBasePath, exCategory, exRename)); |
| 761 |
FileRemove(TextFormat("%s/%s/%s.c", exBasePath, exCategory, exName)); |
| 762 |
|
| 763 |
FileCopy(TextFormat("%s/%s/%s.png", exBasePath, exCategory, exName), |
| 764 |
TextFormat("%s/%s/%s.png", exBasePath, exCategory, exRename)); |
| 765 |
FileRemove(TextFormat("%s/%s/%s.png", exBasePath, exCategory, exName)); |
| 766 |
|
| 767 |
|
| 768 |
UpdateRequiredFiles(); |
| 769 |
} |
| 770 |
|
| 771 |
|
| 772 |
FileRemove(TextFormat("%s/%s/%s.html", exWebPath, exCategory, exName)); |
| 773 |
FileRemove(TextFormat("%s/%s/%s.data", exWebPath, exCategory, exName)); |
| 774 |
FileRemove(TextFormat("%s/%s/%s.wasm", exWebPath, exCategory, exName)); |
| 775 |
FileRemove(TextFormat("%s/%s/%s.js", exWebPath, exCategory, exName)); |
| 776 |
|
| 777 |
|
| 778 |
|
| 779 |
#if defined(_WIN32) |
| 780 |
_putenv("PATH=%PATH%;C:\\raylib\\w64devkit\\bin"); |
| 781 |
system(TextFormat("mingw32-make -C %s -f Makefile.Web %s/%s PLATFORM=PLATFORM_WEB -B", exBasePath, exRecategory, exRename)); |
| 782 |
#else |
| 783 |
system(TextFormat("make -C %s -f Makefile.Web %s/%s PLATFORM=PLATFORM_WEB -B", exBasePath, exRecategory, exRename)); |
| 784 |
#endif |
| 785 |
|
| 786 |
UpdateWebMetadata(TextFormat("%s/%s/%s.html", exBasePath, exCategory, exRename), |
| 787 |
TextFormat("%s/%s/%s.c", exBasePath, exCategory, exRename)); |
| 788 |
|
| 789 |
|
| 790 |
FileCopy(TextFormat("%s/%s/%s.html", exBasePath, exRecategory, exRename), |
| 791 |
TextFormat("%s/%s/%s.html", exWebPath, exRecategory, exRename)); |
| 792 |
FileCopy(TextFormat("%s/%s/%s.data", exBasePath, exRecategory, exRename), |
| 793 |
TextFormat("%s/%s/%s.data", exWebPath, exRecategory, exRename)); |
| 794 |
FileCopy(TextFormat("%s/%s/%s.wasm", exBasePath, exRecategory, exRename), |
| 795 |
TextFormat("%s/%s/%s.wasm", exWebPath, exRecategory, exRename)); |
| 796 |
FileCopy(TextFormat("%s/%s/%s.js", exBasePath, exRecategory, exRename), |
| 797 |
TextFormat("%s/%s/%s.js", exWebPath, exRecategory, exRename)); |
| 798 |
|
| 799 |
#if defined(RENAME_AUTO_COMMIT_CREATION) |
| 800 |
|
| 801 |
putenv("PATH=%PATH%;C:\\Program Files\\Git\\bin"); |
| 802 |
ChangeDirectory("C:\\GitHub\\raylib"); |
| 803 |
system("git --version"); |
| 804 |
system("git status"); |
| 805 |
system("git add -A"); |
| 806 |
int result = system(TextFormat("git commit -m \"REXM: RENAME: example: `%s` --> `%s`\"", exName, exRename)); |
| 807 |
if (result != 0) LOG("WARNING: Error committing changes\n"); |
| 808 |
ChangeDirectory("C:/GitHub/raylib.com"); |
| 809 |
system("git add -A"); |
| 810 |
result = system(TextFormat("git commit -m \"REXM: RENAME: example: `%s` --> `%s`\"", exName, exRename)); |
| 811 |
if (result != 0) LOG("WARNING: Error committing changes\n"); |
| 812 |
|
| 813 |
|
| 814 |
#endif |
| 815 |
|
| 816 |
} break; |
| 817 |
case OP_REMOVE: |
| 818 |
{ |
| 819 |
LOG("INFO: Command requested: REMOVE\n"); |
| 820 |
LOG("INFO: Example to be removed: %s\n", exName); |
| 821 |
|
| 822 |
|
| 823 |
|
| 824 |
LOG("INFO: [%s] Removing example from collection\n", exName); |
| 825 |
char *exCollectionList = LoadFileText(exCollectionFilePath); |
| 826 |
int exIndex = TextFindIndex(exCollectionList, TextFormat("%s;%s", exCategory, exName)); |
| 827 |
if (exIndex > 0) |
| 828 |
{ |
| 829 |
char *exCollectionListUpdated = (char *)RL_CALLOC(REXM_MAX_BUFFER_SIZE, 1); |
| 830 |
|
| 831 |
memcpy(exCollectionListUpdated, exCollectionList, exIndex); |
| 832 |
int lineLen = 0; |
| 833 |
for (int i = exIndex; (exCollectionList[i] != '\n') && (exCollectionList[i] != '\0'); i++) lineLen++; |
| 834 |
|
| 835 |
memcpy(exCollectionListUpdated + exIndex, exCollectionList + exIndex + lineLen + 1, strlen(exCollectionList) - exIndex - lineLen); |
| 836 |
|
| 837 |
SaveFileText(exCollectionFilePath, exCollectionListUpdated); |
| 838 |
RL_FREE(exCollectionListUpdated); |
| 839 |
} |
| 840 |
else LOG("WARNING: REMOVE: Example not found in the collection\n"); |
| 841 |
UnloadFileText(exCollectionList); |
| 842 |
|
| 843 |
|
| 844 |
|
| 845 |
|
| 846 |
|
| 847 |
|
| 848 |
|
| 849 |
|
| 850 |
|
| 851 |
|
| 852 |
|
| 853 |
|
| 854 |
|
| 855 |
|
| 856 |
|
| 857 |
|
| 858 |
|
| 859 |
|
| 860 |
|
| 861 |
|
| 862 |
|
| 863 |
|
| 864 |
|
| 865 |
|
| 866 |
|
| 867 |
|
| 868 |
|
| 869 |
|
| 870 |
|
| 871 |
|
| 872 |
|
| 873 |
|
| 874 |
|
| 875 |
|
| 876 |
|
| 877 |
|
| 878 |
LOG("INFO: [%s] Removing example code file\n", TextFormat("%s.c", exName)); |
| 879 |
FileRemove(TextFormat("%s/%s/%s.c", exBasePath, exCategory, exName)); |
| 880 |
LOG("INFO: [%s] Removing example screenshot file\n", TextFormat("%s.png", exName)); |
| 881 |
FileRemove(TextFormat("%s/%s/%s.png", exBasePath, exCategory, exName)); |
| 882 |
|
| 883 |
|
| 884 |
UpdateRequiredFiles(); |
| 885 |
|
| 886 |
|
| 887 |
LOG("INFO: [%s] Removing example project file\n", TextFormat("%s.vcxproj", exName)); |
| 888 |
FileRemove(TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exName)); |
| 889 |
|
| 890 |
|
| 891 |
LOG("INFO: [%s] Removing example from raylib solution (.sln)\n", exName); |
| 892 |
RemoveVSProjectFromSolution(TextFormat("%s/../projects/VS2022/raylib.sln", exBasePath), exName); |
| 893 |
|
| 894 |
|
| 895 |
FileRemove(TextFormat("%s/%s/%s.html", exBasePath, exCategory, exName)); |
| 896 |
FileRemove(TextFormat("%s/%s/%s.data", exBasePath, exCategory, exName)); |
| 897 |
FileRemove(TextFormat("%s/%s/%s.wasm", exBasePath, exCategory, exName)); |
| 898 |
FileRemove(TextFormat("%s/%s/%s.js", exBasePath, exCategory, exName)); |
| 899 |
|
| 900 |
|
| 901 |
|
| 902 |
|
| 903 |
|
| 904 |
LOG("INFO: [%s] Deleting example from raylib.com\n", exName); |
| 905 |
FileRemove(TextFormat("%s/%s/%s.html", exWebPath, exCategory, exName)); |
| 906 |
FileRemove(TextFormat("%s/%s/%s.data", exWebPath, exCategory, exName)); |
| 907 |
FileRemove(TextFormat("%s/%s/%s.wasm", exWebPath, exCategory, exName)); |
| 908 |
FileRemove(TextFormat("%s/%s/%s.js", exWebPath, exCategory, exName)); |
| 909 |
|
| 910 |
} break; |
| 911 |
case OP_BUILD: |
| 912 |
{ |
| 913 |
LOG("INFO: Command requested: BUILD\n"); |
| 914 |
LOG("INFO: Example(s) to be built: %i [%s]\n", exBuildListCount, (exBuildListCount == 1)? exBuildList[0] : argv[2]); |
| 915 |
|
| 916 |
#if defined(_WIN32) |
| 917 |
|
| 918 |
|
| 919 |
_putenv("PATH=%PATH%;C:\\raylib\\w64devkit\\bin"); |
| 920 |
|
| 921 |
|
| 922 |
#endif |
| 923 |
for (int i = 0; i < exBuildListCount; i++) |
| 924 |
{ |
| 925 |
|
| 926 |
memset(exName, 0, 64); |
| 927 |
strcpy(exName, exBuildList[i]); |
| 928 |
memset(exCategory, 0, 32); |
| 929 |
strncpy(exCategory, exName, TextFindIndex(exName, "_")); |
| 930 |
|
| 931 |
LOG("INFO: [%i/%i] Building example: [%s]\n", i + 1, exBuildListCount, exName); |
| 932 |
|
| 933 |
|
| 934 |
#if defined(_WIN32) |
| 935 |
LOG("INFO: [%s] Building example for PLATFORM_DESKTOP (Host: Win32)\n", exName); |
| 936 |
system(TextFormat("mingw32-make -C %s %s/%s PLATFORM=PLATFORM_DESKTOP -B", exBasePath, exCategory, exName)); |
| 937 |
#elif defined(PLATFORM_DRM) |
| 938 |
LOG("INFO: [%s] Building example for PLATFORM_DRM (Host: POSIX)\n", exName); |
| 939 |
system(TextFormat("make -C %s %s/%s PLATFORM=PLATFORM_DRM -B > %s/%s/logs/%s.build.log 2>&1", |
| 940 |
exBasePath, exCategory, exName, exBasePath, exCategory, exName)); |
| 941 |
#else |
| 942 |
LOG("INFO: [%s] Building example for PLATFORM_DESKTOP (Host: POSIX)\n", exName); |
| 943 |
system(TextFormat("make -C %s %s/%s PLATFORM=PLATFORM_DESKTOP -B", exBasePath, exCategory, exName)); |
| 944 |
#endif |
| 945 |
|
| 946 |
#if !defined(PLATFORM_DRM) |
| 947 |
|
| 948 |
|
| 949 |
|
| 950 |
|
| 951 |
|
| 952 |
#if defined(_WIN32) |
| 953 |
LOG("INFO: [%s] Building example for PLATFORM_WEB (Host: Win32)\n", exName); |
| 954 |
system(TextFormat("mingw32-make -C %s -f Makefile.Web %s/%s PLATFORM=PLATFORM_WEB -B", exBasePath, exCategory, exName)); |
| 955 |
#else |
| 956 |
LOG("INFO: [%s] Building example for PLATFORM_WEB (Host: POSIX)\n", exName); |
| 957 |
system(TextFormat("make -C %s -f Makefile.Web %s/%s PLATFORM=PLATFORM_WEB -B", exBasePath, exCategory, exName)); |
| 958 |
#endif |
| 959 |
|
| 960 |
LOG("INFO: [%s] Updating HTML Metadata...\n", TextFormat("%s.html", exName)); |
| 961 |
UpdateWebMetadata(TextFormat("%s/%s/%s.html", exBasePath, exCategory, exName), |
| 962 |
TextFormat("%s/%s/%s.c", exBasePath, exCategory, exName)); |
| 963 |
|
| 964 |
|
| 965 |
LOG("INFO: [%s] Copy example build to raylib.com\n", exName); |
| 966 |
FileCopy(TextFormat("%s/%s/%s.html", exBasePath, exCategory, exName), |
| 967 |
TextFormat("%s/%s/%s.html", exWebPath, exCategory, exName)); |
| 968 |
FileCopy(TextFormat("%s/%s/%s.data", exBasePath, exCategory, exName), |
| 969 |
TextFormat("%s/%s/%s.data", exWebPath, exCategory, exName)); |
| 970 |
FileCopy(TextFormat("%s/%s/%s.wasm", exBasePath, exCategory, exName), |
| 971 |
TextFormat("%s/%s/%s.wasm", exWebPath, exCategory, exName)); |
| 972 |
FileCopy(TextFormat("%s/%s/%s.js", exBasePath, exCategory, exName), |
| 973 |
TextFormat("%s/%s/%s.js", exWebPath, exCategory, exName)); |
| 974 |
#endif |
| 975 |
|
| 976 |
|
| 977 |
RL_FREE(exBuildList[i]); |
| 978 |
} |
| 979 |
|
| 980 |
} break; |
| 981 |
case OP_VALIDATE: |
| 982 |
case OP_UPDATE: |
| 983 |
{ |
| 984 |
LOG("INFO: Command requested: %s\n", (opCode == OP_VALIDATE)? "VALIDATE" : "UPDATE"); |
| 985 |
LOG("INFO: Example collection is being %s\n", (opCode == OP_VALIDATE)? "validated" : "validated and updated"); |
| 986 |
|
| 987 |
|
| 988 |
|
| 989 |
|
| 990 |
|
| 991 |
|
| 992 |
|
| 993 |
|
| 994 |
|
| 995 |
|
| 996 |
|
| 997 |
|
| 998 |
|
| 999 |
|
| 1000 |
|
| 1001 |
|
| 1002 |
|
| 1003 |
|
| 1004 |
|
| 1005 |
|
| 1006 |
|
| 1007 |
|
| 1008 |
LOG("INFO: Scanning available example (.c) files to be added to collection...\n"); |
| 1009 |
FilePathList clist = LoadDirectoryFilesEx(exBasePath, ".c", true); |
| 1010 |
|
| 1011 |
|
| 1012 |
char *exList = LoadFileText(exCollectionFilePath); |
| 1013 |
int exListLen = (int)strlen(exList); |
| 1014 |
|
| 1015 |
char *exListUpdated = (char *)RL_CALLOC(REXM_MAX_BUFFER_SIZE, 1); |
| 1016 |
bool listUpdated = false; |
| 1017 |
|
| 1018 |
|
| 1019 |
|
| 1020 |
for (unsigned int i = 0; i < clist.count; i++) |
| 1021 |
{ |
| 1022 |
|
| 1023 |
if (!TextIsEqual(GetFileNameWithoutExt(clist.paths[i]), "examples_template") && |
| 1024 |
(TextFindIndex(exList, GetFileNameWithoutExt(clist.paths[i])) == -1)) |
| 1025 |
{ |
| 1026 |
|
| 1027 |
rlExampleInfo *exInfo = LoadExampleInfo(clist.paths[i]); |
| 1028 |
|
| 1029 |
|
| 1030 |
int catIndex = GetTextListIndex(exInfo->category, exCategories, REXM_MAX_EXAMPLE_CATEGORIES); |
| 1031 |
|
| 1032 |
if (catIndex > -1) |
| 1033 |
{ |
| 1034 |
int nextCatIndex = catIndex + 1; |
| 1035 |
if (nextCatIndex > (REXM_MAX_EXAMPLE_CATEGORIES - 1)) nextCatIndex = -1; |
| 1036 |
|
| 1037 |
|
| 1038 |
|
| 1039 |
int exListNextCatIndex = -1; |
| 1040 |
if (nextCatIndex != -1) exListNextCatIndex = TextFindIndex(exList, TextFormat("\n%s", exCategories[nextCatIndex])) + 1; |
| 1041 |
else exListNextCatIndex = exListLen; |
| 1042 |
|
| 1043 |
strncpy(exListUpdated, exList, exListNextCatIndex); |
| 1044 |
|
| 1045 |
|
| 1046 |
char starsText[16] = { 0 }; |
| 1047 |
for (int s = 0; s < 4; s++) |
| 1048 |
{ |
| 1049 |
|
| 1050 |
if (s < exInfo->stars) strcpy(starsText + 3*s, "★"); |
| 1051 |
else strcpy(starsText + 3*s, "☆"); |
| 1052 |
} |
| 1053 |
|
| 1054 |
|
| 1055 |
int exListNewExLen = sprintf(exListUpdated + exListNextCatIndex, |
| 1056 |
TextFormat("%s;%s;%s;%s;%s;%i;%i;\"%s\";@%s\n", |
| 1057 |
exInfo->category, exInfo->name, starsText, exInfo->verCreated, |
| 1058 |
exInfo->verUpdated, exInfo->yearCreated, exInfo->yearReviewed, |
| 1059 |
exInfo->author, exInfo->authorGitHub)); |
| 1060 |
|
| 1061 |
|
| 1062 |
strncpy(exListUpdated + exListNextCatIndex + exListNewExLen, exList + exListNextCatIndex, exListLen - exListNextCatIndex); |
| 1063 |
|
| 1064 |
listUpdated = true; |
| 1065 |
} |
| 1066 |
|
| 1067 |
UnloadExampleInfo(exInfo); |
| 1068 |
} |
| 1069 |
} |
| 1070 |
|
| 1071 |
|
| 1072 |
|
| 1073 |
|
| 1074 |
|
| 1075 |
|
| 1076 |
|
| 1077 |
|
| 1078 |
|
| 1079 |
|
| 1080 |
|
| 1081 |
|
| 1082 |
|
| 1083 |
|
| 1084 |
|
| 1085 |
|
| 1086 |
|
| 1087 |
|
| 1088 |
if (listUpdated) SaveFileText(exCollectionFilePath, exListUpdated); |
| 1089 |
|
| 1090 |
UnloadFileText(exList); |
| 1091 |
RL_FREE(exListUpdated); |
| 1092 |
|
| 1093 |
UnloadDirectoryFiles(clist); |
| 1094 |
|
| 1095 |
|
| 1096 |
|
| 1097 |
LOG("INFO: Validating examples in collection...\n"); |
| 1098 |
int exCollectionCount = 0; |
| 1099 |
rlExampleInfo *exCollection = LoadExampleData("ALL", false, &exCollectionCount); |
| 1100 |
|
| 1101 |
|
| 1102 |
for (int i = 0; i < exCollectionCount; i++) |
| 1103 |
{ |
| 1104 |
rlExampleInfo *exInfo = &exCollection[i]; |
| 1105 |
exInfo->status = 0; |
| 1106 |
|
| 1107 |
LOG("INFO: [%s] Validating example...\n", exInfo->name); |
| 1108 |
|
| 1109 |
|
| 1110 |
if (!FileExists(TextFormat("%s/%s/%s.c", exBasePath, exInfo->category, exInfo->name))) exInfo->status |= VALID_MISSING_C; |
| 1111 |
|
| 1112 |
|
| 1113 |
if (!FileExists(TextFormat("%s/%s/%s.png", exBasePath, exInfo->category, exInfo->name))) exInfo->status |= VALID_MISSING_PNG; |
| 1114 |
|
| 1115 |
|
| 1116 |
Image imScreenshot = LoadImage(TextFormat("%s/%s/%s.png", exBasePath, exInfo->category, exInfo->name)); |
| 1117 |
Image imTemplate = LoadImage(TextFormat("%s/examples_template.png", exBasePath)); |
| 1118 |
if (memcmp(imScreenshot.data, imTemplate.data, GetPixelDataSize(imScreenshot.width, imScreenshot.height, imScreenshot.format)) == 0) |
| 1119 |
exInfo->status |= VALID_INVALID_PNG; |
| 1120 |
UnloadImage(imTemplate); |
| 1121 |
UnloadImage(imScreenshot); |
| 1122 |
|
| 1123 |
|
| 1124 |
if (FileTextFindIndex(TextFormat("%s/Makefile", exBasePath), exInfo->name) == -1) exInfo->status |= VALID_NOT_IN_MAKEFILE; |
| 1125 |
|
| 1126 |
|
| 1127 |
if (FileTextFindIndex(TextFormat("%s/Makefile.Web", exBasePath), exInfo->name) == -1) exInfo->status |= VALID_NOT_IN_MAKEFILE_WEB; |
| 1128 |
|
| 1129 |
|
| 1130 |
if (FileTextFindIndex(TextFormat("%s/README.md", exBasePath), exInfo->name) == -1) exInfo->status |= VALID_NOT_IN_README; |
| 1131 |
|
| 1132 |
|
| 1133 |
if (FileTextFindIndex(TextFormat("%s/../common/examples.js", exWebPath), exInfo->name + TextFindIndex(exInfo->name, "_") + 1) == -1) exInfo->status |= VALID_NOT_IN_JS; |
| 1134 |
|
| 1135 |
|
| 1136 |
if (!FileExists(TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exInfo->name))) exInfo->status |= VALID_MISSING_VCXPROJ; |
| 1137 |
|
| 1138 |
|
| 1139 |
if (FileTextFindIndex(TextFormat("%s/../projects/VS2022/raylib.sln", exBasePath), exInfo->name) == -1) exInfo->status |= VALID_NOT_IN_VCXSOL; |
| 1140 |
|
| 1141 |
|
| 1142 |
|
| 1143 |
|
| 1144 |
char **resPaths = LoadExampleResourcePaths(TextFormat("%s/%s/%s.c", exBasePath, exInfo->category, exInfo->name), &exInfo->resCount); |
| 1145 |
if (exInfo->resCount > 0) |
| 1146 |
{ |
| 1147 |
for (int r = 0; r < exInfo->resCount; r++) |
| 1148 |
{ |
| 1149 |
|
| 1150 |
|
| 1151 |
if (TextFindIndex(resPaths[r], "glsl%i") > -1) |
| 1152 |
{ |
| 1153 |
int glslVer[3] = { 100, 120, 330 }; |
| 1154 |
|
| 1155 |
for (int v = 0; v < 3; v++) |
| 1156 |
{ |
| 1157 |
char *resPathUpdated = TextReplace(resPaths[r], "glsl%i", TextFormat("glsl%i", glslVer[v])); |
| 1158 |
if (!FileExists(TextFormat("%s/%s/%s", exBasePath, exInfo->category, resPathUpdated))) |
| 1159 |
{ |
| 1160 |
exInfo->status |= VALID_MISSING_RESOURCES; |
| 1161 |
|
| 1162 |
LOG("WARNING: [%s] Missing resource: %s\n", exInfo->name, resPathUpdated); |
| 1163 |
} |
| 1164 |
} |
| 1165 |
} |
| 1166 |
else |
| 1167 |
{ |
| 1168 |
if (!FileExists(TextFormat("%s/%s/%s", exBasePath, exInfo->category, resPaths[r]))) |
| 1169 |
{ |
| 1170 |
exInfo->status |= VALID_MISSING_RESOURCES; |
| 1171 |
LOG("WARNING: [%s] Missing resource: %s\n", exInfo->name, resPaths[r]); |
| 1172 |
} |
| 1173 |
} |
| 1174 |
} |
| 1175 |
} |
| 1176 |
UnloadExampleResourcePaths(resPaths); |
| 1177 |
|
| 1178 |
|
| 1179 |
|
| 1180 |
|
| 1181 |
|
| 1182 |
if (!TextIsEqual(exInfo->category, "others") && |
| 1183 |
(!FileExists(TextFormat("%s/%s/%s.html", exWebPath, exInfo->category, exInfo->name)) || |
| 1184 |
!FileExists(TextFormat("%s/%s/%s.wasm", exWebPath, exInfo->category, exInfo->name)) || |
| 1185 |
!FileExists(TextFormat("%s/%s/%s.js", exWebPath, exInfo->category, exInfo->name)) || |
| 1186 |
((exInfo->resCount > 0) && !FileExists(TextFormat("%s/%s/%s.data", exWebPath, exInfo->category, exInfo->name))))) |
| 1187 |
{ |
| 1188 |
exInfo->status |= VALID_MISSING_WEB_OUTPUT; |
| 1189 |
} |
| 1190 |
|
| 1191 |
|
| 1192 |
if (FileExists(TextFormat("%s/%s/%s.html", exWebPath, exInfo->category, exInfo->name))) |
| 1193 |
{ |
| 1194 |
char *exHtmlText = LoadFileText(TextFormat("%s/%s/%s.html", exWebPath, exInfo->category, exInfo->name)); |
| 1195 |
|
| 1196 |
if ((TextFindIndex(exHtmlText, "raylib web game") > -1) || |
| 1197 |
(TextFindIndex(exHtmlText, "New raylib web videogame, developed using raylib videogames library") > -1) || |
| 1198 |
(TextFindIndex(exHtmlText, "https://www.raylib.com/common/raylib_logo.png") > -1) || |
| 1199 |
(TextFindIndex(exHtmlText, "https://www.raylib.com/games.html") > -1) || |
| 1200 |
(TextFindIndex(exHtmlText, "https://github.com/raysan5/raylib';") > -1)) |
| 1201 |
{ |
| 1202 |
exInfo->status |= VALID_MISSING_WEB_METADATA; |
| 1203 |
} |
| 1204 |
|
| 1205 |
UnloadFileText(exHtmlText); |
| 1206 |
} |
| 1207 |
|
| 1208 |
|
| 1209 |
|
| 1210 |
if ((TextFindIndex(exInfo->name, exInfo->category) == -1) || |
| 1211 |
(!TextIsEqual(exInfo->category, "core") && !TextIsEqual(exInfo->category, "shapes") && |
| 1212 |
!TextIsEqual(exInfo->category, "textures") && !TextIsEqual(exInfo->category, "text") && |
| 1213 |
!TextIsEqual(exInfo->category, "models") && !TextIsEqual(exInfo->category, "shaders") && |
| 1214 |
!TextIsEqual(exInfo->category, "audio") && !TextIsEqual(exInfo->category, "others"))) exInfo->status |= VALID_INVALID_CATEGORY; |
| 1215 |
|
| 1216 |
|
| 1217 |
rlExampleInfo *exInfoHeader = LoadExampleInfo(TextFormat("%s/%s/%s.c", exBasePath, exInfo->category, exInfo->name)); |
| 1218 |
|
| 1219 |
if ((strcmp(exInfo->name, exInfoHeader->name) != 0) || |
| 1220 |
(strcmp(exInfo->category, exInfoHeader->category) != 0) || |
| 1221 |
(strcmp(exInfo->author, exInfoHeader->author) != 0) || |
| 1222 |
(strcmp(exInfo->authorGitHub, exInfoHeader->authorGitHub) != 0) || |
| 1223 |
(exInfo->stars != exInfoHeader->stars) || |
| 1224 |
(strcmp(exInfo->verCreated, exInfoHeader->verCreated) != 0) || |
| 1225 |
(strcmp(exInfo->verUpdated, exInfoHeader->verUpdated) != 0)) |
| 1226 |
{ |
| 1227 |
exInfo->status |= VALID_INCONSISTENT_INFO; |
| 1228 |
} |
| 1229 |
|
| 1230 |
if (exInfo->status == 0) LOG("INFO: [%s] Validation result: OK\n", exInfo->name); |
| 1231 |
else LOG("WARNING: [%s] Validation result: ISSUES FOUND\n", exInfo->name); |
| 1232 |
|
| 1233 |
UnloadExampleInfo(exInfoHeader); |
| 1234 |
} |
| 1235 |
|
| 1236 |
if (opCode == OP_UPDATE) |
| 1237 |
{ |
| 1238 |
LOG("INFO: Updating examples with issues in collection...\n"); |
| 1239 |
|
| 1240 |
|
| 1241 |
|
| 1242 |
|
| 1243 |
|
| 1244 |
|
| 1245 |
UpdateRequiredFiles(); |
| 1246 |
for (int i = 0; i < exCollectionCount; i++) |
| 1247 |
{ |
| 1248 |
exCollection[i].status &= ~VALID_NOT_IN_MAKEFILE; |
| 1249 |
exCollection[i].status &= ~VALID_NOT_IN_MAKEFILE_WEB; |
| 1250 |
exCollection[i].status &= ~VALID_NOT_IN_README; |
| 1251 |
exCollection[i].status &= ~VALID_NOT_IN_JS; |
| 1252 |
} |
| 1253 |
|
| 1254 |
|
| 1255 |
for (int i = 0; i < exCollectionCount; i++) |
| 1256 |
{ |
| 1257 |
rlExampleInfo *exInfo = &exCollection[i]; |
| 1258 |
|
| 1259 |
if (exInfo->status & VALID_MISSING_C) LOG("WARNING: [%s] Missing code file\n", exInfo->name); |
| 1260 |
else |
| 1261 |
{ |
| 1262 |
|
| 1263 |
if (exInfo->status & VALID_MISSING_PNG) LOG("WARNING: [%s] Missing screenshot file\n", exInfo->name); |
| 1264 |
if (exInfo->status & VALID_INVALID_PNG) LOG("WARNING: [%s] Invalid screenshot file (using template)\n", exInfo->name); |
| 1265 |
if (exInfo->status & VALID_MISSING_RESOURCES) LOG("WARNING: [%s] Missing resources detected\n", exInfo->name); |
| 1266 |
if (exInfo->status & VALID_INCONSISTENT_INFO) LOG("WARNING: [%s] Inconsistent example header info\n", exInfo->name); |
| 1267 |
if (exInfo->status & VALID_INVALID_CATEGORY) LOG("WARNING: [%s] Invalid example category\n", exInfo->name); |
| 1268 |
|
| 1269 |
|
| 1270 |
|
| 1271 |
if ((strcmp(exInfo->name, "web_basic_window") == 0) || |
| 1272 |
(strcmp(exInfo->name, "raylib_opengl_interop") == 0)) continue; |
| 1273 |
|
| 1274 |
|
| 1275 |
|
| 1276 |
|
| 1277 |
if (exInfo->status & VALID_MISSING_VCXPROJ) |
| 1278 |
{ |
| 1279 |
LOG("WARNING: [%s] Missing VS2022 project file\n", exInfo->name); |
| 1280 |
LOG("INFO: [%s.vcxproj] Creating VS2022 project file\n", exInfo->name); |
| 1281 |
FileCopy(TextFormat("%s/../projects/VS2022/examples/core_basic_window.vcxproj", exBasePath), |
| 1282 |
TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exInfo->name)); |
| 1283 |
FileTextReplace(TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exInfo->name), |
| 1284 |
"core_basic_window", exInfo->name); |
| 1285 |
FileTextReplace(TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exInfo->name), |
| 1286 |
"..\\..\\examples\\core", TextFormat("..\\..\\examples\\%s", exInfo->category)); |
| 1287 |
|
| 1288 |
exInfo->status &= ~VALID_MISSING_VCXPROJ; |
| 1289 |
} |
| 1290 |
|
| 1291 |
|
| 1292 |
if (exInfo->status & VALID_NOT_IN_VCXSOL) |
| 1293 |
{ |
| 1294 |
LOG("WARNING: [%s.vcxproj] Project not included in raylib solution (.sln)\n", exInfo->name); |
| 1295 |
LOG("INFO: [%s.vcxproj] Adding project to raylib solution (.sln)\n", exInfo->name); |
| 1296 |
AddVSProjectToSolution(exVSProjectSolutionFile, |
| 1297 |
TextFormat("%s/../projects/VS2022/examples/%s.vcxproj", exBasePath, exInfo->name), exInfo->category); |
| 1298 |
|
| 1299 |
exInfo->status &= ~VALID_NOT_IN_VCXSOL; |
| 1300 |
} |
| 1301 |
|
| 1302 |
|
| 1303 |
|
| 1304 |
|
| 1305 |
|
| 1306 |
|
| 1307 |
if ((strcmp(exInfo->category, "others") != 0) && |
| 1308 |
((exInfo->status & VALID_MISSING_WEB_OUTPUT) || (exInfo->status & VALID_MISSING_WEB_METADATA))) |
| 1309 |
{ |
| 1310 |
LOG("WARNING: [%s] Example not available on raylib web\n", exInfo->name); |
| 1311 |
|
| 1312 |
|
| 1313 |
#if defined(_WIN32) |
| 1314 |
LOG("INFO: [%s] Building example for PLATFORM_WEB (Host: Win32)\n", exInfo->name); |
| 1315 |
_putenv("PATH=%PATH%;C:\\raylib\\w64devkit\\bin"); |
| 1316 |
system(TextFormat("mingw32-make -C %s -f Makefile.Web %s/%s PLATFORM=PLATFORM_WEB -B", exBasePath, exInfo->category, exInfo->name)); |
| 1317 |
#else |
| 1318 |
LOG("INFO: [%s] Building example for PLATFORM_WEB (Host: POSIX)\n", exInfo->name); |
| 1319 |
system(TextFormat("make -C %s -f Makefile.Web %s/%s PLATFORM=PLATFORM_WEB -B", exBasePath, exInfo->category, exInfo->name)); |
| 1320 |
#endif |
| 1321 |
|
| 1322 |
|
| 1323 |
LOG("INFO: [%s.html] Updating HTML Metadata...\n", exInfo->name); |
| 1324 |
UpdateWebMetadata(TextFormat("%s/%s/%s.html", exBasePath, exInfo->category, exInfo->name), |
| 1325 |
TextFormat("%s/%s/%s.c", exBasePath, exInfo->category, exInfo->name)); |
| 1326 |
|
| 1327 |
|
| 1328 |
LOG("INFO: [%s] Copy example build to raylib.com\n", exInfo->name); |
| 1329 |
FileCopy(TextFormat("%s/%s/%s.html", exBasePath, exInfo->category, exInfo->name), |
| 1330 |
TextFormat("%s/%s/%s.html", exWebPath, exInfo->category, exInfo->name)); |
| 1331 |
FileCopy(TextFormat("%s/%s/%s.data", exBasePath, exInfo->category, exInfo->name), |
| 1332 |
TextFormat("%s/%s/%s.data", exWebPath, exInfo->category, exInfo->name)); |
| 1333 |
FileCopy(TextFormat("%s/%s/%s.wasm", exBasePath, exInfo->category, exInfo->name), |
| 1334 |
TextFormat("%s/%s/%s.wasm", exWebPath, exInfo->category, exInfo->name)); |
| 1335 |
FileCopy(TextFormat("%s/%s/%s.js", exBasePath, exInfo->category, exInfo->name), |
| 1336 |
TextFormat("%s/%s/%s.js", exWebPath, exInfo->category, exInfo->name)); |
| 1337 |
|
| 1338 |
exInfo->status &= ~VALID_MISSING_WEB_OUTPUT; |
| 1339 |
exInfo->status &= ~VALID_MISSING_WEB_METADATA; |
| 1340 |
} |
| 1341 |
|
| 1342 |
if (exInfo->status & VALID_INCONSISTENT_INFO) |
| 1343 |
{ |
| 1344 |
|
| 1345 |
LOG("WARNING: [%s.c] Inconsistent source code metadata\n", exInfo->name); |
| 1346 |
LOG("INFO: [%s.c] Updating source code metadata...\n", exInfo->name); |
| 1347 |
UpdateSourceMetadata(TextFormat("%s/%s/%s.c", exBasePath, exInfo->category, exInfo->name), exInfo); |
| 1348 |
|
| 1349 |
exInfo->status &= ~VALID_INCONSISTENT_INFO; |
| 1350 |
} |
| 1351 |
} |
| 1352 |
} |
| 1353 |
|
| 1354 |
} |
| 1355 |
|
| 1356 |
|
| 1357 |
|
| 1358 |
|
| 1359 |
|
| 1360 |
|
| 1361 |
|
| 1362 |
|
| 1363 |
|
| 1364 |
|
| 1365 |
|
| 1366 |
|
| 1367 |
|
| 1368 |
|
| 1369 |
|
| 1370 |
|
| 1371 |
|
| 1372 |
|
| 1373 |
|
| 1374 |
|
| 1375 |
|
| 1376 |
|
| 1377 |
| ✔ | ✔ | ✔ | |
| 1378 |
| ✔ | ✔ | ✔ | |
| 1379 |
| ✔ | ✔ | ✔ | |
| 1380 |
|
| 1381 |
LOG("INFO: [examples_validation.md] Generating examples validation report...\n"); |
| 1382 |
|
| 1383 |
char *report = (char *)RL_CALLOC(REXM_MAX_BUFFER_SIZE, 1); |
| 1384 |
|
| 1385 |
int repIndex = 0; |
| 1386 |
repIndex += sprintf(report + repIndex, "# EXAMPLES COLLECTION - VALIDATION REPORT\n\n"); |
| 1387 |
|
| 1388 |
repIndex += sprintf(report + repIndex, "```\nExample elements validated:\n\n"); |
| 1389 |
repIndex += sprintf(report + repIndex, " - [C] : Missing .c source file\n"); |
| 1390 |
repIndex += sprintf(report + repIndex, " - [CAT] : Not a recognized category\n"); |
| 1391 |
repIndex += sprintf(report + repIndex, " - [INFO] : Inconsistent example header info (stars, author...)\n"); |
| 1392 |
repIndex += sprintf(report + repIndex, " - [PNG] : Missing screenshot .png\n"); |
| 1393 |
repIndex += sprintf(report + repIndex, " - [WPNG] : Invalid png screenshot (using default one)\n"); |
| 1394 |
repIndex += sprintf(report + repIndex, " - [RES] : Missing resources listed in the code\n"); |
| 1395 |
repIndex += sprintf(report + repIndex, " - [MK] : Not listed in Makefile\n"); |
| 1396 |
repIndex += sprintf(report + repIndex, " - [MKWEB] : Not listed in Makefile.Web\n"); |
| 1397 |
repIndex += sprintf(report + repIndex, " - [VCX] : Missing Visual Studio project file\n"); |
| 1398 |
repIndex += sprintf(report + repIndex, " - [SOL] : Project not included in solution file\n"); |
| 1399 |
repIndex += sprintf(report + repIndex, " - [RDME] : Not listed in README.md\n"); |
| 1400 |
repIndex += sprintf(report + repIndex, " - [JS] : Not listed in Web (examples.js)\n"); |
| 1401 |
repIndex += sprintf(report + repIndex, " - [WOUT] : Missing Web build (.html/.data/.wasm/.js)\n"); |
| 1402 |
repIndex += sprintf(report + repIndex, " - [WMETA] : Missing Web .html example metadata\n```\n"); |
| 1403 |
|
| 1404 |
repIndex += sprintf(report + repIndex, "| **EXAMPLE NAME** | [C] | [CAT]| [INFO]|[PNG]|[WPNG]| [RES]| [MK] |[MKWEB]| [VCX]| [SOL]|[RDME]|[JS] | [WOUT]|[WMETA]|\n"); |
| 1405 |
repIndex += sprintf(report + repIndex, "|:---------------------------------|:---:|:----:|:-----:|:---:|:----:|:----:|:----:|:-----:|:----:|:----:|:----:|:---:|:-----:|:-----:|\n"); |
| 1406 |
|
| 1407 |
for (int i = 0; i < exCollectionCount; i++) |
| 1408 |
{ |
| 1409 |
repIndex += sprintf(report + repIndex, "| %-32s | %s | %s | %s | %s | %s | %s | %s | %s | %s | %s | %s | %s | %s | %s |\n", |
| 1410 |
exCollection[i].name, |
| 1411 |
(exCollection[i].status & VALID_MISSING_C)? "❌" : "✔", |
| 1412 |
(exCollection[i].status & VALID_INVALID_CATEGORY)? "❌" : "✔", |
| 1413 |
(exCollection[i].status & VALID_INCONSISTENT_INFO)? "❌" : "✔", |
| 1414 |
(exCollection[i].status & VALID_MISSING_PNG)? "❌" : "✔", |
| 1415 |
(exCollection[i].status & VALID_INVALID_PNG)? "❌" : "✔", |
| 1416 |
(exCollection[i].status & VALID_MISSING_RESOURCES)? "❌" : "✔", |
| 1417 |
(exCollection[i].status & VALID_NOT_IN_MAKEFILE)? "❌" : "✔", |
| 1418 |
(exCollection[i].status & VALID_NOT_IN_MAKEFILE_WEB)? "❌" : "✔", |
| 1419 |
(exCollection[i].status & VALID_MISSING_VCXPROJ)? "❌" : "✔", |
| 1420 |
(exCollection[i].status & VALID_NOT_IN_VCXSOL)? "❌" : "✔", |
| 1421 |
(exCollection[i].status & VALID_NOT_IN_README)? "❌" : "✔", |
| 1422 |
(exCollection[i].status & VALID_NOT_IN_JS)? "❌" : "✔", |
| 1423 |
(exCollection[i].status & VALID_MISSING_WEB_OUTPUT)? "❌" : "✔", |
| 1424 |
(exCollection[i].status & VALID_MISSING_WEB_METADATA)? "❌" : "✔"); |
| 1425 |
} |
| 1426 |
|
| 1427 |
SaveFileText(TextFormat("%s/../tools/rexm/reports/%s", exBasePath, "examples_validation.md"), report); |
| 1428 |
RL_FREE(report); |
| 1429 |
|
| 1430 |
|
| 1431 |
|
| 1432 |
|
| 1433 |
LOG("INFO: [examples_issues.md] Generating examples issues report...\n"); |
| 1434 |
|
| 1435 |
char *reportIssues = (char *)RL_CALLOC(REXM_MAX_BUFFER_SIZE, 1); |
| 1436 |
|
| 1437 |
repIndex = 0; |
| 1438 |
repIndex += sprintf(reportIssues + repIndex, "# EXAMPLES COLLECTION - VALIDATION REPORT\n\n"); |
| 1439 |
|
| 1440 |
repIndex += sprintf(reportIssues + repIndex, "```\nExample elements validated:\n\n"); |
| 1441 |
repIndex += sprintf(reportIssues + repIndex, " - [C] : Missing .c source file\n"); |
| 1442 |
repIndex += sprintf(reportIssues + repIndex, " - [CAT] : Not a recognized category\n"); |
| 1443 |
repIndex += sprintf(reportIssues + repIndex, " - [INFO] : Inconsistent example header info (stars, author...)\n"); |
| 1444 |
repIndex += sprintf(reportIssues + repIndex, " - [PNG] : Missing screenshot .png\n"); |
| 1445 |
repIndex += sprintf(reportIssues + repIndex, " - [WPNG] : Invalid png screenshot (using default one)\n"); |
| 1446 |
repIndex += sprintf(reportIssues + repIndex, " - [RES] : Missing resources listed in the code\n"); |
| 1447 |
repIndex += sprintf(reportIssues + repIndex, " - [MK] : Not listed in Makefile\n"); |
| 1448 |
repIndex += sprintf(reportIssues + repIndex, " - [MKWEB] : Not listed in Makefile.Web\n"); |
| 1449 |
repIndex += sprintf(reportIssues + repIndex, " - [VCX] : Missing Visual Studio project file\n"); |
| 1450 |
repIndex += sprintf(reportIssues + repIndex, " - [SOL] : Project not included in solution file\n"); |
| 1451 |
repIndex += sprintf(reportIssues + repIndex, " - [RDME] : Not listed in README.md\n"); |
| 1452 |
repIndex += sprintf(reportIssues + repIndex, " - [JS] : Not listed in Web (examples.js)\n"); |
| 1453 |
repIndex += sprintf(reportIssues + repIndex, " - [WOUT] : Missing Web build (.html/.data/.wasm/.js)\n"); |
| 1454 |
repIndex += sprintf(reportIssues + repIndex, " - [WMETA] : Missing Web .html example metadata\n```\n"); |
| 1455 |
|
| 1456 |
repIndex += sprintf(reportIssues + repIndex, "| **EXAMPLE NAME** | [C] | [CAT]| [INFO]|[PNG]|[WPNG]| [RES]| [MK] |[MKWEB]| [VCX]| [SOL]|[RDME]|[JS] | [WOUT]|[WMETA]|\n"); |
| 1457 |
repIndex += sprintf(reportIssues + repIndex, "|:---------------------------------|:---:|:----:|:-----:|:---:|:----:|:----:|:----:|:-----:|:----:|:----:|:----:|:---:|:-----:|:-----:|\n"); |
| 1458 |
|
| 1459 |
for (int i = 0; i < exCollectionCount; i++) |
| 1460 |
{ |
| 1461 |
if (exCollection[i].status > 0) |
| 1462 |
{ |
| 1463 |
repIndex += sprintf(reportIssues + repIndex, "| %-32s | %s | %s | %s | %s | %s | %s | %s | %s | %s | %s | %s | %s | %s | %s |\n", |
| 1464 |
exCollection[i].name, |
| 1465 |
(exCollection[i].status & VALID_MISSING_C)? "❌" : "✔", |
| 1466 |
(exCollection[i].status & VALID_INVALID_CATEGORY)? "❌" : "✔", |
| 1467 |
(exCollection[i].status & VALID_INCONSISTENT_INFO)? "❌" : "✔", |
| 1468 |
(exCollection[i].status & VALID_MISSING_PNG)? "❌" : "✔", |
| 1469 |
(exCollection[i].status & VALID_INVALID_PNG)? "❌" : "✔", |
| 1470 |
(exCollection[i].status & VALID_MISSING_RESOURCES)? "❌" : "✔", |
| 1471 |
(exCollection[i].status & VALID_NOT_IN_MAKEFILE)? "❌" : "✔", |
| 1472 |
(exCollection[i].status & VALID_NOT_IN_MAKEFILE_WEB)? "❌" : "✔", |
| 1473 |
(exCollection[i].status & VALID_MISSING_VCXPROJ)? "❌" : "✔", |
| 1474 |
(exCollection[i].status & VALID_NOT_IN_VCXSOL)? "❌" : "✔", |
| 1475 |
(exCollection[i].status & VALID_NOT_IN_README)? "❌" : "✔", |
| 1476 |
(exCollection[i].status & VALID_NOT_IN_JS)? "❌" : "✔", |
| 1477 |
(exCollection[i].status & VALID_MISSING_WEB_OUTPUT)? "❌" : "✔", |
| 1478 |
(exCollection[i].status & VALID_MISSING_WEB_METADATA)? "❌" : "✔"); |
| 1479 |
} |
| 1480 |
} |
| 1481 |
|
| 1482 |
SaveFileText(TextFormat("%s/../tools/rexm/reports/%s", exBasePath, "examples_issues.md"), reportIssues); |
| 1483 |
RL_FREE(reportIssues); |
| 1484 |
|
| 1485 |
|
| 1486 |
UnloadExampleData(exCollection); |
| 1487 |
|
| 1488 |
|
| 1489 |
} break; |
| 1490 |
case OP_TEST: |
| 1491 |
{ |
| 1492 |
LOG("INFO: Command requested: TEST\n"); |
| 1493 |
LOG("INFO: Example(s) to be build and tested: %i [%s]\n", exBuildListCount, (exBuildListCount == 1)? exBuildList[0] : argv[2]); |
| 1494 |
|
| 1495 |
#if defined(_WIN32) |
| 1496 |
|
| 1497 |
|
| 1498 |
|
| 1499 |
|
| 1500 |
|
| 1501 |
|
| 1502 |
|
| 1503 |
|
| 1504 |
|
| 1505 |
|
| 1506 |
|
| 1507 |
_putenv("PATH=%PATH%;C:\\raylib\\w64devkit\\bin;C:\\raylib\\emsdk\\python\\3.13.3_64bit;C:\\raylib\\emsdk\\node\\22.16.0_64bit\\bin"); |
| 1508 |
#endif |
| 1509 |
|
| 1510 |
for (int i = 0; i < exBuildListCount; i++) |
| 1511 |
{ |
| 1512 |
|
| 1513 |
memset(exName, 0, 64); |
| 1514 |
strcpy(exName, exBuildList[i]); |
| 1515 |
memset(exCategory, 0, 32); |
| 1516 |
strncpy(exCategory, exName, TextFindIndex(exName, "_")); |
| 1517 |
|
| 1518 |
|
| 1519 |
if ((strcmp(exName, "core_custom_logging") == 0) || |
| 1520 |
(strcmp(exName, "core_window_should_close") == 0) || |
| 1521 |
(strcmp(exName, "core_custom_frame_control") == 0)) continue; |
| 1522 |
|
| 1523 |
LOG("INFO: [%i/%i] Testing example: [%s]\n", i + 1, exBuildListCount, exName); |
| 1524 |
|
| 1525 |
|
| 1526 |
MakeDirectory(TextFormat("%s/%s/logs", exBasePath, exCategory)); |
| 1527 |
|
| 1528 |
|
| 1529 |
|
| 1530 |
|
| 1531 |
|
| 1532 |
|
| 1533 |
|
| 1534 |
|
| 1535 |
|
| 1536 |
|
| 1537 |
|
| 1538 |
|
| 1539 |
|
| 1540 |
|
| 1541 |
|
| 1542 |
|
| 1543 |
FileCopy(TextFormat("%s/%s/%s.c", exBasePath, exCategory, exName), |
| 1544 |
TextFormat("%s/%s/%s.original.c", exBasePath, exCategory, exName)); |
| 1545 |
char *srcText = LoadFileText(TextFormat("%s/%s/%s.c", exBasePath, exCategory, exName)); |
| 1546 |
|
| 1547 |
|
| 1548 |
#if defined(BUILD_TESTING_WEB) |
| 1549 |
static const char *mainReplaceText = |
| 1550 |
"#include <stdio.h>\n" |
| 1551 |
"#include <string.h>\n" |
| 1552 |
"#include <stdlib.h>\n" |
| 1553 |
"#include <emscripten/emscripten.h>\n\n" |
| 1554 |
"static char logText[4096] = { 0 };\n" |
| 1555 |
"static int logTextOffset = 0;\n\n" |
| 1556 |
"void CustomTraceLog(int msgType, const char *text, va_list args)\n{\n" |
| 1557 |
" if (logTextOffset < 3800)\n {\n" |
| 1558 |
" switch (msgType)\n {\n" |
| 1559 |
" case LOG_INFO: logTextOffset += sprintf(logText + logTextOffset, \"INFO: \"); break;\n" |
| 1560 |
" case LOG_ERROR: logTextOffset += sprintf(logText + logTextOffset, \"ERROR: \"); break;\n" |
| 1561 |
" case LOG_WARNING: logTextOffset += sprintf(logText + logTextOffset, \"WARNING: \"); break;\n" |
| 1562 |
" case LOG_DEBUG: logTextOffset += sprintf(logText + logTextOffset, \"DEBUG: \"); break;\n" |
| 1563 |
" default: break;\n }\n" |
| 1564 |
" logTextOffset += vsprintf(logText + logTextOffset, text, args);\n" |
| 1565 |
" logTextOffset += sprintf(logText + logTextOffset, \"\\n\");\n}\n}\n\n" |
| 1566 |
"int main(int argc, char *argv[])\n{\n" |
| 1567 |
" SetTraceLogCallback(CustomTraceLog);\n" |
| 1568 |
" int requestedTestFrames = 0;\n" |
| 1569 |
" int testFramesCount = 0;\n" |
| 1570 |
" if ((argc > 1) && (argc == 3) && (strcmp(argv[1], \"--frames\") != 0)) requestedTestFrames = atoi(argv[2]);\n"; |
| 1571 |
|
| 1572 |
static const char *returnReplaceText = |
| 1573 |
" SaveFileText(\"outputLogFileName\", logText);\n" |
| 1574 |
" emscripten_run_script(\"saveFileFromMEMFSToDisk('outputLogFileName','outputLogFileName')\");\n\n" |
| 1575 |
" return 0"; |
| 1576 |
char *returnReplaceTextUpdated = TextReplaceAlloc(returnReplaceText, "outputLogFileName", TextFormat("%s.log", exName)); |
| 1577 |
|
| 1578 |
char *srcTextUpdated[4] = { 0 }; |
| 1579 |
srcTextUpdated[0] = TextReplaceAlloc(srcText, "int main(void)\n{", mainReplaceText); |
| 1580 |
srcTextUpdated[1] = TextReplaceAlloc(srcTextUpdated[0], "WindowShouldClose()", "WindowShouldClose() && (testFramesCount < requestedTestFrames)"); |
| 1581 |
srcTextUpdated[2] = TextReplaceAlloc(srcTextUpdated[1], "EndDrawing();", "EndDrawing(); testFramesCount++;"); |
| 1582 |
srcTextUpdated[3] = TextReplaceAlloc(srcTextUpdated[2], " return 0", returnReplaceTextUpdated); |
| 1583 |
MemFree(returnReplaceTextUpdated); |
| 1584 |
UnloadFileText(srcText); |
| 1585 |
|
| 1586 |
SaveFileText(TextFormat("%s/%s/%s.c", exBasePath, exCategory, exName), srcTextUpdated[3]); |
| 1587 |
for (int i = 0; i < 4; i++) { MemFree(srcTextUpdated[i]); srcTextUpdated[i] = NULL; } |
| 1588 |
|
| 1589 |
|
| 1590 |
|
| 1591 |
|
| 1592 |
|
| 1593 |
|
| 1594 |
#if defined(_WIN32) |
| 1595 |
LOG("INFO: [%s] Building example for PLATFORM_WEB (Host: Win32)\n", exName); |
| 1596 |
system(TextFormat("mingw32-make -C %s -f Makefile.Web %s/%s PLATFORM=PLATFORM_WEB -B > %s/%s/logs/%s.build.log 2>&1", |
| 1597 |
exBasePath, exCategory, exName, exBasePath, exCategory, exName)); |
| 1598 |
#else |
| 1599 |
LOG("INFO: [%s] Building example for PLATFORM_WEB (Host: POSIX)\n", exName); |
| 1600 |
system(TextFormat("make -C %s -f Makefile.Web %s/%s PLATFORM=PLATFORM_WEB -B", exBasePath, exCategory, exName)); |
| 1601 |
#endif |
| 1602 |
|
| 1603 |
FileCopy(TextFormat("%s/%s/%s.original.c", exBasePath, exCategory, exName), |
| 1604 |
TextFormat("%s/%s/%s.c", exBasePath, exCategory, exName)); |
| 1605 |
FileRemove(TextFormat("%s/%s/%s.original.c", exBasePath, exCategory, exName)); |
| 1606 |
|
| 1607 |
|
| 1608 |
if (FileExists(TextFormat("%s/%s/%s.html", exBasePath, exCategory, exName)) && |
| 1609 |
FileExists(TextFormat("%s/%s/%s.wasm", exBasePath, exCategory, exName)) && |
| 1610 |
FileExists(TextFormat("%s/%s/%s.js", exBasePath, exCategory, exName))) |
| 1611 |
{ |
| 1612 |
|
| 1613 |
|
| 1614 |
ChangeDirectory(TextFormat("%s", exBasePath)); |
| 1615 |
if (i == 0) system("start python -m http.server 8080"); |
| 1616 |
system(TextFormat("start explorer \"http:\\localhost:8080/%s/%s.html", exCategory, exName)); |
| 1617 |
} |
| 1618 |
|
| 1619 |
|
| 1620 |
|
| 1621 |
#else |
| 1622 |
|
| 1623 |
static const char *mainReplaceText = |
| 1624 |
"#include <string.h>\n" |
| 1625 |
"#include <stdlib.h>\n" |
| 1626 |
"int main(int argc, char *argv[])\n{\n" |
| 1627 |
" int requestedTestFrames = 0;\n" |
| 1628 |
" int testFramesCount = 0;\n" |
| 1629 |
" if ((argc > 1) && (argc == 3) && (strcmp(argv[1], \"--frames\") != 0)) requestedTestFrames = atoi(argv[2]);\n"; |
| 1630 |
|
| 1631 |
char *srcTextUpdated[3] = { 0 }; |
| 1632 |
srcTextUpdated[0] = TextReplaceAlloc(srcText, "int main(void)\n{", mainReplaceText); |
| 1633 |
srcTextUpdated[1] = TextReplaceAlloc(srcTextUpdated[0], "WindowShouldClose()", "WindowShouldClose() && (testFramesCount < requestedTestFrames)"); |
| 1634 |
srcTextUpdated[2] = TextReplaceAlloc(srcTextUpdated[1], "EndDrawing();", "EndDrawing(); testFramesCount++;"); |
| 1635 |
UnloadFileText(srcText); |
| 1636 |
|
| 1637 |
SaveFileText(TextFormat("%s/%s/%s.c", exBasePath, exCategory, exName), srcTextUpdated[2]); |
| 1638 |
for (int i = 0; i < 3; i++) { MemFree(srcTextUpdated[i]); srcTextUpdated[i] = NULL; } |
| 1639 |
|
| 1640 |
|
| 1641 |
#if defined(_WIN32) |
| 1642 |
|
| 1643 |
|
| 1644 |
_putenv("PATH=%PATH%;C:\\raylib\\w64devkit\\bin"); |
| 1645 |
|
| 1646 |
|
| 1647 |
#endif |
| 1648 |
|
| 1649 |
#if defined(_WIN32) |
| 1650 |
LOG("INFO: [%s] Building example for PLATFORM_DESKTOP (Host: Win32)\n", exName); |
| 1651 |
system(TextFormat("mingw32-make -C %s %s/%s PLATFORM=PLATFORM_DESKTOP -B > %s/%s/logs/%s.build.log 2>&1", |
| 1652 |
exBasePath, exCategory, exName, exBasePath, exCategory, exName)); |
| 1653 |
#elif defined(PLATFORM_DRM) |
| 1654 |
LOG("INFO: [%s] Building example for PLATFORM_DRM (Host: POSIX)\n", exName); |
| 1655 |
system(TextFormat("make -C %s %s/%s PLATFORM=PLATFORM_DRM -B > %s/%s/logs/%s.build.log 2>&1", |
| 1656 |
exBasePath, exCategory, exName, exBasePath, exCategory, exName)); |
| 1657 |
#else |
| 1658 |
LOG("INFO: [%s] Building example for PLATFORM_DESKTOP (Host: POSIX)\n", exName); |
| 1659 |
system(TextFormat("make -C %s %s/%s PLATFORM=PLATFORM_DESKTOP -B > %s/%s/logs/%s.build.log 2>&1", |
| 1660 |
exBasePath, exCategory, exName, exBasePath, exCategory, exName)); |
| 1661 |
#endif |
| 1662 |
|
| 1663 |
FileCopy(TextFormat("%s/%s/%s.original.c", exBasePath, exCategory, exName), |
| 1664 |
TextFormat("%s/%s/%s.c", exBasePath, exCategory, exName)); |
| 1665 |
FileRemove(TextFormat("%s/%s/%s.original.c", exBasePath, exCategory, exName)); |
| 1666 |
|
| 1667 |
|
| 1668 |
|
| 1669 |
ChangeDirectory(TextFormat("%s/%s", exBasePath, exCategory)); |
| 1670 |
|
| 1671 |
#if defined(_WIN32) |
| 1672 |
system(TextFormat("%s --frames 2 > logs/%s.log", exName, exName)); |
| 1673 |
#else |
| 1674 |
system(TextFormat("./%s --frames 2 > logs/%s.log", exName, exName)); |
| 1675 |
#endif |
| 1676 |
#endif |
| 1677 |
} |
| 1678 |
} break; |
| 1679 |
case OP_TESTLOG: |
| 1680 |
{ |
| 1681 |
|
| 1682 |
|
| 1683 |
rlExampleTesting *testing = (rlExampleTesting *)RL_CALLOC(exBuildListCount, sizeof(rlExampleTesting)); |
| 1684 |
|
| 1685 |
for (int i = 0; i < exBuildListCount; i++) |
| 1686 |
{ |
| 1687 |
|
| 1688 |
memset(exName, 0, 64); |
| 1689 |
strcpy(exName, exBuildList[i]); |
| 1690 |
memset(exCategory, 0, 32); |
| 1691 |
strncpy(exCategory, exName, TextFindIndex(exName, "_")); |
| 1692 |
|
| 1693 |
|
| 1694 |
if ((strcmp(exName, "core_custom_logging") == 0) || |
| 1695 |
(strcmp(exName, "core_window_should_close") == 0) || |
| 1696 |
(strcmp(exName, "core_custom_frame_control") == 0)) continue; |
| 1697 |
|
| 1698 |
LOG("INFO: [%i/%i] Checking example log: [%s]\n", i + 1, exBuildListCount, exName); |
| 1699 |
|
| 1700 |
|
| 1701 |
char *exTestBuildLog = LoadFileText(TextFormat("%s/%s/logs/%s.build.log", exBasePath, exCategory, exName)); |
| 1702 |
if (exTestBuildLog == NULL) |
| 1703 |
{ |
| 1704 |
LOG("WARNING: [%s] Build log could not be loaded\n", exName); |
| 1705 |
continue; |
| 1706 |
} |
| 1707 |
|
| 1708 |
|
| 1709 |
int exTestBuildLogLinesCount = 0; |
| 1710 |
char **exTestBuildLogLines = LoadTextLines(exTestBuildLog, &exTestBuildLogLinesCount); |
| 1711 |
|
| 1712 |
for (int k = 0; k < exTestBuildLogLinesCount; k++) |
| 1713 |
{ |
| 1714 |
|
| 1715 |
if (TextFindIndex(exTestBuildLogLines[k], "warning:") >= 0) testing[i].buildwarns++; |
| 1716 |
} |
| 1717 |
|
| 1718 |
UnloadTextLines(exTestBuildLogLines, exTestBuildLogLinesCount); |
| 1719 |
UnloadFileText(exTestBuildLog); |
| 1720 |
|
| 1721 |
#if defined(BUILD_TESTING_WEB) |
| 1722 |
|
| 1723 |
char *exTestLog = LoadFileText(TextFormat("D:/testing_logs_web/%s.log", exName)); |
| 1724 |
#else |
| 1725 |
char *exTestLog = LoadFileText(TextFormat("%s/%s/logs/%s.log", exBasePath, exCategory, exName)); |
| 1726 |
#endif |
| 1727 |
if (exTestLog == NULL) |
| 1728 |
{ |
| 1729 |
LOG("WARNING: [%s] Execution log could not be loaded\n", exName); |
| 1730 |
testing[i].status = 0b1111111; |
| 1731 |
continue; |
| 1732 |
} |
| 1733 |
|
| 1734 |
|
| 1735 |
|
| 1736 |
|
| 1737 |
|
| 1738 |
|
| 1739 |
|
| 1740 |
|
| 1741 |
|
| 1742 |
|
| 1743 |
|
| 1744 |
if (TextFindIndex(exTestLog, "INFO: DISPLAY: Device initialized successfully") == -1) testing[i].status |= TESTING_FAIL_INIT; |
| 1745 |
if (TextFindIndex(exTestLog, "INFO: Window closed successfully") == -1) testing[i].status |= TESTING_FAIL_CLOSE; |
| 1746 |
if (TextFindIndex(exTestLog, "WARNING: FILEIO:") >= 0) testing[i].status |= TESTING_FAIL_ASSETS; |
| 1747 |
if (TextFindIndex(exTestLog, "INFO: RLGL: Default OpenGL state initialized successfully") == -1) testing[i].status |= TESTING_FAIL_RLGL; |
| 1748 |
if (TextFindIndex(exTestLog, "INFO: PLATFORM:") == -1) testing[i].status |= TESTING_FAIL_PLATFORM; |
| 1749 |
if (TextFindIndex(exTestLog, "INFO: FONT: Default font loaded successfully") == -1) testing[i].status |= TESTING_FAIL_FONT; |
| 1750 |
if (TextFindIndex(exTestLog, "INFO: TIMER: Target time per frame:") == -1) testing[i].status |= TESTING_FAIL_TIMER; |
| 1751 |
|
| 1752 |
|
| 1753 |
int exTestLogLinesCount = 0; |
| 1754 |
char **exTestLogLines = LoadTextLines(exTestLog, &exTestLogLinesCount); |
| 1755 |
for (int k = 0; k < exTestLogLinesCount; k++) |
| 1756 |
{ |
| 1757 |
#if defined(BUILD_TESTING_WEB) |
| 1758 |
if (TextFindIndex(exTestLogLines[k], "WARNING: GL: NPOT") >= 0) continue; |
| 1759 |
#endif |
| 1760 |
#if defined(PLATFORM_DRM) |
| 1761 |
if (TextFindIndex(exTestLogLines[k], "WARNING: DISPLAY: No graphic") >= 0) continue; |
| 1762 |
if (TextFindIndex(exTestLogLines[k], "WARNING: GetCurrentMonitor()") >= 0) continue; |
| 1763 |
if (TextFindIndex(exTestLogLines[k], "WARNING: SetWindowPosition()") >= 0) continue; |
| 1764 |
#endif |
| 1765 |
if (TextFindIndex(exTestLogLines[k], "WARNING") >= 0) testing[i].warnings++; |
| 1766 |
} |
| 1767 |
UnloadTextLines(exTestLogLines, exTestLogLinesCount); |
| 1768 |
UnloadFileText(exTestLog); |
| 1769 |
} |
| 1770 |
|
| 1771 |
|
| 1772 |
|
| 1773 |
|
| 1774 |
#if defined(BUILD_TESTING_WEB) |
| 1775 |
const char *osName = "Web"; |
| 1776 |
#else |
| 1777 |
#if defined(PLATFORM_DRM) |
| 1778 |
const char *osName = "DRM"; |
| 1779 |
#elif defined(PLATFORM_DESKTOP) |
| 1780 |
#if defined(_WIN32) |
| 1781 |
const char *osName = "Windows"; |
| 1782 |
#elif defined(__linux__) |
| 1783 |
const char *osName = "Linux"; |
| 1784 |
#elif defined(__FreeBSD__) |
| 1785 |
const char *osName = "FreeBSD"; |
| 1786 |
#elif defined(__APPLE__) |
| 1787 |
const char *osName = "macOS"; |
| 1788 |
#endif |
| 1789 |
#endif |
| 1790 |
#endif |
| 1791 |
|
| 1792 |
|
| 1793 |
|
| 1794 |
|
| 1795 |
|
| 1796 |
|
| 1797 |
|
| 1798 |
|
| 1799 |
|
| 1800 |
|
| 1801 |
|
| 1802 |
|
| 1803 |
|
| 1804 |
|
| 1805 |
| ✔ | |
| 1806 |
|
| 1807 |
LOG("INFO: [examples_testing_os.md] Generating examples testing report...\n"); |
| 1808 |
|
| 1809 |
char *report = (char *)RL_CALLOC(REXM_MAX_BUFFER_SIZE, 1); |
| 1810 |
|
| 1811 |
int repIndex = 0; |
| 1812 |
repIndex += sprintf(report + repIndex, "# EXAMPLES COLLECTION - TESTING REPORT\n\n"); |
| 1813 |
repIndex += sprintf(report + repIndex, TextFormat("## Tested Platform: %s\n\n", osName)); |
| 1814 |
|
| 1815 |
repIndex += sprintf(report + repIndex, "```\nExample automated testing elements validated:\n"); |
| 1816 |
repIndex += sprintf(report + repIndex, " - [CWARN] : Compilation WARNING messages\n"); |
| 1817 |
repIndex += sprintf(report + repIndex, " - [LWARN] : Log WARNING messages count\n"); |
| 1818 |
repIndex += sprintf(report + repIndex, " - [INIT] : Initialization\n"); |
| 1819 |
repIndex += sprintf(report + repIndex, " - [CLOSE] : Closing\n"); |
| 1820 |
repIndex += sprintf(report + repIndex, " - [ASSETS] : Assets loading\n"); |
| 1821 |
repIndex += sprintf(report + repIndex, " - [RLGL] : OpenGL-wrapped initialization\n"); |
| 1822 |
repIndex += sprintf(report + repIndex, " - [PLAT] : Platform initialization\n"); |
| 1823 |
repIndex += sprintf(report + repIndex, " - [FONT] : Font default initialization\n"); |
| 1824 |
repIndex += sprintf(report + repIndex, " - [TIMER] : Timer initialization\n```\n"); |
| 1825 |
|
| 1826 |
repIndex += sprintf(report + repIndex, "| **EXAMPLE NAME** | [CWARN] | [LWARN] | [INIT] | [CLOSE] | [ASSETS] | [RLGL] | [PLAT] | [FONT] | [TIMER] |\n"); |
| 1827 |
repIndex += sprintf(report + repIndex, "|:---------------------------------|:-------:|:-------:|:------:|:-------:|:--------:|:------:|:------:|:------:|:-------:|\n"); |
| 1828 |
|
| 1829 |
|
| 1830 |
|
| 1831 |
|
| 1832 |
|
| 1833 |
|
| 1834 |
|
| 1835 |
|
| 1836 |
|
| 1837 |
|
| 1838 |
for (int i = 0; i < exBuildListCount; i++) |
| 1839 |
{ |
| 1840 |
if ((testing[i].buildwarns > 0) || (testing[i].warnings > 0) || (testing[i].status > 0)) |
| 1841 |
{ |
| 1842 |
repIndex += sprintf(report + repIndex, "| %-32s | %i | %i | %s | %s | %s | %s | %s | %s | %s |\n", |
| 1843 |
exBuildList[i], |
| 1844 |
testing[i].buildwarns, |
| 1845 |
testing[i].warnings, |
| 1846 |
(testing[i].status & TESTING_FAIL_INIT)? "❌" : "✔", |
| 1847 |
(testing[i].status & TESTING_FAIL_CLOSE)? "❌" : "✔", |
| 1848 |
(testing[i].status & TESTING_FAIL_ASSETS)? "❌" : "✔", |
| 1849 |
(testing[i].status & TESTING_FAIL_RLGL)? "❌" : "✔", |
| 1850 |
(testing[i].status & TESTING_FAIL_PLATFORM)? "❌" : "✔", |
| 1851 |
(testing[i].status & TESTING_FAIL_FONT)? "❌" : "✔", |
| 1852 |
(testing[i].status & TESTING_FAIL_TIMER)? "❌" : "✔"); |
| 1853 |
} |
| 1854 |
} |
| 1855 |
|
| 1856 |
repIndex += sprintf(report + repIndex, "\n"); |
| 1857 |
|
| 1858 |
SaveFileText(TextFormat("%s/../tools/rexm/reports/examples_testing_%s.md", exBasePath, TextToLower(osName)), report); |
| 1859 |
|
| 1860 |
RL_FREE(report); |
| 1861 |
|
| 1862 |
|
| 1863 |
} break; |
| 1864 |
default: |
| 1865 |
{ |
| 1866 |
|
| 1867 |
|
| 1868 |
|
| 1869 |
|
| 1870 |
|
| 1871 |
|
| 1872 |
|
| 1873 |
|
| 1874 |
|
| 1875 |
printf("\n////////////////////////////////////////////////////////////////////////////////////////////\n"); |
| 1876 |
printf("// //\n"); |
| 1877 |
printf("// rexm [raylib examples manager] - A simple command-line tool to manage raylib examples //\n"); |
| 1878 |
printf("// powered by raylib v6.0 //\n"); |
| 1879 |
printf("// //\n"); |
| 1880 |
printf("// Copyright (c) 2025-2026 Ramon Santamaria (@raysan5) //\n"); |
| 1881 |
printf("// //\n"); |
| 1882 |
printf("////////////////////////////////////////////////////////////////////////////////////////////\n\n"); |
| 1883 |
|
| 1884 |
printf("USAGE:\n\n"); |
| 1885 |
printf(" > rexm <command> <example_name> [<example_rename>]\n\n"); |
| 1886 |
|
| 1887 |
printf("COMMANDS:\n\n"); |
| 1888 |
printf(" create <new_example_name> : Creates an empty example, from internal template\n"); |
| 1889 |
printf(" add <example_name> : Add existing example, category extracted from name\n"); |
| 1890 |
printf(" Supported categories: core, shapes, textures, text, models\n"); |
| 1891 |
printf(" rename <old_examples_name> <new_example_name> : Rename an existing example\n"); |
| 1892 |
printf(" remove <example_name> : Remove an existing example\n"); |
| 1893 |
printf(" build <example_name> : Build example for Desktop and Web platforms\n"); |
| 1894 |
printf(" test <example_name> : Build and Test example for Desktop and Web platforms\n"); |
| 1895 |
printf(" validate : Validate examples collection, generates report\n"); |
| 1896 |
printf(" update : Validate and update examples collection, generates report\n\n"); |
| 1897 |
printf("OPTIONS:\n\n"); |
| 1898 |
printf(" -h, --help : Show tool version and command line usage help\n"); |
| 1899 |
printf(" -v, --verbose : Verbose mode, show additional logs on processes\n"); |
| 1900 |
printf("\nEXAMPLES:\n\n"); |
| 1901 |
printf(" > rexm add shapes_custom_stars\n"); |
| 1902 |
printf(" Add and updates new example provided <shapes_custom_stars>\n\n"); |
| 1903 |
printf(" > rexm rename core_basic_window core_cool_window\n"); |
| 1904 |
printf(" Renames and updates example <core_basic_window> to <core_cool_window>\n\n"); |
| 1905 |
printf(" > rexm update\n"); |
| 1906 |
printf(" Validates all examples in collection and updates missing elements\n\n"); |
| 1907 |
} break; |
| 1908 |
} |
| 1909 |
|
| 1910 |
return 0; |
| 1911 |
} |
| 1912 |
|
| 1913 |
|
| 1914 |
|
| 1915 |
|
| 1916 |
|
| 1917 |
static int UpdateRequiredFiles(void) |
| 1918 |
{ |
| 1919 |
int result = 0; |
| 1920 |
|
| 1921 |
|
| 1922 |
|
| 1923 |
LOG("INFO: Updating all examples metadata...\n"); |
| 1924 |
int exListCount = 0; |
| 1925 |
rlExampleInfo *exList = LoadExampleData("ALL", true, &exListCount); |
| 1926 |
for (int i = 0; i < exListCount; i++) |
| 1927 |
{ |
| 1928 |
rlExampleInfo *info = &exList[i]; |
| 1929 |
UpdateSourceMetadata(TextFormat("%s/%s/%s.c", exBasePath, info->category, info->name), info); |
| 1930 |
} |
| 1931 |
UnloadExampleData(exList); |
| 1932 |
|
| 1933 |
|
| 1934 |
|
| 1935 |
|
| 1936 |
LOG("INFO: Updating raylib/examples/Makefile\n"); |
| 1937 |
char *mkText = LoadFileText(TextFormat("%s/Makefile", exBasePath)); |
| 1938 |
char *mkTextUpdated = (char *)RL_CALLOC(REXM_MAX_BUFFER_SIZE, 1); |
| 1939 |
|
| 1940 |
int mkListStartIndex = TextFindIndex(mkText, "#EXAMPLES_LIST_START"); |
| 1941 |
int mkListEndIndex = TextFindIndex(mkText, "#EXAMPLES_LIST_END"); |
| 1942 |
|
| 1943 |
int mkIndex = 0; |
| 1944 |
memcpy(mkTextUpdated, mkText, mkListStartIndex); |
| 1945 |
mkIndex = sprintf(mkTextUpdated + mkListStartIndex, "#EXAMPLES_LIST_START\n"); |
| 1946 |
|
| 1947 |
for (int i = 0; i < REXM_MAX_EXAMPLE_CATEGORIES; i++) |
| 1948 |
{ |
| 1949 |
mkIndex += sprintf(mkTextUpdated + mkListStartIndex + mkIndex, TextFormat("%s = \\\n", TextToUpper(exCategories[i]))); |
| 1950 |
|
| 1951 |
int exCollectionCount = 0; |
| 1952 |
rlExampleInfo *exCollection = LoadExampleData(exCategories[i], true, &exCollectionCount); |
| 1953 |
|
| 1954 |
for (int x = 0; x < exCollectionCount - 1; x++) mkIndex += sprintf(mkTextUpdated + mkListStartIndex + mkIndex, TextFormat(" %s/%s \\\n", exCollection[x].category, exCollection[x].name)); |
| 1955 |
mkIndex += sprintf(mkTextUpdated + mkListStartIndex + mkIndex, TextFormat(" %s/%s\n\n", exCollection[exCollectionCount - 1].category, exCollection[exCollectionCount - 1].name)); |
| 1956 |
|
| 1957 |
UnloadExampleData(exCollection); |
| 1958 |
} |
| 1959 |
|
| 1960 |
|
| 1961 |
memcpy(mkTextUpdated + mkListStartIndex + mkIndex - 1, mkText + mkListEndIndex, strlen(mkText) - mkListEndIndex); |
| 1962 |
|
| 1963 |
|
| 1964 |
SaveFileText(TextFormat("%s/Makefile", exBasePath), mkTextUpdated); |
| 1965 |
UnloadFileText(mkText); |
| 1966 |
RL_FREE(mkTextUpdated); |
| 1967 |
|
| 1968 |
|
| 1969 |
|
| 1970 |
|
| 1971 |
LOG("INFO: Updating raylib/examples/Makefile.Web\n"); |
| 1972 |
char *mkwText = LoadFileText(TextFormat("%s/Makefile.Web", exBasePath)); |
| 1973 |
char *mkwTextUpdated = (char *)RL_CALLOC(REXM_MAX_BUFFER_SIZE, 1); |
| 1974 |
|
| 1975 |
int mkwListStartIndex = TextFindIndex(mkwText, "#EXAMPLES_LIST_START"); |
| 1976 |
int mkwListEndIndex = TextFindIndex(mkwText, "#EXAMPLES_LIST_END"); |
| 1977 |
|
| 1978 |
int mkwIndex = 0; |
| 1979 |
memcpy(mkwTextUpdated, mkwText, mkwListStartIndex); |
| 1980 |
mkwIndex = sprintf(mkwTextUpdated + mkwListStartIndex, "#EXAMPLES_LIST_START\n"); |
| 1981 |
|
| 1982 |
for (int i = 0; i < REXM_MAX_EXAMPLE_CATEGORIES; i++) |
| 1983 |
{ |
| 1984 |
mkwIndex += sprintf(mkwTextUpdated + mkwListStartIndex + mkwIndex, TextFormat("%s = \\\n", TextToUpper(exCategories[i]))); |
| 1985 |
|
| 1986 |
int exCollectionCount = 0; |
| 1987 |
rlExampleInfo *exCollection = LoadExampleData(exCategories[i], true, &exCollectionCount); |
| 1988 |
|
| 1989 |
for (int x = 0; x < exCollectionCount - 1; x++) mkwIndex += sprintf(mkwTextUpdated + mkwListStartIndex + mkwIndex, TextFormat(" %s/%s \\\n", exCollection[x].category, exCollection[x].name)); |
| 1990 |
mkwIndex += sprintf(mkwTextUpdated + mkwListStartIndex + mkwIndex, TextFormat(" %s/%s\n\n", exCollection[exCollectionCount - 1].category, exCollection[exCollectionCount - 1].name)); |
| 1991 |
|
| 1992 |
UnloadExampleData(exCollection); |
| 1993 |
} |
| 1994 |
|
| 1995 |
|
| 1996 |
|
| 1997 |
mkwIndex += sprintf(mkwTextUpdated + mkwListStartIndex + mkwIndex, "# Default target entry\n"); |
| 1998 |
mkwIndex += sprintf(mkwTextUpdated + mkwListStartIndex + mkwIndex, "all: $(CORE) $(SHAPES) $(TEXT) $(TEXTURES) $(MODELS) $(SHADERS) $(AUDIO)\n\n"); |
| 1999 |
mkwIndex += sprintf(mkwTextUpdated + mkwListStartIndex + mkwIndex, "core: $(CORE)\n"); |
| 2000 |
mkwIndex += sprintf(mkwTextUpdated + mkwListStartIndex + mkwIndex, "shapes: $(SHAPES)\n"); |
| 2001 |
mkwIndex += sprintf(mkwTextUpdated + mkwListStartIndex + mkwIndex, "textures: $(TEXTURES)\n"); |
| 2002 |
mkwIndex += sprintf(mkwTextUpdated + mkwListStartIndex + mkwIndex, "text: $(TEXT)\n"); |
| 2003 |
mkwIndex += sprintf(mkwTextUpdated + mkwListStartIndex + mkwIndex, "models: $(MODELS)\n"); |
| 2004 |
mkwIndex += sprintf(mkwTextUpdated + mkwListStartIndex + mkwIndex, "shaders: $(SHADERS)\n"); |
| 2005 |
mkwIndex += sprintf(mkwTextUpdated + mkwListStartIndex + mkwIndex, "audio: $(AUDIO)\n\n"); |
| 2006 |
|
| 2007 |
for (int i = 0; i < REXM_MAX_EXAMPLE_CATEGORIES; i++) |
| 2008 |
{ |
| 2009 |
mkwIndex += sprintf(mkwTextUpdated + mkwListStartIndex + mkwIndex, TextFormat("# Compile %s examples\n", TextToUpper(exCategories[i]))); |
| 2010 |
|
| 2011 |
int exCollectionCount = 0; |
| 2012 |
rlExampleInfo *exCollection = LoadExampleData(exCategories[i], true, &exCollectionCount); |
| 2013 |
|
| 2014 |
for (int x = 0; x < exCollectionCount; x++) |
| 2015 |
{ |
| 2016 |
|
| 2017 |
int resPathCount = 0; |
| 2018 |
char **resPaths = LoadExampleResourcePaths(TextFormat("%s/%s/%s.c", exBasePath, exCollection[x].category, exCollection[x].name), &resPathCount); |
| 2019 |
|
| 2020 |
if (resPathCount > 0) |
| 2021 |
{ |
| 2022 |
|
| 2023 |
|
| 2024 |
|
| 2025 |
|
| 2026 |
|
| 2027 |
|
| 2028 |
|
| 2029 |
|
| 2030 |
|
| 2031 |
mkwIndex += sprintf(mkwTextUpdated + mkwListStartIndex + mkwIndex, |
| 2032 |
TextFormat("%s/%s: %s/%s.c\n", exCollection[x].category, exCollection[x].name, exCollection[x].category, exCollection[x].name)); |
| 2033 |
mkwIndex += sprintf(mkwTextUpdated + mkwListStartIndex + mkwIndex, " $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \\\n"); |
| 2034 |
|
| 2035 |
for (int r = 0; r < resPathCount; r++) |
| 2036 |
{ |
| 2037 |
|
| 2038 |
|
| 2039 |
if (TextFindIndex(resPaths[r], "glsl%i") > -1) |
| 2040 |
{ |
| 2041 |
char *resPathUpdated = TextReplaceAlloc(resPaths[r], "glsl%i", "glsl100"); |
| 2042 |
memset(resPaths[r], 0, 256); |
| 2043 |
strcpy(resPaths[r], resPathUpdated); |
| 2044 |
RL_FREE(resPathUpdated); |
| 2045 |
} |
| 2046 |
|
| 2047 |
if (r < (resPathCount - 1)) |
| 2048 |
{ |
| 2049 |
mkwIndex += sprintf(mkwTextUpdated + mkwListStartIndex + mkwIndex, |
| 2050 |
TextFormat(" --preload-file %s/%s@%s \\\n", exCollection[x].category, resPaths[r], resPaths[r])); |
| 2051 |
} |
| 2052 |
else |
| 2053 |
{ |
| 2054 |
mkwIndex += sprintf(mkwTextUpdated + mkwListStartIndex + mkwIndex, |
| 2055 |
TextFormat(" --preload-file %s/%s@%s\n\n", exCollection[x].category, resPaths[r], resPaths[r])); |
| 2056 |
} |
| 2057 |
} |
| 2058 |
} |
| 2059 |
else |
| 2060 |
{ |
| 2061 |
|
| 2062 |
|
| 2063 |
|
| 2064 |
|
| 2065 |
|
| 2066 |
mkwIndex += sprintf(mkwTextUpdated + mkwListStartIndex + mkwIndex, |
| 2067 |
TextFormat("%s/%s: %s/%s.c\n", exCollection[x].category, exCollection[x].name, exCollection[x].category, exCollection[x].name)); |
| 2068 |
mkwIndex += sprintf(mkwTextUpdated + mkwListStartIndex + mkwIndex, " $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)\n\n"); |
| 2069 |
} |
| 2070 |
|
| 2071 |
UnloadExampleResourcePaths(resPaths); |
| 2072 |
} |
| 2073 |
|
| 2074 |
UnloadExampleData(exCollection); |
| 2075 |
} |
| 2076 |
|
| 2077 |
|
| 2078 |
memcpy(mkwTextUpdated + mkwListStartIndex + mkwIndex - 1, mkwText + mkwListEndIndex, strlen(mkwText) - mkwListEndIndex); |
| 2079 |
|
| 2080 |
|
| 2081 |
SaveFileText(TextFormat("%s/Makefile.Web", exBasePath), mkwTextUpdated); |
| 2082 |
UnloadFileText(mkwText); |
| 2083 |
RL_FREE(mkwTextUpdated); |
| 2084 |
|
| 2085 |
|
| 2086 |
|
| 2087 |
|
| 2088 |
LOG("INFO: Updating raylib/examples/README.md\n"); |
| 2089 |
|
| 2090 |
raysan5) | |
| 2091 |
char *mdText = LoadFileText(TextFormat("%s/README.md", exBasePath)); |
| 2092 |
char *mdTextUpdated = (char *)RL_CALLOC(REXM_MAX_BUFFER_SIZE, 1); |
| 2093 |
|
| 2094 |
int mdListStartIndex = TextFindIndex(mdText, "## EXAMPLES COLLECTION"); |
| 2095 |
|
| 2096 |
int mdIndex = 0; |
| 2097 |
memcpy(mdTextUpdated, mdText, mdListStartIndex); |
| 2098 |
|
| 2099 |
int exCollectionFullCount = 0; |
| 2100 |
rlExampleInfo *exCollectionFull = LoadExampleData("ALL", false, &exCollectionFullCount); |
| 2101 |
UnloadExampleData(exCollectionFull); |
| 2102 |
|
| 2103 |
mdIndex += sprintf(mdTextUpdated + mdListStartIndex + mdIndex, TextFormat("## EXAMPLES COLLECTION [TOTAL: %i]\n", exCollectionFullCount)); |
| 2104 |
|
| 2105 |
|
| 2106 |
for (int i = 0; i < REXM_MAX_EXAMPLE_CATEGORIES; i++) |
| 2107 |
{ |
| 2108 |
int exCollectionCount = 0; |
| 2109 |
rlExampleInfo *exCollection = LoadExampleData(exCategories[i], false, &exCollectionCount); |
| 2110 |
|
| 2111 |
|
| 2112 |
if (i == 0) |
| 2113 |
{ |
| 2114 |
mdIndex += sprintf(mdTextUpdated + mdListStartIndex + mdIndex, TextFormat("\n### category: core [%i]\n\n", exCollectionCount)); |
| 2115 |
mdIndex += sprintf(mdTextUpdated + mdListStartIndex + mdIndex, |
| 2116 |
"Examples using raylib [core](../src/rcore.c) module platform functionality: window creation, inputs, drawing modes and system functionality.\n\n"); |
| 2117 |
} |
| 2118 |
else if (i == 1) |
| 2119 |
{ |
| 2120 |
mdIndex += sprintf(mdTextUpdated + mdListStartIndex + mdIndex, TextFormat("\n### category: shapes [%i]\n\n", exCollectionCount)); |
| 2121 |
mdIndex += sprintf(mdTextUpdated + mdListStartIndex + mdIndex, |
| 2122 |
"Examples using raylib shapes drawing functionality, provided by raylib [shapes](../src/rshapes.c) module.\n\n"); |
| 2123 |
} |
| 2124 |
else if (i == 2) |
| 2125 |
{ |
| 2126 |
mdIndex += sprintf(mdTextUpdated + mdListStartIndex + mdIndex, TextFormat("\n### category: textures [%i]\n\n", exCollectionCount)); |
| 2127 |
mdIndex += sprintf(mdTextUpdated + mdListStartIndex + mdIndex, |
| 2128 |
"Examples using raylib textures functionality, including image/textures loading/generation and drawing, provided by raylib [textures](../src/rtextures.c) module.\n\n"); |
| 2129 |
} |
| 2130 |
else if (i == 3) |
| 2131 |
{ |
| 2132 |
mdIndex += sprintf(mdTextUpdated + mdListStartIndex + mdIndex, TextFormat("\n### category: text [%i]\n\n", exCollectionCount)); |
| 2133 |
mdIndex += sprintf(mdTextUpdated + mdListStartIndex + mdIndex, |
| 2134 |
"Examples using raylib text functionality, including sprite fonts loading/generation and text drawing, provided by raylib [text](../src/rtext.c) module.\n\n"); |
| 2135 |
} |
| 2136 |
else if (i == 4) |
| 2137 |
{ |
| 2138 |
mdIndex += sprintf(mdTextUpdated + mdListStartIndex + mdIndex, TextFormat("\n### category: models [%i]\n\n", exCollectionCount)); |
| 2139 |
mdIndex += sprintf(mdTextUpdated + mdListStartIndex + mdIndex, |
| 2140 |
"Examples using raylib models functionality, including models loading/generation and drawing, provided by raylib [models](../src/rmodels.c) module.\n\n"); |
| 2141 |
} |
| 2142 |
else if (i == 5) |
| 2143 |
{ |
| 2144 |
mdIndex += sprintf(mdTextUpdated + mdListStartIndex + mdIndex, TextFormat("\n### category: shaders [%i]\n\n", exCollectionCount)); |
| 2145 |
mdIndex += sprintf(mdTextUpdated + mdListStartIndex + mdIndex, |
| 2146 |
"Examples using raylib shaders functionality, including shaders loading, parameters configuration and drawing using them (model shaders and postprocessing shaders). This functionality is directly provided by raylib [rlgl](../src/rlgl.h) module.\n\n"); |
| 2147 |
} |
| 2148 |
else if (i == 6) |
| 2149 |
{ |
| 2150 |
mdIndex += sprintf(mdTextUpdated + mdListStartIndex + mdIndex, TextFormat("\n### category: audio [%i]\n\n", exCollectionCount)); |
| 2151 |
mdIndex += sprintf(mdTextUpdated + mdListStartIndex + mdIndex, |
| 2152 |
"Examples using raylib audio functionality, including sound/music loading and playing. This functionality is provided by raylib [raudio](../src/raudio.c) module. Note this module can be used standalone independently of raylib.\n\n"); |
| 2153 |
} |
| 2154 |
|
| 2155 |
|
| 2156 |
mdIndex += sprintf(mdTextUpdated + mdListStartIndex + mdIndex, "| example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |\n"); |
| 2157 |
mdIndex += sprintf(mdTextUpdated + mdListStartIndex + mdIndex, "|-----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|\n"); |
| 2158 |
|
| 2159 |
char starsText[16] = { 0 }; |
| 2160 |
for (int x = 0; x < exCollectionCount; x++) |
| 2161 |
{ |
| 2162 |
for (int s = 0; s < 4; s++) |
| 2163 |
{ |
| 2164 |
if (s < exCollection[x].stars) strcpy(starsText + 3*s, "⭐️visual |
| 2165 |
else strcpy(starsText + 3*s, "☆"); |
| 2166 |
} |
| 2167 |
|
| 2168 |
mdIndex += sprintf(mdTextUpdated + mdListStartIndex + mdIndex, |
| 2169 |
TextFormat("| [%s](%s/%s.c) | <img src=\"%s/%s.png\" alt=\"%s\" width=\"80\"> | %s | %s | %s | [%s](https://github.com/%s) |\n", |
| 2170 |
exCollection[x].name, exCollection[x].category, exCollection[x].name, exCollection[x].category, exCollection[x].name, exCollection[x].name, |
| 2171 |
starsText, exCollection[x].verCreated, exCollection[x].verUpdated, exCollection[x].author, exCollection[x].authorGitHub)); |
| 2172 |
} |
| 2173 |
|
| 2174 |
UnloadExampleData(exCollection); |
| 2175 |
} |
| 2176 |
|
| 2177 |
mdIndex += sprintf(mdTextUpdated + mdListStartIndex + mdIndex, |
| 2178 |
"\nSome example missing? As always, contributions are welcome, feel free to send new examples!\n"); |
| 2179 |
mdIndex += sprintf(mdTextUpdated + mdListStartIndex + mdIndex, |
| 2180 |
"Here is an [examples template](examples_template.c) with instructions to start with!\n"); |
| 2181 |
|
| 2182 |
|
| 2183 |
SaveFileText(TextFormat("%s/README.md", exBasePath), mdTextUpdated); |
| 2184 |
UnloadFileText(mdText); |
| 2185 |
RL_FREE(mdTextUpdated); |
| 2186 |
|
| 2187 |
|
| 2188 |
|
| 2189 |
_window'), |
| 2190 |
|
| 2191 |
LOG("INFO: Updating raylib.com/common/examples.js\n"); |
| 2192 |
char *jsText = LoadFileText(TextFormat("%s/../common/examples.js", exWebPath)); |
| 2193 |
if (!jsText) |
| 2194 |
{ |
| 2195 |
LOG("INFO: examples.js not found, skipping web examples list update\n"); |
| 2196 |
} |
| 2197 |
else |
| 2198 |
{ |
| 2199 |
int jsListStartIndex = TextFindIndex(jsText, "//EXAMPLE_DATA_LIST_START"); |
| 2200 |
int jsListEndIndex = TextFindIndex(jsText, "//EXAMPLE_DATA_LIST_END"); |
| 2201 |
if ((jsListStartIndex < 0) || (jsListEndIndex < 0)) |
| 2202 |
{ |
| 2203 |
LOG("WARNING: examples.js markers not found, skipping update\n"); |
| 2204 |
UnloadFileText(jsText); |
| 2205 |
} |
| 2206 |
else |
| 2207 |
{ |
| 2208 |
char *jsTextUpdated = (char *)RL_CALLOC(REXM_MAX_BUFFER_SIZE, 1); |
| 2209 |
int jsIndex = 0; |
| 2210 |
memcpy(jsTextUpdated, jsText, jsListStartIndex); |
| 2211 |
jsIndex = sprintf(jsTextUpdated + jsListStartIndex, "//EXAMPLE_DATA_LIST_START\n"); |
| 2212 |
jsIndex += sprintf(jsTextUpdated + jsListStartIndex + jsIndex, " var exampleData = [\n"); |
| 2213 |
|
| 2214 |
char starsText[16] = { 0 }; |
| 2215 |
|
| 2216 |
for (int i = 0; i < REXM_MAX_EXAMPLE_CATEGORIES; i++) |
| 2217 |
{ |
| 2218 |
int exCollectionCount = 0; |
| 2219 |
rlExampleInfo *exCollection = LoadExampleData(exCategories[i], false, &exCollectionCount); |
| 2220 |
for (int x = 0; x < exCollectionCount; x++) |
| 2221 |
{ |
| 2222 |
for (int s = 0; s < 4; s++) |
| 2223 |
{ |
| 2224 |
if (s < exCollection[x].stars) strcpy(starsText + 3*s, "⭐️visual |
| 2225 |
else strcpy(starsText + 3*s, "☆"); |
| 2226 |
} |
| 2227 |
|
| 2228 |
if ((i == 6) && (x == (exCollectionCount - 1))) |
| 2229 |
{ |
| 2230 |
|
| 2231 |
jsIndex += sprintf(jsTextUpdated + jsListStartIndex + jsIndex, |
| 2232 |
TextFormat(" exampleEntry('%s', '%s', '%s')];\n", starsText, exCollection[x].category, exCollection[x].name + strlen(exCollection[x].category) + 1)); |
| 2233 |
} |
| 2234 |
else |
| 2235 |
{ |
| 2236 |
jsIndex += sprintf(jsTextUpdated + jsListStartIndex + jsIndex, |
| 2237 |
TextFormat(" exampleEntry('%s', '%s', '%s'),\n", starsText, exCollection[x].category, exCollection[x].name + strlen(exCollection[x].category) + 1)); |
| 2238 |
} |
| 2239 |
} |
| 2240 |
|
| 2241 |
UnloadExampleData(exCollection); |
| 2242 |
} |
| 2243 |
|
| 2244 |
|
| 2245 |
memcpy(jsTextUpdated + jsListStartIndex + jsIndex, jsText + jsListEndIndex, strlen(jsText) - jsListEndIndex); |
| 2246 |
|
| 2247 |
|
| 2248 |
SaveFileText(TextFormat("%s/../common/examples.js", exWebPath), jsTextUpdated); |
| 2249 |
UnloadFileText(jsText); |
| 2250 |
RL_FREE(jsTextUpdated); |
| 2251 |
} |
| 2252 |
} |
| 2253 |
|
| 2254 |
|
| 2255 |
return result; |
| 2256 |
} |
| 2257 |
|
| 2258 |
|
| 2259 |
static rlExampleInfo *LoadExampleData(const char *filter, bool sort, int *exCount) |
| 2260 |
{ |
| 2261 |
#define MAX_EXAMPLES_INFO 256 |
| 2262 |
|
| 2263 |
rlExampleInfo *exInfo = (rlExampleInfo *)RL_CALLOC(MAX_EXAMPLES_INFO, sizeof(rlExampleInfo)); |
| 2264 |
int exCounter = 0; |
| 2265 |
*exCount = 0; |
| 2266 |
|
| 2267 |
|
| 2268 |
char *text = LoadFileText(exCollectionFilePath); |
| 2269 |
|
| 2270 |
if (text != NULL) |
| 2271 |
{ |
| 2272 |
int lineCount = 0; |
| 2273 |
char **lines = LoadTextLines(text, &lineCount); |
| 2274 |
|
| 2275 |
for (int i = 0; i < lineCount; i++) |
| 2276 |
{ |
| 2277 |
|
| 2278 |
if ((lines[i][0] != '#') && |
| 2279 |
((lines[i][0] == 'c') || |
| 2280 |
(lines[i][0] == 's') || |
| 2281 |
(lines[i][0] == 't') || |
| 2282 |
(lines[i][0] == 'm') || |
| 2283 |
(lines[i][0] == 'a'))) |
| 2284 |
{ |
| 2285 |
rlExampleInfo info = { 0 }; |
| 2286 |
int result = ParseExampleInfoLine(lines[i], &info); |
| 2287 |
if (result == 1) |
| 2288 |
{ |
| 2289 |
if (strcmp(filter, "ALL") == 0) |
| 2290 |
{ |
| 2291 |
|
| 2292 |
memcpy(&exInfo[exCounter], &info, sizeof(rlExampleInfo)); |
| 2293 |
exCounter++; |
| 2294 |
} |
| 2295 |
else if (strcmp(info.category, filter) == 0) |
| 2296 |
{ |
| 2297 |
|
| 2298 |
memcpy(&exInfo[exCounter], &info, sizeof(rlExampleInfo)); |
| 2299 |
exCounter++; |
| 2300 |
} |
| 2301 |
else if (strcmp(info.name, filter) == 0) |
| 2302 |
{ |
| 2303 |
|
| 2304 |
memcpy(&exInfo[exCounter], &info, sizeof(rlExampleInfo)); |
| 2305 |
exCounter++; |
| 2306 |
break; |
| 2307 |
} |
| 2308 |
} |
| 2309 |
} |
| 2310 |
} |
| 2311 |
|
| 2312 |
UnloadTextLines(lines, lineCount); |
| 2313 |
UnloadFileText(text); |
| 2314 |
} |
| 2315 |
|
| 2316 |
|
| 2317 |
if (sort) SortExampleByName(exInfo, exCounter); |
| 2318 |
|
| 2319 |
*exCount = exCounter; |
| 2320 |
return exInfo; |
| 2321 |
} |
| 2322 |
|
| 2323 |
|
| 2324 |
static void UnloadExampleData(rlExampleInfo *exInfo) |
| 2325 |
{ |
| 2326 |
RL_FREE(exInfo); |
| 2327 |
} |
| 2328 |
|
| 2329 |
|
| 2330 |
|
| 2331 |
static rlExampleInfo *LoadExampleInfo(const char *exFileName) |
| 2332 |
{ |
| 2333 |
rlExampleInfo *exInfo = NULL; |
| 2334 |
|
| 2335 |
if (FileExists(exFileName) && IsFileExtension(exFileName, ".c")) |
| 2336 |
{ |
| 2337 |
|
| 2338 |
exInfo = (rlExampleInfo *)RL_CALLOC(1, sizeof(rlExampleInfo)); |
| 2339 |
|
| 2340 |
strncpy(exInfo->name, GetFileNameWithoutExt(exFileName), 128 - 1); |
| 2341 |
strncpy(exInfo->category, exInfo->name, TextFindIndex(exInfo->name, "_")); |
| 2342 |
|
| 2343 |
char *exText = LoadFileText(exFileName); |
| 2344 |
|
| 2345 |
|
| 2346 |
★ |
| 2347 |
int starsIndex = TextFindIndex(exText, "★"); |
| 2348 |
if (starsIndex > 0) |
| 2349 |
{ |
| 2350 |
const char *starPtr = exText + starsIndex; |
| 2351 |
while (*starPtr) |
| 2352 |
{ |
| 2353 |
if (((unsigned char)starPtr[0] == 0xe2) && |
| 2354 |
((unsigned char)starPtr[1] == 0x98) && |
| 2355 |
((unsigned char)starPtr[2] == 0x85)) |
| 2356 |
{ |
| 2357 |
exInfo->stars++; |
| 2358 |
starPtr += 3; |
| 2359 |
} |
| 2360 |
else starPtr++; |
| 2361 |
} |
| 2362 |
} |
| 2363 |
|
| 2364 |
|
| 2365 |
int verCreateIndex = TextFindIndex(exText, "created with raylib "); |
| 2366 |
int verCreatedLen = 0; |
| 2367 |
for (int i = verCreateIndex + 20; (exText[i] != ' ') && (exText[i] != '\n') && (exText[i] != ','); i++) verCreatedLen++; |
| 2368 |
if (verCreateIndex > 0) strncpy(exInfo->verCreated, exText + verCreateIndex + 20, verCreatedLen); |
| 2369 |
else strcpy(exInfo->verCreated, RAYLIB_VERSION); |
| 2370 |
|
| 2371 |
|
| 2372 |
int verUpdateIndex = TextFindIndex(exText, "updated with raylib "); |
| 2373 |
int verUpdateLen = 0; |
| 2374 |
for (int i = verUpdateIndex + 20; (exText[i] != ' ') && (exText[i] != '\n') && (exText[i] != ','); i++) verUpdateLen++; |
| 2375 |
if (verUpdateIndex > 0) strncpy(exInfo->verUpdated, exText + verUpdateIndex + 20, verUpdateLen); |
| 2376 |
else strcpy(exInfo->verUpdated, RAYLIB_VERSION); |
| 2377 |
|
| 2378 |
|
| 2379 |
|
| 2380 |
|
| 2381 |
|
| 2382 |
|
| 2383 |
int copyrightIndex = TextFindIndex(exText, "Copyright (c) "); |
| 2384 |
int yearStartIndex = copyrightIndex + 14; |
| 2385 |
char yearText[5] = { 0 }; |
| 2386 |
strncpy(yearText, exText + yearStartIndex, 4); |
| 2387 |
exInfo->yearCreated = TextToInteger(yearText); |
| 2388 |
|
| 2389 |
if (exText[yearStartIndex + 4] == '-') strncpy(yearText, exText + yearStartIndex + 5, 4); |
| 2390 |
exInfo->yearReviewed = TextToInteger(yearText); |
| 2391 |
int yearEndIndex = TextFindIndex(exText + yearStartIndex, " "); |
| 2392 |
int authorStartIndex = yearStartIndex + yearEndIndex + 1; |
| 2393 |
int authorEndIndex = TextFindIndex(exText + authorStartIndex, " (@"); |
| 2394 |
if (authorEndIndex != -1) |
| 2395 |
{ |
| 2396 |
authorEndIndex += authorStartIndex; |
| 2397 |
strncpy(exInfo->author, exText + authorStartIndex, authorEndIndex - authorStartIndex); |
| 2398 |
|
| 2399 |
|
| 2400 |
int userStartIndex = authorEndIndex + 3; |
| 2401 |
int userEndIndex = TextFindIndex(exText + userStartIndex, ")"); |
| 2402 |
userEndIndex += userStartIndex; |
| 2403 |
strncpy(exInfo->authorGitHub, exText + userStartIndex, userEndIndex - userStartIndex); |
| 2404 |
} |
| 2405 |
else |
| 2406 |
{ |
| 2407 |
authorEndIndex = TextFindIndex(exText + authorStartIndex, "\n"); |
| 2408 |
authorEndIndex += authorStartIndex; |
| 2409 |
strncpy(exInfo->author, exText + authorStartIndex, authorEndIndex - authorStartIndex); |
| 2410 |
} |
| 2411 |
|
| 2412 |
UnloadFileText(exText); |
| 2413 |
|
| 2414 |
exInfo->resPaths = LoadExampleResourcePaths(exFileName, &exInfo->resCount); |
| 2415 |
} |
| 2416 |
|
| 2417 |
return exInfo; |
| 2418 |
} |
| 2419 |
|
| 2420 |
|
| 2421 |
static void UnloadExampleInfo(rlExampleInfo *exInfo) |
| 2422 |
{ |
| 2423 |
UnloadExampleResourcePaths(exInfo->resPaths); |
| 2424 |
RL_FREE(exInfo); |
| 2425 |
} |
| 2426 |
|
| 2427 |
|
| 2428 |
@raysan5 |
| 2429 |
static int ParseExampleInfoLine(const char *line, rlExampleInfo *entry) |
| 2430 |
{ |
| 2431 |
#define MAX_EXAMPLE_INFO_LINE_LEN 512 |
| 2432 |
|
| 2433 |
char temp[MAX_EXAMPLE_INFO_LINE_LEN] = { 0 }; |
| 2434 |
strncpy(temp, line, MAX_EXAMPLE_INFO_LINE_LEN); |
| 2435 |
temp[MAX_EXAMPLE_INFO_LINE_LEN - 1] = '\0'; |
| 2436 |
|
| 2437 |
int tokenCount = 0; |
| 2438 |
char **tokens = TextSplit(line, ';', &tokenCount); |
| 2439 |
|
| 2440 |
if (tokenCount != 9) |
| 2441 |
{ |
| 2442 |
LOG("REXM: WARNING: Example collection line contains invalid number of tokens: %i\n", tokenCount); |
| 2443 |
} |
| 2444 |
|
| 2445 |
|
| 2446 |
strcpy(entry->category, tokens[0]); |
| 2447 |
strcpy(entry->name, tokens[1]); |
| 2448 |
|
| 2449 |
|
| 2450 |
★ |
| 2451 |
const char *starPtr = tokens[2]; |
| 2452 |
while (*starPtr) |
| 2453 |
{ |
| 2454 |
if (((unsigned char)starPtr[0] == 0xe2) && |
| 2455 |
((unsigned char)starPtr[1] == 0x98) && |
| 2456 |
((unsigned char)starPtr[2] == 0x85)) |
| 2457 |
{ |
| 2458 |
entry->stars++; |
| 2459 |
starPtr += 3; |
| 2460 |
} |
| 2461 |
else starPtr++; |
| 2462 |
} |
| 2463 |
|
| 2464 |
|
| 2465 |
strcpy(entry->verCreated, tokens[3]); |
| 2466 |
strcpy(entry->verUpdated, tokens[4]); |
| 2467 |
|
| 2468 |
|
| 2469 |
entry->yearCreated = TextToInteger(tokens[5]); |
| 2470 |
entry->yearReviewed = TextToInteger(tokens[6]); |
| 2471 |
|
| 2472 |
|
| 2473 |
if (tokens[7][0] == '"') tokens[7] += 1; |
| 2474 |
if (tokens[7][strlen(tokens[7]) - 1] == '"') tokens[7][strlen(tokens[7]) - 1] = '\0'; |
| 2475 |
strcpy(entry->author, tokens[7]); |
| 2476 |
strcpy(entry->authorGitHub, tokens[8] + 1); |
| 2477 |
|
| 2478 |
return 1; |
| 2479 |
} |
| 2480 |
|
| 2481 |
|
| 2482 |
static int rlExampleInfoCompare(const void *a, const void *b) |
| 2483 |
{ |
| 2484 |
const rlExampleInfo *ex1 = (const rlExampleInfo *)a; |
| 2485 |
const rlExampleInfo *ex2 = (const rlExampleInfo *)b; |
| 2486 |
|
| 2487 |
return strcmp(ex1->name, ex2->name); |
| 2488 |
} |
| 2489 |
|
| 2490 |
|
| 2491 |
|
| 2492 |
static void SortExampleByName(rlExampleInfo *items, int count) |
| 2493 |
{ |
| 2494 |
qsort(items, count, sizeof(rlExampleInfo), rlExampleInfoCompare); |
| 2495 |
} |
| 2496 |
|
| 2497 |
|
| 2498 |
|
| 2499 |
|
| 2500 |
static char **LoadExampleResourcePaths(const char *srcFilePath, int *resPathCount) |
| 2501 |
{ |
| 2502 |
char **paths = (char **)RL_CALLOC(REXM_MAX_RESOURCE_PATHS, sizeof(char **)); |
| 2503 |
for (int i = 0; i < REXM_MAX_RESOURCE_PATHS; i++) paths[i] = (char *)RL_CALLOC(REXM_MAX_RESOURCE_PATH_LENGTH, sizeof(char)); |
| 2504 |
|
| 2505 |
int resCounter = 0; |
| 2506 |
char *code = LoadFileText(srcFilePath); |
| 2507 |
|
| 2508 |
if (code != NULL) |
| 2509 |
{ |
| 2510 |
|
| 2511 |
const char *exts[] = { ".png", ".bmp", ".jpg", ".qoi", ".gif", ".raw", ".hdr", ".ttf", ".fnt", ".wav", ".ogg", ".mp3", ".flac", ".mod", ".xm", ".qoa", ".obj", ".iqm", ".glb", ".m3d", ".vox", ".vs", ".fs", ".txt" }; |
| 2512 |
const int extCount = sizeof(exts)/sizeof(char *); |
| 2513 |
|
| 2514 |
char *ptr = code; |
| 2515 |
while ((ptr = strchr(ptr, '"')) != NULL) |
| 2516 |
{ |
| 2517 |
char *start = ptr + 1; |
| 2518 |
char *end = strchr(start, '"'); |
| 2519 |
if (!end) break; |
| 2520 |
|
| 2521 |
|
| 2522 |
|
| 2523 |
|
| 2524 |
int functionIndex01 = TextFindIndex(ptr - 40, "ExportImage"); |
| 2525 |
int functionIndex02 = TextFindIndex(ptr - 10, "TraceLog"); |
| 2526 |
int functionIndex03 = TextFindIndex(ptr - 40, "TakeScreenshot"); |
| 2527 |
int functionIndex04 = TextFindIndex(ptr - 40, "SaveFileData"); |
| 2528 |
int functionIndex05 = TextFindIndex(ptr - 40, "SaveFileText"); |
| 2529 |
|
| 2530 |
if (!((functionIndex01 != -1) && (functionIndex01 < 40)) && |
| 2531 |
!((functionIndex02 != -1) && (functionIndex02 < 10)) && |
| 2532 |
!((functionIndex03 != -1) && (functionIndex03 < 40)) && |
| 2533 |
!((functionIndex04 != -1) && (functionIndex04 < 40)) && |
| 2534 |
!((functionIndex05 != -1) && (functionIndex05 < 40))) |
| 2535 |
{ |
| 2536 |
int len = (int)(end - start); |
| 2537 |
if ((len > 0) && (len < REXM_MAX_RESOURCE_PATH_LENGTH)) |
| 2538 |
{ |
| 2539 |
char buffer[REXM_MAX_RESOURCE_PATH_LENGTH] = { 0 }; |
| 2540 |
strncpy(buffer, start, len); |
| 2541 |
buffer[len] = '\0'; |
| 2542 |
|
| 2543 |
|
| 2544 |
for (int i = 0; i < extCount; i++) |
| 2545 |
{ |
| 2546 |
|
| 2547 |
|
| 2548 |
if (IsFileExtension(buffer, exts[i])) |
| 2549 |
{ |
| 2550 |
|
| 2551 |
bool found = false; |
| 2552 |
for (int j = 0; j < resCounter; j++) |
| 2553 |
{ |
| 2554 |
if (strcmp(paths[j], buffer) == 0) { found = true; break; } |
| 2555 |
} |
| 2556 |
|
| 2557 |
if (!found && (resCounter < REXM_MAX_RESOURCE_PATHS)) |
| 2558 |
{ |
| 2559 |
strcpy(paths[resCounter], buffer); |
| 2560 |
resCounter++; |
| 2561 |
} |
| 2562 |
|
| 2563 |
break; |
| 2564 |
} |
| 2565 |
} |
| 2566 |
} |
| 2567 |
} |
| 2568 |
|
| 2569 |
ptr = end + 1; |
| 2570 |
} |
| 2571 |
|
| 2572 |
UnloadFileText(code); |
| 2573 |
} |
| 2574 |
|
| 2575 |
|
| 2576 |
|
| 2577 |
|
| 2578 |
|
| 2579 |
|
| 2580 |
|
| 2581 |
|
| 2582 |
|
| 2583 |
|
| 2584 |
|
| 2585 |
|
| 2586 |
|
| 2587 |
|
| 2588 |
|
| 2589 |
|
| 2590 |
|
| 2591 |
|
| 2592 |
|
| 2593 |
|
| 2594 |
|
| 2595 |
|
| 2596 |
|
| 2597 |
|
| 2598 |
*resPathCount = resCounter; |
| 2599 |
return paths; |
| 2600 |
} |
| 2601 |
|
| 2602 |
|
| 2603 |
static void UnloadExampleResourcePaths(char **resPaths) |
| 2604 |
{ |
| 2605 |
for (int i = 0; i < REXM_MAX_RESOURCE_PATHS; i++) RL_FREE(resPaths[i]); |
| 2606 |
|
| 2607 |
RL_FREE(resPaths); |
| 2608 |
} |
| 2609 |
|
| 2610 |
|
| 2611 |
|
| 2612 |
|
| 2613 |
|
| 2614 |
|
| 2615 |
static int AddVSProjectToSolution(const char *slnFile, const char *projFile, const char *category) |
| 2616 |
{ |
| 2617 |
int result = 0; |
| 2618 |
|
| 2619 |
|
| 2620 |
|
| 2621 |
|
| 2622 |
|
| 2623 |
const char *uuid = GenerateUUIDv4(); |
| 2624 |
|
| 2625 |
|
| 2626 |
FileTextReplace(projFile, "0981CA98-E4A5-4DF1-987F-A41D09131EFC", uuid); |
| 2627 |
|
| 2628 |
char *slnText = LoadFileText(slnFile); |
| 2629 |
char *slnTextUpdated = (char *)RL_CALLOC(REXM_MAX_BUFFER_SIZE, 1); |
| 2630 |
|
| 2631 |
|
| 2632 |
|
| 2633 |
|
| 2634 |
|
| 2635 |
int prjStartIndex = TextFindIndex(slnText, "Global"); |
| 2636 |
|
| 2637 |
|
| 2638 |
|
| 2639 |
strncpy(slnTextUpdated, slnText, prjStartIndex); |
| 2640 |
int offsetIndex = sprintf(slnTextUpdated + prjStartIndex, |
| 2641 |
TextFormat("Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"%s\", \"examples\\%s\", \"{%s}\"\n", |
| 2642 |
GetFileNameWithoutExt(projFile), GetFileName(projFile), uuid)); |
| 2643 |
offsetIndex += prjStartIndex; |
| 2644 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, "EndProject\n"); |
| 2645 |
|
| 2646 |
|
| 2647 |
|
| 2648 |
|
| 2649 |
|
| 2650 |
int projConfStartIndex = TextFindIndex(slnText, "GlobalSection(ProjectConfigurationPlatforms) = postSolution"); |
| 2651 |
strncpy(slnTextUpdated + offsetIndex, slnText + prjStartIndex, projConfStartIndex - prjStartIndex); |
| 2652 |
offsetIndex += (projConfStartIndex - prjStartIndex); |
| 2653 |
|
| 2654 |
int projConfEndIndex = TextFindIndex(slnText + projConfStartIndex, "EndGlobalSection"); |
| 2655 |
projConfEndIndex += projConfStartIndex; |
| 2656 |
|
| 2657 |
strncpy(slnTextUpdated + offsetIndex, slnText + projConfStartIndex, projConfEndIndex - projConfStartIndex); |
| 2658 |
offsetIndex += (projConfEndIndex - projConfStartIndex); |
| 2659 |
|
| 2660 |
|
| 2661 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, TextFormat("\t{%s}.Debug.DLL|ARM64.ActiveCfg = Debug.DLL|ARM64\n", uuid)); |
| 2662 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, TextFormat("\t\t{%s}.Debug.DLL|ARM64.Build.0 = Debug.DLL|ARM64\n", uuid)); |
| 2663 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, TextFormat("\t\t{%s}.Debug.DLL|x64.ActiveCfg = Debug.DLL|x64\n", uuid)); |
| 2664 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, TextFormat("\t\t{%s}.Debug.DLL|x64.Build.0 = Debug.DLL|x64\n", uuid)); |
| 2665 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, TextFormat("\t\t{%s}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32\n", uuid)); |
| 2666 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, TextFormat("\t\t{%s}.Debug.DLL|x86.Build.0 = Debug.DLL|Win32\n", uuid)); |
| 2667 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, TextFormat("\t\t{%s}.Debug|ARM64.ActiveCfg = Debug|ARM64\n", uuid)); |
| 2668 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, TextFormat("\t\t{%s}.Debug|ARM64.Build.0 = Debug|ARM64\n", uuid)); |
| 2669 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, TextFormat("\t\t{%s}.Debug|x64.ActiveCfg = Debug|x64\n", uuid)); |
| 2670 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, TextFormat("\t\t{%s}.Debug|x64.Build.0 = Debug|x64\n", uuid)); |
| 2671 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, TextFormat("\t\t{%s}.Debug|x86.ActiveCfg = Debug|Win32\n", uuid)); |
| 2672 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, TextFormat("\t\t{%s}.Debug|x86.Build.0 = Debug|Win32\n", uuid)); |
| 2673 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, TextFormat("\t\t{%s}.Release.DLL|ARM64.ActiveCfg = Release.DLL|ARM64\n", uuid)); |
| 2674 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, TextFormat("\t\t{%s}.Release.DLL|ARM64.Build.0 = Release.DLL|ARM64\n", uuid)); |
| 2675 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, TextFormat("\t\t{%s}.Release.DLL|x64.ActiveCfg = Release.DLL|x64\n", uuid)); |
| 2676 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, TextFormat("\t\t{%s}.Release.DLL|x64.Build.0 = Release.DLL|x64\n", uuid)); |
| 2677 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, TextFormat("\t\t{%s}.Release.DLL|x86.ActiveCfg = Release.DLL|Win32\n", uuid)); |
| 2678 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, TextFormat("\t\t{%s}.Release.DLL|x86.Build.0 = Release.DLL|Win32\n", uuid)); |
| 2679 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, TextFormat("\t\t{%s}.Release|ARM64.ActiveCfg = Release|ARM64\n", uuid)); |
| 2680 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, TextFormat("\t\t{%s}.Release|ARM64.Build.0 = Release|ARM64\n", uuid)); |
| 2681 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, TextFormat("\t\t{%s}.Release|x64.ActiveCfg = Release|x64\n", uuid)); |
| 2682 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, TextFormat("\t\t{%s}.Release|x64.Build.0 = Release|x64\n", uuid)); |
| 2683 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, TextFormat("\t\t{%s}.Release|x86.ActiveCfg = Release|Win32\n", uuid)); |
| 2684 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, TextFormat("\t\t{%s}.Release|x86.Build.0 = Release|Win32\n", uuid)); |
| 2685 |
|
| 2686 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, "\tEndGlobalSection\n"); |
| 2687 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, "\tGlobalSection(SolutionProperties) = preSolution\n"); |
| 2688 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, "\t\tHideSolutionNode = FALSE\n"); |
| 2689 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, "\tEndGlobalSection\n\t"); |
| 2690 |
|
| 2691 |
|
| 2692 |
|
| 2693 |
|
| 2694 |
|
| 2695 |
int projFolderStartIndex = TextFindIndex(slnText, "GlobalSection(NestedProjects) = preSolution"); |
| 2696 |
int projFolderEndIndex = TextFindIndex(slnText + projFolderStartIndex, "\tEndGlobalSection"); |
| 2697 |
projFolderEndIndex += projFolderStartIndex; |
| 2698 |
|
| 2699 |
strncpy(slnTextUpdated + offsetIndex, slnText + projFolderStartIndex, projFolderEndIndex - projFolderStartIndex); |
| 2700 |
offsetIndex += (projFolderEndIndex - projFolderStartIndex); |
| 2701 |
|
| 2702 |
|
| 2703 |
|
| 2704 |
if (strcmp(category, "core") == 0) offsetIndex += sprintf(slnTextUpdated + offsetIndex, |
| 2705 |
TextFormat("\t\t{%s} = {6C82BAAE-BDDF-457D-8FA8-7E2490B07035}\n", uuid)); |
| 2706 |
else if (strcmp(category, "shapes") == 0) offsetIndex += sprintf(slnTextUpdated + offsetIndex, |
| 2707 |
TextFormat("\t\t{%s} = {278D8859-20B1-428F-8448-064F46E1F021}\n", uuid)); |
| 2708 |
else if (strcmp(category, "textures") == 0) offsetIndex += sprintf(slnTextUpdated + offsetIndex, |
| 2709 |
TextFormat("\t\t{%s} = {DA049009-21FF-4AC0-84E4-830DD1BCD0CE}\n", uuid)); |
| 2710 |
else if (strcmp(category, "text") == 0) offsetIndex += sprintf(slnTextUpdated + offsetIndex, |
| 2711 |
TextFormat("\t\t{%s} = {8D3C83B7-F1E0-4C2E-9E34-EE5F6AB2502A}\n", uuid)); |
| 2712 |
else if (strcmp(category, "models") == 0) offsetIndex += sprintf(slnTextUpdated + offsetIndex, |
| 2713 |
TextFormat("\t\t{%s} = {AF5BEC5C-1F2B-4DA8-B12D-D09FE569237C}\n", uuid)); |
| 2714 |
else if (strcmp(category, "shaders") == 0) offsetIndex += sprintf(slnTextUpdated + offsetIndex, |
| 2715 |
TextFormat("\t\t{%s} = {5317807F-61D4-4E0F-B6DC-2D9F12621ED9}\n", uuid)); |
| 2716 |
else if (strcmp(category, "audio") == 0) offsetIndex += sprintf(slnTextUpdated + offsetIndex, |
| 2717 |
TextFormat("\t\t{%s} = {CC132A4D-D081-4C26-BFB9-AB11984054F8}\n", uuid)); |
| 2718 |
else if (strcmp(category, "other") == 0) offsetIndex += sprintf(slnTextUpdated + offsetIndex, |
| 2719 |
TextFormat("\t\t{%s} = {E9D708A5-9C1F-4B84-A795-C5F191801762}\n", uuid)); |
| 2720 |
else LOG("WARNING: Provided category is not valid: %s\n", category); |
| 2721 |
|
| 2722 |
|
| 2723 |
|
| 2724 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, "\tEndGlobalSection\n"); |
| 2725 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, "\tGlobalSection(ExtensibilityGlobals) = postSolution\n"); |
| 2726 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, "\t\tSolutionGuid = {E926C768-6307-4423-A1EC-57E95B1FAB29}\n"); |
| 2727 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, "\tEndGlobalSection\n"); |
| 2728 |
offsetIndex += sprintf(slnTextUpdated + offsetIndex, "EndGlobal\n"); |
| 2729 |
|
| 2730 |
SaveFileText(slnFile, slnTextUpdated); |
| 2731 |
UnloadFileText(slnText); |
| 2732 |
RL_FREE(slnTextUpdated); |
| 2733 |
|
| 2734 |
return result; |
| 2735 |
} |
| 2736 |
|
| 2737 |
|
| 2738 |
static int RemoveVSProjectFromSolution(const char *slnFile, const char *exName) |
| 2739 |
{ |
| 2740 |
int result = 0; |
| 2741 |
|
| 2742 |
|
| 2743 |
|
| 2744 |
|
| 2745 |
|
| 2746 |
|
| 2747 |
|
| 2748 |
char *slnText = LoadFileText(slnFile); |
| 2749 |
char *slnTextUpdated = (char *)RL_CALLOC(REXM_MAX_BUFFER_SIZE, 1); |
| 2750 |
|
| 2751 |
int lineCount = 0; |
| 2752 |
char **lines = LoadTextLines(slnText, &lineCount); |
| 2753 |
|
| 2754 |
char uuid[38] = { 0 }; |
| 2755 |
strcpy(uuid, "ABCDEF00-0123-4567-89AB-000000000012"); |
| 2756 |
int textUpdatedOfsset = 0; |
| 2757 |
int exNameLen = (int)strlen(exName); |
| 2758 |
|
| 2759 |
for (int i = 0, index = 0; i < lineCount; i++) |
| 2760 |
{ |
| 2761 |
index = TextFindIndex(lines[i], exName); |
| 2762 |
if (index > 0) |
| 2763 |
{ |
| 2764 |
|
| 2765 |
strncpy(uuid, lines[i] + index + exNameLen*2 + 26, 36); |
| 2766 |
|
| 2767 |
|
| 2768 |
i++; |
| 2769 |
} |
| 2770 |
else |
| 2771 |
{ |
| 2772 |
if (TextFindIndex(lines[i], uuid) == -1) |
| 2773 |
textUpdatedOfsset += sprintf(slnTextUpdated + textUpdatedOfsset, "%s\n", lines[i]); |
| 2774 |
} |
| 2775 |
} |
| 2776 |
|
| 2777 |
SaveFileText(slnFile, slnTextUpdated); |
| 2778 |
|
| 2779 |
UnloadTextLines(lines, lineCount); |
| 2780 |
UnloadFileText(slnText); |
| 2781 |
RL_FREE(slnTextUpdated); |
| 2782 |
|
| 2783 |
return result; |
| 2784 |
} |
| 2785 |
|
| 2786 |
|
| 2787 |
|
| 2788 |
static const char *GenerateUUIDv4(void) |
| 2789 |
{ |
| 2790 |
static char uuid[38] = { 0 }; |
| 2791 |
memset(uuid, 0, 38); |
| 2792 |
|
| 2793 |
unsigned char bytes[16] = { 0 }; |
| 2794 |
|
| 2795 |
for (int i = 0; i < 16; i++) bytes[i] = (unsigned char)GetRandomValue(0, 255); |
| 2796 |
|
| 2797 |
|
| 2798 |
bytes[6] = (bytes[6] & 0x0F) | 0x40; |
| 2799 |
bytes[8] = (bytes[8] & 0x3F) | 0x80; |
| 2800 |
|
| 2801 |
snprintf(uuid, 38, |
| 2802 |
"%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X", |
| 2803 |
bytes[0], bytes[1], bytes[2], bytes[3], |
| 2804 |
bytes[4], bytes[5], |
| 2805 |
bytes[6], bytes[7], |
| 2806 |
bytes[8], bytes[9], |
| 2807 |
bytes[10], bytes[11], bytes[12], bytes[13], bytes[14], bytes[15]); |
| 2808 |
|
| 2809 |
return uuid; |
| 2810 |
} |
| 2811 |
|
| 2812 |
|
| 2813 |
static void UpdateSourceMetadata(const char *exSrcPath, const rlExampleInfo *info) |
| 2814 |
{ |
| 2815 |
if (FileExists(exSrcPath) && IsFileExtension(exSrcPath, ".c") && (!TextIsEqual(info->category, "others"))) |
| 2816 |
{ |
| 2817 |
|
| 2818 |
char exSourcePath[512] = { 0 }; |
| 2819 |
strcpy(exSourcePath, exSrcPath); |
| 2820 |
|
| 2821 |
char *exText = LoadFileText(exSourcePath); |
| 2822 |
char *exTextUpdated[6] = { 0 }; |
| 2823 |
char *exTextUpdatedPtr = exText; |
| 2824 |
|
| 2825 |
char exNameFormated[256] = { 0 }; |
| 2826 |
int exNameIndex = TextFindIndex(info->name, "_"); |
| 2827 |
strcpy(exNameFormated, info->name + exNameIndex + 1); |
| 2828 |
int exNameLen = (int)strlen(exNameFormated); |
| 2829 |
for (int i = 0; i < exNameLen; i++) { if (exNameFormated[i] == '_') exNameFormated[i] = ' '; } |
| 2830 |
|
| 2831 |
|
| 2832 |
|
| 2833 |
exTextUpdated[0] = TextReplaceBetweenAlloc(exTextUpdatedPtr, "* raylib [", "\n", |
| 2834 |
TextFormat("%s] example - %s", info->category, exNameFormated)); |
| 2835 |
if (exTextUpdated[0] != NULL) exTextUpdatedPtr = exTextUpdated[0]; |
| 2836 |
|
| 2837 |
|
| 2838 |
☆] 2/4" |
| 2839 |
|
| 2840 |
char starsText[16] = { 0 }; |
| 2841 |
for (int i = 0; i < 4; i++) |
| 2842 |
{ |
| 2843 |
|
| 2844 |
if (i < info->stars) strcpy(starsText + 3*i, "★"); |
| 2845 |
else strcpy(starsText + 3*i, "☆"); |
| 2846 |
} |
| 2847 |
exTextUpdated[1] = TextReplaceBetweenAlloc(exTextUpdatedPtr, "* Example complexity rating: [", "/4\n", |
| 2848 |
TextFormat("%s] %i", starsText, info->stars)); |
| 2849 |
if (exTextUpdated[1] != NULL) exTextUpdatedPtr = exTextUpdated[1]; |
| 2850 |
|
| 2851 |
|
| 2852 |
|
| 2853 |
exTextUpdated[2] = TextReplaceBetweenAlloc(exTextUpdatedPtr, "* Example originally created with raylib ", "\n", |
| 2854 |
TextFormat("%s, last time updated with raylib %s", info->verCreated, info->verUpdated)); |
| 2855 |
if (exTextUpdated[2] != NULL) exTextUpdatedPtr = exTextUpdated[2]; |
| 2856 |
|
| 2857 |
|
| 2858 |
|
| 2859 |
if (info->yearCreated == info->yearReviewed) |
| 2860 |
{ |
| 2861 |
exTextUpdated[3] = TextReplaceBetweenAlloc(exTextUpdatedPtr, "Copyright (c) ", ")", |
| 2862 |
TextFormat("%i %s (@%s", info->yearCreated, info->author, info->authorGitHub)); |
| 2863 |
if (exTextUpdated[3] != NULL) exTextUpdatedPtr = exTextUpdated[3]; |
| 2864 |
} |
| 2865 |
else |
| 2866 |
{ |
| 2867 |
exTextUpdated[3] = TextReplaceBetweenAlloc(exTextUpdatedPtr, "Copyright (c) ", ")", |
| 2868 |
TextFormat("%i-%i %s (@%s", info->yearCreated, info->yearReviewed, info->author, info->authorGitHub)); |
| 2869 |
if (exTextUpdated[3] != NULL) exTextUpdatedPtr = exTextUpdated[3]; |
| 2870 |
} |
| 2871 |
|
| 2872 |
|
| 2873 |
|
| 2874 |
exTextUpdated[4] = TextReplaceBetweenAlloc(exTextUpdated[3], "InitWindow(screenWidth, screenHeight, \"", "\");", |
| 2875 |
TextFormat("raylib [%s] example - %s", info->category, exNameFormated)); |
| 2876 |
if (exTextUpdated[4] != NULL) exTextUpdatedPtr = exTextUpdated[4]; |
| 2877 |
|
| 2878 |
|
| 2879 |
|
| 2880 |
|
| 2881 |
exTextUpdated[5] = TextReplaceBetweenAlloc(exTextUpdatedPtr, "* Example contributed by ", ")", |
| 2882 |
TextFormat("%s (@%s", info->author, info->authorGitHub)); |
| 2883 |
if (exTextUpdated[5] != NULL) exTextUpdatedPtr = exTextUpdated[5]; |
| 2884 |
|
| 2885 |
if (exTextUpdatedPtr != NULL) SaveFileText(exSourcePath, exTextUpdatedPtr); |
| 2886 |
|
| 2887 |
for (int i = 0; i < 6; i++) { MemFree(exTextUpdated[i]); exTextUpdated[i] = NULL; } |
| 2888 |
|
| 2889 |
UnloadFileText(exText); |
| 2890 |
} |
| 2891 |
} |
| 2892 |
|
| 2893 |
|
| 2894 |
static void UpdateWebMetadata(const char *exHtmlPath, const char *exFilePath) |
| 2895 |
{ |
| 2896 |
if (FileExists(exHtmlPath) && IsFileExtension(exHtmlPath, ".html")) |
| 2897 |
{ |
| 2898 |
|
| 2899 |
char exHtmlPathCopy[512] = { 0 }; |
| 2900 |
strcpy(exHtmlPathCopy, exHtmlPath); |
| 2901 |
|
| 2902 |
char *exHtmlText = LoadFileText(exHtmlPathCopy); |
| 2903 |
char *exHtmlTextUpdated[6] = { 0 }; |
| 2904 |
|
| 2905 |
char exName[64] = { 0 }; |
| 2906 |
char exCategory[16] = { 0 }; |
| 2907 |
char exDescription[256] = { 0 }; |
| 2908 |
char exTitle[64] = { 0 }; |
| 2909 |
|
| 2910 |
|
| 2911 |
strncpy(exName, GetFileNameWithoutExt(exHtmlPathCopy), 64 - 1); |
| 2912 |
strcpy(exTitle, exName); |
| 2913 |
for (int i = 0; (i < 64) && (exTitle[i] != '\0'); i++) { if (exTitle[i] == '_') exTitle[i] = ' '; } |
| 2914 |
|
| 2915 |
|
| 2916 |
for (int i = 0; (exName[i] != '_'); i++) exCategory[i] = exName[i]; |
| 2917 |
|
| 2918 |
|
| 2919 |
char *exText = LoadFileText(exFilePath); |
| 2920 |
int lineCount = 0; |
| 2921 |
char **lines = LoadTextLines(exText, &lineCount); |
| 2922 |
int lineLength = (int)strlen(lines[2]); |
| 2923 |
strncpy(exDescription, lines[2] + 4, lineLength - 4); |
| 2924 |
UnloadTextLines(lines, lineCount); |
| 2925 |
UnloadFileText(exText); |
| 2926 |
|
| 2927 |
|
| 2928 |
exHtmlTextUpdated[0] = TextReplaceAlloc(exHtmlText, "raylib web game", exTitle); |
| 2929 |
exHtmlTextUpdated[1] = TextReplaceAlloc(exHtmlTextUpdated[0], "New raylib web videogame, developed using raylib videogames library", exDescription); |
| 2930 |
exHtmlTextUpdated[2] = TextReplaceAlloc(exHtmlTextUpdated[1], "https://www.raylib.com/common/raylib_logo.png", |
| 2931 |
TextFormat("https://raw.githubusercontent.com/raysan5/raylib/master/examples/%s/%s.png", exCategory, exName)); |
| 2932 |
exHtmlTextUpdated[3] = TextReplaceAlloc(exHtmlTextUpdated[2], "https://www.raylib.com/games.html", |
| 2933 |
TextFormat("https://www.raylib.com/examples/%s/%s.html", exCategory, exName)); |
| 2934 |
exHtmlTextUpdated[4] = TextReplaceAlloc(exHtmlTextUpdated[3], "raylib - example", TextFormat("raylib - %s", exName)); |
| 2935 |
exHtmlTextUpdated[5] = TextReplaceAlloc(exHtmlTextUpdated[4], "https://github.com/raysan5/raylib", |
| 2936 |
TextFormat("https://github.com/raysan5/raylib/blob/master/examples/%s/%s.c", exCategory, exName)); |
| 2937 |
|
| 2938 |
SaveFileText(exHtmlPathCopy, exHtmlTextUpdated[5]); |
| 2939 |
|
| 2940 |
|
| 2941 |
|
| 2942 |
|
| 2943 |
|
| 2944 |
|
| 2945 |
|
| 2946 |
for (int i = 0; i < 6; i++) { MemFree(exHtmlTextUpdated[i]); exHtmlTextUpdated[i] = NULL; } |
| 2947 |
|
| 2948 |
UnloadFileText(exHtmlText); |
| 2949 |
} |
| 2950 |
} |
| 2951 |
|
| 2952 |
|
| 2953 |
static int GetTextListIndex(const char *text, const char **list, int listCount) |
| 2954 |
{ |
| 2955 |
int result = -1; |
| 2956 |
|
| 2957 |
for (int i = 0; i < listCount; i++) |
| 2958 |
{ |
| 2959 |
if (TextIsEqual(text, list[i])) { result = i; break; } |
| 2960 |
} |
| 2961 |
|
| 2962 |
return result; |
| 2963 |
} |
| 2964 |
|
| 2965 |
#if defined(__GNUC__) |
| 2966 |
#pragma GCC diagnostic pop |
| 2967 |
#endif |