{"id":13471067,"url":"https://github.com/shiguredo/rebar3_zig","last_synced_at":"2025-04-12T23:22:12.075Z","repository":{"id":50432694,"uuid":"515851329","full_name":"shiguredo/rebar3_zig","owner":"shiguredo","description":"Rebar3 plugin to call Zig functions from Erlang using NIF","archived":false,"fork":false,"pushed_at":"2023-02-14T08:00:39.000Z","size":949,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"develop","last_synced_at":"2025-04-11T16:11:32.668Z","etag":null,"topics":["erlang","zig"],"latest_commit_sha":null,"homepage":"","language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shiguredo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-20T05:53:21.000Z","updated_at":"2023-10-30T06:19:51.000Z","dependencies_parsed_at":"2024-10-14T14:42:12.050Z","dependency_job_id":"daff0de6-b877-4efe-b4bc-a31cacb95db9","html_url":"https://github.com/shiguredo/rebar3_zig","commit_stats":{"total_commits":26,"total_committers":1,"mean_commits":26.0,"dds":0.0,"last_synced_commit":"e3c9364aa1a9d5678b81774dae026103630c118c"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shiguredo%2Frebar3_zig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shiguredo%2Frebar3_zig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shiguredo%2Frebar3_zig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shiguredo%2Frebar3_zig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shiguredo","download_url":"https://codeload.github.com/shiguredo/rebar3_zig/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248565078,"owners_count":21125415,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["erlang","zig"],"created_at":"2024-07-31T16:00:39.248Z","updated_at":"2025-04-12T23:22:12.055Z","avatar_url":"https://github.com/shiguredo.png","language":"Erlang","funding_links":[],"categories":["Erlang"],"sub_categories":[],"readme":"rebar3_zig\n==========\n\n[![hex.pm version](https://img.shields.io/hexpm/v/rebar3_zig.svg)](https://hex.pm/packages/rebar3_zig)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\n[Erlang] から [Zig] で書かれたコードを利用可能にするための [Rebar3] プラグインです。\n内部では Erlang の [NIF] (Native Implemented Functions) という機能を利用しています。\n\n[Erlang]: https://www.erlang.org/\n[Zig]: https://ziglang.org/\n[Rebar3]: https://github.com/erlang/rebar3\n[NIF]: https://www.erlang.org/doc/tutorial/nif.html\n\n## About Shiguredo's open source software\n\nWe will not respond to PRs or issues that have not been discussed on Discord. Also, Discord is only available in Japanese.\n\nPlease read https://github.com/shiguredo/oss/blob/master/README.en.md before use.\n\n## 時雨堂のオープンソースソフトウェアについて\n\n利用前 https://github.com/shiguredo/oss をお読みください。\n\n## 使い方\n\n基本的な使い方は以下の通りです:\n\n```console\n////////\n// 1) 適当な rebar3 プロジェクトを作成\n$ rebar3 new lib zig_sample\n$ cd zig_sample/\n\n\n////////\n// 2) rebar3_zig をプロジェクトプラグインとして追加\n$ echo \"\\n{project_plugins, [rebar3_zig]}.\" \u003e\u003e rebar.config\n\n\n////////\n// 3) rebar3 のテンプレート機能を使って Zig 用のファイル群を生成\n\n// 自分の環境での NIF 用ヘッダのインクルードパスを指定\n// （ここでは省略して後で C_INCLUDE_PATH 環境変数に指定するのでも可）\n$ INCLUDE_PATH=/path/to/erlang/erts-${ ERTS_VERSION }/include/\n\n// NIF 関数呼び出し用に生成される Erlang のモジュール名を指定\n$ NIF_MODULE_NAME=sample\n\n// ファイル生成\n$ rebar3 new zig name=$NIF_MODULE_NAME include_path=$INCLUDE_PATH\n===\u003e Analyzing applications...\n===\u003e Compiling rebar3_zig\n===\u003e Writing zig_src/build.zig\n===\u003e Writing zig_src/nif.zig\n===\u003e Writing zig_src/main.zig\n===\u003e Writing src/sample.erl\n\n$ cat zig_src/main.zig\nconst std = @import(\"std\");\n\npub fn add(x: c_int, y: c_int) c_int {\n    return x + y;\n}\n\ntest \"add\" {\n    try std.testing.expectEqual(add(1, 2), 3);\n}\n\n\n////////\n// 4) コンパイルとテスト\n$ rebar3 zig compile\n===\u003e Analyzing applications...\n===\u003e Compiling rebar3_zig\n===\u003e Verifying dependencies...\n===\u003e Analyzing applications...\n===\u003e Compiling zig_sample\n===\u003e Running zig compile...\n===\u003e Moving artifacts...\n===\u003e Moved: \"zig_src/zig-out/lib/libsample.0.0.0.dylib\" =\u003e \"priv/libsample.so\"\n\n$ rebar3 zig test\n===\u003e Analyzing applications...\n===\u003e Compiling rebar3_zig\n===\u003e Running zig test...\nAll 1 tests passed.\n\n\n////////\n// 5) Erlang シェルからの NIF 関数呼び出し\n$ rebar3 shell\n\u003e sample:add(1, 2).\n3\n```\n\nまた rebar.config ファイルに以下のフックを追加することで、\n`$ rebar3 compile` や `$ rebar3 eunit` 実行時に自動で Zig のコードのコンパイルやテストが実行可能になります。\n\n```erlang\n{provider_hooks, [{post, [{compile, {zig, compile}},\n                          {eunit, {zig, test}},\n                          {clean, {zig, clean}}]}]}.\n```\n\n## ライセンス\n\n[Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0)\n\n```\nCopyright 2022-2022, Takeru Ohta (Original Author)\nCopyright 2022-2022, Shiguredo Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshiguredo%2Frebar3_zig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshiguredo%2Frebar3_zig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshiguredo%2Frebar3_zig/lists"}