Repository navigation
Add cglm and datoviz recipes #3419
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
Draft
T-Dynamos
wants to merge
11
commits into
kivy:develop
Choose a base branch
from
T-Dynamos:add-datoviz-cglm-recipes
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+132
−0
Draft
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e2f14f7
Add cglm and datoviz recipes
T-Dynamos fdc2fb2
datoviz: install pyyaml in hostpython and detect glslc across platforms
T-Dynamos 4420067
datoviz: declare pyyaml in hostpython_prerequisites
T-Dynamos bab6aec
recipes(datoviz): avoid passing -m64 on Android x86
T-Dynamos 267ead9
recipes(datoviz): pin commit edd17fb and drop merged _ctypes.py patch
T-Dynamos ba048e9
recipes(datoviz): use archive tarball at 7e1ba52 and drop merged patch
T-Dynamos 10497d4
recipes(datoviz): pass -DDVZ_INSTALL=OFF for archive builds
T-Dynamos 8db1be1
recipes(datoviz): fetch imstb_truetype.h for archive builds
T-Dynamos 70aab1c
recipes(datoviz): switch back to git+ URL pinned to 7e1ba52
T-Dynamos 991440a
move cglm -> libcglm
T-Dynamos 7932a54
Fix bug in __init__.py
T-Dynamos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| import glob | ||
| import os | ||
| import shutil | ||
| from os.path import join | ||
|
|
||
| import sh | ||
| from pythonforandroid.logger import info, shprint | ||
| from pythonforandroid.recipe import PyProjectRecipe, Recipe | ||
|
|
||
|
|
||
| class DatovizRecipe(PyProjectRecipe): | ||
| version = "7e1ba52513ea07f2c3a8c13b0979f1ccdb04bb11" | ||
| url = "git+https://github.com/datoviz/datoviz.git" | ||
| depends = ["python3", "numpy", "libcglm"] | ||
| hostpython_prerequisites = ["pyyaml"] | ||
|
|
||
| def _find_glslc(self): | ||
| candidates = glob.glob(join(self.ctx.ndk_dir, "shader-tools", "*", "glslc*")) | ||
| if candidates: | ||
| return candidates[0] | ||
| return shutil.which("glslc") | ||
|
|
||
| def build_arch(self, arch): | ||
| self.install_hostpython_prerequisites() | ||
| build_dir = self.get_build_dir(arch.arch) | ||
| cmake_build_dir = join(build_dir, "p4a_cmake_build") | ||
| toolchain = join(self.ctx.ndk_dir, "build", "cmake", "android.toolchain.cmake") | ||
| generator = "Ninja" if shutil.which("ninja") else "Unix Makefiles" | ||
| cglm_install_dir = join( | ||
| Recipe.get_recipe("libcglm", self.ctx).get_build_dir(arch.arch), | ||
| "installation", | ||
| ) | ||
|
|
||
| cmake_args = [ | ||
| "-S", | ||
| build_dir, | ||
| "-B", | ||
| cmake_build_dir, | ||
| "-G", | ||
| generator, | ||
| f"-DCMAKE_TOOLCHAIN_FILE={toolchain}", | ||
| f"-DANDROID_ABI={arch.arch}", | ||
| f"-DANDROID_PLATFORM=android-{self.ctx.ndk_api}", | ||
| f"-DCMAKE_PREFIX_PATH={cglm_install_dir}", | ||
| f"-DCMAKE_SHARED_LINKER_FLAGS=-L{join(cglm_install_dir, 'lib')}", | ||
| "-DCMAKE_BUILD_TYPE=Release", | ||
| "-DDVZ_CGLM_SOURCE=SYSTEM", | ||
| "-DDVZ_BUILD_TESTING=OFF", | ||
| "-DDVZ_BUILD_EXAMPLES=OFF", | ||
| "-DDVZ_INSTALL=OFF", | ||
| "-DDVZ_WITH_GLFW=OFF", | ||
| "-DDVZ_BUILD_GUI=OFF", | ||
| "-DDVZ_ENABLE_CUDA=OFF", | ||
| "-DDVZ_ENABLE_QT_BRIDGE=OFF", | ||
| "-DDVZ_ENABLE_SHADERC=OFF", | ||
| "-DDVZ_WITH_FREETYPE=OFF", | ||
| "-DDVZ_WITH_MSDF_ATLAS=OFF", | ||
| "-DDVZ_KVAZAAR_SOURCE=OFF", | ||
| f"-DPython3_EXECUTABLE={self.real_hostpython_location}", | ||
| ] | ||
| glslc = self._find_glslc() | ||
| if glslc: | ||
| cmake_args.append(f"-DDVZ_GLSLC_EXECUTABLE={glslc}") | ||
|
|
||
| info(f"Configuring datoviz CMake for {arch.arch} (android-{self.ctx.ndk_api})") | ||
| shprint(sh.cmake, *cmake_args) | ||
|
|
||
| nproc = str(os.cpu_count() or 4) | ||
| info(f"Building libdatoviz.so for {arch.arch}") | ||
| shprint( | ||
| sh.cmake, "--build", cmake_build_dir, "--target", "datoviz", "-j", nproc | ||
| ) | ||
|
|
||
| built_so = join(cmake_build_dir, "src", "libdatoviz.so") | ||
| target_so = join(build_dir, "datoviz", "libdatoviz.so") | ||
| shutil.copy2(built_so, target_so) | ||
|
|
||
| super().build_arch(arch) | ||
|
|
||
|
|
||
| recipe = DatovizRecipe() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import os | ||
| import shutil | ||
| from os.path import join | ||
|
|
||
| import sh | ||
|
|
||
| from pythonforandroid.logger import info, shprint | ||
| from pythonforandroid.recipe import Recipe | ||
| from pythonforandroid.util import ensure_dir | ||
|
|
||
|
|
||
| class LibCglmRecipe(Recipe): | ||
| version = "0.9.6" | ||
| url = "https://github.com/recp/cglm/archive/refs/tags/v{version}.tar.gz" | ||
| built_libraries = { | ||
| "libcglm.so": "installation/lib", | ||
| } | ||
|
|
||
| def build_arch(self, arch): | ||
| source_dir = self.get_build_dir(arch.arch) | ||
| build_dir = join(source_dir, "p4a_build") | ||
| install_dir = join(source_dir, "installation") | ||
| toolchain = join(self.ctx.ndk_dir, "build", "cmake", "android.toolchain.cmake") | ||
| generator = "Ninja" if shutil.which("ninja") else "Unix Makefiles" | ||
|
|
||
| ensure_dir(build_dir) | ||
| cmake_args = [ | ||
| "-S", | ||
| source_dir, | ||
| "-B", | ||
| build_dir, | ||
| "-G", | ||
| generator, | ||
| f"-DCMAKE_TOOLCHAIN_FILE={toolchain}", | ||
| f"-DANDROID_ABI={arch.arch}", | ||
| f"-DANDROID_PLATFORM=android-{self.ctx.ndk_api}", | ||
| f"-DCMAKE_INSTALL_PREFIX={install_dir}", | ||
| "-DCMAKE_BUILD_TYPE=Release", | ||
| "-DCMAKE_POSITION_INDEPENDENT_CODE=ON", | ||
| "-DCGLM_SHARED=ON", | ||
| "-DCGLM_STATIC=OFF", | ||
| "-DCGLM_USE_C99=ON", | ||
| "-DCGLM_USE_TEST=OFF", | ||
| ] | ||
| info(f"Building cglm {self.version} for {arch.arch}") | ||
| shprint(sh.cmake, *cmake_args) | ||
| shprint(sh.cmake, "--build", build_dir, "-j", str(os.cpu_count() or 4)) | ||
| shprint(sh.cmake, "--install", build_dir) | ||
|
|
||
|
|
||
| recipe = LibCglmRecipe() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p4a uses
git fetch --tags --depth 1and this may break as soon as datoviz upstream commits on top of main.Maybe use
archive/<sha>.tar.gzinstead, e.g.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Datoviz uses a lot of submodules we can't use source tar, I will request them to tag a new release.