• This repository has been archived on 20/Nov/2020
  • Stars
    star
    137
  • Rank 266,121 (Top 6 %)
  • Language
    Lua
  • License
    Other
  • Created about 12 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Squish Lua libraries and apps into a single compact file.
# Squish - One language to write them all, one squisher to squish them

Squish is a simple script to build a single file out of multiple scripts, modules, and other files.

For example if you have a script called A, and it requires modules X, Y and Z, all of them could be squished 
into a single file, B.

When run, Squish reads a file called 'squishy' in the current (or specified) directory, which contains 
instructions on how to squish a project.

For an example you can see Squish's own squishy file, included in this package. For reference, see below.

## Building and installing

Squish uses itself to squish itself and its components into a single 'squish' utility that can be run anywhere.
To build squish, just run "make" - there are no dependencies other than Lua.

You can run "make install" to copy squish to /usr/local/bin/ if you have permission.

## Squishing

Running squish will search for a 'squishy' file in the current directory. Alternatively you can pass to squish 
a directory to look in.

Command-line options vary depending on what features squish has been built with. Below are the standard ones.

### Minify
'Minification' is the act of condensing source code by stripping out spaces, line breaks, comments and anything 
that isn't required to be there. Although the source code is re-organised and changed, the program is still the 
same and runs without any changes.

#### --no-minify
Disable minification of the output file after squishing. Default is to minify.

#### --minify-level=level
The level may be one of: none, basic, default, full

They vary in effectiveness, and the time taken to process large files. Experiment!

### Uglify
'Uglification' is the name Squish gives to a certain basic form of compression. With large files it can reduce the 
size by some kilobytes, even after full minification. It works by replacing Lua keywords with a single byte and 
inserting some short code at the start of the script to expand the keywords when it is run.

#### --uglify
Enable the uglification filter. Default is to not uglify.

#### --uglify-level=LEVEL
If the level specified is "full" then Squish will extend its replacement to identifiers and string literals, as
well as Lua keywords. It first assigns each identifier and string a score based on its length and how many times
it appears in the file. The top scorers are assigned single-byte identifiers and replaced the same as the keywords.

### Gzip
Gzip, or rather the DEFLATE algorithm, is extremely good at compressing text-based data, including scripts. Using
this extension compresses the squished code, and adds some runtime decompression code. This decompression code adds
a little bit of time to the loading of the script, and adds 4K to the size of the generated code, but the overall
savings are usually well worth it.

#### --gzip
Compress the generated code with gzip. Requires the gzip command-line utility (for compression only).

### Compile
Squish can compile the resulting file to Lua bytecode. This is experimental at this stage (you may get better results 
with luac right now), however it's a work in progress. Compiling to bytecode can actually increase the size of 
minified output, but it can speed up loading (not that you would notice it anyway, since the Lua compiler is so fast).

#### --compile
Enables compilation of the output file.

### Debug
Due to the way Squish combines multiple scripts into one, sometimes when a squished script raises an error the traceback 
will be fairly unhelpful, and point to a line in the unreadable squished script. This is where the debug extension comes in!

#### --debug
This option includes some code into the squished file which will restore the filenames and line numbers in error messages and 
tracebacks. This option will increase the size of the output by no more than about 6KB, so may be very much worth it when 
squishing large tricky-to-debug applications and libraries.

**Note:** Minification may interfere with the line number calculation, use --minify-level=debug to enable all features of minify 
that don't change line numbers, and everything will be fine.

### Virtual IO
Squish allows you to pack resources (any file) into the squished output. Sometimes it would be convenient to access these through 
the standard Lua io interface. Well now you can! :)

#### --virtual-io
Inserts code into the squished output which replaces io.open, io.lines, dofile and loadfile. The new functions will first check 
whether the specified filename matches a packed resource's name. If it does then it will operate on that resource instead of an 
actual file. If the filename does _not_ match a resource then the function passes on to the real Lua functions.

## Squishy reference

A squishy file is actually a Lua script which calls some Squish functions. These functions are listed here.

### Module "name" "path"
Adds the specified module to the list of those to be squished into the output file. The optional path specifies 
where to find the file (relative to the squishy file), otherwise Squish will attempt to find the module itself.

### Main "script.lua"
Adds a script into the squished output. Scripts are executed in the order specified in the squishy file, but only 
after all modules have been loaded.

### Output "filename.lua"
Names the output file. If none is specified, the default is 'squished.out.lua'.

### Option "name" "value"
Sets the specified option, to 'true', or to the optional given value. This allows a squishy file to set default 
command-line options.

### GetOption "name"
Returns the current value of the given option.

### Resource "name" "path"
Adds a 'resource' to the squished file. A resource may be any file, text, binary, large or small. Scripts can 
retrieve the resource at runtime by calling require_resource("name"). If no path is given then the name is used 
as the path.

