Permalink
Browse files

add alternative build using gyp

  • Loading branch information...
1 parent 5fbccbf commit 7595c3b0122122c7293722dde9b2465cf172ad79 Dane Springmeyer committed Nov 23, 2011
Showing with 131 additions and 1 deletion.
  1. +8 −1 Makefile
  2. +89 −0 build.gyp
  3. +34 −0 gen_settings.py
View
@@ -10,6 +10,12 @@ ifeq ($(OS),Darwin)
NPROCS:=$(shell sysctl -n hw.ncpu)
endif
+gyp:
+ python gen_settings.py
+ python gyp/gyp build.gyp --depth=. -f make --generator-output=./projects/makefiles
+ make -C ./projects/makefiles/
+ cp projects/makefiles/out/Default/_mapnik.node lib/_mapnik.node
+
install: all
@node-waf build install
@@ -18,6 +24,7 @@ mapnik.node:
clean:
@node-waf clean distclean
+ @rm -rf ./projects/makefiles/
uninstall:
@node-waf uninstall
@@ -41,4 +48,4 @@ lint:
@./node_modules/.bin/jshint lib/*js bin/*js test/*js examples/*/*.js examples/*/*/*.js
-.PHONY: test lint fix
+.PHONY: test lint fix gyp
View
@@ -0,0 +1,89 @@
+
+{
+ 'variables': {
+ 'node_mapnik_sources': [
+ "src/node_mapnik.cpp",
+ "src/mapnik_map.cpp",
+ "src/mapnik_color.cpp",
+ "src/mapnik_geometry.cpp",
+ "src/mapnik_feature.cpp",
+ "src/mapnik_image.cpp",
+ "src/mapnik_image_view.cpp",
+ "src/mapnik_grid.cpp",
+ "src/mapnik_grid_view.cpp",
+ "src/mapnik_js_datasource.cpp",
+ "src/mapnik_memory_datasource.cpp",
+ "src/mapnik_palette.cpp",
+ "src/mapnik_projection.cpp",
+ "src/mapnik_layer.cpp",
+ "src/mapnik_datasource.cpp",
+ "src/mapnik_featureset.cpp"
+ ]
+ },
+ 'targets': [
+ {
+ 'target_name': '_mapnik',
+ 'product_name': '_mapnik',
+ 'type': 'loadable_module',
+ 'product_prefix': '',
+ 'product_extension':'node',
+ 'sources': [
+ '<@(node_mapnik_sources)',
+ ],
+ 'defines': [
+ 'PLATFORM="<(OS)"',
+ ],
+ 'conditions': [
+ [ 'OS=="mac"', {
+ 'libraries': [
+ '-lmapnik2',
+ '-undefined dynamic_lookup'
+ ],
+ 'include_dirs': [
+ 'src/',
+ '/usr/local/include/node',
+ '/opt/boost-48/include',
+ '/usr/local/Cellar/icu4c/4.8.1.1/include',
+ '/usr/X11/include/freetype2',
+ '/usr/X11/include',
+ '/usr/include',
+ ],
+ 'defines': [
+ '_LARGEFILE_SOURCE',
+ '_FILE_OFFSET_BITS=64',
+ ],
+ }],
+ [ 'OS=="win"', {
+ 'defines': [
+ 'PLATFORM="win32"',
+ ],
+ 'libraries': [ 'node.lib' ],
+ 'include_dirs': [
+ 'c:\\dev2\\node\\src',
+ 'c:\\dev2\\node\\deps\\uv\\include',
+ 'c:\\dev2\\node\\deps\\v8\\include',
+ 'c:\\dev2\\freetype',
+ 'c:\\dev2\\icu',
+ 'c:\\dev2\\boost',
+ ],
+ 'defines': [
+ 'PLATFORM="<(OS)"',
+ '_LARGEFILE_SOURCE',
+ '_FILE_OFFSET_BITS=64',
+ #'WIN32',
+ #'_WINDOWS',
+ #'_USRDLL',
+ #'BUILDING_NODE_EXTENSION'
+ ],
+ 'msvs_settings': {
+ 'VCLinkerTool': {
+ 'AdditionalLibraryDirectories': [
+ 'c:\\dev2\\node\\Debug',
+ ],
+ },
+ },
+ }],
+ ]
+ },
+ ],
+}
View
@@ -0,0 +1,34 @@
+import os
+
+settings = 'lib/mapnik_settings.js'
+
+# this goes into a mapnik_settings.js file beside the C++ _mapnik.node
+settings_template = """
+module.exports.paths = {
+ 'fonts': %s,
+ 'input_plugins': %s
+};
+"""
+
+def write_mapnik_settings(fonts='undefined',input_plugins='undefined'):
+ global settings_template
+ if '__dirname' in fonts or '__dirname' in input_plugins:
+ settings_template = "var path = require('path');\n" + settings_template
+ open(settings,'w').write(settings_template % (fonts,input_plugins))
+
+
+if __name__ == '__main__':
+ settings_dict = {}
+
+ # settings for fonts and input plugins
+ if os.environ.has_key('MAPNIK_INPUT_PLUGINS'):
+ settings_dict['input_plugins'] = os.environ['MAPNIK_INPUT_PLUGINS']
+ else:
+ settings_dict['input_plugins'] = '\'%s\'' % os.popen("mapnik-config --input-plugins").readline().strip()
+
+ if os.environ.has_key('MAPNIK_FONTS'):
+ settings_dict['fonts'] = os.environ['MAPNIK_FONTS']
+ else:
+ settings_dict['fonts'] = '\'%s\'' % os.popen("mapnik-config --fonts").readline().strip()
+
+ write_mapnik_settings(**settings_dict)

0 comments on commit 7595c3b

Please sign in to comment.