mirror of https://github.com/acidanthera/audk.git
Remove the prototype code.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@423 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
59b05fbba8
commit
6c756d6463
|
@ -1,8 +0,0 @@
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class Auto
|
|
||||||
{
|
|
||||||
public static void main(String args[])
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class Component extends Module
|
|
||||||
{
|
|
||||||
Component()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
Component(String n)
|
|
||||||
{
|
|
||||||
name=n;
|
|
||||||
}
|
|
||||||
String name;
|
|
||||||
|
|
||||||
// These are the libs we want to build with.
|
|
||||||
public Set<LibInst> buildLibs;
|
|
||||||
|
|
||||||
public String name() { return name; }
|
|
||||||
|
|
||||||
public boolean autoBuild()
|
|
||||||
{
|
|
||||||
// buildLibs must contain a list of libInstances. We need to check that
|
|
||||||
// These libs meet certain criterea.
|
|
||||||
if(!duplicateLibClasses(buildLibs).isEmpty())
|
|
||||||
{
|
|
||||||
// Error: The lib instance implement the same lib twice.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(! libClassesProduced(buildLibs).containsAll(consumesLibClasses))
|
|
||||||
{
|
|
||||||
// We can not cover the libclasses consumed with these instances.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
getConstructorOrder(buildLibs);
|
|
||||||
getDestructorOrder(buildLibs);
|
|
||||||
|
|
||||||
// Get PPI, Protocol, GUID, PCDs from the lib instances. These are all simple unions of
|
|
||||||
// the corresponding sets in the modules. There is no ordering needed.
|
|
||||||
// TODO
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,176 +0,0 @@
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
// A directed Acyclic Graph class. The main purpose is to provide a set of nodes
|
|
||||||
// and the dependency relations between them. Then ask for a topological sort of
|
|
||||||
// the nodes.
|
|
||||||
|
|
||||||
public class DAG<Node>
|
|
||||||
{
|
|
||||||
// Constructor.
|
|
||||||
DAG()
|
|
||||||
{
|
|
||||||
children = new HashMap<Node,Set<Node>>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<Node> nodes() { return children.keySet(); }
|
|
||||||
public Set<Node> children(Node parent) { return children.get(parent); }
|
|
||||||
|
|
||||||
// Add the relations from a compatible DAG to this one.
|
|
||||||
public void add(DAG<Node> newDag)
|
|
||||||
{
|
|
||||||
for(Node parent : newDag.children.keySet())
|
|
||||||
{
|
|
||||||
children.put(parent, newDag.children(parent));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// The central data structure is a one-to-many map. Each node is
|
|
||||||
// treated as a parent. It is mapped to a list of its children. Leaf
|
|
||||||
// nodes are also treated as parents and map to an empty list of
|
|
||||||
// children.
|
|
||||||
Map<Node,Set<Node>> children;
|
|
||||||
|
|
||||||
public void remove(Collection<Node> nodes)
|
|
||||||
{
|
|
||||||
// Remove it as a parent
|
|
||||||
for(Node node : nodes)
|
|
||||||
{
|
|
||||||
children.remove(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(Set<Node> childlist : children.values())
|
|
||||||
{
|
|
||||||
// Remove it as a child
|
|
||||||
childlist.removeAll(nodes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove every occurrence of node from the DAG.
|
|
||||||
public void remove(Node node)
|
|
||||||
{
|
|
||||||
// Remove it as a parent
|
|
||||||
children.remove(node);
|
|
||||||
|
|
||||||
for(Set<Node> childlist : children.values())
|
|
||||||
{
|
|
||||||
// Remove it as a child
|
|
||||||
childlist.remove(node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return true iff parent is a direct parent of child.
|
|
||||||
public boolean directDepends(Node parent, Node child)
|
|
||||||
{
|
|
||||||
return children.containsKey(parent) ?
|
|
||||||
children(parent).contains(child) :
|
|
||||||
false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return true iff parent is a direct or indirect parent of child.
|
|
||||||
// This is the transitive closure of the dependency relation.
|
|
||||||
public boolean depends(Node parent, Node child)
|
|
||||||
{
|
|
||||||
if(!children.containsKey(parent))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if( directDepends(parent, child) )
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for(Node descendent : children(parent) )
|
|
||||||
{
|
|
||||||
// Recursively call depends() to compute the transitive closure of
|
|
||||||
// the relation.
|
|
||||||
if(depends(descendent, child))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add a parent child relation to the dag. Fail if there is already
|
|
||||||
// a dependency from the child to the parent. This implies a cycle.
|
|
||||||
// Our invariant is that the DAG must never contain a cycle. That
|
|
||||||
// way it lives up to its name.
|
|
||||||
public void add(Node parent, Node child)
|
|
||||||
{
|
|
||||||
if(depends(child, parent))
|
|
||||||
{
|
|
||||||
System.out.format("Error: There is a cycle from %s to %s.\n", parent, child);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(children.containsKey(parent))
|
|
||||||
{
|
|
||||||
children(parent).add(child);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Set<Node> cs = new HashSet<Node>();
|
|
||||||
cs.add(child);
|
|
||||||
children.put(parent, cs);
|
|
||||||
}
|
|
||||||
if(!children.containsKey(child))
|
|
||||||
{
|
|
||||||
children.put(child,new HashSet<Node>());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Perform a topological sort on the DAG.
|
|
||||||
public List<Node> sort()
|
|
||||||
{
|
|
||||||
// Make an ordered list to hold the topo sort.
|
|
||||||
List<Node> sorted = new LinkedList<Node>();
|
|
||||||
|
|
||||||
// We add the leaves to the beginning of the list until
|
|
||||||
// the sorted list contains all the nodes in the DAG.
|
|
||||||
while(!sorted.containsAll(nodes()))
|
|
||||||
{
|
|
||||||
// Ignoring the ones we have found, what are the leaves of this
|
|
||||||
// DAG?
|
|
||||||
Set<Node> leaves = leaves(sorted);
|
|
||||||
// Put the new leaves at the beginning of the list.
|
|
||||||
sorted.addAll(0, leaves);
|
|
||||||
}
|
|
||||||
return sorted;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the set of nodes that have no children. Pretend
|
|
||||||
// the nodes in the exclude list are not present.
|
|
||||||
public Set<Node> leaves(Collection<Node> exclude)
|
|
||||||
{
|
|
||||||
Set<Node> leaves=new HashSet<Node>();
|
|
||||||
for(Node parent : children.keySet())
|
|
||||||
{
|
|
||||||
if(exclude.contains(parent))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// If the children of parent are a subset of the exclude set,
|
|
||||||
// then parent is a leaf.
|
|
||||||
if(exclude.containsAll(children(parent)))
|
|
||||||
{
|
|
||||||
leaves.add(parent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return leaves;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the set of nodes that have no children.
|
|
||||||
public Set<Node> leaves()
|
|
||||||
{
|
|
||||||
Set<Node> leaves=new HashSet<Node>();
|
|
||||||
for(Node parent : children.keySet())
|
|
||||||
{
|
|
||||||
if( children(parent).isEmpty())
|
|
||||||
{
|
|
||||||
leaves.add(parent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return leaves;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class Database
|
|
||||||
{
|
|
||||||
Database()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
Database(String n)
|
|
||||||
{
|
|
||||||
name=n;
|
|
||||||
}
|
|
||||||
public String name;
|
|
||||||
Map<String,Set<Package>> packages;
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class GuidDecl
|
|
||||||
{
|
|
||||||
GuidDecl()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
GuidDecl(String n)
|
|
||||||
{
|
|
||||||
name=n;
|
|
||||||
}
|
|
||||||
public String name;
|
|
||||||
public String cName;
|
|
||||||
public String guid;
|
|
||||||
public String name() { return name; }
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class LibClass
|
|
||||||
{
|
|
||||||
LibClass()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
LibClass(String n)
|
|
||||||
{
|
|
||||||
name=n;
|
|
||||||
}
|
|
||||||
String name;
|
|
||||||
public String name() { return name; }
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class LibInst extends Module
|
|
||||||
{
|
|
||||||
LibInst()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
LibInst(String n)
|
|
||||||
{
|
|
||||||
name=n;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<LibClass> producesLibClasses;
|
|
||||||
|
|
||||||
public String constructorName, destructorName;
|
|
||||||
|
|
||||||
public boolean autoBuild()
|
|
||||||
{
|
|
||||||
// A simple compile, without link.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,178 +0,0 @@
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class Module
|
|
||||||
{
|
|
||||||
Module()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
Module(String n)
|
|
||||||
{
|
|
||||||
name=n;
|
|
||||||
}
|
|
||||||
String name;
|
|
||||||
|
|
||||||
public String name() { return name; }
|
|
||||||
|
|
||||||
public Set<LibClass> consumesLibClasses;
|
|
||||||
|
|
||||||
// The set of packages that this module depends upon.
|
|
||||||
Set<Package> packageDepends;
|
|
||||||
public Set<Package> packageDeps() { return packageDepends; }
|
|
||||||
|
|
||||||
public boolean autoBuild()
|
|
||||||
{
|
|
||||||
// This should be implemented in the derived class.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure that each class in this set of libclasses is declared in one
|
|
||||||
// of the packages that this module depends on.
|
|
||||||
public boolean validateLibClasses(Set<LibClass> classes)
|
|
||||||
{
|
|
||||||
for(LibClass lc : classes)
|
|
||||||
{
|
|
||||||
// Assume we will not find it.
|
|
||||||
boolean found = false;
|
|
||||||
|
|
||||||
for(Package p : packageDepends)
|
|
||||||
{
|
|
||||||
if(p.libClassDecls.contains(lc))
|
|
||||||
{
|
|
||||||
found=true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(found == false)
|
|
||||||
{
|
|
||||||
// Error: This LibClass is not found in any of our Packages.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Well, we never came up empty handed, so it looks good.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<LibClass> libClassesProduced(Collection<LibInst> instances)
|
|
||||||
{
|
|
||||||
// given a set of lib instances, what is the set of lib classes produced?
|
|
||||||
|
|
||||||
Set<LibClass> classes = new HashSet<LibClass>();
|
|
||||||
|
|
||||||
for(LibInst li : instances)
|
|
||||||
{
|
|
||||||
classes.addAll(li.producesLibClasses);
|
|
||||||
}
|
|
||||||
return classes;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Search the given set of lib instance to see if, among them, they
|
|
||||||
// produce the same LibClass more than once.
|
|
||||||
public Set<LibClass> duplicateLibClasses(Set<LibInst> libs)
|
|
||||||
{
|
|
||||||
// Return true iff each class produced is produced only once.
|
|
||||||
|
|
||||||
List<LibClass> classes = new LinkedList<LibClass>();
|
|
||||||
Set<LibClass> dups = new HashSet<LibClass>();
|
|
||||||
|
|
||||||
for(LibInst li : libs)
|
|
||||||
{
|
|
||||||
classes.addAll(li.producesLibClasses);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(LibClass c : classes)
|
|
||||||
{
|
|
||||||
for(LibClass inner : classes)
|
|
||||||
{
|
|
||||||
if(c.equals(inner))
|
|
||||||
{
|
|
||||||
dups.add(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return dups;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<LibInst> getProducers(LibClass lc, Set<LibInst> libs)
|
|
||||||
{
|
|
||||||
// Return the subset of the given libs that produce this LibClass.
|
|
||||||
|
|
||||||
Set<LibInst> producers = new HashSet<LibInst>();
|
|
||||||
|
|
||||||
for(LibInst li : libs)
|
|
||||||
{
|
|
||||||
if(li.producesLibClasses.contains(lc))
|
|
||||||
{
|
|
||||||
producers.add(li);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return producers;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// The central dependency relationship between library instances is as follows.
|
|
||||||
// A LibInst "A" depends upon LibInst "B" if, and only if, there exists a LibClass
|
|
||||||
// "C" such that A consumes C and B produces C. This is the partial order over which
|
|
||||||
// we construct a Directed Acyclic Graph (DAG). The DAG can be used to detect
|
|
||||||
// cycles in the depends relation (which are illegal) and it can be used to implement a
|
|
||||||
// topological sort which is a total ordering over LibInstances. This total order on
|
|
||||||
// lib instances is what is needed in order to call the constructors and destructors
|
|
||||||
// in the proper sequence.
|
|
||||||
//
|
|
||||||
public DAG<LibInst> makeDAG(Set<LibInst> libs)
|
|
||||||
{
|
|
||||||
DAG<LibInst> dag = new DAG<LibInst>();
|
|
||||||
|
|
||||||
if(duplicateLibClasses(libs).size()>0)
|
|
||||||
{
|
|
||||||
System.out.format("Error: The library instances implement at least one "
|
|
||||||
+ "library class more than once.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
for(LibInst consumer : libs)
|
|
||||||
{
|
|
||||||
// Find all the producers for each LC that li consumes.
|
|
||||||
for(LibClass lc : consumer.consumesLibClasses )
|
|
||||||
{
|
|
||||||
Set<LibInst> producers = getProducers(lc, libs);
|
|
||||||
if(producers.isEmpty())
|
|
||||||
{
|
|
||||||
System.out.format("Error: Unmet dependency libclass:%s .", lc.name() );
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// There is exactly one lib inst that produces this class.
|
|
||||||
LibInst producer = producers.iterator().next();
|
|
||||||
|
|
||||||
// Now we are ready to add the dependency to the dag. It will flag
|
|
||||||
// circular dependencies for us.
|
|
||||||
dag.add(consumer, producer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return dag;
|
|
||||||
}
|
|
||||||
|
|
||||||
// As you evaluate each node in the graph (starting with the module node), you
|
|
||||||
// must call the constructors for all the child nodes before you call the
|
|
||||||
// constructor for the current node.
|
|
||||||
public List<LibInst> getConstructorOrder(Set<LibInst> libs)
|
|
||||||
{
|
|
||||||
List<LibInst> rev = new LinkedList<LibInst>();
|
|
||||||
|
|
||||||
for(LibInst li : getDestructorOrder(libs))
|
|
||||||
rev.add(0, li);
|
|
||||||
|
|
||||||
return rev;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The destructor order is exactly the reverese of the constructor order.
|
|
||||||
// As you evaluate each node in the graph (starting with the module node), you
|
|
||||||
// must call the destructor for the all the parent nodes before calling the
|
|
||||||
// destructors for the current node, and then call the destructors for all the
|
|
||||||
// child nodes.
|
|
||||||
public List<LibInst> getDestructorOrder(Set<LibInst> libs)
|
|
||||||
{
|
|
||||||
DAG<LibInst> dag = makeDAG(libs);
|
|
||||||
|
|
||||||
return dag.sort();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class Package
|
|
||||||
{
|
|
||||||
Package()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
Package(String n)
|
|
||||||
{
|
|
||||||
name=n;
|
|
||||||
}
|
|
||||||
public String name;
|
|
||||||
|
|
||||||
public Set<LibClass> libClassDecls;
|
|
||||||
public Set<GuidDecl> guidDecls;
|
|
||||||
public Set<PpiDecl> ppiDecls;
|
|
||||||
public Set<ProtocolDecl> protocolDecls;
|
|
||||||
public Set<Module> modules;
|
|
||||||
public Set<Package> depends;
|
|
||||||
|
|
||||||
public void genBuild()
|
|
||||||
{
|
|
||||||
for(Module m : modules)
|
|
||||||
{
|
|
||||||
m.autoBuild();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Figure out what this package depends on based on what the modules
|
|
||||||
// depend on.
|
|
||||||
public void calculateDependencies()
|
|
||||||
{
|
|
||||||
depends = new HashSet<Package>();
|
|
||||||
for(Module m : modules)
|
|
||||||
{
|
|
||||||
depends.addAll(m.packageDeps());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void makeJar(String name) {};
|
|
||||||
|
|
||||||
public void addModule(Module m) {};
|
|
||||||
public void removeModule(Module m) {};
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class PpiDecl
|
|
||||||
{
|
|
||||||
PpiDecl()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
PpiDecl(String n)
|
|
||||||
{
|
|
||||||
name=n;
|
|
||||||
}
|
|
||||||
public String name;
|
|
||||||
public String cName;
|
|
||||||
public String guid;
|
|
||||||
public String name() { return name; }
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class ProtocolDecl
|
|
||||||
{
|
|
||||||
ProtocolDecl()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
ProtocolDecl(String n)
|
|
||||||
{
|
|
||||||
name=n;
|
|
||||||
}
|
|
||||||
public String name;
|
|
||||||
public String cName;
|
|
||||||
public String guid;
|
|
||||||
public String name() { return name; }
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class TSort
|
|
||||||
{
|
|
||||||
public static void main(String args[])
|
|
||||||
{
|
|
||||||
DAG<String> dag = new DAG<String>();
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if(args.length % 2==1)
|
|
||||||
{
|
|
||||||
System.out.println("Error: Odd number of elements");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for(i=0; i< args.length/2; i++)
|
|
||||||
{
|
|
||||||
dag.add(args[i*2], args[i*2+1]);
|
|
||||||
// System.out.println(pair.left);
|
|
||||||
// System.out.println(pair.right);
|
|
||||||
}
|
|
||||||
System.out.println(dag.sort().toString());
|
|
||||||
System.out.println(dag.sort().toString());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
<?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 name="proto" default="all">
|
|
||||||
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
|
|
||||||
<target name="all">
|
|
||||||
<javac srcdir=".">
|
|
||||||
<compilerarg value="-Xlint"/>
|
|
||||||
</javac>
|
|
||||||
<jar destfile="Prototype.jar"
|
|
||||||
basedir="."
|
|
||||||
includes="*.class"
|
|
||||||
excludes="**/Not this one.class"
|
|
||||||
/>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="clean"/>
|
|
||||||
<target name="cleanall"/>
|
|
||||||
</project>
|
|
Loading…
Reference in New Issue