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

emsdk_installer init #6163

Merged
merged 48 commits into from
Oct 4, 2021
Merged

emsdk_installer init #6163

merged 48 commits into from
Oct 4, 2021

Conversation

werto87
Copy link
Contributor

@werto87 werto87 commented Jul 5, 2021

emsdk_installer/2.0.10

This recipe creates a package which may be used as build_requires to build packages for emscripten wasm.
This recipe is based on "#4860".

closes #620


  • I've read the guidelines for contributing.
  • I've followed the PEP8 style guides for Python code in the recipes.
  • I've used the latest Conan client version.
  • I've tried at least one configuration locally with the
    conan-center hook activated.

@conan-center-bot

This comment has been minimized.

@conan-center-bot

This comment has been minimized.

@SSE4 SSE4 changed the title init emsdk_installer init Jul 5, 2021
@conan-center-bot

This comment has been minimized.

Copy link
Contributor

@Croydon Croydon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a previous attempt here #4860

recipes/emsdk_installer/all/conanfile.py Outdated Show resolved Hide resolved
recipes/emsdk_installer/all/conanfile.py Outdated Show resolved Hide resolved
@werto87
Copy link
Contributor Author

werto87 commented Jul 6, 2021

Is it acceptable that this package downloads its own node.js? I think I can make this package pass the conan hooks and still work. But is this wanted?

recipes/emsdk_installer/all/conanfile.py Outdated Show resolved Hide resolved
recipes/emsdk_installer/all/conanfile.py Outdated Show resolved Hide resolved
recipes/emsdk_installer/all/conanfile.py Outdated Show resolved Hide resolved
recipes/emsdk_installer/all/conanfile.py Outdated Show resolved Hide resolved
recipes/emsdk_installer/all/conanfile.py Outdated Show resolved Hide resolved
recipes/emsdk_installer/all/conanfile.py Outdated Show resolved Hide resolved
tools.get(**self.conan_data["sources"][self.version])
extracted_folder = "emsdk-%s" % self.version
os.rename(extracted_folder, self._source_subfolder)

Copy link
Contributor

