-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: adds patch system to apply stdout fixes
Updates install script to apply patches to Zint library for saving stdout data to a buffer, converting it to a string, and returning it as part of encodedData.
- Loading branch information
Showing
9 changed files
with
135 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,64 @@ | ||
const clone = require('git-clone') | ||
const replace = require('replace-in-file') | ||
const rimraf = require('rimraf') | ||
const path = require('path') | ||
|
||
console.log('Cloning zint library...') | ||
|
||
clone('https://github.com/woo-j/zint.git', '.zint', () => { | ||
replace.sync({ | ||
files: '.zint/**/*.c', | ||
const patches = [ | ||
{ | ||
files: '.zint/**/zint.h', | ||
from: /struct zint_symbol \{/g, | ||
to: ` | ||
struct zint_symbol { | ||
char rendered_data[100000000]; | ||
` | ||
}, | ||
{ | ||
files: '.zint/**/*.{c,h}', | ||
from: /\<malloc\.h\>/g, | ||
to: '<stdlib.h>' | ||
}, | ||
{ | ||
files: '.zint/**/{svg,ps}.{c,h}', | ||
from: /([a-z]+) = stdout;\n/g, | ||
to: `#ifndef _WIN32 | ||
pipe(p); | ||
#endif | ||
$1 = fdopen(p[1], "w"); | ||
` | ||
}, | ||
{ | ||
files: '.zint/**/{svg,ps}.{c,h}', | ||
from: /int ([a-z]+)_plot([^\n]+)/g, | ||
to: ` | ||
int pipe(int fd[2]); | ||
int close(int fildes); | ||
int read(int fildes, void *buf, unsigned nbytes); | ||
int $1_plot$2 | ||
int p[2];` | ||
}, | ||
{ | ||
files: '.zint/**/{svg,ps}.{c,h}', | ||
from: /(fflush\([a-z]+\);)/g, | ||
to: `$1 | ||
close(p[1]); | ||
read(p[0], symbol->rendered_data, 100000000);` | ||
} | ||
] | ||
|
||
console.log('Removing any existing .zint directory...') | ||
|
||
rimraf(path.join(__dirname, '../.zint'), () => { | ||
console.log('Cloning zint...', path.join(__dirname, '.zint')) | ||
|
||
clone('https://github.com/woo-j/zint.git', '.zint', () => { | ||
console.log('Successfully cloned. Applying code patches...') | ||
|
||
patches.forEach(patch => replace.sync(patch)) | ||
|
||
console.log('Done.') | ||
}) | ||
console.log('Finished cloning zint.') | ||
}) | ||
}) | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module.exports = { | ||
PNG: 'bmp', | ||
PNG: 'png', | ||
SVG: 'svg', | ||
EPS: 'eps' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters