简体   繁体   English

如何使用:emu_args将标志发送到erlang vm?

[英]How do I send flags to the erlang vm using :emu_args?

I want to send arguments to the erlang vm, but 'emu_args: "+A32"' appears after the "-escript main parallel_tree_walk_escript" and appears to become arguments for the elixir program instead of affecting the erlang VM. 我想向erlang vm发送参数,但是'emu_args:“ + A32”在“ -escript main parallel_tree_walk_escript”之后出现,并且似乎成为elixir程序的参数,而不影响erlang VM。

Without 'emu_args: "+A32"', the file created by "mix escript.build" contains line three 如果没有'emu_args:“ + A32”',则由“ mix escript.build”创建的文件包含第三行

%%! -escript main parallel_tree_walk_escript

I seem to get the results I want if I alter that line with emacs (copes well with the non-ascii contents) to 如果我用emacs更改该行(与非ascii内容完全匹配),我似乎得到了想要的结果

%%! +A32 -escript main parallel_tree_walk_escript

However, if I use 'emu_args: "+A32" in mix.esx, the line becomes 但是,如果我在mix.esx中使用'emu_args:“ + A32”,则该行将变为

%%! -escript main parallel_tree_walk_escript +A32

...and "+A32" appears not to go to the erlang vm, but instead appear as the first command line element of the args array. ...和“ + A32”似乎并没有进入erlang vm,而是显示为args数组的第一个命令行元素。

# permits emacs edit of parallel_tree_walk result
  def escript do
    [
      main_module: ParallelTreeWalk,
    ]
  end

But this apparently puts the argument in the wrong location: 但这显然将论点放在错误的位置:

  def escript do
    [
      main_module: ParallelTreeWalk,
      emu_args: "+A32"
    ]
  end

I hoped for 我希望

%%! +A32 -escript main parallel_tree_walk_escript

but the result was 但是结果是

%%! -escript main parallel_tree_walk_escript +A32

which doesn't work. 这不起作用。

If I generate an escript, and manually add the -emu_args flag, in the same way you moved the +A32 flag, I get the same output whether +A32 is before or after the escript name: 如果生成电子脚本,并以与移动+A32标志相同的方式手动添加-emu_args标志,则无论+A32是在电子脚本名称之前还是之后,我都会得到相同的输出:

# %%! -emu_args -escript main test_escript +A32 
# %%! +A32 -emu_args -escript main test_escript

Both produce (truncated some paths for brevity): 两者都会产生(为了简洁起见,将一些路径截断了):

Executing: …beam.smp ./test -B -A32 -- -root …erlang/21.3 -progname erl -- -home /Users/adam -- -boot no_dot_erlang -noshell -escript main test_escript -run escript start -extra ./test

Maybe you could try adding the emu_args parameter to see what's happening. 也许您可以尝试添加emu_args参数以查看发生了什么。 It could be that the +A32 flag is getting to the VM. 可能是+A32标志进入了VM。

This is the first time I've looked at escripts, so I was curious that the argument to beam ended up as -A32 instead of +A32 , but that seems to be a difference between executing the emulator directly, or via a script. 这是我第一次查看脚本,因此我很好奇beam的参数以-A32而不是+A32 -A32 ,但这似乎是直接执行仿真器或通过脚本执行仿真器之间的区别。 Calling …beam.smp --help does indeed list the -A version along with a final note that says: 实际上,调用…beam.smp --help确实会列出-A版本以及最后的注释:

Note that if the emulator is started with erlexec (typically from the erl script), these flags should be specified with +. 请注意,如果仿真器以erlexec启动(通常是从erl脚本启动),则这些标志应使用+指定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM