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