Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #21 from ktgw0316/m1
Browse files Browse the repository at this point in the history
Support build on Apple Silicon m1 (arm64) machine
  • Loading branch information
ktgw0316 committed Jan 29, 2021
2 parents fc0dbd9 + 10a15d7 commit dffefc0
Show file tree
Hide file tree
Showing 60 changed files with 187 additions and 4,448 deletions.
9 changes: 4 additions & 5 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: 4.2.2.{build}-{branch}

image:
- macos
- Visual Studio 2019
- macos-mojave
- Ubuntu2004

clone_depth: 1
Expand Down Expand Up @@ -41,16 +41,16 @@ for:
build_script:
- cmd: bash -lc "MINGW_DIR=/c/$MINGW64_PATH ant -f $ANT_SCRIPT build-installer"
- cmd: bash -lc "ant -f $ANT_SCRIPT clean-native"
- cmd: bash -lc "TARGET=i686 MINGW_DIR=/c/$MINGW32_PATH ant -f $ANT_SCRIPT -Doffline=true build-installer"
- cmd: bash -lc "TARGET_ARCH=i686 MINGW_DIR=/c/$MINGW32_PATH ant -f $ANT_SCRIPT -Doffline=true build-installer"

artifacts:
- path: 'windows/LightZone_Installer_*.exe'
name: windows installer

-
matrix:
only:
- image: macos-mojave
- image: macos

init:
- sh: export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
Expand Down Expand Up @@ -81,4 +81,3 @@ for:

build_script:
- sh: ant -f linux/build.xml -Doffline=true

2 changes: 1 addition & 1 deletion lightcrafts/jnisrc/EDISON/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SEGM_INCLUDES:= segm/tdef.h segm/RAList.h segm/ms.h segm/msImageProcessor.h seg
SEGM_LDFLAGS:= $(PLATFORM_LDFLAGS)

ifeq ($(UNIVERSAL),1)
$(TARGET_PPC) $(TARGET_X86): $(SEGM_SOURCE) $(SEGM_INCLUDES)
$(TARGET_ARM) $(TARGET_X86): $(SEGM_SOURCE) $(SEGM_INCLUDES)
-$(MKDIR) $(TARGET_DIR)
$(CC_LINK) $(CFLAGS) $(INCLUDES) $(SEGM_LDFLAGS) -o $@ $(SEGM_SOURCE)
ifeq ($(PLATFORM),MacOSX)
Expand Down
57 changes: 38 additions & 19 deletions lightcrafts/jnisrc/include/dvec.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,16 @@ class I64vec2 : public M128
I64vec2& operator -=(const I64vec2 &a) { return *this = (I64vec2) _mm_sub_epi64(vec,a); }

I64vec2 operator<<(const I64vec2 &a) { return _mm_sll_epi64(vec,a); }
I64vec2 operator<<(int count) { return _mm_slli_epi64(vec,count); }
I64vec2& operator<<=(const I64vec2 &a) { return *this = (I64vec2) _mm_sll_epi64(vec,a); }
I64vec2& operator<<=(int count) { return *this = (I64vec2) _mm_slli_epi64(vec,count); }
I64vec2 operator>>(const I64vec2 &a) { return _mm_srl_epi64(vec,a); }
I64vec2 operator>>(int count) { return _mm_srli_epi64(vec,count); }
I64vec2& operator>>=(const I64vec2 &a) { return *this = (I64vec2) _mm_srl_epi64(vec,a); }

#if !defined __clang__ && !defined __aarch64__
I64vec2 operator<<(int count) { return _mm_slli_epi64(vec,count); }
I64vec2& operator<<=(int count) { return *this = (I64vec2) _mm_slli_epi64(vec,count); }
I64vec2 operator>>(int count) { return _mm_srli_epi64(vec,count); }
I64vec2& operator>>=(int count) { return *this = (I64vec2) _mm_srli_epi64(vec,count); }
#endif

