< prev index next >

src/jdk.jextract/share/classes/com/sun/tools/jextract/Main.java

Print this page

        

*** 26,35 **** --- 26,36 ---- import jdk.internal.joptsimple.OptionParser; import jdk.internal.joptsimple.OptionSet; import jdk.internal.joptsimple.util.KeyValuePair; import java.io.File; + import java.io.InputStream; import java.io.IOException; import java.io.PrintWriter; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths;
*** 159,168 **** --- 160,184 ---- setupLogging(Level.parse((String) options.valueOf("log"))); } else { setupLogging(Level.WARNING); } + Path builtinIncludeDir = null; + try { + builtinIncludeDir = createBuiltinIncludeDir(); + } catch (IOException ex) { + ctx.err.println(format("cannot.create.builtin.includes", ex)); + if (Main.DEBUG) { + ex.printStackTrace(ctx.err); + } + return 1; + } + + if (builtinIncludeDir != null) { + ctx.addClangArg("-I" + builtinIncludeDir.toString()); + } + if (options.has("I")) { options.valuesOf("I").forEach(p -> ctx.addClangArg("-I" + p)); } if (options.has("C")) {
*** 280,289 **** --- 296,319 ---- } return 0; } + private static final String[] HEADERS = { "stdarg.h" }; + + private Path createBuiltinIncludeDir() throws IOException { + Path tmpDir = Files.createTempDirectory("jextract"); + // copy built-in header from resources. + for (String header : HEADERS) { + Path headerPath = tmpDir.resolve(header); + try (InputStream headerRes = Main.class.getResourceAsStream("resources/" + header)) { + Files.copy(headerRes, headerPath); + } + } + return tmpDir; + } + public static void main(String... args) { Main instance = new Main(new Context()); System.exit(instance.run(args)); }
< prev index next >