Skip to content

Commit

Permalink
Deprecate built-in Skylark rules
Browse files Browse the repository at this point in the history
RELNOTES: Skylark rules that are available from their own repository will now
issue a warning when accessed through @bazel_tools.

--
MOS_MIGRATED_REVID=117730793
  • Loading branch information
kchodorow authored and damienmg committed Mar 21, 2016
1 parent fbcfd50 commit 19b5675
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 29 deletions.
15 changes: 15 additions & 0 deletions tools/build_defs/d/d.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@

"""D rules for Bazel."""

load("//tools/build_rules:deprecation.bzl", "deprecated")

def warning(rule):
print(deprecated(
"d",
rule,
"@bazel_tools//tools/build_defs/d:d.bzl",
"@io_bazel_rules_d//d:d.bzl"))

A_FILETYPE = FileType([".a"])

D_FILETYPE = FileType([
Expand Down Expand Up @@ -198,6 +207,7 @@ def _setup_deps(deps, name, working_dir):

def _d_library_impl(ctx):
"""Implementation of the d_library rule."""
warning("d_library")
d_lib = ctx.outputs.d_lib

# Dependencies
Expand Down Expand Up @@ -296,14 +306,17 @@ def _d_binary_impl_common(ctx, extra_flags=[]):

def _d_binary_impl(ctx):
"""Implementation of the d_binary rule."""
warning("d_binary")
return _d_binary_impl_common(ctx)

def _d_test_impl(ctx):
"""Implementation of the d_test rule."""
warning("d_test")
return _d_binary_impl_common(ctx, extra_flags=["-unittest"])

def _d_source_library_impl(ctx):
"""Implementation of the d_source_library rule."""
warning("d_library")
transitive_d_srcs = set(order="compile")
transitive_libs = set()
transitive_imports = set()
Expand Down Expand Up @@ -345,6 +358,7 @@ def _d_docs_impl(ctx):
documentation.
2. Create a ZIP archive containing the HTML documentation.
"""
warning("d_docs")
d_docs_zip = ctx.outputs.d_docs
docs_dir = d_docs_zip.dirname + "/_d_docs"
objs_dir = d_docs_zip.dirname + "/_d_objs"
Expand Down Expand Up @@ -504,6 +518,7 @@ filegroup(
"""

def d_repositories():
warning("d_repositories")
native.new_http_archive(
name = "dmd_linux_x86_64",
url = "http://downloads.dlang.org/releases/2.x/2.070.0/dmd.2.070.0.linux.tar.xz",
Expand Down
70 changes: 45 additions & 25 deletions tools/build_defs/dotnet/csharp.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@

"""CSharp bazel rules"""

load("//tools/build_rules:deprecation.bzl", "deprecated")

def warning(rule):
print(deprecated(
"dotnet",
rule,
"@bazel_tools//tools/build_defs/dotnet:csharp.bzl",
"@io_bazel_rules_dotnet//dotnet:csharp.bzl"))

_MONO_UNIX_CSC = "/usr/local/bin/mcs"

# TODO(jeremy): Windows when it's available.
Expand Down Expand Up @@ -161,8 +170,8 @@ def _cs_runfiles(ctx, outputs, depinfo):
files = outputs,
transitive_files = set(depinfo.dlls + depinfo.transitive_dlls) or None)


def _csc_compile_impl(ctx):
warning("csharp_library")
if hasattr(ctx.outputs, "csc_lib") and hasattr(ctx.outputs, "csc_exe"):
fail("exactly one of csc_lib and csc_exe must be defined")

Expand Down Expand Up @@ -191,6 +200,7 @@ def _csc_compile_impl(ctx):
runfiles=runfiles)

def _cs_nunit_run_impl(ctx):
warning("csharp_nunit_test")
if hasattr(ctx.outputs, "csc_lib") and hasattr(ctx.outputs, "csc_exe"):
fail("exactly one of csc_lib and csc_exe must be defined")

Expand Down Expand Up @@ -220,66 +230,75 @@ def _cs_nunit_run_impl(ctx):

_COMMON_ATTRS = {
# configuration fragment that specifies
"_flag_start": attr.string(default="-"),
"_flag_start": attr.string(default = "-"),
# where the csharp compiler is.
"csc": attr.string(default=_MONO_UNIX_CSC),
"csc": attr.string(default = _MONO_UNIX_CSC),
# code dependencies for this rule.
# all dependencies must provide an out field.
"deps": attr.label_list(providers=["out", "target_type"]),
"deps": attr.label_list(providers = [
"out",
"target_type",
]),
# source files for this target.
"srcs": attr.label_list(allow_files = FileType([".cs", ".resx"])),
"srcs": attr.label_list(allow_files = FileType([
".cs",
".resx",
])),
# resources to use as dependencies.
# TODO(jeremy): "resources_deps": attr.label_list(allow_files=True),
#TODO(jeremy): # name of the module if you are creating a module.
#TODO(jeremy): "modulename": attri.string(),
# warn level to use
"warn": attr.int(default=4),
"warn": attr.int(default = 4),
# define preprocessor symbols.
#TODO(jeremy): "define": attr.string_list(),
}

_LIB_ATTRS={"_target_type": attr.string(default="library")}
_LIB_ATTRS = {"_target_type": attr.string(default = "library")}

_EXE_ATTRS={
"_target_type": attr.string(default="exe"),
_EXE_ATTRS = {
"_target_type": attr.string(default = "exe"),
# main class to use as entry point.
"main_class": attr.string(),
}

_NUNIT_ATTRS={
"_nunit_exe": attr.label(default=Label("@nunit//:nunit_exe"),
single_file=True),
"_nunit_framework": attr.label(default=Label("@nunit//:nunit_framework")),
"_nunit_exe_libs": attr.label(default=Label("@nunit//:nunit_exe_libs")),
_NUNIT_ATTRS = {
"_nunit_exe": attr.label(
default = Label("@nunit//:nunit_exe"),
single_file = True,
),
"_nunit_framework": attr.label(default = Label("@nunit//:nunit_framework")),
"_nunit_exe_libs": attr.label(default = Label("@nunit//:nunit_exe_libs")),
}

_LIB_OUTPUTS={
_LIB_OUTPUTS = {
"csc_lib": "%{name}.dll",
"doc_xml": "%{name}.xml",
}

_BIN_OUTPUTS={
_BIN_OUTPUTS = {
"csc_exe": "%{name}.exe",
}

csharp_library = rule(
implementation=_csc_compile_impl,
attrs=_COMMON_ATTRS + _LIB_ATTRS,
attrs = _COMMON_ATTRS + _LIB_ATTRS,
outputs = _LIB_OUTPUTS,
implementation = _csc_compile_impl,
)

csharp_binary = rule(
implementation=_csc_compile_impl,
attrs=_COMMON_ATTRS + _EXE_ATTRS,
attrs = _COMMON_ATTRS + _EXE_ATTRS,
executable = True,
outputs = _BIN_OUTPUTS,
executable=True)
implementation = _csc_compile_impl,
)

csharp_nunit_test = rule(
implementation=_cs_nunit_run_impl,
executable=True,
attrs=_COMMON_ATTRS + _LIB_ATTRS +_NUNIT_ATTRS,
attrs = _COMMON_ATTRS + _LIB_ATTRS + _NUNIT_ATTRS,
executable = True,
outputs = _LIB_OUTPUTS,
test=True
test = True,
implementation = _cs_nunit_run_impl,
)

NUNIT_BUILD_FILE = """
Expand All @@ -303,6 +322,7 @@ filegroup(
"""

def csharp_repositories():
warning("csharp_repositories")
native.new_http_archive(
name = "nunit",
build_file_content = NUNIT_BUILD_FILE,
Expand Down
17 changes: 17 additions & 0 deletions tools/build_defs/groovy/groovy.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("//tools/build_rules:deprecation.bzl", "deprecated")

def warning(rule):
print(deprecated(
"groovy",
rule,
"@bazel_tools//tools/build_defs/groovy:groovy.bzl",
"@io_bazel_rules_groovy//groovy:groovy.bzl"))

def _groovy_jar_impl(ctx):
"""Creates a .jar file from Groovy sources. Users should rely on
groovy_library instead of using this rule directly.
"""
warning("groovy_jar")
class_jar = ctx.outputs.class_jar
build_output = class_jar.path + ".build_output"

Expand Down Expand Up @@ -112,6 +122,7 @@ def groovy_library(name, srcs=[], deps=[], **kwargs):
.java sources. The result is wrapped in a java_import so that java rules may
depend on it.
"""
warning("groovy_library")
_groovy_jar(
name = name + "-impl",
srcs = srcs,
Expand All @@ -129,6 +140,7 @@ def groovy_and_java_library(name, srcs=[], deps=[], **kwargs):
java_library. The groovy_library will depend on the java_library, so the
Groovy code may reference the Java code but not vice-versa.
"""
warning("groovy_and_java_library")
groovy_deps = deps
jars = []

Expand Down Expand Up @@ -165,6 +177,7 @@ def groovy_binary(name, main_class, srcs=[], deps=[], **kwargs):
"""Rule analagous to java_binary that accepts .groovy sources instead of .java
sources.
"""
warning("groovy_binary")
all_deps = deps + ["//external:groovy"]
if srcs:
groovy_library(
Expand All @@ -190,6 +203,7 @@ def path_to_class(path):
fail("groovy_test sources must be under src/test/java or src/test/groovy")

def _groovy_test_impl(ctx):
warning("groovy_test")
# Collect jars from the Groovy sdk
groovy_sdk_jars = [file
for file in ctx.files._groovysdk
Expand Down Expand Up @@ -283,6 +297,7 @@ def groovy_junit_test(
jvm_flags=[],
size="small",
tags=[]):
warning("groovy_junit_test")
groovy_lib_deps = deps + ["//external:junit"]
test_deps = deps + ["//external:junit"]

Expand Down Expand Up @@ -330,6 +345,7 @@ def spock_test(
jvm_flags=[],
size="small",
tags=[]):
warning("spock_test")
groovy_lib_deps = deps + [
"//external:junit",
"//external:spock",
Expand Down Expand Up @@ -376,6 +392,7 @@ def spock_test(
)

def groovy_repositories():
warning("groovy_repositories")
native.new_http_archive(
name = "groovy_sdk_artifact",
url = "http://dl.bintray.com/groovy/maven/apache-groovy-binary-2.4.4.zip",
Expand Down
21 changes: 18 additions & 3 deletions tools/build_defs/sass/sass.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.

SASS_FILETYPES = FileType([".sass", ".scss"])
load("//tools/build_rules:deprecation.bzl", "deprecated")

def warning(rule):
print(deprecated(
"sass",
rule,
"@bazel_tools//tools/build_defs/sass:sass.bzl",
"@io_bazel_rules_sass//sass:sass.bzl"))

SASS_FILETYPES = FileType([
".sass",
".scss",
])

def collect_transitive_sources(ctx):
source_files = set(order="compile")
Expand All @@ -21,6 +33,7 @@ def collect_transitive_sources(ctx):
return source_files

def _sass_library_impl(ctx):
warning("sass_library")
transitive_sources = collect_transitive_sources(ctx)
transitive_sources += SASS_FILETYPES.filter(ctx.files.srcs)
return struct(
Expand All @@ -30,6 +43,7 @@ def _sass_library_impl(ctx):
def _sass_binary_impl(ctx):
# Reference the sass compiler and define the default options
# that sass_binary uses.
warning("sass_binary")
sassc = ctx.file._sassc
options = [
"--style={0}".format(ctx.attr.output_style),
Expand All @@ -55,7 +69,6 @@ sass_deps_attr = attr.label_list(
)

sass_library = rule(
implementation = _sass_library_impl,
attrs = {
"srcs": attr.label_list(
allow_files = SASS_FILETYPES,
Expand All @@ -64,10 +77,10 @@ sass_library = rule(
),
"deps": sass_deps_attr,
},
implementation = _sass_library_impl,
)

sass_binary = rule(
implementation = _sass_binary_impl,
attrs = {
"src": attr.label(
allow_files = SASS_FILETYPES,
Expand All @@ -86,6 +99,7 @@ sass_binary = rule(
"css_file": "%{name}.css",
"css_map_file": "%{name}.css.map",
},
implementation = _sass_binary_impl,
)

LIBSASS_BUILD_FILE = """
Expand Down Expand Up @@ -124,6 +138,7 @@ cc_binary(
"""

def sass_repositories():
warning("sass_repositories")
native.new_http_archive(
name = "libsass",
url = "https://github.com/sass/libsass/archive/3.3.0-beta1.tar.gz",
Expand Down
12 changes: 12 additions & 0 deletions tools/build_rules/appengine/appengine.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ APP_ID. If not specified, it uses the default APP_ID provided in the application
web.xml.
"""

load("//tools/build_rules:deprecation.bzl", "deprecated")

def warning(rule):
print(deprecated(
"appengine",
rule,
"@bazel_tools//tools/build_rules/appengine:appengine.bzl",
"@io_bazel_rules_appengine//appengine:appengine.bzl"))

jar_filetype = FileType([".jar"])

def _add_file(in_file, output, path = None):
Expand Down Expand Up @@ -99,6 +108,7 @@ def _short_path_dirname(path):
return sp[0:len(sp)-len(path.basename)-1]

def _war_impl(ctxt):
warning("appengine_war")
zipper = ctxt.file._zipper

data_path = ctxt.attr.data_path
Expand Down Expand Up @@ -231,6 +241,7 @@ appengine_war = rule(
)

def java_war(name, data=[], data_path=None, **kwargs):
warning("java_war")
native.java_library(name = "lib%s" % name, **kwargs)
appengine_war(name = name,
jars = ["lib%s" % name],
Expand Down Expand Up @@ -261,6 +272,7 @@ filegroup(
"""

def appengine_repositories():
warning("appengine_repositories")
native.new_http_archive(
name = "com_google_appengine_java",
url = "http://central.maven.org/maven2/com/google/appengine/appengine-java-sdk/1.9.23/appengine-java-sdk-1.9.23.zip",
Expand Down
Loading

0 comments on commit 19b5675

Please sign in to comment.