### AutoFetchURL "url"
**Experimental** feature which is subject to change. When specified, all the following Module statements will be 
fetched via HTTP if not found on the filesystem. A ? (question mark) in the URL is replaced by the relative path 
of the module file that was given in the Module statement.

## make_squishy

Squish includes a small utility which aims to help with converting a project to use Squish. Pass it a list of files 
and it will scan those files looking for calls to require(). It will then attempt to resolve the module names to 
files relative to the directory of the first filename passed to make_squishy.

It generates a 'squishy.new' file in the current directory. Modify accordingly and rename to just 'squishy'.

More Repositories

1

lua

The Lua programming language with CMake based build
C
1,422
star
2

luajit

LuaJIT is JIT compiler for the Lua language.
C
561
star
3

tcc

Small but fast C compiler. Supports ANSI C, most of the new ISO C99 standard, and many GNUC extensions, including inline assembly.
C
347
star
4

Repository

Repository of LuaDist modules available for installation using the luadist-git command line tool
CMake
236
star
5

toluapp

tolua++ is an extension of toLua, a tool to integrate C/Cpp code with Lua
C
207
star
6

libjpeg

Independent JPEG Group's JPEG software
C
172
star
7

srlua

A tool for building self-running Lua programs.
C
153
star
8

iup

IUP is a portable toolkit for building graphical user interfaces.
C++
81
star
9

luaxml

A minimal set of XML processing function in Lua, with simple mapping between XML and Lua tables
C
72
star
10

dkjson

dkjson is a module for encoding and decoding JSON data.
Lua
70
star
11

lpack

A library for packing and unpacking binary data. The library adds two functions to the string library: pack and unpack.
C
63
star
12

tolua

tolua is a tool that greatly simplifies the integration of C/C++ code with Lua.
C
61
star
13

libsqlite3

SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine
C
43
star
14

lpeg

C
40
star
15

scintilla

Scintilla is a free source code editing component.
C++
34
star
16

lsqlite3

LuaSQLite 3 is a thin wrapper around the public domain SQLite3 database engine.
C
31
star
17

lzlib

Lua bindings to the ZLib compression library
CMake
30
star
18

luasrcdiet

LuaSrcDiet - Compresses Lua source code by removing unnecessary characters.
Lua
30
star
19

gsl

The GNU Scientific Library (GSL) is a numerical library for C and C++ programmers.
C
29
star
20

wxlua

wxLua is a lua scripting language wrapper around the wxWidgets cross-platform GUI library. It consists of an executable for running standalone wxLua scripts and a library for extending C++ programs with a fast, small, fully embeddable scripting language
C++
29
star
21

libpng

Official PNG reference library
C
28
star
22

mapm

Mike's Arbitrary Precision Math Library
C
22
star
23

luabitop

Lua Bit Operations Module by Mile Pall
Lua
21
star
24

lua-signal

Lua support for ANSI C signals
C
21
star
25

libiconv

POSIX library, which converts a sequence of characters from one codeset into a sequence of corresponding characters in another codeset.
C
21
star
26

libtiff

TIFF library.
C
20
star
27

luapretty

Lua
20
star
28

openssl

Open Source toolkit implementing the Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well as a general purpose cryptography library.
C
19
star
29

libbsd

BSD functions common only on BSD systems, for portability to non-BSD systems.
C
18
star
30

luacurl

LuaCURL is Lua 5.x compatible module providing Internet browsing capabilities based on the cURL library.
C
18
star
31

scite

SciTE is a SCIntilla based Text Editor
C++
18
star
32

luadate

LuaDate is a Lua module for date and time calculation and retrieval using the Gregorian Calendar system.
Lua
17
star
33

slnunicode

A Unicode support library for Lua, developed for the Selene database project
C
14
star
34

unzip

Info-ZIP unzip utility
C
13
star
35

fcgi

FastCGI is simple because it is actually CGI with only a few extensions.
Shell
13
star
36

luajava

LuaJava is a scripting tool for Java
Java
13
star
37

bzip2

bzip2 is a high compression ratio data compression library.
C
12
star
38

luaexpat

LuaExpat is a SAX (Simple API for XML) XML parser based on the Expat library
C
12
star
39

libpq

libpq is a connection library for PostgreSQL
C
12
star
40

lsocket

Simple and easy socket support for lua.
C
11
star
41

lua-uri

Lua module for manipulating URIs
Lua
11
star
42

libdevil

Developer's Image Library (DevIL) is a programmer's library to develop applications with very powerful image loading capabilities, yet is easy for a developer to learn and use.
C
11
star
43

luasql-mysql

Database connectivity for Lua - MySQL driver
C
10
star
44

wxwidgets

wxWidgets is a C++ multi-platform GUI toolkit.
C++
10
star
45

luaglut

GLUT and OpenGL bindings for Lua
C
10
star
46

batteries

