+++ /dev/null
-/** @file\r
-This file is used to define class which represents dependency file in ANT task\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.build.global;\r
-\r
-import org.apache.tools.ant.types.DataType;\r
-import org.apache.tools.ant.types.Path;\r
-import org.apache.tools.ant.BuildException;\r
-\r
-import java.io.File;\r
-import java.io.FileReader;\r
-import java.io.IOException;\r
-import java.io.LineNumberReader;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-import java.util.regex.Matcher;\r
-import java.util.regex.Pattern;\r
-\r
-/**\r
- DpFile is a ANT DataType which can be used to specify dependency files from\r
- a file list file, from file list string separated by space, comma or semi-comma,\r
- or from file name with absolute path\r
- **/\r
-public class DpFile extends DataType {\r
- ///\r
- /// keep the list of files path\r
- ///\r
- private List<String> nameList = new ArrayList<String>();\r
-\r
- /**\r
- Empty constructor just in case\r
- **/\r
- public DpFile() {\r
- }\r
-\r
- /**\r
- Empty execute method of ANT task, just in case\r
- **/\r
- public void execute() {\r
- }\r
-\r
- /**\r
- Standard set method of ANT task/datatype, for ListFile attribute. It simply\r
- fetch one file path a line from specified list file, and put them in nameList\r
-\r
- @param fileListFile file which contains a file list, one file a line,\r
- with full path\r
- **/\r
- public void setListFile(String fileListFile) {\r
- File file = new File(fileListFile);\r
- if (!file.exists()) {\r
- return;\r
- }\r
-\r
- try {\r
- FileReader fileReader = new FileReader(file);\r
- LineNumberReader lineReader = new LineNumberReader(fileReader);\r
-\r
- String filePath = null;\r
- while ((filePath = lineReader.readLine()) != null) {\r
- filePath = filePath.trim();\r
- if (filePath.length() == 0) {\r
- continue;\r
- }\r
- this.nameList.add(filePath);\r
- }\r
-\r
- lineReader.close();\r
- fileReader.close();\r
- } catch (IOException e) {\r
- throw new BuildException(e.getMessage());\r
- }\r
- }\r
-\r
- /**\r
- Standard set method of ANT task/datatype, for List attribute.\r
-\r
- @param fileList string with file pathes separated by space, comma,\r
- or semi-comma\r
- **/\r
- public void setList(String fileList) {\r
- //\r
- // space, comma or semi-comma separated files list\r
- //\r
- Pattern pattern = Pattern.compile("([^ ,;\n\r]++)[ ,;\n\r]*+");\r
- Matcher matcher = pattern.matcher(fileList);\r
-\r
- while (matcher.find()) {\r
- //\r
- // keep each file name before " ,;\n\r"\r
- //\r
- String filePath = fileList.substring(matcher.start(1), matcher.end(1)).trim();\r
- if (filePath.length() == 0) {\r
- continue;\r
- }\r
- nameList.add(Path.translateFile(filePath));\r
- }\r
-\r
- }\r
-\r
- /**\r
- Standard set method of ANT task/datatype, for Name attribute.\r
-\r
- @param fileName string of a file full path\r
- **/\r
- public void setName(String fileName) {\r
- this.nameList.add(fileName);\r
- }\r
-\r
- /**\r
- Fetch the file name list.\r
-\r
- @returns A string list which contains file names specified to check dependnecy\r
- **/\r
- public List<String> getList() {\r
- return this.nameList;\r
- }\r
-}\r
-\r
-\r