diff --git a/.plzconfig b/.plzconfig index 28650f2d9d..5efebfe48b 100644 --- a/.plzconfig +++ b/.plzconfig @@ -92,3 +92,6 @@ accept = notice [remote] url = + +[featureflags] +hidedeprecatedconfigoptions = true diff --git a/plugins/BUILD b/plugins/BUILD index bb591bca3b..8dacb07979 100644 --- a/plugins/BUILD +++ b/plugins/BUILD @@ -7,13 +7,13 @@ plugin_repo( plugin_repo( name = "cc", plugin = "cc-rules", - revision = "v0.3.2", + revision = "v0.4.0", ) plugin_repo( name = "shell", plugin = "shell-rules", - revision = "v0.1.1", + revision = "v0.2.0", ) plugin_repo( diff --git a/src/core/config.go b/src/core/config.go index 7303ddf720..03588e2f41 100644 --- a/src/core/config.go +++ b/src/core/config.go @@ -589,86 +589,86 @@ type Configuration struct { KeepLabel []string `help:"Defines a target label to be kept; for example, if you set this to go, no Go targets would ever be considered for deletion." example:"go"` } `help:"Please supports a form of 'garbage collection', by which it means identifying targets that are not used for anything. By default binary targets and all their transitive dependencies are always considered non-garbage, as are any tests directly on those. The config options here allow tweaking this behaviour to retain more things.\n\nNote that it's a very good idea that your BUILD files are in the standard format when running this."` Go struct { - GoTool string `help:"The binary to use to invoke Go & its subtools with." var:"GO_TOOL"` - GoRoot string `help:"If set, will set the GOROOT environment variable appropriately during build actions." var:"GOROOT"` - GoPath string `help:"If set, will set the GOPATH environment variable appropriately during build actions." var:"GOPATH"` - ImportPath string `help:"Sets the default Go import path at the root of this repository.\nFor example, in the Please repo, we might set it to github.com/thought-machine/please to allow imports from that package within the repo." var:"GO_IMPORT_PATH"` - CgoCCTool string `help:"Sets the location of CC while building cgo_library and cgo_test rules. Defaults to gcc" var:"CGO_CC_TOOL"` - CgoEnabled string `help:"Sets the CGO_ENABLED which controls whether the cgo build flag is set during cross compilation. Defaults to '0' (disabled)" var:"CGO_ENABLED"` - FilterTool string `help:"Sets the location of the please_go_filter tool that is used to filter source files against build constraints." var:"GO_FILTER_TOOL"` - PleaseGoTool string `help:"Sets the location of the please_go tool that is used to compile and test go code." var:"PLEASE_GO_TOOL"` - EmbedTool string `help:"Sets the location of the please_go_embed tool that is used to parse //go:embed directives." var:"GO_EMBED_TOOL"` - DelveTool string `help:"Sets the location of the Delve tool that is used for debugging Go code." var:"DELVE_TOOL"` - DefaultStatic bool `help:"Sets Go binaries to default to static linking. Note that enabling this may have negative consequences for some code, including Go's DNS lookup code in the net module." var:"GO_DEFAULT_STATIC"` - GoTestRootCompat bool `help:"Changes the behavior of the build rules to be more compatible with go test i.e. please will descend into the package directory to run unit tests as go test does." var:"GO_TEST_ROOT_COMPAT"` - CFlags string `help:"Sets the CFLAGS env var for go rules." var:"GO_C_FLAGS"` - LDFlags string `help:"Sets the LDFLAGS env var for go rules." var:"GO_LD_FLAGS"` + GoTool string `help:"The binary to use to invoke Go & its subtools with." deprecated:"true" var:"GO_TOOL"` + GoRoot string `help:"If set, will set the GOROOT environment variable appropriately during build actions." deprecated:"true" var:"GOROOT"` + GoPath string `help:"If set, will set the GOPATH environment variable appropriately during build actions." deprecated:"true" var:"GOPATH"` + ImportPath string `help:"Sets the default Go import path at the root of this repository.\nFor example, in the Please repo, we might set it to github.com/thought-machine/please to allow imports from that package within the repo." deprecated:"true" var:"GO_IMPORT_PATH"` + CgoCCTool string `help:"Sets the location of CC while building cgo_library and cgo_test rules. Defaults to gcc" deprecated:"true" var:"CGO_CC_TOOL"` + CgoEnabled string `help:"Sets the CGO_ENABLED which controls whether the cgo build flag is set during cross compilation. Defaults to '0' (disabled)" deprecated:"true" var:"CGO_ENABLED"` + FilterTool string `help:"Sets the location of the please_go_filter tool that is used to filter source files against build constraints." deprecated:"true" var:"GO_FILTER_TOOL"` + PleaseGoTool string `help:"Sets the location of the please_go tool that is used to compile and test go code." deprecated:"true" var:"PLEASE_GO_TOOL"` + EmbedTool string `help:"Sets the location of the please_go_embed tool that is used to parse //go:embed directives." deprecated:"true" var:"GO_EMBED_TOOL"` + DelveTool string `help:"Sets the location of the Delve tool that is used for debugging Go code." deprecated:"true" var:"DELVE_TOOL"` + DefaultStatic bool `help:"Sets Go binaries to default to static linking. Note that enabling this may have negative consequences for some code, including Go's DNS lookup code in the net module." deprecated:"true" var:"GO_DEFAULT_STATIC"` + GoTestRootCompat bool `help:"Changes the behavior of the build rules to be more compatible with go test i.e. please will descend into the package directory to run unit tests as go test does." deprecated:"true" var:"GO_TEST_ROOT_COMPAT"` + CFlags string `help:"Sets the CFLAGS env var for go rules." deprecated:"true" var:"GO_C_FLAGS"` + LDFlags string `help:"Sets the LDFLAGS env var for go rules." deprecated:"true" var:"GO_LD_FLAGS"` } Python struct { - PipTool string `help:"The tool that is invoked during pip_library rules." var:"PIP_TOOL"` - PipFlags string `help:"Additional flags to pass to pip invocations in pip_library rules." var:"PIP_FLAGS"` - PexTool string `help:"The tool that's invoked to build pexes. Defaults to please_pex in the install directory." var:"PEX_TOOL"` - DefaultInterpreter string `help:"The interpreter used for python_binary and python_test rules when none is specified on the rule itself. Defaults to python but you could of course set it to, say, pypy." var:"DEFAULT_PYTHON_INTERPRETER"` - TestRunner string `help:"The test runner used to discover & run Python tests; one of unittest, pytest or behave, or a custom import path to bring your own." var:"PYTHON_TEST_RUNNER"` - TestRunnerBootstrap string `help:"Target providing test-runner library and its transitive dependencies. Injects plz-provided bootstraps if not given." var:"PYTHON_TEST_RUNNER_BOOTSTRAP"` - Debugger string `help:"Sets what debugger to use to debug Python binaries. The available options are: 'pdb' (default) and 'debugpy'." var:"PYTHON_DEBUGGER"` - ModuleDir string `help:"Defines a directory containing modules from which they can be imported at the top level.\nBy default this is empty but by convention we define our pip_library rules in third_party/python and set this appropriately. Hence any of those third-party libraries that try something like import six will have it work as they expect, even though it's actually in a different location within the .pex." var:"PYTHON_MODULE_DIR"` - DefaultPipRepo cli.URL `help:"Defines a location for a pip repo to download wheels from.\nBy default pip_library uses PyPI (although see below on that) but you may well want to use this define another location to upload your own wheels to.\nIs overridden by the repo argument to pip_library." var:"PYTHON_DEFAULT_PIP_REPO"` - WheelRepo cli.URL `help:"Defines a location for a remote repo that python_wheel rules will download from. See python_wheel for more information." var:"PYTHON_WHEEL_REPO"` - UsePyPI bool `help:"Whether or not to use PyPI for pip_library rules or not. Defaults to true, if you disable this you will presumably want to set DefaultPipRepo to use one of your own.\nIs overridden by the use_pypi argument to pip_library." var:"USE_PYPI"` - WheelNameScheme []string `help:"Defines a custom templatized wheel naming scheme. Templatized variables should be surrounded in curly braces, and the available options are: url_base, package_name, version and initial (the first character of package_name). The default search pattern is '{url_base}/{package_name}-{version}-${{OS}}-${{ARCH}}.whl' along with a few common variants." var:"PYTHON_WHEEL_NAME_SCHEME"` - InterpreterOptions string `help:"Options to pass to the python interpeter, when writing shebangs for pex executables." var:"PYTHON_INTERPRETER_OPTIONS"` - DisableVendorFlags bool `help:"Disables injection of vendor specific flags for pip while using pip_library. The option can be useful if you are using something like Pyenv, and the passing of additional flags or configuration that are vendor specific, e.g. --system, breaks your build." var:"DISABLE_VENDOR_FLAGS"` + PipTool string `help:"The tool that is invoked during pip_library rules." deprecated:"true" var:"PIP_TOOL"` + PipFlags string `help:"Additional flags to pass to pip invocations in pip_library rules." deprecated:"true" var:"PIP_FLAGS"` + PexTool string `help:"The tool that's invoked to build pexes. Defaults to please_pex in the install directory." deprecated:"true" var:"PEX_TOOL"` + DefaultInterpreter string `help:"The interpreter used for python_binary and python_test rules when none is specified on the rule itself. Defaults to python but you could of course set it to, say, pypy." deprecated:"true" var:"DEFAULT_PYTHON_INTERPRETER"` + TestRunner string `help:"The test runner used to discover & run Python tests; one of unittest, pytest or behave, or a custom import path to bring your own." deprecated:"true" var:"PYTHON_TEST_RUNNER"` + TestRunnerBootstrap string `help:"Target providing test-runner library and its transitive dependencies. Injects plz-provided bootstraps if not given." deprecated:"true" var:"PYTHON_TEST_RUNNER_BOOTSTRAP"` + Debugger string `help:"Sets what debugger to use to debug Python binaries. The available options are: 'pdb' (default) and 'debugpy'." deprecated:"true" var:"PYTHON_DEBUGGER"` + ModuleDir string `help:"Defines a directory containing modules from which they can be imported at the top level.\nBy default this is empty but by convention we define our pip_library rules in third_party/python and set this appropriately. Hence any of those third-party libraries that try something like import six will have it work as they expect, even though it's actually in a different location within the .pex." deprecated:"true" var:"PYTHON_MODULE_DIR"` + DefaultPipRepo cli.URL `help:"Defines a location for a pip repo to download wheels from.\nBy default pip_library uses PyPI (although see below on that) but you may well want to use this define another location to upload your own wheels to.\nIs overridden by the repo argument to pip_library." deprecated:"true" var:"PYTHON_DEFAULT_PIP_REPO"` + WheelRepo cli.URL `help:"Defines a location for a remote repo that python_wheel rules will download from. See python_wheel for more information." deprecated:"true" var:"PYTHON_WHEEL_REPO"` + UsePyPI bool `help:"Whether or not to use PyPI for pip_library rules or not. Defaults to true, if you disable this you will presumably want to set DefaultPipRepo to use one of your own.\nIs overridden by the use_pypi argument to pip_library." deprecated:"true" var:"USE_PYPI"` + WheelNameScheme []string `help:"Defines a custom templatized wheel naming scheme. Templatized variables should be surrounded in curly braces, and the available options are: url_base, package_name, version and initial (the first character of package_name). The default search pattern is '{url_base}/{package_name}-{version}-${{OS}}-${{ARCH}}.whl' along with a few common variants." deprecated:"true" var:"PYTHON_WHEEL_NAME_SCHEME"` + InterpreterOptions string `help:"Options to pass to the python interpeter, when writing shebangs for pex executables." deprecated:"true" var:"PYTHON_INTERPRETER_OPTIONS"` + DisableVendorFlags bool `help:"Disables injection of vendor specific flags for pip while using pip_library. The option can be useful if you are using something like Pyenv, and the passing of additional flags or configuration that are vendor specific, e.g. --system, breaks your build." deprecated:"true" var:"DISABLE_VENDOR_FLAGS"` } `help:"Please has built-in support for compiling Python.\nPlease's Python artifacts are pex files, which are essentially self-executable zip files containing all needed dependencies, bar the interpreter itself. This fits our aim of at least semi-static binaries for each language.\nSee https://github.com/pantsbuild/pex for more information.\nNote that due to differences between the environment inside a pex and outside some third-party code may not run unmodified (for example, it cannot simply open() files). It's possible to work around a lot of this, but if it all becomes too much it's possible to mark pexes as not zip-safe which typically resolves most of it at a modest speed penalty." exclude:"true"` Java struct { - JavacTool string `help:"Defines the tool used for the Java compiler. Defaults to javac." var:"JAVAC_TOOL"` - JlinkTool string `help:"Defines the tool used for the Java linker. Defaults to jlink." var:"JLINK_TOOL"` - JavaHome string `help:"Defines the path of the Java Home folder." var:"JAVA_HOME"` - JavacWorker string `help:"Defines the tool used for the Java persistent compiler. This is significantly (approx 4x) faster for large Java trees than invoking javac separately each time. Default to javac_worker in the install directory, but can be switched off to fall back to javactool and separate invocation." var:"JAVAC_WORKER"` - JarCatTool string `help:"Defines the tool used to concatenate .jar files which we use to build the output of java_binary, java_test and various other rules. Defaults to arcat in the internal //_please package." var:"JARCAT_TOOL"` - JUnitRunner string `help:"Defines the .jar containing the JUnit runner. This is built into all java_test rules since it's necessary to make JUnit do anything useful.\nDefaults to junit_runner.jar in the internal //_please package." var:"JUNIT_RUNNER"` - DefaultTestPackage string `help:"The Java classpath to search for functions annotated with @Test. If not specified the compiled sources will be searched for files named *Test.java." var:"DEFAULT_TEST_PACKAGE"` - ReleaseLevel string `help:"The default Java release level when compiling.\nSourceLevel and TargetLevel are ignored if this is set. Bear in mind that this flag is only supported in Java version 9+." var:"JAVA_RELEASE_LEVEL"` - SourceLevel string `help:"The default Java source level when compiling. Defaults to 8." var:"JAVA_SOURCE_LEVEL"` - TargetLevel string `help:"The default Java bytecode level to target. Defaults to 8." var:"JAVA_TARGET_LEVEL"` - JavacFlags string `help:"Additional flags to pass to javac when compiling libraries." example:"-Xmx1200M" var:"JAVAC_FLAGS"` - JavacTestFlags string `help:"Additional flags to pass to javac when compiling tests." example:"-Xmx1200M" var:"JAVAC_TEST_FLAGS"` - DefaultMavenRepo []cli.URL `help:"Default location to load artifacts from in maven_jar rules. Can be overridden on a per-rule basis." var:"DEFAULT_MAVEN_REPO"` - Toolchain string `help:"A label identifying a java_toolchain." var:"JAVA_TOOLCHAIN"` + JavacTool string `help:"Defines the tool used for the Java compiler. Defaults to javac." deprecated:"true" var:"JAVAC_TOOL"` + JlinkTool string `help:"Defines the tool used for the Java linker. Defaults to jlink." deprecated:"true" var:"JLINK_TOOL"` + JavaHome string `help:"Defines the path of the Java Home folder." deprecated:"true" var:"JAVA_HOME"` + JavacWorker string `help:"Defines the tool used for the Java persistent compiler. This is significantly (approx 4x) faster for large Java trees than invoking javac separately each time. Default to javac_worker in the install directory, but can be switched off to fall back to javactool and separate invocation." deprecated:"true" var:"JAVAC_WORKER"` + JarCatTool string `help:"Defines the tool used to concatenate .jar files which we use to build the output of java_binary, java_test and various other rules. Defaults to arcat in the internal //_please package." deprecated:"true" var:"JARCAT_TOOL"` + JUnitRunner string `help:"Defines the .jar containing the JUnit runner. This is built into all java_test rules since it's necessary to make JUnit do anything useful.\nDefaults to junit_runner.jar in the internal //_please package." deprecated:"true" var:"JUNIT_RUNNER"` + DefaultTestPackage string `help:"The Java classpath to search for functions annotated with @Test. If not specified the compiled sources will be searched for files named *Test.java." deprecated:"true" var:"DEFAULT_TEST_PACKAGE"` + ReleaseLevel string `help:"The default Java release level when compiling.\nSourceLevel and TargetLevel are ignored if this is set. Bear in mind that this flag is only supported in Java version 9+." deprecated:"true" var:"JAVA_RELEASE_LEVEL"` + SourceLevel string `help:"The default Java source level when compiling. Defaults to 8." deprecated:"true" var:"JAVA_SOURCE_LEVEL"` + TargetLevel string `help:"The default Java bytecode level to target. Defaults to 8." deprecated:"true" var:"JAVA_TARGET_LEVEL"` + JavacFlags string `help:"Additional flags to pass to javac when compiling libraries." example:"-Xmx1200M" deprecated:"true" var:"JAVAC_FLAGS"` + JavacTestFlags string `help:"Additional flags to pass to javac when compiling tests." example:"-Xmx1200M" deprecated:"true" var:"JAVAC_TEST_FLAGS"` + DefaultMavenRepo []cli.URL `help:"Default location to load artifacts from in maven_jar rules. Can be overridden on a per-rule basis." deprecated:"true" var:"DEFAULT_MAVEN_REPO"` + Toolchain string `help:"A label identifying a java_toolchain." deprecated:"true" var:"JAVA_TOOLCHAIN"` } Cpp struct { - CCTool string `help:"The tool invoked to compile C code. Defaults to gcc but you might want to set it to clang, for example." var:"CC_TOOL"` - CppTool string `help:"The tool invoked to compile C++ code. Defaults to g++ but you might want to set it to clang++, for example." var:"CPP_TOOL"` - LdTool string `help:"The tool invoked to link object files. Defaults to ld but you could also set it to gold, for example." var:"LD_TOOL"` - ArTool string `help:"The tool invoked to archive static libraries. Defaults to ar." var:"AR_TOOL"` - LinkWithLdTool bool `help:"If true, instructs Please to use the tool set earlier in ldtool to link binaries instead of cctool.\nThis is an esoteric setting that most people don't want; a vanilla ld will not perform all steps necessary here (you'll get lots of missing symbol messages from having no libc etc). Generally best to leave this disabled unless you have very specific requirements." var:"LINK_WITH_LD_TOOL"` - DefaultOptCflags string `help:"Compiler flags passed to all C rules during opt builds; these are typically pretty basic things like what language standard you want to target, warning flags, etc.\nDefaults to --std=c99 -O3 -DNDEBUG -Wall -Wextra -Werror" var:"DEFAULT_OPT_CFLAGS"` - DefaultDbgCflags string `help:"Compiler rules passed to all C rules during dbg builds.\nDefaults to --std=c99 -g3 -DDEBUG -Wall -Wextra -Werror." var:"DEFAULT_DBG_CFLAGS"` - DefaultOptCppflags string `help:"Compiler flags passed to all C++ rules during opt builds; these are typically pretty basic things like what language standard you want to target, warning flags, etc.\nDefaults to --std=c++11 -O3 -DNDEBUG -Wall -Wextra -Werror" var:"DEFAULT_OPT_CPPFLAGS"` - DefaultDbgCppflags string `help:"Compiler rules passed to all C++ rules during dbg builds.\nDefaults to --std=c++11 -g3 -DDEBUG -Wall -Wextra -Werror." var:"DEFAULT_DBG_CPPFLAGS"` - DefaultLdflags string `help:"Linker flags passed to all C++ rules.\nBy default this is empty." var:"DEFAULT_LDFLAGS"` - PkgConfigPath string `help:"Custom PKG_CONFIG_PATH for pkg-config.\nBy default this is empty." var:"PKG_CONFIG_PATH"` - Coverage bool `help:"If true (the default), coverage will be available for C and C++ build rules.\nThis is still a little experimental but should work for GCC. Right now it does not work for Clang (it likely will in Clang 4.0 which will likely support --fprofile-dir) and so this can be useful to disable it.\nIt's also useful in some cases for CI systems etc if you'd prefer to avoid the overhead, since the tests have to be compiled with extra instrumentation and without optimisation." var:"CPP_COVERAGE"` - TestMain BuildLabel `help:"The build target to use for the default main for C++ test rules." example:"///pleasings//cc:unittest_main" var:"CC_TEST_MAIN"` - ClangModules bool `help:"Uses Clang-style arguments for compiling cc_module rules. If disabled gcc-style arguments will be used instead. Experimental, expected to be removed at some point once module compilation methods are more consistent." var:"CC_MODULES_CLANG"` - DsymTool string `help:"Set this to dsymutil or equivalent on macOS to use this tool to generate xcode symbol information for debug builds." var:"DSYM_TOOL"` + CCTool string `help:"The tool invoked to compile C code. Defaults to gcc but you might want to set it to clang, for example." deprecated:"true" var:"CC_TOOL"` + CppTool string `help:"The tool invoked to compile C++ code. Defaults to g++ but you might want to set it to clang++, for example." deprecated:"true" var:"CPP_TOOL"` + LdTool string `help:"The tool invoked to link object files. Defaults to ld but you could also set it to gold, for example." deprecated:"true" var:"LD_TOOL"` + ArTool string `help:"The tool invoked to archive static libraries. Defaults to ar." deprecated:"true" var:"AR_TOOL"` + LinkWithLdTool bool `help:"If true, instructs Please to use the tool set earlier in ldtool to link binaries instead of cctool.\nThis is an esoteric setting that most people don't want; a vanilla ld will not perform all steps necessary here (you'll get lots of missing symbol messages from having no libc etc). Generally best to leave this disabled unless you have very specific requirements." deprecated:"true" var:"LINK_WITH_LD_TOOL"` + DefaultOptCflags string `help:"Compiler flags passed to all C rules during opt builds; these are typically pretty basic things like what language standard you want to target, warning flags, etc.\nDefaults to --std=c99 -O3 -DNDEBUG -Wall -Wextra -Werror" deprecated:"true" var:"DEFAULT_OPT_CFLAGS"` + DefaultDbgCflags string `help:"Compiler rules passed to all C rules during dbg builds.\nDefaults to --std=c99 -g3 -DDEBUG -Wall -Wextra -Werror." deprecated:"true" var:"DEFAULT_DBG_CFLAGS"` + DefaultOptCppflags string `help:"Compiler flags passed to all C++ rules during opt builds; these are typically pretty basic things like what language standard you want to target, warning flags, etc.\nDefaults to --std=c++11 -O3 -DNDEBUG -Wall -Wextra -Werror" deprecated:"true" var:"DEFAULT_OPT_CPPFLAGS"` + DefaultDbgCppflags string `help:"Compiler rules passed to all C++ rules during dbg builds.\nDefaults to --std=c++11 -g3 -DDEBUG -Wall -Wextra -Werror." deprecated:"true" var:"DEFAULT_DBG_CPPFLAGS"` + DefaultLdflags string `help:"Linker flags passed to all C++ rules.\nBy default this is empty." deprecated:"true" var:"DEFAULT_LDFLAGS"` + PkgConfigPath string `help:"Custom PKG_CONFIG_PATH for pkg-config.\nBy default this is empty." deprecated:"true" var:"PKG_CONFIG_PATH"` + Coverage bool `help:"If true (the default), coverage will be available for C and C++ build rules.\nThis is still a little experimental but should work for GCC. Right now it does not work for Clang (it likely will in Clang 4.0 which will likely support --fprofile-dir) and so this can be useful to disable it.\nIt's also useful in some cases for CI systems etc if you'd prefer to avoid the overhead, since the tests have to be compiled with extra instrumentation and without optimisation." deprecated:"true" var:"CPP_COVERAGE"` + TestMain BuildLabel `help:"The build target to use for the default main for C++ test rules." example:"///pleasings//cc:unittest_main" deprecated:"true" var:"CC_TEST_MAIN"` + ClangModules bool `help:"Uses Clang-style arguments for compiling cc_module rules. If disabled gcc-style arguments will be used instead. Experimental, expected to be removed at some point once module compilation methods are more consistent." deprecated:"true" var:"CC_MODULES_CLANG"` + DsymTool string `help:"Set this to dsymutil or equivalent on macOS to use this tool to generate xcode symbol information for debug builds." deprecated:"true" var:"DSYM_TOOL"` } Proto struct { - ProtocTool string `help:"The binary invoked to compile .proto files. Defaults to protoc." var:"PROTOC_TOOL"` - ProtocGoPlugin string `help:"The binary passed to protoc as a plugin to generate Go code. Defaults to protoc-gen-go.\nWe've found this easier to manage with a go_get rule instead though, so you can also pass a build label here. See the Please repo for an example." var:"PROTOC_GO_PLUGIN"` - GrpcPythonPlugin string `help:"The plugin invoked to compile Python code for grpc_library.\nDefaults to protoc-gen-grpc-python." var:"GRPC_PYTHON_PLUGIN"` - GrpcJavaPlugin string `help:"The plugin invoked to compile Java code for grpc_library.\nDefaults to protoc-gen-grpc-java." var:"GRPC_JAVA_PLUGIN"` - GrpcGoPlugin string `help:"The plugin invoked to compile Go code for grpc_library.\nIf not set, then the protoc plugin will be used instead." var:"GRPC_GO_PLUGIN"` - GrpcCCPlugin string `help:"The plugin invoked to compile C++ code for grpc_library.\nDefaults to grpc_cpp_plugin." var:"GRPC_CC_PLUGIN"` - Language []string `help:"Sets the default set of languages that proto rules are built for.\nChosen from the set of {cc, java, go, py}.\nDefaults to all of them!" var:"PROTO_LANGUAGES"` - PythonDep string `help:"An in-repo dependency that's applied to any Python proto libraries." var:"PROTO_PYTHON_DEP"` - JavaDep string `help:"An in-repo dependency that's applied to any Java proto libraries." var:"PROTO_JAVA_DEP"` - GoDep string `help:"An in-repo dependency that's applied to any Go proto libraries." var:"PROTO_GO_DEP"` - JsDep string `help:"An in-repo dependency that's applied to any Javascript proto libraries." var:"PROTO_JS_DEP"` - PythonGrpcDep string `help:"An in-repo dependency that's applied to any Python gRPC libraries." var:"GRPC_PYTHON_DEP"` - JavaGrpcDep string `help:"An in-repo dependency that's applied to any Java gRPC libraries." var:"GRPC_JAVA_DEP"` - GoGrpcDep string `help:"An in-repo dependency that's applied to any Go gRPC libraries." var:"GRPC_GO_DEP"` - ProtocFlag []string `help:"Flags to pass to protoc i.e. the location of well known types. Can be repeated." var:"PROTOC_FLAGS"` + ProtocTool string `help:"The binary invoked to compile .proto files. Defaults to protoc." deprecated:"true" var:"PROTOC_TOOL"` + ProtocGoPlugin string `help:"The binary passed to protoc as a plugin to generate Go code. Defaults to protoc-gen-go.\nWe've found this easier to manage with a go_get rule instead though, so you can also pass a build label here. See the Please repo for an example." deprecated:"true" var:"PROTOC_GO_PLUGIN"` + GrpcPythonPlugin string `help:"The plugin invoked to compile Python code for grpc_library.\nDefaults to protoc-gen-grpc-python." deprecated:"true" var:"GRPC_PYTHON_PLUGIN"` + GrpcJavaPlugin string `help:"The plugin invoked to compile Java code for grpc_library.\nDefaults to protoc-gen-grpc-java." deprecated:"true" var:"GRPC_JAVA_PLUGIN"` + GrpcGoPlugin string `help:"The plugin invoked to compile Go code for grpc_library.\nIf not set, then the protoc plugin will be used instead." deprecated:"true" var:"GRPC_GO_PLUGIN"` + GrpcCCPlugin string `help:"The plugin invoked to compile C++ code for grpc_library.\nDefaults to grpc_cpp_plugin." deprecated:"true" var:"GRPC_CC_PLUGIN"` + Language []string `help:"Sets the default set of languages that proto rules are built for.\nChosen from the set of {cc, java, go, py}.\nDefaults to all of them!" deprecated:"true" var:"PROTO_LANGUAGES"` + PythonDep string `help:"An in-repo dependency that's applied to any Python proto libraries." deprecated:"true" var:"PROTO_PYTHON_DEP"` + JavaDep string `help:"An in-repo dependency that's applied to any Java proto libraries." deprecated:"true" var:"PROTO_JAVA_DEP"` + GoDep string `help:"An in-repo dependency that's applied to any Go proto libraries." deprecated:"true" var:"PROTO_GO_DEP"` + JsDep string `help:"An in-repo dependency that's applied to any Javascript proto libraries." deprecated:"true" var:"PROTO_JS_DEP"` + PythonGrpcDep string `help:"An in-repo dependency that's applied to any Python gRPC libraries." deprecated:"true" var:"GRPC_PYTHON_DEP"` + JavaGrpcDep string `help:"An in-repo dependency that's applied to any Java gRPC libraries." deprecated:"true" var:"GRPC_JAVA_DEP"` + GoGrpcDep string `help:"An in-repo dependency that's applied to any Go gRPC libraries." deprecated:"true" var:"GRPC_GO_DEP"` + ProtocFlag []string `help:"Flags to pass to protoc i.e. the location of well known types. Can be repeated." deprecated:"true" var:"PROTOC_FLAGS"` } Licences struct { Accept []string `help:"Licences that are accepted in this repository.\nWhen this is empty licences are ignored. As soon as it's set any licence detected or assigned must be accepted explicitly here.\nThere's no fuzzy matching, so some package managers (especially PyPI and Maven, but shockingly not npm which rather nicely uses SPDX) will generate a lot of slightly different spellings of the same thing, which will all have to be accepted here. We'd rather that than trying to 'cleverly' match them which might result in matching the wrong thing."` @@ -691,6 +691,7 @@ type Configuration struct { buildEnvStored *storedBuildEnv FeatureFlags struct { + HideDeprecatedConfigOptions bool `help:"Don't expose deprecated config options to the BUILD language"` } `help:"Flags controlling preview features for the next release. Typically these config options gate breaking changes and only have a lifetime of one major release."` Metrics struct { PrometheusGatewayURL string `help:"The gateway URL to push prometheus updates to."` diff --git a/src/help/config.go b/src/help/config.go index 89b7336ff1..c31a58c7d7 100644 --- a/src/help/config.go +++ b/src/help/config.go @@ -79,6 +79,9 @@ func allConfigHelp(config *core.Configuration) helpSection { help += fmt.Sprintf("\nThis variable is exposed to BUILD rules via the variable ${BOLD_CYAN}CONFIG.%s${RESET},\n"+ "and can be overridden package-locally via ${GREEN}package${RESET}(${YELLOW}%s${RESET}='${GREY}${RESET}').\n", v, strings.ToLower(v)) } + if subt.Tag.Get("deprecated") == "true" { + help += "\n${BOLD_RED}This config option is deprecated and will be removed at the next Please major version.${RESET}\n" + } sect.Topics[name] = help sect.Topics[sectname+"."+name] = help subfields = append(subfields, " "+name) diff --git a/src/parse/asp/config.go b/src/parse/asp/config.go index 5d76b79d4a..6aa22e30f4 100644 --- a/src/parse/asp/config.go +++ b/src/parse/asp/config.go @@ -38,12 +38,15 @@ func newConfig(state *core.BuildState) *pyConfig { base := make(pyDict, 100) v := reflect.ValueOf(state.Config).Elem() + emitDeprecated := !state.Config.FeatureFlags.HideDeprecatedConfigOptions for i := 0; i < v.NumField(); i++ { if field := v.Field(i); field.Kind() == reflect.Struct { for j := 0; j < field.NumField(); j++ { subfieldType := field.Type().Field(j) if varName := subfieldType.Tag.Get("var"); varName != "" { - base[varName] = valueToPyObject(field.Field(j)) + if subfieldType.Tag.Get("deprecated") != "true" || emitDeprecated { + base[varName] = valueToPyObject(field.Field(j)) + } } } } diff --git a/test/build_defs/BUILD b/test/build_defs/BUILD index a3db1ca2d6..46e36c7918 100644 --- a/test/build_defs/BUILD +++ b/test/build_defs/BUILD @@ -25,12 +25,6 @@ filegroup( ], ) -filegroup( - name = "cc_embed_binary", - srcs = ["cc_embed_binary.build_defs"], - visibility = ["//test/..."], -) - # Used for some of the parse tests that want a subinclude that isn't visible to them. filegroup( name = "not_visible", diff --git a/test/build_defs/cc_embed_binary.build_defs b/test/build_defs/cc_embed_binary.build_defs deleted file mode 100644 index d17aac957d..0000000000 --- a/test/build_defs/cc_embed_binary.build_defs +++ /dev/null @@ -1,206 +0,0 @@ -def cc_embed_binary(name:str, src:str, deps:list=[], visibility:list=None, - test_only:bool&testonly=False, namespace:str=None, _c:bool=False): - """Build rule to embed an arbitrary binary file into a C++ library. - - You can depend on the output of this as though it were a cc_library rule. - There are five functions available to access the data once compiled, all of which are - prefixed with the file's basename: - filename_start(): returns a const char* pointing to the beginning of the data. - filename_end(): returns a const char* pointing to the end of the data. - filename_size(): returns the length of the data in bytes. - filename_start_nc(): returns a char* pointing to the beginning of the data. - This is a convenience wrapper using const_cast, you should not - mutate the contents of the returned pointer. - filename_end_nc(): returns a char* pointing to the end of the data. - Again, don't mutate the contents of the pointer. - You don't own the contents of any of these pointers so don't try to delete them :) - - Args: - name (str): Name of the rule. - src (str): Source file to embed. - deps (list): Dependencies. - visibility (list): Rule visibility. - test_only (bool): If True, is only available to test rules. - namespace (str): Allows specifying the namespace the symbols will be available in. - """ - if src.startswith(':') or src.startswith('/'): - deps += [src] - namespace = namespace or CONFIG.DEFAULT_NAMESPACE - # Just use the C (non-namespaced) version if no namespace is given. - if not namespace: - _c = True - darwin = CONFIG.OS == 'darwin' - hdr_contents = _C_HEADER_CONTENTS if _c else _CC_HEADER_CONTENTS - hdr_rule = build_rule( - name = name, - tag = 'hdr', - outs = [name + '.h'], - srcs = [src], - deps = deps, - cmd = '; '.join([ - # This replacement roughly mimics what ld will do to munge it into a symbol name. - 'export ENCODED_FILENAME="${SRCS//[\\/\\.]/_}"', - f'export BINARY_NAME="{name}"', - f'export NAMESPACE="{namespace}"', - f'echo "{hdr_contents}" > "$OUT"', - ]), - visibility = visibility, - building_description = 'Writing header...', - requires = ['cc'], - test_only = test_only, - ) - - tools = {'arcat': [CONFIG.ARCAT_TOOL], 'ar': [CONFIG.AR_TOOL]} - if darwin: - # OSX's ld doesn't support '--format binary', and this is the least fiddly - # alternative. Requiring an additional tool is a bit suboptimal but probably - # in the end easier than the alternatives. - cmd = ' && '.join([ - 'export ENCODED_FILENAME=${SRCS//[\\/\\.]/_}', - f'echo "{_CC_DARWIN_ASM_CONTENTS}" > embedded.asm', - '$TOOLS_ASM -fmacho64 embedded.asm -o ${OUTS/.a/.o}', - '$TOOLS_ARCAT ar --srcs ${OUTS/.a/.o}', - '$TOOLS_AR s "$OUTS"', - ]) - tools['asm'] = [CONFIG.ASM_TOOL] - else: - cmd = '$TOOLS_LD -r --format binary -z noexecstack -m elf_$XARCH %s -o "${OUTS/.a/.o}" $SRC && $TOOLS_ARCAT ar --srcs "${OUTS/.a/.o}" && $TOOLS_AR s "$OUTS"' % CONFIG.DEFAULT_LDFLAGS - tools['ld'] = [CONFIG.LD_TOOL] - - lib_rule = build_rule( - name = name, - tag = 'lib', - srcs = [src], - outs = ['lib%s.a' % name], - deps = deps, - cmd = cmd, - visibility = visibility, - building_description = 'Embedding...', - requires = ['cc'], - tools = tools, - test_only = test_only, - ) - return filegroup( - name = name, - srcs = [lib_rule, hdr_rule], - visibility = visibility, - test_only = test_only, - provides = { - 'cc_hdrs': hdr_rule, - 'cc': lib_rule, - }, - ) - - -def c_embed_binary(name:str, src:str, deps:list=[], visibility:list=None, - test_only:bool&testonly=False): - """Build rule to embed an arbitrary binary file into a C library. - - You can depend on the output of this as though it were a c_library rule. - There are five functions available to access the data once compiled, all of which are - prefixed with the file's basename: - filename_start(): returns a const char* pointing to the beginning of the data. - filename_end(): returns a const char* pointing to the end of the data. - filename_size(): returns the length of the data in bytes. - filename_start_nc(): returns a char* pointing to the beginning of the data. - This is a convenience wrapper using const_cast, you should not - mutate the contents of the returned pointer. - filename_end_nc(): returns a char* pointing to the end of the data. - Again, don't mutate the contents of the pointer. - You don't own the contents of any of these pointers so don't try to delete them :) - - Args: - name (str): Name of the rule. - src (str): Source file to embed. - deps (list): Dependencies. - visibility (list): Rule visibility. - test_only (bool): If True, is only available to test rules. - """ - return cc_embed_binary( - name = name, - src = src, - deps = deps, - visibility = visibility, - test_only = test_only, - _c = True, - ) - - -_CC_HEADER_CONTENTS = """\ -#ifdef __cplusplus -namespace ${NAMESPACE} { -extern \\"C\\" { -#endif // __cplusplus -extern const char _binary_${ENCODED_FILENAME}_start[]; -extern const char _binary_${ENCODED_FILENAME}_end[]; -#ifdef __cplusplus -} -#endif // __cplusplus - -// Nicer aliases. -static inline const char* ${BINARY_NAME}_start() { - return _binary_${ENCODED_FILENAME}_start; -} -static inline const char* ${BINARY_NAME}_end() { - return _binary_${ENCODED_FILENAME}_end; -} -static inline unsigned long ${BINARY_NAME}_size() { - return _binary_${ENCODED_FILENAME}_end - _binary_${ENCODED_FILENAME}_start; -} -static inline char* ${BINARY_NAME}_start_nc() { - return (char*)(_binary_${ENCODED_FILENAME}_start); -} -static inline char* ${BINARY_NAME}_end_nc() { - return (char*)(_binary_${ENCODED_FILENAME}_end); -} -#ifdef __cplusplus -} // namespace ${NAMESPACE} -#endif // __cplusplus -""" - -_C_HEADER_CONTENTS = """\ -extern const char _binary_${ENCODED_FILENAME}_start[]; -extern const char _binary_${ENCODED_FILENAME}_end[]; - -static inline const char* ${BINARY_NAME}_start() { - return _binary_${ENCODED_FILENAME}_start; -} -static inline const char* ${BINARY_NAME}_end() { - return _binary_${ENCODED_FILENAME}_end; -} -static inline unsigned long ${BINARY_NAME}_size() { - return _binary_${ENCODED_FILENAME}_end - _binary_${ENCODED_FILENAME}_start; -} -static inline char* ${BINARY_NAME}_start_nc() { - return (char*)(_binary_${ENCODED_FILENAME}_start); -} -static inline char* ${BINARY_NAME}_end_nc() { - return (char*)(_binary_${ENCODED_FILENAME}_end); -} -""" - -# We duplicate the symbols with _ and __ preceding, the compiler fails if _ is not -# present and the linker fails if __ isn't. -_CC_DARWIN_ASM_CONTENTS = r""" -bits 64 - -section .rodata - -global _binary_${ENCODED_FILENAME}_start -global __binary_${ENCODED_FILENAME}_start -global _binary_${ENCODED_FILENAME}_end -global __binary_${ENCODED_FILENAME}_end -global _binary_${ENCODED_FILENAME}_size -global __binary_${ENCODED_FILENAME}_size - -_binary_${ENCODED_FILENAME}_start: incbin \"${SRCS}\" -__binary_${ENCODED_FILENAME}_start: incbin \"${SRCS}\" -_binary_${ENCODED_FILENAME}_end: -__binary_${ENCODED_FILENAME}_end: -_binary_${ENCODED_FILENAME}_size: dd \\$-_binary_${ENCODED_FILENAME}_start -__binary_${ENCODED_FILENAME}_size: dd \\$-_binary_${ENCODED_FILENAME}_start -""" - - -CONFIG.setdefault('ASM_TOOL', 'nasm') -CONFIG.setdefault('DEFAULT_NAMESPACE', '') diff --git a/test/cross_compile/lib/BUILD b/test/cross_compile/lib/BUILD index fb7af1e3e0..6a5c6cc698 100644 --- a/test/cross_compile/lib/BUILD +++ b/test/cross_compile/lib/BUILD @@ -1,7 +1,7 @@ # This contains an arbitrary set of rules intended to exercise # aspects of the cross-compilation code. -subinclude("//test/build_defs:cc_embed_binary", "///cc//build_defs:c") +subinclude("///cc//build_defs:c", "///cc//build_defs:cc_embed_binary") go_binary( name = "generator", diff --git a/test/parse/pre_post_build_config/BUILD.test b/test/parse/pre_post_build_config/BUILD.test index 6e4025520b..daf53a357d 100644 --- a/test/parse/pre_post_build_config/BUILD.test +++ b/test/parse/pre_post_build_config/BUILD.test @@ -1,6 +1,7 @@ -package(GO_TOOL = "foo") +package(go = { + "go_tool": "foo", +}) subinclude("//test/parse/pre_post_build_config/build_defs:build_foo") build_foo(name = "target") - diff --git a/test/parse/pre_post_build_config/build_defs/build_foo.build_defs b/test/parse/pre_post_build_config/build_defs/build_foo.build_defs index 6b02da0d67..3912c22d09 100644 --- a/test/parse/pre_post_build_config/build_defs/build_foo.build_defs +++ b/test/parse/pre_post_build_config/build_defs/build_foo.build_defs @@ -1,8 +1,8 @@ def _prebuild(x): - assert CONFIG.GO_TOOL == "foo" + assert CONFIG.GO.GO_TOOL == "foo" def _postbuild(x, y): - assert CONFIG.GO_TOOL == "foo" + assert CONFIG.GO.GO_TOOL == "foo" def build_foo(name): return build_rule( @@ -11,4 +11,3 @@ def build_foo(name): pre_build = _prebuild, post_build = _postbuild, ) -