Skip to content

Commit

Permalink
Support Apple Silicon
Browse files Browse the repository at this point in the history
  • Loading branch information
bertfrees committed Apr 30, 2024
1 parent 6786715 commit 4295a94
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 19 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,27 @@ on:

jobs:
build-macos:
name: Build on macos
runs-on: macos-11
name: Build on macOS (x86_64 and aarch64)
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- macos-11 # x86_64
- macos-13-xlarge # aarch64

steps:
- uses: actions/checkout@v2
- name: Install build dependencies
run: |
brew update
brew install automake
brew install automake autoconf libtool
- uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '8'
cache: 'maven'
- name: Build and test the package
run: mvn test
run: make compile-macosx
- name: Store the build arctifacts
uses: actions/upload-artifact@v3
with:
Expand Down
42 changes: 28 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,49 @@ MVN := mvn
COMPOSE := docker-compose
VERSION := $(shell xmllint --xpath "/*/*[local-name()='version']/text()" pom.xml)

TARGET_NAR_LINUX_32 := $(addprefix target/nar/louis-$(VERSION)-i386-Linux-gpp-,executable shared)
TARGET_NAR_LINUX_64 := $(addprefix target/nar/louis-$(VERSION)-amd64-Linux-gpp-,executable shared)
TARGET_NAR_MAC_32 := $(addprefix target/nar/louis-$(VERSION)-i386-MacOSX-gpp-,executable shared)
TARGET_NAR_MAC_64 := $(addprefix target/nar/louis-$(VERSION)-x86_64-MacOSX-gpp-,executable shared)
TARGET_NAR_WIN_32 := $(addprefix target/nar/louis-$(VERSION)-i686-w64-mingw32-gpp-,executable shared)
TARGET_NAR_WIN_64 := $(addprefix target/nar/louis-$(VERSION)-x86_64-w64-mingw32-gpp-,executable shared)
TARGET_NAR_LINUX_32 := $(addprefix target/nar/louis-$(VERSION)-i386-Linux-gpp-,executable shared)
TARGET_NAR_LINUX_64 := $(addprefix target/nar/louis-$(VERSION)-amd64-Linux-gpp-,executable shared)
TARGET_NAR_MAC_32 := $(addprefix target/nar/louis-$(VERSION)-i386-MacOSX-gpp-,executable shared)
TARGET_NAR_MAC_X64 := $(addprefix target/nar/louis-$(VERSION)-x86_64-MacOSX-gpp-,executable shared)
TARGET_NAR_MAC_ARM64 := $(addprefix target/nar/louis-$(VERSION)-aarch64-MacOSX-gpp-,executable shared)
TARGET_NAR_WIN_32 := $(addprefix target/nar/louis-$(VERSION)-i686-w64-mingw32-gpp-,executable shared)
TARGET_NAR_WIN_64 := $(addprefix target/nar/louis-$(VERSION)-x86_64-w64-mingw32-gpp-,executable shared)

all : compile-linux compile-macosx compile-windows
all : compile-linux compile-windows
compile-linux : $(TARGET_NAR_LINUX_32) $(TARGET_NAR_LINUX_64)
compile-windows : $(TARGET_NAR_WIN_32) $(TARGET_NAR_WIN_64)

ifeq ($(shell uname -s),Darwin)
all : compile-macosx
ifeq ($(shell uname -m),x86_64)
compile-macosx : $(TARGET_NAR_MAC_X64)
else
compile-macosx : $(TARGET_NAR_MAC_ARM64)
endif
endif

clean :
$(MVN) clean

compile-linux : $(TARGET_NAR_LINUX_32) $(TARGET_NAR_LINUX_64)
compile-macosx : $(TARGET_NAR_MAC_64)
compile-windows : $(TARGET_NAR_WIN_32) $(TARGET_NAR_WIN_64)

$(TARGET_NAR_LINUX_32) :
$(COMPOSE) run debian $(MVN) test -Dos.arch=i386

$(TARGET_NAR_LINUX_64) :
$(COMPOSE) run debian $(MVN) test

$(TARGET_NAR_MAC_32) :
[[ "$$(uname)" == Darwin ]]
[[ "$$(uname -s)" == Darwin ]]
$(MVN) test -Dos.arch=i386

$(TARGET_NAR_MAC_64) :
[[ "$$(uname)" == Darwin && "$$(uname -m)" == x86_64 ]]
$(TARGET_NAR_MAC_X64) :
[[ "$$(uname -s)" == Darwin && "$$(uname -m)" == x86_64 ]]
$(MVN) test

$(TARGET_NAR_MAC_ARM64) :
[[ "$$(uname)" == Darwin && "$$(uname -m)" == arm64 ]]
$(MVN) test
cp target/nar/gnu/aarch64-MacOSX-gpp/target/lib/liblouis.dylib \
target/nar/louis-$(VERSION)-aarch64-MacOSX-gpp-shared/lib/aarch64-MacOSX-gpp/shared/

$(TARGET_NAR_WIN_32) :
$(COMPOSE) run debian $(MVN) test -Pcross-compile -Dhost.os=w64-mingw32 -Dos.arch=i686
Expand Down
5 changes: 4 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.liblouis</groupId>
<artifactId>louis</artifactId>
<version>3.27.0-p1</version>
<version>3.27.0-p2-SNAPSHOT</version>
<packaging>nar</packaging>
<name>liblouis-nar</name>
<description>liblouis packaged in a NAR (Native ARchive).</description>
Expand Down Expand Up @@ -87,6 +87,9 @@
<type>shared</type>
</library>
</libraries>
<linker>
<name>g++</name>
</linker>
</configuration>
<executions>
<!--
Expand Down

0 comments on commit 4295a94

Please sign in to comment.