const int64_t& operator[](int i)const
{
Expand Down Expand Up @@ -156,10 +159,12 @@ class I32vec4 : public M128
I32vec4& operator -=(const I32vec4 &a) { return *this = (I32vec4)_mm_sub_epi32(vec,a); }

I32vec4 operator<<(const I32vec4 &a) { return _mm_sll_epi32(vec,a); }
I32vec4 operator<<(int count) { return _mm_slli_epi32(vec,count); }
I32vec4& operator<<=(const I32vec4 &a) { return *this = (I32vec4)_mm_sll_epi32(vec,a); }
I32vec4& operator<<=(int count) { return *this = (I32vec4)_mm_slli_epi32(vec,count); }

#if !defined __clang__ && !defined __aarch64__
I32vec4 operator<<(int count) { return _mm_slli_epi32(vec,count); }
I32vec4& operator<<=(int count) { return *this = (I32vec4)_mm_slli_epi32(vec,count); }
#endif
};

inline I32vec4 cmpeq(const I32vec4 &a,const I32vec4 &b) { return _mm_cmpeq_epi32(a,b); }
Expand Down Expand Up @@ -191,14 +196,16 @@ class Is32vec4 : public I32vec4
Is32vec4& operator -=(const I32vec4 &a) { return *this = (Is32vec4)_mm_sub_epi32(vec,a); }

Is32vec4 operator<<(const M128 &a) { return _mm_sll_epi32(vec,a); }
Is32vec4 operator<<(int count) { return _mm_slli_epi32(vec,count); }
Is32vec4& operator<<=(const M128 &a) { return *this = (Is32vec4)_mm_sll_epi32(vec,a); }
Is32vec4& operator<<=(int count) { return *this = (Is32vec4)_mm_slli_epi32(vec,count); }

Is32vec4 operator>>(const M128 &a) { return _mm_sra_epi32(vec,a); }
Is32vec4 operator>>(int count) { return _mm_srai_epi32(vec,count); }
Is32vec4& operator>>=(const M128 &a) { return *this = (Is32vec4) _mm_sra_epi32(vec,a); }

#if !defined __clang__ && !defined __aarch64__
Is32vec4 operator<<(int count) { return _mm_slli_epi32(vec,count); }
Is32vec4& operator<<=(int count) { return *this = (Is32vec4)_mm_slli_epi32(vec,count); }
Is32vec4 operator>>(int count) { return _mm_srai_epi32(vec,count); }
Is32vec4& operator>>=(int count) { return *this = (Is32vec4) _mm_srai_epi32(vec,count); }
#endif

#if defined(_ENABLE_VEC_DEBUG)

Expand Down Expand Up @@ -256,13 +263,16 @@ class Iu32vec4 : public I32vec4
Iu32vec4& operator -=(const I32vec4 &a) { return *this = (Iu32vec4)_mm_sub_epi32(vec,a); }

Iu32vec4 operator<<(const M128 &a) { return _mm_sll_epi32(vec,a); }
Iu32vec4 operator<<(int count) { return _mm_slli_epi32(vec,count); }
Iu32vec4& operator<<=(const M128 &a) { return *this = (Iu32vec4)_mm_sll_epi32(vec,a); }
Iu32vec4& operator<<=(int count) { return *this = (Iu32vec4)_mm_slli_epi32(vec,count); }
Iu32vec4 operator>>(const M128 &a) { return _mm_srl_epi32(vec,a); }
Iu32vec4 operator>>(int count) { return _mm_srli_epi32(vec,count); }
Iu32vec4& operator>>=(const M128 &a) { return *this = (Iu32vec4) _mm_srl_epi32(vec,a); }

#if !defined __clang__ && !defined __aarch64__
Iu32vec4& operator>>=(int count) { return *this = (Iu32vec4) _mm_srli_epi32(vec,count); }
Iu32vec4 operator<<(int count) { return _mm_slli_epi32(vec,count); }
Iu32vec4& operator<<=(int count) { return *this = (Iu32vec4)_mm_slli_epi32(vec,count); }
Iu32vec4 operator>>(int count) { return _mm_srli_epi32(vec,count); }
#endif

