@@ -11,6 +11,8 @@ const outputDirForGit = path.relative(repoRoot, outputDir);
1111
1212const imageSize = process . env . FRAMEOS_VISUAL_IMG_SIZE || "4000,3000" ;
1313const colorscheme = process . env . FRAMEOS_VISUAL_COLORSCHEME || "Tomorrow" ;
14+ const xvfbServerArgs =
15+ process . env . FRAMEOS_VISUAL_XVFB_SERVER_ARGS || defaultXvfbServerArgs ( ) ;
1416const openscadCommand =
1517 process . env . FRAMEOS_OPENSCAD_COMMAND || findOpenSCADCommand ( ) ;
1618const checkMode = process . argv . includes ( "--check" ) ;
@@ -38,10 +40,17 @@ Environment:
3840 FRAMEOS_VISUAL_COLORSCHEME OpenSCAD colorscheme, default ${ colorscheme }
3941 FRAMEOS_OPENSCAD_COMMAND OpenSCAD CLI command, default ${ openscadCommand }
4042 FRAMEOS_VISUAL_XVFB=0 Disable xvfb-run on Linux
43+ FRAMEOS_VISUAL_XVFB_SERVER_ARGS
44+ Override xvfb-run server args, default ${ xvfbServerArgs }
4145` ) ;
4246 process . exit ( 0 ) ;
4347}
4448
49+ function defaultXvfbServerArgs ( ) {
50+ const [ width , height ] = imageSize . split ( "," ) ;
51+ return `-screen 0 ${ width } x${ height } x24 +extension GLX +render -noreset` ;
52+ }
53+
4554function sortedEntries ( directory ) {
4655 return fs
4756 . readdirSync ( directory , { withFileTypes : true } )
@@ -68,13 +77,28 @@ function findScadFiles(directory) {
6877}
6978
7079function commandExists ( command ) {
71- const result = spawnSync ( "sh" , [ "-lc" , `command -v "${ command } "` ] , {
72- cwd : repoRoot ,
73- encoding : "utf8" ,
74- } ) ;
80+ const result = spawnSync (
81+ "sh" ,
82+ [ "-c" , 'command -v "$1" >/dev/null 2>&1' , "sh" , command ] ,
83+ {
84+ cwd : repoRoot ,
85+ encoding : "utf8" ,
86+ }
87+ ) ;
7588 return result . status === 0 ;
7689}
7790
91+ function openscadEnvironment ( ) {
92+ if ( process . platform !== "linux" ) {
93+ return process . env ;
94+ }
95+
96+ return {
97+ ...process . env ,
98+ LIBGL_ALWAYS_SOFTWARE : process . env . LIBGL_ALWAYS_SOFTWARE || "1" ,
99+ } ;
100+ }
101+
78102function findOpenSCADCommand ( ) {
79103 for ( const command of [ "openscad-unstable" , "openscad" ] ) {
80104 if ( commandExists ( command ) ) {
@@ -95,16 +119,9 @@ function openscadInvocation(args) {
95119 return { command : openscadCommand , args } ;
96120 }
97121
98- const [ width , height ] = imageSize . split ( "," ) ;
99122 return {
100123 command : "xvfb-run" ,
101- args : [
102- "-a" ,
103- "-s" ,
104- `-screen 0 ${ width } x${ height } x24` ,
105- openscadCommand ,
106- ...args ,
107- ] ,
124+ args : [ "-a" , "-s" , xvfbServerArgs , openscadCommand , ...args ] ,
108125 } ;
109126}
110127
@@ -138,6 +155,7 @@ function runOpenSCAD(args) {
138155 return spawnSync ( command , finalArgs , {
139156 cwd : repoRoot ,
140157 encoding : "utf8" ,
158+ env : openscadEnvironment ( ) ,
141159 maxBuffer : 64 * 1024 * 1024 ,
142160 } ) ;
143161}
0 commit comments