-
Notifications
You must be signed in to change notification settings - Fork 305
Compiling bwipjs
The requirements for compiling bwipjs are fairly basic:
- A bash shell with standard posix utilities
- A recent version of node.js
For the first requirement, you can use either a linux OS (Mac OS X not tested) or cygwin running on Windows. If you want to compile FreeType as well and only have a windows OS, I recommend installing VirtualBox running the latest 64-bit version of ubuntu.
For node, you need a recent version, at minimum version 4.
If you want to run the test framework, then ghostscript is also required. The test framework compares the output of BWIPP run using ghostscript with bwipjs. We don't compare images since it would be impossible to get pixel-perfect
matches, but rather the rendering data that is generated by each encoder. This requires a bit a trickery both with barcode.ps
and with bwipp.js
but is completely transparent to you. The test framework takes care of it all.
Download links:
If you install ubuntu on VirtualBox, you should go back to the VirtualBox download page and install the guest additions. Makes moving between windows and linux much friendlier.
If you install cygwin, ensure you get the sed
and grep
utilities (should be standard but it's been too long since my last install and cannot remember).
If you installed ghostscript, it must be available as gs
from the command line. For linux,
this is usually the standard. For cygwin on windows, you need to create a wrapper script. Pick a
directory that is already in your path (for example, ~/bin
is where many developers store their wizardry).
Then create a new file called gs
in the directory:
#!/bin/bash
"/c/Program Files/gs/gs9.07/bin/gswin64c.exe" "$@"
Note the 'c' in the gswin64c.exe
. We want the console version of ghostscript. The path above is from my local system. Yours may be different. The double-quotes around the path and the positional parameters variable are
required.
Make sure the script is executable:
$ chmod u+x gs
$ gs --version
9.07
Next, verify node is in your PATH. From a bash prompt:
$ node --version
v5.11.0
If node is not in your PATH, make the necessary changes to PATH in your ~/.bashrc
, exit the console and re-open.
The npm package js-beautify
is used on the cross-compiled JavaScript to make it more legible:
$ npm install js-beautify
Now clone the develop branch of bwipjs. If you have git installed, from your bash prompt:
$ cd <to where you want to install bwipjs>
$ git clone -b develop --single-branch git@github.com:metafloor/bwip-js.git .
(Don't miss the space-dot on the end of the clone command.)
Otherwise, use the github web interface to download the develop branch and unpack to your desired directory.
To compile:
$ ./psc
A new bwipp.js
and bwipp-min.js
will be in the current directory.
To run the test cases:
$ ./runtests [encoder]
If you runtests
without an encoder name, plan on a cup of coffee.
To run the benchmark:
$ node --expose-gc benchmark
The benchmark script is fully synchronous so the event loop never runs and GC is never triggered. The benchmark script therefore manually GCs after each round. The benchmark will run 10 warm-up rounds followed by 50 timing rounds.
Output from the benchmark will be in benchmark.md
. The first table is sorted slowest to fastest. The second table by encoder name. Not all encoders are timed; just the more modern or frequently used bar code types.