Skip to content

Commit 23a8a41

Browse files
committed
[GR-42375] Introduce -H:±GenerateBuildArtifactsFile option.
PullRequest: graal/13186
2 parents 5885ca4 + 6f6ef02 commit 23a8a41

File tree

40 files changed

+350
-112
lines changed

40 files changed

+350
-112
lines changed
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
{
2+
"$id": "https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/build-artifacts-schema-v0.9.0.json",
3+
"$schema": "https://json-schema.org/draft/2019-09/schema",
4+
"default": {},
5+
"examples": [
6+
{
7+
"build_info": [
8+
"build-output.json"
9+
],
10+
"debug_info": [
11+
"helloworld",
12+
"sources"
13+
],
14+
"executables": [
15+
"helloworld"
16+
]
17+
}
18+
],
19+
"properties": {
20+
"build_info": {
21+
"default": [],
22+
"items": {
23+
"format": "uri-reference",
24+
"title": "Relative path to file or directory",
25+
"type": "string"
26+
},
27+
"title": "Build information generated by Native Image (not needed at run-time)",
28+
"type": "array"
29+
},
30+
"c_headers": {
31+
"default": [],
32+
"items": {
33+
"format": "uri-reference",
34+
"title": "Relative path to file or directory",
35+
"type": "string"
36+
},
37+
"title": "C header files generated by Native Image (not needed at run-time)",
38+
"type": "array"
39+
},
40+
"debug_info": {
41+
"default": [],
42+
"items": {
43+
"format": "uri-reference",
44+
"title": "Relative path to file or directory",
45+
"type": "string"
46+
},
47+
"title": "Debug information generated by Native Image (not needed at run-time)",
48+
"type": "array"
49+
},
50+
"executables": {
51+
"default": [],
52+
"items": {
53+
"format": "uri-reference",
54+
"title": "Relative path to file or directory",
55+
"type": "string"
56+
},
57+
"title": "Executables generated by Native Image (needed at run-time)",
58+
"type": "array"
59+
},
60+
"import_libraries": {
61+
"default": [],
62+
"items": {
63+
"format": "uri-reference",
64+
"title": "Relative path to file or directory",
65+
"type": "string"
66+
},
67+
"title": "Import libraries generated by Native Image (not needed at run-time)",
68+
"type": "array"
69+
},
70+
"jdk_libraries": {
71+
"default": [],
72+
"items": {
73+
"format": "uri-reference",
74+
"title": "Relative path to file or directory",
75+
"type": "string"
76+
},
77+
"title": "JDK libraries copied by Native Image (needed at run-time)",
78+
"type": "array"
79+
},
80+
"language_home": {
81+
"default": [],
82+
"items": {
83+
"format": "uri-reference",
84+
"title": "Relative path to file or directory",
85+
"type": "string"
86+
},
87+
"title": "Language home artifacts for Truffle languages (needed at run-time)",
88+
"type": "array"
89+
},
90+
"shared_libraries": {
91+
"default": [],
92+
"items": {
93+
"format": "uri-reference",
94+
"title": "Relative path to file or directory",
95+
"type": "string"
96+
},
97+
"title": "Shared libraries generated by Native Image (not needed at run-time)",
98+
"type": "array"
99+
}
100+
},
101+
"required": [],
102+
"title": "JSON schema for the build artifacts of GraalVM Native Image",
103+
"type": "object"
104+
}

substratevm/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This changelog summarizes major changes to GraalVM Native Image.
99
* (GR-41674) Class instanceOf and isAssignableFrom checks do need to make the checked type reachable.
1010
* (GR-41100) Add support for `-XX:HeapDumpPath` to control where heap dumps are created.
1111
* (GR-42148) Adjust build output to report types (primitives, classes, interfaces, and arrays) instead of classes and revise the output schema of `-H:BuildOutputJSONFile`.
12+
* (GR-42375) Add `-H:±GenerateBuildArtifactsFile` option, which generates a `build-artifacts.json` file with a list of all artifacts produced by Native Image. `.build_artifacts.txt` files are now deprecated, disabled (can be re-enabled with env setting `NATIVE_IMAGE_DEPRECATED_BUILD_ARTIFACTS_TXT=true`), and will be removed in a future release.
1213

1314
## Version 22.3.0
1415
* (GR-35721) Remove old build output style and the `-H:±BuildOutputUseNewStyle` option.

substratevm/mx.substratevm/mx_substratevm.py

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -415,28 +415,36 @@ def help_stdout_check(output):
415415
if t:
416416
hellomodule(args.extra_image_builder_arguments)
417417

