-
Notifications
You must be signed in to change notification settings - Fork 2k
recipes: add new uvloop recipe
#3015
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
Merged
+67
−0
Merged
Changes from all commits
Commits
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,51 @@ | ||
| from os import makedirs, remove | ||
| from os.path import exists, join | ||
| import sh | ||
|
|
||
| from pythonforandroid.recipe import Recipe | ||
| from pythonforandroid.logger import shprint | ||
|
|
||
|
|
||
| class LibPthread(Recipe): | ||
| ''' | ||
| This is a dumb recipe. We may need this because some recipes inserted some | ||
| flags `-lpthread` without our control, case of: | ||
| - :class:`~pythonforandroid.recipes.uvloop.UvloopRecipe` | ||
| .. note:: the libpthread doesn't exist in android but it is integrated into | ||
| libc, so we create a symbolic link which we will remove when our build | ||
| finishes''' | ||
|
|
||
| def build_arch(self, arch): | ||
| libc_path = join(arch.ndk_lib_dir_versioned, 'libc') | ||
| # Create a temporary folder to add to link path with a fake libpthread.so: | ||
| fake_libpthread_temp_folder = join( | ||
| self.get_build_dir(arch.arch), | ||
| "p4a-libpthread-recipe-tempdir" | ||
| ) | ||
| if not exists(fake_libpthread_temp_folder): | ||
| makedirs(fake_libpthread_temp_folder) | ||
|
|
||
| # Set symlinks, and make sure to update them on every build run: | ||
| if exists(join(fake_libpthread_temp_folder, "libpthread.so")): | ||
| remove(join(fake_libpthread_temp_folder, "libpthread.so")) | ||
| shprint(sh.ln, '-sf', | ||
| libc_path + '.so', | ||
| join(fake_libpthread_temp_folder, "libpthread.so"), | ||
| ) | ||
| if exists(join(fake_libpthread_temp_folder, "libpthread.a")): | ||
| remove(join(fake_libpthread_temp_folder, "libpthread.a")) | ||
| shprint(sh.ln, '-sf', | ||
| libc_path + '.a', | ||
| join(fake_libpthread_temp_folder, "libpthread.a"), | ||
| ) | ||
|
|
||
| # Add folder as -L link option for all recipes if not done yet: | ||
| if fake_libpthread_temp_folder not in arch.extra_global_link_paths: | ||
| arch.extra_global_link_paths.append( | ||
| fake_libpthread_temp_folder | ||
| ) | ||
|
|
||
|
|
||
| recipe = LibPthread() |
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,16 @@ | ||
| from pythonforandroid.recipe import PyProjectRecipe | ||
|
|
||
|
|
||
| class UvloopRecipe(PyProjectRecipe): | ||
| version = 'v0.19.0' | ||
| url = 'git+https://github.com/MagicStack/uvloop' | ||
| depends = ['librt', 'libpthread'] | ||
|
|
||
| def get_recipe_env(self, arch, **kwargs): | ||
| env = super().get_recipe_env(arch, **kwargs) | ||
| env["LIBUV_CONFIGURE_HOST"] = arch.command_prefix | ||
| env["PLATFORM"] = "android" | ||
| return env | ||
|
|
||
|
|
||
| recipe = UvloopRecipe() | ||
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.
Uh oh!
There was an error while loading. Please reload this page.