#if defined(_ENABLE_VEC_DEBUG)

Expand Down Expand Up @@ -313,9 +323,12 @@ class I16vec8 : public M128
I16vec8& operator *=(const I16vec8 &a) { return *this = (I16vec8) _mm_mullo_epi16(vec,a); }

I16vec8 operator<<(const M128 &a) { return _mm_sll_epi16(vec,a); }
I16vec8 operator<<(int count) { return _mm_slli_epi16(vec,count); }
I16vec8& operator<<=(const M128 &a) { return *this = (I16vec8)_mm_sll_epi16(vec,a); }

#if !defined __clang__ && !defined __aarch64__
I16vec8& operator<<=(int count) { return *this = (I16vec8)_mm_slli_epi16(vec,count); }
I16vec8 operator<<(int count) { return _mm_slli_epi16(vec,count); }
#endif

};

Expand Down Expand Up @@ -355,14 +368,17 @@ class Is16vec8 : public I16vec8
Is16vec8& operator *=(const I16vec8 &a) { return *this = (Is16vec8) _mm_mullo_epi16(vec,a); }

Is16vec8 operator<<(const M128 &a) { return _mm_sll_epi16(vec,a); }
Is16vec8 operator<<(int count) { return _mm_slli_epi16(vec,count); }
Is16vec8& operator<<=(const M128 &a) { return *this = (Is16vec8)_mm_sll_epi16(vec,a); }
Is16vec8& operator<<=(int count) { return *this = (Is16vec8)_mm_slli_epi16(vec,count); }

Is16vec8 operator>>(const M128 &a) { return _mm_sra_epi16(vec,a); }
Is16vec8 operator>>(int count) { return _mm_srai_epi16(vec,count); }
Is16vec8& operator>>=(const M128 &a) { return *this = (Is16vec8)_mm_sra_epi16(vec,a); }

#if !defined __clang__ && !defined __aarch64__
Is16vec8 operator<<(int count) { return _mm_slli_epi16(vec,count); }
Is16vec8& operator<<=(int count) { return *this = (Is16vec8)_mm_slli_epi16(vec,count); }
Is16vec8 operator>>(int count) { return _mm_srai_epi16(vec,count); }
Is16vec8& operator>>=(int count) { return *this = (Is16vec8)_mm_srai_epi16(vec,count); }
#endif

#if defined(_ENABLE_VEC_DEBUG)

Expand Down Expand Up @@ -440,13 +456,16 @@ class Iu16vec8 : public I16vec8
Iu16vec8& operator *=(const I16vec8 &a) { return *this = (Iu16vec8) _mm_mullo_epi16(vec,a); }

Iu16vec8 operator<<(const M128 &a) { return _mm_sll_epi16(vec,a); }
Iu16vec8 operator<<(int count) { return _mm_slli_epi16(vec,count); }
Iu16vec8& operator<<=(const M128 &a) { return *this = (Iu16vec8)_mm_sll_epi16(vec,a); }
Iu16vec8& operator<<=(int count) { return *this = (Iu16vec8)_mm_slli_epi16(vec,count); }
Iu16vec8 operator>>(const M128 &a) { return _mm_srl_epi16(vec,a); }
Iu16vec8 operator>>(int count) { return _mm_srli_epi16(vec,count); }
Iu16vec8& operator>>=(const M128 &a) { return *this = (Iu16vec8) _mm_srl_epi16(vec,a); }

#if !defined __clang__ && !defined __aarch64__
Iu16vec8 operator<<(int count) { return _mm_slli_epi16(vec,count); }
Iu16vec8& operator<<=(int count) { return *this = (Iu16vec8)_mm_slli_epi16(vec,count); }
Iu16vec8 operator>>(int count) { return _mm_srli_epi16(vec,count); }
Iu16vec8& operator>>=(int count) { return *this = (Iu16vec8) _mm_srli_epi16(vec,count); }
#endif

#if defined(_ENABLE_VEC_DEBUG)