A meta package that provides batteries for the Lua language. Modeled after Lua for Windows distribution.
10
star
47

luasql-sqlite3

Database connectivity for Lua - SQLite3 driver
C
9
star
48

lrandom

A library for generating random numbers based on the Mersenne Twister, a pseudorandom number generating algorithm.
C
9
star
49

remdebug

Remote Debugger for the Lua programming language
Lua
9
star
50

classlib

A multiple-inheritance class library for Lua.
Lua
9
star
51

diluculum

Diluculum is a library that intends to make the coexistence of C++ and Lua more harmonious.
C++
9
star
52

zip

Info-ZIP zip utility
C
8
star
53

onig

Oniguruma is a regular expressions library
C
8
star
54

bitlib

Tiny library for bitwise operations
Shell
8
star
55

lbc

A simple arbitrary precision library for Lua, based on code from GNU bc
C
8
star
56

iup-examples

Examples for IUP. IUP is a portable toolkit for building graphical user interfaces.
C
7
star
57

sdl

Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D.
C
7
star
58

lpty

A simple facility for lua to control other programs via PTYs.
C
7
star
59

luaex

Implemenation of 'ex' API - portable os and io extension functions
C
7
star
60

libexpat

Expat is a C library for parsing XML
Shell
7
star
61

luabind

Luabind is a library that helps you create bindings between C++ and Lua.
C++
7
star
62

loop

LOOP stands for Lua Object-Oriented Programming and is a set of packages for supporting different models of object-oriented programming in the Lua language
Lua
7
star
63

cd

CD (Canvas Draw) is a platform-independent graphics library.
C
6
star
64

diff

This module provides a small collection of functions for diffing text.
Lua
6
star
65

luametrics

Lua
6
star
66

freeglut

FreeGLUT is a free alternative GLUT library.
C
6
star
67

luadocer

Lua
6
star
68

luagl

A library that provides access to all of the OpenGL functionality from Lua.
C
6
star
69

luagd

Lua bindings to the GD library
C
6
star
70

luatask

LuaTask - Multitasking support Library
C
6
star
71

qtlua

The QtLua library aims to make Qt4 applications scriptable using the Lua scripting language.
C++
6
star
72

lbci

A bytecode inspector library for Lua 5.1. It allows you to look inside Lua functions from Lua.
C
5
star
73

regex

Henry Spencer's regular expressions library
C
5
star
74

lualibusb

Lua libusb binding
C
5
star
75

Binaries

Binary distributions for download purposes
Lua
5
star
76

libmysql

libmysql provides C interface library to connect to MySQL
C
5
star
77

lcms

LittleCMS is a CMM, a color management engine
C++
5
star
78

luapi

LuaPi: Concurrent programming made simple
Lua
5
star
79

mixlua

A preprocessor for files including embedded Lua code
C
5
star
80

luamotif

Lua binding for OpenMotif
C
5
star
81

fontconfig

Shell
5
star
82

lbase64

A Base64 library for Lua
C
5
star
83

im

IM is a toolkit for Digital Imaging.
C
4
star
84

alt-getopt

Process application arguments the same way as getopt_long
Lua
4
star
85

lemock

Mock creation module intended for use together with a unit test framework such as lunit or lunity.
Lua
4
star
86

luuid

A library for UUID generation
C
4
star
87

lpc

Allows Lua scripts to call external processes while capturing both their input and output.
C
4
star
88

luaprofiler

LuaProfiler is a time profiler designed to help finding bottlenecks on your Lua program.
C
4
star
89

libffi

FFI stands for Foreign Function Interface. A foreign function interface is the popular name for the interface that allows code written in one language t o call code written in another language.
C
4
star
90

bootstrap

Bootstrap process to create the deployment utility from scratch
Shell
4
star
91

luasql-odbc

LuaSQL is a simple interface from Lua to a DBMS - ODBC driver
C
4
star
92

markdown

A pure-lua implementation of the Markdown text-to-html markup system.
Lua
4
star
93

cmake

A cross-platform, open-source build system that generates native makefiles.
C++
4
star
94

libzzip

The zziplib provides read access to zipped files in a zip-archive.
Shell
4
star
95

gslshell

GSL shell is an interactive Lua command line interface that gives easy access to the GNU Scientific Library (GSL) collection of mathematical methods for numerical computations.
C
4
star
96

luagraph

LuaGRAPH is a binding to the graphviz library.
Lua
3
star
97

lcms2

LittleCMS is a CMM, a color management engine
C
3
star
98

lmd5

A message digest library for Lua based on OpenSSL: MD2, MD4, MD5, SHA1, SHA2, RIPEMD160, MDC2
C
3
star
99

luasql-firebird

LuaSQL is a simple interface from Lua to a DBMS - Firebird driver
C
3
star
100

concurrentlua

Concurrency Oriented Programming in Lua
Lua
3
star