Skip to content

Commit

Permalink
Added flag for wasm build
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharad committed Nov 13, 2024
1 parent 2258aeb commit ff91869
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ CREATE TABLE tasks (
3. Build the binary for linux:

```bash
stack build :sql2er-exe
stack build
cp $(stack path --local-install-root)/bin/sql2er-exe .
./sql2er-exe test.sql -o erd.svg
```
Expand All @@ -104,7 +104,7 @@ CREATE TABLE tasks (
2. Make sure to download the `9.8` `FLAVOUR`.

```bash
wasm32-wasi-cabal build sql2er-wasm
wasm32-wasi-cabal build sql2er-wasm -f build-sql2er-wasm
cp path/to/sql2er-wasm.wasm .
python3 -m http.server
```
Expand Down
12 changes: 12 additions & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ library:
default-extensions:
- ImportQualifiedPost

flags:
build-sql2er-wasm:
description: Build the sql2er WASM app
manual: true
default: false

executables:
sql2er-exe:
main: Main.hs
Expand All @@ -63,6 +69,12 @@ executables:
- "-optl-Wl,--export=hs_init,--export=hs_runWorker,--export=freeBuffer,--export=callocBuffer"
dependencies:
- sql2er
when:
- condition: flag(build-sql2er-wasm)
then:
buildable: true
else:
buildable: false

tests:
sql2er-test:
Expand Down
9 changes: 9 additions & 0 deletions sql2er.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ source-repository head
type: git
location: https://github.com/tusharad/sql2er

flag build-sql2er-wasm
description: Build the sql2er WASM app
manual: True
default: False

library
exposed-modules:
Sql2er.CmdArgs
Expand Down Expand Up @@ -83,6 +88,10 @@ executable sql2er-wasm
, sql2er
, text
default-language: Haskell2010
if flag(build-sql2er-wasm)
buildable: True
else
buildable: False

test-suite sql2er-test
type: exitcode-stdio-1.0
Expand Down
1 change: 0 additions & 1 deletion src/Sql2er/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module Sql2er.Parser (parseSql, parseSqlScript, parseScript, postParsingSetup) w

import Data.List (find)
import Data.Maybe
import Data.Text (Text)
import Data.Text qualified as T
import Sql2er.Common.Types
import Sql2er.Common.Utils (ignoreStatement, lexeme)
Expand Down
2 changes: 1 addition & 1 deletion test/ExamplesForTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ tableConstraint =
, tableConstraints =
[ UniqueConstraint ["z"]
, PrimaryKeyConstraint "y"
, ForeignKeyConstraint "z" "sometable" (Just "z")
, ForeignKeyConstraint "sometable" "z" (Just "z")
, CheckConstraint "z > 23"
, UniqueConstraint ["y", "z"]
]
Expand Down

0 comments on commit ff91869

Please sign in to comment.