diff options
| author | Jean-Philippe Lesot <jplesot@google.com> | 2015-02-27 12:11:21 +0100 |
|---|---|---|
| committer | Jean-Philippe Lesot <jplesot@google.com> | 2015-02-27 15:08:03 +0100 |
| commit | 46761f5f9b7b4f40f13ae1c26e145cf123461abb (patch) | |
| tree | d611bae5490bdc683eecc1c8ce6d163ffd9270c5 /jack-api/src/com/android/jack/api/example/Main.java | |
| parent | f02aec7098433dfaa9a29c9f496bcc870f27bde4 (diff) | |
| download | toolchain_jack-46761f5f9b7b4f40f13ae1c26e145cf123461abb.tar.gz toolchain_jack-46761f5f9b7b4f40f13ae1c26e145cf123461abb.tar.bz2 toolchain_jack-46761f5f9b7b4f40f13ae1c26e145cf123461abb.zip | |
Working on Jack API
Change-Id: I1e5467956ccb3a593fcbf07d9e774eb995bd1cdb
Diffstat (limited to 'jack-api/src/com/android/jack/api/example/Main.java')
| -rw-r--r-- | jack-api/src/com/android/jack/api/example/Main.java | 80 |
1 files changed, 48 insertions, 32 deletions
diff --git a/jack-api/src/com/android/jack/api/example/Main.java b/jack-api/src/com/android/jack/api/example/Main.java index 36738898..573ed169 100644 --- a/jack-api/src/com/android/jack/api/example/Main.java +++ b/jack-api/src/com/android/jack/api/example/Main.java @@ -1,13 +1,29 @@ -package com.android.jack.api.example; +/* + * Copyright (C) 2015 The Android Open Source Project + * + * 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 com.android.jack.api.example; -import com.android.jack.api.AbortException; +import com.android.jack.api.ConfigNotSupportedException; import com.android.jack.api.JackConfig; import com.android.jack.api.JackConfigProvider; -import com.android.jack.api.UnrecoverableException; -import com.android.jack.api.arzon.ArzonCompiler; -import com.android.jack.api.arzon.ArzonConfig; +import com.android.jack.api.brest.AbortException; +import com.android.jack.api.brest.BrestCompiler; import com.android.jack.api.brest.BrestConfig; +import com.android.jack.api.brest.ConfigurationException; +import com.android.jack.api.brest.UnrecoverableException; import java.io.File; import java.lang.reflect.InvocationTargetException; @@ -16,22 +32,9 @@ import java.net.URL; import java.net.URLClassLoader; /** - * + * STOPSHIP */ public class Main { - - /** - * - * @param args - * @throws MalformedURLException - * @throws ClassNotFoundException - * @throws SecurityException - * @throws NoSuchMethodException - * @throws IllegalArgumentException - * @throws InstantiationException - * @throws IllegalAccessException - * @throws InvocationTargetException - */ public static void main(String[] args) throws MalformedURLException, ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { @@ -56,25 +59,38 @@ public class Main { } System.out.println(); - ArzonConfig arzonConfig = confProvider.getConfig(ArzonConfig.class); - arzonConfig.setProperty("c.a.n.arzon", "bar").setProperty("a.b.c.d", "foo"); - ArzonCompiler arzonCompiler = arzonConfig.build(); + BrestCompiler brestCompiler; + BrestConfig brestConfig; + + // Get configuration object try { - arzonCompiler.run(); - } catch (AbortException e) { - e.printStackTrace(); - } catch (UnrecoverableException e) { - e.printStackTrace(); + brestConfig = confProvider.getConfig(BrestConfig.class); + } catch (ConfigNotSupportedException e1) { + System.err.println("Brest config not supported)"); + return; + } + + // Configure the compiler + try { + brestConfig.setProperty(BrestConfig.PROPERTY_REPORTER, "sdk"); + brestCompiler = brestConfig.build(); + } catch (ConfigurationException e) { + System.err.println(e.getMessage()); + return; } - BrestConfig brest = confProvider.getConfig(BrestConfig.class); - brest.setProperty("c.a.n.brest", "toto"); + // Run the compilation try { - brest.build().run(); + // First + brestCompiler.run(); + // Same compilation + brestCompiler.run(); } catch (AbortException e) { - e.printStackTrace(); + System.out.println("User error, see reporter"); + return; } catch (UnrecoverableException e) { - e.printStackTrace(); + System.out.println("Something out of Jack control has happen: " + e.getMessage()); + return; } } } |
