-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy path0001-Remove-hardcoded-paths-from-rules_ros-config-impleme.patch
19159 lines (19145 loc) · 751 KB
/
0001-Remove-hardcoded-paths-from-rules_ros-config-impleme.patch
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
From 06d50e698117a1d22f537a342f50eb3f208968af Mon Sep 17 00:00:00 2001
From: Revati Naik <[email protected]>
Date: Tue, 11 Feb 2025 11:27:10 -0800
Subject: [PATCH] Remove hardcoded paths from rules_ros config implementation
Fix the generation of repos lock file
Avoid creating .bzl files in config workspace
Update actual lock target
Remove duplicate py_binary target
---
0001-Add-apex_http_archive.patch | 86 +
...reate-a-MACRO-for-the-py_binary-rule.patch | 100 +
...ix-the-generation-fo-repos-lock-file.patch | 70 +
repos/config/BUILD.bazel | 2 +-
repos/config/defs.bzl | 3 +-
repos/config/detail/BUILD.bazel | 18 +-
repos/config/detail/generate_repos_lock.bzl | 18 +
repos/config/detail/ros2_config.bzl | 28 +-
.../detail/test/test_repos_index_sha256.sh | 23 +
rules_ros.patch | 18692 ++++++++++++++++
10 files changed, 19017 insertions(+), 23 deletions(-)
create mode 100644 0001-Add-apex_http_archive.patch
create mode 100644 0001-Create-a-MACRO-for-the-py_binary-rule.patch
create mode 100644 0002-Fix-the-generation-fo-repos-lock-file.patch
create mode 100644 repos/config/detail/generate_repos_lock.bzl
create mode 100755 repos/config/detail/test/test_repos_index_sha256.sh
create mode 100644 rules_ros.patch
diff --git a/0001-Add-apex_http_archive.patch b/0001-Add-apex_http_archive.patch
new file mode 100644
index 0000000..eaa4a83
--- /dev/null
+++ b/0001-Add-apex_http_archive.patch
@@ -0,0 +1,86 @@
+From e859c13e36e0f15167b5fbcc4970768c4d973d3d Mon Sep 17 00:00:00 2001
+From: "kilian.funk" <[email protected]>
+Date: Thu, 19 Sep 2024 17:35:38 -0700
+Subject: [PATCH] Add apex_http_archive
+
+---
+ repos/config/detail/generate_ros2_config.py | 17 +++++++++++++++++
+ repos/config/detail/lock_repos.py | 6 +++---
+ 2 files changed, 20 insertions(+), 3 deletions(-)
+
+diff --git a/repos/config/detail/generate_ros2_config.py b/repos/config/detail/generate_ros2_config.py
+index 184315b..428e7e0 100755
+--- a/repos/config/detail/generate_ros2_config.py
++++ b/repos/config/detail/generate_ros2_config.py
+@@ -21,6 +21,7 @@ HEADER = """#
+ # To update, call `bazel run @rules_ros//repos/config:repos_lock.update` with the right distro set in the WORKSPACE
+ #
+
++load("@apex//tools/bazel/rules_repo:defs.bzl", "apex_http_archive")
+ load("@bazel_tools//tools/build_defs/repo:utils.bzl", _maybe = "maybe")
+ load("@rules_ros//repos/config/detail:git_repository.bzl", "git_repository")
+ load("@rules_ros//repos/config/detail:http_archive.bzl", "http_archive")
+@@ -43,6 +44,7 @@ def build_load_command(repo, spec):
+ "git": build_git_load_command,
+ "http_archive": build_http_archive_load_command,
+ "local": build_local_load_command,
++ "apex_http_archive": build_apex_http_archive_load_command
+ }
+ if spec.get('type') not in builder.keys():
+ return f"""
+@@ -60,6 +62,21 @@ def build_build_files_attr(build_files):
+ }},"""
+
+
++def build_apex_http_archive_load_command(repo, spec):
++ spec_string = "\n ".join(
++ f'{k} = "{v}",'
++ for k,v in spec.items()
++ if k not in ["type", "bazel"]
++ )
++ return f"""\
++ _maybe(
++ name = "{repo.replace('/','.')}",
++ {spec_string}
++ repo_rule = apex_http_archive,
++ )
++"""
++
++
+ def build_http_archive_load_command(repo, spec):
+ return f"""\
+ _maybe(
+diff --git a/repos/config/detail/lock_repos.py b/repos/config/detail/lock_repos.py
+index 08eebc4..40a458d 100755
+--- a/repos/config/detail/lock_repos.py
++++ b/repos/config/detail/lock_repos.py
+@@ -23,7 +23,7 @@ import hashlib
+ from pathlib import Path
+ from generate_ros2_config import print_setup_file
+
+-REPO_TYPES = ["git", "tar"]
++REPO_TYPES = ["git", "tar", "apex_http_archive"]
+
+ def main():
+ parser = argparse.ArgumentParser(description='Generate a Bazel setup file containing repo '
+@@ -55,7 +55,7 @@ def main():
+
+
+ def fetch_dependency_details(*, use_tar, type, **kwargs):
+- if type == "tar" or use_tar:
++ if type in ["tar", "apex_http_archive"] or use_tar:
+ return fetch_http_details(type = type, **kwargs)
+ return fetch_git_details(type = type, **kwargs)
+
+@@ -64,7 +64,7 @@ def add_attributes(dictionary, additional_attributes):
+ dictionary[k] = v
+
+ def fetch_http_details(*, type, version = None, url = None, **kwargs):
+- forward_type = "http_archive"
++ forward_type = "apex_http_archive" if type == "apex_http_archive" else "http_archive"
+ if "sha256" in kwargs:
+ return { "type": forward_type}
+ with tempfile.TemporaryDirectory() as tempdir:
+--
+2.34.1
+
diff --git a/0001-Create-a-MACRO-for-the-py_binary-rule.patch b/0001-Create-a-MACRO-for-the-py_binary-rule.patch
new file mode 100644
index 0000000..9056096
--- /dev/null
+++ b/0001-Create-a-MACRO-for-the-py_binary-rule.patch
@@ -0,0 +1,100 @@
+From 62a75641a0909673f60870a07fb9abcb42338b74 Mon Sep 17 00:00:00 2001
+From: Revati Naik <[email protected]>
+Date: Tue, 11 Feb 2025 11:27:10 -0800
+Subject: [PATCH 1/2] Create a MACRO for the py_binary rule
+
+---
+ repos/config/defs.bzl | 3 ++-
+ repos/config/detail/generate_repos_lock.bzl | 24 +++++++++++++++++++++
+ repos/config/detail/ros2_config.bzl | 20 +++++++++++++++--
+ 3 files changed, 44 insertions(+), 3 deletions(-)
+ create mode 100644 repos/config/detail/generate_repos_lock.bzl
+
+diff --git a/repos/config/defs.bzl b/repos/config/defs.bzl
+index ed10d70..ef35ef9 100644
+--- a/repos/config/defs.bzl
++++ b/repos/config/defs.bzl
+@@ -46,11 +46,12 @@ def configure_ros2(*, name = "ros2_config", repos_index_overlays = [], distro):
+ fail("repos_index_overlays needs to be a list of *.repos files")
+ _configure_ros2(name = name, distro_src = distro_src, repos_index_overlays = repos_index_overlays)
+
+-def configure_repos(*, name = "ros2_config", repos_index, repos_index_overlays = [], setup_file):
++def configure_repos(*, name, repos_index, setup_file, repos_index_overlays = []):
+ """Configure ROS 2 repositories based on the custom *.repos file."""
+
+ if not type(repos_index_overlays) == type([]):
+ fail("repos_index_overlays needs to be a list of *.repos files")
++
+ ros2_config(
+ name = name,
+ repos_index = repos_index,
+diff --git a/repos/config/detail/generate_repos_lock.bzl b/repos/config/detail/generate_repos_lock.bzl
+new file mode 100644
+index 0000000..0d9bdf5
+--- /dev/null
++++ b/repos/config/detail/generate_repos_lock.bzl
+@@ -0,0 +1,24 @@
++load("@python_deps//:requirements.bzl", "requirement")
++load("@rules_python//python:defs.bzl", "py_binary")
++
++def generate_repos_lock(name, repos_file, setup_file, overlay_files):
++ """Macro to create a py_binary for generating repos_lock.update"""
++
++ py_binary(
++ name = name,
++ srcs = [
++ Label("generate_ros2_config.py"),
++ Label("lock_repos.py"),
++ ],
++ args = [
++ "$(execpath {})".format(repos_file),
++ "$(execpath {})".format(setup_file),
++ ] + ["$(execpath {})".format(f) for f in overlay_files],
++ data = [
++ repos_file,
++ setup_file,
++ ] + overlay_files,
++ main = Label("lock_repos.py"),
++ visibility = ["//visibility:public"],
++ deps = [requirement("pyyaml")],
++ )
+\ No newline at end of file
+diff --git a/repos/config/detail/ros2_config.bzl b/repos/config/detail/ros2_config.bzl
+index 0e9102c..7fa83e3 100644
+--- a/repos/config/detail/ros2_config.bzl
++++ b/repos/config/detail/ros2_config.bzl
+@@ -30,13 +30,29 @@ _archive_attrs = {
+ ),
+ }
+
++BUILD_FILE_CONTENT = """\
++load("@rules_ros//repos/config/detail:generate_repos_lock.bzl", "generate_repos_lock")
++
++generate_repos_lock(
++ name = "repos_lock.update",
++ repos_file = ":repos_index_file.repos", # Custom repos file
++ setup_file = ":repos_setup_file.bzl", # Custom setup file
++ overlay_files = [
++ ":repos_overlay_files.repos",
++ ],
++)
++
++exports_files(glob(["**/*"]))
++"""
++
++
+ def _ros2_config_impl(ctx):
+ ctx.file("repos_index_file.bzl", content = "REPOS_INDEX_FILE = '{}'".format(ctx.attr.repos_index))
+- ctx.file("repos_overlay_files.bzl", content = "REPOS_OVERLAY_FILES = {}".format(["{}".format(l) for l in ctx.attr.repos_index_overlays]))
++ ctx.file("repos_overlay_files.bzl", content = "REPOS_OVERLAY_FILES = {}".format(["{}".format(i) for i in ctx.attr.repos_index_overlays]))
+ ctx.file("repos_setup_file.bzl", content = "REPOS_SETUP_FILE = '{}'".format(ctx.attr.setup_file))
+ ctx.symlink(ctx.attr.setup_file, "setup.bzl")
+ ctx.file("WORKSPACE", content = "workspace(name = {})".format(ctx.name), executable = False)
+- ctx.file("BUILD.bazel", content = "exports_files(glob(['**/*']))", executable = False)
++ ctx.file("BUILD.bazel", content = BUILD_FILE_CONTENT, executable = False)
+
+ return update_attrs(ctx.attr, _archive_attrs.keys(), {})
+
+--
+2.34.1
+
diff --git a/0002-Fix-the-generation-fo-repos-lock-file.patch b/0002-Fix-the-generation-fo-repos-lock-file.patch
new file mode 100644
index 0000000..770e0d9
--- /dev/null
+++ b/0002-Fix-the-generation-fo-repos-lock-file.patch
@@ -0,0 +1,70 @@
+From 208e21581dc16a9fb20841d230a0c5577bb61e41 Mon Sep 17 00:00:00 2001
+From: Revati Naik <[email protected]>
+Date: Tue, 11 Feb 2025 13:46:31 -0800
+Subject: [PATCH 2/2] Fix the generation fo repos lock file
+
+---
+ repos/config/detail/generate_repos_lock.bzl | 23 +++++++++------------
+ repos/config/detail/ros2_config.bzl | 4 ++--
+ 2 files changed, 12 insertions(+), 15 deletions(-)
+
+diff --git a/repos/config/detail/generate_repos_lock.bzl b/repos/config/detail/generate_repos_lock.bzl
+index 0d9bdf5..f1d7d80 100644
+--- a/repos/config/detail/generate_repos_lock.bzl
++++ b/repos/config/detail/generate_repos_lock.bzl
+@@ -1,4 +1,7 @@
+ load("@python_deps//:requirements.bzl", "requirement")
++load("@ros2_config//:repos_index_file.bzl", "REPOS_INDEX_FILE")
++load("@ros2_config//:repos_overlay_files.bzl", "REPOS_OVERLAY_FILES")
++load("@ros2_config//:repos_setup_file.bzl", "REPOS_SETUP_FILE")
+ load("@rules_python//python:defs.bzl", "py_binary")
+
+ def generate_repos_lock(name, repos_file, setup_file, overlay_files):
+@@ -6,19 +9,13 @@ def generate_repos_lock(name, repos_file, setup_file, overlay_files):
+
+ py_binary(
+ name = name,
+- srcs = [
+- Label("generate_ros2_config.py"),
+- Label("lock_repos.py"),
+- ],
++ srcs = ["lock_repos.py", "generate_ros2_config.py"],
++ main = "lock_repos.py",
++ data = [REPOS_INDEX_FILE, REPOS_SETUP_FILE] + REPOS_OVERLAY_FILES,
+ args = [
+- "$(execpath {})".format(repos_file),
+- "$(execpath {})".format(setup_file),
+- ] + ["$(execpath {})".format(f) for f in overlay_files],
+- data = [
+- repos_file,
+- setup_file,
+- ] + overlay_files,
+- main = Label("lock_repos.py"),
+- visibility = ["//visibility:public"],
++ "$(execpath {})".format(REPOS_INDEX_FILE),
++ "$(execpath {})".format(REPOS_SETUP_FILE),
++ ] + ["$(execpath {})".format(f) for f in REPOS_OVERLAY_FILES],
+ deps = [requirement("pyyaml")],
++ visibility = ["//visibility:public"],
+ )
+\ No newline at end of file
+diff --git a/repos/config/detail/ros2_config.bzl b/repos/config/detail/ros2_config.bzl
+index 7fa83e3..f067301 100644
+--- a/repos/config/detail/ros2_config.bzl
++++ b/repos/config/detail/ros2_config.bzl
+@@ -35,10 +35,10 @@ load("@rules_ros//repos/config/detail:generate_repos_lock.bzl", "generate_repos_
+
+ generate_repos_lock(
+ name = "repos_lock.update",
+- repos_file = ":repos_index_file.repos", # Custom repos file
++ repos_file = ":repos_index_file.bzl", # Custom repos file
+ setup_file = ":repos_setup_file.bzl", # Custom setup file
+ overlay_files = [
+- ":repos_overlay_files.repos",
++ ":repos_overlay_files.bzl",
+ ],
+ )
+
+--
+2.34.1
+
diff --git a/repos/config/BUILD.bazel b/repos/config/BUILD.bazel
index c716378..98e6e39 100644
--- a/repos/config/BUILD.bazel
+++ b/repos/config/BUILD.bazel
@@ -16,5 +16,5 @@ exports_files(["bazel.repos"] + glob(["*.lock.bzl"]))
alias(
name = "repos_lock.update",
- actual = "//repos/config/detail:repos_lock.update",
+ actual = "@ros2_config//:repos_lock.update",
)
diff --git a/repos/config/defs.bzl b/repos/config/defs.bzl
index ed10d70..ef35ef9 100644
--- a/repos/config/defs.bzl
+++ b/repos/config/defs.bzl
@@ -46,11 +46,12 @@ def configure_ros2(*, name = "ros2_config", repos_index_overlays = [], distro):
fail("repos_index_overlays needs to be a list of *.repos files")
_configure_ros2(name = name, distro_src = distro_src, repos_index_overlays = repos_index_overlays)
-def configure_repos(*, name = "ros2_config", repos_index, repos_index_overlays = [], setup_file):
+def configure_repos(*, name, repos_index, setup_file, repos_index_overlays = []):
"""Configure ROS 2 repositories based on the custom *.repos file."""
if not type(repos_index_overlays) == type([]):
fail("repos_index_overlays needs to be a list of *.repos files")
+
ros2_config(
name = name,
repos_index = repos_index,
diff --git a/repos/config/detail/BUILD.bazel b/repos/config/detail/BUILD.bazel
index 498ad90..f9f633d 100644
--- a/repos/config/detail/BUILD.bazel
+++ b/repos/config/detail/BUILD.bazel
@@ -12,21 +12,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-load("@python_deps//:requirements.bzl", "requirement")
-load("@ros2_config//:repos_index_file.bzl", "REPOS_INDEX_FILE")
-load("@ros2_config//:repos_overlay_files.bzl", "REPOS_OVERLAY_FILES")
-load("@ros2_config//:repos_setup_file.bzl", "REPOS_SETUP_FILE")
-load("@rules_python//python:defs.bzl", "py_binary")
-py_binary(
- name = "repos_lock.update",
- srcs = ["lock_repos.py", "generate_ros2_config.py"],
- main = "lock_repos.py",
- data = [REPOS_INDEX_FILE, REPOS_SETUP_FILE] + REPOS_OVERLAY_FILES,
- args = [
- "$(execpath {})".format(REPOS_INDEX_FILE),
- "$(execpath {})".format(REPOS_SETUP_FILE),
- ] + ["$(execpath {})".format(f) for f in REPOS_OVERLAY_FILES],
- deps = [requirement("pyyaml")],
- visibility = ["//visibility:public"],
-)
+exports_files(["generate_ros2_config.py", "lock_repos.py"])
\ No newline at end of file
diff --git a/repos/config/detail/generate_repos_lock.bzl b/repos/config/detail/generate_repos_lock.bzl
new file mode 100644
index 0000000..859623b
--- /dev/null
+++ b/repos/config/detail/generate_repos_lock.bzl
@@ -0,0 +1,18 @@
+load("@python_deps//:requirements.bzl", "requirement")
+load("@rules_python//python:defs.bzl", "py_binary")
+
+def generate_repos_lock(*, name, repos_file, setup_file, overlay_files):
+ """Macro to create a py_binary for generating repos_lock.update"""
+
+ py_binary(
+ name = name,
+ srcs = [Label("lock_repos.py"), Label("generate_ros2_config.py")],
+ main = Label("lock_repos.py"),
+ data = [repos_file, setup_file] + overlay_files,
+ args = [
+ "$(execpath {})".format(repos_file),
+ "$(execpath {})".format(setup_file),
+ ] + ["$(execpath {})".format(f) for f in overlay_files],
+ deps = [requirement("pyyaml")],
+ visibility = ["//visibility:public"],
+ )
diff --git a/repos/config/detail/ros2_config.bzl b/repos/config/detail/ros2_config.bzl
index 0e9102c..f554e43 100644
--- a/repos/config/detail/ros2_config.bzl
+++ b/repos/config/detail/ros2_config.bzl
@@ -30,13 +30,33 @@ _archive_attrs = {
),
}
+BUILD_FILE_CONTENT = """\
+load("@rules_ros//repos/config/detail:generate_repos_lock.bzl", "generate_repos_lock")
+
+generate_repos_lock(
+ name = "repos_lock.update",
+ repos_file = "ros.repos", # Custom repos file
+ setup_file = "setup.bzl", # Custom setup file
+ overlay_files = [
+{overlays}
+ ],
+)
+
+exports_files(glob(["**/*"]))
+"""
+
def _ros2_config_impl(ctx):
- ctx.file("repos_index_file.bzl", content = "REPOS_INDEX_FILE = '{}'".format(ctx.attr.repos_index))
- ctx.file("repos_overlay_files.bzl", content = "REPOS_OVERLAY_FILES = {}".format(["{}".format(l) for l in ctx.attr.repos_index_overlays]))
- ctx.file("repos_setup_file.bzl", content = "REPOS_SETUP_FILE = '{}'".format(ctx.attr.setup_file))
+ ctx.symlink(ctx.attr.repos_index, "ros.repos")
ctx.symlink(ctx.attr.setup_file, "setup.bzl")
+ i = 0
+ overlay_files = []
+ for file in ctx.attr.repos_index_overlays:
+ filname = "overlay_{}.bzl".format(i)
+ ctx.symlink(file, filname)
+ i += 1
+ overlay_files.append(filname)
ctx.file("WORKSPACE", content = "workspace(name = {})".format(ctx.name), executable = False)
- ctx.file("BUILD.bazel", content = "exports_files(glob(['**/*']))", executable = False)
+ ctx.file("BUILD.bazel", content = BUILD_FILE_CONTENT.format(overlays="\n".join([' "{}",'.format(filename) for filename in overlay_files])), executable = False)
return update_attrs(ctx.attr, _archive_attrs.keys(), {})
diff --git a/repos/config/detail/test/test_repos_index_sha256.sh b/repos/config/detail/test/test_repos_index_sha256.sh
new file mode 100755
index 0000000..64e013e
--- /dev/null
+++ b/repos/config/detail/test/test_repos_index_sha256.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+REPOS_INDEX_FILE="$1"
+REPOS_SETUP_FILE="$2"
+
+REPOS_SETUP_FILE_SHA256=$(grep "SHA256" "${REPOS_SETUP_FILE}" | cut -f 5 -d ' ')
+
+if [[ -z "${REPOS_SETUP_FILE_SHA256}" ]]; then
+ echo "${REPOS_SETUP_FILE} DOES NOT HAVE A SHA256 COMMENT. TERMINATING"
+ exit -1
+elif [[ "${REPOS_SETUP_FILE_SHA256}" =~ ^[a-f0-9]{65}$ ]]; then
+ echo "${REPOS_SETUP_FILE} INVALID SHA256 COMMENT of ${REPOS_SETUP_FILE_SHA256}. TERMINATING"
+ exit -1
+fi
+
+REPOS_INDEX_FILE_SHA256=$(sha256sum "${REPOS_INDEX_FILE}" | cut -f 1 -d ' ')
+
+if [ "${REPOS_INDEX_FILE_SHA256}" != "${REPOS_SETUP_FILE_SHA256}" ]; then
+ echo "SHA256 MISMATCH. RUN 'bazel run @rules_ros//repos/config:repos_lock.update' THEN TRY AGAIN"
+ exit -1
+fi
+
+exit 0
\ No newline at end of file
diff --git a/rules_ros.patch b/rules_ros.patch
new file mode 100644
index 0000000..f1c0006
--- /dev/null
+++ b/rules_ros.patch
@@ -0,0 +1,18692 @@
+From 310c9680b58d24a3a5012d80c3e089776fbc94fa Mon Sep 17 00:00:00 2001
+From: "kilian.funk" <[email protected]>
+Date: Thu, 13 Oct 2022 14:11:58 +0200
+Subject: [PATCH 01/27] Initial bazel support
+
+---
+ .bazelrc | 12 ++
+ .bazelversion | 1 +
+ README.md | 139 +++++++++++++-----
+ WORKSPACE | 14 ++
+ examples/BUILD.bazel | 27 ++++
+ examples/bazel_simple_example/BUILD | 47 ++++++
+ examples/bazel_simple_example/publisher.cpp | 58 ++++++++
+ examples/bazel_simple_example/subscriber.cpp | 40 +++++
+ examples/hello_world/BUILD.bazel | 32 ++++
+ .../main.cpp | 0
+ examples/simple_pkg_example/BUILD.bazel | 17 ---
+ pkg/defs.bzl | 14 ++
+ pkg/detail/BUILD | 14 ++
+ pkg/detail/executable_wrapper_generator.py | 14 ++
+ pkg/detail/package_xml_generator.py | 14 ++
+ pkg/detail/ros_archive.bzl | 14 ++
+ pkg/detail/ros_pkg.bzl | 14 ++
+ pkg/detail/setup_bash_generator.py | 14 ++
+ pkg/detail/templates/install.template | 26 +++-
+ pkg/detail/utils.bzl | 14 ++
+ pkg/providers.bzl | 14 ++
+ .../ament_index_cpp.BUILD.bazel | 23 +++
+ .../ament_index_python.BUILD.bazel | 81 ++++++++++
+ repos/config/BUILD.bazel | 14 ++
+ repos/config/bazel.repos | 65 +++++---
+ repos/config/defs.bzl | 14 ++
+ repos/config/detail/BUILD.bazel | 14 ++
+ repos/config/detail/generate_ros2_config.py | 38 +++++
+ repos/config/detail/git_repository.bzl | 14 ++
+ repos/config/detail/lock_repos.py | 14 ++
+ repos/config/detail/new_local_repository.bzl | 77 ++++++++++
+ repos/config/detail/ros2_config.bzl | 14 ++
+ .../root.BUILD.bazel | 34 +++++
+ .../std_msgs.BUILD.bazel | 29 ++++
+ repos/ros2.rcl.BUILD/rcl.BUILD.bazel | 14 ++
+ .../rcl_yaml_param_parser.BUILD.bazel | 14 ++
+ .../builtin_interfaces.BUILD.bazel | 20 ++-
+ .../rcl_interfaces.BUILD.bazel | 15 ++
+ .../rosgraph_msgs.BUILD.bazel | 28 ++++
+ .../statistics_msgs.BUILD.bazel | 28 ++++
+ .../rcl_logging_interface.BUILD.bazel | 14 ++
+ repos/ros2.rclcpp.BUILD/build_interfaces.py | 37 +++++
+ repos/ros2.rclcpp.BUILD/rclcpp.BUILD.bazel | 75 +++++++++-
+ .../rcpputils.BUILD.bazel | 14 ++
+ .../build_logging_macros.py | 15 +-
+ repos/ros2.rcutils.BUILD/root.BUILD.bazel | 14 ++
+ repos/ros2.rmw.BUILD/rmw.BUILD.bazel | 19 ++-
+ .../tracetools.BUILD.bazel | 14 ++
+ repos/ros2.ros2cli.BUILD/ros2cli.BUILD.bazel | 90 ++++++++++++
+ repos/ros2.ros2cli.BUILD/ros2pkg.BUILD.bazel | 80 ++++++++++
+ repos/ros2.ros2cli.BUILD/ros2run.BUILD.bazel | 71 +++++++++
+ .../rosidl_adapter.BUILD.bazel | 58 ++++++++
+ .../ros2.rosidl.BUILD/rosidl_cli.BUILD.bazel | 28 ++++
+ .../rosidl_cmake.BUILD.bazel | 28 ++++
+ .../rosidl_generator_c.BUILD.bazel | 108 ++++++++++++++
+ .../rosidl_generator_cpp.BUILD.bazel | 71 +++++++++
+ .../rosidl_parser.BUILD.bazel | 28 ++++
+ .../rosidl_runtime_c.BUILD.bazel | 14 ++
+ .../rosidl_runtime_cpp.BUILD.bazel | 27 ++++
+ .../rosidl_typesupport_interface.BUILD.bazel | 14 ++
+ .../rosidl_generator_dds_idl.BUILD.bazel | 54 +++++++
+ .../rosidl_typesupport_c.BUILD.bazel | 82 +++++++++++
+ rosidl/defs.bzl | 104 ++++++++++++-
+ ..._library_with_hdrs_extracted_from_srcs.bzl | 45 ++++++
+ .../detail/cc_library_with_msgs_provider.bzl | 36 +++++
+ rosidl/detail/common_config.bzl | 80 ++++++++++
+ rosidl/detail/misc_support.bzl | 91 ++++++++++++
+ rosidl/detail/rosidl_adapter.bzl | 131 +++++++++++++++++
+ rosidl/detail/rosidl_generator_c.bzl | 131 +++++++++++++++++
+ rosidl/detail/rosidl_generator_cpp.bzl | 98 ++++++++++++
+ rosidl/detail/rosidl_generator_dds_idl.bzl | 118 +++++++++++++++
+ rosidl/detail/rosidl_typesupport_c.bzl | 109 ++++++++++++++
+ rosidl/detail/visiability_control.bzl | 26 ++++
+ rosidl/providers.bzl | 14 ++
+ thirdparty/bazel_skylib/repositories.bzl | 14 ++
+ thirdparty/bazel_skylib/setup.bzl | 14 ++
+ thirdparty/libyaml/libyaml.BUILD | 16 --
+ thirdparty/libyaml/libyaml.BUILD.bazel | 30 ++++
+ thirdparty/libyaml/repositories.bzl | 16 +-
+ thirdparty/python/repositories.bzl | 14 ++
+ thirdparty/python/requirements_lock.in | 6 +-
+ thirdparty/python/requirements_lock.txt | 54 +++++++
+ thirdparty/setup_01.bzl | 14 ++
+ thirdparty/setup_02.bzl | 14 ++
+ thirdparty/setup_03.bzl | 14 ++
+ thirdparty/setup_04.bzl | 14 ++
+ utils/template_expansion.bzl | 68 +++++++--
+ 87 files changed, 3184 insertions(+), 131 deletions(-)
+ create mode 100644 .bazelrc
+ create mode 100644 .bazelversion
+ create mode 100644 examples/BUILD.bazel
+ create mode 100644 examples/bazel_simple_example/BUILD
+ create mode 100644 examples/bazel_simple_example/publisher.cpp
+ create mode 100644 examples/bazel_simple_example/subscriber.cpp
+ create mode 100644 examples/hello_world/BUILD.bazel
+ rename examples/{simple_pkg_example => hello_world}/main.cpp (100%)
+ delete mode 100644 examples/simple_pkg_example/BUILD.bazel
+ create mode 100644 repos/ament.ament_index.BUILD/ament_index_cpp.BUILD.bazel
+ create mode 100644 repos/ament.ament_index.BUILD/ament_index_python.BUILD.bazel
+ create mode 100644 repos/config/detail/new_local_repository.bzl
+ create mode 100644 repos/ros-tooling.libstatistics_collector.BUILD/root.BUILD.bazel
+ create mode 100644 repos/ros2.common_interfaces.BUILD/std_msgs.BUILD.bazel
+ create mode 100644 repos/ros2.rcl_interfaces.BUILD/rosgraph_msgs.BUILD.bazel
+ create mode 100644 repos/ros2.rcl_interfaces.BUILD/statistics_msgs.BUILD.bazel
+ create mode 100644 repos/ros2.rclcpp.BUILD/build_interfaces.py
+ create mode 100644 repos/ros2.ros2cli.BUILD/ros2cli.BUILD.bazel
+ create mode 100644 repos/ros2.ros2cli.BUILD/ros2pkg.BUILD.bazel
+ create mode 100644 repos/ros2.ros2cli.BUILD/ros2run.BUILD.bazel
+ create mode 100644 repos/ros2.rosidl.BUILD/rosidl_adapter.BUILD.bazel
+ create mode 100644 repos/ros2.rosidl.BUILD/rosidl_cli.BUILD.bazel
+ create mode 100644 repos/ros2.rosidl.BUILD/rosidl_cmake.BUILD.bazel
+ create mode 100644 repos/ros2.rosidl.BUILD/rosidl_generator_c.BUILD.bazel
+ create mode 100644 repos/ros2.rosidl.BUILD/rosidl_generator_cpp.BUILD.bazel
+ create mode 100644 repos/ros2.rosidl.BUILD/rosidl_parser.BUILD.bazel
+ create mode 100644 repos/ros2.rosidl.BUILD/rosidl_runtime_cpp.BUILD.bazel
+ create mode 100644 repos/ros2.rosidl_dds.BUILD/rosidl_generator_dds_idl.BUILD.bazel
+ create mode 100644 repos/ros2.rosidl_typesupport.BUILD/rosidl_typesupport_c.BUILD.bazel
+ create mode 100644 rosidl/detail/cc_library_with_hdrs_extracted_from_srcs.bzl
+ create mode 100644 rosidl/detail/cc_library_with_msgs_provider.bzl
+ create mode 100644 rosidl/detail/common_config.bzl
+ create mode 100644 rosidl/detail/misc_support.bzl
+ create mode 100644 rosidl/detail/rosidl_adapter.bzl
+ create mode 100644 rosidl/detail/rosidl_generator_c.bzl
+ create mode 100644 rosidl/detail/rosidl_generator_cpp.bzl
+ create mode 100644 rosidl/detail/rosidl_generator_dds_idl.bzl
+ create mode 100644 rosidl/detail/rosidl_typesupport_c.bzl
+ create mode 100644 rosidl/detail/visiability_control.bzl
+ delete mode 100644 thirdparty/libyaml/libyaml.BUILD
+ create mode 100644 thirdparty/libyaml/libyaml.BUILD.bazel
+
+diff --git a/.bazelrc b/.bazelrc
+new file mode 100644
+index 0000000..e6717c0
+--- /dev/null
++++ b/.bazelrc
+@@ -0,0 +1,12 @@
++# enable incompatible python init mode
++build --incompatible_default_to_explicit_init_py
++
++# enable implementation_deps on cc_library targets
++build --experimental_cc_implementation_deps
++
++# set c++14 for all builds
++build --cxxopt="-std=c++17"
++build --host_cxxopt="-std=c++17"
++
++# try to import a user-specific bazelrc (gitignored)
++try-import %workspace%/user.bazelrc
+diff --git a/.bazelversion b/.bazelversion
+new file mode 100644
+index 0000000..7d3cdbf
+--- /dev/null
++++ b/.bazelversion
+@@ -0,0 +1 @@
++5.3.1
+\ No newline at end of file
+diff --git a/README.md b/README.md
+index 55bd0dc..01ef700 100644
+--- a/README.md
++++ b/README.md
+@@ -5,11 +5,11 @@
+ This repository contains all the setup, rules and build configuration to use
+ [Bazel](http://bazel.build) with ROS2. As reccomended by Bazel, all ROS2 packages
+ are built from source. They are loaded as needed, so no a priori loading or manual version
+-management of ROS2 repos is required.
++management of ROS2 repos (e.g. via vcs tool) is required.
+
+ The neccessary BUILD files for ROS2 repos are injected while loading. In case bazel will
+-gain some traction within the ROS community, Bazel BUILD files can also be provided directly
+-by the ROS2 repositories.
++gain some traction within the ROS community, Bazel BUILD files should ideally be provided
++directly by the ROS2 repositories.
+
+ Specific rules for message generation and packaging are provided in this repository (see
+ [rosidl/defs.bzl](rosidl/defs.bzl) and [pkg/defs.bzl](pkg/defs.bzl)).
+@@ -22,51 +22,110 @@ Here is a short list of major restrictions:
+ will not be supported in the foreseeable future.
+ * Only ROS2 humble supported. Other distros may work after extending
+ `@rules_ros//repos/config/defs.bzl` accordingly.
+-* Message generation is still incomplete. Therefore even the simples examples will not compile
+- fully yet.
++* Message generation is still incomplete. Therefore even the simplest examples will not run
++ due to not yet bazelized middleware.
+ * Not all packages have been bazelized yet. Main focus currently lies on generating an
+- install space and providing message generation support.
+-* The addition of custom packages into the repo setup is not yet available. Same applies to
+- adding additional python packages. This will be added soon.
++ install space and providing message generation support. From the `ros2cli` only the `run`
++ command is currently bazelized.
++* The streamlined integration of custom packages into the repo setup is not yet available.
++ Same applies to adding additional python packages.
++ This will be added soon.
+
+ ## Getting started
+
+-### Workspace setup
+-
+-To import rules_ros in your project, add the following code snippet to your WORKSPACE file:
+-
+-```python
+-load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+-
+-RULES_ROS_VERSION = "xxx" # TODO: where to find the right version
+-RUIES_ROS_SHA = "xxx"
+-
+-https_archive(
+- name = "rules_ros",
+- sha256 = RUIES_ROS_SHA,
+- strip_prefix = "xxx",
+- url = "https://github.com/ApexAI/rules_ros/archive/{}.zip".format(RULES_ROS_VERSION),
+-)
+-
+-load("@rules_ros//repos/config:defs.bzl", "configure_ros2")
+-configure_ros2(distro = "humble") # currently only humble is supported
+-
+-load("@ros2_config//:setup.bzl", "setup")
+-setup()
++### Prerequisits
++Bazel needs to be available. We reccomend using [bazelisk](https://github.com/bazelbuild/bazelisk)
++as a launch tool for bazel.
+
+-load("@rules_ros//thirdparty:setup_01.bzl", "setup_01")
+-setup_01()
+-
+-load("@rules_ros//thirdparty:setup_02.bzl", "setup_02")
+-setup_02()
++### Workspace setup
++Create an empty folder and add the following files to it:
++* `WORKSPACE` file:
++ ```python
++ workspace(name = "my_first_bazel_ros_workspace") # choose your workspace name here
++ # load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
++ load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
++
++ RULES_ROS_VERSION = "xxx" # TODO: where to find the right version
++ RUIES_ROS_SHA = "xxx"
++
++ # until we have a first release, please use this:
++ git_repository(
++ name = "rules_ros",
++ remote = "https://github.com/ApexAI/rules_ros.git",
++ branch = "main",
++ )
++
++ # after the first release, switch to this dependency
++ #https_archive(
++ # name = "rules_ros",
++ # sha256 = RULES_ROS_SHA,
++ # strip_prefix = "xxx",
++ # url = "https://github.com/ApexAI/rules_ros/archive/{}.zip".format(RULES_ROS_VERSION),
++ #)
++
++ load("@rules_ros//repos/config:defs.bzl", "configure_ros2")
++ configure_ros2(distro = "humble") # currently only humble is supported
++
++ load("@ros2_config//:setup.bzl", "setup")
++ setup()
++
++ load("@rules_ros//thirdparty:setup_01.bzl", "setup_01")
++ setup_01()
++
++ load("@rules_ros//thirdparty:setup_02.bzl", "setup_02")
++ setup_02()
++
++ load("@rules_ros//thirdparty:setup_03.bzl", "setup_03")
++ setup_03()
++
++ load("@rules_ros//thirdparty:setup_04.bzl", "setup_04")
++ setup_04()
++ ```
++* `.bazelrc` file:
++ ```bash
++ # enable incompatible python init mode
++ build --incompatible_default_to_explicit_init_py
++
++ # enable implementation_deps on cc_library targets
++ build --experimental_cc_implementation_deps
++
++ # set c++14 for all builds
++ build --cxxopt="-std=c++17"
++ build --host_cxxopt="-std=c++17"
++ ```
++
++* `.bazelversion` file (in case you are using bazelisk):
++ ```text
++ 5.3.1
++ ```
++
++### Run bazel example
++To **build** an example delivered in the `rules_ros` repository run e.g.
++```bash
++bazel build @rules_ros//examples/hello_world
++```
++from anywhere within your workspace.
+
+-load("@rules_ros//thirdparty:setup_03.bzl", "setup_03")
+-setup_03()
++**Executing** the example can be done by calling
++```bash
++bazel run @rules_ros//examples/hello_world
++```
++Note that no sourcing is necessary. Bazel will take care of all the dependencies.
+
+-load("@rules_ros//thirdparty:setup_04.bzl", "setup_04")
+-setup_04()
++**Deploying** a package archive to an install folder can be done by
++```bash
++bazel run @rules_ros//examples:rules_ros_examples.install <install_folder>
++```
++Now we are back to working with ROS as usual. Source the package as usual:
++```bash
++source <install_folder>/setup.bash
++```
++and run an executable with
++```bash
++ros2 run hello_world hello_world
+ ```
+
++## Features
+ ### Python Interpreter
+
+ In this setup a hermetic python interpreter is included. The version is specified in
+@@ -77,7 +136,7 @@ you must run
+ bazel run @rules_ros//thirdparty/python:requirements_lock.update
+ ```
+ to pin specific versions of the dependencies. In the future there will be a possibility to
+-inject any customization in the WORKSPACE file.
++inject a customization in the WORKSPACE file.
+
+ ### ROS2 Repositories
+
+diff --git a/WORKSPACE b/WORKSPACE
+index 6a5bbcf..a9159b5 100644
+--- a/WORKSPACE
++++ b/WORKSPACE
+@@ -1,3 +1,17 @@
++# Copyright 2022 Apex.AI, Inc.
++#
++# Licensed under the Apache License, Version 2.0 (the "License");
++# you may not use this file except in compliance with the License.
++# You may obtain a copy of the License at
++#
++# http://www.apache.org/licenses/LICENSE-2.0
++#
++# Unless required by applicable law or agreed to in writing, software
++# distributed under the License is distributed on an "AS IS" BASIS,
++# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++# See the License for the specific language governing permissions and
++# limitations under the License.
++
+ workspace(name = "rules_ros")
+
+ load("//repos/config:defs.bzl", "configure_ros2")
+diff --git a/examples/BUILD.bazel b/examples/BUILD.bazel
+new file mode 100644
+index 0000000..d633e88
+--- /dev/null
++++ b/examples/BUILD.bazel
+@@ -0,0 +1,27 @@
++# Copyright 2022 Apex.AI, Inc.
++#
++# Licensed under the Apache License, Version 2.0 (the "License");
++# you may not use this file except in compliance with the License.
++# You may obtain a copy of the License at
++#
++# http://www.apache.org/licenses/LICENSE-2.0
++#
++# Unless required by applicable law or agreed to in writing, software
++# distributed under the License is distributed on an "AS IS" BASIS,
++# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++# See the License for the specific language governing permissions and
++# limitations under the License.
++load("@rules_ros//pkg:defs.bzl", "ros_archive", "ros_pkg_set")
++
++ros_pkg_set(
++ name = "rules_ros_examples_pkgs",
++ deps = [
++ "//examples/hello_world:hello_world_pkg",
++ "@ros2.ros2cli//ros2cli",
++ ],
++)
++
++ros_archive(
++ name = "rules_ros_examples",
++ ros_pkgs = [":rules_ros_examples_pkgs"],
++)
+diff --git a/examples/bazel_simple_example/BUILD b/examples/bazel_simple_example/BUILD
+new file mode 100644
+index 0000000..ddf0dd1
+--- /dev/null
++++ b/examples/bazel_simple_example/BUILD
+@@ -0,0 +1,47 @@
++# Copyright 2022 Apex.AI, Inc.
++#
++# Licensed under the Apache License, Version 2.0 (the "License");
++# you may not use this file except in compliance with the License.
++# You may obtain a copy of the License at
++#
++# http://www.apache.org/licenses/LICENSE-2.0
++#
++# Unless required by applicable law or agreed to in writing, software
++# distributed under the License is distributed on an "AS IS" BASIS,
++# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++# See the License for the specific language governing permissions and
++# limitations under the License.
++load("@rules_ros//pkg:defs.bzl", "ros_pkg")
++
++cc_binary(
++ name = "publisher",
++ srcs = ["publisher.cpp"],
++ deps = [
++ "@ros2.common_interfaces//std_msgs",
++ "@ros2.rclcpp//rclcpp",
++ ],
++)
++
++cc_binary(
++ name = "subscriber",
++ srcs = ["subscriber.cpp"],
++ deps = [
++ "@ros2.common_interfaces//std_msgs",
++ "@ros2.rclcpp//rclcpp",
++ ],
++)
++
++ros_pkg(
++ name = "bazel_simple_example_pkg",
++ description = "Simple pub/sub example",
++ lib_executables = [
++ "publisher",
++ "subscriber",
++ ],
++ license = "Apex.AI License",
++ maintainer_email = "[email protected]",
++ maintainer_name = "Kilian Funk",
++ pkg_name = "bazel_simple_example",
++ version = "1.0.0",
++ visibility = ["//visibility:public"],
++)
+diff --git a/examples/bazel_simple_example/publisher.cpp b/examples/bazel_simple_example/publisher.cpp
+new file mode 100644
+index 0000000..5973bcf
+--- /dev/null
++++ b/examples/bazel_simple_example/publisher.cpp
+@@ -0,0 +1,58 @@
++// Copyright 2022 Apex.AI, Inc.
++//
++// Licensed under the Apache License, Version 2.0 (the "License");
++// you may not use this file except in compliance with the License.
++// You may obtain a copy of the License at
++//
++// http://www.apache.org/licenses/LICENSE-2.0
++//
++// Unless required by applicable law or agreed to in writing, software
++// distributed under the License is distributed on an "AS IS" BASIS,
++// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++// See the License for the specific language governing permissions and
++// limitations under the License.
++
++#include <rclcpp/duration.hpp>
++#include <rclcpp/node.hpp>
++
++#include <iostream>
++
++#include <chrono>
++#include <functional>
++#include <memory>
++#include <string>
++
++#include "rclcpp/rclcpp.hpp"
++#include "std_msgs/msg/string.hpp"
++
++using namespace std::chrono_literals;
++
++/* This example creates a subclass of Node and uses std::bind() to register a
++ * member function as a callback from the timer. */
++
++class MinimalPublisher : public rclcpp::Node {
++public:
++ MinimalPublisher() : Node("minimal_publisher"), count_(0) {
++ publisher_ = this->create_publisher<std_msgs::msg::String>("topic", 10);
++ timer_ = this->create_wall_timer(
++ 500ms, std::bind(&MinimalPublisher::timer_callback, this));
++ }
++
++private:
++ void timer_callback() {
++ auto message = std_msgs::msg::String();
++ message.data = "Hello, world! " + std::to_string(count_++);
++ RCLCPP_INFO(this->get_logger(), "Publishing: '%s'", message.data.c_str());
++ publisher_->publish(message);
++ }
++ rclcpp::TimerBase::SharedPtr timer_;
++ rclcpp::Publisher<std_msgs::msg::String>::SharedPtr publisher_;
++ size_t count_;
++};
++
++int main(int argc, char *argv[]) {
++ rclcpp::init(argc, argv);
++ rclcpp::spin(std::make_shared<MinimalPublisher>());
++ rclcpp::shutdown();
++ return 0;
++}
+diff --git a/examples/bazel_simple_example/subscriber.cpp b/examples/bazel_simple_example/subscriber.cpp
+new file mode 100644
+index 0000000..916725e
+--- /dev/null
++++ b/examples/bazel_simple_example/subscriber.cpp
+@@ -0,0 +1,40 @@
++// Copyright 2022 Apex.AI, Inc.
++//
++// Licensed under the Apache License, Version 2.0 (the "License");
++// you may not use this file except in compliance with the License.
++// You may obtain a copy of the License at
++//
++// http://www.apache.org/licenses/LICENSE-2.0
++//
++// Unless required by applicable law or agreed to in writing, software
++// distributed under the License is distributed on an "AS IS" BASIS,
++// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++// See the License for the specific language governing permissions and
++// limitations under the License.
++
++#include <memory>
++
++#include "rclcpp/rclcpp.hpp"
++#include "std_msgs/msg/string.hpp"
++using std::placeholders::_1;
++
++class MinimalSubscriber : public rclcpp::Node {