]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Extract msa license info from inf file.
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 13 Oct 2006 03:47:05 +0000 (03:47 +0000)
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 13 Oct 2006 03:47:05 +0000 (03:47 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1737 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Java/Source/MigrationTools/org/tianocore/migration/ModuleInfo.java
Tools/Java/Source/MigrationTools/org/tianocore/migration/ModuleReader.java
Tools/Java/Source/MigrationTools/org/tianocore/migration/MsaOwner.java
Tools/Java/Source/MigrationTools/org/tianocore/migration/MsaWriter.java

index aa19522e02d1dd2af8e75ef9187c9a8485678495..48ecc56e56b88adb062618801456f1809ed2dc86 100644 (file)
@@ -36,6 +36,7 @@ public final class ModuleInfo {
     public String guidvalue = null;\r
     public String moduletype = null;\r
     public String entrypoint = null;\r
+    public String license = null;\r
     \r
     public final Set<String> localmodulesources = new HashSet<String>();        //contains both .c and .h\r
     public final Set<String> preprocessedccodes = new HashSet<String>();\r
index 09d426282f0d46e94b7a39b1f0c40e548e7ef826..0f1df7b59343187de77f4dbd95a1f0fa066638e7 100644 (file)
@@ -26,7 +26,7 @@ public final class ModuleReader implements Common.ForDoAll {
     private static final Pattern ptninfequation = Pattern.compile("([^\\s]*)\\s*=\\s*([^\\s]*)");\r
     private static final Pattern ptnsection = Pattern.compile("\\[([^\\[\\]]*)\\]([^\\[\\]]*)\\n", Pattern.MULTILINE);\r
     private static final Pattern ptnfilename = Pattern.compile("[^\\s]+");\r
-    \r
+\r
     public final void ModuleScan() throws Exception {\r
         Common.toDoAll(mi.modulepath, ModuleInfo.class.getMethod("enroll", String.class), mi, null, Common.FILE);\r
 \r
@@ -72,7 +72,36 @@ public final class ModuleReader implements Common.ForDoAll {
             }\r
         }\r
     }\r
-    \r
+    private final String extractLicense(String wholeline) throws Exception {\r
+        String tempLine;\r
+        String license = null;\r
+\r
+        BufferedReader rd = new BufferedReader(new StringReader(wholeline));\r
+        while ((tempLine = rd.readLine()) != null) {\r
+            if (tempLine.contains("#")) {\r
+                if (tempLine.contains("Copyright")) {\r
+                    //\r
+                    // Find license info.\r
+                    // \r
+                    license = "";\r
+                    while ((tempLine = rd.readLine())!= null) {\r
+                        if (!tempLine.contains("#") ||\r
+                             tempLine.contains("Module Name:") ||\r
+                             tempLine.contains("Abstract:")) {\r
+                            //\r
+                            // We assume license ends here.\r
+                            // \r
+                            break;\r
+                        }\r
+                        license += "      " + tempLine.replaceAll("\\s*[#]\\s*(.*)", "$1\n");\r
+                    }\r
+                    break;\r
+                }\r
+            }\r
+        }\r
+        return license;\r
+    }\r
+\r
     private final void readInf(String name) throws Exception {\r
         System.out.println("\nParsing INF file: " + name);\r
         String wholeline;\r
@@ -81,6 +110,7 @@ public final class ModuleReader implements Common.ForDoAll {
         Matcher mtrfilename;\r
 \r
         wholeline = Common.file2string(mi.modulepath + File.separator + name);\r
+        mi.license = extractLicense(wholeline);\r
         mtrsection = ptnsection.matcher(wholeline);\r
         while (mtrsection.find()) {\r
             if (mtrsection.group(1).matches("defines")) {\r
index 65873a3c69fdbc459d1e2650115541572a4f2ab8..9217857fc634efd7c7295db447218b7adef68dd7 100644 (file)
@@ -1,3 +1,15 @@
+/** @file\r
\r
+ Copyright (c) 2006, Intel Corporation\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution.  The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
+ **/\r
 package org.tianocore.migration;\r
 \r
 import java.io.BufferedWriter;\r
index 132d6c3bc5a59b9d58da1fcdbd4c41d3f4830e90..af8646f792d0de4b946f7d3a7ffe22021da535c2 100644 (file)
@@ -100,18 +100,16 @@ public class MsaWriter {
             msaheader.setModuleType(ModuleTypeDef.Enum.forString(mi.moduletype = Query("Guid Value Not Found!  Please Input Guid Value")));\r
         }\r
 \r
-        msaheader.setCopyright("Copyright (c) 2006, Intel Corporation");\r
+        msaheader.setCopyright("Copyright (c) 2006, Intel Corporation. All right reserved.");\r
         msaheader.setVersion("1.0");\r
         msaheader.setAbstract("Component name for module " + mi.modulename);\r
         msaheader.setDescription("FIX ME!");\r
-        msaheader.addNewLicense().setStringValue("All rights reserved.\n" +\r
-                "      This software and associated documentation (if any) is furnished\n" +\r
-                "      under a license and may only be used or copied in accordance\n" +\r
-                "      with the terms of the license. Except as permitted by such\n" +\r
-                "      license, no part of this software or documentation may be\n" +\r
-                "      reproduced, stored in a retrieval system, or transmitted in any\n" +\r
-                "      form or by any means without the express written consent of\n" +\r
-                "      Intel Corporation.");\r
+\r
+        if (mi.license == null) {\r
+            mi.license = "FIX ME!";\r
+            MigrationTool.ui.println ("Fail to extract license info in inf file"); \r
+        }\r
+        msaheader.addNewLicense().setStringValue(mi.license);\r
         msaheader.setSpecification("FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052");\r
         \r
         List<Enum> arch = new ArrayList<Enum>();\r