aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/com/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-08-12 16:19:23 +0200
committerSven Gothel <[email protected]>2023-08-12 16:19:23 +0200
commit7bf095d6426ce9b88f901a70bf8237b04009a0ff (patch)
tree796ae85208bc8c38cd3790d8e0cca2f6c045d736 /src/main/java/com/jogamp
parentf4e42c4210f687e7f414aec24d1c82401f85b37c (diff)
Preprocessor: Add feature UNIFIED_OUTPUT (now default in GlueGen's JCPP): line_token() shall output Unix '/' file separatorHEADv2.5.0master
Diffstat (limited to 'src/main/java/com/jogamp')
-rw-r--r--src/main/java/com/jogamp/gluegen/jcpp/Feature.java9
-rw-r--r--src/main/java/com/jogamp/gluegen/jcpp/JCPP.java1
-rw-r--r--src/main/java/com/jogamp/gluegen/jcpp/Preprocessor.java12
3 files changed, 18 insertions, 4 deletions
diff --git a/src/main/java/com/jogamp/gluegen/jcpp/Feature.java b/src/main/java/com/jogamp/gluegen/jcpp/Feature.java
index 86202fc..1628721 100644
--- a/src/main/java/com/jogamp/gluegen/jcpp/Feature.java
+++ b/src/main/java/com/jogamp/gluegen/jcpp/Feature.java
@@ -38,5 +38,12 @@ public enum Feature {
OBJCSYNTAX,
INCLUDENEXT,
/** Random extensions. */
- PRAGMA_ONCE
+ PRAGMA_ONCE,
+ /**
+ * Unified output for reproducible platform-agnostic builds, i.e.:
+ * <ul>
+ * <li>Use unix-file-separator '/' on all platform.</li>
+ * </ul>
+ */
+ UNIFIED_OUTPUT
}
diff --git a/src/main/java/com/jogamp/gluegen/jcpp/JCPP.java b/src/main/java/com/jogamp/gluegen/jcpp/JCPP.java
index 3f1e057..d499372 100644
--- a/src/main/java/com/jogamp/gluegen/jcpp/JCPP.java
+++ b/src/main/java/com/jogamp/gluegen/jcpp/JCPP.java
@@ -54,6 +54,7 @@ public class JCPP implements GenericCPP {
cpp.addFeature(Feature.DIGRAPHS);
cpp.addFeature(Feature.TRIGRAPHS);
cpp.addFeature(Feature.LINEMARKERS);
+ cpp.addFeature(Feature.UNIFIED_OUTPUT);
cpp.addFeature(Feature.CSYNTAX);
cpp.addFeature(Feature.KEEPCOMMENTS);
if (enablePragmaOnce) {
diff --git a/src/main/java/com/jogamp/gluegen/jcpp/Preprocessor.java b/src/main/java/com/jogamp/gluegen/jcpp/Preprocessor.java
index 3427467..dc2d119 100644
--- a/src/main/java/com/jogamp/gluegen/jcpp/Preprocessor.java
+++ b/src/main/java/com/jogamp/gluegen/jcpp/Preprocessor.java
@@ -31,6 +31,7 @@ import java.util.Map;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
+import java.util.regex.Matcher;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
@@ -638,10 +639,15 @@ public class Preprocessor implements Closeable {
buf.append("#line ").append(line)
.append(" \"");
/* XXX This call to escape(name) is correct but ugly. */
- if (name == null)
+ if (name == null) {
buf.append("<no file>");
- else
- MacroTokenSource.escape(buf, name);
+ } else {
+ if( File.separatorChar != '/' && getFeature(Feature.UNIFIED_OUTPUT) ) {
+ MacroTokenSource.escape(buf, name.replaceAll(Matcher.quoteReplacement(File.separator), "/"));
+ } else {
+ MacroTokenSource.escape(buf, name);
+ }
+ }
buf.append("\"").append(extra).append("\n");
return new Token(P_LINE, line, 0, buf.toString(), null);
}