Add an option to generate a config file (as on first run) to a specific location
shared.py defines two behaviors for the .emscripten config:
(1) existence check
(2) initialization
Currently the code errors out when it hits (1) which means that (2) never executes for cases where EM_SCRIPTEN is defined but is not yet initialized. This is required to support initialization of .emscripten in files locations other than ~/.emscripten.
I don't understand - using a location other than ~/.emscripten is what that option does, so you're saying it is broken? I believe we have tests for it (grep for EM_CONFIG in the tests suite), do those pass for you?
If EM_CONFIG is undefined everything is OK (the code initialized a ~/.emscripten file).
If EM_CONFIG is set then the code breaks (it does not initialized the configuration file - it expects it to have already been configured).
It sounds like the tests don't cover this case.
OK, so the problematic scenario seems to be that EM_CONFIG is set to some nonexistent place, and the expectation is that it will be initialized if it does not exist. This initialization-if-does-not-exist behavior matches what's done for the default location, i.e. ~/.emscripten. But the actual behavior is that if EM_CONFIG is set and doesn't exist, we complain instead of initializing it. Is that correct?
Assuming the above description is correct, I don't know what to do here: presumably the non-existence check is to catch cases where the user has made a typo in setting EM_CONFIG. That behavior seems valuable to me. With the proposed behavior, a typo would cause some default settings to be used, which could be very confusing for the person who has set EM_CONFIG!
One way to address this is a EM_CREATE_NONEXISTENT_CONFIG environment variable or somesuch, but that feels like kind of a hack. Alternatively, we could just say that if you want a config someplace else than ~/.emscripten, tools/settings_template_readonly.py is available or you can cause ~/.emscripten to be created, and then move that file where you would like and set EM_CONFIG to said location.
Other ideas? Or should this be closed as wontfix?
Yes, that's a correct description of the problem.
I think having a standalone way to generate a configuration at any given path would be a good solution. Obviously this should be the only code path that generates any default configs.
What kind of warning or error do we show now for EM_CONFIG on a non-existent place? If we make that a clear error I think that's reasonable.
@mdobrogostsc I agree we should make it easy to create a configuration file. Maybe something like emcc --generate-config?
emcc --generate-config $PATH makes sense to me.
Cool, edited the title.
Implemented by that PR.