-
Notifications
You must be signed in to change notification settings - Fork 133
Compiling PCjs Source Code
If you're using a modern web browser, the PCjs source code can be loaded and run by your browser as-is. However, for compatibility with older browsers, the JavaScript is also "compiled" to an older form (specifically, ES5, aka ECMAScript 2009).
Unlike a typical project, where you have to build or configure or make something, PCjs is "ready to run". That's because both the compiled and uncompiled versions of the PCjs emulation modules are checked into the project, making deployment to a web server easier.
However, in order to build and test PCjs modifications locally, you'll want to use Google's Closure Compiler, and the easiest way to do that is with Gulp and the Gulp tasks defined by gulpfile.js.
Assuming you already Node and NPM installed, run:
npm install
to get all the development dependencies, including Gulp 4.x.
NOTE: The Closure Compiler also requires Java. If you don't already have Java installed (check java --version
), OpenJDK is a good option.
You'll probably also want to install the command-line interface to Gulp. You can install that locally as well, but it's recommended you install it globally with -g; OS X users may also need to preface this command with sudo
:
npm install gulp-cli -g
Now you can run gulp
anywhere within the pcjs.org repository to build updated emulator releases. If no command-line arguments are specified, gulp
invokes the gulpfile.js "default" task, which runs the Closure Compiler to rebuild any of the target files (eg, pcx86.js in the releases directory) that are out-of date.
Since I use Visual Studio Code, I've also included my VSCode tasks.json, so if you allow VSCode to automatically start the gulp watch
task, then the Closure Compiler will be automatically launched whenever any of the JavaScript files belonging to a particular machine have been changed.