From 13cce8ec45fd59bd8a1f1101a92576796cba97d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Thu, 11 Mar 2010 20:56:25 +0000 Subject: [PATCH 01/15] Making 'bin2c' to be built with the compiler for the local system. I copied the configure.ac code about CC_FOR_BUILD from libX11. --- configure.ac | 9 +++++++++ src/bin2c/Makefile.am | 3 +++ 2 files changed, 12 insertions(+) diff --git a/configure.ac b/configure.ac index 708e619684..4c92bcb5c3 100644 --- a/configure.ac +++ b/configure.ac @@ -86,6 +86,15 @@ fi AC_PROG_CC AC_PROG_CXX +# To build programs to be run in the build machine +if test "$CC_FOR_BUILD" = ""; then + if test "$cross_compiling" = "yes"; then + AC_CHECK_PROGS(CC_FOR_BUILD, gcc cc) + else + CC_FOR_BUILD="$CC" + fi +fi +AC_SUBST([CC_FOR_BUILD]) # We are going to use libtool. AC_DISABLE_STATIC diff --git a/src/bin2c/Makefile.am b/src/bin2c/Makefile.am index bdd58808a1..f5f118d052 100644 --- a/src/bin2c/Makefile.am +++ b/src/bin2c/Makefile.am @@ -1,3 +1,6 @@ noinst_PROGRAMS = bin2c bin2c_SOURCES = bin2c.c + +bin2c: bin2c.c + $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) -o bin2c bin2c.c From 2fb0df83e960d6b39dd43b47cc6168cad3732746 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Thu, 11 Mar 2010 21:22:52 +0000 Subject: [PATCH 02/15] Uh. somehow a Makefile tab got in as spaces. Fixing. --- src/bin2c/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin2c/Makefile.am b/src/bin2c/Makefile.am index f5f118d052..2245ff3a26 100644 --- a/src/bin2c/Makefile.am +++ b/src/bin2c/Makefile.am @@ -3,4 +3,4 @@ noinst_PROGRAMS = bin2c bin2c_SOURCES = bin2c.c bin2c: bin2c.c - $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) -o bin2c bin2c.c + $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) -o bin2c bin2c.c From 741b7577c14911fed71b6d52d8d90e88ef2e05ef Mon Sep 17 00:00:00 2001 From: Nicolas Pierron Date: Sun, 14 Mar 2010 11:58:07 +0000 Subject: [PATCH 03/15] Merge r20344 & r20346. --- src/aterm-helper.pl | 5 +++-- src/libexpr/parser.y | 8 +++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/aterm-helper.pl b/src/aterm-helper.pl index 9b2bde7000..f1eb77ee80 100755 --- a/src/aterm-helper.pl +++ b/src/aterm-helper.pl @@ -146,8 +146,9 @@ while () { my $value = $2; print HEADER "extern ATerm $name;\n"; print IMPL "ATerm $name = 0;\n"; - $init .= " $name = $value;\n"; - } + $init .= " $name = $value;\n"; + $init .= " ATprotect(&$name);\n"; + } elsif (/^\s*init\s+(\w+)\s*$/) { $initFun = $1; diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index c4afb72eac..8706ce0254 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -85,6 +85,10 @@ static Expr fixAttrs(bool recursive, ATermList as) { Tree attrs; + /* This ATermMap is needed to ensure that the `leaf' fields in the + Tree nodes are not garbage collected. */ + ATermMap gcRoots; + for (ATermIterator i(as); i; ++i) { ATermList names, attrPath; Expr src, e; ATerm name, pos; @@ -95,7 +99,9 @@ static Expr fixAttrs(bool recursive, ATermList as) throw ParseError(format("duplicate definition of attribute `%1%' at %2%") % showAttrPath(ATmakeList1(*j)) % showPos(pos)); Tree & t(attrs.children[*j]); - t.leaf = fromScope ? makeVar(*j) : makeSelect(src, *j); + Expr leaf = fromScope ? makeVar(*j) : makeSelect(src, *j); + gcRoots.set(leaf, leaf); + t.leaf = leaf; t.pos = pos; if (recursive && fromScope) t.recursive = false; } From fe1b8781ae310bfa6baea80ed475b6c3ae00d991 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 16 Mar 2010 12:58:20 +0000 Subject: [PATCH 04/15] * Fix a broken link (reported by Peter Koppstein). --- doc/manual/package-management.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual/package-management.xml b/doc/manual/package-management.xml index fa40af2ef7..8cc6aa857e 100644 --- a/doc/manual/package-management.xml +++ b/doc/manual/package-management.xml @@ -38,7 +38,7 @@ to end-user applications like Mozilla Firefox. (Nix is however not tied to the Nix Package collection; you could write your own Nix expressions based on it, or completely new ones.) You can download the latest version from . +xlink:href='http://nixos.org/nixpkgs/download.html' />. Assuming that you have downloaded and unpacked a release of Nix Packages, you can view the set of available packages in the release: From f0c473c5f70b8d6dc072da3d6d53a898766546a2 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 16 Mar 2010 13:01:52 +0000 Subject: [PATCH 05/15] * Fix building on Cygwin (http://hydra.nixos.org/build/325071). --- src/bin2c/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin2c/Makefile.am b/src/bin2c/Makefile.am index 2245ff3a26..bba3c3e3ac 100644 --- a/src/bin2c/Makefile.am +++ b/src/bin2c/Makefile.am @@ -2,5 +2,5 @@ noinst_PROGRAMS = bin2c bin2c_SOURCES = bin2c.c -bin2c: bin2c.c +bin2c$(EXEEXT): bin2c.c $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) -o bin2c bin2c.c From 8e3d98eb41ab0516814fa34cba6198d2472bdd3e Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 16 Mar 2010 13:12:18 +0000 Subject: [PATCH 06/15] * Release notes for Nix 0.15. --- doc/manual/release-notes.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/manual/release-notes.xml b/doc/manual/release-notes.xml index 907d6dc7c9..08dc884970 100644 --- a/doc/manual/release-notes.xml +++ b/doc/manual/release-notes.xml @@ -6,6 +6,18 @@ + + +
Release 0.15 (March 16, 2010) + +This is a bug-fix release. Among other things, it fixes +building on Mac OS X (Snow Leopard), and improves the contents of +/etc/passwd and /etc/group +in chroot builds. + +
+ +
Release 0.14 (February 4, 2010) From c4cfb392d381dd68122d0fcbba71e192d0d11690 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 17 Mar 2010 10:08:34 +0000 Subject: [PATCH 07/15] --- doc/manual/release-notes.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual/release-notes.xml b/doc/manual/release-notes.xml index 08dc884970..e795634404 100644 --- a/doc/manual/release-notes.xml +++ b/doc/manual/release-notes.xml @@ -8,7 +8,7 @@ -
Release 0.15 (March 16, 2010) +
Release 0.15 (March 17, 2010) This is a bug-fix release. Among other things, it fixes building on Mac OS X (Snow Leopard), and improves the contents of From 74299c1cfb770fee1860e62701cd093faffa0119 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 17 Mar 2010 12:12:45 +0000 Subject: [PATCH 08/15] * Bump version number. --- version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version b/version index 20adfac7f5..a59ac46083 100644 --- a/version +++ b/version @@ -1 +1 @@ -0.15 \ No newline at end of file +0.16 \ No newline at end of file From 141294ff38fb3623ae24c2d47cf0c3180cc363d3 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 19 Mar 2010 11:36:34 +0000 Subject: [PATCH 09/15] * Clean up error messages in killUser(). --- src/libutil/util.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/libutil/util.cc b/src/libutil/util.cc index eec60867df..790c257680 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -810,7 +810,8 @@ void killUser(uid_t uid) case 0: try { /* child */ - if (setuid(uid) == -1) abort(); + if (setuid(uid) == -1) + throw SysError("setting uid"); while (true) { if (kill(-1, SIGKILL) == 0) break; @@ -820,7 +821,7 @@ void killUser(uid_t uid) } } catch (std::exception & e) { - std::cerr << format("killing processes beloging to uid `%1%': %1%") + std::cerr << format("killing processes belonging to uid `%1%': %2%") % uid % e.what() << std::endl; quickExit(1); } @@ -828,8 +829,9 @@ void killUser(uid_t uid) } /* parent */ - if (pid.wait(true) != 0) - throw Error(format("cannot kill processes for uid `%1%'") % uid); + int status = pid.wait(true); + if (status != 0) + throw Error(format("cannot kill processes for uid `%1%': %2%") % uid % statusToString(status)); /* !!! We should really do some check to make sure that there are no processes left running under `uid', but there is no portable From 3bfd3a4e9511e16d8a826cb271fc95acc2fb9845 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 23 Mar 2010 14:26:27 +0000 Subject: [PATCH 10/15] * Test "with as; with bs;" since nobody knows what its semantics is. --- tests/lang/eval-okay-with.exp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tests/lang/eval-okay-with.exp b/tests/lang/eval-okay-with.exp index 31e24293be..033e8d3aba 100644 --- a/tests/lang/eval-okay-with.exp +++ b/tests/lang/eval-okay-with.exp @@ -1 +1,19 @@ -Str("xyzzybar",[]) +let { + + a = "xyzzy"; + + as = { + a = "foo"; + b = "bar"; + }; + + bs = { + a = "bar"; + }; + + x = with as; a + b; + + y = with as; with bs; a + b; + + body = x + y; +} From 71be50cc25544f742db2275b4621b92c4e938400 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 23 Mar 2010 14:51:32 +0000 Subject: [PATCH 11/15] * Doh. --- tests/lang/eval-okay-with.exp | 20 +------------------- tests/lang/eval-okay-with.nix | 8 +++++++- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/tests/lang/eval-okay-with.exp b/tests/lang/eval-okay-with.exp index 033e8d3aba..2c9bd8ba0e 100644 --- a/tests/lang/eval-okay-with.exp +++ b/tests/lang/eval-okay-with.exp @@ -1,19 +1 @@ -let { - - a = "xyzzy"; - - as = { - a = "foo"; - b = "bar"; - }; - - bs = { - a = "bar"; - }; - - x = with as; a + b; - - y = with as; with bs; a + b; - - body = x + y; -} +Str("xyzzybarxyzzybar",[]) diff --git a/tests/lang/eval-okay-with.nix b/tests/lang/eval-okay-with.nix index ea4ea612de..033e8d3aba 100644 --- a/tests/lang/eval-okay-with.nix +++ b/tests/lang/eval-okay-with.nix @@ -7,7 +7,13 @@ let { b = "bar"; }; + bs = { + a = "bar"; + }; + x = with as; a + b; - body = x; + y = with as; with bs; a + b; + + body = x + y; } From eb07a4f1ee532833407b40a9992bfe65c8a4d1d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 31 Mar 2010 08:29:01 +0000 Subject: [PATCH 12/15] Escape `>' signs in the XML output. * src/libutil/xml-writer.cc (nix::XMLWriter::writeAttrs): Escape `>'. --- src/libutil/xml-writer.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libutil/xml-writer.cc b/src/libutil/xml-writer.cc index 20351e2c30..7d698bf6ae 100644 --- a/src/libutil/xml-writer.cc +++ b/src/libutil/xml-writer.cc @@ -91,6 +91,7 @@ void XMLWriter::writeAttrs(const XMLAttrs & attrs) char c = i->second[j]; if (c == '"') output << """; else if (c == '<') output << "<"; + else if (c == '>') output << ">"; else if (c == '&') output << "&"; /* Escape newlines to prevent attribute normalisation (see XML spec, section 3.3.3. */ From 471419d1fac21412dea9a47eff200d44cd75d825 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 31 Mar 2010 08:29:05 +0000 Subject: [PATCH 13/15] Add source location information to the XML output. * src/libexpr/expr-to-xml.cc (nix::showAttrs): Dereference the attribute RHS. Add "path", "line", and "column" XML attributes to the node when source location information is available. (nix::printTermAsXML): Likewise for functions. --- src/libexpr/expr-to-xml.cc | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/src/libexpr/expr-to-xml.cc b/src/libexpr/expr-to-xml.cc index e401001ead..4ca71c8890 100644 --- a/src/libexpr/expr-to-xml.cc +++ b/src/libexpr/expr-to-xml.cc @@ -34,8 +34,25 @@ static void showAttrs(const ATermMap & attrs, XMLWriter & doc, for (ATermMap::const_iterator i = attrs.begin(); i != attrs.end(); ++i) names.insert(aterm2String(i->key)); for (StringSet::iterator i = names.begin(); i != names.end(); ++i) { - XMLOpenElement _(doc, "attr", singletonAttrs("name", *i)); - printTermAsXML(attrs.get(toATerm(*i)), doc, context, drvsSeen); + ATerm attrRHS = attrs.get(toATerm(*i)); + ATerm attr; + Pos pos; + XMLAttrs xmlAttrs; + + xmlAttrs["name"] = *i; + if(matchAttrRHS(attrRHS, attr, pos)) { + ATerm path; + int line, column; + if (matchPos(pos, path, line, column)) { + xmlAttrs["path"] = aterm2String(path); + xmlAttrs["line"] = (format("%1%") % line).str(); + xmlAttrs["column"] = (format("%1%") % column).str(); + } + } else + abort(); // Should not happen. + + XMLOpenElement _(doc, "attr", xmlAttrs); + printTermAsXML(attr, doc, context, drvsSeen); } } @@ -97,9 +114,12 @@ static void printTermAsXML(Expr e, XMLWriter & doc, PathSet & context, else if (matchAttrs(e, as)) { ATermMap attrs; - queryAllAttrs(e, attrs); + queryAllAttrs(e, attrs, true); - Expr a = attrs.get(toATerm("type")); + Expr aRHS = attrs.get(toATerm("type")); + Expr a = NULL; + if (aRHS) + matchAttrRHS(aRHS, a, pos); if (a && matchStr(a, s, context) && s == "derivation") { XMLAttrs xmlAttrs; @@ -135,7 +155,15 @@ static void printTermAsXML(Expr e, XMLWriter & doc, PathSet & context, } else if (matchFunction(e, pat, body, pos)) { - XMLOpenElement _(doc, "function"); + ATerm path; + int line, column; + XMLAttrs xmlAttrs; + if (matchPos(pos, path, line, column)) { + xmlAttrs["path"] = aterm2String(path); + xmlAttrs["line"] = (format("%1%") % line).str(); + xmlAttrs["column"] = (format("%1%") % column).str(); + } + XMLOpenElement _(doc, "function", xmlAttrs); printPatternAsXML(pat, doc); } From 09381cccffe675ccbc8d183f043788f99dc018cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 31 Mar 2010 12:38:31 +0000 Subject: [PATCH 14/15] Make source location info in the XML output optional. * src/libexpr/expr-to-xml.cc (nix::showAttrs): Add `location' parameter. Provide location XML attributes when it's true. Update callers. (nix::printTermAsXML): Likewise. * src/libexpr/expr-to-xml.hh (nix::printTermAsXML): Update prototype; have `location' default to `false'. * src/nix-instantiate/nix-instantiate.cc (printResult, processExpr): Add `location' parameter; update callers. (run): Add support for `--no-location'. * src/nix-instantiate/help.txt: Update accordingly. * tests/lang.sh: Invoke `nix-instantiate' with `--no-location' for the XML tests. * tests/lang/eval-okay-toxml.exp, tests/lang/eval-okay-to-xml.nix: New files. --- src/libexpr/expr-to-xml.cc | 22 +++++++++++----------- src/libexpr/expr-to-xml.hh | 2 +- src/nix-instantiate/help.txt | 2 ++ src/nix-instantiate/nix-instantiate.cc | 15 +++++++++------ tests/lang.sh | 3 ++- tests/lang/eval-okay-toxml.exp | 1 + tests/lang/eval-okay-toxml.nix | 3 +++ 7 files changed, 29 insertions(+), 19 deletions(-) create mode 100644 tests/lang/eval-okay-toxml.exp create mode 100644 tests/lang/eval-okay-toxml.nix diff --git a/src/libexpr/expr-to-xml.cc b/src/libexpr/expr-to-xml.cc index 4ca71c8890..5857537d75 100644 --- a/src/libexpr/expr-to-xml.cc +++ b/src/libexpr/expr-to-xml.cc @@ -24,11 +24,11 @@ typedef set ExprSet; static void printTermAsXML(Expr e, XMLWriter & doc, PathSet & context, - ExprSet & drvsSeen); + ExprSet & drvsSeen, bool location); static void showAttrs(const ATermMap & attrs, XMLWriter & doc, - PathSet & context, ExprSet & drvsSeen) + PathSet & context, ExprSet & drvsSeen, bool location) { StringSet names; for (ATermMap::const_iterator i = attrs.begin(); i != attrs.end(); ++i) @@ -43,7 +43,7 @@ static void showAttrs(const ATermMap & attrs, XMLWriter & doc, if(matchAttrRHS(attrRHS, attr, pos)) { ATerm path; int line, column; - if (matchPos(pos, path, line, column)) { + if (location && matchPos(pos, path, line, column)) { xmlAttrs["path"] = aterm2String(path); xmlAttrs["line"] = (format("%1%") % line).str(); xmlAttrs["column"] = (format("%1%") % column).str(); @@ -52,7 +52,7 @@ static void showAttrs(const ATermMap & attrs, XMLWriter & doc, abort(); // Should not happen. XMLOpenElement _(doc, "attr", xmlAttrs); - printTermAsXML(attr, doc, context, drvsSeen); + printTermAsXML(attr, doc, context, drvsSeen, location); } } @@ -83,7 +83,7 @@ static void printPatternAsXML(Pattern pat, XMLWriter & doc) static void printTermAsXML(Expr e, XMLWriter & doc, PathSet & context, - ExprSet & drvsSeen) + ExprSet & drvsSeen, bool location) { XMLAttrs attrs; string s; @@ -137,28 +137,28 @@ static void printTermAsXML(Expr e, XMLWriter & doc, PathSet & context, if (drvsSeen.find(e) == drvsSeen.end()) { drvsSeen.insert(e); - showAttrs(attrs, doc, context, drvsSeen); + showAttrs(attrs, doc, context, drvsSeen, location); } else doc.writeEmptyElement("repeated"); } else { XMLOpenElement _(doc, "attrs"); - showAttrs(attrs, doc, context, drvsSeen); + showAttrs(attrs, doc, context, drvsSeen, location); } } else if (matchList(e, es)) { XMLOpenElement _(doc, "list"); for (ATermIterator i(es); i; ++i) - printTermAsXML(*i, doc, context, drvsSeen); + printTermAsXML(*i, doc, context, drvsSeen, location); } else if (matchFunction(e, pat, body, pos)) { ATerm path; int line, column; XMLAttrs xmlAttrs; - if (matchPos(pos, path, line, column)) { + if (location && matchPos(pos, path, line, column)) { xmlAttrs["path"] = aterm2String(path); xmlAttrs["line"] = (format("%1%") % line).str(); xmlAttrs["column"] = (format("%1%") % column).str(); @@ -172,12 +172,12 @@ static void printTermAsXML(Expr e, XMLWriter & doc, PathSet & context, } -void printTermAsXML(Expr e, std::ostream & out, PathSet & context) +void printTermAsXML(Expr e, std::ostream & out, PathSet & context, bool location) { XMLWriter doc(true, out); XMLOpenElement root(doc, "expr"); ExprSet drvsSeen; - printTermAsXML(e, doc, context, drvsSeen); + printTermAsXML(e, doc, context, drvsSeen, location); } diff --git a/src/libexpr/expr-to-xml.hh b/src/libexpr/expr-to-xml.hh index 36b8e40424..de9d55f320 100644 --- a/src/libexpr/expr-to-xml.hh +++ b/src/libexpr/expr-to-xml.hh @@ -9,7 +9,7 @@ namespace nix { -void printTermAsXML(Expr e, std::ostream & out, PathSet & context); +void printTermAsXML(Expr e, std::ostream & out, PathSet & context, bool location = false); } diff --git a/src/nix-instantiate/help.txt b/src/nix-instantiate/help.txt index fa0a4590ee..21822132ae 100644 --- a/src/nix-instantiate/help.txt +++ b/src/nix-instantiate/help.txt @@ -22,6 +22,8 @@ Options: For --eval-only / --parse-only: --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: diff --git a/src/nix-instantiate/nix-instantiate.cc b/src/nix-instantiate/nix-instantiate.cc index 3822de5c62..21f352f258 100644 --- a/src/nix-instantiate/nix-instantiate.cc +++ b/src/nix-instantiate/nix-instantiate.cc @@ -38,13 +38,13 @@ static bool indirectRoot = false; static void printResult(EvalState & state, Expr e, - bool evalOnly, bool xmlOutput, const ATermMap & autoArgs) + bool evalOnly, bool xmlOutput, bool location, const ATermMap & autoArgs) { PathSet context; if (evalOnly) if (xmlOutput) - printTermAsXML(e, std::cout, context); + printTermAsXML(e, std::cout, context, location); else std::cout << format("%1%\n") % canonicaliseExpr(e); @@ -67,7 +67,7 @@ static void printResult(EvalState & state, Expr e, void processExpr(EvalState & state, const Strings & attrPaths, bool parseOnly, bool strict, const ATermMap & autoArgs, - bool evalOnly, bool xmlOutput, Expr e) + bool evalOnly, bool xmlOutput, bool location, Expr e) { for (Strings::const_iterator i = attrPaths.begin(); i != attrPaths.end(); ++i) { Expr e2 = findAlongAttrPath(state, *i, autoArgs, e); @@ -76,7 +76,7 @@ void processExpr(EvalState & state, const Strings & attrPaths, e2 = strictEvalExpr(state, e2); else e2 = evalExpr(state, e2); - printResult(state, e2, evalOnly, xmlOutput, autoArgs); + printResult(state, e2, evalOnly, xmlOutput, location, autoArgs); } } @@ -89,6 +89,7 @@ void run(Strings args) bool evalOnly = false; bool parseOnly = false; bool xmlOutput = false; + bool xmlOutputSourceLocation = true; bool strict = false; Strings attrPaths; ATermMap autoArgs(128); @@ -124,6 +125,8 @@ void run(Strings args) indirectRoot = true; else if (arg == "--xml") xmlOutput = true; + else if (arg == "--no-location") + xmlOutputSourceLocation = false; else if (arg == "--strict") strict = true; else if (arg[0] == '-') @@ -139,7 +142,7 @@ void run(Strings args) if (readStdin) { Expr e = parseStdin(state); processExpr(state, attrPaths, parseOnly, strict, autoArgs, - evalOnly, xmlOutput, e); + evalOnly, xmlOutput, xmlOutputSourceLocation, e); } for (Strings::iterator i = files.begin(); @@ -148,7 +151,7 @@ void run(Strings args) Path path = absPath(*i); Expr e = parseExprFromFile(state, path); processExpr(state, attrPaths, parseOnly, strict, autoArgs, - evalOnly, xmlOutput, e); + evalOnly, xmlOutput, xmlOutputSourceLocation, e); } printEvalStats(state); diff --git a/tests/lang.sh b/tests/lang.sh index 18eb0278cf..54f0107637 100644 --- a/tests/lang.sh +++ b/tests/lang.sh @@ -54,7 +54,8 @@ for i in lang/eval-okay-*.nix; do fi 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" fail=1 elif ! cmp -s lang/$i.out.xml lang/$i.exp.xml; then diff --git a/tests/lang/eval-okay-toxml.exp b/tests/lang/eval-okay-toxml.exp new file mode 100644 index 0000000000..379f3c0761 --- /dev/null +++ b/tests/lang/eval-okay-toxml.exp @@ -0,0 +1 @@ +Str("\n\n \n \n \n \n \n\n",[]) diff --git a/tests/lang/eval-okay-toxml.nix b/tests/lang/eval-okay-toxml.nix new file mode 100644 index 0000000000..068c97a6c1 --- /dev/null +++ b/tests/lang/eval-okay-toxml.nix @@ -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"; } From aac5fcfbb54ff64c593d8919f7f52025415ea996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Fri, 9 Apr 2010 21:30:55 +0000 Subject: [PATCH 15/15] Re-add `drvPath' and `outPath' attributes to XML nodes. This fixes a regression introduced in r20882 ("Add source location information to the XML output."). * src/libexpr/expr-to-xml.cc (nix::printTermAsXML): Dereference the attribute RHS from "drvPath" and "outPath". --- src/libexpr/expr-to-xml.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/libexpr/expr-to-xml.cc b/src/libexpr/expr-to-xml.cc index 5857537d75..1e59eebfc4 100644 --- a/src/libexpr/expr-to-xml.cc +++ b/src/libexpr/expr-to-xml.cc @@ -124,15 +124,17 @@ static void printTermAsXML(Expr e, XMLWriter & doc, PathSet & context, XMLAttrs xmlAttrs; Path outPath, drvPath; - - a = attrs.get(toATerm("drvPath")); + + aRHS = attrs.get(toATerm("drvPath")); + matchAttrRHS(aRHS, a, pos); if (matchStr(a, drvPath, context)) xmlAttrs["drvPath"] = drvPath; - - a = attrs.get(toATerm("outPath")); + + aRHS = attrs.get(toATerm("outPath")); + matchAttrRHS(aRHS, a, pos); if (matchStr(a, outPath, context)) xmlAttrs["outPath"] = outPath; - + XMLOpenElement _(doc, "derivation", xmlAttrs); if (drvsSeen.find(e) == drvsSeen.end()) {