Skip to content

Command Line Options And Environment Variables

Peter Froud edited this page Oct 31, 2018 · 5 revisions

JNAerator Files

As the number of arguments needed for a project might quickly grow and produce insane command lines, you might consider putting some or all of your arguments in a *.jnaerator file (preferably, config.jnaerator).

Please read JNAeratorFiles for more details about these files, and JNAeratorFAQ for more general questions.

Syntax

java -jar jnaerator.jar options headerFiles dynamicLibrariesFiles

Options

  • file

    Any header (or directory containing headers at any level of hierarchy), shared library, *.bridgesupport file or *.jnaerator file

    file: OptionalFile

  • -noComp

    (deprecated) Do not compile JNAerated headers. Use -mode Directory instead.

  • -noJar

    (deprecated) Do not create an output JAR. Use -mode Directory instead.

  • -noLibBundle

    Do not bundle libraries in output JAR

  • -h

  • -help

    Show command line arguments help

  • -Dname=value

  • -D name value

  • -Dname=

  • -DmacroName(x, y, z)=macroBody

    Define a macro symbol

    name: String
    value: String

  • -Fpath

  • -F path

    Add a directory to the frameworks path. See doc of JNAERATOR_FRAMEWORKS_PATH

    path: File

  • -Ipath

  • -I path

    Add a directory to the include path or include a file. See doc of JNAERATOR_INCLUDE_PATH

    path: File

  • -Mname=value

  • -M name value

  • -Mname=

    Define an implicit macro symbol, as if it were added by the system (won't count as an explicit macro when generating GYP files and other build artifacts)

    name: String
    value: String

  • -Tname=value

  • -T name value

  • -Tname=

    _Define a type symbol

    name: String
    value: String

  • -Uname

  • -U name

    Undefine a preprocessor symbol after the autoconfiguration phase.

    name: String

  • -addRootDir path

    Remove this directory from the path of descendant source files in the generated documentation.

    path: ExistingDir

  • -allowedFileExts extensions

    _Colon-separated list of file extensions used to restrict files used when recursing on directories, or "*" to parse all files (by default = h:hpp:hxx)

    extensions: String

  • -arch archName

    Define the current architecture for libraries (state variable)

    archName: linux_x64 | linux_x86 | armeabi | sunos_x86 | sunos_sparc | darwin_universal | win32 | win64

  • -beanStructs

    Generate getters and setters for struct fields (JNA & JNAerator runtimes only)

  • -beautifyNames

    Transform C names to Java-looking names : some_func() => someFunc()

  • -bridgeSupportOut outFile

    Write the definitions extracted from bridgesupport files in a file (automatically set when ${Verbose} is used).

    outFile: OutputFile

  • -callbacksInvokeMethodName methodName

    Name of the invocation method of callbacks (apply by default)

    methodName: String

  • -choices choicesFile

    Read the function alternative choices from a file in the format used by -choicesOut.

    choicesFile: ExistingFile

  • -choicesOut outFile

    Write the function alternative choices made (automatically set when ${Verbose} is used).

    outFile: OutputFile

  • -com

    Generate Microsoft COM (C++) bindings.

  • -convertBodies

    Experimental conversion of function bodies to equivalent Java code (BridJ only).

  • -defaultLibrary libName

    Name of output library for elements declared in files not covered by a ${CurrentLibrary} switch

    libName: String

  • -dependencies lib1,lib2

    Comma-separated list of dependencies for the current library (BridJ only).

    methodName: CommaList

  • -direct

    JNAerate libraries that use JNA's faster direct call convention

  • -dontCastConstants

    Don't cast generated constants

  • -emptyStructsAsForwardDecls

    Treat empty structs as forward declarations

  • -entryClass entryClassName

    Generate a class entryclassName.EntryClassName that will contain all of the jnaerated libraries instances. User code will just need to static import or derive from this class to access to the instances (has no effect for BridJ runtime).

    entryClassName: String

  • -extractDeclarations interfaceSimpleClassName

    Extract current library's declarations to an interface with the provided simple name (will be in same package as library implementation class); BridJ-specific

    interfaceSimpleClassName: String

  • -extractionOut outFile

    Write the symbols extracted from libraries in a file (automatically set when ${Verbose} is used).

    outFile: OutputFile

  • -f

    Force the overwrite of existing files

  • -forceNames

    Force @Name annotations on all supported entities (structs, classes, enums, methods) to allow refactoring of resulting sources (BridJ-only).

  • -forceStringSignatures

    Force String and String.md signatures for char* and char** params (JNA runtime only).

  • -fpreprocessed

    Consider source files as being already preprocessed (preprocessor won't be run)

  • -framework frameworkName

    JNAerate a framework using its headers and its *.bridgesupport files if available

    frameworkName: String

  • -frameworksPath path1:path2...

    See doc of JNAERATOR_FRAMEWORKS_PATH

    path1:path2...: String

  • -gccLong

    Use GCC convention for size of 'long' (4 bytes on 32 bits platforms, 8 bytes on 64 bits platforms)

  • -genCPlusPlus

    [Experimental, Not working at all] Generate C++ classes.

  • -genPrivateMembers

    Generate wrappers for private fields and methods (will be protected and deprecated).

  • -gui

    Show minimalist progression GUI

  • -ifRegexMatch javaProperty regex thenArg elseArg

    Conditional evaluation of an argument if a java system property matches a regular expression

    javaProperty: String
    regex: String
    thenArg: String
    elseArg: String

  • -jar outFile

    Jar file where all generated sources and the compiled classes go

    outFile: OutputFile

  • -libFile resourceFile

    Bundle the provided file with the JNAerated JAR so that it is extracted with the library when it is first used.

    resourceFile: ExistingFile

  • -library libName

    Define the name of the output library. This is a state parameter, it will affect all files listed after it, until another -library switch is provided. It does not affect sources included from a project file (Visual Studio...).

    C functions exported in library "test" will end up in class "TestLibrary", for instance. The name of the library is the one fed to JNA to find the shared library, so library "test" must be in "test.dll" on Windows, "libtest.dylib" on Mac OS X and "libtest.so" on other Unices. Note that a special hack is done for library "c" on Windows systems : the output name is set to "msvcrt" instead of "c".

    libName: String

  • -libraryNamingPrefixes commaSeparatedPrefixes

    Define prefixes commonly used in the library so that reification of functions is optimal (See -reification)

    commaSeparatedPrefixes: String

  • -libraryOverrides list

    Comma-separated list of symbol=library library overrides (when isolated functions are located in a different library than their surrounding code).

    list: Map

  • -limitComments

    Avoid useless comments (source file + line, skipped items...)

  • -macrosOut outFile Write the preprocessor macros in a file (automatically set when ${Verbose} is used).

    outFile: OutputFile

  • -mavenArtifactId artifactId

    Set artifact id of the generated Maven project

    artifactId: String

  • -mavenGroupId groupId Set group id of the generated Maven project

    groupId: String

  • -mavenVersion version

    Set version of the generated Maven project

    version: String

  • -maxConstrFields fieldCount

    Maximum number of fields allowed for structure fields constructors. If a struct has more fields, it will only get a default constructor.

    fieldCount: Int

  • -mode mode

    Choose the output mode of JNAerator

    mode: Jar : JAR with bindings only | StandaloneJar : JAR with bindings and runtime dependencies | Directory : Bindings sources in simple file hierarchy | Maven : Bindings sources in Maven project ready to build | AutoGeneratedMaven : Maven project that automatically regenerates its bindings

  • -noAuto

    No auto-configuration of preprocessor symbols and paths

  • -noAutoImport

    Don't add import statements automatically to output java source files

  • -noComments

    Don't output any member comment.

  • -noMangling

    Don't output any C++ name mangling information (may cause C++-decorated symbols not to be found at execution time).

  • -noPrimitiveArrays

    Never output primitive arrays for function arguments (use NIO buffers instead)

  • -noRawBindings

    Don't generate raw bindings amenable for assembler optimizations.

  • -noStaticInit

    Don't generate static init block with BridJ.register() call (BridJ-specific)

  • -noStringReturns

    Prevent const char* and const wchar_t* return types from being converted to String and WString.

  • -nocpp

    Do not define the cplusplus symbol

  • -o outDir

    Output directory for all artifacts

    outDir: OutputDir

  • -onlineDoc linkDisplayFormat urlMessageFormat

    Define a format for online documentation URLs (uses MessageFormat syntax, with arg 0 being the name of the function / structure).

    linkDisplayFormat: MessageFormat
    urlMessageFormat: MessageFormat

  • -optionalFunctions namePattern

    Mark functions which name matches the provided regular expression pattern with the @Optional annotation (BridJ-only)

    namePattern: String

  • -package forcedPackageName

    Set the Java package in which all the output will reside (by default, set to the library name).

    forcedPackageName: String

  • -parseInOnePiece

    Doesn't split the pre-processor output into multiple smaller parts and parse everything as it should (in theory everything should be parsed in one chunk, but in practice this means errors are not isolated from the rest of the parsing)

  • -preferJavac

    Use Sun's Javac compiler instead of Eclipse's ecj, if possible

  • -preprocessingOut outFile

    Write the preprocessor output in a file (automatically set when ${Verbose} is used).

    outFile: OutputFile

  • -project solutionFile "Config|Platform"

    Read Visual Studio 2008 project or solution file and use the configuration specified (e.g. "Release|Win32").

    solutionFile: ExistingFile
    Config|Platform: String

  • -publicRawBindings

    Make raw bindings public.

  • -reification

    Automatically create OO shortcuts for functions that look like methods (typedPtr.someFunc() for someFunc(typedPtr))

  • -removeInlineAsm

    Remove inline asm from preprocessed source, useful when its unsupported syntax makes parsing to fail.

  • -root

  • -rootPackage

    Define the root package for all output classes

    package: String

  • -runtime enum

    Choose target runtime library between JNA, JNAerator (based on JNA), BridJ (faster runtime that supports C++), NodeJS (experimental native library bindings for node.js) (default: BridJ (faster runtime that supports C++)).

    enum: JNA | JNAerator (based on JNA) | BridJ (faster runtime that supports C++) | NodeJS (experimental native library bindings for node.js)

  • -scalaOut outDir

    Experimental Output Scala wrappers (callbacks implicits...)

    outDir: OutputDir

  • -scalaStructSetters

    Generate Scala-style setters for BridJ structs (with a name like fieldName_$eq)

  • -scanSymbols

    Extract, unmangle and parse the symbols all listed shared libraries

  • -sizeAsLong

    Treat size_t and ptrdiff_t values as long values. ONLY HERE FOR COMPATIBILITY WITH PREVIOUS VERSIONS, WILL EVENTUALLY BE REMOVED.

  • -skipDeprecated

    Don't generate members that would be tagged as @Deprecated

  • -skipEnums namePattern

    Skip enumerations which name matches the provided regular expression pattern

    namePattern: String

  • -skipFunctions namePattern

    Skip functions which name matches the provided regular expression pattern

    namePattern: String

  • -skipIncludedFrameworks

    Skip Included Frameworks

  • -skipLibraryInstance

    Skip library instance declarations

  • -skipStructs namePattern

    Skip structs and classes which name matches the provided regular expression pattern

    namePattern: String

  • -structsInLibrary

    Force structs to be JNAerated as inner classes of their declaring libraries (otherwise, each top-level structure is defined as a top-level class in its library's package)

  • -studio

    Launch JNAeratorStudio

  • -synchronized

    Generate synchronized native methods

  • -v

  • -verbose

    Verbose output (both console and files)

  • -wcharAsShort

    Force treatment of wchar_t as short (char by default)

  • -wikiHelp

    Output a wiki-friendly help

  • @path

  • @ path

    Read command-line arguments from a file. File may contain multiple lines (those beginning with "//" will be skipped), file wildcards will be resolved within the file content, as well as variables substitutions : $(someEnvOrJavaVarName), with `$(DIR)`` being the parent directory of the current arguments file.

    path: ExistingFile

Environment Variables

All of these variables may be overridden by setting the environment variable (set VAR=value on Windows, export VAR=value on most unices) or through Java properties (java -DVAR=value -jar jnaerator.jar ...).

  • VISUAL_STUDIO_HOME = C:\Program Files\Microsoft Visual Studio 9.0

  • WINDOWS_SDK_HOME C:\Program Files\Microsoft SDKs\Windows\v6.0A

  • VISUAL_STUDIO_INCLUDES = %VISUAL_STUDIO_HOME%;%WINDOWS_SDK_HOME%

  • JNAERATOR_INCLUDE_PATH : has the following platform-dependent default values :

    • Windows : uses %VISUAL_STUDIO_INCLUDES%
    • Mac OS X : /Developer/SDKs/MacOSX10.4u.sdk/usr/include:.
    • Current dir on any other platform
  • JNAERATOR_FRAMEWORKS_PATH is only set on Mac OS X : /System/Library/Frameworks/CoreServices.framework/Versions/Current/Frameworks:\ /System/Library/Frameworks/ApplicationServices.framework/Versions/Current/Frameworks:\ /System/Library/Frameworks:\ /Library/Frameworks:\ ~/Library/Frameworks

  • library.Xxx (Java property) or XXX_LIBRARY (env. variable) : path to the binary of library Xxx.