418-
with Task('Validate JSON build output', tasks, tags=[mx_gate.Tags.style]) as t:
418+
with Task('Validate JSON build info', tasks, tags=[mx_gate.Tags.style]) as t:
419419
if t:
420420
import json
421421
try:
422422
from jsonschema import validate as json_validate
423423
from jsonschema.exceptions import ValidationError, SchemaError
424424
except ImportError:
425425
mx.abort('Unable to import jsonschema')
426-
with open(join(suite.dir, '..', 'docs', 'reference-manual', 'native-image', 'assets', 'build-output-schema-v0.9.1.json')) as f:
427-
json_schema = json.load(f)
428-
with tempfile.NamedTemporaryFile(prefix='build_json') as json_file:
429-
helloworld(['--output-path', svmbuild_dir(), f'-H:BuildOutputJSONFile={json_file.name}'])
430-
try:
431-
with open(json_file.name) as f:
432-
json_output = json.load(f)
433-
json_validate(json_output, json_schema)
434-
except IOError as e:
435-
mx.abort(f'Unable to load JSON build output: {e}')
436-
except ValidationError as e:
437-
mx.abort(f'Unable to validate JSON build output against the schema: {e}')
438-
except SchemaError as e:
439-
mx.abort(f'JSON schema not valid: {e}')
426+
427+
json_and_schema_file_pairs = [
428+
('build-artifacts.json', 'build-artifacts-schema-v0.9.0.json'),
429+
('build-output.json', 'build-output-schema-v0.9.1.json'),
430+
]
431+
432+
build_output_file = join(svmbuild_dir(), 'build-output.json')
433+
helloworld(['--output-path', svmbuild_dir(), f'-H:BuildOutputJSONFile={build_output_file}', '-H:+GenerateBuildArtifactsFile'])
434+
435+
try:
436+
for json_file, schema_file in json_and_schema_file_pairs:
437+
with open(join(svmbuild_dir(), json_file)) as f:
438+
json_contents = json.load(f)
439+
with open(join(suite.dir, '..', 'docs', 'reference-manual', 'native-image', 'assets', schema_file)) as f:
440+
schema_contents = json.load(f)
441+
json_validate(json_contents, schema_contents)
442+
except IOError as e:
443+
mx.abort(f'Unable to load JSON build info: {e}')
444+
except ValidationError as e:
445+
mx.abort(f'Unable to validate JSON build info against the schema: {e}')
446+
except SchemaError as e:
447+
mx.abort(f'JSON schema not valid: {e}')
440448

441449

442450
def native_unittests_task(extra_build_args=None):

substratevm/src/com.oracle.svm.agent/src/com/oracle/svm/agent/conditionalconfig/ConditionalConfigurationPartialRunWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import com.oracle.svm.agent.configwithorigins.ConfigurationWithOriginsTracer;
3333
import com.oracle.svm.agent.tracing.core.TracingResultWriter;
3434
import com.oracle.svm.configure.config.conditional.PartialConfigurationWithOrigins;
35-
import com.oracle.svm.configure.json.JsonWriter;
35+
import com.oracle.svm.core.util.json.JsonWriter;
3636
import com.oracle.svm.core.configure.ConfigurationFile;
3737

3838
public class ConditionalConfigurationPartialRunWriter implements TracingResultWriter {

substratevm/src/com.oracle.svm.agent/src/com/oracle/svm/agent/tracing/TraceFileWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
import com.oracle.svm.agent.tracing.core.Tracer;
3838
import com.oracle.svm.agent.tracing.core.TracingResultWriter;
39-
import com.oracle.svm.configure.json.JsonWriter;
39+
import com.oracle.svm.core.util.json.JsonWriter;
4040
import com.oracle.svm.core.util.VMError;
4141

4242
public class TraceFileWriter extends Tracer implements TracingResultWriter {
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
Args = --add-exports=org.graalvm.sdk/org.graalvm.nativeimage.impl=ALL-UNNAMED -H:IncludeResources=com/oracle/svm/configure/test/config/.*json
1+
Args = \
2+
--add-exports=org.graalvm.sdk/org.graalvm.nativeimage.impl=ALL-UNNAMED \
3+
--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.util.json=ALL-UNNAMED \
4+
-H:IncludeResources=com/oracle/svm/configure/test/config/.*json

substratevm/src/com.oracle.svm.configure.test/src/com/oracle/svm/configure/test/conditionalconfig/ConfigurationVerifier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
import com.oracle.svm.configure.config.ConfigurationFileCollection;
3636
import com.oracle.svm.configure.config.ConfigurationSet;
37-
import com.oracle.svm.configure.json.JsonWriter;
37+
import com.oracle.svm.core.util.json.JsonWriter;
3838
import com.oracle.svm.core.configure.ConfigurationFile;
3939
import com.oracle.svm.core.util.VMError;
4040

substratevm/src/com.oracle.svm.configure.test/src/com/oracle/svm/configure/test/config/ResourceConfigurationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
import org.junit.Test;
3939

4040
import com.oracle.svm.configure.config.ResourceConfiguration;
41-
import com.oracle.svm.configure.json.JsonWriter;
41+
import com.oracle.svm.core.util.json.JsonWriter;
4242
import com.oracle.svm.core.configure.ResourceConfigurationParser;
4343
import com.oracle.svm.core.configure.ResourcesRegistry;
4444

substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/ConfigurationBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
import java.util.function.Consumer;
2828

29-
import com.oracle.svm.configure.json.JsonPrintable;
29+
import com.oracle.svm.core.util.json.JsonPrintable;
3030
import com.oracle.svm.core.configure.ConfigurationParser;
3131
import org.graalvm.nativeimage.impl.ConfigurationCondition;
3232

substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/ConfigurationTool.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
import com.oracle.svm.configure.filters.FilterConfigurationParser;
6262
import com.oracle.svm.configure.filters.ModuleFilterTools;
6363
import com.oracle.svm.configure.filters.HierarchyFilterNode;
64-
import com.oracle.svm.configure.json.JsonWriter;
64+
import com.oracle.svm.core.util.json.JsonWriter;
6565
import com.oracle.svm.configure.trace.AccessAdvisor;
6666
import com.oracle.svm.configure.trace.TraceProcessor;
6767
import com.oracle.svm.core.configure.ConfigurationFile;

0 commit comments

Comments
 (0)