forked from protocolbuffers/protobuf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBUILD.bazel
139 lines (125 loc) · 3.91 KB
/
BUILD.bazel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# Protobuf PHP runtime
#
# See also code generation logic under /src/google/protobuf/compiler/php.
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
load("@upb//cmake:build_defs.bzl", "staleness_test")
load("//build_defs:internal_shell.bzl", "inline_sh_binary")
load("//conformance:defs.bzl", "conformance_test")
filegroup(
name = "source_files",
visibility = [
"//conformance:__pkg__",
"//php:__pkg__",
],
srcs = glob([
"ext/google/protobuf/*.h",
"ext/google/protobuf/*.c",
"src/GPBMetadata/Google/Protobuf/**/*.php",
"src/Google/Protobuf/**/*.php",
]) + [
"composer.json",
"ext/google/protobuf/wkt.inc",
"ext/google/protobuf/config.m4",
"ext/google/protobuf/package.xml",
],
)
################################################################################
# PHP Extension
################################################################################
inline_sh_binary(
name = "build_extension",
cmd = """
mkdir -p php/ext/google/protobuf/third_party/utf8_range
cp external/utf8_range/* php/ext/google/protobuf/third_party/utf8_range
pushd php/ext/google/protobuf
phpize
./configure --with-php-config=$$(which php-config)
make
popd
""",
)
genrule(
name = "extension",
srcs = [
":source_files",
"@utf8_range//:utf8_range_srcs",
],
tools = [":build_extension"],
outs = ["protobuf.so"],
cmd = """
./$(execpath :build_extension) $@
cp php/ext/google/protobuf/modules/protobuf.so $(OUTS)
""",
visibility = ["//visibility:public"],
)
################################################################################
# Tests
################################################################################
conformance_test(
name = "conformance_test",
failure_list = "//conformance:failure_list_php.txt",
testee = "//conformance:conformance_php",
text_format_failure_list = "//conformance:text_format_failure_list_php.txt",
target_compatible_with = select({
"@platforms//os:osx": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
)
conformance_test(
name = "conformance_test_c",
failure_list = "//conformance:failure_list_php_c.txt",
testee = "//conformance:conformance_php_c",
text_format_failure_list = "//conformance:text_format_failure_list_php.txt",
target_compatible_with = select({
"@platforms//os:osx": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
)
genrule(
name = "copy_php_amalgamation_h",
srcs = ["@upb//:php-upb.h"],
outs = ["generated-in/ext/google/protobuf/php-upb.h"],
cmd = "cp $< $@",
)
genrule(
name = "copy_php_amalgamation_c",
srcs = ["@upb//:php-upb.c"],
outs = ["generated-in/ext/google/protobuf/php-upb.c"],
cmd = "cp $< $@",
)
staleness_test(
name = "test_amalgamation_staleness",
outs = [
"ext/google/protobuf/php-upb.h",
"ext/google/protobuf/php-upb.c",
],
generated_pattern = "generated-in/%s",
)
################################################################################
# Distribution files
################################################################################
pkg_files(
name = "dist_files",
srcs = glob([
"ext/google/protobuf/**/*",
"tests/*.php",
"tests/*.sh",
"tests/generated_previous/**/*.php",
"tests/proto/**/*.proto",
"tests/proto_previous/*.proto",
]) + [
":source_files",
"BUILD.bazel",
"README.md",
"REFCOUNTING.md",
"composer.json",
"generate_descriptor_protos.sh",
"generate_test_protos.sh",
"release.sh",
"src/phpdoc.dist.xml",
"tests/valgrind.supp",
],
prefix = "php",
strip_prefix = strip_prefix.from_pkg(""),
visibility = ["//pkg:__pkg__"],
)