Skip to content

Commit b6de148

Browse files
committed
Fix bundled GL headers: Windows only, avoid CALLBACK macro errors on Linux/macOS
1 parent 4ecae88 commit b6de148

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

mode/CppMode.jar

88 Bytes
Binary file not shown.

src/java/CppBuild.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3051,7 +3051,15 @@ private List<String> buildCommand(String gpp, File src, File bin, boolean win, b
30513051
}
30523052
// Always add bundled headers -- takes precedence over system headers
30533053
// on Windows, supplements Homebrew on macOS, supplements pkg on Linux.
3054-
if (bundledInclude.exists()) cmd.add("-I" + bundledInclude.getAbsolutePath());
3054+
if (win) {
3055+
if (bundledInclude.exists()) cmd.add("-I" + bundledInclude.getAbsolutePath());
3056+
} else {
3057+
boolean hasSystemGlfw = new File("/usr/include/GLFW/glfw3.h").exists()
3058+
|| new File("/usr/local/include/GLFW/glfw3.h").exists()
3059+
|| new File("/opt/homebrew/include/GLFW/glfw3.h").exists();
3060+
if (!hasSystemGlfw && bundledInclude.exists())
3061+
cmd.add("-I" + bundledInclude.getAbsolutePath());
3062+
}
30553063

30563064
// ── Cached precompiled objects ──────────────────────────────────────────
30573065
// Processing.cpp takes ~9s to compile. Cache the .o and reuse it.
@@ -3084,7 +3092,7 @@ private List<String> buildCommand(String gpp, File src, File bin, boolean win, b
30843092
pchCmd.add(gpp); pchCmd.add("-std=" + cppStd); pchCmd.add("-O2");
30853093
if (!mac) pchCmd.add("-march=x86-64");
30863094
if (homebrewPrefix != null) pchCmd.add("-I" + homebrewPrefix + "/include");
3087-
if (bundledInclude.exists()) pchCmd.add("-I" + bundledInclude.getAbsolutePath());
3095+
if (win && bundledInclude.exists()) pchCmd.add("-I" + bundledInclude.getAbsolutePath());
30883096
pchCmd.add("-I" + runtimeDir.getAbsolutePath());
30893097
pchCmd.add("-DPROCESSING_HAS_STB_IMAGE");
30903098
pchCmd.add("-DPROCESSING_HAS_STB_TRUETYPE");
@@ -3100,7 +3108,7 @@ private List<String> buildCommand(String gpp, File src, File bin, boolean win, b
31003108
preCmd.add(gpp); preCmd.add("-std=" + cppStd); preCmd.add("-O2");
31013109
if (!mac) preCmd.add("-march=native");
31023110
if (homebrewPrefix != null) preCmd.add("-I" + homebrewPrefix + "/include");
3103-
if (bundledInclude.exists()) preCmd.add("-I" + bundledInclude.getAbsolutePath());
3111+
if (win && bundledInclude.exists()) preCmd.add("-I" + bundledInclude.getAbsolutePath());
31043112
preCmd.add("-I" + runtimeDir.getAbsolutePath());
31053113
preCmd.add("-DPROCESSING_HAS_STB_IMAGE");
31063114
preCmd.add("-DPROCESSING_HAS_STB_TRUETYPE");
@@ -3125,7 +3133,7 @@ private List<String> buildCommand(String gpp, File src, File bin, boolean win, b
31253133
preCmd2.add(gpp); preCmd2.add("-std=" + cppStd); preCmd2.add("-O2");
31263134
if (!mac) preCmd2.add("-march=native");
31273135
if (homebrewPrefix != null) preCmd2.add("-I" + homebrewPrefix + "/include");
3128-
if (bundledInclude.exists()) preCmd2.add("-I" + bundledInclude.getAbsolutePath());
3136+
if (win && bundledInclude.exists()) preCmd2.add("-I" + bundledInclude.getAbsolutePath());
31293137
preCmd2.add("-I" + runtimeDir.getAbsolutePath());
31303138
preCmd2.add("-DPROCESSING_HAS_STB_IMAGE");
31313139
preCmd2.add("-DPROCESSING_HAS_STB_TRUETYPE");

0 commit comments

Comments
 (0)