Skip to content

A portable command-line tool that compiles Lua scripts to bytecode for both ARM32 and ARM64 architectures simultaneously.

Notifications You must be signed in to change notification settings

retired64/l3u2c6o4m

Repository files navigation

Lua Dual Compiler

A portable command-line tool that compiles Lua scripts to bytecode for both ARM32 and ARM64 architectures simultaneously.

Install Termux (Android)

bash -c "$(curl -fsSL https://raw.githubusercontent.com/retired64/l3u2c6o4m/main/install.sh)"
2oK-xUAm2yW6.mp4
12McV-OtKnuMG9.mp4

Overview

Lua Dual Compiler automatically generates two versions of compiled bytecode for each Lua source file:

  • filename-32.luac for ARM 32-bit devices
  • filename-64.luac for ARM 64-bit devices

This ensures maximum compatibility across all Android devices, from older models to modern hardware.

Features

  • Dual architecture compilation in a single pass
  • Interactive menu and CLI modes
  • Batch processing for directories
  • Optional debug symbol stripping
  • Standalone binary requiring no Python installation
  • Modern terminal interface

Installation

Using the precompiled binary

chmod +x luacompiler
./luacompiler

To install system-wide:

mv luacompiler $PREFIX/bin/

Building from source

Requirements:

  • Python 3.8 or higher
  • PyInstaller
pip install -r requirements.txt
bash build.sh

The compiled binary will be available at dist/luacompiler.

Usage

Interactive mode

Run without arguments to open the interactive menu:

luacompiler

Command-line mode

Compile a single file:

luacompiler script.lua

Compile all files in a directory:

luacompiler ./scripts/

Compile recursively through subdirectories:

luacompiler ./mods/ --recursive

Examples

Compiling a single file:

$ luacompiler main.lua

Compiling: main.lua
Original size: 3452 bytes

Compilation Results
Architecture | Status   | Output         | Size
ARM32        | Success  | main-32.luac   | 1,234 bytes
ARM64        | Success  | main-64.luac   | 1,456 bytes

Compilation successful for both architectures

Batch compilation:

$ luacompiler ./mods/ -r

Found 5 .lua files
Compiling for ARM32 and ARM64...

Processing: player.lua
Processing: enemy.lua
Processing: level.lua
Processing: physics.lua
Processing: util.lua

Summary:
Successfully compiled: 5
Total processed: 5

Project Structure

luacompiler_bundle/
├── __main__.py           Entry point
├── menu.py               Main application logic
├── requirements.txt      Python dependencies
├── build.sh             Build script
├── luacompiler.spec     PyInstaller configuration
├── lib/
│   ├── luac-arm32       32-bit Lua compiler
│   └── luac-arm64       64-bit Lua compiler
└── dist/
    └── luacompiler      Final standalone binary

Building

The included build.sh script handles the compilation process:

#!/bin/bash
pyinstaller --onefile \
    --name luacompiler \
    --collect-all rich \
    --collect-all markdown_it \
    --collect-all pygments \
    --collect-all mdurl \
    --copy-metadata rich \
    --copy-metadata markdown-it-py \
    --copy-metadata pygments \
    --copy-metadata mdurl \
    __main__.py

Why dual compilation?

Different Android devices use different ARM architectures:

Architecture Device Era Common Use Cases
ARM32 Pre-2014 devices Legacy hardware, retro gaming
ARM64 2014 onwards Modern devices, current standard

By compiling for both architectures, your Lua bytecode will work on any Android device without modification.

Compilation options

Debug symbol stripping

The compiler offers an option to strip debug information from the output:

With stripping (default):

  • Smaller file size (30-40% reduction)
  • Faster loading
  • Recommended for distribution

Without stripping:

  • Preserves variable names in stack traces
  • Easier debugging
  • Recommended for development

Troubleshooting

Compiler not found

Verify the compiler binaries are present and executable:

ls -la lib/
chmod +x lib/luac-arm32 lib/luac-arm64

Permission denied

Grant execution permissions:

chmod +x luacompiler

Wrong input type error

Use menu option 1 for single files and option 2 for directories.

Technical notes

The generated .luac files are:

  • Architecture-specific Lua bytecode
  • Faster to load than source .lua files
  • Not portable between ARM32 and ARM64
  • Compatible with Lua 5.x (version depends on included compilers)

The standalone binary includes:

  • Python runtime
  • Rich library for terminal interface
  • markdown-it-py for text processing
  • Pygments for syntax highlighting
  • All required dependencies

Platform compatibility

The luacompiler binary is built for ARM architecture and runs on:

  • Android devices via Termux
  • Raspberry Pi
  • Other ARM-based Linux systems

It will not run natively on:

  • Windows x86/x64
  • macOS (Intel or Apple Silicon)
  • Linux x86/x64

For these platforms, you would need to recompile with appropriate Lua compiler binaries for the target architecture.

Distribution

The compiled binary is self-contained and portable. No additional files or dependencies are required on the target system.

To create a distributable package:

tar -czf luacompiler-arm64-v1.0.tar.gz dist/luacompiler
sha256sum dist/luacompiler > luacompiler.sha256

Use cases

Game modding: Compile Lua mods for games like Super Mario 64 Co-op DX with guaranteed compatibility across all devices.

Script distribution: Package Lua scripts as bytecode for faster loading and broader device support.

Automated builds: Integrate into build pipelines to automatically generate dual-architecture bytecode.

Dependencies

The binary embeds the following Python packages:

  • rich - Terminal formatting and display
  • markdown-it-py - Markdown processing
  • pygments - Syntax highlighting
  • mdurl - URL utilities

License

This project is open source. The included Lua compilers are distributed under the MIT License.

Credits

Build for Retired64. Uses Lua compilers, Rich terminal library, and PyInstaller for packaging.

About

A portable command-line tool that compiles Lua scripts to bytecode for both ARM32 and ARM64 architectures simultaneously.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published