src/share/classes/org/openjdk/jigsaw/cli/Librarian.java

Print this page

        

@@ -69,18 +69,19 @@
             if (opts.has(nativeCmds))
                 natcmds = opts.valueOf(nativeCmds);
             File configs = null;
             if (opts.has(configFiles))
                 configs = opts.valueOf(configFiles);
-
+            ModuleArchitecture modArch = ModuleArchitecture.create(opts.valueOf(osOpt),
+                                                                   opts.valueOf(archOpt));
             Set<StorageOption> createOpts = new HashSet<>();
             if (opts.has("z"))
                 createOpts.add(StorageOption.DEFLATED);
 
             try {
                 lib = SimpleLibrary.create(lp, pp, natlibs, natcmds,
-                                           configs, createOpts);
+                                           configs, createOpts, modArch);
             } catch (IOException x) {
                 throw new Command.Exception(x);
             }
         }
     }

@@ -131,10 +132,15 @@
             noDry();
             finishArgs();
             out.format("path %s%n", lib.root());
             out.format("version %d.%d%n",
                        lib.majorVersion(), lib.minorVersion());
+            ModuleArchitecture modArch = lib.architecture();
+            if (!modArch.os().equals(""))
+                out.format("os: %s%n", modArch.os());
+            if (!modArch.arch().equals(""))
+                out.format("arch: %s%n", modArch.arch());
             if (lib.natlibs() != null)
                 out.format("natlibs %s%n", lib.natlibs());
             if (lib.natcmds() != null)
                 out.format("natcmds %s%n", lib.natcmds());
             if (lib.configs() != null)

@@ -276,11 +282,11 @@
             throws Command.Exception
         {
             noDry();
             File classes = new File(takeArg());
             File dst = new File(takeArg());
-            List<Manifest> mfs = new ArrayList<Manifest>();
+            List<Manifest> mfs = new ArrayList<>();
             while (hasArg())
                 mfs.add(Manifest.create(takeArg(), classes));
             finishArgs();
             try {
                 lib.preInstall(mfs, dst);

@@ -296,11 +302,11 @@
         {
             if (dry && force)
                 throw new Command.Exception("%s: specify only one of "
                                         + "-n (--dry-run) or -f (--force)",
                                         command);
-            List<ModuleId> mids = new ArrayList<ModuleId>();
+            List<ModuleId> mids = new ArrayList<>();
             try {
                 while (hasArg())
                     mids.add(jms.parseModuleId(takeArg()));
             } catch (IllegalArgumentException x) {
                 throw new Command.Exception(x.getMessage());

@@ -353,11 +359,11 @@
     static class Config extends Command<SimpleLibrary> {
         protected void go(SimpleLibrary lib)
             throws Command.Exception
         {
             noDry();
-            List<ModuleId> mids = new ArrayList<ModuleId>();
+            List<ModuleId> mids = new ArrayList<>();
             try {
                 while (hasArg())
                     mids.add(jms.parseModuleId(takeArg()));
             } catch (IllegalArgumentException x) {
                 throw new Command.Exception(x.getMessage());

@@ -547,17 +553,20 @@
     private static OptionSpec<File> libPath;
     private static OptionSpec<File> parentPath;
     private static OptionSpec<File> nativeLibs;
     private static OptionSpec<File> nativeCmds;
     private static OptionSpec<File> configFiles;
+    private static OptionSpec<String> osOpt;
+    private static OptionSpec<String> archOpt;
 
     private void usage() {
         out.format("%n");
         out.format("usage: jmod add-repo [-i <index>] URL%n");
         out.format("       jmod config [<module-id> ...]%n");
-        out.format("       jmod create [-L <library>] [-P <parent>]" +
-                " [--natlib <natlib>] [--natcmd <natcmd>] [--config <config>]%n");
+        out.format("       jmod create      [-L <library>] [-P <parent>] [--natlib <natlib>]%n");
+        out.format("                        [--natcmd <natcmd>] [--config <config>]%n");
+        out.format("                        [-os <os>] [-arch <arch>]%n");
         out.format("       jmod del-repo URL%n");
         out.format("       jmod dump-class <module-id> <class-name> <output-file>%n");
         out.format("       jmod dump-config <module-id>%n");
         out.format("       jmod extract <module-file> ...%n");
         out.format("       jmod identify%n");

@@ -614,10 +623,20 @@
         configFiles
             = (parser.accepts("config", "Directory to store config files")
                .withRequiredArg()
                .describedAs("dir")
                .ofType(File.class));
+        osOpt
+            = (parser.accepts("os", "Target Operating System of the library")
+               .withRequiredArg()
+               .describedAs("os")
+               .ofType(String.class));
+        archOpt
+            = (parser.accepts("arch", "Target Architecture of the library")
+               .withRequiredArg()
+               .describedAs("arch")
+               .ofType(String.class));
         parser.acceptsAll(Arrays.asList("N", "no-parent"),
                           "Use no parent library when creating");
         parser.acceptsAll(Arrays.asList("v", "verbose"),
                           "Enable verbose output");
         parser.acceptsAll(Arrays.asList("h", "?", "help"),