|
39 | 39 | import java.nio.file.attribute.BasicFileAttributes;
|
40 | 40 | import java.util.List;
|
41 | 41 |
|
42 |
| -import com.oracle.svm.core.SubstrateUtil; |
43 | 42 | import org.graalvm.collections.UnmodifiableEconomicMap;
|
44 |
| -import jdk.graal.compiler.options.Option; |
| 43 | +import org.graalvm.nativeimage.ImageSingletons; |
| 44 | +import org.graalvm.nativeimage.Platform; |
45 | 45 |
|
| 46 | +import com.oracle.svm.core.SubstrateUtil; |
46 | 47 | import com.oracle.svm.core.option.HostedOptionKey;
|
47 | 48 | import com.oracle.svm.core.option.SubstrateOptionsParser;
|
48 | 49 | import com.oracle.svm.core.util.UserError;
|
49 | 50 | import com.oracle.svm.hosted.c.info.NativeCodeInfo;
|
50 | 51 | import com.oracle.svm.hosted.c.query.QueryResultParser;
|
| 52 | + |
| 53 | +import jdk.graal.compiler.options.Option; |
51 | 54 | import jdk.graal.compiler.options.OptionKey;
|
52 | 55 | import jdk.graal.compiler.options.OptionValues;
|
53 |
| -import org.graalvm.nativeimage.ImageSingletons; |
54 |
| -import org.graalvm.nativeimage.Platform; |
55 | 56 |
|
56 | 57 | /**
|
57 | 58 | * Cache of pre-computed information for the {@link CAnnotationProcessor}. The cache is helpful to
|
@@ -103,6 +104,9 @@ public Boolean getValue(OptionValues values) {
|
103 | 104 | @Option(help = "Directory where information generated by the CAnnotation Processor are cached.")//
|
104 | 105 | public static final HostedOptionKey<String> CAPCacheDir = new HostedOptionKey<>("");
|
105 | 106 |
|
| 107 | + @Option(help = "Generate a query (i.e., C source code) if a CAP cache is used but the requested data is not found in the cache.")// |
| 108 | + public static final HostedOptionKey<Boolean> QueryIfNotInCAPCache = new HostedOptionKey<>(false); |
| 109 | + |
106 | 110 | @Option(help = "Exit image generation after C Annotation Processor Cache creation.")//
|
107 | 111 | public static final HostedOptionKey<Boolean> ExitAfterCAPCache = new HostedOptionKey<>(false);
|
108 | 112 |
|
@@ -160,13 +164,17 @@ private static String toPath(NativeCodeInfo nativeCodeInfo) {
|
160 | 164 | return nativeCodeInfo.getName().replaceAll("\\W", "_").concat(FILE_EXTENSION);
|
161 | 165 | }
|
162 | 166 |
|
163 |
| - public void get(NativeLibraries nativeLibs, NativeCodeInfo nativeCodeInfo) { |
| 167 | + public boolean get(NativeLibraries nativeLibs, NativeCodeInfo nativeCodeInfo) { |
164 | 168 | File file = new File(cache, toPath(nativeCodeInfo));
|
165 | 169 | try (FileInputStream fis = new FileInputStream(file)) {
|
166 | 170 | QueryResultParser.parse(nativeLibs, nativeCodeInfo, fis);
|
| 171 | + return true; |
167 | 172 | } catch (IOException e) {
|
168 |
| - throw UserError.abort("Could not load CAPCache file. Ensure that options %s and %s are used on the same version of your application. Raw error: %s", |
169 |
| - Options.UseCAPCache.getName(), Options.NewCAPCache, e.getMessage()); |
| 173 | + if (!CAnnotationProcessorCache.Options.QueryIfNotInCAPCache.getValue()) { |
| 174 | + throw UserError.abort("Could not load CAPCache file. Ensure that options %s and %s are used on the same version of your application. Raw error: %s", |
| 175 | + Options.UseCAPCache.getName(), Options.NewCAPCache, e.getMessage()); |
| 176 | + } |
| 177 | + return false; |
170 | 178 | }
|
171 | 179 | }
|
172 | 180 |
|
|
0 commit comments