/ graphql.nimble
graphql.nimble
 1  # nim-graphql
 2  # Copyright (c) 2021-2024 Status Research & Development GmbH
 3  # Licensed under either of
 4  #  * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
 5  #  * MIT license ([LICENSE-MIT](LICENSE-MIT))
 6  # at your option.
 7  # This file may not be copied, modified, or distributed except according to
 8  # those terms.
 9  
10  mode = ScriptMode.Verbose
11  
12  packageName   = "graphql"
13  version       = "0.2.30"
14  author        = "Status Research & Development GmbH"
15  description   = "GraphQL parser, server and client implementation"
16  license       = "Apache License 2.0"
17  skipDirs      = @["tests", "resources", "fuzzer", "docs", "playground"]
18  
19  requires "nim >= 1.6.0",
20           "faststreams",
21           "stew",
22           "json_serialization",
23           "chronicles",
24           "https://github.com/status-im/nim-zlib",
25           "unittest2",
26           "https://github.com/status-im/nim-chronos#head",
27           "https://github.com/status-im/nim-bearssl#head"
28  
29  proc test(args, path: string, shouldRun = true) =
30    # Compilation language is controlled by TEST_LANG
31    let nimc = getEnv("NIMC", "nim") # Which nim compiler to use
32    let lang = getEnv("NIMLANG", "c") # Which backend (c/cpp/js)
33    let flags = getEnv("NIMFLAGS", "") # Extra flags for the compiler
34    let verbose = getEnv("V", "") notin ["", "0"]
35  
36    let run = if shouldRun: " -r" else: ""
37    let cfg = " --styleCheck:usages --styleCheck: error" &
38              (if verbose: "" else: " --verbosity:0 --hints:off") & run &
39              " -d:unittest2DisableParamFiltering"
40  
41    exec nimc & " " & lang & " " & cfg & " " & flags & " " & args & " " & path
42    if (NimMajor, NimMinor) > (1, 6):
43      exec nimc & " " & lang & " " & cfg & " --mm:refc " & flags & " " & args & " " & path
44  
45  task test, "Run all tests":
46    test "--threads:off", "tests/test_all"
47    test "--threads:on", "tests/test_all"
48    test "--threads:off -d:release", "tests/test_all"
49    test "--threads:on -d:release", "tests/test_all"
50    test "--threads:off -d:release -d:tls", "tests/test_httpserver"
51    test "--threads:on -d:release -d:tls", "tests/test_httpserver"
52    test "-d:release", "playground/swserver", false
53    test "-d:release", "playground/tests/test_all"
54    test "--threads:on -d:release", "playground/tests/test_all"
55  
56  proc playground(server: string) =
57    exec "nim c -r -d:release playground/swserver " & server
58  
59  task ethereum, "run Ethereum playground server":
60    playground("ethereum")
61  
62  task starwars, "run starwars playground server":
63    playground("starwars")