{"id":24218036,"url":"https://github.com/sackosoft/zig-luajit-build","last_synced_at":"2025-06-18T03:37:15.471Z","repository":{"id":272201065,"uuid":"915808295","full_name":"sackosoft/zig-luajit-build","owner":"sackosoft","description":"A package to compile LuaJIT using the Zig toolchain. Install to access the LuaJIT C API. For Zig API see https://github.com/sackosoft/zig-luajit","archived":false,"fork":false,"pushed_at":"2025-05-18T02:03:10.000Z","size":59,"stargazers_count":12,"open_issues_count":1,"forks_count":4,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-05-18T03:22:24.140Z","etag":null,"topics":["luajit","zig","zig-package"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sackosoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"zenodo":null}},"created_at":"2025-01-12T21:13:06.000Z","updated_at":"2025-05-18T02:02:20.000Z","dependencies_parsed_at":"2025-01-12T22:25:40.192Z","dependency_job_id":"070f7d92-3ed4-4b52-af90-bd6014643fda","html_url":"https://github.com/sackosoft/zig-luajit-build","commit_stats":null,"previous_names":["sackosoft/zig-luajit-build"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/sackosoft/zig-luajit-build","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sackosoft%2Fzig-luajit-build","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sackosoft%2Fzig-luajit-build/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sackosoft%2Fzig-luajit-build/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sackosoft%2Fzig-luajit-build/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sackosoft","download_url":"https://codeload.github.com/sackosoft/zig-luajit-build/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sackosoft%2Fzig-luajit-build/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260483599,"owners_count":23016084,"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":["luajit","zig","zig-package"],"created_at":"2025-01-14T05:14:36.122Z","updated_at":"2025-06-18T03:37:10.455Z","avatar_url":"https://github.com/sackosoft.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# zig-luajit-build\n\nUsed to compile and link the native [LuaJIT][LUAJIT] C API into Zig ⚡ applications.\n\n![Ubuntu Build Status Badge](https://img.shields.io/github/actions/workflow/status/sackosoft/zig-luajit-build/build-ubuntu.yml?label=Linux%20Build)\n![Windows Build Status Badge](https://img.shields.io/github/actions/workflow/status/sackosoft/zig-luajit-build/build-windows.yml?label=Windows%20Build)\n![GitHub License](https://img.shields.io/github/license/sackosoft/zig-luajit-build)\n\n\u003c!--\nTODO: Capture attention with a visualization, diagram, demo or other visual placeholder here.\n![Placeholder]()\n--\u003e\n\n\u003c/div\u003e\n\nLuaJIT is a fork from the [Lua][LUA] project -- \"Lua is a powerful, efficient, lightweight, embeddable scripting language.\"\n\n[LUAJIT]: https://luajit.org/index.html\n[LUA]: https://www.lua.org/about.html\n\n## Are you looking for a Zig interface to the LuaJIT C API?\n\nThis package does not contain Zig language bindings to the C API. This package only handles building and linking the\nLuaJIT library into a Zig application.\n\nIf you're looking to run Lua on LuaJIT in your Zig application, you're probably looking for one of these projects:\n\n1. [sackosoft/zig-luajit](https://github.com/sackosoft/zig-luajit) **- Zig language bindings LuaJIT.**\n    - Preferred solution when only one Lua runtime (LuaJIT) is required;  built on top of `zig-luajit-build`.\n2. [natecraddock/ziglua](https://github.com/natecraddock/ziglua) - Zig language bindings for Lua 5.x and Luau and LuaJIT.\n    - More mature project, maintained by Nathan Craddock. Has some quirks as a result of supporting all Lua runtimes\n      with the same Zig API.\n\n## Zig Version\n\nThe `main` branch targets Zig's `master` (nightly) deployment (last tested with `0.14.0-dev.3267+59dc15fa0`).\n\n## Installation \u0026 Usage\n\nInstall using `zig fetch`. This will add a `luajit_build` dependency to your `build.zig.zon` file.\n\n```bash\nzig fetch --save=luajit_build git+https://github.com/sackosoft/zig-luajit-build\n```\n\nNext, in order for your code to import the LuaJIT C API, you'll need to update your `build.zig` to:\n\n1. get a reference to the `luajit-build` dependency which was added by zig fetch.\n2. get a reference to the `luajit-build` module, containing the native LuaJIT C API.\n3. attach that module as an import to your library or executable, so that your code can reference the C API.\n\n```zig\n// (1) Reference the dependency\nconst luajit_build_dep = b.dependency(\"luajit_build\", .{\n    .target = target, \n    .optimize = optimize,\n    .link_as = .static  // Or .dynamic to link as a shared library\n});\n\n// (2) Reference the module containing the LuaJIT C API.\nconst luajit_build = luajit_build_dep.module(\"luajit-build\");\n\n// Set up your library or executable\nconst lib = // ...\nconst exe = // ...\n\n// (3) Add the module as an import, available via `@import(\"c\")`, or any other name you choose here.\nlib.root_module.addImport(\"c\", luajit_build);\n// Or\nexe.root_module.addImport(\"c\", luajit_build);\n```\n\nNow the code in your library or executable can import and access the LuaJIT C API!\n\n```zig\nconst c = @import(\"c\");  // Access LuaJIT functions via 'c'\n\npub fn main() !void {\n    const state: ?*c.lua_State = c.luaL_newstate();\n    if (state) |L| {\n        c.luaL_openlibs(L);\n        c.luaL_dostring(\n            L, \n            \\\\ print(\"Hello, world!\")\n        );\n    }\n}\n```\n\n## Configuration\n\nThis package supports one configuration option, shown in the example above.\n\n- `link_as`: Controls how LuaJIT is linked\n  - `.static`: Build and link LuaJIT as a static library (default).\n  - `.dynamic`: Build and link LuaJIT as a shared library.\n\n## License\n\nSome files in this repository were copied or adapted from the [natecraddock/ziglua](https://github.com/natecraddock/ziglua) project.\nAny files copied or adapted from that project have a comment describing the attribution at the top. Such files are shared by Nathan\nCraddock under the MIT License in [ziglua/license](https://github.com/natecraddock/ziglua/blob/90dab7e72173709353dcaaa6d911bed7655c030d/license).\n\nAll other files are released under the MIT License in [zig-luajit-build/LICENSE](./LICENSE).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsackosoft%2Fzig-luajit-build","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsackosoft%2Fzig-luajit-build","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsackosoft%2Fzig-luajit-build/lists"}