1- load (
2- "@gz//bazel/skylark:build_defs.bzl" ,
3- "GZ_FEATURES" ,
4- "GZ_ROOT" ,
5- "GZ_VISIBILITY" ,
6- "gz_configure_header" ,
7- "gz_export_header" ,
8- "gz_include_header" ,
9- )
10- load (
11- "@gz//bazel/lint:lint.bzl" ,
12- "add_lint_tests" ,
13- )
14- load (
15- "@rules_license//rules:license.bzl" ,
16- "license" ,
17- )
1+ load ("@pybind11_bazel//:build_defs.bzl" , "pybind_extension" )
2+ load ("@rules_gazebo//gazebo:headers.bzl" , "gz_configure_header" , "gz_export_header" , "gz_include_header" )
3+ load ("@rules_license//rules:license.bzl" , "license" )
4+ load ("@rules_python//python:py_library.bzl" , "py_library" )
5+ load ("@rules_python//python:py_test.bzl" , "py_test" )
186
197package (
20- default_applicable_licenses = [GZ_ROOT + "math:license" ],
21- default_visibility = GZ_VISIBILITY ,
22- features = GZ_FEATURES ,
8+ default_applicable_licenses = [":license" ],
9+ default_visibility = ["__subpackages__" ],
10+ features = [
11+ "layering_check" ,
12+ "parse_headers" ,
13+ ],
2314)
2415
2516license (
@@ -29,75 +20,129 @@ license(
2920
3021licenses (["notice" ])
3122
32- exports_files (["LICENSE" ])
33-
34- gz_configure_header (
35- name = "config" ,
36- src = "include/gz/math/config.hh.in" ,
37- cmakelists = ["CMakeLists.txt" ],
38- package = "math" ,
39- )
23+ exports_files ([
24+ "LICENSE" ,
25+ "MODULE.bazel" ,
26+ ])
4027
4128gz_export_header (
42- name = "include/gz/math/Export.hh" ,
29+ name = "Export" ,
30+ out = "include/gz/math/Export.hh" ,
4331 export_base = "GZ_MATH" ,
4432 lib_name = "gz-math" ,
45- visibility = ["//visibility:private" ],
4633)
4734
48- public_headers_no_gen = glob ([
49- "include/gz/math/*.hh" ,
50- "include/gz/math/detail/*.hh" ,
51- "include/gz/math/graph/*.hh" ,
52- ])
53-
54- private_headers = glob (["src/*.hh" ])
35+ gz_configure_header (
36+ name = "Config" ,
37+ src = "include/gz/math/config.hh.in" ,
38+ package_xml = "package.xml" ,
39+ )
5540
56- sources = glob (
57- ["src/*.cc" ],
58- exclude = ["src/*_TEST.cc" ],
41+ public_headers_no_gen = glob (
42+ include = [
43+ "include/gz/math/*.hh" ,
44+ "include/gz/math/detail/*.hh" ,
45+ "include/gz/math/graph/*.hh" ,
46+ ],
5947)
6048
6149gz_include_header (
62- name = "mathhh_genrule " ,
50+ name = "Include " ,
6351 out = "include/gz/math.hh" ,
64- hdrs = public_headers_no_gen + [
65- "include/gz/math/config.hh" ,
66- "include/gz/math/Export.hh" ,
67- ],
52+ hdrs = public_headers_no_gen + ["include/gz/math/config.hh" ],
6853)
6954
7055public_headers = public_headers_no_gen + [
71- "include/gz/math/config.hh" ,
72- "include/gz/math/Export.hh" ,
7356 "include/gz/math.hh" ,
57+ "include/gz/math/Export.hh" ,
58+ "include/gz/math/config.hh" ,
7459]
7560
61+ private_headers = glob (
62+ include = [
63+ "src/*.hh" ,
64+ ],
65+ )
66+
67+ sources = glob (
68+ include = [
69+ "src/*.cc" ,
70+ ],
71+ exclude = [
72+ "src/*_TEST.cc" ,
73+ ],
74+ )
75+
7676cc_library (
77- name = "math" ,
77+ name = "gz- math" ,
7878 srcs = sources + private_headers ,
7979 hdrs = public_headers ,
80- includes = ["include" ],
80+ includes = [
81+ "include" ,
82+ ],
83+ visibility = ["//visibility:public" ],
8184 deps = [
82- GZ_ROOT + "utils" ,
85+ "@gz-utils//:ImplPtr" ,
86+ "@gz-utils//:NeverDestroyed" ,
87+ "@gz-utils//:SuppressWarning" ,
8388 ],
8489)
8590
91+ pybind_extension (
92+ name = "gz/math8" ,
93+ srcs = glob (
94+ include = [
95+ "src/python_pybind11/src/*.cc" ,
96+ "src/python_pybind11/src/*.hh" ,
97+ ],
98+ ),
99+ defines = [
100+ "BINDINGS_MODULE_NAME=math8" ,
101+ ],
102+ linkstatic = True ,
103+ visibility = ["//visibility:private" ],
104+ deps = [":gz-math" ],
105+ )
106+
107+ py_library (
108+ name = "python" ,
109+ data = [":gz/math8" ],
110+ visibility = ["//visibility:public" ],
111+ )
112+
86113test_sources = glob (
87- [
114+ include = [
88115 "src/*_TEST.cc" ,
89116 "src/graph/*_TEST.cc" ,
90117 ],
91118)
92119
93- [cc_test (
94- name = src .replace ("/" , "_" ).replace (".cc" , "" ).replace ("src_" , "" ),
95- srcs = [src ],
96- deps = [
97- ":math" ,
98- "@gtest" ,
99- "@gtest//:gtest_main" ,
120+ [
121+ cc_test (
122+ name = src .replace ("/" , "_" ).replace (".cc" , "" ).replace ("src_" , "" ),
123+ srcs = [src ],
124+ deps = [
125+ ":gz-math" ,
126+ "@googletest//:gtest" ,
127+ "@googletest//:gtest_main" ,
128+ "@gz-utils//:SuppressWarning" ,
129+ ],
130+ )
131+ for src in test_sources
132+ ]
133+
134+ py_test_sources = glob (
135+ include = [
136+ "src/python_pybind11/test/*_TEST.py" ,
100137 ],
101- ) for src in test_sources ]
138+ )
102139
103- add_lint_tests ()
140+ [
141+ py_test (
142+ name = src .replace ("/" , "_" ).replace (".py" , "_py" ).replace ("src_python_pybind11_test_" , "" ),
143+ srcs = [src ],
144+ main = src ,
145+ deps = [":python" ],
146+ )
147+ for src in py_test_sources
148+ ]
0 commit comments