2 This file is used to define class which represents dependency file in ANT task
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
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.
14 package org
.tianocore
.build
.global
;
16 import org
.apache
.tools
.ant
.types
.DataType
;
17 import org
.apache
.tools
.ant
.types
.Path
;
18 import org
.apache
.tools
.ant
.BuildException
;
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
;
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
34 public class DpFile
extends DataType
{
36 /// keep the list of files path
38 private List
<String
> nameList
= new ArrayList
<String
>();
41 Empty constructor just in case
47 Empty execute method of ANT task, just in case
49 public void execute() {
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
56 @param fileListFile file which contains a file list, one file a line,
59 public void setListFile(String fileListFile
) {
60 File file
= new File(fileListFile
);
66 FileReader fileReader
= new FileReader(file
);
67 LineNumberReader lineReader
= new LineNumberReader(fileReader
);
69 String filePath
= null;
70 while ((filePath
= lineReader
.readLine()) != null) {
71 filePath
= filePath
.trim();
72 if (filePath
.length() == 0) {
75 this.nameList
.add(filePath
);
80 } catch (IOException e
) {
81 throw new BuildException(e
.getMessage());
86 Standard set method of ANT task/datatype, for List attribute.
88 @param fileList string with file pathes separated by space, comma,
91 public void setList(String fileList
) {
93 // space, comma or semi-comma separated files list
95 Pattern pattern
= Pattern
.compile("([^ ,;\n\r]++)[ ,;\n\r]*+");
96 Matcher matcher
= pattern
.matcher(fileList
);
98 while (matcher
.find()) {
100 // keep each file name before " ,;\n\r"
102 String filePath
= fileList
.substring(matcher
.start(1), matcher
.end(1)).trim();
103 if (filePath
.length() == 0) {
106 nameList
.add(Path
.translateFile(filePath
));
112 Standard set method of ANT task/datatype, for Name attribute.
114 @param fileName string of a file full path
116 public void setName(String fileName
) {
117 this.nameList
.add(fileName
);
121 Fetch the file name list.
123 @returns A string list which contains file names specified to check dependnecy
125 public List
<String
> getList() {
126 return this.nameList
;