Expand Down
40 changes: 20 additions & 20 deletions lightcrafts/jnisrc/jni.mk
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
# platform only, the makefile can replace "EXTRA" with one of "MACOSX",
# "WINDOWS" or "LINUX".
#
# In addition to the above, there are also JNI_PPC_CFLAGS, JNI_PPC_DEFINES, and
# JNI_PPC_LDFLAGS for PowerPC-specific directives, and JNI_X86_CFLAGS,
# In addition to the above, there are also JNI_ARM_CFLAGS, JNI_ARM_DEFINES, and
# JNI_ARM_LDFLAGS for arm64-specific directives, and JNI_X86_CFLAGS,
# JNI_X86_DEFINES, and JNI_X86_LDFLAGS for Intel-specific directives.
#
# If a makefile needs to override how the TARGET is build, it can do:
Expand All @@ -57,7 +57,7 @@ COMMON_DIR:= $(ROOT)/lightcrafts
include $(COMMON_DIR)/mk/platform.mk

ifeq ($(UNIVERSAL),1)
CFLAGS_PPC:= $(PLATFORM_CFLAGS_PPC) $(JNI_EXTRA_CFLAGS)
CFLAGS_ARM:= $(PLATFORM_CFLAGS_ARM) $(JNI_EXTRA_CFLAGS)
CFLAGS_X86:= $(PLATFORM_CFLAGS_X86) $(JNI_EXTRA_CFLAGS)
else
CFLAGS:= $(PLATFORM_CFLAGS) $(JNI_EXTRA_CFLAGS)
Expand All @@ -82,7 +82,7 @@ TARGET_DIR:= ../../products
ifeq ($(PLATFORM),MacOSX)
DEFINES+= $(JNI_MACOSX_DEFINES)
INCLUDES:= $(MACOSX_ISYSROOT) $(INCLUDES) $(JNI_MACOSX_INCLUDES)
LDFLAGS+= -dynamiclib -framework JavaVM $(JNI_MACOSX_LDFLAGS)
LDFLAGS+= -dynamiclib $(JNI_MACOSX_LDFLAGS)
LINK+= $(JNI_MACOSX_LINK)
ifdef JNI_MACOSX_DYLIB
JNILIB_EXT:= $(DYLIB_EXT)
Expand All @@ -93,15 +93,15 @@ ifeq ($(PLATFORM),MacOSX)
endif
endif
ifeq ($(UNIVERSAL),1)
CFLAGS_PPC+= $(JNI_MACOSX_CFLAGS) $(JNI_PPC_CFLAGS)
CFLAGS_ARM+= $(JNI_MACOSX_CFLAGS) $(JNI_ARM_CFLAGS)
CFLAGS_X86+= $(JNI_MACOSX_CFLAGS) $(JNI_X86_CFLAGS)
else
CFLAGS+= $(JNI_MACOSX_CFLAGS)
ifeq ($(PROCESSOR),powerpc)
CFLAGS+= $(JNI_PPC_CFLAGS)
DEFINES+= $(JNI_PPC_DEFINES)
LDFLAGS+= $(JNI_PPC_LDFLAGS)
LINK+= $(JNI_PPC_LINK)
ifeq ($(PROCESSOR),arm64)
CFLAGS+= $(JNI_ARM_CFLAGS)
DEFINES+= $(JNI_ARM_DEFINES)
LDFLAGS+= $(JNI_ARM_LDFLAGS)
LINK+= $(JNI_ARM_LINK)
endif
ifeq ($(PROCESSOR),x86_64)
CFLAGS+= $(JNI_X86_CFLAGS)
Expand Down Expand Up @@ -147,9 +147,9 @@ DEFINES+= -DDEBUG
endif

