使用Bazel作为构建系统的Erlang Hello World

iqih9akk  于 2022-12-16  发布在  Erlang
关注(0)|答案(1)|浏览(202)

我想在Ubuntu 22.04上使用rules_erlang构建一个Erlang hello world示例。
我的设置如下所示:

  • 构建bazel*
load("@rules_erlang//:erlang_app.bzl", "erlang_app", "test_erlang_app")
load("@rules_erlang//:xref.bzl", "xref")
load("@rules_erlang//:dialyze.bzl", "dialyze", "plt")
load("@rules_erlang//:ct.bzl", "ct_suite", "assert_suites")

APP_NAME = "hello_world"
APP_VERSION = "0.1.0"

erlang_app(
    app_name = APP_NAME,
    app_version = APP_VERSION,
)
  • 源代码/hello_world.erl*
-module(hello_world).
-compile(export_all).

hello() ->
    io:format("hello world~n").
  • 工作空间.bazel*
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "bazel_skylib",
    sha256 = "af87959afe497dc8dfd4c6cb66e1279cb98ccc84284619ebfec27d9c09a903de",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.2.0/bazel-skylib-1.2.0.tar.gz",
        "https://github.com/bazelbuild/bazel-skylib/releases/download/1.2.0/bazel-skylib-1.2.0.tar.gz",
    ],
)

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()

http_archive(
    name = "rules_erlang",
    sha256 = "5e59800ecc786d5375951028c959c6e6275c94eff2a52f5d53ccb1ad8b2ea20a",
    strip_prefix = "rules_erlang-3.8.4",
    urls = ["https://github.com/rabbitmq/rules_erlang/archive/refs/tags/3.8.4.zip"],
)

load(
    "@rules_erlang//:rules_erlang.bzl",
    "erlang_config",
    "rules_erlang_dependencies",
)

erlang_config()

rules_erlang_dependencies()

load("@erlang_config//:defaults.bzl", "register_defaults")

register_defaults()

该代码也可以在here中找到。
当我执行bazel build //...的时候
错误:/home/顶点路径/.cache/bazel/_bazel_顶点路径/b5 f945 f94177 a8 ffa 6ac 0 f7108 dfc 1cd/外部/erlang_config/外部/构建.bazel:12:16:验证/usr处的OTP失败:(退出1):bash失败:执行命令/bin/bash -c时出错...(跳过剩余的1个参数)
使用--sandbox_debug查看来自沙箱的详细消息,并保留沙箱构建根以调试Erlang版本不匹配(预期为UNKNOWN,实际为24.2.1)
任何提示,让这个工作是受欢迎的!

im9ewurl

im9ewurl1#

bazel build //... --sandbox_debug

给了我

compile: warnings being treated as errors
hello_world.erl:2:2: export_all flag enabled - all functions will be exported

使用-export([hello/0]).而不是-compile(export_all).时,它可以正常工作
一个二个一个一个

相关问题