-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Support emsdk --embedded mode #10935
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
Conversation
tools/shared.py
Outdated
@@ -265,6 +265,12 @@ def generate_config(path, first_time=False): | |||
# 4. Fall back users home directory (~/.emscripten). | |||
|
|||
embedded_config = path_from_root('.emscripten') | |||
# For compatability with emsdk --embedded mode also look two levels up. This | |||
# could be removed in emsdk was use the emscripten directory itself for the |
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.
I don't follow this statement - should in
be if
, and use
be using
?
But I'm not sure I get it. When are embedded_config
and emsdk_embedded_config
different? Clarifying that would be useful here I think.
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.
Thanks, fixed the grammar there.
The issue is that emsdk's --embedded mode currently always puts the .emscripton config file in the root of the emsdk, which is two levels up from the emscripten directory. I'm working on trying to change that but it seems a little complicated.
emscripten already has support for an embedded config, but only its own directory.
This change is only really needs for users who don't run emsdk_env.sh
and just run emcc
directly.
Most users are expected to run emsdk_env.sh
to use the SDK, but it turns out the if you just run /path/to/emscripten/emcc
without running emsdk_env.sh
today it often just works because emscripten knowns how to find its config and everything flows from there. Without this change if you use emsdk --embedded
and then run /path/to/emcc
without having first run emsdk_env.sh
then emscripten will not find any config file at all and default back to its method of create new config file with default settings in $HOME.
This change means that emsdk users won't see this default bahaviour becuse them will look in the correct plance for the embedded config file, even if EM_CONFIG is not set (which it normally is when you run emsdk_env.sh
).
Sorry for the long explanation, its kind of annoyingly complicated.
This change allows emsdk --embdded mode to work out of the box without running emsdk_env.sh. This paves makes it easier to justify using embedded mode by default: emscripten-core/emsdk#472 This is part of a larger plan to avoid using the $HOME directory to store anything at all: #9543
3eb672b
to
bb27346
Compare
tldr; This change is the minimize the impact of switch to |
tools/shared.py
Outdated
@@ -265,6 +265,12 @@ def generate_config(path, first_time=False): | |||
# 4. Fall back users home directory (~/.emscripten). | |||
|
|||
embedded_config = path_from_root('.emscripten') | |||
# For compatibility with emsdk --embedded mode also look two levels up. This |
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.
maybe mention why two levels up? That is, that when using the emsdk, the structure would look like
emsdk/
emscripten/
But that picture must be wrong since you say two levels and not one..?
The tl;dr sounds good! Sorry I don't get the technical details yet. |
Added more comments that should make it more obvious why we need this. |
I'm sorry, I still don't get it  why 2 levels up? Is it not this:
Where is the extra directory? I really think it would be good to add a little drawing like that into the comment, it would have helped me get this a lot sooner. |
Also not that this change is more a convenience for emsdk users that forget to run emsdk users that correctly set thier environment will not be effected by this. It also only effects users of |
The places that emscripten lives with the emsdk look like this:
Or if building from source they look like:
It never lives directly in |
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.
I see now, thanks!
lgtm with an explanation for the 2 levels in a comment. I think something like your last comment would be great.
I did add a lot of comments to the code already. Did you look at the latest version? Do you think it needs more? |
tools/shared.py
Outdated
# 3. If emscripten-local .emscripten file is found, use that | ||
# 4. Fall back users home directory (~/.emscripten). | ||
# 3. Local .emscripten file, if found | ||
# 4. Local .emscripten file, as written by emsdk --embedded (two levels up), if found. |
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.
It says "two levels" here, but without a little graph like in that comment of yours, it's very unclear I think.
likewise, on line 269 it also says "two levels" but doesn't explain.
If I'm being unclear here, I apologize, and feel free to land this - I'll open a followup PR.
I included some exampels. |
Thanks! |
This change allows
emsdk --embdded
mode to work out of the boxwithout running emsdk_env.sh.
This paves makes it easier to justify using embedded mode by default:
emscripten-core/emsdk#472
This is part of a larger plan to avoid using the $HOME directory to
store anything at all: #9543