{"id":13896240,"url":"https://github.com/jirutka/luapak","last_synced_at":"2025-10-06T20:17:53.436Z","repository":{"id":62678202,"uuid":"92597357","full_name":"jirutka/luapak","owner":"jirutka","description":"Easily build a standalone executable for any Lua program","archived":false,"fork":false,"pushed_at":"2022-11-12T20:17:26.000Z","size":160,"stargazers_count":203,"open_issues_count":8,"forks_count":8,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-11-25T01:33:32.534Z","etag":null,"topics":["build-tool","lua","luarocks","static-binary"],"latest_commit_sha":null,"homepage":null,"language":"Lua","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/jirutka.png","metadata":{"files":{"readme":"README.adoc","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}},"created_at":"2017-05-27T12:27:57.000Z","updated_at":"2024-11-10T17:19:18.000Z","dependencies_parsed_at":"2022-11-04T10:45:56.212Z","dependency_job_id":null,"html_url":"https://github.com/jirutka/luapak","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/jirutka/luapak","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirutka%2Fluapak","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirutka%2Fluapak/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirutka%2Fluapak/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirutka%2Fluapak/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jirutka","download_url":"https://codeload.github.com/jirutka/luapak/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirutka%2Fluapak/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278672051,"owners_count":26025826,"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","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["build-tool","lua","luarocks","static-binary"],"created_at":"2024-08-06T18:02:45.909Z","updated_at":"2025-10-06T20:17:53.382Z","avatar_url":"https://github.com/jirutka.png","language":"Lua","funding_links":[],"categories":["Lua","Resources"],"sub_categories":["Build Tools and Standalone Makers"],"readme":"= Luapak\nJakub Jirutka \u003chttps://github.com/jirutka[@jirutka]\u003e\n:toc: macro\n:toc-title:\n// custom\n:proj-name: luapak\n:gh-name: jirutka/{proj-name}\n:gh-branch: master\n:appveyor-id: qmkkk86ldwvkvdc9\n:ldoc-url: https://jirutka.github.io/{proj-name}/ldoc/\n\nifdef::env-github[]\nimage:https://travis-ci.org/{gh-name}.svg?branch={gh-branch}[\"Build Status\", link=\"https://travis-ci.org/{gh-name}\"]\nimage:https://ci.appveyor.com/api/projects/status/{appveyor-id}/branch/{gh-branch}?svg=true[\"Windows Build Status\", link=\"https://ci.appveyor.com/project/{gh-name}\"]\nimage:https://img.shields.io/badge/ldoc-docs-blue.svg[\"LDoc\", link=\"{ldoc-url}\"]\nendif::env-github[]\n\n\nLuapak is a command-line tool that offers complete, multi-platform (Linux, macOS, and Windows), adjustable, all-in-one (yet modular) solution for building a standalone, zero-dependencies, possibly statically linked (only on Linux) executable for (almost) any Lua program.\nIt Just Works!\n\n. Resolves, builds and installs project’s Lua dependencies (declared in rockspec) from https://luarocks.org/[LuaRocks].\n  Lua/C modules (aka native extensions) are built as static libraries (`.a` archive files), so they can be statically linked into resulting executable.footnote:[Luapak includes LuaRocks package manager with rewritten https://github.com/luarocks/luarocks/wiki/Rockspec-format#builtin[builtin build backend] and modified settings to build Lua/C modules as static libraries. Other backends (make, cmake, …) are not supported in the sense that Luapak cannot alter build process to produce static libraries; it’s up to the user to ensure that.]\n. Resolves actually __require__d Lua and Lua/C modules (`.lua` and `.a` files) using static code analysis of the project and its dependencies (recursively).\n. Merges all required Lua modules into a single Lua script.\n. Minifies the Lua script (i.e. removes unnecessary characters to shrink its size) using https://github.com/jirutka/luasrcdiet[LuaSrcDiet].\n. Compresses the Lua script using https://github.com/jibsen/brieflz[BriefLZ] algorithm.\n. Embeds the Lua script into a generated C wrapper.\n. Compiles the C wrapper and links it with Lua interpreter (PUC Lua 5.1–5.3 and LuaJIT supported) and Lua/C libraries (aka native extensions) into a standalone executable.\n\nAll these steps can be run with single command `luapak make \u003crockspec\u003e`, or separately if you need more control.\nYou can discover available commands and their options in section \u003c\u003cCommands\u003e\u003e.\n\n\n[discrete]\n== Table of Contents\n\ntoc::[]\n\n\n== Commands\n\n=== luapak make\n\n// include:help-make:start\n// This is a generated content, do not edit it!\n// Note: AsciiDoc supports includes, but it's not enabled on GitHub.\n++++\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003csup\u003e\u003cem\u003eClick here to expand…\u003c/em\u003e\u003c/sup\u003e\n    \u003cpre\u003eUsage: luapak make [options] [PACKAGE...]\n       luapak make --help\n\nMakes a standalone executable from Lua package(s). This is the main Luapak\ncommand that handles entire process from installing dependencies to\ncompiling executable.\u003c/pre\u003e\n  \u003c/summary\u003e\n  \u003cpre\u003e\nArguments:\n  PACKAGE                         Lua package to build specified as \u0026lt;source-dir\u0026gt;:\u0026lt;rockspec\u0026gt;.\n                                  :\u0026lt;rockspec\u0026gt; may be omitted if the \u0026lt;source-dir\u0026gt; or\n                                  \u0026lt;source-dir\u0026gt;/rockspec(s) contains single rockspec, or multiple\n                                  rockspecs for the same package (i.e. with different version).\n                                  In the further case rockspec with the highest version is used.\n                                  \u0026lt;source-dir\u0026gt;: may be omitted if the \u0026lt;rockspec\u0026gt; is in the\n                                  project's source directory or rockspec(s) subdirectory.\n                                  If no argument is given, the current directory is used as\n                                  \u0026lt;source-dir\u0026gt;.\n\nOptions:\n  -s, --entry-script=FILE         The entry point of your program, i.e. the main Lua script. If not\n                                  specified and the last PACKAGE defines exactly one CLI script,\n                                  then it's used.\n\n  -e, --exclude-modules=PATTERNS  Module(s) to exclude from dependencies analysis and the\n                                  generated binary. PATTERNS is one or more glob patterns matching\n                                  module name in dot notation (e.g. \"pl.*\"). Patterns may be\n                                  delimited by comma or space. This option can be also specified\n                                  multiple times.\n\n  -g, --debug                     Enable debug mode, i.e. preserve line numbers, module names and\n                                  local variable names for error messages and backtraces.\n\n  -i, --include-modules=PATTERNS  Extra module(s) to include in dependencies analysis and add to\n                                  the generated binary. PATTERNS has the same format as in\n                                  \"--exclude-module\".\n\n      --lua-impl=NAME             The Lua implementation that should be used - \"PUC\" (default),\n                                  or \"LuaJIT\". This is currently used only as a hint to find the\n                                  correct library and headers when auto-detection is used\n                                  (i.e. --lua-incdir or --lua-lib is not specified).\n\n      --lua-incdir=DIR            The directory that contains Lua (or LuaJIT) headers. If not\n                                  specified, luapak will look for the lua.h (and luajit.h) file\n                                  inside: Luarock's LUA_INCDIR, ./vendor/lua, ./deps/lua,\n                                  /usr/local/include, and /usr/include. If --lua-version is\n                                  specified, then it will also try subdirectories lua\u0026lt;version\u0026gt; and\n                                  lua-\u0026lt;version\u0026gt; of each of the named directories and verify that\n                                  the found lua.h (or luajit.h) is for the specified Lua\n                                  (or LuaJIT) version.\n\n      --lua-lib=FILE              The library of Lua interpreter to include in the binary. If not\n                                  specified, luapak will try to find library with version\n                                  corresponding to the headers inside Luarock's LUA_LIBDIR,\n                                  ./vendor/lua, ./deps/lua, /usr/local/lib, /usr/local/lib64,\n                                  /usr/lib, and /usr/lib64.\n\n      --lua-version=VERSION       The version number of Lua (or LuaJIT) headers and library to try\n                                  to find (e.g. \"5.3\", \"2.0\").\n\n  -o, --output=FILE               Output file name or path. Defaults to base name of the main\n                                  script with stripped .lua extension.\n\n  -C, --no-compress               Disable BriefLZ compression of Lua sources.\n\n  -M, --no-minify                 Disable minification of Lua sources.\n\n  -t, --rocks-tree=DIR            The prefix where to install required modules. Default is\n                                  \".luapak\" in the current directory.\n  -q, --quiet                     Be quiet, i.e. print only errors.\n\n  -v, --verbose                   Be verbose, i.e. print debug messages.\n\n  -h, --help                      Display this help message and exit.\n\nEnvironment Variables:\n  AR          Archive-maintaining program; default is \"ar\".\n  CC          Command for compiling C; default is \"gcc\".\n  CMAKE       Command for processing CMakeLists.txt files; default is \"cmake\".\n  CFLAGS      Extra flags to give to the C compiler; default is \"-Os -fPIC\".\n  LD          Command for linking object files and archive files; default is \"ld\".\n  LDFLAGS     Extra flags to give to compiler when they are supposed to invoke the linker;\n              default on macOS is \"-pagezero_size 10000 -image_base 100000000\".\n  MAKE        Command for executing Makefile; default is \"make\".\n  RANLIB      Command for generating index to the contents of an archive; default is \"ranlib\".\n  STRIP       Command for discarding symbols from an object file; default is \"strip\".\u003c/pre\u003e\n\u003c/details\u003e\n++++\n// include:help-make:end\n\n\n=== luapak analyse-deps\n\n// include:help-analyse-deps:start\n// This is a generated content, do not edit it!\n// Note: AsciiDoc supports includes, but it's not enabled on GitHub.\n++++\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003csup\u003e\u003cem\u003eClick here to expand…\u003c/em\u003e\u003c/sup\u003e\n    \u003cpre\u003eUsage: luapak analyse-deps [-a|-f|-m|-g] [options] FILE...\n       luapak analyse-deps --help\n\nAnalyses dependency graph of Lua module(s) using static code analysis (looks\nfor \"require\" expressions).\u003c/pre\u003e\n  \u003c/summary\u003e\n  \u003cpre\u003e\nArguments:\n  FILE                        The entry point(s); path(s) to Lua script(s) to analyse.\n\nOptions:\n  -a, --all                   Print all information (default).\n  -f, --found                 Print only found modules.\n  -m, --missing               Print only missing modules.\n  -g, --ignored               Print only excluded/ignored modules.\n\n  -e, --excludes=PATTERNS     Module(s) to exclude from the dependencies analysis. PATTERNS is one\n                              or more glob patterns matching module name in dot notation\n                              (e.g. \"pl.*\"). Patterns may be delimited by comma or space. This\n                              option can be also specified multiple times.\n\n  -n, --ignore-errors         Ignore errors from dependencies resolution (like unredable or unparseable files).\n\n  -P, --no-pcalls             Do not analyse pcall requires.\n\n  -W, --no-wildcards          Do not expand \"wildcard\" requires.\n\n  -p, --pkg-path=PATH         The path pattern where to search for Lua and C/Lua modules instead of\n                              the default path.\n\n  -v, --verbose               Be verbose, i.e. print debug messages.\n\n  -h, --help                  Display this help message and exit.\u003c/pre\u003e\n\u003c/details\u003e\n++++\n// include:help-analyse-deps:end\n\n\n=== luapak build-rock\n\n// include:help-build-rock:start\n// This is a generated content, do not edit it!\n// Note: AsciiDoc supports includes, but it's not enabled on GitHub.\n++++\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003csup\u003e\u003cem\u003eClick here to expand…\u003c/em\u003e\u003c/sup\u003e\n    \u003cpre\u003eUsage: luapak build-rock [options] ROCKSPEC...\n       luapak build-rock --help\n\nBuilds Lua/C module as a library archive suitable for static linking\nand installs it into rocks tree.\u003c/pre\u003e\n  \u003c/summary\u003e\n  \u003cpre\u003e\nArguments:\n  ROCKSPEC                    Path of the rockspec file to build and install.\n\nOptions:\n  -C, --directory=DIR         Change directory before doing anything.\n\n  -i, --lua-impl=NAME         The Lua implementation that should be used - \"PUC\" (default), or\n                              \"LuaJIT\". This is currently used only as a hint to find the correct\n                              headers when auto-detection is used (i.e. --lua-incdir unspecified).\n\n  -I, --lua-incdir=DIR        The directory that contains Lua (or LuaJIT) headers. If not\n                              specified, luapak will look for the lua.h (and luajit.h) file inside:\n                              Luarock's LUA_INCDIR, ./vendor/lua, ./deps/lua, /usr/local/include,\n                              and /usr/include. If --lua-version is specified, then it will also\n                              try subdirectories lua\u0026lt;version\u0026gt; and lua-\u0026lt;version\u0026gt; of each of the\n                              named directories and verify that the found lua.h (or luajit.h) is\n                              for the specified Lua (or LuaJIT) version.\n\n  -l, --lua-version=VERSION   The version number of Lua (or LuaJIT) headers and library to try\n                              to find (e.g. \"5.3\", \"2.0\").\n\n  -t, --rocks-tree=DIR        The prefix where to install Lua/C modules Default is \".luapak\" in\n                              the current directory.\n\n  -v, --verbose               Be verbose, i.e. print debug messages.\n\n  -h, --help                  Display this help message and exit.\n\nEnvironment Variables:\n  AR          Archive-maintaining program; default is \"ar\".\n  CC          Command for compiling C; default is \"gcc\".\n  CMAKE       Command for processing CMakeLists.txt files; default is \"cmake\".\n  CFLAGS      Extra flags to give to the C compiler; default is \"-Os -fPIC\".\n  LD          Command for linking object files and archive files; default is \"ld\".\n  LDFLAGS     Extra flags to give to compiler when they are supposed to invoke the linker;\n              default on macOS is \"-pagezero_size 10000 -image_base 100000000\".\n  MAKE        Command for executing Makefile; default is \"make\".\n  RANLIB      Command for generating index to the contents of an archive; default is \"ranlib\".\u003c/pre\u003e\n\u003c/details\u003e\n++++\n// include:help-build-rock:end\n\n\n=== luapak merge\n\n// include:help-merge:start\n// This is a generated content, do not edit it!\n// Note: AsciiDoc supports includes, but it's not enabled on GitHub.\n++++\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003csup\u003e\u003cem\u003eClick here to expand…\u003c/em\u003e\u003c/sup\u003e\n    \u003cpre\u003eUsage: luapak merge [options] MODULE...\n       luapak merge --help\n\nCombines multiple Lua modules into a single file. Each module is be wrapped in\na function, or string loaded by \"load\" (--debug), and assigned to\n\"package.preload\" table.\u003c/pre\u003e\n  \u003c/summary\u003e\n  \u003cpre\u003e\nArguments:\n  MODULE                    Name and path of Lua module delimited with \"=\"\n                            (e.g. \"luapak.utils=luapak/utils.lua\") or just path of module.\n\nOptions:\n  -g, --debug               Preserve module names and line numbers in error backtraces?\n  -o, --output=FILE         Where to write the generated code. Use \"-\" for stdout. Default is \"-\".\n  -v, --verbose             Be verbose, i.e. print debug messages.\n  -h, --help                Display this help message and exit.\u003c/pre\u003e\n\u003c/details\u003e\n++++\n// include:help-merge:end\n\n\n=== luapak minify\n\n// include:help-minify:start\n// This is a generated content, do not edit it!\n// Note: AsciiDoc supports includes, but it's not enabled on GitHub.\n++++\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003csup\u003e\u003cem\u003eClick here to expand…\u003c/em\u003e\u003c/sup\u003e\n    \u003cpre\u003eUsage: luapak minify [options] [FILE]\n       luapak minify --help\n\nMinifies Lua source code - removes comments, unnecessary white spaces and\nempty lines, shortens numbers and names of local variables.\u003c/pre\u003e\n  \u003c/summary\u003e\n  \u003cpre\u003e\nArguments:\n  FILE                        Path of the Lua source file, or \"-\" for stdin.\n\nOptions:\n  -l, --keep-lno              Do not affect line numbers.\n  -n, --keep-names            Do not rename local variables.\n  -o, --output=FILE           Where to write the output. Use \"-\" for stdout. Default is \"-\".\n  -v, --verbose               Be verbose, i.e. print debug messages.\n  -h, --help                  Display this help message and exit.\u003c/pre\u003e\n\u003c/details\u003e\n++++\n// include:help-minify:end\n\n\n=== luapak wrapper\n\n// include:help-wrapper:start\n// This is a generated content, do not edit it!\n// Note: AsciiDoc supports includes, but it's not enabled on GitHub.\n++++\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003csup\u003e\u003cem\u003eClick here to expand…\u003c/em\u003e\u003c/sup\u003e\n    \u003cpre\u003eUsage: luapak wrapper [options] FILE [MODULE_NAME...]\n       luapak wrapper --help\n\nWraps Lua script into a generated C file that can be compiled and linked with\nLua interpreter and Lua/C native extensions into a standalone executable.\u003c/pre\u003e\n  \u003c/summary\u003e\n  \u003cpre\u003e\nArguments:\n  FILE                        The Lua file to embed into the wrapper.\n  MODULE_NAME                 Name of native module to preload (e.g. \"cjson\").\n\nOptions:\n  -C, --no-compress           Do not compress FILE using BriefLZ algorithm.\n  -o, --output=FILE           Where to write the generated code; \"-\" for stdout. Default is \"-\".\n  -v, --verbose               Be verbose, i.e. print debug messages.\n  -h, --help                  Display this help message and exit.\u003c/pre\u003e\n\u003c/details\u003e\n++++\n// include:help-wrapper:end\n\n\n== What Luapak Is _Not_?\n\n* Luapak is _not_ a transpiler from Lua to C, nor compiler to a native code.\n  It does not save you from runtime errors in your Lua code, nor increase its performance.\n\n\n== Installation\n\nNote: If you want to bootstrap development environment for running tests, read the next section.\n\n\n=== Using LuaRocks\n\nYou can install {proj-name} using https://luarocks.org[LuaRocks] (the Lua package manager):\n\n[source, subs=\"+attributes\"]\nluarocks install {proj-name}\n\nor to get the latest development version:\n\n[source, subs=\"+attributes\"]\nluarocks install --server=http://luarocks.org/dev {proj-name}\n\n\n=== Download Standalone Binary\n\nYou can also download standalone Luapak binaries for Linux, macOS and Windows from https://github.com/{gh-name}/releases/[Releases].\n\nNote: Linux binaries are statically linked with http://www.musl-libc.org/[musl libc], so they should work on any Linux system.\n\n\n== Set Up Development Environment\n\n. Clone this repository:\n[source, subs=\"+attributes\"]\ngit clone https://github.com/{gh-name}.git\ncd {proj-name}\n\n. Source file `.envrc` into your shell (or manually add `$(pwd)/.venv/bin` to your `PATH`):\n[source]\nsource .envrc\n\n. Install Lua and modules for running tests into directory `.venv`:\n[source]\n./script/bootstrap\n\n. Start hacking!\n\n. Run linters:\n[source]\n./script/test\n\n\n== TODO\n\n* Write documentation into README.\n* Write integration tests.\n* Analyse usage of Lua standard modules and exclude unused from the binary.\n\n\n== Similar Projects\n\nLuapak is not the first tool for packing Lua code into standalone executable, but it’s the most complete.\nHere’s a list of similar projects I know about, some of them served as an inspiration for Luapak.\n\n* https://github.com/ers35/luastatic[luastatic] by Eric R. Schulz\n* https://github.com/siffiejoe/lua-amalg[Amalg] by Philipp Janda\n* http://matthewwild.co.uk/projects/squish/home[Squish] by Matthew Wild\n\n\n== License\n\nThis project is licensed under http://opensource.org/licenses/MIT/[MIT License].\nFor the full text of the license, see the link:LICENSE[LICENSE] file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjirutka%2Fluapak","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjirutka%2Fluapak","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjirutka%2Fluapak/lists"}