【问题标题】:Skip port compilation for certain OS?跳过某些操作系统的端口编译?
【发布时间】:2012-09-11 13:29:10
【问题描述】:

我有一个基于 Rebar 的 Erlang 应用程序,它构建了一个端口程序。此端口程序是 Linux 特定的,因此在 Mac OS 上编译失败。但是,我希望 Rebar 在 Mac OS 上构建时跳过端口程序。我该怎么做?

rebar.config 中的当前规范如下所示:

{port_specs, [{"priv/my_port", ["c_src/foo.c", "c_src/bar.c"]}]}.

【问题讨论】:

    标签: compilation erlang rebar


    【解决方案1】:

    作为documented in comments in rebar_port_compiler.erlport_specs 的列表元素有另一种形式{ArchRegex, TargetFile, Sources}。所以像这样编写你的 Rebar 配置:

    {port_specs, [{"linux", "priv/my_port", ["c_src/foo.c", "c_src/bar.c"]}]}.
    

    “那个正则表达式匹配的是什么?”,你可能会问。它与rebar_utils:get_arch的返回值匹配,它由以下部分组成,用连字符分隔:

    • erlang:system_info(otp_release) 返回的 OTP 版本,例如"R15B02"
    • erlang:system_info(system_architecture) 返回的系统架构。对于类 Unix 系统,这是由配置脚本确定的 CPU-vendor-OS 三元组,例如"i386-apple-darwin10.8.0""x86_64-unknown-linux-gnu"
    • 模拟器字长,32 或 64,基于 erlang:system_info({wordsize, external}) 的返回值。
    • 操作系统系列,unixwin32。 (os:type/0 返回的元组的第一个元素)

    所以最终结果将类似于"R15B01-i386-apple-darwin10.8.0-32-unix""R15B02-x86_64-unknown-linux-gnu-64-unix"

    【讨论】:

      猜你喜欢
      • 2010-09-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-14
      • 2023-03-18
      • 2015-03-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多