More renames for Tool Packages
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1675 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
903
Tools/CodeTools/Source/GenDepex/DepexParser.c
Normal file
903
Tools/CodeTools/Source/GenDepex/DepexParser.c
Normal file
@ -0,0 +1,903 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004, 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.
|
||||
|
||||
Module Name:
|
||||
|
||||
DepexParser.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Validate Dependency Expression syntax
|
||||
recursive descent Algorithm
|
||||
|
||||
The original BNF grammar(taken from "Pre EFI Initialization Core Interface Specification
|
||||
draft review 0.9") is thus:
|
||||
<depex> ::= BEFORE <guid> END
|
||||
| AFTER <guid> END
|
||||
| SOR <bool> END
|
||||
| <bool> END
|
||||
<bool> ::= <bool> AND <term>
|
||||
| <bool> OR <term>
|
||||
| <term>
|
||||
<term> ::= NOT <factor>
|
||||
| <factor>
|
||||
<factor> ::= <bool>
|
||||
| TRUE
|
||||
| FALSE
|
||||
| GUID
|
||||
|
||||
<guid> ::= '{' <hex32> ',' <hex16> ',' <hex16> ','
|
||||
<hex8> ',' <hex8> ',' <hex8> ',' <hex8> ','
|
||||
<hex8> ',' <hex8> ',' <hex8> ',' <hex8> '}'
|
||||
<hex32> ::= <hexprefix> <hexvalue>
|
||||
<hex16> ::= <hexprefix> <hexvalue>
|
||||
<hex8> ::= <hexprefix> <hexvalue>
|
||||
<hexprefix>::= '0' 'x'
|
||||
| '0' 'X'
|
||||
<hexvalue> ::= <hexdigit> <hexvalue>
|
||||
| <hexdigit>
|
||||
<hexdigit> ::= [0-9]
|
||||
| [a-f]
|
||||
| [A-F]
|
||||
|
||||
After cleaning left recursive and parentheses supported, the BNF grammar used in this module is thus:
|
||||
<depex> ::= BEFORE <guid>
|
||||
| AFTER <guid>
|
||||
| SOR <bool>
|
||||
| <bool>
|
||||
<bool> ::= <term><rightbool>
|
||||
<rightbool>::= AND <term><rightbool>
|
||||
| OR <term><rightbool>
|
||||
| ''
|
||||
<term> ::= NOT <factor>
|
||||
| <factor>
|
||||
<factor> ::= '('<bool>')'<rightfactor>
|
||||
| NOT <factor> <rightbool> <rightfactor>
|
||||
| TRUE <rightfactor>
|
||||
| FALSE <rightfactor>
|
||||
| END <rightfactor>
|
||||
| <guid> <rightfactor>
|
||||
<rightfactor> ::=AND <term><rightbool> <rightfactor>
|
||||
| OR <term><rightbool> <rightfactor>
|
||||
| ''
|
||||
<guid> ::= '{' <hex32> ',' <hex16> ',' <hex16> ','
|
||||
<hex8> ',' <hex8> ',' <hex8> ',' <hex8> ','
|
||||
<hex8> ',' <hex8> ',' <hex8> ',' <hex8> '}'
|
||||
<hex32> ::= <hexprefix> <hexvalue>
|
||||
<hex16> ::= <hexprefix> <hexvalue>
|
||||
<hex8> ::= <hexprefix> <hexvalue>
|
||||
<hexprefix>::= '0' 'x'
|
||||
| '0' 'X'
|
||||
<hexvalue> ::= <hexdigit> <hexvalue>
|
||||
| <hexdigit>
|
||||
<hexdigit> ::= [0-9]
|
||||
| [a-f]
|
||||
| [A-F]
|
||||
|
||||
Note: 1. There's no precedence in operators except parentheses;
|
||||
2. For hex32, less and equal than 8 bits is valid, more than 8 bits is invalid.
|
||||
Same constraint for hex16 is 4, hex8 is 2. All hex should contains at least 1 bit.
|
||||
3. "<factor> ::= '('<bool>')'<rightfactor>" is added to support parentheses;
|
||||
4. "<factor> ::= GUID" is changed to "<factor> ::= <guid>";
|
||||
5. "DEPENDENCY_END" is the terminal of the expression. But it has been filtered by caller.
|
||||
During parsing, "DEPENDENCY_END" will be treated as illegal factor;
|
||||
|
||||
This code should build in any environment that supports a standard C-library w/ string
|
||||
operations and File I/O services.
|
||||
|
||||
As an example of usage, consider the following:
|
||||
|
||||
The input string could be something like:
|
||||
|
||||
NOT ({ 0xce345171, 0xba0b, 0x11d2, 0x8e, 0x4f, 0x0, 0xa0, 0xc9, 0x69, 0x72,
|
||||
0x3b } AND { 0x964e5b22, 0x6459, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69,
|
||||
0x72, 0x3b }) OR { 0x03c4e603, 0xac28, 0x11d3, 0x9a, 0x2d, 0x00, 0x90, 0x27,
|
||||
0x3f, 0xc1, 0x4d } AND
|
||||
|
||||
It's invalid for an extra "AND" in the end.
|
||||
|
||||
Complies with Tiano C Coding Standards Document, version 0.33, 16 Aug 2001.
|
||||
|
||||
--*/
|
||||
|
||||
#include "DepexParser.h"
|
||||
|
||||
BOOLEAN
|
||||
ParseBool (
|
||||
IN INT8 *Pbegin,
|
||||
IN UINT32 length,
|
||||
IN OUT INT8 **Pindex
|
||||
);
|
||||
|
||||
BOOLEAN
|
||||
ParseTerm (
|
||||
IN INT8 *Pbegin,
|
||||
IN UINT32 length,
|
||||
IN OUT INT8 **Pindex
|
||||
);
|
||||
|
||||
BOOLEAN
|
||||
ParseRightBool (
|
||||
IN INT8 *Pbegin,
|
||||
IN UINT32 length,
|
||||
IN OUT INT8 **Pindex
|
||||
);
|
||||
|
||||
BOOLEAN
|
||||
ParseFactor (
|
||||
IN INT8 *Pbegin,
|
||||
IN UINT32 length,
|
||||
IN OUT INT8 **Pindex
|
||||
);
|
||||
|
||||
VOID
|
||||
LeftTrim (
|
||||
IN INT8 *Pbegin,
|
||||
IN UINT32 length,
|
||||
IN OUT INT8 **Pindex
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Left trim the space, '\n' and '\r' character in string.
|
||||
The space at the end does not need trim.
|
||||
|
||||
|
||||
Arguments:
|
||||
|
||||
Pbegin The pointer to the string
|
||||
length length of the string
|
||||
Pindex The pointer of pointer to the next parse character in the string
|
||||
|
||||
Returns:
|
||||
|
||||
None
|
||||
|
||||
|
||||
--*/
|
||||
{
|
||||
while
|
||||
(
|
||||
((*Pindex) < (Pbegin + length)) &&
|
||||
((strncmp (*Pindex, " ", 1) == 0) || (strncmp (*Pindex, "\n", 1) == 0) || (strncmp (*Pindex, "\r", 1) == 0))
|
||||
) {
|
||||
(*Pindex)++;
|
||||
}
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
ParseHexdigit (
|
||||
IN INT8 *Pbegin,
|
||||
IN UINT32 length,
|
||||
IN OUT INT8 **Pindex
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Parse Hex bit in dependency expression.
|
||||
|
||||
Arguments:
|
||||
|
||||
Pbegin The pointer to the string
|
||||
length Length of the string
|
||||
Pindex The pointer of pointer to the next parse character in the string
|
||||
|
||||
Returns:
|
||||
|
||||
BOOLEAN If parses a valid hex bit, return TRUE, otherwise FALSE
|
||||
|
||||
|
||||
--*/
|
||||
{
|
||||
//
|
||||
// <hexdigit> ::= [0-9] | [a-f] | [A-F]
|
||||
//
|
||||
if (((**Pindex) >= '0' && (**Pindex) <= '9') ||
|
||||
((**Pindex) >= 'a' && (**Pindex) <= 'f') ||
|
||||
((**Pindex) >= 'A' && (**Pindex) <= 'F')
|
||||
) {
|
||||
(*Pindex)++;
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
ParseHex32 (
|
||||
IN INT8 *Pbegin,
|
||||
IN UINT32 length,
|
||||
IN OUT INT8 **Pindex
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Parse Hex32 in dependency expression.
|
||||
|
||||
Arguments:
|
||||
|
||||
Pbegin The pointer to the string
|
||||
length Length of the string
|
||||
Pindex The pointer of point to the next parse character in the string
|
||||
|
||||
Returns:
|
||||
|
||||
BOOLEAN If parses a valid hex32, return TRUE, otherwise FALSE
|
||||
|
||||
|
||||
--*/
|
||||
{
|
||||
INT32 Index;
|
||||
INT8 *Pin;
|
||||
|
||||
Index = 0;
|
||||
Pin = *Pindex;
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
|
||||
if ((strncmp (*Pindex, "0x", 2) != 0) && (strncmp (*Pindex, "0X", 2) != 0)) {
|
||||
return FALSE;
|
||||
}
|
||||
(*Pindex) += 2;
|
||||
|
||||
while (ParseHexdigit (Pbegin, length, Pindex)) {
|
||||
Index++;
|
||||
}
|
||||
|
||||
if (Index > 0 && Index <= 8) {
|
||||
return TRUE;
|
||||
} else {
|
||||
*Pindex = Pin;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
ParseHex16 (
|
||||
IN INT8 *Pbegin,
|
||||
IN UINT32 length,
|
||||
IN OUT INT8 **Pindex
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Parse Hex16 in dependency expression.
|
||||
|
||||
Arguments:
|
||||
|
||||
Pbegin The pointer to the string
|
||||
length Length of the string
|
||||
Pindex The pointer of pointer to the next parse character in the string
|
||||
|
||||
Returns:
|
||||
|
||||
BOOLEAN If parses a valid hex16, return TRUE, otherwise FALSE
|
||||
|
||||
|
||||
--*/
|
||||
{
|
||||
int Index;
|
||||
INT8 *Pin;
|
||||
|
||||
Index = 0;
|
||||
Pin = *Pindex;
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
|
||||
if ((strncmp (*Pindex, "0x", 2) != 0) && (strncmp (*Pindex, "0X", 2) != 0)) {
|
||||
return FALSE;
|
||||
}
|
||||
(*Pindex) += 2;
|
||||
|
||||
while (ParseHexdigit (Pbegin, length, Pindex)) {
|
||||
Index++;
|
||||
}
|
||||
|
||||
if (Index > 0 && Index <= 4) {
|
||||
return TRUE;
|
||||
} else {
|
||||
*Pindex = Pin;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
ParseHex8 (
|
||||
IN INT8 *Pbegin,
|
||||
IN UINT32 length,
|
||||
IN OUT INT8 **Pindex
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Parse Hex8 in dependency expression.
|
||||
|
||||
Arguments:
|
||||
|
||||
Pbegin The pointer to the string
|
||||
length Length of the string
|
||||
Pindex The pointer of pointer to the next parse character in the string
|
||||
|
||||
Returns:
|
||||
|
||||
BOOLEAN If parses a valid hex8, return TRUE, otherwise FALSE
|
||||
|
||||
|
||||
--*/
|
||||
{
|
||||
int Index;
|
||||
INT8 *Pin;
|
||||
|
||||
Index = 0;
|
||||
Pin = *Pindex;
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
|
||||
if ((strncmp (*Pindex, "0x", 2) != 0) && (strncmp (*Pindex, "0X", 2) != 0)) {
|
||||
return FALSE;
|
||||
}
|
||||
(*Pindex) += 2;
|
||||
|
||||
while (ParseHexdigit (Pbegin, length, Pindex)) {
|
||||
Index++;
|
||||
}
|
||||
|
||||
if (Index > 0 && Index <= 2) {
|
||||
return TRUE;
|
||||
} else {
|
||||
*Pindex = Pin;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
ParseGuid (
|
||||
IN INT8 *Pbegin,
|
||||
IN UINT32 length,
|
||||
IN OUT INT8 **Pindex
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Parse guid in dependency expression.
|
||||
There can be any number of spaces between '{' and hexword, ',' and hexword,
|
||||
hexword and ',', hexword and '}'. The hexword include hex32, hex16 and hex8.
|
||||
|
||||
Arguments:
|
||||
|
||||
Pbegin The pointer to the string
|
||||
length length of the string
|
||||
Pindex The pointer of pointer to the next parse character in the string
|
||||
|
||||
Returns:
|
||||
|
||||
BOOLEAN If parses a valid guid, return TRUE, otherwise FALSE
|
||||
|
||||
|
||||
--*/
|
||||
{
|
||||
INT32 Index;
|
||||
INT8 *Pin;
|
||||
Pin = *Pindex;
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
if (strncmp (*Pindex, "{", 1) != 0) {
|
||||
return FALSE;
|
||||
}
|
||||
(*Pindex)++;
|
||||
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
if (!ParseHex32 (Pbegin, length, Pindex)) {
|
||||
*Pindex = Pin;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
if (strncmp (*Pindex, ",", 1) != 0) {
|
||||
return FALSE;
|
||||
} else {
|
||||
(*Pindex)++;
|
||||
}
|
||||
|
||||
for (Index = 0; Index < 2; Index++) {
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
if (!ParseHex16 (Pbegin, length, Pindex)) {
|
||||
*Pindex = Pin;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
if (strncmp (*Pindex, ",", 1) != 0) {
|
||||
return FALSE;
|
||||
} else {
|
||||
(*Pindex)++;
|
||||
}
|
||||
}
|
||||
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
if (strncmp (*Pindex, "{", 1) != 0) {
|
||||
return FALSE;
|
||||
}
|
||||
(*Pindex)++;
|
||||
|
||||
for (Index = 0; Index < 7; Index++) {
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
if (!ParseHex8 (Pbegin, length, Pindex)) {
|
||||
*Pindex = Pin;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
if (strncmp (*Pindex, ",", 1) != 0) {
|
||||
return FALSE;
|
||||
} else {
|
||||
(*Pindex)++;
|
||||
}
|
||||
}
|
||||
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
if (!ParseHex8 (Pbegin, length, Pindex)) {
|
||||
*Pindex = Pin;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
if (strncmp (*Pindex, "}", 1) != 0) {
|
||||
return FALSE;
|
||||
} else {
|
||||
(*Pindex)++;
|
||||
}
|
||||
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
if (strncmp (*Pindex, "}", 1) != 0) {
|
||||
return FALSE;
|
||||
} else {
|
||||
(*Pindex)++;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
ParseRightFactor (
|
||||
IN INT8 *Pbegin,
|
||||
IN UINT32 length,
|
||||
IN OUT INT8 **Pindex
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Parse rightfactor in bool expression.
|
||||
|
||||
Arguments:
|
||||
|
||||
Pbegin The pointer to the string
|
||||
length length of the string
|
||||
Pindex The pointer of pointer to the next parse character in the string
|
||||
|
||||
Returns:
|
||||
|
||||
BOOLEAN If string is a valid rightfactor expression, return TRUE, otherwise FALSE
|
||||
|
||||
|
||||
--*/
|
||||
{
|
||||
INT8 *Pin;
|
||||
|
||||
Pin = *Pindex;
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
|
||||
//
|
||||
// <rightfactor> ::=AND <term> <rightbool> <rightfactor>
|
||||
//
|
||||
if (strncmp (*Pindex, OPERATOR_AND, strlen (OPERATOR_AND)) == 0) {
|
||||
*Pindex += strlen (OPERATOR_AND);
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
|
||||
if (ParseTerm (Pbegin, length, Pindex)) {
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
|
||||
if (ParseRightBool (Pbegin, length, Pindex)) {
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
if (ParseRightFactor (Pbegin, length, Pindex)) {
|
||||
return TRUE;
|
||||
} else {
|
||||
*Pindex = Pin;
|
||||
}
|
||||
} else {
|
||||
*Pindex = Pin;
|
||||
}
|
||||
} else {
|
||||
*Pindex = Pin;
|
||||
}
|
||||
}
|
||||
//
|
||||
// <rightfactor> ::=OR <term> <rightbool> <rightfactor>
|
||||
//
|
||||
if (strncmp (*Pindex, OPERATOR_OR, strlen (OPERATOR_OR)) == 0) {
|
||||
*Pindex += strlen (OPERATOR_OR);
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
|
||||
if (ParseTerm (Pbegin, length, Pindex)) {
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
|
||||
if (ParseRightBool (Pbegin, length, Pindex)) {
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
if (ParseRightFactor (Pbegin, length, Pindex)) {
|
||||
return TRUE;
|
||||
} else {
|
||||
*Pindex = Pin;
|
||||
}
|
||||
} else {
|
||||
*Pindex = Pin;
|
||||
}
|
||||
} else {
|
||||
*Pindex = Pin;
|
||||
}
|
||||
}
|
||||
//
|
||||
// <rightfactor> ::= ''
|
||||
//
|
||||
*Pindex = Pin;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
ParseRightBool (
|
||||
IN INT8 *Pbegin,
|
||||
IN UINT32 length,
|
||||
IN OUT INT8 **Pindex
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Parse rightbool in bool expression.
|
||||
|
||||
Arguments:
|
||||
|
||||
Pbegin The pointer to the string
|
||||
length length of the string
|
||||
Pindex The pointer of pointer to the next parse character in the string
|
||||
|
||||
Returns:
|
||||
|
||||
BOOLEAN If string is a valid rightbool expression, return TRUE, otherwise FALSE
|
||||
|
||||
|
||||
--*/
|
||||
{
|
||||
INT8 *Pin;
|
||||
|
||||
Pin = *Pindex;
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
|
||||
//
|
||||
// <rightbool>::= AND <term><rightbool>
|
||||
//
|
||||
if (strncmp (*Pindex, OPERATOR_AND, strlen (OPERATOR_AND)) == 0) {
|
||||
*Pindex += strlen (OPERATOR_AND);
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
|
||||
if (ParseTerm (Pbegin, length, Pindex)) {
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
|
||||
if (ParseRightBool (Pbegin, length, Pindex)) {
|
||||
return TRUE;
|
||||
} else {
|
||||
*Pindex = Pin;
|
||||
}
|
||||
} else {
|
||||
*Pindex = Pin;
|
||||
}
|
||||
}
|
||||
//
|
||||
// <rightbool>::= OR <term><rightbool>
|
||||
//
|
||||
if (strncmp (*Pindex, OPERATOR_OR, strlen (OPERATOR_OR)) == 0) {
|
||||
*Pindex += strlen (OPERATOR_OR);
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
|
||||
if (ParseTerm (Pbegin, length, Pindex)) {
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
|
||||
if (ParseRightBool (Pbegin, length, Pindex)) {
|
||||
return TRUE;
|
||||
} else {
|
||||
*Pindex = Pin;
|
||||
}
|
||||
} else {
|
||||
*Pindex = Pin;
|
||||
}
|
||||
}
|
||||
//
|
||||
// <rightbool>::= ''
|
||||
//
|
||||
*Pindex = Pin;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
ParseFactor (
|
||||
IN INT8 *Pbegin,
|
||||
IN UINT32 length,
|
||||
IN OUT INT8 **Pindex
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Parse factor in bool expression.
|
||||
|
||||
Arguments:
|
||||
|
||||
Pbegin The pointer to the string
|
||||
length length of the string
|
||||
Pindex The pointer of pointer to the next parse character in the string
|
||||
|
||||
Returns:
|
||||
|
||||
BOOLEAN If string is a valid factor, return TRUE, otherwise FALSE
|
||||
|
||||
|
||||
--*/
|
||||
{
|
||||
INT8 *Pin;
|
||||
|
||||
Pin = *Pindex;
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
|
||||
//
|
||||
// <factor> ::= '('<bool>')'<rightfactor>
|
||||
//
|
||||
if (strncmp (*Pindex, OPERATOR_LEFT_PARENTHESIS, strlen (OPERATOR_LEFT_PARENTHESIS)) == 0) {
|
||||
*Pindex += strlen (OPERATOR_LEFT_PARENTHESIS);
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
|
||||
if (!ParseBool (Pbegin, length, Pindex)) {
|
||||
*Pindex = Pin;
|
||||
} else {
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
|
||||
if (strncmp (*Pindex, OPERATOR_RIGHT_PARENTHESIS, strlen (OPERATOR_RIGHT_PARENTHESIS)) == 0) {
|
||||
*Pindex += strlen (OPERATOR_RIGHT_PARENTHESIS);
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
|
||||
if (ParseRightFactor (Pbegin, length, Pindex)) {
|
||||
return TRUE;
|
||||
} else {
|
||||
*Pindex = Pin;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
// <factor> ::= NOT <factor> <rightbool> <rightfactor>
|
||||
//
|
||||
if (strncmp (*Pindex, OPERATOR_NOT, strlen (OPERATOR_NOT)) == 0) {
|
||||
*Pindex += strlen (OPERATOR_NOT);
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
|
||||
if (ParseFactor (Pbegin, length, Pindex)) {
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
|
||||
if (ParseRightBool (Pbegin, length, Pindex)) {
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
|
||||
if (ParseRightFactor (Pbegin, length, Pindex)) {
|
||||
return TRUE;
|
||||
} else {
|
||||
*Pindex = Pin;
|
||||
}
|
||||
} else {
|
||||
*Pindex = Pin;
|
||||
}
|
||||
} else {
|
||||
*Pindex = Pin;
|
||||
}
|
||||
}
|
||||
//
|
||||
// <factor> ::= TRUE <rightfactor>
|
||||
//
|
||||
if (strncmp (*Pindex, OPERATOR_TRUE, strlen (OPERATOR_TRUE)) == 0) {
|
||||
*Pindex += strlen (OPERATOR_TRUE);
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
|
||||
if (ParseRightFactor (Pbegin, length, Pindex)) {
|
||||
return TRUE;
|
||||
} else {
|
||||
*Pindex = Pin;
|
||||
}
|
||||
}
|
||||
//
|
||||
// <factor> ::= FALSE <rightfactor>
|
||||
//
|
||||
if (strncmp (*Pindex, OPERATOR_FALSE, strlen (OPERATOR_FALSE)) == 0) {
|
||||
*Pindex += strlen (OPERATOR_FALSE);
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
|
||||
if (ParseRightFactor (Pbegin, length, Pindex)) {
|
||||
return TRUE;
|
||||
} else {
|
||||
*Pindex = Pin;
|
||||
}
|
||||
}
|
||||
//
|
||||
// <factor> ::= <guid> <rightfactor>
|
||||
//
|
||||
if (ParseGuid (Pbegin, length, Pindex)) {
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
|
||||
if (ParseRightFactor (Pbegin, length, Pindex)) {
|
||||
return TRUE;
|
||||
} else {
|
||||
*Pindex = Pin;
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
*Pindex = Pin;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
ParseTerm (
|
||||
IN INT8 *Pbegin,
|
||||
IN UINT32 length,
|
||||
IN OUT INT8 **Pindex
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Parse term in bool expression.
|
||||
|
||||
Arguments:
|
||||
|
||||
Pbegin The pointer to the string
|
||||
length length of the string
|
||||
Pindex The pointer of pointer to the next parse character in the string
|
||||
|
||||
Returns:
|
||||
|
||||
BOOLEAN If string is a valid term, return TRUE, otherwise FALSE
|
||||
|
||||
|
||||
--*/
|
||||
{
|
||||
INT8 *Pin;
|
||||
|
||||
Pin = *Pindex;
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
|
||||
//
|
||||
// <term> ::= NOT <factor>
|
||||
//
|
||||
if (strncmp (*Pindex, OPERATOR_NOT, strlen (OPERATOR_NOT)) == 0) {
|
||||
*Pindex += strlen (OPERATOR_NOT);
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
|
||||
if (!ParseFactor (Pbegin, length, Pindex)) {
|
||||
*Pindex = Pin;
|
||||
} else {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
//
|
||||
// <term> ::=<factor>
|
||||
//
|
||||
if (ParseFactor (Pbegin, length, Pindex)) {
|
||||
return TRUE;
|
||||
} else {
|
||||
*Pindex = Pin;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
ParseBool (
|
||||
IN INT8 *Pbegin,
|
||||
IN UINT32 length,
|
||||
IN OUT INT8 **Pindex
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Parse bool expression.
|
||||
|
||||
Arguments:
|
||||
|
||||
Pbegin The pointer to the string
|
||||
length length of the string
|
||||
Pindex The pointer of pointer to the next parse character in the string
|
||||
|
||||
Returns:
|
||||
|
||||
BOOLEAN If string is a valid bool expression, return TRUE, otherwise FALSE
|
||||
|
||||
|
||||
--*/
|
||||
{
|
||||
INT8 *Pin;
|
||||
Pin = *Pindex;
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
|
||||
if (ParseTerm (Pbegin, length, Pindex)) {
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
|
||||
if (!ParseRightBool (Pbegin, length, Pindex)) {
|
||||
*Pindex = Pin;
|
||||
return FALSE;
|
||||
} else {
|
||||
return TRUE;
|
||||
}
|
||||
} else {
|
||||
*Pindex = Pin;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
ParseDepex (
|
||||
IN INT8 *Pbegin,
|
||||
IN UINT32 length
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Parse whole dependency expression.
|
||||
|
||||
Arguments:
|
||||
|
||||
Pbegin The pointer to the string
|
||||
length length of the string
|
||||
|
||||
Returns:
|
||||
|
||||
BOOLEAN If string is a valid dependency expression, return TRUE, otherwise FALSE
|
||||
|
||||
|
||||
--*/
|
||||
{
|
||||
BOOLEAN Result;
|
||||
INT8 **Pindex;
|
||||
INT8 *temp;
|
||||
|
||||
Result = FALSE;
|
||||
temp = Pbegin;
|
||||
Pindex = &temp;
|
||||
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
if (strncmp (*Pindex, OPERATOR_BEFORE, strlen (OPERATOR_BEFORE)) == 0) {
|
||||
(*Pindex) += strlen (OPERATOR_BEFORE);
|
||||
Result = ParseGuid (Pbegin, length, Pindex);
|
||||
|
||||
} else if (strncmp (*Pindex, OPERATOR_AFTER, strlen (OPERATOR_AFTER)) == 0) {
|
||||
(*Pindex) += strlen (OPERATOR_AFTER);
|
||||
Result = ParseGuid (Pbegin, length, Pindex);
|
||||
|
||||
} else if (strncmp (*Pindex, OPERATOR_SOR, strlen (OPERATOR_SOR)) == 0) {
|
||||
(*Pindex) += strlen (OPERATOR_SOR);
|
||||
Result = ParseBool (Pbegin, length, Pindex);
|
||||
|
||||
} else {
|
||||
Result = ParseBool (Pbegin, length, Pindex);
|
||||
|
||||
}
|
||||
|
||||
LeftTrim (Pbegin, length, Pindex);
|
||||
return (BOOLEAN) (Result && (*Pindex) >= (Pbegin + length));
|
||||
}
|
26
Tools/CodeTools/Source/GenDepex/DepexParser.h
Normal file
26
Tools/CodeTools/Source/GenDepex/DepexParser.h
Normal file
@ -0,0 +1,26 @@
|
||||
/*++
|
||||
Copyright (c) 2004, 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.
|
||||
|
||||
Module Name:
|
||||
GenDepex.h
|
||||
|
||||
Abstract:
|
||||
This file contains the relevant declarations required
|
||||
to generate a binary Dependency File
|
||||
|
||||
Complies with Tiano C Coding Standards Document, version 0.31, 12 Dec 2000.
|
||||
|
||||
--*/
|
||||
|
||||
// TODO: fix comment to set correct module name: DepexParser.h
|
||||
#ifndef _EFI_DEPEX_PARSER_H_
|
||||
#define _EFI_DEPEX_PARSER_H_
|
||||
#include "GenDepex.h"
|
||||
#endif
|
919
Tools/CodeTools/Source/GenDepex/GenDepex.c
Normal file
919
Tools/CodeTools/Source/GenDepex/GenDepex.c
Normal file
@ -0,0 +1,919 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004, 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.
|
||||
|
||||
Module Name:
|
||||
|
||||
GenDepex.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Generate Dependency Expression ("GenDepex")
|
||||
|
||||
Infix to Postfix Algorithm
|
||||
|
||||
This code has been scrubbed to be free of having any EFI core tree dependencies.
|
||||
It should build in any environment that supports a standard C-library w/ string
|
||||
operations and File I/O services.
|
||||
|
||||
As an example of usage, consider the following:
|
||||
|
||||
The input user file could be something like "Sample.DXS" whose contents are
|
||||
|
||||
#include "Tiano.h"
|
||||
|
||||
DEPENDENCY_START
|
||||
NOT (DISK_IO_PROTOCOL AND SIMPLE_FILE_SYSTEM_PROTOCOL)
|
||||
OR EFI_PXE_BASE_CODE_PROTOCOL
|
||||
DEPENDENCY_END
|
||||
|
||||
This file is then washed through the C-preprocessor, viz.,
|
||||
|
||||
cl /EP Sample.DXS > Sample.TMP1
|
||||
|
||||
This yields the following file "Sample.TMP1" whose contents are
|
||||
|
||||
DEPENDENCY_START
|
||||
NOT ({ 0xce345171, 0xba0b, 0x11d2, 0x8e, 0x4f, 0x0, 0xa0, 0xc9, 0x69, 0x72,
|
||||
0x3b } AND { 0x964e5b22, 0x6459, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69,
|
||||
0x72, 0x3b }) OR { 0x03c4e603, 0xac28, 0x11d3, 0x9a, 0x2d, 0x00, 0x90, 0x27,
|
||||
0x3f, 0xc1, 0x4d }
|
||||
DEPENDENCY_END
|
||||
|
||||
This file, in turn, will be fed into the utility, viz.,
|
||||
|
||||
GenDepex Sample.TMP1 Sample.TMP2
|
||||
|
||||
With a file that is 55 bytes long:
|
||||
|
||||
55 bytes for the grammar binary
|
||||
PUSH opcode - 1 byte
|
||||
GUID Instance - 16 bytes
|
||||
PUSH opcode - 1 byte
|
||||
GUID Instance - 16 bytes
|
||||
AND opcode - 1 byte
|
||||
NOT opcode - 1 byte
|
||||
PUSH opcode - 1 byte
|
||||
GUID Instance - 16 bytes
|
||||
OR opcode - 1 byte
|
||||
END opcode - 1 byte
|
||||
|
||||
The file "Sample.TMP2" could be fed via a Section-builder utility
|
||||
(GenSection) that would be used for the creation of a dependency
|
||||
section file (.DPX) which in turn would be used by a generate FFS
|
||||
utility (GenFfsFile) to produce a DXE driver/core (.DXE) or
|
||||
a DXE application (.APP) file.
|
||||
|
||||
Complies with Tiano C Coding Standards Document, version 0.31, 12 Dec 2000.
|
||||
|
||||
--*/
|
||||
|
||||
#include "GenDepex.h"
|
||||
|
||||
#define TOOL_NAME "GenDepex"
|
||||
|
||||
extern
|
||||
ParseDepex (
|
||||
IN INT8 *Pbegin,
|
||||
IN UINT32 length
|
||||
);
|
||||
|
||||
VOID
|
||||
PrintGenDepexUtilityInfo (
|
||||
VOID
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Displays the standard utility information to SDTOUT.
|
||||
|
||||
Arguments:
|
||||
|
||||
None
|
||||
|
||||
Returns:
|
||||
|
||||
None
|
||||
|
||||
--*/
|
||||
{
|
||||
printf (
|
||||
"%s, Tiano Dependency Expression Generation Utility. Version %d.%d.\n",
|
||||
UTILITY_NAME,
|
||||
UTILITY_MAJOR_VERSION,
|
||||
UTILITY_MINOR_VERSION
|
||||
);
|
||||
printf ("Copyright (C) 1996-2002 Intel Corporation. All rights reserved.\n\n");
|
||||
}
|
||||
|
||||
VOID
|
||||
PrintGenDepexUsageInfo (
|
||||
VOID
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Displays the utility usage syntax to STDOUT.
|
||||
|
||||
Arguments:
|
||||
|
||||
None
|
||||
|
||||
Returns:
|
||||
|
||||
None
|
||||
|
||||
--*/
|
||||
{
|
||||
printf (
|
||||
"Usage: %s -I <INFILE> -O <OUTFILE> [-P <Optional Boundary for padding up>] \n",
|
||||
UTILITY_NAME
|
||||
);
|
||||
printf (" Where:\n");
|
||||
printf (" <INFILE> is the input pre-processed dependency text files name.\n");
|
||||
printf (" <OUTFILE> is the output binary dependency files name.\n");
|
||||
printf (" <Optional Boundary for padding up> is the padding integer value.\n");
|
||||
printf (" This is the boundary to align the output file size to.\n");
|
||||
}
|
||||
|
||||
DEPENDENCY_OPCODE
|
||||
PopOpCode (
|
||||
IN OUT VOID **Stack
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Pop an element from the Opcode stack.
|
||||
|
||||
Arguments:
|
||||
|
||||
Stack Current top of the OpCode stack location
|
||||
|
||||
Returns:
|
||||
|
||||
DEPENDENCY_OPCODE OpCode at the top of the OpCode stack.
|
||||
Stack New top of the OpCode stack location
|
||||
|
||||
|
||||
--*/
|
||||
{
|
||||
DEPENDENCY_OPCODE *OpCodePtr;
|
||||
|
||||
OpCodePtr = *Stack;
|
||||
OpCodePtr--;
|
||||
*Stack = OpCodePtr;
|
||||
return *OpCodePtr;
|
||||
}
|
||||
|
||||
VOID
|
||||
PushOpCode (
|
||||
IN OUT VOID **Stack,
|
||||
IN DEPENDENCY_OPCODE OpCode
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Push an element onto the Opcode Stack
|
||||
|
||||
Arguments:
|
||||
|
||||
Stack Current top of the OpCode stack location
|
||||
OpCode OpCode to push onto the stack
|
||||
|
||||
Returns:
|
||||
|
||||
Stack New top of the OpCode stack location
|
||||
|
||||
--*/
|
||||
{
|
||||
DEPENDENCY_OPCODE *OpCodePtr;
|
||||
|
||||
OpCodePtr = *Stack;
|
||||
*OpCodePtr = OpCode;
|
||||
OpCodePtr++;
|
||||
*Stack = OpCodePtr;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
GenerateDependencyExpression (
|
||||
IN FILE *InFile,
|
||||
IN OUT FILE *OutFile,
|
||||
IN INT8 Padding OPTIONAL
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
This takes the pre-compiled dependency text file and
|
||||
converts it into a binary dependency file.
|
||||
|
||||
The BNF for the dependency expression is as follows
|
||||
(from the DXE 1.0 Draft specification).
|
||||
|
||||
The inputted BNF grammar is thus:
|
||||
<depex> ::= sor <dep> |
|
||||
before GUID <dep> |
|
||||
after GUID <dep> |
|
||||
<bool>
|
||||
|
||||
<dep> ::= <bool> |
|
||||
|
||||
<bool> ::= <bool> and <term> |
|
||||
<bool> or <term> |
|
||||
<term>
|
||||
|
||||
<term> ::= not <factor> |
|
||||
<factor>
|
||||
|
||||
<factor> ::= ( <bool> ) |
|
||||
<term> <term> |
|
||||
GUID |
|
||||
<boolval>
|
||||
|
||||
<boolval> ::= true |
|
||||
false
|
||||
|
||||
The outputed binary grammer is thus:
|
||||
<depex> ::= sor <dep> |
|
||||
before <depinst> <dep> |
|
||||
after <depinst> <dep> |
|
||||
<bool>
|
||||
|
||||
<dep> ::= <bool> |
|
||||
|
||||
<bool> ::= <bool> and <term> |
|
||||
<bool> or <term> | <term>
|
||||
|
||||
<term> ::= not <factor> |
|
||||
<factor>
|
||||
|
||||
<factor> ::= ( <bool> ) |
|
||||
<term> <term> |
|
||||
<boolval> |
|
||||
<depinst> |
|
||||
<termval>
|
||||
|
||||
<boolval> ::= true |
|
||||
false
|
||||
|
||||
<depinst> ::= push GUID
|
||||
|
||||
<termval> ::= end
|
||||
|
||||
BugBug: A correct grammer is parsed correctly. A file that violates the
|
||||
grammer may parse when it should generate an error. There is some
|
||||
error checking and it covers most of the case when it's an include
|
||||
of definition issue. An ill formed expresion may not be detected.
|
||||
|
||||
Arguments:
|
||||
|
||||
InFile - Input pre-compiled text file of the dependency expression.
|
||||
This needs to be in ASCII.
|
||||
The file pointer can not be NULL.
|
||||
|
||||
OutFile - Binary dependency file.
|
||||
The file pointer can not be NULL.
|
||||
|
||||
Padding - OPTIONAL integer value to pad the output file to.
|
||||
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS The function completed successfully.
|
||||
EFI_INVALID_PARAMETER One of the parameters in the text file was invalid.
|
||||
EFI_OUT_OF_RESOURCES Unable to allocate memory.
|
||||
EFI_ABORTED An misc error occurred.
|
||||
|
||||
--*/
|
||||
{
|
||||
INT8 *Ptrx;
|
||||
INT8 *Pend;
|
||||
INT8 *EvaluationStack;
|
||||
INT8 *StackPtr;
|
||||
INT8 *Buffer;
|
||||
INT8 Line[LINESIZE];
|
||||
UINTN Index;
|
||||
UINTN OutFileSize;
|
||||
UINTN FileSize;
|
||||
UINTN Results;
|
||||
BOOLEAN NotDone;
|
||||
BOOLEAN Before_Flag;
|
||||
BOOLEAN After_Flag;
|
||||
BOOLEAN Dep_Flag;
|
||||
BOOLEAN SOR_Flag;
|
||||
EFI_GUID Guid;
|
||||
UINTN ArgCountParsed;
|
||||
DEPENDENCY_OPCODE Opcode;
|
||||
|
||||
Before_Flag = FALSE;
|
||||
After_Flag = FALSE;
|
||||
Dep_Flag = FALSE;
|
||||
SOR_Flag = FALSE;
|
||||
|
||||
memset (Line, 0, LINESIZE);
|
||||
|
||||
OutFileSize = 0;
|
||||
|
||||
EvaluationStack = (INT8 *) malloc (EVAL_STACK_SIZE);
|
||||
|
||||
if (EvaluationStack != NULL) {
|
||||
StackPtr = EvaluationStack;
|
||||
} else {
|
||||
printf ("Unable to allocate memory to EvaluationStack - Out of resources\n");
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Results = (UINTN) fseek (InFile, 0, SEEK_END);
|
||||
|
||||
if (Results != 0) {
|
||||
printf ("FSEEK failed - Aborted\n");
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
|
||||
FileSize = ftell (InFile);
|
||||
|
||||
if (FileSize == -1L) {
|
||||
printf ("FTELL failed - Aborted\n");
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
|
||||
Buffer = (INT8 *) malloc (FileSize + BUFFER_SIZE);
|
||||
|
||||
if (Buffer == NULL) {
|
||||
printf ("Unable to allocate memory to Buffer - Out of resources\n");
|
||||
free (EvaluationStack);
|
||||
|
||||
Results = (UINTN) fclose (InFile);
|
||||
if (Results != 0) {
|
||||
printf ("FCLOSE failed\n");
|
||||
}
|
||||
|
||||
Results = (UINTN) fclose (OutFile);
|
||||
if (Results != 0) {
|
||||
printf ("FCLOSE failed\n");
|
||||
}
|
||||
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Results = (UINTN) fseek (InFile, 0, SEEK_SET);
|
||||
|
||||
if (Results != 0) {
|
||||
printf ("FSEEK failed - Aborted\n");
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
|
||||
memset (Buffer, 0, FileSize + BUFFER_SIZE);
|
||||
fread (Buffer, FileSize, 1, InFile);
|
||||
|
||||
Ptrx = Buffer;
|
||||
Pend = Ptrx + FileSize - strlen (DEPENDENCY_END);
|
||||
Index = FileSize;
|
||||
|
||||
NotDone = TRUE;
|
||||
while ((Index--) && NotDone) {
|
||||
|
||||
if (strncmp (Pend, DEPENDENCY_END, strlen (DEPENDENCY_END)) == 0) {
|
||||
NotDone = FALSE;
|
||||
} else {
|
||||
Pend--;
|
||||
}
|
||||
}
|
||||
|
||||
if (NotDone) {
|
||||
printf ("Couldn't find end string %s\n", DEPENDENCY_END);
|
||||
|
||||
Results = (UINTN) fclose (InFile);
|
||||
if (Results != 0) {
|
||||
printf ("FCLOSE failed\n");
|
||||
}
|
||||
|
||||
Results = (UINTN) fclose (OutFile);
|
||||
if (Results != 0) {
|
||||
printf ("FCLOSE failed\n");
|
||||
}
|
||||
|
||||
free (Buffer);
|
||||
free (EvaluationStack);
|
||||
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Index = FileSize;
|
||||
|
||||
NotDone = TRUE;
|
||||
while ((Index--) && NotDone) {
|
||||
|
||||
if (strncmp (Ptrx, DEPENDENCY_START, strlen (DEPENDENCY_START)) == 0) {
|
||||
Ptrx += sizeof (DEPENDENCY_START);
|
||||
NotDone = FALSE;
|
||||
//
|
||||
// BUGBUG -- should Index be decremented by sizeof(DEPENDENCY_START)?
|
||||
//
|
||||
} else {
|
||||
Ptrx++;
|
||||
}
|
||||
}
|
||||
|
||||
if (NotDone) {
|
||||
printf ("Couldn't find start string %s\n", DEPENDENCY_START);
|
||||
|
||||
Results = (UINTN) fclose (InFile);
|
||||
if (Results != 0) {
|
||||
printf ("FCLOSE failed\n");
|
||||
}
|
||||
|
||||
Results = (UINTN) fclose (OutFile);
|
||||
if (Results != 0) {
|
||||
printf ("FCLOSE failed\n");
|
||||
}
|
||||
|
||||
free (Buffer);
|
||||
free (EvaluationStack);
|
||||
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
//
|
||||
// validate the syntax of expression
|
||||
//
|
||||
if (!ParseDepex (Ptrx, Pend - Ptrx - 1)) {
|
||||
printf ("The syntax of expression is wrong\n");
|
||||
|
||||
Results = (UINTN) fclose (InFile);
|
||||
if (Results != 0) {
|
||||
printf ("FCLOSE failed\n");
|
||||
}
|
||||
|
||||
Results = (UINTN) fclose (OutFile);
|
||||
if (Results != 0) {
|
||||
printf ("FCLOSE failed\n");
|
||||
}
|
||||
|
||||
free (Buffer);
|
||||
free (EvaluationStack);
|
||||
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
NotDone = TRUE;
|
||||
|
||||
while ((Index--) && NotDone) {
|
||||
|
||||
if (*Ptrx == ' ') {
|
||||
Ptrx++;
|
||||
} else if (*Ptrx == '\n' || *Ptrx == '\r') {
|
||||
Ptrx++;
|
||||
} else if (strncmp (Ptrx, OPERATOR_SOR, strlen (OPERATOR_SOR)) == 0) {
|
||||
//
|
||||
// Checks for some invalid dependencies
|
||||
//
|
||||
if (Before_Flag) {
|
||||
|
||||
printf ("A BEFORE operator was detected.\n");
|
||||
printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
||||
} else if (After_Flag) {
|
||||
|
||||
printf ("An AFTER operator was detected.\n");
|
||||
printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
||||
} else if (SOR_Flag) {
|
||||
|
||||
printf ("Another SOR operator was detected.\n");
|
||||
printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
||||
} else if (Dep_Flag) {
|
||||
|
||||
printf ("The Schedule On Request - SOR operator must be the first operator following DEPENDENCY_START\n");
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
||||
} else {
|
||||
//
|
||||
// BUGBUG - This was not in the spec but is in the CORE code
|
||||
// An OPERATOR_SOR has to be first - following the DEPENDENCY_START
|
||||
//
|
||||
fputc (EFI_DEP_SOR, OutFile);
|
||||
OutFileSize++;
|
||||
Ptrx += sizeof (OPERATOR_SOR);
|
||||
SOR_Flag = TRUE;
|
||||
|
||||
}
|
||||
} else if (strncmp (Ptrx, OPERATOR_BEFORE, strlen (OPERATOR_BEFORE)) == 0) {
|
||||
//
|
||||
// Checks for some invalid dependencies
|
||||
//
|
||||
if (Before_Flag) {
|
||||
|
||||
printf ("Another BEFORE operator was detected.\n");
|
||||
printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
||||
} else if (After_Flag) {
|
||||
|
||||
printf ("An AFTER operator was detected.\n");
|
||||
printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
||||
} else if (SOR_Flag) {
|
||||
|
||||
printf ("A SOR operator was detected.\n");
|
||||
printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
||||
} else if (Dep_Flag) {
|
||||
|
||||
printf ("The BEFORE operator must be the first operator following DEPENDENCY_START\n");
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
||||
} else {
|
||||
fputc (EFI_DEP_BEFORE, OutFile);
|
||||
OutFileSize++;
|
||||
Ptrx += sizeof (OPERATOR_BEFORE);
|
||||
Before_Flag = TRUE;
|
||||
}
|
||||
} else if (strncmp (Ptrx, OPERATOR_AFTER, strlen (OPERATOR_AFTER)) == 0) {
|
||||
//
|
||||
// Checks for some invalid dependencies
|
||||
//
|
||||
if (Before_Flag) {
|
||||
|
||||
printf ("A BEFORE operator was detected.\n");
|
||||
printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
||||
} else if (After_Flag) {
|
||||
|
||||
printf ("Another AFTER operator was detected.\n");
|
||||
printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
||||
} else if (SOR_Flag) {
|
||||
|
||||
printf ("A SOR operator was detected.\n");
|
||||
printf ("There can only be one SOR or one AFTER or one BEFORE operator\n");
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
||||
} else if (Dep_Flag) {
|
||||
|
||||
printf ("The AFTER operator must be the first operator following DEPENDENCY_START\n");
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
||||
} else {
|
||||
fputc (EFI_DEP_AFTER, OutFile);
|
||||
OutFileSize++;
|
||||
Ptrx += sizeof (OPERATOR_AFTER);
|
||||
Dep_Flag = TRUE;
|
||||
After_Flag = TRUE;
|
||||
}
|
||||
} else if (strncmp (Ptrx, OPERATOR_AND, strlen (OPERATOR_AND)) == 0) {
|
||||
while (StackPtr != EvaluationStack) {
|
||||
Opcode = PopOpCode ((VOID **) &StackPtr);
|
||||
if (Opcode != DXE_DEP_LEFT_PARENTHESIS) {
|
||||
fputc (Opcode, OutFile);
|
||||
OutFileSize++;
|
||||
} else {
|
||||
PushOpCode ((VOID **) &StackPtr, DXE_DEP_LEFT_PARENTHESIS);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PushOpCode ((VOID **) &StackPtr, EFI_DEP_AND);
|
||||
Ptrx += sizeof (OPERATOR_AND);
|
||||
Dep_Flag = TRUE;
|
||||
|
||||
} else if (strncmp (Ptrx, OPERATOR_OR, strlen (OPERATOR_OR)) == 0) {
|
||||
while (StackPtr != EvaluationStack) {
|
||||
Opcode = PopOpCode ((VOID **) &StackPtr);
|
||||
if (Opcode != DXE_DEP_LEFT_PARENTHESIS) {
|
||||
fputc (Opcode, OutFile);
|
||||
OutFileSize++;
|
||||
} else {
|
||||
PushOpCode ((VOID **) &StackPtr, DXE_DEP_LEFT_PARENTHESIS);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PushOpCode ((VOID **) &StackPtr, EFI_DEP_OR);
|
||||
Ptrx += sizeof (OPERATOR_OR);
|
||||
Dep_Flag = TRUE;
|
||||
|
||||
} else if (strncmp (Ptrx, OPERATOR_NOT, strlen (OPERATOR_NOT)) == 0) {
|
||||
while (StackPtr != EvaluationStack) {
|
||||
Opcode = PopOpCode ((VOID **) &StackPtr);
|
||||
if (Opcode != DXE_DEP_LEFT_PARENTHESIS) {
|
||||
fputc (Opcode, OutFile);
|
||||
OutFileSize++;
|
||||
} else {
|
||||
PushOpCode ((VOID **) &StackPtr, DXE_DEP_LEFT_PARENTHESIS);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PushOpCode ((VOID **) &StackPtr, EFI_DEP_NOT);
|
||||
Ptrx += sizeof (OPERATOR_NOT);
|
||||
Dep_Flag = TRUE;
|
||||
|
||||
} else if (*Ptrx == '\t') {
|
||||
|
||||
printf ("File contains tabs. This violates the coding standard\n");
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
||||
} else if (*Ptrx == '\n') {
|
||||
//
|
||||
// Skip the newline character in the file
|
||||
//
|
||||
Ptrx++;
|
||||
|
||||
} else if (strncmp (Ptrx, OPERATOR_LEFT_PARENTHESIS, strlen (OPERATOR_LEFT_PARENTHESIS)) == 0) {
|
||||
PushOpCode ((VOID **) &StackPtr, DXE_DEP_LEFT_PARENTHESIS);
|
||||
|
||||
Ptrx += strlen (OPERATOR_LEFT_PARENTHESIS);
|
||||
Dep_Flag = TRUE;
|
||||
|
||||
} else if (strncmp (Ptrx, OPERATOR_RIGHT_PARENTHESIS, strlen (OPERATOR_RIGHT_PARENTHESIS)) == 0) {
|
||||
while (StackPtr != EvaluationStack) {
|
||||
Opcode = PopOpCode ((VOID **) &StackPtr);
|
||||
if (Opcode != DXE_DEP_LEFT_PARENTHESIS) {
|
||||
fputc (Opcode, OutFile);
|
||||
OutFileSize++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Ptrx += strlen (OPERATOR_RIGHT_PARENTHESIS);
|
||||
Dep_Flag = TRUE;
|
||||
|
||||
} else if (strncmp (Ptrx, OPERATOR_TRUE, strlen (OPERATOR_TRUE)) == 0) {
|
||||
|
||||
fputc (EFI_DEP_TRUE, OutFile);
|
||||
|
||||
OutFileSize++;
|
||||
|
||||
//
|
||||
// OutFileSize += sizeof (EFI_DEP_TRUE);
|
||||
//
|
||||
Dep_Flag = TRUE;
|
||||
|
||||
Ptrx += strlen (OPERATOR_TRUE);
|
||||
|
||||
} else if (strncmp (Ptrx, OPERATOR_FALSE, strlen (OPERATOR_FALSE)) == 0) {
|
||||
|
||||
fputc (EFI_DEP_FALSE, OutFile);
|
||||
|
||||
OutFileSize++;
|
||||
|
||||
//
|
||||
// OutFileSize += sizeof (EFI_DEP_FALSE);
|
||||
//
|
||||
Dep_Flag = TRUE;
|
||||
|
||||
Ptrx += strlen (OPERATOR_FALSE);
|
||||
|
||||
} else if (*Ptrx == '{') {
|
||||
Ptrx++;
|
||||
|
||||
if (*Ptrx == ' ') {
|
||||
Ptrx++;
|
||||
}
|
||||
|
||||
{
|
||||
int byte_index;
|
||||
// This is an array of UINT32s. sscanf will trash memory
|
||||
// if you try to read into a UINT8 with a %x formatter.
|
||||
UINT32 Guid_Data4[8];
|
||||
|
||||
ArgCountParsed = sscanf (
|
||||
Ptrx,
|
||||
"%x, %x, %x, { %x, %x, %x, %x, %x, %x, %x, %x }",
|
||||
&Guid.Data1,
|
||||
&Guid.Data2,
|
||||
&Guid.Data3,
|
||||
&Guid_Data4[0],
|
||||
&Guid_Data4[1],
|
||||
&Guid_Data4[2],
|
||||
&Guid_Data4[3],
|
||||
&Guid_Data4[4],
|
||||
&Guid_Data4[5],
|
||||
&Guid_Data4[6],
|
||||
&Guid_Data4[7]
|
||||
);
|
||||
|
||||
// Now we can copy the 32 bit ints into the GUID.
|
||||
for (byte_index=0; byte_index<8; byte_index++) {
|
||||
Guid.Data4[byte_index] = (UINT8) Guid_Data4[byte_index];
|
||||
}
|
||||
}
|
||||
|
||||
if (ArgCountParsed != 11) {
|
||||
printf ("We have found an illegal GUID\n");
|
||||
printf ("Fix your depex\n");
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
while (*Ptrx != '}') {
|
||||
Ptrx++;
|
||||
}
|
||||
|
||||
Ptrx++;
|
||||
while (*Ptrx != '}') {
|
||||
Ptrx++;
|
||||
}
|
||||
//
|
||||
// Absorb the closing }
|
||||
//
|
||||
Ptrx++;
|
||||
|
||||
//
|
||||
// Don't provide a PUSH Opcode for the Before and After case
|
||||
//
|
||||
if ((!Before_Flag) && (!After_Flag)) {
|
||||
fputc (EFI_DEP_PUSH, OutFile);
|
||||
OutFileSize++;
|
||||
}
|
||||
|
||||
fwrite (&Guid, sizeof (EFI_GUID), 1, OutFile);
|
||||
|
||||
OutFileSize += sizeof (EFI_GUID);
|
||||
Dep_Flag = TRUE;
|
||||
|
||||
} else if (strncmp (Ptrx, DEPENDENCY_END, strlen (DEPENDENCY_END)) == 0) {
|
||||
NotDone = FALSE;
|
||||
} else {
|
||||
//
|
||||
// Not a valid construct. Null terminate somewhere out there and
|
||||
// print an error message.
|
||||
//
|
||||
*(Ptrx + 20) = 0;
|
||||
printf (TOOL_NAME " ERROR: Unrecognized input at: \"%s\"...\n", Ptrx);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
//
|
||||
// DRAIN();
|
||||
//
|
||||
while (StackPtr != EvaluationStack) {
|
||||
fputc (PopOpCode ((VOID **) &StackPtr), OutFile);
|
||||
OutFileSize++;
|
||||
}
|
||||
|
||||
if (OutFileSize == 0) {
|
||||
printf ("Grammer contains no operators or constants\n");
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
fputc (EFI_DEP_END, OutFile);
|
||||
|
||||
OutFileSize++;
|
||||
|
||||
//
|
||||
// Checks for invalid padding values
|
||||
//
|
||||
if (Padding < 0) {
|
||||
|
||||
printf ("The inputted padding value was %d\n", Padding);
|
||||
printf ("The optional padding value can not be less than ZERO\n");
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
||||
} else if (Padding > 0) {
|
||||
|
||||
while ((OutFileSize % Padding) != 0) {
|
||||
|
||||
fputc (' ', OutFile);
|
||||
OutFileSize++;
|
||||
}
|
||||
}
|
||||
|
||||
Results = (UINTN) fclose (InFile);
|
||||
if (Results != 0) {
|
||||
printf ("FCLOSE failed\n");
|
||||
}
|
||||
|
||||
Results = (UINTN) fclose (OutFile);
|
||||
if (Results != 0) {
|
||||
printf ("FCLOSE failed\n");
|
||||
}
|
||||
|
||||
free (Buffer);
|
||||
free (EvaluationStack);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
} // End GenerateDependencyExpression function
|
||||
|
||||
int
|
||||
main (
|
||||
IN UINTN argc,
|
||||
IN CHAR8 *argv[]
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Parse user entries. Print some rudimentary help
|
||||
|
||||
Arguments:
|
||||
|
||||
argc The count of input arguments
|
||||
argv The input arguments string array
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS The function completed successfully.
|
||||
EFI_INVALID_PARAMETER One of the input parameters was invalid or one of the parameters in the text file was invalid.
|
||||
EFI_OUT_OF_RESOURCES Unable to allocate memory.
|
||||
EFI_ABORTED Unable to open/create a file or a misc error.
|
||||
|
||||
--*/
|
||||
// TODO: ] - add argument and description to function comment
|
||||
{
|
||||
FILE *OutFile;
|
||||
FILE *InFile;
|
||||
UINT8 Padding;
|
||||
UINTN Index;
|
||||
BOOLEAN Input_Flag;
|
||||
BOOLEAN Output_Flag;
|
||||
BOOLEAN Pad_Flag;
|
||||
|
||||
InFile = NULL;
|
||||
OutFile = NULL;
|
||||
Padding = 0;
|
||||
Input_Flag = FALSE;
|
||||
Output_Flag = FALSE;
|
||||
Pad_Flag = FALSE;
|
||||
|
||||
if (argc < 5) {
|
||||
printf ("Not enough arguments\n");
|
||||
PrintGenDepexUsageInfo ();
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
for (Index = 1; Index < argc - 1; Index++) {
|
||||
|
||||
if ((strcmp (argv[Index], "-I") == 0) || (strcmp (argv[Index], "-i") == 0)) {
|
||||
|
||||
if (!Input_Flag) {
|
||||
|
||||
InFile = fopen (argv[Index + 1], "rb");
|
||||
Input_Flag = TRUE;
|
||||
|
||||
} else {
|
||||
printf ("GenDepex only allows one INPUT (-I) argument\n");
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
} else if ((strcmp (argv[Index], "-O") == 0) || (strcmp (argv[Index], "-o") == 0)) {
|
||||
|
||||
if (!Output_Flag) {
|
||||
|
||||
OutFile = fopen (argv[Index + 1], "wb");
|
||||
Output_Flag = TRUE;
|
||||
|
||||
} else {
|
||||
printf ("GenDepex only allows one OUTPUT (-O) argument\n");
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
} else if ((strcmp (argv[Index], "-P") == 0) || (strcmp (argv[Index], "-p") == 0)) {
|
||||
|
||||
if (!Pad_Flag) {
|
||||
|
||||
Padding = (UINT8) atoi (argv[Index + 1]);
|
||||
Pad_Flag = TRUE;
|
||||
|
||||
} else {
|
||||
printf ("GenDepex only allows one PADDING (-P) argument\n");
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PrintGenDepexUtilityInfo ();
|
||||
|
||||
if (InFile == NULL) {
|
||||
printf ("Can not open <INFILE> for reading.\n");
|
||||
PrintGenDepexUsageInfo ();
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
|
||||
if (OutFile == NULL) {
|
||||
printf ("Can not open <OUTFILE> for writting.\n");
|
||||
PrintGenDepexUsageInfo ();
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
|
||||
return GenerateDependencyExpression (InFile, OutFile, Padding);
|
||||
}
|
71
Tools/CodeTools/Source/GenDepex/GenDepex.h
Normal file
71
Tools/CodeTools/Source/GenDepex/GenDepex.h
Normal file
@ -0,0 +1,71 @@
|
||||
/*++
|
||||
Copyright (c) 2004, 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.
|
||||
|
||||
Module Name:
|
||||
GenDepex.h
|
||||
|
||||
Abstract:
|
||||
This file contains the relevant declarations required
|
||||
to generate a binary Dependency File
|
||||
|
||||
Complies with Tiano C Coding Standards Document, version 0.31, 12 Dec 2000.
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _EFI_GEN_DEPEX_H
|
||||
#define _EFI_GEN_DEPEX_H
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
#include <string.h>
|
||||
#ifndef __GNUC__
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
#include <Common/UefiBaseTypes.h>
|
||||
#include <Common/Dependency.h>
|
||||
|
||||
#define DEPENDENCY_START "DEPENDENCY_START"
|
||||
#define OPERATOR_BEFORE "BEFORE"
|
||||
#define OPERATOR_AFTER "AFTER"
|
||||
#define OPERATOR_AND "AND"
|
||||
#define OPERATOR_OR "OR"
|
||||
#define OPERATOR_NOT "NOT"
|
||||
#define OPERATOR_TRUE "TRUE"
|
||||
#define OPERATOR_FALSE "FALSE"
|
||||
#define OPERATOR_SOR "SOR"
|
||||
#define OPERATOR_END "END"
|
||||
#define OPERATOR_LEFT_PARENTHESIS "("
|
||||
#define OPERATOR_RIGHT_PARENTHESIS ")"
|
||||
#define DEPENDENCY_END "DEPENDENCY_END"
|
||||
|
||||
#define DXE_DEP_LEFT_PARENTHESIS 0x0a
|
||||
#define DXE_DEP_RIGHT_PARENTHESIS 0x0b
|
||||
|
||||
#define LINESIZE 320
|
||||
#define SIZE_A_SYMBOL 60
|
||||
#define DEPENDENCY_OPCODE UINT8
|
||||
#define EVAL_STACK_SIZE 0x1024
|
||||
#define BUFFER_SIZE 0x100
|
||||
|
||||
//
|
||||
// Utility Name
|
||||
//
|
||||
#define UTILITY_NAME "GenDepex"
|
||||
|
||||
//
|
||||
// Utility version information
|
||||
//
|
||||
#define UTILITY_MAJOR_VERSION 0
|
||||
#define UTILITY_MINOR_VERSION 5
|
||||
|
||||
#endif
|
68
Tools/CodeTools/Source/GenDepex/build.xml
Normal file
68
Tools/CodeTools/Source/GenDepex/build.xml
Normal file
@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" ?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<project default="GenTool" basedir=".">
|
||||
<!--
|
||||
EDK GenDepex Tool
|
||||
Copyright (c) 2006, Intel Corporation
|
||||
-->
|
||||
<property name="ToolName" value="GenDepex"/>
|
||||
<property name="FileSet" value="DepexParser.c GenDepex.c GenDepex.h"/>
|
||||
|
||||
<taskdef resource="cpptasks.tasks"/>
|
||||
<typedef resource="cpptasks.types"/>
|
||||
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
|
||||
|
||||
<property name="LINK_OUTPUT_TYPE" value="static"/>
|
||||
<property name="BUILD_DIR" value="${PACKAGE_DIR}/${ToolName}/tmp"/>
|
||||
|
||||
<target name="GenTool" depends="init, Tool">
|
||||
<echo message="The EDK Tool: ${ToolName} build has completed!"/>
|
||||
</target>
|
||||
|
||||
<target name="init">
|
||||
<echo message="Building the EDK Tool: ${ToolName}"/>
|
||||
<mkdir dir="${BUILD_DIR}"/>
|
||||
</target>
|
||||
|
||||
<target name="Tool" depends="init">
|
||||
<cc name="${ToolChain}" objdir="${BUILD_DIR}"
|
||||
outfile="${BIN_DIR}/${ToolName}"
|
||||
outtype="executable"
|
||||
debug="true"
|
||||
optimize="speed">
|
||||
<compilerarg value="${ExtraArgus}" if="ExtraArgus" />
|
||||
|
||||
<fileset dir="${basedir}/${ToolName}"
|
||||
includes="${FileSet}" />
|
||||
|
||||
<includepath path="${PACKAGE_DIR}/Include"/>
|
||||
<includepath path="${PACKAGE_DIR}/Include/Ia32"/>
|
||||
<includepath path="${PACKAGE_DIR}/Common"/>
|
||||
</cc>
|
||||
</target>
|
||||
|
||||
<target name="clean">
|
||||
<echo message="Removing Intermediate Files Only"/>
|
||||
<delete>
|
||||
<fileset dir="${BUILD_DIR}" includes="*.obj"/>
|
||||
</delete>
|
||||
</target>
|
||||
|
||||
<target name="cleanall">
|
||||
<echo message="Removing Object Files and the Executable: ${ToolName}${ext_exe}"/>
|
||||
<delete failonerror="false" quiet="true" includeEmptyDirs="true">
|
||||
<fileset dir="${BUILD_DIR}"/>
|
||||
<fileset file="${BIN_DIR}/${ToolName}${ext_exe}"/>
|
||||
</delete>
|
||||
</target>
|
||||
|
||||
</project>
|
Reference in New Issue
Block a user