Skip to content

Commit

Permalink
Add forwarding references for js, jvm, ktlint.
Browse files Browse the repository at this point in the history
Revert loading android rules until they can be loaded via sub repo
Issue: #556

Signed-off-by: restingbull@cabaretmechanique.com <restingbull@cabaretmechanique.com>
  • Loading branch information
restingbull committed Jul 19, 2021
1 parent 6423eb3 commit 74cb1f9
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 22 deletions.
10 changes: 10 additions & 0 deletions kotlin/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ bzl_library(
],
)

bzl_library(
name = "android",
srcs = ["android.bzl"],
visibility = ["//kotlin:__subpackages__"],
deps = [
"//kotlin/internal",
],
)

stardoc(
name = "stardoc",
out = "kotlin.md",
Expand All @@ -59,6 +68,7 @@ stardoc(
"kt_javac_options",
],
deps = [
"android",
"kotlin",
],
)
8 changes: 8 additions & 0 deletions kotlin/android.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
load(
"//kotlin/internal/jvm:android.bzl",
_kt_android_library = "kt_android_library",
_kt_android_local_test = "kt_android_local_test",
)

kt_android_library = _kt_android_library
kt_android_local_test = _kt_android_local_test
8 changes: 3 additions & 5 deletions kotlin/internal/jvm/android.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
load("@rules_android//android:rules.bzl", "android_library", "android_local_test")

# Copyright 2018 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -40,7 +38,7 @@ def _kt_android_artifact(

