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