Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,7 @@ jobs:
${{ runner.os }}-cabal-${{ matrix.ghc }}-
- name: Update Cabal package index
run: cabal update
- name: Configure project
run: |
cabal configure --enable-tests --flags=dump-ast --ghc-options="-Werror"
- name: Build project (GHC ${{ steps.setup-ghc.outputs.ghc-version }})
run: cabal build all
run: cabal build --project-file cabal.project.ci all
- name: Run tests (GHC ${{ steps.setup-ghc.outputs.ghc-version }})
run: cabal test --test-show-details=direct all
run: cabal test --project-file cabal.project.ci --test-show-details=direct all
8 changes: 2 additions & 6 deletions .github/workflows/future-proofing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ jobs:
}}
restore-keys: |
${{ runner.os }}-cabal-${{ steps.get-ghc.outputs.ghc-version }}-
- name: Configure project
shell: bash
run: |
cabal configure --enable-tests --flags=dump-ast --ghc-options="-Werror"
- name: Build project (GHC latest)
run: cabal build all
run: cabal build --project-file cabal.project.ci all
- name: Run tests (GHC latest)
run: cabal test --test-show-details=direct all
run: cabal test --project-file cabal.project.ci --test-show-details=direct all
16 changes: 14 additions & 2 deletions app/Main.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# LANGUAGE CPP #-}

module Main (
main,
) where
Expand All @@ -13,7 +15,10 @@ import IOUtils
import Parsing.Jbeam (parseNodes)
import System.Directory (copyFile)
import System.Environment (getArgs)

#ifdef ENABLE_TRANSFORMATION
import Transformation (transform)
#endif

import Data.ByteString.Lazy qualified as BL (
toStrict,
Expand Down Expand Up @@ -53,5 +58,12 @@ processNodes outFile nodes formattingConfig =
. encodeUtf8
. TL.fromStrict
. formatNode formattingConfig newCursor
. transform
$ nodes
$ applyTransform nodes

#ifdef ENABLE_TRANSFORMATION
applyTransform :: Node -> Node
applyTransform = transform
#else
applyTransform :: Node -> Node
applyTransform = id
#endif
8 changes: 8 additions & 0 deletions cabal.project.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
packages: .
tests: True

program-options
ghc-options: -Werror

package jbeam-edit
flags: +dump-ast +transformation
2 changes: 1 addition & 1 deletion cabal.project.dev
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ package *
ghc-options: -haddock

package jbeam-edit
flags: +dump-ast
flags: +dump-ast +transformation
13 changes: 12 additions & 1 deletion jbeam-edit.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ flag dump-ast
manual: True
default: False

flag transformation
description: Enable transformation (experimental)
manual: True
default: False

library
exposed-modules:
CommandLineOptions
Expand All @@ -46,7 +51,6 @@ library
Parsing.Common.Helpers
Parsing.DSL
Parsing.Jbeam
Transformation
other-modules:
Paths_jbeam_edit
autogen-modules:
Expand All @@ -69,6 +73,11 @@ library
, text >=2.0
, vector
default-language: Haskell2010
if flag(transformation)
exposed-modules:
Transformation
hs-source-dirs:
src-extra/transformation

executable jbeam-edit
main-is: Main.hs
Expand All @@ -95,6 +104,8 @@ executable jbeam-edit
, text >=2.0
, vector
default-language: Haskell2010
if flag(transformation)
cpp-options: -DENABLE_TRANSFORMATION

executable jbeam-edit-dump-ast
main-is: Main.hs
Expand Down
11 changes: 11 additions & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,30 @@ ghc-options:
library:
source-dirs: src
generated-other-modules: Paths_jbeam_edit
when:
condition: flag(transformation)
source-dirs: [src-extra/transformation]
exposed-modules: [Transformation]

flags:
dump-ast:
description: Enable building the dump-ast executable
manual: true
default: false
transformation:
description: Enable transformation (experimental)
manual: true
default: false

executables:
jbeam-edit:
main: Main.hs
source-dirs: app
ghc-options: [-threaded, -rtsopts, -with-rtsopts=-N]
dependencies: [jbeam-edit]
when:
condition: flag(transformation)
cpp-options: -DENABLE_TRANSFORMATION
jbeam-edit-dump-ast:
when:
condition: flag(dump-ast)
Expand Down
File renamed without changes.
Loading