Mon, 27 Jul 2009 04:33:39 +0100
-g == --debug
17 | 1 | |
2 | # Squish - One language to write them all, one squisher to squish them | |
3 | ||
4 | Squish is a simple script to build a single file out of multiple scripts, modules, and other files. | |
5 | ||
6 | For example if you have a script called A, and it requires modules X, Y and Z, all of them could be squished | |
7 | into a single file, B. | |
8 | ||
9 | When run, Squish reads a file called 'squishy' in the current (or specified) directory, which contains | |
10 | instructions on how to squish a project. | |
11 | ||
12 | For an example you can see Squish's own squishy file, included in this package. For reference, see below. | |
13 | ||
14 | ## Squishing | |
15 | ||
16 | Running squish will search for a 'squishy' file in the current directory. Alternatively you can pass to squish | |
17 | a directory to look in. | |
18 | ||
19 | Command-line options vary depending on what features squish has been built with. Below are the standard ones. | |
20 | ||
21 | ### Minify | |
22 | 'Minification' is the act of condensing source code by stripping out spaces, line breaks, comments and anything | |
23 | that isn't required to be there. Although the source code is re-organised and changed, the program is still the | |
24 | same and runs without any changes. | |
25 | ||
26 | #### --no-minify | |
27 | Disable minification of the output file after squishing. Default is to minify. | |
28 | ||
29 | #### --minify-level=level | |
30 | The level may be one of: none, basic, default, full | |
31 | ||
32 | They vary in effectiveness, and the time taken to process large files. Experiment! | |
33 | ||
34 | ### Uglify | |
35 | 'Uglification' is the name Squish gives to a certain basic form of compression. With large files it can reduce the | |
36 | size by some kilobytes, even after full minification. It works by replacing Lua keywords with a single byte and | |
37 | inserting code at the start of the script to expand the keywords when it is run. | |
38 | ||
39 | #### --uglify | |
40 | Enable the uglification filter. Default is to not uglify. | |
41 | ||
42 | ### Compile | |
43 | Squish can compile the resulting file to Lua bytecode. This is experimental at this stage (you may get better results | |
44 | with luac right now), however it's a work in progress. Compiling to bytecode can actually increase the size of | |
45 | minified output, but it can speed up loading (not that you would notice it anyway, since the Lua compiler is so fast). | |
46 | ||
47 | #### --compile | |
48 | Enables compilation of the output file. | |
49 | ||
35
8843ea9f9e27
Update README for debug extension
Matthew Wild <mwild1@gmail.com>
parents:
17
diff
changeset
|
50 | ### Debug |
8843ea9f9e27
Update README for debug extension
Matthew Wild <mwild1@gmail.com>
parents:
17
diff
changeset
|
51 | Due to the way Squish combines multiple scripts into one, sometimes when a squished script raises an error the traceback |
8843ea9f9e27
Update README for debug extension
Matthew Wild <mwild1@gmail.com>
parents:
17
diff
changeset
|
52 | will be fairly unhelpful, and point to a line in the unreadable squished script. This is where the debug extension comes in! |
8843ea9f9e27
Update README for debug extension
Matthew Wild <mwild1@gmail.com>
parents:
17
diff
changeset
|
53 | |
40
ab43c18f9d31
Update README to reflect --debug change
Matthew Wild <mwild1@gmail.com>
parents:
35
diff
changeset
|
54 | #### --debug |
35
8843ea9f9e27
Update README for debug extension
Matthew Wild <mwild1@gmail.com>
parents:
17
diff
changeset
|
55 | This option includes some code into the squished file which will restore the filenames and line numbers in error messages and |
8843ea9f9e27
Update README for debug extension
Matthew Wild <mwild1@gmail.com>
parents:
17
diff
changeset
|
56 | tracebacks. This option will increase the size of the output by no more than about 6KB, so may be very much worth it when |
8843ea9f9e27
Update README for debug extension
Matthew Wild <mwild1@gmail.com>
parents:
17
diff
changeset
|
57 | squishing large tricky-to-debug applications and libraries. |
8843ea9f9e27
Update README for debug extension
Matthew Wild <mwild1@gmail.com>
parents:
17
diff
changeset
|
58 | |
8843ea9f9e27
Update README for debug extension
Matthew Wild <mwild1@gmail.com>
parents:
17
diff
changeset
|
59 | **Note:** Minification may interfere with the line number calculation, use --minify-level=debug to enable all features of minify |
8843ea9f9e27
Update README for debug extension
Matthew Wild <mwild1@gmail.com>
parents:
17
diff
changeset
|
60 | that don't change line numbers, and everything will be fine. |
8843ea9f9e27
Update README for debug extension
Matthew Wild <mwild1@gmail.com>
parents:
17
diff
changeset
|
61 | |
42
7b1896ff4315
Add virtual IO section to the README
Matthew Wild <mwild1@gmail.com>
parents:
40
diff
changeset
|
62 | ### Virtual IO |
7b1896ff4315
Add virtual IO section to the README
Matthew Wild <mwild1@gmail.com>
parents:
40
diff
changeset
|
63 | Squish allows you to pack resources (any file) into the squished output. Sometimes it would be convenient to access these through |
7b1896ff4315
Add virtual IO section to the README
Matthew Wild <mwild1@gmail.com>
parents:
40
diff
changeset
|
64 | the standard Lua io interface. Well now you can! :) |
7b1896ff4315
Add virtual IO section to the README
Matthew Wild <mwild1@gmail.com>
parents:
40
diff
changeset
|
65 | |
7b1896ff4315
Add virtual IO section to the README
Matthew Wild <mwild1@gmail.com>
parents:
40
diff
changeset
|
66 | #### --virtual-io |
7b1896ff4315
Add virtual IO section to the README
Matthew Wild <mwild1@gmail.com>
parents:
40
diff
changeset
|
67 | Inserts code into the squished output which replaces io.open, io.lines, dofile and loadfile. The new functions will first check |
7b1896ff4315
Add virtual IO section to the README
Matthew Wild <mwild1@gmail.com>
parents:
40
diff
changeset
|
68 | whether the specified filename matches a packed resource's name. If it does then it will operate on that resource instead of an |
7b1896ff4315
Add virtual IO section to the README
Matthew Wild <mwild1@gmail.com>
parents:
40
diff
changeset
|
69 | actual file. If the filename does _not_ match a resource then the function passes on to the real Lua functions. |
7b1896ff4315
Add virtual IO section to the README
Matthew Wild <mwild1@gmail.com>
parents:
40
diff
changeset
|
70 | |
17 | 71 | ## Squishy reference |
72 | ||
73 | A squishy file is actually a Lua script which calls some Squish functions. These functions are listed here. | |
74 | ||
75 | ### Module "name" "path" | |
76 | Adds the specified module to the list of those to be squished into the output file. The optional path specifies | |
77 | where to find the file (relative to the squishy file), otherwise Squish will attempt to find the module itself. | |
78 | ||
79 | ### Main "script.lua" | |
80 | Adds a script into the squished output. Scripts are executed in the order specified in the squishy file, but only | |
81 | after all modules have been loaded. | |
82 | ||
83 | ### Output "filename.lua" | |
84 | Names the output file. If none is specified, the default is 'squished.out.lua'. | |
85 | ||
86 | ### Option "name" "value" | |
87 | Sets the specified option, to 'true', or to the optional given value. This allows a squishy file to set default | |
88 | command-line options. | |
89 | ||
90 | ### GetOption "name" | |
91 | Returns the current value of the given option. | |
92 | ||
93 | ### Resource "name" "path" | |
94 | Adds a 'resource' to the squished file. A resource may be any file, text, binary, large or small. Scripts can | |
95 | retrieve the resource at runtime by calling require_resource("name"). If no path is given then the name is used | |
96 | as the path. | |
97 | ||
98 | ### AutoFetchURL "url" | |
99 | **Experimental** feature which is subject to change. When specified, all the following Module statements will be | |
100 | fetched via HTTP if not found on the filesystem. A ? (question mark) in the URL is replaced by the relative path | |
101 | of the module file that was given in the Module statement. | |
44
5d710c0cfb45
Add to README about make_squishy
Matthew Wild <mwild1@gmail.com>
parents:
42
diff
changeset
|
102 | |
5d710c0cfb45
Add to README about make_squishy
Matthew Wild <mwild1@gmail.com>
parents:
42
diff
changeset
|
103 | ## make_squishy |
5d710c0cfb45
Add to README about make_squishy
Matthew Wild <mwild1@gmail.com>
parents:
42
diff
changeset
|
104 | |
5d710c0cfb45
Add to README about make_squishy
Matthew Wild <mwild1@gmail.com>
parents:
42
diff
changeset
|
105 | Squish includes a small utility which aims to help with converting a project to use Squish. Pass it a list of files |
5d710c0cfb45
Add to README about make_squishy
Matthew Wild <mwild1@gmail.com>
parents:
42
diff
changeset
|
106 | and it will scan those files looking for calls to require(). It will then attempt to resolve the module names to |
5d710c0cfb45
Add to README about make_squishy
Matthew Wild <mwild1@gmail.com>
parents:
42
diff
changeset
|
107 | files relative to the directory of the first filename passed to make_squishy. |
5d710c0cfb45
Add to README about make_squishy
Matthew Wild <mwild1@gmail.com>
parents:
42
diff
changeset
|
108 | |
5d710c0cfb45
Add to README about make_squishy
Matthew Wild <mwild1@gmail.com>
parents:
42
diff
changeset
|
109 | It generates a 'squishy.new' file in the current directory. Modify accordingly and rename to just 'squishy'. |