Skip to content

Commit 9c0f4b6

Browse files
committed
macOS: ad-hoc codesign dylibs as fallback if xattr fails
1 parent 58d132d commit 9c0f4b6

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

mode/CppMode.jar

149 Bytes
Binary file not shown.

src/java/CppBuild.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3261,11 +3261,19 @@ else if (!cmd.contains(defaultsCpp.getAbsolutePath()))
32613261
boolean hasBundled = new File(macLibsDir, "libglfw.3.dylib").exists()
32623262
&& new File(macLibsDir, "libGLEW.dylib").exists();
32633263
if (hasBundled) {
3264-
// Strip macOS quarantine attribute so Gatekeeper does not block the dylibs
3264+
// Strip macOS quarantine attribute so Gatekeeper does not block the dylibs.
3265+
// xattr -dr removes the quarantine flag; codesign ad-hoc signs as fallback
3266+
// in case xattr fails (e.g. SIP-restricted path).
32653267
try {
32663268
new ProcessBuilder("xattr", "-dr", "com.apple.quarantine", macLibsDir.getAbsolutePath())
32673269
.start().waitFor();
32683270
} catch (Exception ignored) {}
3271+
try {
3272+
for (java.io.File dylib : macLibsDir.listFiles((d,n) -> n.endsWith(".dylib"))) {
3273+
new ProcessBuilder("codesign", "--force", "--sign", "-", dylib.getAbsolutePath())
3274+
.start().waitFor();
3275+
}
3276+
} catch (Exception ignored) {}
32693277
cmd.add("-L" + macLibsDir.getAbsolutePath());
32703278
cmd.add("-Wl,-rpath," + macLibsDir.getAbsolutePath());
32713279
cmd.add("-Wl,-rpath,@executable_path");

0 commit comments

Comments
 (0)