diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a34da9cfec..c330a7fbf1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -329,3 +329,33 @@ Occasionally other changes to `master` might mean that your pull request cannot be merged automatically. In this case you may need to rebase your branch on a more recent `master`, resolve any conflicts, and `git push --force` to update your branch so that it can be merged automatically. + +## Building on Windows + +Most developers build on Linux. Building on Windows is possible under Cygwin. +When installing Cygwin from https://www.cygwin.com/, include the developer +tools to get GNU make. + +First (before npm install), to avoid file permission problems between Windows +and Cygwin, edit Cygwin's /etc/fstab file to disable ACLs like this +`none /cygdrive cygdrive binary,noacl,posix=0,user 0 0` + +Python is normally installed with Cygwin so need not be installed separately. +By default Cygwin will use its own version of Python rather than Window's, +so the Python modules should be installed for Cygwin's Python. + +The build targets `check-deps`, `serve`, `lint`, `build`, `test`, `check` and +`host-examples` described above should all work. `host-examples` takes quite a +while to run. If a target does not run properly first time, try it again. + +Currently, Firefox fails to run http://localhost:3000/build/examples +from make serve, but Chrome and Internet Explorer will. + +Microsoft Visual Studio's javascript debugger may be used to debug the +build/hosted/your-branch/examples. It will be convenient to set +build/hosted/your-branch/examples/index.html as the startup page. + +Your ol3 source tree need not be under the Cygwin root. +if you checkout to c:/ol3 then you can build under Cygwin at /cygdrive/c/ol3 . +However, keep the path to the ol3 files short otherwise you may see +`ENAMETOOLONG` errors. diff --git a/Makefile b/Makefile index 35e843a1f2..77c6e55ad7 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,11 @@ CHECK_EXAMPLE_TIMESTAMPS = $(patsubst examples/%.html,build/timestamps/check-%-t TASKS_JS := $(shell find tasks -name '*.js') -CLOSURE_LIB = $(shell node -e 'process.stdout.write(require("closure-util").getLibraryPath())') +ifeq (CYGWIN,$(findstring CYGWIN,$(OS))) + CLOSURE_LIB = $(shell cygpath -u $(shell node -e 'process.stdout.write(require("closure-util").getLibraryPath())')) +else + CLOSURE_LIB = $(shell node -e 'process.stdout.write(require("closure-util").getLibraryPath())') +endif ifeq ($(OS),Darwin) STAT_COMPRESSED = stat -f ' compressed: %z bytes' diff --git a/tasks/generate-info.js b/tasks/generate-info.js index d79bb67eee..1ba741ed70 100644 --- a/tasks/generate-info.js +++ b/tasks/generate-info.js @@ -5,6 +5,7 @@ var spawn = require('child_process').spawn; var async = require('async'); var fse = require('fs-extra'); var walk = require('walk').walk; +var isWindows = process.platform.indexOf('win') === 0; var sourceDir = path.join(__dirname, '..', 'src'); var externsDir = path.join(__dirname, '..', 'externs'); @@ -14,6 +15,12 @@ var externsPaths = [ ]; var infoPath = path.join(__dirname, '..', 'build', 'info.json'); var jsdoc = path.join(__dirname, '..', 'node_modules', '.bin', 'jsdoc'); + +// on Windows, use jsdoc.cmd +if (isWindows) { + jsdoc += '.cmd'; +} + var jsdocConfig = path.join( __dirname, '..', 'config', 'jsdoc', 'info', 'conf.json'); @@ -92,6 +99,17 @@ function getNewer(date, newer, callback) { callback(new Error('Trouble walking ' + sourceDir)); }); walker.on('end', function() { + + /** + * Windows has restrictions on length of command line, so passing all the + * changed paths to a task will fail if this limit is exceeded. + * To get round this, if this is Windows and there are newer files, just + * pass the sourceDir to the task so it can do the walking. + */ + if (isWindows) { + paths = [sourceDir].concat(externsPaths); + } + callback(null, newer ? paths : []); }); }