Add --flags=tracing, and document it in README.md
This commit is contained in:
parent
7188c71d0a
commit
92217059b5
16
README.md
16
README.md
|
@ -21,6 +21,21 @@ $ cabal test
|
||||||
$ LANGUAGE_TESTS=yes NIXPKGS_TESTS=yes cabal test
|
$ LANGUAGE_TESTS=yes NIXPKGS_TESTS=yes cabal test
|
||||||
$ ./dist/build/hnix/hnix --help
|
$ ./dist/build/hnix/hnix --help
|
||||||
```
|
```
|
||||||
|
## Building with full debug info
|
||||||
|
|
||||||
|
To build `hnix` for debugging, and with full tracing output and stack traces,
|
||||||
|
use:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ nix-shell --arg doProfiling true
|
||||||
|
$ cabal configure --enable-tests --enable-profiling --flags=tracing
|
||||||
|
$ cabal build
|
||||||
|
$ ./dist/build/hnix/hnix -v5 <args> +RTS -xc
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that this will run quite slowly, but will give the most information as to
|
||||||
|
what might potentially be going wrong during parsing or evaluation.
|
||||||
|
|
||||||
## Building with benchmarks enabled
|
## Building with benchmarks enabled
|
||||||
|
|
||||||
To build `hnix` with benchmarks enabled:
|
To build `hnix` with benchmarks enabled:
|
||||||
|
@ -32,7 +47,6 @@ $ cabal build
|
||||||
$ cabal bench
|
$ cabal bench
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Building with profiling enabled
|
## Building with profiling enabled
|
||||||
|
|
||||||
To build `hnix` with profiling enabled:
|
To build `hnix` with profiling enabled:
|
||||||
|
|
15
hnix.cabal
15
hnix.cabal
|
@ -2,7 +2,7 @@
|
||||||
--
|
--
|
||||||
-- see: https://github.com/sol/hpack
|
-- see: https://github.com/sol/hpack
|
||||||
--
|
--
|
||||||
-- hash: 7880788afb8b7755b22c9bd91a3c47598fe26b9a643b2bb55816331ae179aa50
|
-- hash: c030de7d44eabbd21ae044bd9108da5b34d7e3feaf8a8facbc9383c85e382186
|
||||||
|
|
||||||
name: hnix
|
name: hnix
|
||||||
version: 0.5.0
|
version: 0.5.0
|
||||||
|
@ -25,6 +25,11 @@ source-repository head
|
||||||
type: git
|
type: git
|
||||||
location: https://github.com/jwiegley/hnix
|
location: https://github.com/jwiegley/hnix
|
||||||
|
|
||||||
|
flag tracing
|
||||||
|
description: Enable full debug tracing
|
||||||
|
manual: True
|
||||||
|
default: False
|
||||||
|
|
||||||
library
|
library
|
||||||
exposed-modules:
|
exposed-modules:
|
||||||
Nix
|
Nix
|
||||||
|
@ -103,6 +108,8 @@ library
|
||||||
, unordered-containers >=0.2.9 && <0.3
|
, unordered-containers >=0.2.9 && <0.3
|
||||||
, vector
|
, vector
|
||||||
, xml
|
, xml
|
||||||
|
if flag(tracing)
|
||||||
|
cpp-options: -DENABLE_TRACING=1
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
||||||
executable hnix
|
executable hnix
|
||||||
|
@ -133,6 +140,8 @@ executable hnix
|
||||||
, text
|
, text
|
||||||
, transformers
|
, transformers
|
||||||
, unordered-containers >=0.2.9 && <0.3
|
, unordered-containers >=0.2.9 && <0.3
|
||||||
|
if flag(tracing)
|
||||||
|
cpp-options: -DENABLE_TRACING=1
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
||||||
test-suite hnix-tests
|
test-suite hnix-tests
|
||||||
|
@ -175,6 +184,8 @@ test-suite hnix-tests
|
||||||
, transformers
|
, transformers
|
||||||
, unix
|
, unix
|
||||||
, unordered-containers >=0.2.9 && <0.3
|
, unordered-containers >=0.2.9 && <0.3
|
||||||
|
if flag(tracing)
|
||||||
|
cpp-options: -DENABLE_TRACING=1
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
||||||
benchmark hnix-benchmarks
|
benchmark hnix-benchmarks
|
||||||
|
@ -205,4 +216,6 @@ benchmark hnix-benchmarks
|
||||||
, text
|
, text
|
||||||
, transformers
|
, transformers
|
||||||
, unordered-containers >=0.2.9 && <0.3
|
, unordered-containers >=0.2.9 && <0.3
|
||||||
|
if flag(tracing)
|
||||||
|
cpp-options: -DENABLE_TRACING=1
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
10
package.yaml
10
package.yaml
|
@ -36,6 +36,16 @@ ghc-options:
|
||||||
# - -fexpose-all-unfoldings
|
# - -fexpose-all-unfoldings
|
||||||
# - -O2
|
# - -O2
|
||||||
|
|
||||||
|
flags:
|
||||||
|
tracing:
|
||||||
|
description: Enable full debug tracing
|
||||||
|
manual: True
|
||||||
|
default: False
|
||||||
|
|
||||||
|
when:
|
||||||
|
- condition: flag(tracing)
|
||||||
|
cpp-options: -DENABLE_TRACING=1
|
||||||
|
|
||||||
library:
|
library:
|
||||||
source-dirs: src
|
source-dirs: src
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
{-# LANGUAGE FlexibleInstances #-}
|
{-# LANGUAGE FlexibleInstances #-}
|
||||||
{-# LANGUAGE RankNTypes #-}
|
{-# LANGUAGE RankNTypes #-}
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
@ -25,7 +26,11 @@ import Nix.Parser.Library (reservedNames)
|
||||||
import Nix.Parser.Operators
|
import Nix.Parser.Operators
|
||||||
import Nix.StringOperations
|
import Nix.StringOperations
|
||||||
import Nix.Thunk
|
import Nix.Thunk
|
||||||
|
#if ENABLE_TRACING
|
||||||
|
import Nix.Utils
|
||||||
|
#else
|
||||||
import Nix.Utils hiding ((<$>))
|
import Nix.Utils hiding ((<$>))
|
||||||
|
#endif
|
||||||
import Nix.Value
|
import Nix.Value
|
||||||
import Prelude hiding ((<$>))
|
import Prelude hiding ((<$>))
|
||||||
import Text.PrettyPrint.ANSI.Leijen
|
import Text.PrettyPrint.ANSI.Leijen
|
||||||
|
|
|
@ -55,7 +55,7 @@ valueRef = Value
|
||||||
buildThunk :: MonadVar m => m v -> m (Thunk m v)
|
buildThunk :: MonadVar m => m v -> m (Thunk m v)
|
||||||
buildThunk action =
|
buildThunk action =
|
||||||
#if ENABLE_TRACING
|
#if ENABLE_TRACING
|
||||||
let !x = unsafePerformIO (atomicModifyIORef' counter (\x -> (succ x, x))) in
|
let !x = unsafePerformIO (atomicModifyIORef' counter (\c -> (succ c, c))) in
|
||||||
Thunk x
|
Thunk x
|
||||||
#else
|
#else
|
||||||
Thunk
|
Thunk
|
||||||
|
|
Loading…
Reference in a new issue