emscripten icon indicating copy to clipboard operation
emscripten copied to clipboard

Add an option to generate a config file (as on first run) to a specific location

Open mdobrogostsc opened this issue 8 years ago • 8 comments

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.

mdobrogostsc avatar Mar 06 '18 16:03 mdobrogostsc

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?

kripken avatar Mar 12 '18 18:03 kripken

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.

mdobrogostsc avatar Mar 12 '18 19:03 mdobrogostsc

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?

froydnj avatar Mar 30 '18 20:03 froydnj

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.

mdobrogostsc avatar Apr 02 '18 16:04 mdobrogostsc

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?

kripken avatar Apr 02 '18 23:04 kripken

emcc --generate-config $PATH makes sense to me.

mdobrogostsc avatar Apr 03 '18 21:04 mdobrogostsc

Cool, edited the title.

kripken avatar Apr 03 '18 21:04 kripken

Implemented by that PR.

kripken avatar Jul 16 '18 16:07 kripken