Skip to content

Commit

Permalink
update project (#7)
Browse files Browse the repository at this point in the history
* bump gradle versions

* allow multiple native iOS sources

* latest gradle versions

* define AndroidPlatform

* update workflows

* undo change

* add compile option for Android

* remove use of release
  • Loading branch information
jperedadnr authored Apr 3, 2024
1 parent 5d55169 commit 19b2e22
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 35 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
build:
name: Build
runs-on: macos-10.15
runs-on: macos-11
strategy:
fail-fast: false
steps:
Expand All @@ -19,25 +19,24 @@ jobs:
with:
fetch-depth: 5

- name: Setup Java 11
uses: actions/setup-java@v1
- name: Setup Java 17
uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'temurin'
java-version: 17

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build project
run: |
export ANDROID_SDK=$ANDROID_HOME
export ANDROID_NDK=$ANDROID_HOME/ndk-bundle
./gradlew -i nativeBuild
- name: Deploy Snapshot
if: github.ref == 'refs/heads/master'
run: |
export ANDROID_SDK=$ANDROID_HOME
export ANDROID_NDK=$ANDROID_HOME/ndk-bundle
./gradlew publish -PgluonNexusDeployUsername=$NEXUS_DEPLOY_USERNAME -PgluonNexusDeployPassword=$NEXUS_DEPLOY_PASSWORD
env:
NEXUS_DEPLOY_USERNAME: ${{ secrets.NEXUS_DEPLOY_USERNAME }}
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ on:
jobs:
build:
name: Deploy
runs-on: macos-10.15
runs-on: macos-11
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 5
persist-credentials: false

- name: Setup Java 11
uses: actions/setup-java@v1
- name: Setup Java 17
uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'temurin'
java-version: 17

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Deploy Release
run: |
export ANDROID_SDK=$ANDROID_HOME
export ANDROID_NDK=$ANDROID_HOME/ndk-bundle
./gradlew publish -PgluonNexusDeployUsername=$NEXUS_DEPLOY_USERNAME -PgluonNexusDeployPassword=$NEXUS_DEPLOY_PASSWORD
env:
NEXUS_DEPLOY_USERNAME: ${{ secrets.NEXUS_DEPLOY_USERNAME }}
Expand All @@ -44,4 +44,4 @@ jobs:
git commit gradle.properties -m "Prepare development of $newVersion"
git push https://gluon-bot:[email protected]/$GITHUB_REPOSITORY HEAD:master
env:
PAT: ${{ secrets.PAT }}
PAT: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'java-library'
id "org.openjfx.javafxplugin" version "0.0.10" apply false
id "org.openjfx.javafxplugin" version "0.1.0" apply false
}