# TODO(bazelbuild/rules_kotlin/issues/273): This should be retrieved from a provider.
base_deps = deps + [_ANDROID_SDK_JAR]
android_library(
native.android_library(
name = base_name,
visibility = ["//visibility:private"],
exports = base_deps,
Expand Down Expand Up @@ -70,7 +68,7 @@ def kt_android_library(name, exports = [], visibility = None, **kwargs):
`srcs`, `deps`, `plugins` are routed to `kt_jvm_library` the other android
related attributes are handled by the native `android_library` rule.
"""
android_library(
native.android_library(
name = name,
exports = exports + _kt_android_artifact(name, **kwargs),
visibility = visibility,
Expand All @@ -96,7 +94,7 @@ def kt_android_local_test(
related attributes are handled by the native `android_library` rule while the test attributes
are picked out and handled by the `android_local_test` rule.
"""
android_local_test(
native.android_local_test(
name = name,
deps = kwargs.get("deps", []) + _kt_android_artifact(name = name, testonly = True, **kwargs),
jvm_flags = jvm_flags,
Expand Down
8 changes: 8 additions & 0 deletions kotlin/js.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
load(
"//kotlin/internal/js:js.bzl",
_kt_js_import = "kt_js_import_macro",
_kt_js_library = "kt_js_library_macro",
)

kt_js_import = _kt_js_import
kt_js_library = _kt_js_library
14 changes: 14 additions & 0 deletions kotlin/jvm.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
load(
"//kotlin/internal/jvm:jvm.bzl",
_kt_compiler_plugin = "kt_compiler_plugin",
_kt_jvm_binary = "kt_jvm_binary",
_kt_jvm_import = "kt_jvm_import",
_kt_jvm_library = "kt_jvm_library",
_kt_jvm_test = "kt_jvm_test",
)

kt_compiler_plugin = _kt_compiler_plugin
kt_jvm_binary = _kt_jvm_binary
kt_jvm_import = _kt_jvm_import
kt_jvm_library = _kt_jvm_library
kt_jvm_test = _kt_jvm_test
7 changes: 7 additions & 0 deletions kotlin/lint.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
load("//kotlin/internal/lint:ktlint_config.bzl", _ktlint_config = "ktlint_config")
load("//kotlin/internal/lint:ktlint_fix.bzl", _ktlint_fix = "ktlint_fix")
load("//kotlin/internal/lint:ktlint_test.bzl", _ktlint_test = "ktlint_test")

ktlint_fix = _ktlint_fix
ktlint_test = _ktlint_test
ktlint_config = _ktlint_config
129 changes: 112 additions & 17 deletions kotlin/rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -25,40 +25,135 @@ load(
_kt_kotlinc_options = "kt_kotlinc_options",
)
load(
"//kotlin/internal/jvm:jvm.bzl",
":jvm.bzl",
_kt_compiler_plugin = "kt_compiler_plugin",
_kt_jvm_binary = "kt_jvm_binary",
_kt_jvm_import = "kt_jvm_import",
_kt_jvm_library = "kt_jvm_library",
_kt_jvm_test = "kt_jvm_test",
)
load(
"//kotlin/internal/jvm:android.bzl",
":android.bzl",
_kt_android_library = "kt_android_library",
_kt_android_local_test = "kt_android_local_test",
)
load(
"//kotlin/internal/js:js.bzl",
":js.bzl",
_kt_js_import = "kt_js_import_macro",
_kt_js_library = "kt_js_library_macro",
)
load("//kotlin/internal/lint:ktlint_config.bzl", _ktlint_config = "ktlint_config")
load("//kotlin/internal/lint:ktlint_fix.bzl", _ktlint_fix = "ktlint_fix")
load("//kotlin/internal/lint:ktlint_test.bzl", _ktlint_test = "ktlint_test")
load(
":lint.bzl",
_ktlint_config = "ktlint_config",
_ktlint_fix = "ktlint_fix",
_ktlint_test = "ktlint_test",
)

define_kt_toolchain = _define_kt_toolchain

kt_kotlinc_options = _kt_kotlinc_options

kt_javac_options = _kt_javac_options
kt_js_library = _kt_js_library
kt_js_import = _kt_js_import

def kt_js_library(**kwargs):
"""
Forwarding macro for kt_js_library
Deprecated:
kt_js_library should be loaded from //kotlin:js.bzl
"""
_kt_js_library(**kwargs)

def kt_js_import(**kwargs):
"""
Forwarding macro for kt_js_import
Deprecated:
kt_js_import should be loaded from //kotlin:js.bzl
"""
_kt_js_import(**kwargs)

kt_register_toolchains = _kt_register_toolchains
kt_jvm_binary = _kt_jvm_binary
kt_jvm_import = _kt_jvm_import
kt_jvm_library = _kt_jvm_library
kt_jvm_test = _kt_jvm_test
kt_android_library = _kt_android_library
kt_android_local_test = _kt_android_local_test

def kt_jvm_binary(**kwargs):
"""
Forwarding macro for kt_jvm_binary
Deprecated:
kt_jvm_binary should be loaded from //kotlin:jvm.bzl
"""
_kt_jvm_binary(**kwargs)

def kt_jvm_import(**kwargs):
"""
Forwarding macro for kt_jvm_import
Deprecated:
kt_jvm_import should be loaded from //kotlin:jvm.bzl
"""
_kt_jvm_import(**kwargs)

def kt_jvm_library(**kwargs):
"""
Forwarding macro for kt_jvm_library
Deprecated:
kt_jvm_library should be loaded from //kotlin:jvm.bzl
"""
_kt_jvm_library(**kwargs)

def kt_jvm_test(**kwargs):
"""
Forwarding macro for kt_jvm_test
Deprecated:
kt_jvm_test should be loaded from //kotlin:jvm.bzl
"""
_kt_jvm_test(**kwargs)

def kt_android_library(**kwargs):
"""
Forwarding macro for kt_android_local_test
Deprecated:
kt_android_library should be loaded from //kotlin:android.bzl
"""
_kt_android_library(**kwargs)

def kt_android_local_test(**kwargs):
"""
Forwarding macro for kt_android_local_test
Deprecated:
kt_android_local_test should be loaded from //kotlin:android.bzl
"""
_kt_android_local_test(**kwargs)

kt_compiler_plugin = _kt_compiler_plugin
ktlint_config = _ktlint_config
ktlint_fix = _ktlint_fix
ktlint_test = _ktlint_test

def ktlint_config(**kwargs):
"""
Forwarding macro for ktlint_config
Deprecated:
ktlint_config should be loaded from //kotlin:lint.bzl
"""
_ktlint_config(**kwargs)

def ktlint_fix(**kwargs):
"""
Forwarding macro for ktlint_fix
Deprecated:
ktlint_fix should be loaded from //kotlin:lint.bzl
"""
_ktlint_fix(**kwargs)

def ktlint_test(**kwargs):
"""
Forwarding macro for ktlint_test
Deprecated:
ktlint_test should be loaded from //kotlin:lint.bzl
"""
_ktlint_test(**kwargs)

0 comments on commit 74cb1f9

Please sign in to comment.