public static void main(String[] argsArray) { // argsArray = "-library foo -dependencies bar,baz /Users/ochafik/test.h -mode Directory -o /Users/ochafik/tmp".split(" "); // argsArray = new String[] { "/Users/ochafik/github/nativelibs4java/libraries/tmp/glib/config.jnaerator", "-mode", "Directory", "-f", "-o", "/Users/ochafik/github/nativelibs4java/libraries/tmp/glib" }; // argsArray = new String[] { "/Users/ochafik/tmp/test.h", "-T__be16=short", "-mode", "Directory", "-f", "-o", "/Users/ochafik/github/nativelibs4java/libraries/jnaerator/test", "-v" }; // argsArray = new String[] { "/Users/ochafik/tmp/test.h", "-T__be16=short", "-mode", "Directory", "-f", "-o", "/Users/ochafik/github/nativelibs4java/libraries/jnaerator/test", "-v", "-Dfoo" }; // argsArray = new String[] { "-mode", "Jar", "-f", "-o", "/Users/ochafik/github/nativelibs4java/libraries/tmp", "/Users/ochafik/github/nativelibs4java/libraries/OpenCL/OpenCL4Java/src/main/jnaerator/config.jnaerator" }; main(new JNAerator(new JNAeratorConfig()), argsArray); }
static String preprocess(File source) throws IOException, LexerException { JNAeratorConfig config = new JNAeratorConfig(); JNAeratorConfigUtils.autoConfigure(config); config.preprocessorConfig.implicitIncludes.add("C:\\program files\\Microsoft SDKs\\Windows\\v7.0A\\Include"); config.preprocessorConfig.implicitIncludes.add("C:\\program files\\Microsoft Visual Studio 10.0\\VC\\include"); //config.preprocessorConfig.includeStrings.add(source); config.addSourceFile(source, null, false, true, true); Result result = new Result(config, null, null); String pre = PreprocessorUtils.preprocessSources(config, Collections.EMPTY_LIST, false, result.typeConverter, null); return pre; }
public static String preprocessSources(JNAeratorConfig config, List<Define> defines, boolean verbose, TypeConversion typeConverter, MacroUseCallback macrosDependenciesOut) throws IOException, LexerException { return preprocessSources(config, config.preprocessorConfig.includeStrings, config.getFiles(), defines, verbose, typeConverter, macrosDependenciesOut, null); }
String javaOutPath = javaOutDir.getCanonicalPath(); for (File file : sources) { final JNAeratorConfig config = new JNAeratorConfig(); config.autoConf = true; config.forceOverwrite = true; javaOutDir.mkdirs(); config.outputDir = javaOutDir; config.addSourceFile(file, null, false, true, true); config.addRootDir(root);
public void addFramework(String framework) throws IOException { File file = JNAeratorConfigUtils.getFrameworkDirectory(framework, preprocessorConfig.frameworksPath); frameworks.add(framework); File headers = new File(file, "Headers"); if (headers.exists()) { preprocessorConfig.implicitIncludes.add(headers.getAbsolutePath()); File mainHeader = new File(headers, framework + ".h"); if (mainHeader.exists()) { addSourceFile(mainHeader, framework, true, true, false); } else { addSourceFile(headers, framework, true, true, false); } } else { new IOException("No Headers subdirectory in framework '" + framework + "' found here : " + file).printStackTrace(); } File naturalDir = new File(file, "Resources/BridgeSupport"); File f; f = new File(naturalDir, framework + ".bridgesupport"); if (!f.exists()) { f = new File(naturalDir, framework + "Full.bridgesupport"); } if (f.exists()) { bridgeSupportFiles.add(f); } }
config.addRootDir(a.getFileParam("dir")); break; case SkipDeprecated: break; case LibFile: config.addLibraryFile(a.getFileParam(0), arch); break; case File: break; case Framework: config.addFramework(a.getStringParam(0)); break; case IncludeArgs:
String getFileCommentContent(File file, Element e) { if (file != null) { String path = result.config.relativizeFileForSourceComments(file.getAbsolutePath()); String inCategoryStr = ""; if (e instanceof Function) { Function fc = (Function) e; Struct parent; if (fc.getType() == Type.ObjCMethod && ((parent = as(fc.getParentElement(), Struct.class)) != null) && (parent.getCategoryName() != null)) { inCategoryStr = "from " + parent.getCategoryName() + " "; } } return "<i>" + inCategoryStr + "native declaration : " + path + (e == null || e.getElementLine() < 0 ? "" : ":" + e.getElementLine()) + "</i>"; } else if (e != null && e.getElementLine() >= 0) { return "<i>native declaration : <input>:" + e.getElementLine() + "</i>"; } return null; }
parsedArgs.add(Pair.create(OptionDef.File, Arrays.asList(a.getFileParam(0).toString()))); if (file.isDirectory() && fn.matches(".*\\.framework")) { config.addFramework(file.toString()); } else if (fn.matches(".*\\.bridgesupport")) { config.bridgeSupportFiles.add(file); System.out.println("Adding file '" + file + "' for arch '" + arch + "'."); config.addLibraryFile(file, arch);
config.addRootDir(new File(".")); for (String i : config.preprocessorConfig.explicitIncludes) { try { config.addRootDir(new File(i)); } catch (Exception ex) {
private void parsedActualFile(File file, boolean retainAsTarget) throws Exception { String lib = currentLibrary; String fn = file.getName(); String lfn = fn.toLowerCase(); if (!lfn.matches(".*?\\.(c|cpp|h|hpp|hxx|m)")) { throw new CommandLineException("File '" + file + "' does not seem to be a C, C++ or Objective-C source file, nor a dynamic library, nor a *.jnaerator file."); } if (lib == null) { String name = fn; int i = name.indexOf('.'); if (i >= 0) { name = name.substring(0, i).trim(); } if (name.length() > 0) { lib = name; } System.out.println("Warning: no -library option for file '" + fn + "', using \"" + lib + "\"."); } config.addSourceFile(file, lib, !file.isFile(), retainAsTarget, true); }
config.addRootDir(a.getFileParam("dir")); break; case SkipDeprecated: break; case LibFile: config.addLibraryFile(a.getFileParam(0), arch); break; case File: break; case Framework: config.addFramework(a.getStringParam(0)); break; case IncludeArgs:
String getFileCommentContent(File file, Element e) { if (file != null) { String path = result.config.relativizeFileForSourceComments(file.getAbsolutePath()); String inCategoryStr = ""; if (e instanceof Function) { Function fc = (Function) e; Struct parent; if (fc.getType() == Type.ObjCMethod && ((parent = as(fc.getParentElement(), Struct.class)) != null) && (parent.getCategoryName() != null)) { inCategoryStr = "from " + parent.getCategoryName() + " "; } } return "<i>" + inCategoryStr + "native declaration : " + path + (e == null || e.getElementLine() < 0 ? "" : ":" + e.getElementLine()) + "</i>"; } else if (e != null && e.getElementLine() >= 0) { return "<i>native declaration : <input>:" + e.getElementLine() + "</i>"; } return null; }
parsedArgs.add(Pair.create(OptionDef.File, Arrays.asList(a.getFileParam(0).toString()))); if (file.isDirectory() && fn.matches(".*\\.framework")) { config.addFramework(file.toString()); } else if (fn.matches(".*\\.bridgesupport")) { config.bridgeSupportFiles.add(file); System.out.println("Adding file '" + file + "' for arch '" + arch + "'."); config.addLibraryFile(file, arch);
config.addRootDir(new File(".")); for (String i : config.preprocessorConfig.explicitIncludes) { try { config.addRootDir(new File(i)); } catch (Exception ex) {
public static void main(String[] argsArray) { // argsArray = "-library foo -dependencies bar,baz /Users/ochafik/test.h -mode Directory -o /Users/ochafik/tmp".split(" "); // argsArray = new String[] { "/Users/ochafik/github/nativelibs4java/libraries/tmp/glib/config.jnaerator", "-mode", "Directory", "-f", "-o", "/Users/ochafik/github/nativelibs4java/libraries/tmp/glib" }; // argsArray = new String[] { "/Users/ochafik/tmp/test.h", "-T__be16=short", "-mode", "Directory", "-f", "-o", "/Users/ochafik/github/nativelibs4java/libraries/jnaerator/test", "-v" }; // argsArray = new String[] { "/Users/ochafik/tmp/test.h", "-T__be16=short", "-mode", "Directory", "-f", "-o", "/Users/ochafik/github/nativelibs4java/libraries/jnaerator/test", "-v", "-Dfoo" }; // argsArray = new String[] { "-mode", "Jar", "-f", "-o", "/Users/ochafik/github/nativelibs4java/libraries/tmp", "/Users/ochafik/github/nativelibs4java/libraries/OpenCL/OpenCL4Java/src/main/jnaerator/config.jnaerator" }; main(new JNAerator(new JNAeratorConfig()), argsArray); }
static String preprocess(File source) throws IOException, LexerException { JNAeratorConfig config = new JNAeratorConfig(); JNAeratorConfigUtils.autoConfigure(config); config.preprocessorConfig.implicitIncludes.add("C:\\program files\\Microsoft SDKs\\Windows\\v7.0A\\Include"); config.preprocessorConfig.implicitIncludes.add("C:\\program files\\Microsoft Visual Studio 10.0\\VC\\include"); //config.preprocessorConfig.includeStrings.add(source); config.addSourceFile(source, null, false, true, true); Result result = new Result(config, null, null); String pre = PreprocessorUtils.preprocessSources(config, Collections.EMPTY_LIST, false, result.typeConverter, null); return pre; }
private void parsedActualFile(File file, boolean retainAsTarget) throws Exception { String lib = currentLibrary; String fn = file.getName(); String lfn = fn.toLowerCase(); if (!lfn.matches(".*?\\.(c|cpp|h|hpp|hxx|m)")) { throw new CommandLineException("File '" + file + "' does not seem to be a C, C++ or Objective-C source file, nor a dynamic library, nor a *.jnaerator file."); } if (lib == null) { String name = fn; int i = name.indexOf('.'); if (i >= 0) { name = name.substring(0, i).trim(); } if (name.length() > 0) { lib = name; } System.out.println("Warning: no -library option for file '" + fn + "', using \"" + lib + "\"."); } config.addSourceFile(file, lib, !file.isFile(), retainAsTarget, true); }
String srcFilePath = result.config.relativizeFileForSourceComments(rawSrcFilePath); File srcFile = new File(srcFilePath); String srcParent = srcFile.getParent();
public static String preprocessSources(JNAeratorConfig config, List<Define> defines, boolean verbose, TypeConversion typeConverter, MacroUseCallback macrosDependenciesOut) throws IOException, LexerException { return preprocessSources(config, config.preprocessorConfig.includeStrings, config.getFiles(), defines, verbose, typeConverter, macrosDependenciesOut, null); }
public static void main(String[] args) { JNAerator.main(new JavaCLGenerator(new JNAeratorConfig()), new String[] { "-o", "target/generated-sources/test", //"-o", "/Users/ochafik/Prog/Java/versionedSources/nativelibs4java/trunk/libraries/OpenCL/Demos/target/generated-sources/main/java", "-noJar", "-noComp", "-v", "-addRootDir", "src/test/opencl", "src/test/opencl/com/nativelibs4java/opencl/generator/Structs.c", //"-addRootDir", "/Users/ochafik/Prog/Java/versionedSources/nativelibs4java/trunk/libraries/OpenCL/Blas/target/../src/main/opencl", //"/Users/ochafik/Prog/Java/versionedSources/nativelibs4java/trunk/libraries/OpenCL/Blas/src/main/opencl/com/nativelibs4java/opencl/blas/LinearAlgebraKernels.c" //"-addRootDir", "/Users/ochafik/Prog/Java/versionedSources/nativelibs4java/trunk/libraries/OpenCL/Demos/target/../src/main/opencl", //"/Users/ochafik/Prog/Java/versionedSources/nativelibs4java/trunk/libraries/OpenCL/Demos/target/../src/main/opencl/com/nativelibs4java/opencl/demos/sobelfilter/SimpleSobel.cl" } ); } }