mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
Use NODE_PATH instead linking to wabt to improve test speed.
This commit is contained in:
parent
c4ed671b99
commit
daaa648a04
@ -61,6 +61,8 @@ public class WasmRule extends TemporaryFolder {
|
|||||||
|
|
||||||
private static boolean npmWabtNightly;
|
private static boolean npmWabtNightly;
|
||||||
|
|
||||||
|
private static String nodeModulePath;
|
||||||
|
|
||||||
private final Class<?>[] classes;
|
private final Class<?>[] classes;
|
||||||
|
|
||||||
private final JWebAssembly compiler;
|
private final JWebAssembly compiler;
|
||||||
@ -268,14 +270,30 @@ public class WasmRule extends TemporaryFolder {
|
|||||||
}
|
}
|
||||||
execute( processBuilder );
|
execute( processBuilder );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ProcessBuilder processBuilder = new ProcessBuilder( "npm", "link", "wabt" );
|
/**
|
||||||
|
* Get the path of the global installed module pathes.
|
||||||
|
*
|
||||||
|
* @return the path
|
||||||
|
* @throws Exception
|
||||||
|
* if any error occur.
|
||||||
|
*/
|
||||||
|
private static String getNodeModulePath() throws Exception {
|
||||||
|
if( nodeModulePath == null ) {
|
||||||
|
ProcessBuilder processBuilder = new ProcessBuilder( "npm", "root", "-g" );
|
||||||
if( IS_WINDOWS ) {
|
if( IS_WINDOWS ) {
|
||||||
processBuilder.command().add( 0, "cmd" );
|
processBuilder.command().add( 0, "cmd" );
|
||||||
processBuilder.command().add( 1, "/C" );
|
processBuilder.command().add( 1, "/C" );
|
||||||
}
|
}
|
||||||
execute( processBuilder );
|
Process process = processBuilder.start();
|
||||||
|
int exitCode = process.waitFor();
|
||||||
|
nodeModulePath = readStream( process.getInputStream() ).trim(); // module install path
|
||||||
|
System.out.println( "node global module path: " + nodeModulePath );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
return nodeModulePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -456,7 +474,9 @@ public class WasmRule extends TemporaryFolder {
|
|||||||
return nodeJsCommand( nodeScript );
|
return nodeJsCommand( nodeScript );
|
||||||
case NodeWat:
|
case NodeWat:
|
||||||
prepareNodeWat();
|
prepareNodeWat();
|
||||||
return nodeJsCommand( nodeWatScript );
|
ProcessBuilder processBuilder = nodeJsCommand( nodeWatScript );
|
||||||
|
processBuilder.environment().put( "NODE_PATH", getNodeModulePath() );
|
||||||
|
return processBuilder;
|
||||||
case Wat2Wasm:
|
case Wat2Wasm:
|
||||||
prepareWat2Wasm();
|
prepareWat2Wasm();
|
||||||
return nodeJsCommand( wat2WasmScript );
|
return nodeJsCommand( wat2WasmScript );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user