56
56
57
57
#define SUPPORT_LOG_INFO
58
58
#if defined(SUPPORT_LOG_INFO ) && defined(_DEBUG )
59
- #define LOG (...) printf(__VA_ARGS__)
59
+ #define LOG (...) printf("REXM: " __VA_ARGS__)
60
60
#else
61
61
#define LOG (...)
62
62
#endif
@@ -221,10 +221,12 @@ int main(int argc, char *argv[])
221
221
char exRecategory [32 ] = { 0 }; // Example re-name category: shapes
222
222
char exRename [64 ] = { 0 }; // Example re-name, without extension
223
223
224
+ char exRebuildRequested [16 ] = { 0 }; // Example category/full rebuild request
225
+
224
226
int opCode = OP_NONE ; // Operation code: 0-None(Help), 1-Create, 2-Add, 3-Rename, 4-Remove
225
227
bool verbose = false; // Flag for verbose log info
226
228
227
- // Command-line usage mode
229
+ // Command-line usage mode: command args processing
228
230
//--------------------------------------------------------------------------------------
229
231
if (argc > 1 )
230
232
{
@@ -387,16 +389,25 @@ int main(int argc, char *argv[])
387
389
else if (argc > 3 ) LOG ("WARNING: Too many arguments provided\n" );
388
390
else
389
391
{
390
- // Verify example exists in collection to be removed
391
- char * exColInfo = LoadFileText (exCollectionFilePath );
392
- if (TextFindIndex (exColInfo , argv [2 ]) != -1 ) // Example in the collection
392
+ // Support building not only individual examples but categories and "ALL"
393
+ if ((strcmp (argv [2 ], "ALL" ) == 0 ) || TextInList (argv [2 ], exCategories , REXM_MAX_EXAMPLE_CATEGORIES ))
394
+ {
395
+ // Category/ALL rebuilt requested
396
+ strcpy (exRebuildRequested , argv [2 ]);
397
+ }
398
+ else
393
399
{
394
- strcpy (exName , argv [2 ]); // Register example name for removal
395
- strncpy (exCategory , exName , TextFindIndex (exName , "_" ));
396
- opCode = OP_BUILD ;
400
+ // Verify example exists in collection to be removed
401
+ char * exColInfo = LoadFileText (exCollectionFilePath );
402
+ if (TextFindIndex (exColInfo , argv [2 ]) != -1 ) // Example in the collection
403
+ {
404
+ strcpy (exName , argv [2 ]); // Register example name for removal
405
+ strncpy (exCategory , exName , TextFindIndex (exName , "_" ));
406
+ opCode = OP_BUILD ;
407
+ }
408
+ else LOG ("WARNING: BUILD: Example requested not available in the collection\n" );
409
+ UnloadFileText (exColInfo );
397
410
}
398
- else LOG ("WARNING: BUILD: Example not available in the collection\n" );
399
- UnloadFileText (exColInfo );
400
411
}
401
412
}
402
413
@@ -407,10 +418,14 @@ int main(int argc, char *argv[])
407
418
}
408
419
}
409
420
421
+ // Command-line usage mode: command execution
410
422
switch (opCode )
411
423
{
412
424
case OP_CREATE : // Create: New example from template
413
425
{
426
+ LOG ("INFO: Command requested: CREATE\n" );
427
+ LOG ("INFO: Example to create: %s\n" , exName );
428
+
414
429
// Create: raylib/examples/<category>/<category>_example_name.c
415
430
char * exText = LoadFileText (exTemplateFilePath );
416
431
char * exTextUpdated [6 ] = { 0 };
@@ -430,6 +445,9 @@ int main(int argc, char *argv[])
430
445
}
431
446
case OP_ADD : // Add: Example from command-line input filename
432
447
{
448
+ if (opCode != OP_CREATE ) LOG ("INFO: Command requested: ADD\n" );
449
+ LOG ("INFO: Example file to be added: %s\n" , inFileName );
450
+
433
451
// Add: raylib/examples/<category>/<category>_example_name.c
434
452
if (opCode != OP_CREATE ) FileCopy (inFileName , TextFormat ("%s/%s/%s.c" , exBasePath , exCategory , exName ));
435
453
@@ -629,6 +647,9 @@ int main(int argc, char *argv[])
629
647
} break ;
630
648
case OP_RENAME : // Rename
631
649
{
650
+ LOG ("INFO: Command requested: RENAME\n" );
651
+ LOG ("INFO: Example to be renamed: %s --> %s\n" , exName , exRename );
652
+
632
653
// NOTE: At this point provided values have been validated:
633
654
// exName, exCategory, exRename, exRecategory
634
655
if (strcmp (exCategory , exRecategory ) == 0 )
@@ -740,6 +761,9 @@ int main(int argc, char *argv[])
740
761
} break ;
741
762
case OP_REMOVE : // Remove
742
763
{
764
+ LOG ("INFO: Command requested: REMOVE\n" );
765
+ LOG ("INFO: Example to be removed: %s\n" , exName );
766
+
743
767
// Remove example from collection for files update
744
768
//------------------------------------------------------------------------------------------------
745
769
char * exCollectionList = LoadFileText (exCollectionFilePath );
@@ -818,10 +842,70 @@ int main(int argc, char *argv[])
818
842
FileRemove (TextFormat ("%s/%s/%s.wasm" , exWebPath , exCategory , exName ));
819
843
FileRemove (TextFormat ("%s/%s/%s.js" , exWebPath , exCategory , exName ));
820
844
845
+ } break ;
846
+ case OP_BUILD :
847
+ {
848
+ LOG ("INFO: Command requested: BUILD\n" );
849
+ LOG ("INFO: Example to be built: %s\n" , exRebuildRequested );
850
+
851
+ if ((strcmp (exRebuildRequested , "others" ) != 0 ) &&
852
+ (strcmp (exCategory , "others" ) != 0 )) // Skipping "others" category for rebuild: Special needs
853
+ {
854
+ int exRebuildCount = 0 ;
855
+ rlExampleInfo * exRebuildList = LoadExamplesData (exCollectionFilePath , exRebuildRequested , false, & exRebuildCount );
856
+
857
+ // Build: raylib.com/examples/<category>/<category>_example_name.html
858
+ // Build: raylib.com/examples/<category>/<category>_example_name.data
859
+ // Build: raylib.com/examples/<category>/<category>_example_name.wasm
860
+ // Build: raylib.com/examples/<category>/<category>_example_name.js
861
+
862
+ #if defined(_WIN32 )
863
+ // Set required environment variables
864
+ //putenv(TextFormat("RAYLIB_DIR=%s\\..", exBasePath));
865
+ putenv ("PATH=%PATH%;C:\\raylib\\w64devkit\\bin" );
866
+ //putenv("MAKE=mingw32-make");
867
+ //ChangeDirectory(exBasePath);
868
+ #endif
869
+ for (int i = 0 ; i < exRebuildCount ; i ++ )
870
+ {
871
+ // Build example for PLATFORM_DESKTOP
872
+ #if defined(_WIN32 )
873
+ system (TextFormat ("mingw32-make -C %s %s/%s PLATFORM=PLATFORM_DESKTOP -B" , exBasePath , exRebuildList [i ].category , exRebuildList [i ].name ));
874
+ #else
875
+ system (TextFormat ("make -C %s %s/%s PLATFORM=PLATFORM_DESKTOP -B" , exBasePath , exRebuildList [i ].category , exRebuildList [i ].name ));
876
+ #endif
877
+
878
+ // Build example for PLATFORM_WEB
879
+ #if defined(_WIN32 )
880
+ system (TextFormat ("mingw32-make -C %s -f Makefile.Web %s/%s PLATFORM=PLATFORM_WEB -B" , exBasePath , exRebuildList [i ].category , exRebuildList [i ].name ));
881
+ #else
882
+ system (TextFormat ("make -C %s -f Makefile.Web %s/%s PLATFORM=PLATFORM_WEB -B" , exBasePath , exRebuildList [i ].category , exRebuildList [i ].name ));
883
+ #endif
884
+ // Update generated .html metadata
885
+ UpdateWebMetadata (TextFormat ("%s/%s/%s.html" , exBasePath , exRebuildList [i ].category , exRebuildList [i ].name ),
886
+ TextFormat ("%s/%s/%s.c" , exBasePath , exRebuildList [i ].category , exRebuildList [i ].name ));
887
+
888
+ // Copy results to web side
889
+ FileCopy (TextFormat ("%s/%s/%s.html" , exBasePath , exRebuildList [i ].category , exRebuildList [i ].name ),
890
+ TextFormat ("%s/%s/%s.html" , exWebPath , exRebuildList [i ].category , exRebuildList [i ].name ));
891
+ FileCopy (TextFormat ("%s/%s/%s.data" , exBasePath , exRebuildList [i ].category , exRebuildList [i ].name ),
892
+ TextFormat ("%s/%s/%s.data" , exWebPath , exRebuildList [i ].category , exRebuildList [i ].name ));
893
+ FileCopy (TextFormat ("%s/%s/%s.wasm" , exBasePath , exRebuildList [i ].category , exRebuildList [i ].name ),
894
+ TextFormat ("%s/%s/%s.wasm" , exWebPath , exRebuildList [i ].category , exRebuildList [i ].name ));
895
+ FileCopy (TextFormat ("%s/%s/%s.js" , exBasePath , exRebuildList [i ].category , exRebuildList [i ].name ),
896
+ TextFormat ("%s/%s/%s.js" , exWebPath , exRebuildList [i ].category , exRebuildList [i ].name ));
897
+ }
898
+
899
+ UnloadExamplesData (exRebuildList );
900
+ }
901
+ else LOG ("WARNING: [others] category examples should be build manually, they could have specific build requirements\n" );
902
+
821
903
} break ;
822
904
case OP_VALIDATE : // Validate: report and actions
823
905
case OP_UPDATE :
824
906
{
907
+ LOG ("INFO: Command requested: %s\n" , (opCode == OP_VALIDATE )? "VALIDATE" : "UPDATE" );
908
+ LOG ("INFO: Example collection is being %s\n" , (opCode == OP_VALIDATE )? "validated" : "validated and updated" );
825
909
/*
826
910
// Validation flags available:
827
911
VALID_MISSING_C
@@ -1285,48 +1369,6 @@ int main(int argc, char *argv[])
1285
1369
//------------------------------------------------------------------------------------------------
1286
1370
1287
1371
} break ;
1288
- case OP_BUILD :
1289
- {
1290
- // Build: raylib.com/examples/<category>/<category>_example_name.html
1291
- // Build: raylib.com/examples/<category>/<category>_example_name.data
1292
- // Build: raylib.com/examples/<category>/<category>_example_name.wasm
1293
- // Build: raylib.com/examples/<category>/<category>_example_name.js
1294
- if (strcmp (exCategory , "others" ) != 0 ) // Skipping "others" category
1295
- {
1296
- // Build example for PLATFORM_DESKTOP
1297
- #if defined(_WIN32 )
1298
- //putenv(TextFormat("RAYLIB_DIR=%s\\..", exBasePath));
1299
- putenv ("PATH=%PATH%;C:\\raylib\\w64devkit\\bin" );
1300
- //putenv("MAKE=mingw32-make");
1301
- //ChangeDirectory(exBasePath);
1302
- system (TextFormat ("mingw32-make -C %s %s/%s PLATFORM=PLATFORM_DESKTOP -B" , exBasePath , exCategory , exName ));
1303
- #else
1304
- system (TextFormat ("make -C %s %s/%s PLATFORM=PLATFORM_DESKTOP -B" , exBasePath , exCategory , exName ));
1305
- #endif
1306
-
1307
- // Build example for PLATFORM_WEB
1308
- #if defined(_WIN32 )
1309
- putenv ("PATH=%PATH%;C:\\raylib\\w64devkit\\bin" );
1310
- system (TextFormat ("mingw32-make -C %s -f Makefile.Web %s/%s PLATFORM=PLATFORM_WEB -B" , exBasePath , exCategory , exName ));
1311
- #else
1312
- system (TextFormat ("make -C %s -f Makefile.Web %s/%s PLATFORM=PLATFORM_WEB -B" , exBasePath , exCategory , exName ));
1313
- #endif
1314
-
1315
- // Update generated .html metadata
1316
- UpdateWebMetadata (TextFormat ("%s/%s/%s.html" , exBasePath , exCategory , exName ),
1317
- TextFormat ("%s/%s/%s.c" , exBasePath , exCategory , exName ));
1318
-
1319
- // Copy results to web side
1320
- FileCopy (TextFormat ("%s/%s/%s.html" , exBasePath , exCategory , exName ),
1321
- TextFormat ("%s/%s/%s.html" , exWebPath , exCategory , exName ));
1322
- FileCopy (TextFormat ("%s/%s/%s.data" , exBasePath , exCategory , exName ),
1323
- TextFormat ("%s/%s/%s.data" , exWebPath , exCategory , exName ));
1324
- FileCopy (TextFormat ("%s/%s/%s.wasm" , exBasePath , exCategory , exName ),
1325
- TextFormat ("%s/%s/%s.wasm" , exWebPath , exCategory , exName ));
1326
- FileCopy (TextFormat ("%s/%s/%s.js" , exBasePath , exCategory , exName ),
1327
- TextFormat ("%s/%s/%s.js" , exWebPath , exCategory , exName ));
1328
- }
1329
- } break ;
1330
1372
default : // Help
1331
1373
{
1332
1374
// Supported commands:
0 commit comments