if (System.getProperty('os.name').toLowerCase().contains("mac")) {
Expand All @@ -17,7 +17,7 @@ if (System.getProperty('os.name').toLowerCase().contains("mac")) {
ext.IOS_VERSION = ""
}

ext.libraryVersions = [attach: '4.0.14']
ext.libraryVersions = [attach: '4.0.20']

subprojects {
apply plugin: "org.openjfx.javafxplugin"
Expand Down
4 changes: 1 addition & 3 deletions gradle/android_project/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@ buildscript {
repositories {
mavenCentral()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0-alpha09'
classpath 'com.android.tools.build:gradle:8.3.1'
}
}

allprojects {
repositories {
google()
mavenCentral()
jcenter()
}
}
2 changes: 1 addition & 1 deletion gradle/android_project/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
android.useAndroidX=true
org.gradle.daemon=false
org.gradle.jvmargs=-Xms512M -Xmx4g -XX:MaxPermSize=1024m -XX:MaxMetaspaceSize=1g
org.gradle.jvmargs=-Xms512M -Xmx4g -XX:MaxMetaspaceSize=1g
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
12 changes: 8 additions & 4 deletions gradle/android_project/library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 29

namespace 'com.gluonhq.helloandroid'

compileSdkVersion 33

defaultConfig {
minSdkVersion 21
targetSdkVersion 29
targetSdkVersion 33
}

dependencies {
compileOnly fileTree(dir: '../libs', include: '*.jar')
}

afterEvaluate {
generateDebugBuildConfig.enabled = false
buildFeatures {
buildConfig = false
resValues = false
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding="utf-8"?>
<manifest xmlns:android='http://schemas.android.com/apk/res/android' xmlns:tools="http://schemas.android.com/tools" package='com.gluonhq.helloandroid'>
<manifest xmlns:android='http://schemas.android.com/apk/res/android' xmlns:tools="http://schemas.android.com/tools">
<uses-sdk android:minSdkVersion="21" />
</manifest>

1 change: 0 additions & 1 deletion gradle/include/AttachMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ static __inline__ void AttachLog(const char *file, int lineNumber, const char *f
[dateFormatter setTimeZone:[NSTimeZone systemTimeZone]];
}
fprintf(stderr, "[AttachLog] %s %s:%3d %s\n", [[dateFormatter stringFromDate:[NSDate date]] UTF8String], funcName, lineNumber, [formattedMessage UTF8String]);
[formattedMessage release];
}

#define AttachLog(MSG, ...) AttachLog(__FILE__, __LINE__, __PRETTY_FUNCTION__, MSG, ## __VA_ARGS__ )
Expand Down
24 changes: 15 additions & 9 deletions gradle/native-build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ def sdkPath(String platform) {
return "/Applications/Xcode.app/Contents/Developer/Platforms/${platform}.platform/Developer/SDKs/${platform}${IOS_VERSION}.sdk";
}

def AndroidPlatform = 33

configurations {
util
}
Expand Down Expand Up @@ -123,7 +125,7 @@ ext.aarBuild = { buildDir, projectDir, name, os ->
if (sdk == null) {
throw new GradleException("Error: ANDROID_SDK can't be null")
}
def androidJar = sdk + "/platforms/android-29/android.jar"
def androidJar = sdk + "/platforms/android-${AndroidPlatform}/android.jar"
if (!file(androidJar).exists()) {
throw new GradleException("Error: path for ${androidJar} doesn't exist")
}
Expand Down Expand Up @@ -277,19 +279,20 @@ ext.nativeBuildLib = { buildDir, projectDir, name, os ->
println "Skipping native-build on iOS: path for ${platform} doesn't exist"
return
}

osSources = "$projectDir/src/main/native/$os/${name}.m"


File nativeSourcesDir = file("$projectDir/src/main/native/$os/")
osSources = [nativeSourcesDir.listFiles().findAll {it.name.endsWith(".m")}].flatten()

def compileOutput = "$buildDir/native/ios/$arch"
new File(compileOutput).mkdirs()
def compileOutputs = ["$buildDir/native/ios/$arch/${name}.o"]
def linkerOutput = "$buildDir/native/ios/$arch/lib${name}.a"

File outputDir = new File(compileOutput)
outputDir.mkdirs()

def clangArgs = [
"-xobjective-c",
"-mios-version-min=11.0",
includeFlags,
osIncludeFlags,
"-fobjc-arc",
"-c",
"-fPIC",
"-arch", arch,
Expand All @@ -303,6 +306,9 @@ ext.nativeBuildLib = { buildDir, projectDir, name, os ->
workingDir compileOutput
}

def compileOutputs = [outputDir.listFiles().findAll {it.name.endsWith(".o")}].flatten()
def linkerOutput = "$buildDir/native/ios/$arch/lib${name}.a"

def linkerArgs = [
"-static",
"-framework", "Foundation",
Expand Down Expand Up @@ -368,7 +374,7 @@ ext.nativeBuildLib = { buildDir, projectDir, name, os ->
File nativeSourcesDir = file("$projectDir/src/main/native/$os/c/")
osSources = [nativeSourcesDir.listFiles().findAll {it.name.endsWith(".c")}].flatten()

def compilerArgs = ["-target", platform, "-Werror", "-c", includeFlags, osIncludeFlags, osSources].flatten()
def compilerArgs = ["-target", platform, "-Werror", "-c", "-fPIC", includeFlags, osIncludeFlags, osSources].flatten()

exec {
executable compiler
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit 19b2e22

Please sign in to comment.