]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/GenBuild/org/tianocore/build/global/DpFile.java
Removed the BASE type as any type in the check of SupModuleList in getLibraryClasses()
[mirror_edk2.git] / Tools / Java / Source / GenBuild / org / tianocore / build / global / DpFile.java
1 /** @file
2 This file is used to define class which represents dependency file in ANT task
3
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14 package org.tianocore.build.global;
15
16 import org.apache.tools.ant.types.DataType;
17 import org.apache.tools.ant.types.Path;
18 import org.apache.tools.ant.BuildException;
19
20 import java.io.File;
21 import java.io.FileReader;
22 import java.io.IOException;
23 import java.io.LineNumberReader;
24 import java.util.ArrayList;
25 import java.util.List;
26 import java.util.regex.Matcher;
27 import java.util.regex.Pattern;
28
29 /**
30 DpFile is a ANT DataType which can be used to specify dependency files from
31 a file list file, from file list string separated by space, comma or semi-comma,
32 or from file name with absolute path
33 **/
34 public class DpFile extends DataType {
35 ///
36 /// keep the list of files path
37 ///
38 private List<String> nameList = new ArrayList<String>();
39
40 /**
41 Empty constructor just in case
42 **/
43 public DpFile() {
44 }
45
46 /**
47 Empty execute method of ANT task, just in case
48 **/
49 public void execute() {
50 }
51
52 /**
53 Standard set method of ANT task/datatype, for ListFile attribute. It simply
54 fetch one file path a line from specified list file, and put them in nameList
55
56 @param fileListFile file which contains a file list, one file a line,
57 with full path
58 **/
59 public void setListFile(String fileListFile) {
60 File file = new File(fileListFile);
61 if (!file.exists()) {
62 return;
63 }
64
65 try {
66 FileReader fileReader = new FileReader(file);
67 LineNumberReader lineReader = new LineNumberReader(fileReader);
68
69 String filePath = null;
70 while ((filePath = lineReader.readLine()) != null) {
71 filePath = filePath.trim();
72 if (filePath.length() == 0) {
73 continue;
74 }
75 this.nameList.add(filePath);
76 }
77
78 lineReader.close();
79 fileReader.close();
80 } catch (IOException e) {
81 throw new BuildException(e.getMessage());
82 }
83 }
84
85 /**
86 Standard set method of ANT task/datatype, for List attribute.
87
88 @param fileList string with file pathes separated by space, comma,
89 or semi-comma
90 **/
91 public void setList(String fileList) {
92 //
93 // space, comma or semi-comma separated files list
94 //
95 Pattern pattern = Pattern.compile("([^ ,;\n\r]++)[ ,;\n\r]*+");
96 Matcher matcher = pattern.matcher(fileList);
97
98 while (matcher.find()) {
99 //
100 // keep each file name before " ,;\n\r"
101 //
102 String filePath = fileList.substring(matcher.start(1), matcher.end(1)).trim();
103 if (filePath.length() == 0) {
104 continue;
105 }
106 nameList.add(Path.translateFile(filePath));
107 }
108
109 }
110
111 /**
112 Standard set method of ANT task/datatype, for Name attribute.
113
114 @param fileName string of a file full path
115 **/
116 public void setName(String fileName) {
117 this.nameList.add(fileName);
118 }
119
120 /**
121 Fetch the file name list.
122
123 @returns A string list which contains file names specified to check dependnecy
124 **/
125 public List<String> getList() {
126 return this.nameList;
127 }
128 }
129
130