@@ -205,12 +205,22 @@ int main(int argc, char *argv[])
205
205
exCollectionFilePath = getenv ("REXM_EXAMPLES_COLLECTION_FILE_PATH" );
206
206
exVSProjectSolutionFile = getenv ("REXM_EXAMPLES_VS2022_SLN_FILE" );
207
207
208
+ #if defined(_WIN32 )
208
209
if (!exBasePath ) exBasePath = "C:/GitHub/raylib/examples" ;
209
210
if (!exWebPath ) exWebPath = "C:/GitHub/raylib.com/examples" ;
210
211
if (!exTemplateFilePath ) exTemplateFilePath = "C:/GitHub/raylib/examples/examples_template.c" ;
211
212
if (!exTemplateScreenshot ) exTemplateScreenshot = "C:/GitHub/raylib/examples/examples_template.png" ;
212
213
if (!exCollectionFilePath ) exCollectionFilePath = "C:/GitHub/raylib/examples/examples_list.txt" ;
213
214
if (!exVSProjectSolutionFile ) exVSProjectSolutionFile = "C:/GitHub/raylib/projects/VS2022/raylib.sln" ;
215
+ #else
216
+ // Cross-platform relative fallbacks (run from tools/rexm directory)
217
+ if (!exBasePath ) exBasePath = "../../examples" ;
218
+ if (!exWebPath ) exWebPath = "../../raylib.com/examples" ;
219
+ if (!exTemplateFilePath ) exTemplateFilePath = "../../examples/examples_template.c" ;
220
+ if (!exTemplateScreenshot ) exTemplateScreenshot = "../../examples/examples_template.png" ;
221
+ if (!exCollectionFilePath ) exCollectionFilePath = "../../examples/examples_list.txt" ;
222
+ if (!exVSProjectSolutionFile ) exVSProjectSolutionFile = "../../projects/VS2022/raylib.sln" ;
223
+ #endif
214
224
215
225
char inFileName [1024 ] = { 0 }; // Example input filename (to be added)
216
226
@@ -1660,54 +1670,67 @@ static int UpdateRequiredFiles(void)
1660
1670
// NOTE: Entries format: exampleEntry('⭐️☆☆☆' , 'core' , 'basic_window'),
1661
1671
//------------------------------------------------------------------------------------------------
1662
1672
char * jsText = LoadFileText (TextFormat ("%s/../common/examples.js" , exWebPath ));
1663
- char * jsTextUpdated = (char * )RL_CALLOC (REXM_MAX_BUFFER_SIZE , 1 ); // Updated examples.js copy, 2MB
1673
+ if (!jsText )
1674
+ {
1675
+ LOG ("INFO: examples.js not found, skipping web examples list update\n" );
1676
+ }
1677
+ else
1678
+ {
1679
+ int jsListStartIndex = TextFindIndex (jsText , "//EXAMPLE_DATA_LIST_START" );
1680
+ int jsListEndIndex = TextFindIndex (jsText , "//EXAMPLE_DATA_LIST_END" );
1681
+ if ((jsListStartIndex < 0 ) || (jsListEndIndex < 0 ))
1682
+ {
1683
+ LOG ("WARNING: examples.js markers not found, skipping update\n" );
1684
+ UnloadFileText (jsText );
1685
+ }
1686
+ else
1687
+ {
1688
+ char * jsTextUpdated = (char * )RL_CALLOC (REXM_MAX_BUFFER_SIZE , 1 ); // Updated examples.js copy, 2MB
1689
+ int jsIndex = 0 ;
1690
+ memcpy (jsTextUpdated , jsText , jsListStartIndex );
1691
+ jsIndex = sprintf (jsTextUpdated + jsListStartIndex , "//EXAMPLE_DATA_LIST_START\n" );
1692
+ jsIndex += sprintf (jsTextUpdated + jsListStartIndex + jsIndex , " var exampleData = [\n" );
1664
1693
1665
- int jsListStartIndex = TextFindIndex (jsText , "//EXAMPLE_DATA_LIST_START" );
1666
- int jsListEndIndex = TextFindIndex (jsText , "//EXAMPLE_DATA_LIST_END" );
1694
+ char starsText [16 ] = { 0 };
1667
1695
1668
- int jsIndex = 0 ;
1669
- memcpy (jsTextUpdated , jsText , jsListStartIndex );
1670
- jsIndex = sprintf (jsTextUpdated + jsListStartIndex , "//EXAMPLE_DATA_LIST_START\n" );
1671
- jsIndex += sprintf (jsTextUpdated + jsListStartIndex + jsIndex , " var exampleData = [\n" );
1696
+ // NOTE: We avoid "others" category
1697
+ for (int i = 0 ; i < REXM_MAX_EXAMPLE_CATEGORIES - 1 ; i ++ )
1698
+ {
1699
+ int exCollectionCount = 0 ;
1700
+ rlExampleInfo * exCollection = LoadExamplesData (exCollectionFilePath , exCategories [i ], false, & exCollectionCount );
1701
+ for (int x = 0 ; x < exCollectionCount ; x ++ )
1702
+ {
1703
+ for (int s = 0 ; s < 4 ; s ++ )
1704
+ {
1705
+ if (s < exCollection [x ].stars ) strcpy (starsText + 3 * s , "⭐️" ); // WARNING: Different than '★', more visual
1706
+ else strcpy (starsText + 3 * s , "☆" );
1707
+ }
1672
1708
1673
- char starsText [16 ] = { 0 };
1709
+ if ((i == 6 ) && (x == (exCollectionCount - 1 )))
1710
+ {
1711
+ // NOTE: Last line to add, special case to consider
1712
+ jsIndex += sprintf (jsTextUpdated + jsListStartIndex + jsIndex ,
1713
+ TextFormat (" exampleEntry('%s', '%s', '%s')];\n" , starsText , exCollection [x ].category , exCollection [x ].name + strlen (exCollection [x ].category ) + 1 ));
1714
+ }
1715
+ else
1716
+ {
1717
+ jsIndex += sprintf (jsTextUpdated + jsListStartIndex + jsIndex ,
1718
+ TextFormat (" exampleEntry('%s', '%s', '%s'),\n" , starsText , exCollection [x ].category , exCollection [x ].name + strlen (exCollection [x ].category ) + 1 ));
1719
+ }
1720
+ }
1674
1721
1675
- // NOTE: We avoid "others" category
1676
- for (int i = 0 ; i < REXM_MAX_EXAMPLE_CATEGORIES - 1 ; i ++ )
1677
- {
1678
- int exCollectionCount = 0 ;
1679
- rlExampleInfo * exCollection = LoadExamplesData (exCollectionFilePath , exCategories [i ], false, & exCollectionCount );
1680
- for (int x = 0 ; x < exCollectionCount ; x ++ )
1681
- {
1682
- for (int s = 0 ; s < 4 ; s ++ )
1683
- {
1684
- if (s < exCollection [x ].stars ) strcpy (starsText + 3 * s , "⭐️" ); // WARNING: Different than '★', more visual
1685
- else strcpy (starsText + 3 * s , "☆" );
1722
+ UnloadExamplesData (exCollection );
1686
1723
}
1687
1724
1688
- if ((i == 6 ) && (x == (exCollectionCount - 1 )))
1689
- {
1690
- // NOTE: Last line to add, special case to consider
1691
- jsIndex += sprintf (jsTextUpdated + jsListStartIndex + jsIndex ,
1692
- TextFormat (" exampleEntry('%s', '%s', '%s')];\n" , starsText , exCollection [x ].category , exCollection [x ].name + strlen (exCollection [x ].category ) + 1 ));
1693
- }
1694
- else
1695
- {
1696
- jsIndex += sprintf (jsTextUpdated + jsListStartIndex + jsIndex ,
1697
- TextFormat (" exampleEntry('%s', '%s', '%s'),\n" , starsText , exCollection [x ].category , exCollection [x ].name + strlen (exCollection [x ].category ) + 1 ));
1698
- }
1699
- }
1725
+ // Add the remaining part of the original file
1726
+ memcpy (jsTextUpdated + jsListStartIndex + jsIndex , jsText + jsListEndIndex , strlen (jsText ) - jsListEndIndex );
1700
1727
1701
- UnloadExamplesData (exCollection );
1728
+ // Save updated file
1729
+ SaveFileText (TextFormat ("%s/../common/examples.js" , exWebPath ), jsTextUpdated );
1730
+ UnloadFileText (jsText );
1731
+ RL_FREE (jsTextUpdated );
1732
+ }
1702
1733
}
1703
-
1704
- // Add the remaining part of the original file
1705
- memcpy (jsTextUpdated + jsListStartIndex + jsIndex , jsText + jsListEndIndex , strlen (jsText ) - jsListEndIndex );
1706
-
1707
- // Save updated file
1708
- SaveFileText (TextFormat ("%s/../common/examples.js" , exWebPath ), jsTextUpdated );
1709
- UnloadFileText (jsText );
1710
- RL_FREE (jsTextUpdated );
1711
1734
//------------------------------------------------------------------------------------------------
1712
1735
1713
1736
return result ;
0 commit comments