@madebr madebr Jul 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A validate method to check whether os is valid would be useful, I think.
This recipe is supposed to be used in a cross build configuration. So it should also probably test whether the target os is actually wasm.
Something like:

    def validate(self):
        if self.settings.os not in ("Linux", "Macos", "Windows"):
             raise ConanInvalidConfiguration("Invalid OS. Only Linux, Macos and Windows are supported.")
        if hasattr(self, "settings_target"):
            if self.settings_target.os != "wasm":
                 raise ConanInvalidConfiguration("Emscripten targets only os=wasm, not {}.".format(self.settings_target.os)

You will also need to add from conans import ConanInvalidConfiguration at the top of this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When providing "--profile:host" self.settings.os contains the value of that profile. So when the consumer sets a profile as host which os is Emscripten this does not work.

I think "wasm" is not an os.

To be honest I do not know what configurations are wrong.
I think it is a great idea to give the user feedback.
Maybe we could use "self.settings_build" instead of "self.settings.os" to check if the build os is linux mac or windows.

recipes/emsdk_installer/all/test_package/CMakeLists.txt Outdated Show resolved Hide resolved
recipes/emsdk_installer/all/test_package/conanfile.py Outdated Show resolved Hide resolved
recipes/emsdk_installer/all/test_package/conanfile.py Outdated Show resolved Hide resolved
@conan-center-bot

This comment has been minimized.

@conan-center-bot

This comment has been minimized.

@conan-center-bot

This comment has been minimized.

@conan-center-bot

This comment has been minimized.

@conan-center-bot

This comment has been minimized.

@conan-center-bot

This comment has been minimized.

@conan-center-bot

This comment has been minimized.

@conan-center-bot

This comment has been minimized.

@werto87
Copy link
Contributor Author

werto87 commented Jul 7, 2021

The build fails with "CMakeFiles/test_package.dir/test_package.cpp.o: must specify -mwasm64 to process wasm64 object files"
I get the same error on my system if I do not set "--profile:build=clang --profile:host=emscripten". How to fix this on conan CI?
For reference:
cat .conan/profiles/emscripten
[settings]
os=Emscripten
arch=wasm
compiler=clang
compiler.version=12
compiler.libcxx=libc++
[options]
[build_requires]
emsdk_installer/2.0.10@
[env]

cat .conan/profiles/clang
[settings]
os=Linux
arch=x86_64
compiler=clang
compiler.version=13
compiler.libcxx=libc++
[env]
CC=/usr/bin/clang
CXX=/usr/bin/clang++

@madebr
Copy link
Contributor

madebr commented Jul 7, 2021

The test_package log contains:

cache:INFO: generating system library: libc++-noexcept.a... (this will be cached in "/home/conan/w/BuildSingleReference/.conan/data/emsdk_installer/2.0.10/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/bin/.emscripten_cache/wasm/libc++-noexcept.a" for subsequent builds)

Is it possible to configure this cache folder? conan generates a manifest file after packaging, but it's always nice to keep the package folder pristine.

@werto87
Copy link
Contributor Author

werto87 commented Jul 7, 2021

The test_package log contains:

cache:INFO: generating system library: libc++-noexcept.a... (this will be cached in "/home/conan/w/BuildSingleReference/.conan/data/emsdk_installer/2.0.10/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/bin/.emscripten_cache/wasm/libc++-noexcept.a" for subsequent builds)

Is it possible to configure this cache folder? conan generates a manifest file after packaging, but it's always nice to keep the package folder pristine.

It is possible to set the folder. Which path do you suggest and what is wrong with the current path?

@madebr
Copy link
Contributor

madebr commented Jul 7, 2021

The build fails with "CMakeFiles/test_package.dir/test_package.cpp.o: must specify -mwasm64 to process wasm64 object files"
I get the same error on my system if I do not set "--profile:build=clang --profile:host=emscripten". How to fix this on conan CI?

This recipe is supposed to be used as a build requirement, so the test should be run with emscripten as a build requirement.
See conan-io/conan#8787 on how to do this (new conan 1.36.0 feature)

I would try to write the test package such that, when not using conan's cross building feature, try to work around the missing bits.
How come cmake only adds -mwasm64 to the link command when cross building? Is it possible to force it when not using conan's cross building support?

It is possible to set the folder. Which path do you suggest and what is wrong with the current path?

I am asking because it caches in the package folder.
To give a counter example: I am recently toying a bit with writing Android apps. Its build system, gradle, caches libraries in ~/.gradle.

@conan-center-bot

This comment has been minimized.

@conan-center-bot

This comment has been minimized.

@conan-center-bot

This comment has been minimized.

recipes/emsdk/all/conanfile.py Outdated Show resolved Hide resolved
@conan-center-bot

This comment has been minimized.

@jgsogo
Copy link
Contributor

jgsogo commented Oct 4, 2021

I'm having a look at this PR. Trying to polish it for Macos world (running locally 💪 )

@conan-center-bot

This comment has been minimized.

@conan-center-bot

This comment has been minimized.

@conan-center-bot

This comment has been minimized.

@jgsogo
Copy link
Contributor

jgsogo commented Oct 4, 2021

One more hook... we've never reached that far (Windows builds) 🚀

[HOOK - conan-center.py] post_package(): ERROR: [MS RUNTIME FILES (KB-H021)] The conan-center repository doesn't allow Microsoft Visual Studio runtime files. (https://github.com/conan-io/conan-center-index/blob/master/docs/error_knowledge_base.md#KB-H021) 
[HOOK - conan-center.py] post_package(): ERROR: [MS RUNTIME FILES (KB-H021)] Found files: ./bin/python/3.9.2-1_64bit/vcruntime140.dll; ./bin/python/3.9.2-1_64bit/vcruntime140_1.dll (https://github.com/conan-io/conan-center-index/blob/master/docs/error_knowledge_base.md#KB-H021) 
ERROR: [HOOK - conan-center.py] post_package(): Some checks failed running the hook, check the output

@conan-center-bot
Copy link
Collaborator

All green in build 57 (487e64d5500e454c5c4837ab8065c045bb1cf250):

  • emsdk/2.0.30@:
    All packages built successfully! (All logs)

@SSE4 SSE4 requested a review from jgsogo October 4, 2021 12:33
Copy link
Contributor

@jgsogo jgsogo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@conan-center-bot conan-center-bot merged commit a4781bd into conan-io:master Oct 4, 2021
@jgsogo
Copy link
Contributor

jgsogo commented Oct 4, 2021

Thanks a lot, @werto87

During the weekend I kept working with magnum and I realized that it is using SDL1 for emscripten builds. As SDL is available in the emsdk it is not a big deal, but if we want to consume packages from ConanCenter for emscripten builds (#7427) we need to migrate magnum to use SDL2 or figure out how to work with sdl12-compat (a compatibility layer to provide SDL1 to SDL2 library, and help during the transition).

I don't know if you have any insights about this new topic, any idea if newer versions of magnum will use only SDL2? I have no knowledge at all of SDL so it is very hard for me to port the project to SDL2 😞

@werto87
Copy link
Contributor Author

werto87 commented Oct 4, 2021

Thanks a lot, @werto87

During the weekend I kept working with magnum and I realized that it is using SDL1 for emscripten builds. As SDL is available in the emsdk it is not a big deal, but if we want to consume packages from ConanCenter for emscripten builds (#7427) we need to migrate magnum to use SDL2 or figure out how to work with sdl12-compat (a compatibility layer to provide SDL1 to SDL2 library, and help during the transition).

I don't know if you have any insights about this new topic, any idea if newer versions of magnum will use only SDL2? I have no knowledge at all of SDL so it is very hard for me to port the project to SDL2 😞

Thank you too,
to be honest I did not know (or forgot) about SDL1 and 2 before you mentiont it 😄 so I think I can not help. I think you should not worry about the next version of magnum because if something breaks in it we can fix it.
Please let me know when you managed to get magnum integration with imgui build for wasm working. I whould then test it with my project and help with bug fixes.

@jgsogo
Copy link
Contributor

jgsogo commented Oct 5, 2021

@werto87 . The issue is that here I need to talk as a package manager advocate (this is ConanCenter). I can build magnum using this emsdk recipe and it works almost out of the box... but only if I consume sdl from the emscripten port (it is already distributed with emsdk) because it provides all the patches required... but it is not SDL2 recipe and package provided by ConanCenter.
On the other hand, SDL2 builds using this emsdk recipe as well, but magnum is not prepared to use SDL2.

@werto87
Copy link
Contributor Author

werto87 commented Oct 5, 2021

@jgsogo. I tried to replace my magnum-integration/2020.06 recipe with the conan magnum-integration/2020.06 recipe.
I get the error:
"ERROR: egl/system: Invalid configuration: This recipes supports only Linux and FreeBSD"

my profiles are:
clang

[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=clang
compiler.version=13
compiler.libcxx=libc++
[env]
CC=/usr/bin/clang
CXX=/usr/bin/clang++

and
emscripten

[settings]
os=Emscripten
arch=wasm
compiler=clang
compiler.version=14
compiler.libcxx=libc++
[options]
[build_requires]
emsdk/2.0.30
[env]

I run the command
conan install .. --profile:build=clang --profile:host=emscripten --build missing -s build_type=Debug

@jgsogo
Copy link
Contributor

jgsogo commented Oct 5, 2021

You need to disable some components, you need to modify magnum recipe in this direction: #7412. As you can see, many components are disabled/deactivated for emscripten but at least sdl2application (using SDL2 embedded in emsdk) and emscriptenapplication are built.

It works, I promise, I did it live here: https://youtu.be/PjiJ-3sxKbs. Anyway I plan to write a blogpost with detailed information, and future work to be done.

@werto87
Copy link
Contributor Author

werto87 commented Oct 6, 2021

@jgsogo. Sounds great! I'm looking forward to the blogpost. Where and when do you post it?

@jgsogo
Copy link
Contributor

jgsogo commented Oct 15, 2021

@jgsogo. Sounds great! I'm looking forward to the blogpost. Where and when do you post it?

@werto87

I think the blogpost will be a bit delayed... because I thought it was a good idea to refactor my personal blog using some modern technology... and now I'm starting to play with NuxtJS and TailwindCSS 😅

But, you can check the steps here: https://github.com/jgsogo/blog-20211008-example-emsdk-magnum

@jgsogo
Copy link
Contributor

jgsogo commented Nov 10, 2021

Hi! I've finally recreated my blog from scratch... and learned some NuxtJS in the process (still a lot of details to improve, I'm really bad at CSS) 🚀 Here you have the blogpost (most like a draft/quick notes): https://jgsogo.es/blog/2021-11-10-emscripten-magnum/

@werto87
Copy link
Contributor Author

werto87 commented Nov 11, 2021

Hi, thanks for the credits. It was a good read. I will try it out.

@werto87
Copy link
Contributor Author

werto87 commented Nov 11, 2021

I tried it on arch linux and it works perfectly 👍 .
Is there a reason why you show an image instead of the same image as wasm at the beginning?

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

Successfully merging this pull request may close these issues.

[request] libraries needed to update conan/examples: emsdk, imgui, glfw, glew, folly
8 participants