Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crosscompile #27

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
343 changes: 232 additions & 111 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,129 +48,250 @@
<name>Jigawatts</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.includes>${env.JAVA_HOME}</java.includes>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.includes>${env.JAVA_HOME}</java.includes>
</properties>

<dependencies>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.7.0</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<compilerVersion>8</compilerVersion>
<source>8</source>
<target>8</target>
</configuration>
<executions>
<execution>
<id>header-generation</id>
<phase>process-sources</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<compilerArgs>
<arg>-h</arg>
<arg>${project.build.directory}/native/javah</arg>
</compilerArgs>
<includes>
<include>com/redhat/jigawatts/Jigawatts.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<!-- TODO this only needed when printf is used in native code; can be remove once its gone -->
<forkNode implementation="org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory"/>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>compile-cpp</id>
<goals>
<goal>exec</goal>
</goals>
<phase>process-classes</phase>
<profiles>
<profile>
<id>natives</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>compile-cpp</id>
<goals>
<goal>exec</goal>
</goals>
<phase>process-classes</phase>
<configuration>
<executable>gcc</executable>
<arguments>
<argument>-v</argument>
<argument>-shared</argument>
<argument>-fPIC</argument>
<argument>-I${java.includes}/include</argument>
<argument>-I${java.includes}/include/linux</argument>
<argument>-I/usr/lib64/</argument>
<argument>-I/usr/include/criu</argument>
<argument>-I${project.build.directory}/native/javah</argument>
<argument>-lcriu</argument>
<argument>-o${project.build.outputDirectory}/libJigawatts.so</argument>
<argument>${project.basedir}/src/main/cpp/com_redhat_jigawatts_Jigawatts.cpp
</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>crosscompile</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>cross-compile-cpp-aarch64</id>
<goals>
<goal>exec</goal>
</goals>
<phase>process-classes</phase>
<configuration>
<!-- may not work under root!-->
<executable>aarch64-linux-gnu-gcc
</executable><!-- dnf install gcc-c++-aarch64-linux-gnu gcc-aarch64-linux-gnu -->
<arguments>
<argument>-v</argument>
<argument>-shared</argument>
<!--<argument>-static</argument> ???? can criu be static ????-->
<!-- mock -r fedora-35-aarch64 -install glibc-devel glibc-static criu-devel -->
<argument>--sysroot=/var/lib/mock/fedora-35-aarch64/root/</argument>
<argument>-fPIC</argument>
<argument>-I${java.includes}/include</argument>
<argument>-I${java.includes}/include/linux</argument>
<argument>-I/usr/lib64/</argument>
<argument>-I/usr/include/criu</argument>
<argument>-I${project.build.directory}/native/javah</argument>
<argument>-Lcriu</argument>
<argument>-o${project.build.outputDirectory}/libJigawatts_aarch64.so</argument>
<argument>${project.basedir}/src/main/cpp/com_redhat_jigawatts_Jigawatts.cpp
</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>cross-compile-cpp-ppc64le</id>
<goals>
<goal>exec</goal>
</goals>
<phase>process-classes</phase>
<configuration>
<!-- may not work under root!-->
<executable>ppc64le-linux-gnu-gcc
</executable><!-- dnf install gcc-c++-ppc64le-linux-gnu gcc-ppc64le-linux-gnu -->
<arguments>
<argument>-v</argument>
<argument>-shared</argument>
<!--<argument>-static</argument> ???? can criu be static ????-->
<!-- mock -r fedora-35-ppc64le -install glibc-devel glibc-static criu-devel -->
<argument>--sysroot=/var/lib/mock/fedora-35-ppc64le/root/</argument>
<argument>-fPIC</argument>
<argument>-I${java.includes}/include</argument>
<argument>-I${java.includes}/include/linux</argument>
<argument>-I/usr/lib64/</argument>
<argument>-I/usr/include/criu</argument>
<argument>-I${project.build.directory}/native/javah</argument>
<argument>-Lcriu</argument>
<argument>-o${project.build.outputDirectory}/libJigawatts_ppc64le.so</argument>
<argument>${project.basedir}/src/main/cpp/com_redhat_jigawatts_Jigawatts.cpp
</argument>
</arguments>
</configuration>
</execution>
<execution>
<!-- this may sound like nonsense, but the goal is to build against same os as ppc and aarch-->
<id>cross-compile-cpp-x86_64</id>
<goals>
<goal>exec</goal>
</goals>
<phase>process-classes</phase>
<configuration>
<!-- may not work under root!-->
<executable>gcc</executable><!-- dnf install gcc-c++ gcc -->
<arguments>
<argument>-v</argument>
<argument>-shared</argument>
<!--<argument>-static</argument> ???? can criu be static ????-->
<!-- mock -r fedora-35-x86_64 -install glibc-devel glibc-static criu-devel -->
<argument>--sysroot=/var/lib/mock/fedora-35-x86_64/root/</argument>
<argument>-fPIC</argument>
<argument>-I${java.includes}/include</argument>
<argument>-I${java.includes}/include/linux</argument>
<argument>-I/usr/lib64/</argument>
<argument>-I/usr/include/criu</argument>
<argument>-I${project.build.directory}/native/javah</argument>
<argument>-Lcriu</argument>
<argument>-o${project.build.outputDirectory}/libJigawatts_x86_64.so</argument>
<argument>${project.basedir}/src/main/cpp/com_redhat_jigawatts_Jigawatts.cpp
</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>java</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<compilerVersion>8</compilerVersion>
<source>8</source>
<target>8</target>
</configuration>
<executions>
<execution>
<id>header-generation</id>
<phase>process-sources</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<compilerArgs>
<arg>-h</arg>
<arg>${project.build.directory}/native/javah</arg>
</compilerArgs>
<includes>
<include>com/redhat/jigawatts/Jigawatts.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<!-- TODO this only needed when printf is used in native code; can be remove once its gone -->
<forkNode
implementation="org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory"/>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<id>jigawatts</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>jigawatts</finalName>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<executable>gcc</executable>
<arguments>
<argument>-v</argument>
<argument>-shared</argument>
<argument>-fPIC</argument>
<argument>-I${java.includes}/include</argument>
<argument>-I${java.includes}/include/linux</argument>
<argument>-I/usr/lib64/</argument>
<argument>-I/usr/include/criu</argument>
<argument>-I${project.build.directory}/native/javah</argument>
<argument>-lcriu</argument>
<argument>-o${project.build.outputDirectory}/libJigawatts.so</argument>
<argument>${project.basedir}/src/main/cpp/com_redhat_jigawatts_Jigawatts.cpp</argument>
</arguments>
<filesets>
<fileset>
<directory>src/test/resources</directory>
<includes>
<include>jigawatts/*</include>
<include>1*</include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<id>jigawatts</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<finalName>jigawatts</finalName>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<filesets>
<fileset>
<directory>src/test/resources</directory>
<includes>
<include>jigawatts/*</include>
<include>1*</include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<configuration>
</configuration>
</plugin>
</plugins>
</build>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Loading