Skip to content

Commit be4e69e

Browse files
authored
Merge pull request #181 from mering/fix-new-bazel
Fix rules_cc and rules_shell usage
2 parents 3678302 + 7ea4919 commit be4e69e

8 files changed

Lines changed: 13 additions & 9 deletions

File tree

MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ bazel_dep(name = "rules_cc", version = "0.2.2", dev_dependency = True)
1717
bazel_dep(name = "rules_java", version = "8.16.1", dev_dependency = True)
1818
bazel_dep(name = "rules_pkg", version = "1.0.1", dev_dependency = True)
1919
bazel_dep(name = "rules_python", version = "0.35.0", dev_dependency = True)
20+
bazel_dep(name = "rules_shell", version = "0.6.1", dev_dependency = True)
2021
bazel_dep(name = "rules_testing", version = "0.6.0", dev_dependency = True)
2122
bazel_dep(name = "stardoc", version = "0.6.2", dev_dependency = True)

examples/manifest/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ android_binary(
3030
data = [
3131
":licenses",
3232
],
33+
use_bash_launcher = True,
3334
)
3435

3536
golden_cmd_test(

examples/manifest/android_mock.bzl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
2+
load("@rules_shell//shell:sh_library.bzl", "sh_library")
13
load("manifest.bzl", "manifest")
24

35
"""This is a proof of concept to show how to modify a macro definition to
@@ -15,7 +17,7 @@ def android_library(name, **kwargs):
1517
)
1618

1719
# Inject the data dependency into the library, preserving any other data it has.
18-
native.sh_library(
20+
sh_library(
1921
name = name + "_w_licenses",
2022
data = data + [name + "_manifest.txt"],
2123
**kwargs
@@ -55,7 +57,7 @@ def android_binary(name, **kwargs):
5557
kwargs["data"] = newdeps
5658

5759
# Compile the executable with the user's originally supplied name, but with the new content.
58-
native.sh_binary(
60+
sh_binary(
5961
name = name,
6062
**kwargs
6163
)

examples/manifest/license_display.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
function display_licenses {
44
echo -n "Licenses: "
5-
cat "$0.runfiles/rules_license/examples/manifest/licenses_manifest.txt"
5+
cat "$(rlocation "rules_license/examples/manifest/licenses_manifest.txt")"
66
echo
77
}

examples/manifest/main.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
#!/bin/bash
22

3-
#source gbash.sh || exit
4-
5-
#source "$RUNFILES/google3/tools/build_defs/license/examples/manifest/license_display.sh"
6-
source "$0.runfiles/rules_license/examples/manifest/license_display.sh"
7-
#source module google3/tools/build_defs/license/examples/manifest/license_display.sh
3+
source "$(rlocation "rules_license/examples/manifest/license_display.sh")"
84

95
echo "I am a program that uses open source code."
106
display_licenses

examples/vndor/acme/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414
# A package with a commercial license.
1515

16+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
1617
load("@rules_license//rules:license.bzl", "license")
1718

1819
package(

examples/vndor/libhhgttg/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# A package with all code under a single license. This is the most common case
1515
# we expect to see.
1616

17+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
1718
load("@rules_license//rules:license.bzl", "license")
1819

1920
# Using a package wide default ensure that all targets are associated with the

tools/test_helpers.bzl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
load("@rules_shell//shell:sh_test.bzl", "sh_test")
16+
1517
"""Compare rule output to a golden version."""
1618

1719
def golden_test(
@@ -25,7 +27,7 @@ def golden_test(
2527
golden: expected content of subect
2628
subject: build target
2729
"""
28-
native.sh_test(
30+
sh_test(
2931
name = name,
3032
size = "medium",
3133
srcs = ["@rules_license//tools:diff_test.sh"],

0 commit comments

Comments
 (0)