Patch macOS build-script
This commit is contained in:
parent
98c040138b
commit
fdaabdc249
|
@ -15,43 +15,34 @@
|
|||
</condition>
|
||||
|
||||
<property name="sdk_path" value="Platforms/MacOSX.platform/Developer/SDKs"/>
|
||||
<property name="jvm_headers_path" value="System/Library/Frameworks/JavaVM.framework/Versions/A/Headers"/>
|
||||
<property name="jvm_headers_path" value="include"/>
|
||||
<property name="jvm_headers_path_md" value="${jvm_headers_path}/darwin"/>
|
||||
|
||||
<!-- Choose a JavaVM.framework -->
|
||||
<condition property="javavmroot" value="${developer_path}/${sdk_path}/MacOSX10.9.sdk">
|
||||
<!-- TODO: detect link version -->
|
||||
<!--<property name="macos_link_ver" value="10.5"/>-->
|
||||
<property name="macos_link_ver" value="10.9"/>
|
||||
|
||||
<condition property="javavmroot" value="${java.home}">
|
||||
<and>
|
||||
<not><isset property="javavmroot"/></not>
|
||||
<available file="${developer_path}/${sdk_path}/MacOSX10.9.sdk/${jvm_headers_path}" type="dir"/>
|
||||
<available file="${java.home}/${jvm_headers_path}" type="dir"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="javavmroot" value="${developer_path}/${sdk_path}/MacOSX10.8.sdk">
|
||||
</condition>
|
||||
<condition property="javavmroot" value="${env.JAVA_HOME}">
|
||||
<and>
|
||||
<not><isset property="javavmroot"/></not>
|
||||
<available file="${developer_path}/${sdk_path}/MacOSX10.8.sdk/${jvm_headers_path}" type="dir"/>
|
||||
<available file="${env.JAVA_HOME}/${jvm_headers_path}" type="dir"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="javavmroot" value="${developer_path}/${sdk_path}/MacOSX10.7.sdk">
|
||||
<and>
|
||||
<not><isset property="javavmroot"/></not>
|
||||
<available file="${developer_path}/${sdk_path}/MacOSX10.7.sdk/${jvm_headers_path}" type="dir"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="javavmroot" value="${developer_path}/${sdk_path}/MacOSX10.6.sdk">
|
||||
<and>
|
||||
<not><isset property="javavmroot"/></not>
|
||||
<available file="${developer_path}/${sdk_path}/MacOSX10.6.sdk/${jvm_headers_path}" type="dir"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="javavmroot" value=""> <!-- Old location -->
|
||||
<and>
|
||||
<not><isset property="javavmroot"/></not>
|
||||
<available file="/${jvm_headers_path}" type="dir"/>
|
||||
</and>
|
||||
</condition>
|
||||
</condition>
|
||||
|
||||
<!-- Choose a MacOSX SDK -->
|
||||
<property name="compiler" value="clang"/> <!-- Default to clang for 10.8 and up -->
|
||||
|
||||
<condition property="sdkroot" value="${developer_path}/${sdk_path}/MacOSX.sdk">
|
||||
<and>
|
||||
<not><isset property="sdkroot"/></not>
|
||||
<available file="${developer_path}/${sdk_path}/MacOSX.sdk" type="dir"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="sdkroot" value="${developer_path}/${sdk_path}/MacOSX10.9.sdk">
|
||||
<and>
|
||||
<not><isset property="sdkroot"/></not>
|
||||
|
@ -66,16 +57,21 @@
|
|||
</condition>
|
||||
|
||||
<!-- If we're on 10.7 or lower, use gcc instead of clang -->
|
||||
<condition property="compiler" value="clang">
|
||||
<and>
|
||||
<not><isset property="compiler"/></not>
|
||||
<available file="clang" filepath="${env.PATH}"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="compiler" value="gcc-4.2">
|
||||
<and>
|
||||
<not><isset property="sdkroot"/></not>
|
||||
<not><isset property="compiler"/></not>
|
||||
<available file="gcc-4.2" filepath="${env.PATH}"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="compiler" value="gcc">
|
||||
<and>
|
||||
<not><isset property="sdkroot"/></not>
|
||||
<not><available file="gcc-4.2" filepath="${env.PATH}"/></not>
|
||||
<not><isset property="compiler"/></not>
|
||||
<available file="gcc" filepath="${env.PATH}"/>
|
||||
</and>
|
||||
</condition>
|
||||
|
@ -111,7 +107,7 @@
|
|||
|
||||
<target name="compile" depends="init">
|
||||
<apply dir="${dstdir}" executable="${compiler}" os="Mac OS X" skipemptyfilesets="true" failonerror="true" dest="${dstdir}">
|
||||
<arg line="${cflags} -ObjC -O2 -Wall -Wunused -c -fPIC -I${javavmroot}/${jvm_headers_path} -I${native}/common -I${native}/common/opengl -I${native}/macosx"/>
|
||||
<arg line="${cflags} -ObjC -O2 -Wall -Wunused -c -fPIC -I${javavmroot}/${jvm_headers_path_md} -I${javavmroot}/${jvm_headers_path} -I${native}/common -I${native}/common/opengl -I${native}/macosx"/>
|
||||
<!-- Map from *.m and *.c to .o -->
|
||||
<mapper type="regexp" from="^(.*)\.(c|m)" to="\1.o"/>
|
||||
<fileset dir="${native}/macosx" includes="*.m"/>
|
||||
|
@ -133,16 +129,19 @@
|
|||
</condition>
|
||||
|
||||
<apply dir="${objdir}" parallel="true" executable="${compiler}" os="Mac OS X" failonerror="true" skipemptyfilesets="true">
|
||||
<arg line="${linkerflags} -exported_symbols_list ../lwjgl.symbols -dynamiclib -o ${libname} -framework Foundation -weak_framework AppKit -framework Carbon -framework OpenGL -framework QuartzCore -L${jdk_lib} -ljawt"/>
|
||||
<arg line="${linkerflags} -exported_symbols_list ../lwjgl.symbols -dynamiclib -o ${libname} -framework Foundation -weak_framework AppKit -framework Carbon -framework OpenGL -framework QuartzCore -L${jdk_lib} -ljawt -L${sdkroot}/usr/lib"/>
|
||||
<fileset dir="${objdir}" includes="*.o"/>
|
||||
</apply>
|
||||
</apply>
|
||||
<echo message="Linked library"/>
|
||||
<apply dir="${objdir}" executable="strip" os="Mac OS X" failonerror="true">
|
||||
<arg line="-S -X"/>
|
||||
<fileset dir="." file="${libname}"/>
|
||||
<fileset file="${libname}"/>
|
||||
</apply>
|
||||
<echo message="Stripped library"/>
|
||||
</target>
|
||||
|
||||
<target name="nativelibrary" depends="init">
|
||||
<echo message=" Java Home: ${java.home}"/>
|
||||
<echo message=" Compiler: ${compiler}"/>
|
||||
<echo message=" Mac OS SDK: ${sdkroot}"/>
|
||||
<echo message="JavaVM.framework: ${javavmroot}"/>
|
||||
|
@ -165,12 +164,12 @@
|
|||
<antcall target="compile">
|
||||
<param name="dstdir" location="i386"/>
|
||||
<param name="sdkroot" location="${universal_sdkroot}"/>
|
||||
<param name="cflags" value="${universal_flags} -arch i386 -mmacosx-version-min=10.5"/>
|
||||
<param name="cflags" value="${universal_flags} -arch i386 -mmacosx-version-min=${macos_link_ver}"/>
|
||||
</antcall>
|
||||
<antcall target="compile">
|
||||
<param name="dstdir" location="x86_64"/>
|
||||
<param name="sdkroot" location="${universal_sdkroot}"/>
|
||||
<param name="cflags" value="-isysroot ${x86_64_sdkroot} -arch x86_64 -mmacosx-version-min=10.5"/>
|
||||
<param name="cflags" value="-isysroot ${x86_64_sdkroot} -arch x86_64 -mmacosx-version-min=${macos_link_ver}"/>
|
||||
</antcall>
|
||||
<exec vmlauncher="true" executable="sh" output="lwjgl.symbols" failonerror="true">
|
||||
<arg path="../../platform_build/macosx_ant/build-symbol-list"/>
|
||||
|
@ -179,12 +178,12 @@
|
|||
<antcall target="link">
|
||||
<param name="objdir" location="i386"/>
|
||||
<param name="libname" value="liblwjgl-i386.dylib"/>
|
||||
<param name="linkerflags" value="${universal_flags} -arch i386 -mmacosx-version-min=10.5"/>
|
||||
<param name="linkerflags" value="${universal_flags} -arch i386 -mmacosx-version-min=${macos_link_ver}"/>
|
||||
</antcall>
|
||||
<antcall target="link">
|
||||
<param name="objdir" location="x86_64"/>
|
||||
<param name="libname" value="liblwjgl-i86_64.dylib"/>
|
||||
<param name="linkerflags" value="-isysroot ${x86_64_sdkroot} -arch x86_64 -mmacosx-version-min=10.5"/>
|
||||
<param name="linkerflags" value="-isysroot ${x86_64_sdkroot} -arch x86_64 -mmacosx-version-min=${macos_link_ver}"/>
|
||||
</antcall>
|
||||
<apply dir="." parallel="true" executable="lipo" os="Mac OS X" failonerror="true" skipemptyfilesets="true">
|
||||
<arg value="-create"/>
|
||||
|
@ -200,7 +199,7 @@
|
|||
<antcall target="compile">
|
||||
<param name="dstdir" location="x86_64"/>
|
||||
<param name="sdkroot" location="${sdkroot}"/>
|
||||
<param name="cflags" value="-isysroot ${sdkroot} -arch x86_64 -mmacosx-version-min=10.5"/>
|
||||
<param name="cflags" value="-isysroot ${sdkroot} -arch x86_64 -mmacosx-version-min=${macos_link_ver}"/>
|
||||
</antcall>
|
||||
<exec vmlauncher="true" executable="sh" output="lwjgl.symbols" failonerror="true">
|
||||
<arg path="../../platform_build/macosx_ant/build-symbol-list"/>
|
||||
|
@ -209,7 +208,7 @@
|
|||
<antcall target="link">
|
||||
<param name="objdir" location="x86_64"/>
|
||||
<param name="libname" value="liblwjgl-i86_64.dylib"/>
|
||||
<param name="linkerflags" value="-isysroot ${sdkroot} -arch x86_64 -mmacosx-version-min=10.5"/>
|
||||
<param name="linkerflags" value="-isysroot ${sdkroot} -arch x86_64 -mmacosx-version-min=${macos_link_ver}"/>
|
||||
</antcall>
|
||||
<apply dir="." parallel="true" executable="lipo" os="Mac OS X" failonerror="true" skipemptyfilesets="true">
|
||||
<arg value="-create"/>
|
||||
|
@ -219,4 +218,4 @@
|
|||
<fileset file="x86_64/liblwjgl-i86_64.dylib"/>
|
||||
</apply>
|
||||
</target>
|
||||
</project>
|
||||
</project>
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
|
||||
#include <jni.h>
|
||||
#ifdef __MACH__
|
||||
#include <JavaVM/jawt_md.h>
|
||||
#include <jawt_md.h>
|
||||
#else
|
||||
#include <jawt_md.h>
|
||||
#endif
|
||||
|
|
|
@ -117,7 +117,7 @@ typedef struct {
|
|||
|
||||
@interface GLLayer : CAOpenGLLayer {
|
||||
@public
|
||||
JAWT_MacOSXDrawingSurfaceInfo *macosx_dsi;
|
||||
JAWT_DrawingSurfaceInfo *macosx_dsi;
|
||||
JAWT_Rectangle canvasBounds;
|
||||
MacOSXWindowInfo *window_info;
|
||||
bool setViewport;
|
||||
|
|
|
@ -87,6 +87,25 @@ void extgl_Close(void)
|
|||
}
|
||||
}
|
||||
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
|
||||
size_t CGDisplayBitsPerPixel(CGDirectDisplayID display) {
|
||||
CGDisplayModeRef mode = CGDisplayCopyDisplayMode(display);
|
||||
size_t depth = 0;
|
||||
|
||||
CFStringRef pixEnc = CGDisplayModeCopyPixelEncoding(mode);
|
||||
if(CFStringCompare(pixEnc, CFSTR(IO32BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)
|
||||
depth = 32;
|
||||
else if(CFStringCompare(pixEnc, CFSTR(IO16BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)
|
||||
depth = 16;
|
||||
else if(CFStringCompare(pixEnc, CFSTR(IO8BitIndexedPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)
|
||||
depth = 8;
|
||||
|
||||
return depth;
|
||||
}
|
||||
#else
|
||||
// CGDisplayBitsPerPixel is defined
|
||||
#endif
|
||||
|
||||
NSOpenGLPixelFormat *choosePixelFormat(JNIEnv *env, jobject pixel_format, bool gl32, bool use_display_bpp, bool support_window, bool support_pbuffer, bool double_buffered) {
|
||||
int bpp;
|
||||
jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);
|
||||
|
|
|
@ -53,7 +53,7 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXCanvasPeerInfo_nInitHandle
|
|||
|
||||
MacOSXPeerInfo *peer_info = (MacOSXPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
|
||||
AWTSurfaceLock *surface = (AWTSurfaceLock *)(*env)->GetDirectBufferAddress(env, lock_buffer_handle);
|
||||
JAWT_MacOSXDrawingSurfaceInfo *macosx_dsi = (JAWT_MacOSXDrawingSurfaceInfo *)surface->dsi->platformInfo;
|
||||
JAWT_DrawingSurfaceInfo *macosx_dsi = (JAWT_DrawingSurfaceInfo *)surface->dsi->platformInfo;
|
||||
|
||||
// force CALayer usage or check if CALayer is supported (i.e. on Java 5 and Java 6)
|
||||
if(forceCALayer || (surface->awt.version & 0x80000000)) { //JAWT_MACOSX_USE_CALAYER) {
|
||||
|
@ -93,11 +93,16 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXCanvasPeerInfo_nInitHandle
|
|||
return window_handle;
|
||||
}
|
||||
}
|
||||
|
||||
// no CALayer support, fallback to using legacy method of getting the NSView of an AWT Canvas
|
||||
peer_info->parent = macosx_dsi->cocoaViewRef;
|
||||
peer_info->isCALayer = false;
|
||||
peer_info->isWindowed = true;
|
||||
|
||||
// no CALayer support
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
|
||||
throwException(env, "No CALayer support and no support legacy for getting NSView of an AWT Canvas");
|
||||
#else
|
||||
// fallback to using legacy method of getting the NSView of an AWT Canvas
|
||||
peer_info->parent = macosx_dsi->cocoaViewRef;
|
||||
peer_info->isCALayer = false;
|
||||
peer_info->isWindowed = true;
|
||||
#endif
|
||||
|
||||
[pool release];
|
||||
return NULL;
|
||||
|
@ -335,4 +340,4 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXCanvasPeerInfo_nSetLayerBound
|
|||
|
||||
}
|
||||
|
||||
@end
|
||||
@end
|
||||
|
|
Loading…
Reference in New Issue