ifeq ($(UNIVERSAL),1)
CFLAGS_PPC+= $(DEFINES) $(JNI_PPC_DEFINES)
CFLAGS_ARM+= $(DEFINES) $(JNI_ARM_DEFINES)
CFLAGS_X86+= $(DEFINES) $(JNI_X86_DEFINES)
INCLUDES_PPC:= $(INCLUDES) $(JNI_PPC_INCLUDES)
INCLUDES_ARM:= $(INCLUDES) $(JNI_ARM_INCLUDES)
INCLUDES_X86:= $(INCLUDES) $(JNI_X86_INCLUDES)
else
CFLAGS+= $(DEFINES)
Expand All @@ -174,7 +174,7 @@ endif
# These are always defined even when UNIVERSAL is not set so a "make disclean"
# will remove them.
##
TARGET_PPC:= $(JNILIB_PREFIX)$(TARGET_BASE)-ppc$(JNILIB_EXT)
TARGET_ARM:= $(JNILIB_PREFIX)$(TARGET_BASE)-arm64$(JNILIB_EXT)
TARGET_X86:= $(JNILIB_PREFIX)$(TARGET_BASE)-x86$(JNILIB_EXT)

##
Expand Down Expand Up @@ -213,21 +213,21 @@ endif

ifeq ($(UNIVERSAL),1)

$(TARGET): $(TARGET_PPC) $(TARGET_X86)
$(TARGET): $(TARGET_ARM) $(TARGET_X86)
-$(MKDIR) $(TARGET_DIR)
$(LIPO) -create $(TARGET_PPC) $(TARGET_X86) -output $@
$(LIPO) -create $(TARGET_ARM) $(TARGET_X86) -output $@
ifeq ($(PLATFORM),MacOSX)
cp -p $@ $(TARGET_DIR)
endif

ifndef JNI_MANUAL_TARGET
ifdef USE_AR_RANLIB
$(TARGET_PPC): $(OBJECTS_PPC) $(BUILT_LIBS)
ar -rc $@ *-ppc.o
$(TARGET_ARM): $(OBJECTS_ARM) $(BUILT_LIBS)
ar -rc $@ *-arm64.o
-ranlib $@
else
$(TARGET_PPC): $(OBJECTS_PPC) $(LOCAL_RANLIBS) $(BUILT_LIBS)
$(CC_LINK) $(CFLAGS_PPC) $(LDFLAGS) -o $@ *-ppc.o $(LINK)
$(TARGET_ARM): $(OBJECTS_ARM) $(LOCAL_RANLIBS) $(BUILT_LIBS)
$(CC_LINK) $(CFLAGS_ARM) $(LDFLAGS) -o $@ *-arm64.o $(LINK)
endif

ifdef USE_AR_RANLIB
Expand Down Expand Up @@ -274,6 +274,6 @@ clean:
$(RM) *.o .*.d javah *-ranlib.a *.dSYM *.res $(TARGET).dSYM $(JNI_EXTRA_CLEAN)

distclean mostlyclean: clean
$(RM) $(TARGET) $(TARGET_IMPLIB) $(TARGET_PPC) $(TARGET_X86) $(POST_TARGET) $(JNI_EXTRA_DISTCLEAN)
$(RM) $(TARGET) $(TARGET_IMPLIB) $(TARGET_ARM) $(TARGET_X86) $(POST_TARGET) $(JNI_EXTRA_DISTCLEAN)

# vim:set noet sw=8 ts=8:
4 changes: 0 additions & 4 deletions lightcrafts/jnisrc/jpeg/GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
ROOT:= ../../..
COMMON_DIR:= $(ROOT)/lightcrafts
include $(COMMON_DIR)/mk/platform.mk

##
# Build rules
##
Expand Down
9 changes: 2 additions & 7 deletions lightcrafts/jnisrc/jpeg/lcjpeg.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
ROOT:= ../../..
COMMON_DIR:= $(ROOT)/lightcrafts
include $(COMMON_DIR)/mk/platform.mk

HIGH_PERFORMANCE:= 1

TARGET_BASE:= LCJPEG
Expand All @@ -10,9 +6,7 @@ TARGET_BASE:= LCJPEG
#DEBUG:= true

