Skip to content

Commit

Permalink
drawinfo build refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
tomas-mraz authored and Tomáš Mráz committed Nov 28, 2022
1 parent e5f9302 commit 4fe36a0
Show file tree
Hide file tree
Showing 27 changed files with 521 additions and 152 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# JetBrains IDE
.idea/
*.iml

# Applications
*.app
*.exe
*.war
*.syso
*.so
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ require (
github.com/stretchr/testify v1.8.0 // indirect
github.com/veandco/go-sdl2 v0.4.5
github.com/vulkan-go/asche v0.0.0-20190912134304-d4b318b67e07
github.com/vulkan-go/vulkan v0.0.0-20210402152248-956e3850d8f9
github.com/xlab/android-go v0.0.0-20180723170811-ebf4d6dd1830
github.com/vulkan-go/vulkan v0.0.0-20221127130951-d13440166fa0
github.com/xlab/android-go v0.0.0-20221106204035-3cc54d5032fa
github.com/xlab/catcher v0.0.0-20170222110830-4ce3d20cbee2
github.com/xlab/closer v0.0.0-20190328110542-03326addb7c2
github.com/xlab/ios-go v0.0.0-20170702230120-5c6163f67cd4
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ github.com/veandco/go-sdl2 v0.4.5 h1:GFIjMabK7y2XWpr9sGvN7RDKHt7vrA7XPTUW60eOw+Y
github.com/veandco/go-sdl2 v0.4.5/go.mod h1:OROqMhHD43nT4/i9crJukyVecjPNYYuCofep6SNiAjY=
github.com/vulkan-go/asche v0.0.0-20190912134304-d4b318b67e07 h1:QIXP1nx5b+YZt1cKDP5SR/89tRXrLxWslBBFBvH/+Y0=
github.com/vulkan-go/asche v0.0.0-20190912134304-d4b318b67e07/go.mod h1:fIbNY6YffQRtdF22h26OXRprI/BGOWPKlxJWtNC78OA=
github.com/vulkan-go/vulkan v0.0.0-20210402152248-956e3850d8f9 h1:WFujQpkMAAd8dqccEm10n8dly4yQ/R5d2+Us7GutowA=
github.com/vulkan-go/vulkan v0.0.0-20210402152248-956e3850d8f9/go.mod h1:Y5Ti1uUBdKDsb0W8aPtIo9krs+29Y7p6Bc9yyy4AM6g=
github.com/xlab/android-go v0.0.0-20180723170811-ebf4d6dd1830 h1:t4JWwVd06FAAZiTLSIGzNtOQYXkX90Y3bXWwAXvjepk=
github.com/xlab/android-go v0.0.0-20180723170811-ebf4d6dd1830/go.mod h1:cX5Ob29gFddv5hlAJN3tmNcvHuNQwUXzIP06azWW1M8=
github.com/vulkan-go/vulkan v0.0.0-20221127130951-d13440166fa0 h1:Ap4awTVoyePaU6/vJOFwVnmqgl1n554IWSSm4KWPy9A=
github.com/vulkan-go/vulkan v0.0.0-20221127130951-d13440166fa0/go.mod h1:Y5Ti1uUBdKDsb0W8aPtIo9krs+29Y7p6Bc9yyy4AM6g=
github.com/xlab/android-go v0.0.0-20221106204035-3cc54d5032fa h1:fJnl39vCautixum6jJL40AULKdF1r+2/IWzPHOcFCeM=
github.com/xlab/android-go v0.0.0-20221106204035-3cc54d5032fa/go.mod h1:WNGsHAaW0HwZ/T5KZPDOHJHtX+lHUElskKRPVtQ1/xs=
github.com/xlab/catcher v0.0.0-20170222110830-4ce3d20cbee2 h1:Zpa3je19AZ1GU/UIgDO+87Vwa0+awqbpKprjfBb+So8=
github.com/xlab/catcher v0.0.0-20170222110830-4ce3d20cbee2/go.mod h1:wLwj0uiLs18rq5dVL7qeTy8ZQsraFHXqas1pUVTa+8A=
github.com/xlab/closer v0.0.0-20190328110542-03326addb7c2 h1:LPYwXwwHigHHFX3SFa9W9zBIa5reyaLJos2e95eHh68=
Expand Down
63 changes: 39 additions & 24 deletions vulkaninfo/vulkaninfo_android/Makefile
Original file line number Diff line number Diff line change
@@ -1,33 +1,48 @@
ANDROID_TOOLCHAIN_DIR ?= $(shell pwd)/toolchain
ANDROID_API ?= 21
ANDROID_SYSROOT = $(NDK)/platforms/android-$(ANDROID_API)/arch-arm

all: toolchain build apk

toolchain:
$(NDK)/build/tools/make_standalone_toolchain.py \
--api=$(ANDROID_API) --install-dir=$(ANDROID_TOOLCHAIN_DIR) \
--arch=arm --stl libc++

build:
mkdir -p android/jni/lib
CC="$(ANDROID_TOOLCHAIN_DIR)/bin/arm-linux-androideabi-gcc" \
CXX="$(ANDROID_TOOLCHAIN_DIR)/bin/arm-linux-androideabi-g++" \
CGO_CFLAGS="-march=armv7-a" \
HOST_TAG ?= linux-x86_64
API_LEVEL ?= 26
TOOLCHAIN ?= $(NDK)/toolchains/llvm/prebuilt/$(HOST_TAG)/bin

all: clean build apk
echo "WORK DONE"

build: build32 build64 build-amd64
echo "builded all"

build32:
echo "compile for old phones with arm (32bit)"
CC="$(TOOLCHAIN)/armv7a-linux-androideabi$(API_LEVEL)-clang" \
CXX="$(TOOLCHAIN)/armv7a-linux-androideabi$(API_LEVEL)-clang++" \
GOOS=android \
GOARCH=arm \
GOARM=7 \
CGO_ENABLED=1 \
go build -buildmode=c-shared -o android/jni/lib/libvulkaninfo.so

apk:
cd android && make
go build -buildmode=c-shared -o android/app/src/main/jniLibs/armeabi-v7a/libvulkaninfo.so

build64:
echo "compile for arm64 (64bit)"
CC="$(TOOLCHAIN)/aarch64-linux-android$(API_LEVEL)-clang" \
CXX="$(TOOLCHAIN)/aarch64-linux-android$(API_LEVEL)-clang++" \
GOOS=android \
GOARCH=arm64 \
CGO_ENABLED=1 \
go build -buildmode=c-shared -o android/app/src/main/jniLibs/arm64-v8a/libvulkaninfo.so

build-amd64:
echo "compile for emulator"
CC="$(TOOLCHAIN)/x86_64-linux-android$(API_LEVEL)-clang" \
CXX="$(TOOLCHAIN)/x86_64-linux-android$(API_LEVEL)-clang++" \
GOOS=android \
GOARCH=amd64 \
CGO_ENABLED=1 \
go build -buildmode=c-shared -o android/app/src/main/jniLibs/x86_64/libvulkaninfo.so

clean:
cd android && make clean
echo "delete generated files"
rm -rf android/app/build
rm -rf android/app/build-native

install:
cd android && make install
apk:
echo "run gradle"
cd android; ./gradlew -q clean assembleDebug > /dev/null 2>&1

listen:
adb logcat -c
Expand Down
6 changes: 6 additions & 0 deletions vulkaninfo/vulkaninfo_android/android/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# These are explicitly windows files and should use crlf
*.bat text eol=crlf

7 changes: 7 additions & 0 deletions vulkaninfo/vulkaninfo_android/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Ignore Gradle project-specific cache directory
.gradle

# Ignore Gradle build output directory
build
build-native
local.properties
20 changes: 0 additions & 20 deletions vulkaninfo/vulkaninfo_android/android/AndroidManifest.xml

This file was deleted.

21 changes: 0 additions & 21 deletions vulkaninfo/vulkaninfo_android/android/Makefile

This file was deleted.

13 changes: 13 additions & 0 deletions vulkaninfo/vulkaninfo_android/android/app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

# Mention the cmake version name.
cmake_minimum_required(VERSION 3.4.1)

project( VulkanInfo )

# Application
add_library(vulkaninfo SHARED IMPORTED)

set_target_properties( vulkaninfo
PROPERTIES IMPORTED_LOCATION
${CMAKE_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libvulkaninfo.so
)
56 changes: 56 additions & 0 deletions vulkaninfo/vulkaninfo_android/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
plugins {
id 'com.android.application'
}

android {
namespace 'org.golang.android.vulkan.info'
compileSdk 26
buildToolsVersion '33.0.0'
ndkVersion '25.1.8937393'

defaultConfig {
applicationId "org.golang.android.vulkan.info"
minSdk 26
targetSdk 26
versionCode 1
versionName "1.0"

externalNativeBuild {
cmake {
abiFilters.addAll('armeabi-v7a', 'arm64-v8a', 'x86_64')
}
}
}

buildTypes {
debug {
debuggable true
jniDebuggable true
minifyEnabled false
}

release {
debuggable false
jniDebuggable false
minifyEnabled false
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

sourceSets {
main.assets.srcDirs = ['assets']
main {
res.srcDirs += [ '../../../app/android/res' ]
}
}
externalNativeBuild {
cmake {
path 'CMakeLists.txt'
buildStagingDirectory 'build-native'
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0">

<!-- Require Vulkan 1.0 -->
<uses-feature android:name="android.hardware.vulkan.version" android:version="0x400003" android:required="true" />
<uses-feature android:name="android.hardware.vulkan.level" android:version="0" android:required="true" />

<application android:label="@string/app_name"
android:icon="@drawable/icon"
android:hasCode="false">
<activity android:name="android.app.NativeActivity"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:configChanges="orientation|keyboardHidden"
android:exported="true">
<meta-data android:name="android.app.lib_name" android:value="vulkaninfo" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Vulkan Info</string> <!-- User visible app name on home screen -->
</resources>
5 changes: 5 additions & 0 deletions vulkaninfo/vulkaninfo_android/android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.3.1' apply false
id 'com.android.library' version '7.3.1' apply false
}
4 changes: 4 additions & 0 deletions vulkaninfo/vulkaninfo_android/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
android.useAndroidX=true
android.enableJetifier=true
org.gradle.parallel=true
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 4fe36a0

Please sign in to comment.