forked from lix-project/lix
* Sync with the trunk.
This commit is contained in:
commit
83dfa89870
|
@ -29,10 +29,18 @@ sub createLinks {
|
||||||
$baseName =~ s/^.*\///g; # strip directory
|
$baseName =~ s/^.*\///g; # strip directory
|
||||||
my $dstFile = "$dstDir/$baseName";
|
my $dstFile = "$dstDir/$baseName";
|
||||||
|
|
||||||
|
# The files below are special-cased so that they don't show up
|
||||||
|
# in user profiles, either because they are useless, or
|
||||||
|
# because they would cause pointless collisions (e.g., each
|
||||||
|
# Python package brings its own
|
||||||
|
# `$out/lib/pythonX.Y/site-packages/easy-install.pth'.)
|
||||||
# Urgh, hacky...
|
# Urgh, hacky...
|
||||||
if ($srcFile =~ /\/propagated-build-inputs$/ ||
|
if ($srcFile =~ /\/propagated-build-inputs$/ ||
|
||||||
$srcFile =~ /\/nix-support$/ ||
|
$srcFile =~ /\/nix-support$/ ||
|
||||||
$srcFile =~ /\/perllocal.pod$/ ||
|
$srcFile =~ /\/perllocal.pod$/ ||
|
||||||
|
$srcFile =~ /\/easy-install.pth$/ ||
|
||||||
|
$srcFile =~ /\/site.py$/ ||
|
||||||
|
$srcFile =~ /\/site.pyc$/ ||
|
||||||
$srcFile =~ /\/info\/dir$/ ||
|
$srcFile =~ /\/info\/dir$/ ||
|
||||||
$srcFile =~ /\/log$/)
|
$srcFile =~ /\/log$/)
|
||||||
{
|
{
|
||||||
|
|
|
@ -342,7 +342,7 @@ $ nix-store --gc --max-freed $((100 * 1024 * 1024))</screen>
|
||||||
|
|
||||||
<cmdsynopsis>
|
<cmdsynopsis>
|
||||||
<command>nix-store</command>
|
<command>nix-store</command>
|
||||||
<arg choice='plain'><option>--gc</option></arg>
|
<arg choice='plain'><option>--delete</option></arg>
|
||||||
<arg><option>--ignore-liveness</option></arg>
|
<arg><option>--ignore-liveness</option></arg>
|
||||||
<arg choice='plain' rep='repeat'><replaceable>paths</replaceable></arg>
|
<arg choice='plain' rep='repeat'><replaceable>paths</replaceable></arg>
|
||||||
</cmdsynopsis>
|
</cmdsynopsis>
|
||||||
|
|
|
@ -582,7 +582,7 @@ static void prim_toXML(EvalState & state, Value * * args, Value & v)
|
||||||
{
|
{
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
PathSet context;
|
PathSet context;
|
||||||
printValueAsXML(state, true, *args[0], out, context);
|
printValueAsXML(state, true, false, *args[0], out, context);
|
||||||
mkString(v, out.str(), context);
|
mkString(v, out.str(), context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,26 +16,40 @@ static XMLAttrs singletonAttrs(const string & name, const string & value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void printValueAsXML(EvalState & state, bool strict, Value & v,
|
static void printValueAsXML(EvalState & state, bool strict, bool location,
|
||||||
XMLWriter & doc, PathSet & context, PathSet & drvsSeen);
|
Value & v, XMLWriter & doc, PathSet & context, PathSet & drvsSeen);
|
||||||
|
|
||||||
|
|
||||||
static void showAttrs(EvalState & state, bool strict, Bindings & attrs,
|
static void posToXML(XMLAttrs & xmlAttrs, const Pos & pos)
|
||||||
XMLWriter & doc, PathSet & context, PathSet & drvsSeen)
|
{
|
||||||
|
xmlAttrs["path"] = pos.file;
|
||||||
|
xmlAttrs["line"] = (format("%1%") % pos.line).str();
|
||||||
|
xmlAttrs["column"] = (format("%1%") % pos.column).str();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void showAttrs(EvalState & state, bool strict, bool location,
|
||||||
|
Bindings & attrs, XMLWriter & doc, PathSet & context, PathSet & drvsSeen)
|
||||||
{
|
{
|
||||||
StringSet names;
|
StringSet names;
|
||||||
foreach (Bindings::iterator, i, attrs)
|
foreach (Bindings::iterator, i, attrs)
|
||||||
names.insert(i->first);
|
names.insert(i->first);
|
||||||
foreach (StringSet::iterator, i, names) {
|
foreach (StringSet::iterator, i, names) {
|
||||||
XMLOpenElement _(doc, "attr", singletonAttrs("name", *i));
|
Attr & a(attrs[state.symbols.create(*i)]);
|
||||||
printValueAsXML(state, strict, attrs[state.symbols.create(*i)].value,
|
|
||||||
doc, context, drvsSeen);
|
XMLAttrs xmlAttrs;
|
||||||
|
xmlAttrs["name"] = *i;
|
||||||
|
if (location && a.pos != &noPos) posToXML(xmlAttrs, *a.pos);
|
||||||
|
|
||||||
|
XMLOpenElement _(doc, "attr", xmlAttrs);
|
||||||
|
printValueAsXML(state, strict, location,
|
||||||
|
a.value, doc, context, drvsSeen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void printValueAsXML(EvalState & state, bool strict, Value & v,
|
static void printValueAsXML(EvalState & state, bool strict, bool location,
|
||||||
XMLWriter & doc, PathSet & context, PathSet & drvsSeen)
|
Value & v, XMLWriter & doc, PathSet & context, PathSet & drvsSeen)
|
||||||
{
|
{
|
||||||
checkInterrupt();
|
checkInterrupt();
|
||||||
|
|
||||||
|
@ -72,25 +86,31 @@ static void printValueAsXML(EvalState & state, bool strict, Value & v,
|
||||||
|
|
||||||
Path drvPath;
|
Path drvPath;
|
||||||
a = v.attrs->find(state.sDrvPath);
|
a = v.attrs->find(state.sDrvPath);
|
||||||
if (a != v.attrs->end() && a->second.value.type == tString)
|
if (a != v.attrs->end()) {
|
||||||
xmlAttrs["drvPath"] = drvPath = a->second.value.string.s;
|
if (strict) state.forceValue(a->second.value);
|
||||||
|
if (a->second.value.type == tString)
|
||||||
|
xmlAttrs["drvPath"] = drvPath = a->second.value.string.s;
|
||||||
|
}
|
||||||
|
|
||||||
a = v.attrs->find(state.sOutPath);
|
a = v.attrs->find(state.sOutPath);
|
||||||
if (a != v.attrs->end() && a->second.value.type == tString)
|
if (a != v.attrs->end()) {
|
||||||
xmlAttrs["outPath"] = a->second.value.string.s;
|
if (strict) state.forceValue(a->second.value);
|
||||||
|
if (a->second.value.type == tString)
|
||||||
|
xmlAttrs["outPath"] = a->second.value.string.s;
|
||||||
|
}
|
||||||
|
|
||||||
XMLOpenElement _(doc, "derivation", xmlAttrs);
|
XMLOpenElement _(doc, "derivation", xmlAttrs);
|
||||||
|
|
||||||
if (drvPath != "" && drvsSeen.find(drvPath) == drvsSeen.end()) {
|
if (drvPath != "" && drvsSeen.find(drvPath) == drvsSeen.end()) {
|
||||||
drvsSeen.insert(drvPath);
|
drvsSeen.insert(drvPath);
|
||||||
showAttrs(state, strict, *v.attrs, doc, context, drvsSeen);
|
showAttrs(state, strict, location, *v.attrs, doc, context, drvsSeen);
|
||||||
} else
|
} else
|
||||||
doc.writeEmptyElement("repeated");
|
doc.writeEmptyElement("repeated");
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
XMLOpenElement _(doc, "attrs");
|
XMLOpenElement _(doc, "attrs");
|
||||||
showAttrs(state, strict, *v.attrs, doc, context, drvsSeen);
|
showAttrs(state, strict, location, *v.attrs, doc, context, drvsSeen);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -98,12 +118,15 @@ static void printValueAsXML(EvalState & state, bool strict, Value & v,
|
||||||
case tList: {
|
case tList: {
|
||||||
XMLOpenElement _(doc, "list");
|
XMLOpenElement _(doc, "list");
|
||||||
for (unsigned int n = 0; n < v.list.length; ++n)
|
for (unsigned int n = 0; n < v.list.length; ++n)
|
||||||
printValueAsXML(state, strict, *v.list.elems[n], doc, context, drvsSeen);
|
printValueAsXML(state, strict, location, *v.list.elems[n], doc, context, drvsSeen);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case tLambda: {
|
case tLambda: {
|
||||||
XMLOpenElement _(doc, "function");
|
XMLAttrs xmlAttrs;
|
||||||
|
if (location) posToXML(xmlAttrs, v.lambda.fun->pos);
|
||||||
|
XMLOpenElement _(doc, "function", xmlAttrs);
|
||||||
|
|
||||||
if (v.lambda.fun->matchAttrs) {
|
if (v.lambda.fun->matchAttrs) {
|
||||||
XMLAttrs attrs;
|
XMLAttrs attrs;
|
||||||
if (!v.lambda.fun->arg.empty()) attrs["name"] = v.lambda.fun->arg;
|
if (!v.lambda.fun->arg.empty()) attrs["name"] = v.lambda.fun->arg;
|
||||||
|
@ -113,6 +136,7 @@ static void printValueAsXML(EvalState & state, bool strict, Value & v,
|
||||||
doc.writeEmptyElement("attr", singletonAttrs("name", i->name));
|
doc.writeEmptyElement("attr", singletonAttrs("name", i->name));
|
||||||
} else
|
} else
|
||||||
doc.writeEmptyElement("varpat", singletonAttrs("name", v.lambda.fun->arg));
|
doc.writeEmptyElement("varpat", singletonAttrs("name", v.lambda.fun->arg));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,13 +146,13 @@ static void printValueAsXML(EvalState & state, bool strict, Value & v,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void printValueAsXML(EvalState & state, bool strict,
|
void printValueAsXML(EvalState & state, bool strict, bool location,
|
||||||
Value & v, std::ostream & out, PathSet & context)
|
Value & v, std::ostream & out, PathSet & context)
|
||||||
{
|
{
|
||||||
XMLWriter doc(true, out);
|
XMLWriter doc(true, out);
|
||||||
XMLOpenElement root(doc, "expr");
|
XMLOpenElement root(doc, "expr");
|
||||||
PathSet drvsSeen;
|
PathSet drvsSeen;
|
||||||
printValueAsXML(state, strict, v, doc, context, drvsSeen);
|
printValueAsXML(state, strict, location, v, doc, context, drvsSeen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
void printValueAsXML(EvalState & state, bool strict,
|
void printValueAsXML(EvalState & state, bool strict, bool location,
|
||||||
Value & v, std::ostream & out, PathSet & context);
|
Value & v, std::ostream & out, PathSet & context);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,6 +91,7 @@ void XMLWriter::writeAttrs(const XMLAttrs & attrs)
|
||||||
char c = i->second[j];
|
char c = i->second[j];
|
||||||
if (c == '"') output << """;
|
if (c == '"') output << """;
|
||||||
else if (c == '<') output << "<";
|
else if (c == '<') output << "<";
|
||||||
|
else if (c == '>') output << ">";
|
||||||
else if (c == '&') output << "&";
|
else if (c == '&') output << "&";
|
||||||
/* Escape newlines to prevent attribute normalisation (see
|
/* Escape newlines to prevent attribute normalisation (see
|
||||||
XML spec, section 3.3.3. */
|
XML spec, section 3.3.3. */
|
||||||
|
|
|
@ -22,6 +22,8 @@ Options:
|
||||||
For --eval-only / --parse-only:
|
For --eval-only / --parse-only:
|
||||||
|
|
||||||
--xml: print an XML representation of the abstract syntax tree
|
--xml: print an XML representation of the abstract syntax tree
|
||||||
|
--no-location: don't provide source location information in the
|
||||||
|
output XML tree
|
||||||
|
|
||||||
For --eval-only:
|
For --eval-only:
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ static bool indirectRoot = false;
|
||||||
|
|
||||||
void processExpr(EvalState & state, const Strings & attrPaths,
|
void processExpr(EvalState & state, const Strings & attrPaths,
|
||||||
bool parseOnly, bool strict, const Bindings & autoArgs,
|
bool parseOnly, bool strict, const Bindings & autoArgs,
|
||||||
bool evalOnly, bool xmlOutput, Expr * e)
|
bool evalOnly, bool xmlOutput, bool location, Expr * e)
|
||||||
{
|
{
|
||||||
if (parseOnly)
|
if (parseOnly)
|
||||||
std::cout << format("%1%\n") % *e;
|
std::cout << format("%1%\n") % *e;
|
||||||
|
@ -52,7 +52,7 @@ void processExpr(EvalState & state, const Strings & attrPaths,
|
||||||
PathSet context;
|
PathSet context;
|
||||||
if (evalOnly)
|
if (evalOnly)
|
||||||
if (xmlOutput)
|
if (xmlOutput)
|
||||||
printValueAsXML(state, strict, v, std::cout, context);
|
printValueAsXML(state, strict, location, v, std::cout, context);
|
||||||
else {
|
else {
|
||||||
if (strict) state.strictForceValue(v);
|
if (strict) state.strictForceValue(v);
|
||||||
std::cout << v << std::endl;
|
std::cout << v << std::endl;
|
||||||
|
@ -83,6 +83,7 @@ void run(Strings args)
|
||||||
bool evalOnly = false;
|
bool evalOnly = false;
|
||||||
bool parseOnly = false;
|
bool parseOnly = false;
|
||||||
bool xmlOutput = false;
|
bool xmlOutput = false;
|
||||||
|
bool xmlOutputSourceLocation = true;
|
||||||
bool strict = false;
|
bool strict = false;
|
||||||
Strings attrPaths;
|
Strings attrPaths;
|
||||||
Bindings autoArgs;
|
Bindings autoArgs;
|
||||||
|
@ -116,6 +117,8 @@ void run(Strings args)
|
||||||
indirectRoot = true;
|
indirectRoot = true;
|
||||||
else if (arg == "--xml")
|
else if (arg == "--xml")
|
||||||
xmlOutput = true;
|
xmlOutput = true;
|
||||||
|
else if (arg == "--no-location")
|
||||||
|
xmlOutputSourceLocation = false;
|
||||||
else if (arg == "--strict")
|
else if (arg == "--strict")
|
||||||
strict = true;
|
strict = true;
|
||||||
else if (arg[0] == '-')
|
else if (arg[0] == '-')
|
||||||
|
@ -131,14 +134,14 @@ void run(Strings args)
|
||||||
if (readStdin) {
|
if (readStdin) {
|
||||||
Expr * e = parseStdin(state);
|
Expr * e = parseStdin(state);
|
||||||
processExpr(state, attrPaths, parseOnly, strict, autoArgs,
|
processExpr(state, attrPaths, parseOnly, strict, autoArgs,
|
||||||
evalOnly, xmlOutput, e);
|
evalOnly, xmlOutput, xmlOutputSourceLocation, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Strings::iterator, i, files) {
|
foreach (Strings::iterator, i, files) {
|
||||||
Path path = absPath(*i);
|
Path path = absPath(*i);
|
||||||
Expr * e = parseExprFromFile(state, path);
|
Expr * e = parseExprFromFile(state, path);
|
||||||
processExpr(state, attrPaths, parseOnly, strict, autoArgs,
|
processExpr(state, attrPaths, parseOnly, strict, autoArgs,
|
||||||
evalOnly, xmlOutput, e);
|
evalOnly, xmlOutput, xmlOutputSourceLocation, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
state.printStats();
|
state.printStats();
|
||||||
|
|
|
@ -50,7 +50,8 @@ for i in lang/eval-okay-*.nix; do
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -e lang/$i.exp.xml; then
|
if test -e lang/$i.exp.xml; then
|
||||||
if ! $nixinstantiate --eval-only --xml --strict lang/$i.nix > lang/$i.out.xml; then
|
if ! $nixinstantiate --eval-only --xml --no-location --strict \
|
||||||
|
lang/$i.nix > lang/$i.out.xml; then
|
||||||
echo "FAIL: $i should evaluate"
|
echo "FAIL: $i should evaluate"
|
||||||
fail=1
|
fail=1
|
||||||
elif ! cmp -s lang/$i.out.xml lang/$i.exp.xml; then
|
elif ! cmp -s lang/$i.out.xml lang/$i.exp.xml; then
|
||||||
|
|
1
tests/lang/eval-okay-toxml.exp
Normal file
1
tests/lang/eval-okay-toxml.exp
Normal file
|
@ -0,0 +1 @@
|
||||||
|
"<?xml version='1.0' encoding='utf-8'?>\n<expr>\n <attrs>\n <attr name=\"a\">\n <string value=\"s\" />\n </attr>\n </attrs>\n</expr>\n"
|
3
tests/lang/eval-okay-toxml.nix
Normal file
3
tests/lang/eval-okay-toxml.nix
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# Make sure the expected XML output is produced; in particular, make sure it
|
||||||
|
# doesn't contain source location information.
|
||||||
|
builtins.toXML { a = "s"; }
|
Loading…
Reference in a new issue