Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jarcode-foss/gcc-maven-plugin

a really simple maven plugin to compile C/C++ code with GCC
https://github.com/jarcode-foss/gcc-maven-plugin

Last synced: 4 days ago
JSON representation

a really simple maven plugin to compile C/C++ code with GCC

Awesome Lists containing this project

README

        

# gcc-maven-plugin
a really simple maven plugin to compile C/C++ code with GCC

Feel free to use, modify, PR, whatever. I made this for my own maven projects that had JNI libraries.

You don't _nessecarily_ have to use GCC (there are settings to change flags/compilers), but all the default
settings are made for GCC. If you want to compile for multiple platforms, you will need to add multiple
executions.

Example usage (excerpt from one of my own projects):


ca.jarcode
gcc-maven-plugin
1.4


compile-library
compile

compile


-O2 -Wall -D_REENTRANT -I${env.JAVA_HOME}/include -I${env.JAVA_HOME}/include/linux -Itarget/include -I/usr/include/luajit-2.0 -I/usr/include/luajit -fPIC



link-library
compile

link


-Lsrc/main/resources -lluajit-5.1 -lffi
true
libcomputerimpl.so



There are two goals in this plugin `link` and `compile`, which do exactly as they suggest. The `compile` goal passes the `-c` flag to gcc, and both flags will pass `-o` following the output file for the goal.

Sources are searched (recursively) in `src/main/c` by default, and their respective objects are compiled and stored in `target/objects`. Targets (executables and libraries) produced during the linking goal are placed in `target/natives`.

note: arguments are split on spaces, so adding arguments that point to directories with spaces could be difficult (string encapsulation is not parsed)

liscense: GPLv3