diff options
author | Oliver Reiche <oliver.reiche@huawei.com> | 2022-08-24 18:21:32 +0200 |
---|---|---|
committer | Oliver Reiche <oliver.reiche@huawei.com> | 2022-09-13 10:51:13 +0200 |
commit | f9eaf2e93b6a53cef235770e9c48f4a7dc52facf (patch) | |
tree | 5355c1f3f8cb749ae42764ee73eb8d2bab752bad | |
parent | ea3fc91585374eb4e8dc6310006168a51878ae27 (diff) | |
download | justbuild-f9eaf2e93b6a53cef235770e9c48f4a7dc52facf.tar.gz |
Defaults: Use hierarchical defaults for flags and toolchain
-rw-r--r-- | etc/defaults/CC/TARGETS | 258 | ||||
-rw-r--r-- | etc/defaults/CC/TARGETS.absl | 64 | ||||
-rw-r--r-- | etc/defaults/CC/TARGETS.boringssl | 10 | ||||
-rw-r--r-- | etc/defaults/CC/TARGETS.git2 | 120 | ||||
-rw-r--r-- | etc/defaults/CC/TARGETS.just | 32 | ||||
-rw-r--r-- | etc/defaults/CC/TARGETS.nowerror | 10 | ||||
-rw-r--r-- | etc/defaults/CC/TARGETS.protobuf | 10 | ||||
-rw-r--r-- | etc/defaults/CC/TARGETS.re2 | 9 | ||||
-rw-r--r-- | etc/defaults/CC/test/TARGETS.just | 1 | ||||
-rw-r--r-- | etc/defaults/shell/test/TARGETS.just | 1 | ||||
-rw-r--r-- | etc/repos.json | 18 |
11 files changed, 374 insertions, 159 deletions
diff --git a/etc/defaults/CC/TARGETS b/etc/defaults/CC/TARGETS index 2cb6ab4b..c2f93fdf 100644 --- a/etc/defaults/CC/TARGETS +++ b/etc/defaults/CC/TARGETS @@ -1,17 +1,257 @@ { "defaults": { "type": ["CC", "defaults"] + , "arguments_config": ["COMPILER_FAMILY", "DEBUG"] + , "base": ["toolchain"] + , "ADD_CFLAGS": + { "type": "case" + , "expr": {"type": "var", "name": "COMPILER_FAMILY", "default": "unknown"} + , "case": + { "msvc": + { "type": "if" + , "cond": {"type": "var", "name": "DEBUG"} + , "then": ["/Od", "/Z7"] + , "else": ["/O2", "/DNDEBUG"] + } + } + , "default": + { "type": "if" + , "cond": {"type": "var", "name": "DEBUG"} + , "then": ["-O0", "-g"] + , "else": ["-O2", "-DNDEBUG"] + } + } + , "ADD_CXXFLAGS": + { "type": "case" + , "expr": {"type": "var", "name": "COMPILER_FAMILY", "default": "unknown"} + , "case": + { "msvc": + { "type": "if" + , "cond": {"type": "var", "name": "DEBUG"} + , "then": ["/Od", "/Z7"] + , "else": ["/O2", "/DNDEBUG"] + } + } + , "default": + { "type": "if" + , "cond": {"type": "var", "name": "DEBUG"} + , "then": ["-O0", "-g"] + , "else": ["-O2", "-DNDEBUG"] + } + } + } +, "toolchain": + { "type": ["CC", "defaults"] + , "arguments_config": + ["OS", "ARCH", "HOST_ARCH", "TARGET_ARCH", "COMPILER_FAMILY"] + , "base": + { "type": "let*" + , "bindings": + [ [ "HOST_ARCH" + , { "type": "var" + , "name": "HOST_ARCH" + , "default": {"type": "var", "name": "ARCH"} + } + ] + , [ "TARGET_ARCH" + , { "type": "var" + , "name": "TARGET_ARCH" + , "default": {"type": "var", "name": "ARCH"} + } + ] + , [ "COMPILER_FAMILY" + , { "type": "if" + , "cond": + { "type": "and" + , "$1": + [{"type": "var", "name": "OS"}, {"type": "var", "name": "ARCH"}] + } + , "then": {"type": "var", "name": "COMPILER_FAMILY"} + , "else": "unknown" + } + ] + ] + , "body": + { "type": "case" + , "expr": + {"type": "var", "name": "COMPILER_FAMILY", "default": "unknown"} + , "case": {"gnu": ["gcc"], "clang": ["clang"], "unknown": ["unknown"]} + , "default": + { "type": "fail" + , "msg": + [ "Unsupported COMPILER_FAMILY" + , {"type": "var", "name": "COMPILER_FAMILY"} + ] + } + } + } + } +, "unknown": + { "type": ["CC", "defaults"] + , "CC": ["cc"] + , "CXX": ["c++"] + , "AR": ["ar"] + , "PATH": ["/bin", "/sbin", "/usr/bin", "/usr/sbin"] + } +, "gcc": + { "type": ["CC", "defaults"] + , "arguments_config": ["OS", "HOST_ARCH", "TARGET_ARCH"] + , "CC": + { "type": "let*" + , "bindings": + [ [ "PLATFORM" + , { "type": "join" + , "separator": "_" + , "$1": + [ {"type": "var", "name": "OS"} + , {"type": "var", "name": "TARGET_ARCH"} + ] + } + ] + ] + , "body": + { "type": "case" + , "expr": {"type": "var", "name": "PLATFORM"} + , "case": + { "linux_x86": ["i686-linux-gnu-gcc"] + , "linux_x86_64": ["x86_64-linux-gnu-gcc"] + , "linux_arm": ["arm-linux-gnueabi-gcc"] + , "linux_arm64": ["aarch64-linux-gnu-gcc"] + } + , "default": + { "type": "fail" + , "msg": + ["Unsupported PLATFORM for gcc", {"type": "var", "name": "PLATFORM"}] + } + } + } + , "CXX": + { "type": "let*" + , "bindings": + [ [ "PLATFORM" + , { "type": "join" + , "separator": "_" + , "$1": + [ {"type": "var", "name": "OS"} + , {"type": "var", "name": "TARGET_ARCH"} + ] + } + ] + ] + , "body": + { "type": "case" + , "expr": {"type": "var", "name": "PLATFORM"} + , "case": + { "linux_x86": ["i686-linux-gnu-g++"] + , "linux_x86_64": ["x86_64-linux-gnu-g++"] + , "linux_arm": ["arm-linux-gnueabi-g++"] + , "linux_arm64": ["aarch64-linux-gnu-g++"] + } + , "default": + { "type": "fail" + , "msg": + ["Unsupported PLATFORM for g++", {"type": "var", "name": "PLATFORM"}] + } + } + } + , "AR": + { "type": "let*" + , "bindings": + [ [ "PLATFORM" + , { "type": "join" + , "separator": "_" + , "$1": + [ {"type": "var", "name": "OS"} + , {"type": "var", "name": "TARGET_ARCH"} + ] + } + ] + ] + , "body": + { "type": "case" + , "expr": {"type": "var", "name": "PLATFORM"} + , "case": + { "linux_x86": ["i686-linux-gnu-ar"] + , "linux_x86_64": ["x86_64-linux-gnu-ar"] + , "linux_arm": ["arm-linux-gnueabi-ar"] + , "linux_arm64": ["aarch64-linux-gnu-ar"] + } + , "default": + { "type": "fail" + , "msg": + ["Unsupported PLATFORM for ar", {"type": "var", "name": "PLATFORM"}] + } + } + } + , "PATH": ["/bin", "/sbin", "/usr/bin", "/usr/sbin"] + } +, "clang": + { "type": ["CC", "defaults"] + , "arguments_config": ["OS", "HOST_ARCH", "TARGET_ARCH"] , "CC": ["clang"] , "CXX": ["clang++"] - , "CFLAGS": ["-std=gnu17", "-O2"] - , "CXXFLAGS": - [ "-std=c++20" - , "-O2" - , "-Wall" - , "-Wextra" - , "-Wpedantic" - , "-Wsign-conversion" - ] , "AR": ["ar"] + , "CFLAGS": + { "type": "let*" + , "bindings": + [ [ "PLATFORM" + , { "type": "join" + , "separator": "_" + , "$1": + [ {"type": "var", "name": "OS"} + , {"type": "var", "name": "TARGET_ARCH"} + ] + } + ] + ] + , "body": + { "type": "case" + , "expr": {"type": "var", "name": "PLATFORM"} + , "case": + { "linux_x86": ["-target", "i686-linux-gnu"] + , "linux_x86_64": ["-target", "x86_64-linux-gnu"] + , "linux_arm": ["-target", "arm-linux-gnueabi"] + , "linux_arm64": ["-target", "aarch64-linux-gnu"] + } + , "default": + { "type": "fail" + , "msg": + [ "Unsupported PLATFORM for clang" + , {"type": "var", "name": "PLATFORM"} + ] + } + } + } + , "CXXFLAGS": + { "type": "let*" + , "bindings": + [ [ "PLATFORM" + , { "type": "join" + , "separator": "_" + , "$1": + [ {"type": "var", "name": "OS"} + , {"type": "var", "name": "TARGET_ARCH"} + ] + } + ] + ] + , "body": + { "type": "case" + , "expr": {"type": "var", "name": "PLATFORM"} + , "case": + { "linux_x86": ["-target", "i686-linux-gnu"] + , "linux_x86_64": ["-target", "x86_64-linux-gnu"] + , "linux_arm": ["-target", "arm-linux-gnueabi"] + , "linux_arm64": ["-target", "aarch64-linux-gnu"] + } + , "default": + { "type": "fail" + , "msg": + [ "Unsupported PLATFORM for clang++" + , {"type": "var", "name": "PLATFORM"} + ] + } + } + } , "PATH": ["/bin", "/sbin", "/usr/bin", "/usr/sbin"] } } diff --git a/etc/defaults/CC/TARGETS.absl b/etc/defaults/CC/TARGETS.absl index 15df20d1..836aa8b3 100644 --- a/etc/defaults/CC/TARGETS.absl +++ b/etc/defaults/CC/TARGETS.absl @@ -1,57 +1,23 @@ { "defaults": { "type": ["CC", "defaults"] - , "CC": ["clang"] - , "CXX": ["clang++"] - , "CFLAGS": [] - , "CXXFLAGS": + , "base": [["@", "base", "CC", "defaults"]] + , "ADD_CXXFLAGS": [ "-std=c++20" - , "-O2" , "-Wall" , "-Wextra" - , "-Weverything" - , "-Wno-c++98-compat-pedantic" - , "-Wno-conversion" - , "-Wno-covered-switch-default" - , "-Wno-deprecated" - , "-Wno-disabled-macro-expansion" - , "-Wno-double-promotion" - , "-Wno-comma" - , "-Wno-extra-semi" - , "-Wno-extra-semi-stmt" - , "-Wno-packed" - , "-Wno-padded" - , "-Wno-sign-compare" - , "-Wno-float-conversion" - , "-Wno-float-equal" - , "-Wno-format-nonliteral" - , "-Wno-gcc-compat" - , "-Wno-global-constructors" - , "-Wno-exit-time-destructors" - , "-Wno-non-modular-include-in-module" - , "-Wno-old-style-cast" - , "-Wno-range-loop-analysis" - , "-Wno-reserved-id-macro" - , "-Wno-shorten-64-to-32" - , "-Wno-switch-enum" - , "-Wno-thread-safety-negative" - , "-Wno-unknown-warning-option" - , "-Wno-unreachable-code" - , "-Wno-unused-macros" - , "-Wno-weak-vtables" - , "-Wno-zero-as-null-pointer-constant" - , "-Wbitfield-enum-conversion" - , "-Wbool-conversion" - , "-Wconstant-conversion" - , "-Wenum-conversion" - , "-Wint-conversion" - , "-Wliteral-conversion" - , "-Wnon-literal-null-conversion" - , "-Wnull-conversion" - , "-Wobjc-literal-conversion" - , "-Wno-sign-conversion" - , "-Wstring-conversion" + , "-Wcast-qual" + , "-Wconversion-null" + , "-Wformat-security" + , "-Wmissing-declarations" + , "-Woverlength-strings" + , "-Wpointer-arith" + , "-Wundef" + , "-Wunused-local-typedefs" + , "-Wunused-result" + , "-Wvarargs" + , "-Wvla" + , "-Wwrite-strings" + , "-DNOMINMAX" ] - , "AR": ["ar"] - , "PATH": ["/bin", "/sbin", "/usr/bin", "/usr/sbin"] } } diff --git a/etc/defaults/CC/TARGETS.boringssl b/etc/defaults/CC/TARGETS.boringssl index 2466c2d8..8f443e55 100644 --- a/etc/defaults/CC/TARGETS.boringssl +++ b/etc/defaults/CC/TARGETS.boringssl @@ -1,12 +1,11 @@ { "defaults": { "type": ["CC", "defaults"] , "arguments_config": ["OS", "ARCH", "TARGET_ARCH"] - , "CC": ["clang"] - , "CXX": ["clang++"] - , "CFLAGS": + , "base": [["@", "base", "CC", "defaults"]] + , "ADD_CFLAGS": { "type": "++" , "$1": - [ ["-std=gnu17", "-O2"] + [ ["-std=gnu17"] , { "type": "let*" , "bindings": [ [ "OS" @@ -82,8 +81,5 @@ } ] } - , "CXXFLAGS": [] - , "AR": ["ar"] - , "PATH": ["/bin", "/sbin", "/usr/bin", "/usr/sbin"] } } diff --git a/etc/defaults/CC/TARGETS.git2 b/etc/defaults/CC/TARGETS.git2 index 056b745e..4326ce62 100644 --- a/etc/defaults/CC/TARGETS.git2 +++ b/etc/defaults/CC/TARGETS.git2 @@ -1,82 +1,74 @@ { "defaults": { "type": ["CC", "defaults"] - , "arguments_config": ["OS", "ARCH"] - , "CC": ["clang"] - , "CXX": ["clang++"] - , "CFLAGS": + , "arguments_config": ["COMPILER_FAMILY", "OS"] + , "base": [["@", "base", "CC", "defaults"]] + , "ADD_CFLAGS": { "type": "let*" , "bindings": - [ [ "OS" + [ [ "COMPILER_FAMILY" + , {"type": "var", "name": "COMPILER_FAMILY", "default": "unknown"} + ] + , [ "OS" , { "type": "var" , "name": "OS" , "default": {"type": "fail", "msg": "Required variable 'OS' is not set."} } ] - , [ "ARCH" - , { "type": "var" - , "name": "ARCH" - , "default": - {"type": "fail", "msg": "Required variable 'ARCH' is not set."} - } - ] ] , "body": - { "type": "++" - , "$1": - [ ["-std=gnu17", "-O2"] - , { "type": "case" - , "expr": {"type": "var", "name": "OS"} - , "case": - { "windows": - [ "-D_SCL_SECURE_NO_WARNINGS" - , "-D_CRT_SECURE_NO_DEPRECATE" - , "-D_CRT_NONSTDC_NO_DEPRECATE" - , "/GF" - , "/MP" - , "/nologo" - ] - } - , "default": - { "type": "++" - , "$1": - [ ["-D_GNU_SOURCE", "-Wall", "-Wextra"] - , { "type": "case" - , "expr": {"type": "var", "name": "OS"} - , "case": - { "sunos": - [ "-D_POSIX_C_SOURCE=200112L" - , "-D__EXTENSIONS__" - , "-D_POSIX_PTHREAD_SEMANTICS" - ] - , "solaris": - [ "-D_POSIX_C_SOURCE=200112L" - , "-D__EXTENSIONS__" - , "-D_POSIX_PTHREAD_SEMANTICS" - ] - } - } - , [ "-Wdocumentation" - , "-Wno-documentation-deprecated-sync" - , "-Wno-missing-field-initializers" - , "-Wstrict-aliasing" - , "-Wstrict-prototypes" - , "-Wdeclaration-after-statement" - , "-Wshift-count-overflow" - , "-Wunused-const-variable" - , "-Wunused-function" - , "-Wint-conversion" - , "-Wformat" - , "-Wformat-security" + { "type": "case" + , "expr": {"type": "var", "name": "COMPILER_FAMILY"} + , "case": + { "msvc": + [ "-D_SCL_SECURE_NO_WARNINGS" + , "-D_CRT_SECURE_NO_DEPRECATE" + , "-D_CRT_NONSTDC_NO_DEPRECATE" + , "/GF" + , "/MP" + , "/nologo" + ] + } + , "default": + { "type": "++" + , "$1": + [ { "type": "case" + , "expr": {"type": "var", "name": "OS"} + , "case": + { "sunos": + [ "-D_POSIX_C_SOURCE=200112L" + , "-D__EXTENSIONS__" + , "-D_POSIX_PTHREAD_SEMANTICS" + ] + , "solaris": + [ "-D_POSIX_C_SOURCE=200112L" + , "-D__EXTENSIONS__" + , "-D_POSIX_PTHREAD_SEMANTICS" ] - ] + } } - } - ] + , [ "-D_GNU_SOURCE" + , "-Wall" + , "-Wextra" + , "-Wno-documentation-deprecated-sync" + , "-Wno-missing-field-initializers" + , "-Wstrict-aliasing" + , "-Wstrict-prototypes" + , "-Wdeclaration-after-statement" + , "-Wshift-count-overflow" + , "-Wunused-const-variable" + , "-Wunused-function" + , "-Wint-conversion" + , "-Wformat" + , "-Wformat-security" + ] + , { "type": "case" + , "expr": {"type": "var", "name": "COMPILER_FAMILY"} + , "case": {"clang": ["-Wdocumentation"]} + } + ] + } } } - , "CXXFLAGS": [] - , "AR": ["ar"] - , "PATH": ["/bin", "/sbin", "/usr/bin", "/usr/sbin"] } } diff --git a/etc/defaults/CC/TARGETS.just b/etc/defaults/CC/TARGETS.just new file mode 100644 index 00000000..ea501e09 --- /dev/null +++ b/etc/defaults/CC/TARGETS.just @@ -0,0 +1,32 @@ +{ "defaults": + { "type": ["CC", "defaults"] + , "arguments_config": ["DEBUG"] + , "base": [["@", "base", "CC", "defaults"]] + , "ADD_CFLAGS": + [ "-std=gnu17" + , "-Wall" + , "-Wextra" + , "-Wpedantic" + , "-Wsign-conversion" + , "-Werror" + , "-pedantic-errors" + ] + , "ADD_CXXFLAGS": + { "type": "++" + , "$1": + [ [ "-std=c++20" + , "-Wall" + , "-Wextra" + , "-Wpedantic" + , "-Wsign-conversion" + , "-Werror" + , "-pedantic-errors" + ] + , { "type": "if" + , "cond": {"type": "var", "name": "DEBUG"} + , "then": ["-Dgsl_CONFIG_CONTRACT_CHECKING_AUDIT=1"] + } + ] + } + } +} diff --git a/etc/defaults/CC/TARGETS.nowerror b/etc/defaults/CC/TARGETS.nowerror deleted file mode 100644 index a3a41f9d..00000000 --- a/etc/defaults/CC/TARGETS.nowerror +++ /dev/null @@ -1,10 +0,0 @@ -{ "defaults": - { "type": ["CC", "defaults"] - , "CC": ["clang"] - , "CXX": ["clang++"] - , "CFLAGS": ["-std=gnu17", "-O2"] - , "CXXFLAGS": ["-std=c++20", "-O2"] - , "AR": ["ar"] - , "PATH": ["/bin", "/sbin", "/usr/bin", "/usr/sbin"] - } -} diff --git a/etc/defaults/CC/TARGETS.protobuf b/etc/defaults/CC/TARGETS.protobuf index 4bf6c5d8..16e481bc 100644 --- a/etc/defaults/CC/TARGETS.protobuf +++ b/etc/defaults/CC/TARGETS.protobuf @@ -1,11 +1,9 @@ { "defaults": { "type": ["CC", "defaults"] - , "CC": ["clang"] - , "CXX": ["clang++"] - , "CFLAGS": ["-std=gnu17", "-O2"] - , "CXXFLAGS": + , "base": [["@", "base", "CC", "defaults"]] + , "ADD_CFLAGS": ["-std=gnu17"] + , "ADD_CXXFLAGS": [ "-std=c++20" - , "-O2" , "-DHAVE_PTHREAD" , "-DHAVE_ZLIB" , "-Woverloaded-virtual" @@ -14,7 +12,5 @@ , "-Wno-write-strings" , "-Wno-deprecated-declarations" ] - , "AR": ["ar"] - , "PATH": ["/bin", "/sbin", "/usr/bin", "/usr/sbin"] } } diff --git a/etc/defaults/CC/TARGETS.re2 b/etc/defaults/CC/TARGETS.re2 index 2128f459..34fc7c8c 100644 --- a/etc/defaults/CC/TARGETS.re2 +++ b/etc/defaults/CC/TARGETS.re2 @@ -1,18 +1,13 @@ { "defaults": { "type": ["CC", "defaults"] - , "CC": ["clang"] - , "CXX": ["clang++"] - , "CFLAGS": [] - , "CXXFLAGS": + , "base": [["@", "base", "CC", "defaults"]] + , "ADD_CXXFLAGS": [ "-std=c++11" - , "-O2" , "-pthread" , "-Wall" , "-Wextra" , "-Wno-unused-parameter" , "-Wno-missing-field-initializers" ] - , "AR": ["ar"] - , "PATH": ["/bin", "/sbin", "/usr/bin", "/usr/sbin"] } } diff --git a/etc/defaults/CC/test/TARGETS.just b/etc/defaults/CC/test/TARGETS.just new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/etc/defaults/CC/test/TARGETS.just @@ -0,0 +1 @@ +{} diff --git a/etc/defaults/shell/test/TARGETS.just b/etc/defaults/shell/test/TARGETS.just new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/etc/defaults/shell/test/TARGETS.just @@ -0,0 +1 @@ +{} diff --git a/etc/repos.json b/etc/repos.json index 77554148..431c44e6 100644 --- a/etc/repos.json +++ b/etc/repos.json @@ -2,7 +2,7 @@ { "just": { "repository": {"type": "file", "path": "."} , "bindings": - { "rules": "rules" + { "rules": "rules-just" , "just-distfiles": "just-distfiles" , "gsl-lite": "gsl-lite" , "cli11": "cli11" @@ -57,44 +57,50 @@ {"type": "file", "path": "rules", "pragma": {"to_git": true}} , "target_root": "defaults" , "rule_root": "rules" - , "bindings": {"protoc": "protobuf", "grpc": "com_github_grpc_grpc"} } - , "rules-nowarn": + , "rules-just": { "repository": "rules" , "target_root": "defaults" , "rule_root": "rules" - , "target_file_name": "TARGETS.nowerror" + , "target_file_name": "TARGETS.just" + , "bindings": + {"base": "rules", "protoc": "protobuf", "grpc": "com_github_grpc_grpc"} } , "rules-boringssl": { "repository": "rules" , "target_root": "defaults" , "rule_root": "rules" , "target_file_name": "TARGETS.boringssl" + , "bindings": {"base": "rules"} } , "rules-protobuf": { "repository": "rules" , "target_root": "defaults" , "rule_root": "rules" , "target_file_name": "TARGETS.protobuf" - , "bindings": {"protoc": "protobuf", "grpc": "com_github_grpc_grpc"} + , "bindings": + {"base": "rules", "protoc": "protobuf", "grpc": "com_github_grpc_grpc"} } , "rules-absl": { "repository": "rules" , "target_root": "defaults" , "rule_root": "rules" , "target_file_name": "TARGETS.absl" + , "bindings": {"base": "rules"} } , "rules-re2": { "repository": "rules" , "target_root": "defaults" , "rule_root": "rules" , "target_file_name": "TARGETS.re2" + , "bindings": {"base": "rules"} } , "rules-git2": { "repository": "rules" , "target_root": "defaults" , "rule_root": "rules" , "target_file_name": "TARGETS.git2" + , "bindings": {"base": "rules"} } , "import targets": { "repository": @@ -157,7 +163,7 @@ } , "target_root": "import targets" , "target_file_name": "TARGETS.fmt" - , "bindings": {"rules": "rules-nowarn"} + , "bindings": {"rules": "rules"} , "bootstrap": { "include_dir": "include/fmt" , "build": "cd src && clang++ -I ../include -c *.cc && ar cqs ../libfmt.a *.o" |