File tree 11 files changed +85
-0
lines changed
Cabal-syntax/src/Distribution/PackageDescription
cabal-testsuite/PackageTests/JS/JsOptions
11 files changed +85
-0
lines changed Original file line number Diff line number Diff line change @@ -622,6 +622,7 @@ buildInfoFieldGrammar =
622
622
<*> monoidalFieldAla " cxx-options" (alaList' NoCommaFSep Token' ) L. cxxOptions
623
623
^^^ availableSince CabalSpecV2_2 []
624
624
<*> monoidalFieldAla " js-options" (alaList' NoCommaFSep Token' ) L. jsOptions
625
+ ^^^ availableSince CabalSpecV3_14 []
625
626
<*> monoidalFieldAla " ld-options" (alaList' NoCommaFSep Token' ) L. ldOptions
626
627
<*> monoidalFieldAla " hsc2hs-options" (alaList' NoCommaFSep Token' ) L. hsc2hsOptions
627
628
^^^ availableSince CabalSpecV3_6 []
Original file line number Diff line number Diff line change
1
+ packages : .
Original file line number Diff line number Diff line change
1
+ module Main where
2
+
3
+ import Lib
4
+
5
+ main :: IO ()
6
+ main = foo
Original file line number Diff line number Diff line change
1
+ import Test.Cabal.Prelude
2
+
3
+ main = do
4
+ skipUnlessJavaScript
5
+ skipIfWindows " "
6
+ setupAndCabalTest $ do
7
+ skipUnlessGhcVersion " >= 9.12"
8
+ res <- cabal' " v2-run" [" demo" ]
9
+ assertOutputContains " Hello definition!" res
Original file line number Diff line number Diff line change
1
+ //#OPTIONS: CPP
2
+
3
+ function foo ( ) {
4
+ #ifdef PRINT_DEF
5
+ console . log ( "Hello definition!" ) ;
6
+ #else
7
+ console . log ( "Hello!" ) ;
8
+ #endif
9
+ }
Original file line number Diff line number Diff line change
1
+ cabal-version : 3.14
2
+ name : jsoptions
3
+ version : 0
4
+ build-type : Simple
5
+
6
+ library
7
+ default-language : Haskell2010
8
+ exposed-modules : Lib
9
+ build-depends : base
10
+
11
+ if impl(javascript)
12
+ js-sources : jsbits/lib.js
13
+ js-options : -optJSP-DPRINT_DEF
14
+
15
+ executable demo
16
+ default-language : Haskell2010
17
+ main-is : Main.hs
18
+ hs-source-dirs : demo
19
+ build-depends : base, jsoptions
Original file line number Diff line number Diff line change
1
+ # cabal v2-run
2
+ Configuration is affected by the following files:
3
+ - cabal.project
4
+ Resolving dependencies...
5
+ Build profile: -w ghc-<GHCVER> -O1
6
+ In order, the following will be built:
7
+ - jsoptions-exe-0 (lib) (first run)
8
+ - jsoptions-exe-0 (exe:demo) (first run)
9
+ Configuring library for jsoptions-exe-0...
10
+ Preprocessing library for jsoptions-exe-0...
11
+ Building library for jsoptions-exe-0...
12
+ Configuring executable 'demo' for jsoptions-exe-0...
13
+ Preprocessing executable 'demo' for jsoptions-exe-0...
14
+ Building executable 'demo' for jsoptions-exe-0...
Original file line number Diff line number Diff line change
1
+ import Test.Cabal.Prelude
2
+
3
+ main = do
4
+ skipIfJavaScript
5
+ cabalTest $ do
6
+ -- Ensure the field `js-options` does not raise issues
7
+ res <- cabal' " v2-run" [" demo" ]
8
+ assertOutputContains " foo_fallback" res
Original file line number Diff line number Diff line change
1
+ {-# LANGUAGE CPP #-}
2
+ module Lib where
3
+
4
+ #if defined(javascript_HOST_ARCH)
5
+ foreign import javascript foo :: IO ()
6
+ #else
7
+ foo :: IO ()
8
+ foo = putStrLn " foo_fallback"
9
+ #endif
Original file line number Diff line number Diff line change @@ -271,6 +271,14 @@ cxx-options
271
271
.. math ::
272
272
{\left \{ \mathop {\mathit {hs\text {-}string}}\mid {{[\mathop {\mathord {``}\mathtt {\ }\mathord {"}}]^c}}^+_{} \right\} }^\ast _{\bullet }
273
273
274
+ js-options
275
+ * Monoidal field
276
+ * Available since ``cabal-version: 3.14 ``.
277
+ * Documentation of :pkg-field: `library:js-options `
278
+
279
+ .. math ::
280
+ {\left \{ \mathop {\mathit {hs\text {-}string}}\mid {{[\mathop {\mathord {``}\mathtt {\ }\mathord {"}}]^c}}^+_{} \right\} }^\ast _{\bullet }
281
+
274
282
cxx-sources
275
283
* Monoidal field
276
284
* Available since ``cabal-version: 2.2 ``.
Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ syn keyword cabalFieldName contained
67
67
\ copyright
68
68
\ cpp - options
69
69
\ cxx- options
70
+ \ js - options
70
71
\ cxx- sources
71
72
\ data- dir
72
73
\ data- files
You can’t perform that action at this time.
0 commit comments