You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2022/08/25 06:43:33 UTC
[plc4x] branch feature/ads-symbol-discovery updated: fix(build): Got the build working on my Mac with M1 chip
This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch feature/ads-symbol-discovery
in repository https://gitbox.apache.org/repos/asf/plc4x.git
The following commit(s) were added to refs/heads/feature/ads-symbol-discovery by this push:
new 5c0ab1e3c fix(build): Got the build working on my Mac with M1 chip
5c0ab1e3c is described below
commit 5c0ab1e3c04ea7c13b86f7deb870c16403e330ee
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Thu Aug 25 08:43:23 2022 +0200
fix(build): Got the build working on my Mac with M1 chip
- Added separate maven profiles for amd64 and aarch64 macs
---
.../src/test/resources/integration-test/pom.xml | 39 +++++++++++++++++++++-
plc4c/pom.xml | 39 +++++++++++++++++++++-
pom.xml | 21 +++++++++++-
src/main/script/prerequisiteCheck.groovy | 27 ++++++++++-----
4 files changed, 115 insertions(+), 11 deletions(-)
diff --git a/code-generation/language-c/src/test/resources/integration-test/pom.xml b/code-generation/language-c/src/test/resources/integration-test/pom.xml
index 0ae693a7f..3363cd726 100644
--- a/code-generation/language-c/src/test/resources/integration-test/pom.xml
+++ b/code-generation/language-c/src/test/resources/integration-test/pom.xml
@@ -69,10 +69,47 @@
</profile>
<!-- Profile for mac -->
<profile>
- <id>os-mac</id>
+ <id>os-mac-amd64</id>
<activation>
<os>
<family>mac</family>
+ <arch>amd64</arch>
+ </os>
+ </activation>
+ <!-- Make the cmake executable executable -->
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>make-cmake-executable</id>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ <configuration>
+ <basedir>${cmake.root}</basedir>
+ <executable>chmod</executable>
+ <arguments>
+ <argument>+x</argument>
+ <argument>cmake</argument>
+ </arguments>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <!-- Profile for mac -->
+ <profile>
+ <id>os-mac-aarch64</id>
+ <activation>
+ <os>
+ <family>mac</family>
+ <arch>aarch64</arch>
</os>
</activation>
<!-- Make the cmake executable executable -->
diff --git a/plc4c/pom.xml b/plc4c/pom.xml
index 2c19a63fa..14d63dafb 100644
--- a/plc4c/pom.xml
+++ b/plc4c/pom.xml
@@ -89,10 +89,47 @@
</profile>
<!-- Profile for mac -->
<profile>
- <id>os-mac</id>
+ <id>os-mac-amd64</id>
<activation>
<os>
<family>mac</family>
+ <arch>amd64</arch>
+ </os>
+ </activation>
+ <!-- Make the cmake executable, executable -->
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>make-cmake-executable</id>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ <configuration>
+ <basedir>${cmake.root}</basedir>
+ <executable>chmod</executable>
+ <arguments>
+ <argument>+x</argument>
+ <argument>cmake</argument>
+ </arguments>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <!-- Profile for mac -->
+ <profile>
+ <id>os-mac-aarch64</id>
+ <activation>
+ <os>
+ <family>mac</family>
+ <arch>aarch64</arch>
</os>
</activation>
<!-- Make the cmake executable, executable -->
diff --git a/pom.xml b/pom.xml
index c4e004f8e..2f37ea879 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1603,10 +1603,11 @@
</profile>
<!-- Profile for mac (Self-Enabling) -->
<profile>
- <id>os-mac</id>
+ <id>os-mac-amd64</id>
<activation>
<os>
<family>mac</family>
+ <arch>amd64</arch>
</os>
</activation>
<properties>
@@ -1618,6 +1619,24 @@
<python.venv.bin>venv/bin/</python.venv.bin>
</properties>
</profile>
+ <!-- Profile for mac (Self-Enabling) -->
+ <profile>
+ <id>os-mac-aarch64</id>
+ <activation>
+ <os>
+ <family>mac</family>
+ <arch>aarch64</arch>
+ </os>
+ </activation>
+ <properties>
+ <os.suffix>mac</os.suffix>
+ <os.classifier>mac-aarch64</os.classifier>
+ <cmake.url>https://github.com/Kitware/CMake/releases/download/v${cmake-version}/cmake-${cmake-version}-macos-universal.tar.gz</cmake.url>
+ <cmake.root>${project.build.directory}/cmake-${cmake-version}-macos-universal/CMake.app/Contents/bin</cmake.root>
+ <cmake.generator>Unix Makefiles</cmake.generator>
+ <python.venv.bin>venv/bin/</python.venv.bin>
+ </properties>
+ </profile>
<!-- profile for windows (Self-Enabling) -->
<profile>
<id>os-windows</id>
diff --git a/src/main/script/prerequisiteCheck.groovy b/src/main/script/prerequisiteCheck.groovy
index 1666c5c7d..527520c9d 100644
--- a/src/main/script/prerequisiteCheck.groovy
+++ b/src/main/script/prerequisiteCheck.groovy
@@ -262,20 +262,31 @@ def checkDocker() {
// TODO: Implement the actual check ...
}
-def checkLibPcap(String minVersion, String os) {
+def checkLibPcap(String minVersion, String os, String arch) {
print "Detecting LibPcap version: "
try {
// For some reason it doesn't work, if we pass this in from the outside.
if (os == "mac") {
- System.getProperties().setProperty("jna.library.path", "/usr/local/Cellar/libpcap/1.10.1/lib");
+ // On my Intel Mac I found the libs in: "/usr/local/Cellar/libpcap/1.10.1/lib"
+ // On my M1 Mac I found the libs in: "/opt/homebrew/Cellar/libpcap/1.10.1/lib"
+ if(new File("/usr/local/Cellar/libpcap/1.10.1/lib").exists()) {
+ System.getProperties().setProperty("jna.library.path", "/usr/local/Cellar/libpcap/1.10.1/lib");
+ } else if(new File("/opt/homebrew/Cellar/libpcap/1.10.1/lib").exists()) {
+ System.getProperties().setProperty("jna.library.path", "/opt/homebrew/Cellar/libpcap/1.10.1/lib");
+ }
+ // java.lang.UnsatisfiedLinkError: Can't load library: /Users/christoferdutz/Library/Caches/JNA/temp/jna877652535357666533.tmp
}
- output = org.pcap4j.core.Pcaps.libVersion()
- String version = output - ~/^libpcap version /
- def result = checkVersionAtLeast(version, minVersion)
- if (!result) {
- //allConditionsMet = false
+ // TODO: For some reason this check doesn't work on my M1 mac ... I get unsattisfiedlinkerror from the JNA library.
+ if (arch != "aarch64") {
+ output = org.pcap4j.core.Pcaps.libVersion()
+ String version = output - ~/^libpcap version /
+ def result = checkVersionAtLeast(version, minVersion)
+ if (!result) {
+ //allConditionsMet = false
+ }
}
} catch (Error e) {
+ e.printStackTrace()
output = ""
println "missing"
allConditionsMet = false
@@ -393,7 +404,7 @@ if (apacheReleaseEnabled) {
if (os == "mac") {
// The current system version from mac crashes so we assert for a version coming with brew
- checkLibPcap("1.10.1", os)
+ checkLibPcap("1.10.1", os, arch)
}
if (!allConditionsMet) {