Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions substratevm/mx.substratevm/mx_substratevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,23 +351,29 @@ def _native_image(args, **kwargs):

def query_native_image(all_args, option):

stdoutdata = []
def stdout_collector(x):
stdoutdata.append(x.rstrip())
_native_image(['--dry-run'] + all_args, out=stdout_collector)

def remove_quotes(val):
if len(val) >= 2 and val.startswith("'") and val.endswith("'"):
return val[1:-1].replace("\\'", "'")
else:
return val

out = mx.LinesOutputCapture()
_native_image(['--dry-run'] + all_args, out=out)
for line in out.lines:
for line in stdoutdata:
arg = remove_quotes(line.rstrip('\\').strip())
_, sep, after = arg.partition(option)
if sep:
return after.split(' ')[0].rstrip()
return None

server_use = set()
def native_image_func(args, **kwargs):
all_args = base_args + common_args + args
if '--experimental-build-server' in all_args:
server_use.add(True)
path = query_native_image(all_args, '-H:Path=')
name = query_native_image(all_args, '-H:Name=')
image = join(path, name)
Expand All @@ -380,7 +386,7 @@ def native_image_func(args, **kwargs):
_native_image(['--server-wipe'])
yield native_image_func
finally:
if exists(native_image_cmd) and has_server:
if exists(native_image_cmd) and has_server and server_use:
def timestr():
return time.strftime('%d %b %Y %H:%M:%S') + ' - '
mx.log(timestr() + 'Shutting down image build servers for ' + native_image_cmd)
Expand Down
3 changes: 3 additions & 0 deletions substratevm/src/com.oracle.svm.driver/resources/HelpExtra.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ Non-standard options help:

-V<key>=<value> provide values for placeholders in native-image.properties files

--help-experimental-build-server
displays help for experimental image-build server use

14 changes: 8 additions & 6 deletions substratevm/src/com.oracle.svm.driver/resources/HelpServer.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
Server options help:

--no-server do not use image-build server
--no-server do not use experimental image-build server (default)
--experimental-build-server
use experimental image-build server

--server-list lists current image-build servers
--server-list lists current experimental image-build servers
--server-list-details same as -server-list with more details
--server-cleanup remove stale image-build servers entries
--server-shutdown shutdown image-build servers under current session ID
--server-shutdown-all shutdown all image-build servers
--server-cleanup remove stale experimental image-build servers entries
--server-shutdown shutdown experimental image-build servers under current session ID
--server-shutdown-all shutdown all experimental image-build servers

--server-session=<custom-session-name>
use custom session name instead of system provided
session ID of the calling process

--verbose-server enable verbose output for image-build server handling
--verbose-server enable verbose output for experimental image-build server handling

Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ final class NativeImageServer extends NativeImage {
private static final String pKeyMaxServers = "MaxServers";
private static final String machineProperties = "machine.properties";

private boolean useServer = true;
private boolean useServer = false;
private boolean verboseServer = false;
private String sessionName = null;

Expand Down Expand Up @@ -810,7 +810,9 @@ boolean useServer() {
@Override
protected void setDryRun(boolean val) {
super.setDryRun(val);
useServer = !val;
if (val) {
useServer = false;
}
}

void setVerboseServer(boolean val) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@
import java.util.List;
import java.util.Queue;

import com.oracle.svm.driver.MacroOption.MacroOptionKind;

class ServerOptionHandler extends NativeImage.OptionHandler<NativeImageServer> {

private static final String helpTextServer = NativeImage.getResource("/HelpServer.txt");
private static final String enableServerOption = "--experimental-build-server";

ServerOptionHandler(NativeImageServer nativeImage) {
super(nativeImage);
Expand All @@ -41,18 +40,22 @@ class ServerOptionHandler extends NativeImage.OptionHandler<NativeImageServer> {
public boolean consume(Queue<String> args) {
String headArg = args.peek();
switch (headArg) {
case "--help-extra":
case "--help-experimental-build-server":
args.poll();
nativeImage.showMessage(DefaultOptionHandler.helpExtraText);
nativeImage.showMessage(helpTextServer);
nativeImage.optionRegistry.showOptions(MacroOptionKind.Macro, true, nativeImage::showMessage);
nativeImage.showNewline();
System.exit(0);
return true;
case DefaultOptionHandler.noServerOption:
args.poll();
nativeImage.setUseServer(false);
return true;
case enableServerOption:
args.poll();
if (!nativeImage.isDryRun()) {
nativeImage.setUseServer(true);
}
return true;
case DefaultOptionHandler.verboseServerOption:
args.poll();
nativeImage.setVerboseServer(true);
Expand Down