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

embedded mode #13

Open
vladdu opened this issue Oct 23, 2014 · 8 comments
Open

embedded mode #13

vladdu opened this issue Oct 23, 2014 · 8 comments

Comments

@vladdu
Copy link

vladdu commented Oct 23, 2014

Hi! I like mad as a replacement for rebar.

I see however that it's still meant to be used as a script, while I would like to be able to use it from the Erlang shell -- it would not shut down after running and the errors/warnings/progress messages would be returned or sent to a listener process as Erlang messages.

Do you have any plans for supporting something like that?

@5HT
Copy link
Member

5HT commented Oct 23, 2014

You can use mad a a regular OTP application, from shell and from other apps.
We created MAD to embed in our application to be able to recompile itself.
That is why we need lightweight recompilation framework, this is main purpose of MAD.
As you can see N2O sample already includes MAD as a dep.

@5HT 5HT closed this as completed Oct 23, 2014
@vladdu
Copy link
Author

vladdu commented Oct 23, 2014

Ok, but if I want to get the warnings/errors back in order to process them, I need to install my own group leader and listen what is written to the output. Is this something you might want to handle, or is it up to each user?

Regarding the shutting down, I see it's only after calling help() that it happens, so it should not be called in embedded mode.

@5HT
Copy link
Member

5HT commented Oct 23, 2014

You mean only extending the error reporting ?

@vladdu
Copy link
Author

vladdu commented Oct 23, 2014

Yes. A way to do that would be to let the user supply an (optional) callback that will receive the results for each compiled file and do something with them. The default would be to io:format them. Then the compilers should return any errors/warnings/info as a list and feed them to the callback.

I'm not sure if all the supported compilers have a 'return' option that would do that; in the worst case the alternative would be to still install an own group leader, but it would be hidden from the users.

If this is interesting, I will be glad to contribute implementation.

@5HT
Copy link
Member

5HT commented Oct 23, 2014

It should be easy.
I'm reopening the issue, please provide a small patch, I will accept it.

@5HT 5HT reopened this Oct 23, 2014
@5HT
Copy link
Member

5HT commented Oct 23, 2014

just put some Pid ! ErrorOrStatusMessage near MAD's printfs.

@vladdu
Copy link
Author

vladdu commented Oct 23, 2014

I'm not sure if that is enough, each compiler does io:format on its own. I will look at all supported compilers to see if they can return errors/warnings.

I understand that you want a simple callback via a Pid, not some fun that the user can provide, right?

@5HT
Copy link
Member

5HT commented Oct 23, 2014

Better just register Pid and use message protocol than use JavaScript-like callbacks spaghetti.

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

No branches or pull requests

2 participants