JNI_EXTRA_CFLAGS:= -fexceptions -std=c++0x
JNI_EXTRA_INCLUDES:= $(shell $(PKGCFG) --cflags libjpeg)
JNI_EXTRA_LINK:= $(shell $(PKGCFG) --libs-only-l libjpeg)
JNI_EXTRA_LDFLAGS:= $(shell $(PKGCFG) --libs-only-L libjpeg)
JNI_EXTRA_PKGCFG:= libjpeg
JNI_WINDOWS_LINK:= -lLCJNI
JNI_LINUX_LINK:= -lLCJNI
JNI_MACOSX_LINK:= ../jniutils/libLCJNI.a
Expand All @@ -22,6 +16,7 @@ JNI_MACOSX_INCLUDES:= -I/usr/local/opt/jpeg-turbo/include
JAVAH_CLASSES:= com.lightcrafts.image.libs.LCJPEGReader \
com.lightcrafts.image.libs.LCJPEGWriter

ROOT:= ../../..
include ../jni.mk

# vim:set noet sw=8 ts=8:
12 changes: 1 addition & 11 deletions lightcrafts/jnisrc/lensfun/GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
HIGH_PERFORMANCE:= 1

ROOT:= ../../..
COMMON_DIR:= $(ROOT)/lightcrafts
include $(COMMON_DIR)/mk/platform.mk

TARGET_BASE:= LCLENSFUN

JNI_EXTRA_CFLAGS:= -std=c++14
JNI_EXTRA_INCLUDES:= $(shell $(PKGCFG) --cflags lensfun)
JNI_EXTRA_LINK:= $(shell $(PKGCFG) --libs-only-l lensfun)
ifneq ($(PLATFORM),MacOSX)
JNI_EXTRA_LDFLAGS:= $(shell $(PKGCFG) --libs-only-L lensfun)
endif
JNI_MACOSX_INCLUDES:= -I/usr/local/include
JNI_MACOSX_LDFLAGS:= -L/usr/local/lib
JNI_EXTRA_PKGCFG:= lensfun

JAVAH_CLASSES:= com.lightcrafts.utils.Lensfun

Expand Down
4 changes: 0 additions & 4 deletions lightcrafts/jnisrc/tiff/GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
ROOT:= ../../..
COMMON_DIR:= $(ROOT)/lightcrafts
include $(COMMON_DIR)/mk/platform.mk

##
# Build rules
##
Expand Down
9 changes: 2 additions & 7 deletions lightcrafts/jnisrc/tiff/lctiff.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
ROOT:= ../../..
COMMON_DIR:= $(ROOT)/lightcrafts
include $(COMMON_DIR)/mk/platform.mk

HIGH_PERFORMANCE:= 1
ifeq ($(PLATFORM),MacOSX)
USE_ICC_HERE:= 1
Expand All @@ -12,9 +8,7 @@ TARGET_BASE:= LCTIFF
# Uncomment to compile in debug mode.
#DEBUG:= true

JNI_EXTRA_INCLUDES:= $(shell $(PKGCFG) --cflags libtiff-4)
JNI_EXTRA_LINK:= $(shell $(PKGCFG) --libs-only-l libtiff-4)
JNI_EXTRA_LDFLAGS:= $(shell $(PKGCFG) --libs-only-L libtiff-4)
JNI_EXTRA_PKGCFG:= libtiff-4
JNI_WINDOWS_LINK:= -Wl,-Bdynamic -lLCJNI -Wl,-Bstatic -lstdc++
JNI_LINUX_LINK:= -lLCJNI -lstdc++
JNI_MACOSX_LINK:= ../jniutils/libLCJNI.a
Expand All @@ -27,6 +21,7 @@ JAVAH_CLASSES:= com.lightcrafts.image.libs.LCTIFFCommon \
com.lightcrafts.image.libs.LCTIFFReader \
com.lightcrafts.image.libs.LCTIFFWriter

ROOT:= ../../..
include ../jni.mk

# vim:set noet sw=8 ts=8:
Loading

0 comments on commit dffefc0

Please sign in to comment.