Skip to content

Commit 14a0a4d

Browse files
authored
FIXED: rexm's makefile and default paths (#5224)
* FIXED: rexm's makefile and default paths Fixed a windows only backslash in rexm's makefile causing build errors on macOS and linux Added unix paths to rexm for better compatibility * Update rexm.c Readded the fall-through in OP_CREATE Added some safety checks to UpdateRequiredFiles() so it plays nicely outside of the raylib.com context (would segfault previously)
1 parent 6f10777 commit 14a0a4d

File tree

2 files changed

+65
-43
lines changed

2 files changed

+65
-43
lines changed

tools/rexm/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ PROJECT_BUILD_PATH ?= .
3535
PROJECT_SOURCE_FILES ?= rexm.c
3636

3737
# raylib library variables
38-
RAYLIB_SRC_PATH ?= ..\..\src
38+
RAYLIB_SRC_PATH ?= ../../src
3939
RAYLIB_INCLUDE_PATH ?= $(RAYLIB_SRC_PATH)
4040
RAYLIB_LIB_PATH ?= $(RAYLIB_SRC_PATH)
4141

@@ -236,7 +236,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
236236
# --source-map-base # allow debugging in browser with source map
237237
# --shell-file shell.html # define a custom shell .html and output extension
238238
LDFLAGS += -sUSE_GLFW=3 -sTOTAL_MEMORY=$(BUILD_WEB_HEAP_SIZE) -sSTACK_SIZE=$(BUILD_WEB_STACK_SIZE) -sFORCE_FILESYSTEM=1 -sMINIFY_HTML=0
239-
239+
240240
# Build using asyncify
241241
ifeq ($(BUILD_WEB_ASYNCIFY),TRUE)
242242
LDFLAGS += -sASYNCIFY -sASYNCIFY_STACK_SIZE=$(BUILD_WEB_ASYNCIFY_STACK_SIZE)
@@ -363,4 +363,3 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
363363
del *.o *.html *.js
364364
endif
365365
@echo Cleaning done
366-

tools/rexm/rexm.c

Lines changed: 63 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,22 @@ int main(int argc, char *argv[])
205205
exCollectionFilePath = getenv("REXM_EXAMPLES_COLLECTION_FILE_PATH");
206206
exVSProjectSolutionFile = getenv("REXM_EXAMPLES_VS2022_SLN_FILE");
207207

208+
#if defined(_WIN32)
208209
if (!exBasePath) exBasePath = "C:/GitHub/raylib/examples";
209210
if (!exWebPath) exWebPath = "C:/GitHub/raylib.com/examples";
210211
if (!exTemplateFilePath) exTemplateFilePath = "C:/GitHub/raylib/examples/examples_template.c";
211212
if (!exTemplateScreenshot) exTemplateScreenshot = "C:/GitHub/raylib/examples/examples_template.png";
212213
if (!exCollectionFilePath) exCollectionFilePath = "C:/GitHub/raylib/examples/examples_list.txt";
213214
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
214224

215225
char inFileName[1024] = { 0 }; // Example input filename (to be added)
216226

@@ -1660,54 +1670,67 @@ static int UpdateRequiredFiles(void)
16601670
// NOTE: Entries format: exampleEntry('⭐️☆☆☆' , 'core' , 'basic_window'),
16611671
//------------------------------------------------------------------------------------------------
16621672
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");
16641693

1665-
int jsListStartIndex = TextFindIndex(jsText, "//EXAMPLE_DATA_LIST_START");
1666-
int jsListEndIndex = TextFindIndex(jsText, "//EXAMPLE_DATA_LIST_END");
1694+
char starsText[16] = { 0 };
16671695

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+
}
16721708

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+
}
16741721

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);
16861723
}
16871724

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);
17001727

1701-
UnloadExamplesData(exCollection);
1728+
// Save updated file
1729+
SaveFileText(TextFormat("%s/../common/examples.js", exWebPath), jsTextUpdated);
1730+
UnloadFileText(jsText);
1731+
RL_FREE(jsTextUpdated);
1732+
}
17021733
}
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);
17111734
//------------------------------------------------------------------------------------------------
17121735

17131736
return result;

0 commit comments

Comments
 (0)