Skip to content

Commit

Permalink
libjpeg-turbo for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
vweevers committed Mar 19, 2016
1 parent a3492e3 commit 5e0fb4e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
19 changes: 16 additions & 3 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,20 @@
['OS=="win"', {
'variables': {
'GTK_Root%': 'C:/GTK', # Set the location of GTK all-in-one bundle
'with_jpeg%': 'false',
'with_gif%': 'false',
'with_pango%': 'false',
'with_freetype%': 'false'
'with_freetype%': 'false',
'variables': { # Nest jpeg_root to evaluate it before with_jpeg
'jpeg_root%': '<!(node ./util/win_jpeg_lookup)'
},
'jpeg_root%': '<(jpeg_root)', # Take value of nested variable
'conditions': [
['jpeg_root==""', {
'with_jpeg%': 'false'
}, {
'with_jpeg%': 'true'
}]
]
}
}, { # 'OS!="win"'
'variables': {
Expand Down Expand Up @@ -139,7 +149,10 @@
'conditions': [
['OS=="win"', {
'libraries': [
'-l<(GTK_Root)/lib/jpeg.lib'
'-l<(jpeg_root)/lib/jpeg-static.lib'
],
'include_dirs': [
'<(jpeg_root)/include'
]
}, {
'libraries': [
Expand Down
21 changes: 21 additions & 0 deletions util/win_jpeg_lookup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
var fs = require('fs')
var paths = ['C:/libjpeg-turbo']

if (process.arch === 'x64') {
paths.unshift('C:/libjpeg-turbo64')
}

paths.forEach(function(path){
if (exists(path)) {
process.stdout.write(path)
process.exit()
}
})

function exists(path) {
try {
return fs.lstatSync(path).isDirectory()
} catch(e) {
return false
}
}

0 comments on commit 5e0fb4e

Please sign in to comment.