Discussion:
[m-users.] Adding a command line option
Mark Green
2013-07-27 00:39:50 UTC
Permalink
Hi,

What's the easiest way to add a new command line option to mmc? I have been
trying to deal with my Erlang build problem by modifying
compile_target_code.m to pass full paths to erlc, but I would like to make
this behavior optional and I cannot find the part of the code that converts
from strings on the command line to atoms that are looked up via
lookup_bool_option.

Mark
Peter Wang
2013-07-27 01:53:53 UTC
Permalink
Post by Mark Green
Hi,
What's the easiest way to add a new command line option to mmc? I have been
trying to deal with my Erlang build problem by modifying
compile_target_code.m to pass full paths to erlc, but I would like to make
this behavior optional and I cannot find the part of the code that converts
from strings on the command line to atoms that are looked up via
lookup_bool_option.
In options.m. For a quick test, you can make use of an existing
string option "--experiment".

Which paths are problematic?

Peter
Mark Green
2013-07-27 23:50:25 UTC
Permalink
When the build calls erlc, it passes it relative paths to the input and
output directory, which can cause problems if you are running under MSYS
and using a Windows build of erlc, because erlc will run in the Windows
context rather than the bash context that mmc and MSYS are running in and
thus have a different base for relative paths. I did find though that
calling dir.get-current-directory does return the correct path from mmc's
bash environment and thus prepending that to the paths passed to erlc may
fix the problem - I have still to try it fully though.

(For some reason a moderator blocked this message off the list saying I'm
not a member, but I am...?)

Mark
Julien Fischer
2013-07-29 01:48:43 UTC
Permalink
Hi,
Post by Mark Green
When the build calls erlc, it passes it relative paths to the input
and output directory, which can cause problems if you are running
under MSYS and using a Windows build of erlc, because erlc will run in
the Windows context rather than the bash context that mmc and MSYS are
running in and thus have a different base for relative paths. I did
find though that calling dir.get-current-directory does return the
correct path from mmc's bash environment and thus prepending that to
the paths passed to erlc may fix the problem - I have still to try it
fully though.
(For some reason a moderator blocked this message off the list saying
I'm not a member, but I am...?)
The message was blocked because it was from a different email address.
(I approved it -- I think -- but it hasn't showed up.)

Cheers,
Julien.
Julien Fischer
2013-07-29 17:02:54 UTC
Permalink
Post by Mark Green
Post by Mark Green
Hi,
What's the easiest way to add a new command line option to mmc? I have
been
Post by Mark Green
trying to deal with my Erlang build problem by modifying
compile_target_code.m to pass full paths to erlc, but I would like to
make
Post by Mark Green
this behavior optional and I cannot find the part of the code that
converts
Post by Mark Green
from strings on the command line to atoms that are looked up via
lookup_bool_option.
In options.m. For a quick test, you can make use of an existing
string option "--experiment".
Which paths are problematic?
I'm not sure about the problem that Mark has encountered, but one issue we
definitely have
with the erlang grade on Windows is that the values of
MERCURY_ERLANG_{COMPILER,INTERPRETER}
contains spaces if the OTP is installed in the default location (in Program
Files). This breaks compilation of
the standard library. We should take the basename of the value returned by
the configuration tests in this case,
as we do for the Java tools in the same situation (I'll commit a
change that does this tomorrow.)

Cheers,
Julien.
Mark Green
2013-07-29 17:57:54 UTC
Permalink
Hi,

The problem I've had is that when mmc calls erlc, it passes it two relative
paths in the -I and -O options.

This causes a problem if mmc is running within MSYS under Windows, because
the Windows erlc - being a full blown Windows program, not an MSYS one -
will interpret those paths relative to the current Windows directory, not
to the current MSYS/bash directory, which might not be the same. If they
are not the same then erlc will fail to find the paths and abort.

The change I wanted to make was to calculate the current absolute paths and
pass those to erlc rather than the relative paths, so that it does not
matter which directory erlc considers its base directory.

Mark
Post by Julien Fischer
Post by Mark Green
Post by Mark Green
Hi,
What's the easiest way to add a new command line option to mmc? I have
been
Post by Mark Green
trying to deal with my Erlang build problem by modifying
compile_target_code.m to pass full paths to erlc, but I would like to
make
Post by Mark Green
this behavior optional and I cannot find the part of the code that
converts
Post by Mark Green
from strings on the command line to atoms that are looked up via
lookup_bool_option.
In options.m. For a quick test, you can make use of an existing
string option "--experiment".
Which paths are problematic?
I'm not sure about the problem that Mark has encountered, but one issue we
definitely have
with the erlang grade on Windows is that the values of
MERCURY_ERLANG_{COMPILER,INTERPRETER}
contains spaces if the OTP is installed in the default location (in
Program Files). This breaks compilation of
the standard library. We should take the basename of the value returned by
the configuration tests in this case,
as we do for the Java tools in the same situation (I'll commit a
change that does this tomorrow.)
Cheers,
Julien.
_______________________________________________
users mailing list
http://lists.mercurylang.org/listinfo/users
Zoltan Somogyi
2013-07-27 01:08:41 UTC
Permalink
Post by Mark Green
What's the easiest way to add a new command line option to mmc? I have been
trying to deal with my Erlang build problem by modifying
compile_target_code.m to pass full paths to erlc, but I would like to make
this behavior optional and I cannot find the part of the code that converts
from strings on the command line to atoms that are looked up via
lookup_bool_option.
The actual code that does that is in library/getopt.m (generic option handling)
and compiler/handle_options.m, but you probably do not need to touch any of
that. What you are after is almost certainly the options database in
compiler/options.m.

Zoltan.
Julien Fischer
2013-07-29 01:38:55 UTC
Permalink
Hi,
Post by Mark Green
What's the easiest way to add a new command line option to mmc? I have
been trying to deal with my Erlang build problem by modifying
compile_target_code.m to pass full paths to erlc, but I would like to
make this behavior optional and I cannot find the part of the code
that converts from strings on the command line to atoms that are
looked up via lookup_bool_option.
If badly formed paths are being passed to the Erlang compiler then
passing the correct ones should not be optional. It's possible that
compile_target_code.m needs to modify the paths for erlc on Windows
depending on what the setting of --host-env-type is. (We do soemthing
similar for the csharp grade.)

Where (and how) exactly is your Erlang build going wrong?

Cheers,
Julien.
Loading...