2019-09-09 21:07:45 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2017 - 2019 Volker Berlin (i-net software)
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
package de.inetsoftware.jwebassembly.wasm;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
2019-12-31 13:04:52 +01:00
|
|
|
import javax.annotation.Nonnull;
|
|
|
|
|
2019-09-09 21:07:45 +02:00
|
|
|
import de.inetsoftware.jwebassembly.JWebAssembly;
|
2019-09-10 21:41:50 +02:00
|
|
|
import de.inetsoftware.jwebassembly.module.FunctionName;
|
2019-09-09 21:07:45 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The option/properties for the behavior of the compiler.
|
|
|
|
*
|
|
|
|
* @author Volker Berlin
|
|
|
|
*/
|
|
|
|
public class WasmOptions {
|
|
|
|
|
2019-09-10 17:52:14 +02:00
|
|
|
private final boolean debugNames;
|
|
|
|
|
2019-09-09 21:07:45 +02:00
|
|
|
private final boolean useGC;
|
|
|
|
|
2019-12-31 13:04:52 +01:00
|
|
|
@Nonnull
|
|
|
|
private final String sourceMapBase;
|
|
|
|
|
2019-09-10 21:41:50 +02:00
|
|
|
/**
|
|
|
|
* NonGC function for ref_eq polyfill.
|
|
|
|
*/
|
|
|
|
public FunctionName ref_eq;
|
|
|
|
|
2019-09-09 21:07:45 +02:00
|
|
|
/**
|
|
|
|
* Create a new instance of options
|
|
|
|
*
|
|
|
|
* @param properties
|
|
|
|
* compiler properties
|
|
|
|
*/
|
|
|
|
public WasmOptions( HashMap<String, String> properties ) {
|
2019-09-10 17:52:14 +02:00
|
|
|
debugNames = Boolean.parseBoolean( properties.get( JWebAssembly.DEBUG_NAMES ) );
|
2019-09-09 21:07:45 +02:00
|
|
|
useGC = Boolean.parseBoolean( properties.getOrDefault( JWebAssembly.WASM_USE_GC, "false" ) );
|
2019-12-31 13:04:52 +01:00
|
|
|
String base = properties.getOrDefault( JWebAssembly.SOURCE_MAP_BASE, "" );
|
|
|
|
if( !base.isEmpty() && !base.endsWith( "/" ) ) {
|
|
|
|
base += "/";
|
|
|
|
}
|
|
|
|
sourceMapBase = base;
|
2019-09-09 21:07:45 +02:00
|
|
|
}
|
|
|
|
|
2019-09-10 17:52:14 +02:00
|
|
|
/**
|
|
|
|
* Property for adding debug names to the output if true.
|
|
|
|
*
|
|
|
|
* @return true, add debug information
|
|
|
|
*/
|
|
|
|
public boolean debugNames() {
|
|
|
|
return debugNames;
|
|
|
|
}
|
|
|
|
|
2019-09-09 21:07:45 +02:00
|
|
|
/**
|
|
|
|
* If the GC feature of WASM should be use or the GC of the JavaScript host.
|
|
|
|
*
|
|
|
|
* @return true, use the GC instructions of WASM.
|
|
|
|
*/
|
|
|
|
public boolean useGC() {
|
|
|
|
return useGC;
|
|
|
|
}
|
2019-12-31 13:04:52 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the relative path between the final wasm file location and the source files location.
|
|
|
|
* If not empty it should end with a slash like "../../src/main/java/".
|
|
|
|
* @return the path
|
|
|
|
*/
|
|
|
|
@Nonnull
|
|
|
|
public String getSourceMapBase() {
|
|
|
|
return sourceMapBase;
|
|
|
|
}
|
2019-09-09 21:07:45 +02:00
|
|
|
}
|