Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build samples for Android on Windows #45

Open
elix22 opened this issue Sep 7, 2019 · 14 comments
Open

build samples for Android on Windows #45

elix22 opened this issue Sep 7, 2019 · 14 comments

Comments

@elix22
Copy link

elix22 commented Sep 7, 2019

I haven't found a way (the right config) to build "sapp-" samples for Android on Windows .
Is it possible ?

@floooh
Copy link
Owner

floooh commented Sep 7, 2019

Hi, if the procedure described here doesn't work, then something seems to be broken again (not unusual with the Android dev tools unfortunately):

https://github.com/floooh/sokol-samples#to-build-for-android

What sort of errors are you getting?

PS: apart from the "usual tools" (python and cmake), you'd also need a make tool, e.g. via:

> scoop install make

PPS: the build config android-vscode-debug should also work on Windows, this uses the Ninja build tool instead of GNU make, and there comes a ninja executable for Windows bundled with fips.

I'll give it a try when I do some Windows stuff later today or tomorrow :)

@elix22
Copy link
Author

elix22 commented Sep 17, 2019

Apparently the ndk-bundle downloaded into fips-sdks/android was wrong it was a 32 bit version .
I overridden it with my ndk-bundle and compilation succeeded , however the apps crash on one of my devices.

09-17 09:09:50.253  7326  7326 F DEBUG   : Abort message: 'D:/GAME-ENGINES/SOKOL/sokol\sokol_app.h:4841: int _sapp_android_main_cb(int, int, void *): assertion "result" failed'

09-17 09:09:50.254 7326 7326 F DEBUG : r0 00000000 r1 00001c98 r2 00000006 r3 00000008
09-17 09:09:50.254 7326 7326 F DEBUG : r4 00001c4a r5 00001c98 r6 904906bc r7 0000010c
09-17 09:09:50.254 7326 7326 F DEBUG : r8 00000000 r9 a2812540 sl 00000001 fp 00000000
09-17 09:09:50.254 7326 7326 F DEBUG : ip 90490770 sp 904906a8 lr aae658bd pc aae5f40e cpsr 200f0030

@floooh
Copy link
Owner

floooh commented Sep 17, 2019

...I'm trying to reproduce the problem but I'm stuck finding an OpenJDK8 for Windows (scoop doesn't have one, and I can't find a download link that looks somewhat official anywhere, only for newer versions).

Basically, it's strange that a 32-bit NDK wouldn't work on a 64-bit Windows.

@elix22
Copy link
Author

elix22 commented Sep 17, 2019

Regarding the 32 bit NDK , cmake is failing because the 32 bit ndk doesn't have an "windows-x86_64" folder

CMake Error at CMakeLists.txt:5 (project):
The CMAKE_C_COMPILER:

D:/GAME-ENGINES/SOKOL/fips-sdks/android/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe

is not a full path to an existing compiler tool.

I fixed several places and passing now _sapp_android_init_egl()
However I am getting the following error:

2019-09-17 13:34:29.127 8868-8954/org.fips.triangle_sapp I/SOKOL_APP: sg_pipeline_desc.shader missing or invalid
2019-09-17 13:34:29.127 8868-8954/org.fips.triangle_sapp I/SOKOL_APP: ^^^^ VALIDATION FAILED, TERMINATING

It's a low cost device (Xiaomi Redmi 6A), I configured cmake to

        add_definitions(-DSOKOL_GLES2)
        set(slang "glsl100")

On my LG G6 it's running fine

@elix22
Copy link
Author

elix22 commented Sep 17, 2019

OK , I made it to work (GLES2).
Changes uploaded to GDrive.
https://drive.google.com/open?id=1Owf8wI969bvK7jiV8DF1acL0jm-q__pA

@floooh
Copy link
Owner

floooh commented Sep 17, 2019

Hmm, if I'm seeing this right your changes essentially hardware the Android code path in sokol_app.h to GLES2.

The softer bit-depth selection looks useful though, I'll attach the changes here in case anyone wants to turn them into a pull request.

sokol_changes.zip

@floooh
Copy link
Owner

floooh commented Sep 17, 2019

I've opened a new issue in the sokol repository:

floooh/sokol#218

@floooh
Copy link
Owner

floooh commented Sep 17, 2019

...one last question: where did you get the 64-bit ndk-bundle? I want to open a fips issue for this (since it needs to be fixed there).

@elix22
Copy link
Author

elix22 commented Sep 17, 2019

The NDK was taken from my sdk directory that came with Android Studio however you can download it directly from https://developer.android.com/ndk/downloads
There are both 32 bit and 64 bit NDK's.

I will P.R. the changes during the weekend.

@elix22
Copy link
Author

elix22 commented Sep 17, 2019

I verified that GLES3 is also working on the same device so the following is needed to make it work :

