Skip to content

libjpeg-turbo for windows #458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}