mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
reduce npm warnings and improve speed through singel global installation
This commit is contained in:
parent
cc5d794c07
commit
088e689daa
@ -29,6 +29,8 @@ import java.nio.charset.StandardCharsets;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,6 +44,8 @@ public class WasmRule extends TemporaryFolder {
|
|||||||
|
|
||||||
private static final SpiderMonkey spiderMonkey = new SpiderMonkey();
|
private static final SpiderMonkey spiderMonkey = new SpiderMonkey();
|
||||||
|
|
||||||
|
private static boolean wastInstalled;
|
||||||
|
|
||||||
private final Class<?>[] classes;
|
private final Class<?>[] classes;
|
||||||
|
|
||||||
private File wasmFile;
|
private File wasmFile;
|
||||||
@ -113,11 +117,29 @@ public class WasmRule extends TemporaryFolder {
|
|||||||
spiderMonkeyScript = createScript( "SpiderMonkeyTest.js" );
|
spiderMonkeyScript = createScript( "SpiderMonkeyTest.js" );
|
||||||
nodeWastScript = createScript( "WatTest.js" );
|
nodeWastScript = createScript( "WatTest.js" );
|
||||||
|
|
||||||
ProcessBuilder processBuilder = IS_WINDOWS ? new ProcessBuilder( "cmd", "/C", "npm", "install", "wabt@nightly" ) : new ProcessBuilder( "npm", "install", "wabt@nightly" );
|
if( !wastInstalled ) {
|
||||||
|
wastInstalled = true;
|
||||||
|
ProcessBuilder processBuilder = new ProcessBuilder( "npm", "install", "-g", "wabt@nightly" );
|
||||||
|
if( IS_WINDOWS ) {
|
||||||
|
processBuilder.command().add( 0, "cmd" );
|
||||||
|
processBuilder.command().add( 1, "/C" );
|
||||||
|
}
|
||||||
|
//processBuilder.directory( getRoot() );
|
||||||
|
processBuilder.redirectOutput( Redirect.INHERIT );
|
||||||
|
processBuilder.redirectError( Redirect.INHERIT );
|
||||||
|
System.out.println( String.join( " ", processBuilder.command() ) );
|
||||||
|
Process process = processBuilder.start();
|
||||||
|
int exitCode = process.waitFor();
|
||||||
|
if( exitCode != 0 ) {
|
||||||
|
fail( readStream( process.getErrorStream() ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ProcessBuilder processBuilder = new ProcessBuilder( "npm", "link", "wabt" );
|
||||||
|
if( IS_WINDOWS ) {
|
||||||
|
processBuilder.command().add( 0, "cmd" );
|
||||||
|
processBuilder.command().add( 1, "/C" );
|
||||||
|
}
|
||||||
processBuilder.directory( getRoot() );
|
processBuilder.directory( getRoot() );
|
||||||
processBuilder.redirectOutput( Redirect.INHERIT );
|
|
||||||
processBuilder.redirectError( Redirect.INHERIT );
|
|
||||||
System.out.println( String.join( " ", processBuilder.command() ) );
|
|
||||||
Process process = processBuilder.start();
|
Process process = processBuilder.start();
|
||||||
int exitCode = process.waitFor();
|
int exitCode = process.waitFor();
|
||||||
if( exitCode != 0 ) {
|
if( exitCode != 0 ) {
|
||||||
@ -295,13 +317,12 @@ public class WasmRule extends TemporaryFolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a ProcessBuilder for node.js
|
* The executable of the node command.
|
||||||
*
|
*
|
||||||
* @param script
|
* @return the node executable
|
||||||
* the path to the script that should be executed
|
|
||||||
* @return the value from the script
|
|
||||||
*/
|
*/
|
||||||
private static ProcessBuilder nodeJsCommand( File script ) {
|
@Nonnull
|
||||||
|
private static String nodeExecuable() {
|
||||||
String command = System.getProperty( "node.dir" );
|
String command = System.getProperty( "node.dir" );
|
||||||
if( command == null ) {
|
if( command == null ) {
|
||||||
command = "node";
|
command = "node";
|
||||||
@ -312,6 +333,18 @@ public class WasmRule extends TemporaryFolder {
|
|||||||
command += "/bin/node";
|
command += "/bin/node";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return command;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a ProcessBuilder for node.js
|
||||||
|
*
|
||||||
|
* @param script
|
||||||
|
* the path to the script that should be executed
|
||||||
|
* @return the value from the script
|
||||||
|
*/
|
||||||
|
private static ProcessBuilder nodeJsCommand( File script ) {
|
||||||
|
String command = nodeExecuable();
|
||||||
// details see with command: node --v8-options
|
// details see with command: node --v8-options
|
||||||
return new ProcessBuilder( command, "--experimental-wasm-se", "--experimental-wasm-sat-f2i-conversions", "--experimental-wasm-eh", "--experimental-wasm-anyref", script.getAbsolutePath() );
|
return new ProcessBuilder( command, "--experimental-wasm-se", "--experimental-wasm-sat-f2i-conversions", "--experimental-wasm-eh", "--experimental-wasm-anyref", script.getAbsolutePath() );
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user