xref: /aosp_15_r20/external/bazelbuild-rules_python/tests/whl_filegroup/BUILD.bazel (revision 60517a1edbc8ecf509223e9af94a7adec7d736b8)
1*60517a1eSAndroid Build Coastguard Workerload("@bazel_skylib//rules:write_file.bzl", "write_file")
2*60517a1eSAndroid Build Coastguard Workerload("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
3*60517a1eSAndroid Build Coastguard Workerload("//python:defs.bzl", "py_library", "py_test")
4*60517a1eSAndroid Build Coastguard Workerload("//python:packaging.bzl", "py_package", "py_wheel")
5*60517a1eSAndroid Build Coastguard Workerload("//python:pip.bzl", "whl_filegroup")
6*60517a1eSAndroid Build Coastguard Workerload(":whl_filegroup_tests.bzl", "whl_filegroup_test_suite")
7*60517a1eSAndroid Build Coastguard Worker
8*60517a1eSAndroid Build Coastguard Workerwhl_filegroup_test_suite(name = "whl_filegroup_tests")
9*60517a1eSAndroid Build Coastguard Worker
10*60517a1eSAndroid Build Coastguard Workerpy_test(
11*60517a1eSAndroid Build Coastguard Worker    name = "extract_wheel_files_test",
12*60517a1eSAndroid Build Coastguard Worker    size = "small",
13*60517a1eSAndroid Build Coastguard Worker    srcs = ["extract_wheel_files_test.py"],
14*60517a1eSAndroid Build Coastguard Worker    data = ["//examples/wheel:minimal_with_py_package"],
15*60517a1eSAndroid Build Coastguard Worker    deps = ["//python/private/whl_filegroup:extract_wheel_files"],
16*60517a1eSAndroid Build Coastguard Worker)
17*60517a1eSAndroid Build Coastguard Worker
18*60517a1eSAndroid Build Coastguard Workerwrite_file(
19*60517a1eSAndroid Build Coastguard Worker    name = "header",
20*60517a1eSAndroid Build Coastguard Worker    out = "include/whl_headers/header.h",
21*60517a1eSAndroid Build Coastguard Worker    content = [
22*60517a1eSAndroid Build Coastguard Worker        "#pragma once",
23*60517a1eSAndroid Build Coastguard Worker        "#include <Python.h>",
24*60517a1eSAndroid Build Coastguard Worker        "#define CUSTOM_ZERO ((Py_ssize_t) 0)",
25*60517a1eSAndroid Build Coastguard Worker    ],
26*60517a1eSAndroid Build Coastguard Worker)
27*60517a1eSAndroid Build Coastguard Worker
28*60517a1eSAndroid Build Coastguard Workerwrite_file(
29*60517a1eSAndroid Build Coastguard Worker    name = "lib_py",
30*60517a1eSAndroid Build Coastguard Worker    out = "lib.py",
31*60517a1eSAndroid Build Coastguard Worker)
32*60517a1eSAndroid Build Coastguard Worker
33*60517a1eSAndroid Build Coastguard Workerpy_library(
34*60517a1eSAndroid Build Coastguard Worker    name = "lib",
35*60517a1eSAndroid Build Coastguard Worker    srcs = ["lib.py"],
36*60517a1eSAndroid Build Coastguard Worker    data = [":header"],
37*60517a1eSAndroid Build Coastguard Worker)
38*60517a1eSAndroid Build Coastguard Worker
39*60517a1eSAndroid Build Coastguard Workerpy_package(
40*60517a1eSAndroid Build Coastguard Worker    name = "pkg",
41*60517a1eSAndroid Build Coastguard Worker    deps = [":lib"],
42*60517a1eSAndroid Build Coastguard Worker)
43*60517a1eSAndroid Build Coastguard Worker
44*60517a1eSAndroid Build Coastguard Workerpy_wheel(
45*60517a1eSAndroid Build Coastguard Worker    name = "wheel",
46*60517a1eSAndroid Build Coastguard Worker    distribution = "wheel",
47*60517a1eSAndroid Build Coastguard Worker    python_tag = "py3",
48*60517a1eSAndroid Build Coastguard Worker    version = "0.0.1",
49*60517a1eSAndroid Build Coastguard Worker    deps = [":pkg"],
50*60517a1eSAndroid Build Coastguard Worker)
51*60517a1eSAndroid Build Coastguard Worker
52*60517a1eSAndroid Build Coastguard Workerwhl_filegroup(
53*60517a1eSAndroid Build Coastguard Worker    name = "filegroup",
54*60517a1eSAndroid Build Coastguard Worker    pattern = "tests/whl_filegroup/include/.*\\.h",
55*60517a1eSAndroid Build Coastguard Worker    whl = ":wheel",
56*60517a1eSAndroid Build Coastguard Worker)
57*60517a1eSAndroid Build Coastguard Worker
58*60517a1eSAndroid Build Coastguard Workercc_library(
59*60517a1eSAndroid Build Coastguard Worker    name = "whl_headers",
60*60517a1eSAndroid Build Coastguard Worker    hdrs = [":filegroup"],
61*60517a1eSAndroid Build Coastguard Worker    includes = ["filegroup/tests/whl_filegroup/include"],
62*60517a1eSAndroid Build Coastguard Worker    deps = ["@rules_python//python/cc:current_py_cc_headers"],
63*60517a1eSAndroid Build Coastguard Worker)
64*60517a1eSAndroid Build Coastguard Worker
65*60517a1eSAndroid Build Coastguard Workercc_test(
66*60517a1eSAndroid Build Coastguard Worker    name = "whl_headers_test",
67*60517a1eSAndroid Build Coastguard Worker    srcs = ["whl_headers_test.c"],
68*60517a1eSAndroid Build Coastguard Worker    deps = [":whl_headers"],
69*60517a1eSAndroid Build Coastguard Worker)
70