Procházet zdrojové kódy

Using aligned_alloc instead of std::aligned_alloc (#526)

* Using aligned_alloc instead of std::aligned_alloc to fix compilation issue in certain versions of macOS
* Upgraded Android gradle to newest version and switch to Java 17

Fixes #514
Jorrit Rouwe před 2 roky
rodič
revize
b1766f345d

+ 6 - 1
.github/workflows/build.yml

@@ -254,9 +254,14 @@ jobs:
     steps:
     - name: Checkout Code
       uses: actions/checkout@v3
+    - name: Setup Java
+      uses: actions/setup-java@v3
+      with:
+        distribution: 'temurin'
+        java-version: '17'
     - name: Gradle Build
       working-directory: ${{github.workspace}}/Build/Android
-      run: ./gradlew build
+      run: ./gradlew build --no-daemon
 
   ios:
     runs-on: macos-latest

+ 1 - 1
Build/Android/build.gradle

@@ -5,7 +5,7 @@ buildscript {
         mavenCentral()
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:7.4.2'
+        classpath 'com.android.tools.build:gradle:8.0.1'
 
         // NOTE: Do not place your application dependencies here; they belong
         // in the individual module build.gradle files

+ 4 - 1
Build/Android/gradle.properties

@@ -16,4 +16,7 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
 # https://developer.android.com/topic/libraries/support-library/androidx-rn
 android.useAndroidX=true
 # Automatically convert third-party libraries to use AndroidX
-android.enableJetifier=true
+android.enableJetifier=true
+android.defaults.buildfeatures.buildconfig=true
+android.nonTransitiveRClass=false
+android.nonFinalResIds=false

+ 1 - 1
Build/Android/gradle/wrapper/gradle-wrapper.properties

@@ -1,5 +1,5 @@
 distributionBase=GRADLE_USER_HOME
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
 distributionPath=wrapper/dists
 zipStorePath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME

+ 3 - 2
Jolt/Core/Memory.cpp

@@ -37,7 +37,8 @@ JPH_ALLOC_SCOPE void *JPH_ALLOC_FN(AlignedAllocate)(size_t inSize, size_t inAlig
 #elif defined(JPH_PLATFORM_ANDROID)
 	return memalign(inAlignment, AlignUp(inSize, inAlignment));
 #else
-	return std::aligned_alloc(inAlignment, AlignUp(inSize, inAlignment));
+	// Using aligned_alloc instead of std::aligned_alloc because the latter is not available on some macOS versions
+	return aligned_alloc(inAlignment, AlignUp(inSize, inAlignment));
 #endif
 }
 
@@ -48,7 +49,7 @@ JPH_ALLOC_SCOPE void JPH_ALLOC_FN(AlignedFree)(void *inBlock)
 #elif defined(JPH_PLATFORM_ANDROID)
 	free(inBlock);
 #else
-	std::free(inBlock);
+	free(inBlock);
 #endif
 }