1
1
mirror of https://github.com/github/semantic.git synced 2025-01-07 16:07:28 +03:00

rename the flags and condense around compilation_mode

This commit is contained in:
Patrick Thomson 2020-07-01 00:35:09 -04:00
parent 20ac0523e3
commit b034378ac2
13 changed files with 55 additions and 30 deletions

View File

@ -8,7 +8,7 @@ build --disk_cache=.bazel-cache/bazel-disk
build --repository_cache=tmp/bazel-repo build --repository_cache=tmp/bazel-repo
build --color=yes build --color=yes
build --jobs=8 build --jobs=8
common --compilation_mode=fastbuild
# test environment does not propagate locales by default # test environment does not propagate locales by default
# some tests reads files written in UTF8, we need to propagate the correct # some tests reads files written in UTF8, we need to propagate the correct

View File

@ -34,6 +34,21 @@ haskell_toolchain_library(name = "template-haskell")
haskell_toolchain_library(name = "transformers") haskell_toolchain_library(name = "transformers")
config_setting(
name = "release",
values = {"compilation_mode": "opt"},
)
config_setting(
name = "development",
values = {"compilation_mode": "fastbuild"},
)
config_setting(
name = "debug",
values = {"compilation_mode": "dbg"},
)
haskell_repl( haskell_repl(
name = "hie-bios", name = "hie-bios",
collect_data = False, collect_data = False,

View File

@ -7,8 +7,10 @@ load(
) )
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
STANDARD_GHC_WARNINGS = [ DEVELOPMENT_GHC_FLAGS = ["-O0"]
"-O0", RELEASE_GHC_FLAGS = ["-O1"]
GHC_FLAGS = [
"-v1", "-v1",
"-j8", "-j8",
"-fdiagnostics-color=always", "-fdiagnostics-color=always",
@ -25,7 +27,13 @@ STANDARD_GHC_WARNINGS = [
"-Wno-all-missed-specialisations", "-Wno-all-missed-specialisations",
"-Wno-star-is-type", "-Wno-star-is-type",
"-Wno-missing-deriving-strategies", "-Wno-missing-deriving-strategies",
] ] + select(
{
"//:release": RELEASE_GHC_FLAGS,
"//:development": DEVELOPMENT_GHC_FLAGS,
"//:debug": DEVELOPMENT_GHC_FLAGS,
},
)
STANDARD_EXECUTABLE_FLAGS = [ STANDARD_EXECUTABLE_FLAGS = [
"-threaded", "-threaded",
@ -58,10 +66,10 @@ def semantic_language_library(language, name, srcs, ts_package = "", nodetypes =
# We can't use Template Haskell to find out the location of the # We can't use Template Haskell to find out the location of the
# node-types.json files, but we can pass it in as a preprocessor # node-types.json files, but we can pass it in as a preprocessor
# directive. # directive.
compiler_flags = STANDARD_GHC_WARNINGS + [ compiler_flags = GHC_FLAGS + [
'-DNODE_TYPES_PATH="../../../../$(rootpath {})"'.format(nodetypes), '-DNODE_TYPES_PATH="../../../../$(rootpath {})"'.format(nodetypes),
], ],
repl_ghci_args = STANDARD_GHC_WARNINGS + [ repl_ghci_args = GHC_FLAGS + [
'-DNODE_TYPES_PATH="../../../../$(rootpath {})"'.format(nodetypes), '-DNODE_TYPES_PATH="../../../../$(rootpath {})"'.format(nodetypes),
], ],
srcs = srcs, srcs = srcs,

View File

@ -20,8 +20,9 @@ The first time you run `bazel build`, it'll take some time, as Bazel will compil
| Build `TARGET` library | `cabal build TARGET:lib` | `bazel build //TARGET` | | Build `TARGET` library | `cabal build TARGET:lib` | `bazel build //TARGET` |
| Build semantic executable | `cabal build semantic:exe:semantic` | `bazel build //semantic:exe` | | Build semantic executable | `cabal build semantic:exe:semantic` | `bazel build //semantic:exe` |
| Build/run executable | `cabal run semantic -- ARGS` | `bazel run //semantic:exe -- ARGS` | | Build/run executable | `cabal run semantic -- ARGS` | `bazel run //semantic:exe -- ARGS` |
| Load REPL component | `script/ghci` and `:load` | `bazel build //TARGET@repl` | | Load REPL component | `script/ghci` and `:load` | `bazel build //TARGET@repl` |
| Run tests | `cabal test all` | `bazel test //...` | | Run tests | `cabal test all` | `bazel test //...` |
| Build with optimizations | `cabal build --flags="+release"` | `bazel build -copt //...` |
## Adding a new dependency ## Adding a new dependency
@ -53,7 +54,7 @@ The default `.bazelrc` file imports a `.bazelrc.local` file if it's present; use
## Shared variables ## Shared variables
* `STANDARD_GHC_WARNINGS`: the standard set of Cabal flags that all targets should use. * `GHC_FLAGS`: the standard set of Cabal flags that all targets should use.
* `STANDARD_EXECUTABLE_FLAGS`: ditto, but with executable-specific flags. * `STANDARD_EXECUTABLE_FLAGS`: ditto, but with executable-specific flags.
## Custom rules ## Custom rules

View File

@ -14,13 +14,13 @@ load(
) )
load( load(
"//:build/common.bzl", "//:build/common.bzl",
"STANDARD_GHC_WARNINGS", "GHC_FLAGS",
) )
haskell_library( haskell_library(
name = "semantic-analysis", name = "semantic-analysis",
srcs = glob(["src/**/*.hs"]), srcs = glob(["src/**/*.hs"]),
compiler_flags = STANDARD_GHC_WARNINGS + ["-XOverloadedStrings"], compiler_flags = GHC_FLAGS + ["-XOverloadedStrings"],
deps = [ deps = [
"//:base", "//:base",
"//:containers", "//:containers",

View File

@ -14,13 +14,13 @@ load(
) )
load( load(
"//:build/common.bzl", "//:build/common.bzl",
"STANDARD_GHC_WARNINGS", "GHC_FLAGS",
) )
haskell_library( haskell_library(
name = "semantic-ast", name = "semantic-ast",
srcs = glob(["src/**/*.hs"]), srcs = glob(["src/**/*.hs"]),
compiler_flags = STANDARD_GHC_WARNINGS + ["-XOverloadedStrings"], compiler_flags = GHC_FLAGS + ["-XOverloadedStrings"],
deps = [ deps = [
"//:base", "//:base",
"//:bytestring", "//:bytestring",

View File

@ -14,5 +14,6 @@ semantic_language_library(
semantic_language_parsing_test( semantic_language_parsing_test(
language = "codeql", language = "codeql",
project = "ql", semantic_package = "ql",
ts_package = "ql",
) )

View File

@ -14,14 +14,14 @@ load(
) )
load( load(
"//:build/common.bzl", "//:build/common.bzl",
"GHC_FLAGS",
"STANDARD_EXECUTABLE_FLAGS", "STANDARD_EXECUTABLE_FLAGS",
"STANDARD_GHC_WARNINGS",
) )
haskell_library( haskell_library(
name = "semantic-core", name = "semantic-core",
srcs = glob(["src/**/*.hs"]), srcs = glob(["src/**/*.hs"]),
compiler_flags = STANDARD_GHC_WARNINGS, compiler_flags = GHC_FLAGS,
deps = [ deps = [
"//:base", "//:base",
"//:text", "//:text",
@ -45,7 +45,7 @@ haskell_test(
"test/*.hs", "test/*.hs",
"test/Source/Test.hs", "test/Source/Test.hs",
]), ]),
compiler_flags = STANDARD_GHC_WARNINGS + STANDARD_EXECUTABLE_FLAGS, compiler_flags = GHC_FLAGS + STANDARD_EXECUTABLE_FLAGS,
deps = [ deps = [
"//:base", "//:base",
"//:text", "//:text",

View File

@ -8,7 +8,7 @@ load(
) )
load( load(
"//:build/common.bzl", "//:build/common.bzl",
"STANDARD_GHC_WARNINGS", "GHC_FLAGS",
) )
# Doesn't build right now. # Doesn't build right now.
@ -16,7 +16,7 @@ load(
haskell_binary( haskell_binary(
name = "exe", name = "exe",
srcs = ["app/Main.hs"], srcs = ["app/Main.hs"],
compiler_flags = STANDARD_GHC_WARNINGS, compiler_flags = GHC_FLAGS,
deps = [ deps = [
"//:base", "//:base",
"//:bytestring", "//:bytestring",

View File

@ -14,13 +14,13 @@ load(
) )
load( load(
"//:build/common.bzl", "//:build/common.bzl",
"STANDARD_GHC_WARNINGS", "GHC_FLAGS",
) )
haskell_library( haskell_library(
name = "semantic-scope-graph", name = "semantic-scope-graph",
srcs = glob(["src/**/*.hs"]), srcs = glob(["src/**/*.hs"]),
compiler_flags = STANDARD_GHC_WARNINGS + ["-XOverloadedStrings"], compiler_flags = GHC_FLAGS + ["-XOverloadedStrings"],
deps = [ deps = [
"//:base", "//:base",
"//:containers", "//:containers",

View File

@ -14,14 +14,14 @@ load(
) )
load( load(
"//:build/common.bzl", "//:build/common.bzl",
"GHC_FLAGS",
"STANDARD_EXECUTABLE_FLAGS", "STANDARD_EXECUTABLE_FLAGS",
"STANDARD_GHC_WARNINGS",
) )
haskell_library( haskell_library(
name = "semantic-source", name = "semantic-source",
srcs = glob(["src/**/*.hs"]), srcs = glob(["src/**/*.hs"]),
compiler_flags = STANDARD_GHC_WARNINGS + ["-XOverloadedStrings"], compiler_flags = GHC_FLAGS + ["-XOverloadedStrings"],
deps = [ deps = [
"//:base", "//:base",
"//:bytestring", "//:bytestring",
@ -44,7 +44,7 @@ haskell_test(
"test/Source/Test.hs", "test/Source/Test.hs",
"test/Test.hs", "test/Test.hs",
], ],
compiler_flags = STANDARD_GHC_WARNINGS + STANDARD_EXECUTABLE_FLAGS, compiler_flags = GHC_FLAGS + STANDARD_EXECUTABLE_FLAGS,
deps = [ deps = [
":semantic-source", ":semantic-source",
"//:base", "//:base",

View File

@ -14,13 +14,13 @@ load(
) )
load( load(
"//:build/common.bzl", "//:build/common.bzl",
"STANDARD_GHC_WARNINGS", "GHC_FLAGS",
) )
haskell_library( haskell_library(
name = "semantic-tags", name = "semantic-tags",
srcs = glob(["src/**/*.hs"]), srcs = glob(["src/**/*.hs"]),
compiler_flags = STANDARD_GHC_WARNINGS, compiler_flags = GHC_FLAGS,
deps = [ deps = [
"//:base", "//:base",
"//:text", "//:text",

View File

@ -16,8 +16,8 @@ load(
) )
load( load(
"//:build/common.bzl", "//:build/common.bzl",
"GHC_FLAGS",
"STANDARD_EXECUTABLE_FLAGS", "STANDARD_EXECUTABLE_FLAGS",
"STANDARD_GHC_WARNINGS",
) )
load( load(
"//:build/example_repos.bzl", "//:build/example_repos.bzl",
@ -55,7 +55,7 @@ semantic_common_dependencies = [
haskell_library( haskell_library(
name = "semantic", name = "semantic",
srcs = glob(["src/**/*.hs"]), srcs = glob(["src/**/*.hs"]),
compiler_flags = STANDARD_GHC_WARNINGS + ["-XStrictData"], compiler_flags = GHC_FLAGS + ["-XStrictData"],
version = "0.11.0.0", version = "0.11.0.0",
deps = semantic_common_dependencies + [ deps = semantic_common_dependencies + [
"//:base", "//:base",
@ -110,7 +110,7 @@ haskell_library(
haskell_binary( haskell_binary(
name = "exe", name = "exe",
srcs = glob(["app/**/*.hs"]), srcs = glob(["app/**/*.hs"]),
compiler_flags = STANDARD_GHC_WARNINGS + STANDARD_EXECUTABLE_FLAGS + ["-XStrictData"], compiler_flags = GHC_FLAGS + STANDARD_EXECUTABLE_FLAGS + ["-XStrictData"],
deps = [ deps = [
":semantic", ":semantic",
"//:base", "//:base",
@ -142,7 +142,7 @@ haskell_test(
"test/System/Path/Fixture.hs", "test/System/Path/Fixture.hs",
], ],
), ),
compiler_flags = STANDARD_GHC_WARNINGS + STANDARD_EXECUTABLE_FLAGS + [ compiler_flags = GHC_FLAGS + STANDARD_EXECUTABLE_FLAGS + [
"-XStrictData", "-XStrictData",
], ],
data = glob(include = [ data = glob(include = [
@ -186,7 +186,7 @@ haskell_test(
srcs = [ srcs = [
"test/Examples.hs", "test/Examples.hs",
], ],
compiler_flags = STANDARD_GHC_WARNINGS + STANDARD_EXECUTABLE_FLAGS + [ compiler_flags = GHC_FLAGS + STANDARD_EXECUTABLE_FLAGS + [
"-XStrictData", "-XStrictData",
], ],
data = glob(include = [ data = glob(include = [