const EGLint cfg_attributes[] = {
      EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
#if defined(SOKOL_GLES3)
  	EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT,
#else	
  	EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
#endif
      EGL_RED_SIZE, 8,
      EGL_GREEN_SIZE, 8,
      EGL_BLUE_SIZE, 8,
      EGL_ALPHA_SIZE, alpha_size,
      EGL_DEPTH_SIZE, 16,
      EGL_STENCIL_SIZE, 0,
      EGL_NONE,
  };

@floooh
Copy link
Owner

floooh commented Sep 17, 2019

Hmm, regarding the Android SDK/NDK 32/64-bit problems, I cannot reproduce them here on a Win10 machine.

Here's what I'm doing roughly (cmake, OpenJDK8 and make have been installed with scoop, and the commands are run in a "Developer Command Prompt for VS2015" terminal, and from within the sokol-samples directory

> cmake --version
cmake version 3.15.3
...
> java -version
openjdk version "1.8.0_212-1-ojdkbuild"
...
> make --version
GNU Make 4.2.1
Built for Windows32
...
> fips setup android
...
> fips gen
=== dependency: 'sokol':
dir 'D:/projects/sokol' exists
=== dependency: 'sokol-tools-bin':
dir 'D:/projects/sokol-tools-bin' exists
=== dependency: 'fips-glfw':
dir 'D:/projects/fips-glfw' exists
=== dependency: 'fips-cimgui':
dir 'D:/projects/fips-cimgui' exists
=== dependency: 'fips-imgui':
dir 'D:/projects/fips-imgui' exists
=== dependency: 'fips-libmodplug':
dir 'D:/projects/fips-libmodplug' exists
=== generating: sapp-android-make-debug
config file: D:/projects/sokol-samples/fips-files/configs/sapp-android-make-debug.yml
Using Toolchain File: D:/projects/fips/cmake-toolchains/android.toolchain.cmake
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=D:/projects/fips/cmake-toolchains/android.toolchain.cmake -DFIPS_CONFIG=sapp-android-make-debug -DUSE_SOKOL_APP=ON -DANDROID_ABI="armeabi-v7a" -DANDROID_PLATFORM="android-21" -DFIPS_USE_CCACHE=OFF -DFIPS_AUTO_IMPORT=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -BD:/projects/fips-build/sokol-samples/sapp-android-make-debug -HD:/projects/sokol-samples
-- Check for working C compiler: D:/projects/fips-sdks/android/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- Check for working C compiler: D:/projects/fips-sdks/android/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: D:/projects/fips-sdks/android/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe
-- Check for working CXX compiler: D:/projects/fips-sdks/android/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMAKE_BUILD_TYPE: Debug
FIPS_ROOT_DIR: D:/projects/fips
FIPS_PROJECT_DIR: D:/projects/sokol-samples
FIPS_BUILD_DIR: D:/projects/fips-build
FIPS_DEPLOY_DIR: D:/projects/fips-deploy
FIPS_PROJECT_NAME: sokol-samples
FIPS_AUTO_IMPORT: OFF
FIPS_CONFIG: sapp-android-make-debug
FIPS_PROJECT_BUILD_DIR: D:/projects/fips-build/sokol-samples/sapp-android-make-debug
FIPS_PROJECT_DEPLOY_DIR: D:/projects/fips-deploy/sokol-samples/sapp-android-make-debug
Host system: Windows
CMAKE_CXX_COMPILER_ID: Clang
Detected C++ Compiler: Clang (FIPS_CLANG)
FIPS_PLATFORM: ANDROID
FIPS_PLATFORM_NAME: android
-- Configuring done
-- Generating done
-- Build files have been written to: D:/projects/fips-build/sokol-samples/sapp-android-make-debug
1 configs generated

The following fips build also works (although the terminal colors are a bit messed up due to the cmake Makefile generator's colored output.

@elix22
Copy link
Author

elix22 commented Sep 18, 2019

I tried on another laptop at my work and it downloaded the 64 bit ndk-bundle, compilation succeeded .
I have no clue why it downloaded the 32 bit ndk-bundle on my personal laptop , will try again during the weekend

@elix22
Copy link
Author

elix22 commented Sep 20, 2019

OK , I found the root cause of the 32 bit ndk-bundle installation .

I have both 32 and 64 bit JDK's installed .
My environment vars were pointing to the 32 bit JDK :

JAVA_HOME
C:\Program Files (x86)\Java\jdk1.8.0_181

JDK_HOME
C:\Program Files (x86)\Java\jdk1.8.0_181

As a result

./fips setup android

downloaded the 32 bit ndk-bundle

Changing these environment variables to point to the 64 bit JDK solved the issue.

JAVA_HOME
C:\Program Files\Java\jdk1.8.0_181

JDK_HOME
C:\Program Files\Java\jdk1.8.0_181

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants