-
Notifications
You must be signed in to change notification settings - Fork 397
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add examples/bazel with a sample downstream use, licensed as MIT-0. Other fixes: - Adjust lcm_eventlog.py test to not require copying the example log. - Fix a small typo in the go example.
- Loading branch information
1 parent
29044b6
commit a3808b3
Showing
51 changed files
with
1,618 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# When traversing //... don't incorporate the example. | ||
examples/bazel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
8.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: test_bazel | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
bazel: | ||
strategy: | ||
matrix: | ||
os: [ubuntu-24.04, macos-14] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: bazel-contrib/setup-bazel@0.13.0 | ||
with: | ||
bazelisk-cache: true | ||
disk-cache: ${{ github.workflow }} | ||
repository-cache: true | ||
- name: Test Main | ||
run : 'bazel test //...' | ||
- name: Test Example | ||
working-directory: examples/bazel | ||
run : 'bazel test //...' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
build*/ | ||
__pycache__ | ||
docs/_build/ | ||
bazel-* | ||
MODULE.bazel.lock | ||
|
||
.vscode/ | ||
.idea/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
load("@rules_license//rules:license.bzl", "license") | ||
|
||
package( | ||
default_applicable_licenses = [":license"], | ||
default_visibility = ["//visibility:public"], | ||
) | ||
|
||
exports_files([ | ||
"COPYING", | ||
]) | ||
|
||
license( | ||
name = "license", | ||
license_kinds = ["@rules_license//licenses/spdx:LGPL-2.1"], | ||
license_text = "COPYING", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# This file specifies a Bazel workspace (see https://bazel.build/). | ||
# | ||
# For now, LCM's Bazel build only supports C, C++, Java, and Python. | ||
# We invite users to submit pull requests for other languages if needed. | ||
|
||
module( | ||
name = "lcm", | ||
bazel_compatibility = [">=8.0.1"], | ||
) | ||
|
||
# Load bazel rules. | ||
|
||
bazel_dep(name = "apple_support", version = "1.17.1", repo_name = "build_bazel_apple_support") | ||
bazel_dep(name = "bazel_skylib", version = "1.7.1") | ||
bazel_dep(name = "platforms", version = "0.0.10") | ||
bazel_dep(name = "rules_cc", version = "0.0.17") | ||
bazel_dep(name = "rules_java", version = "8.6.1") | ||
bazel_dep(name = "rules_jvm_external", version = "6.6") | ||
bazel_dep(name = "rules_license", version = "1.0.0") | ||
bazel_dep(name = "rules_python", version = "0.40.0") | ||
|
||
# Load runtime dependencies. | ||
|
||
bazel_dep(name = "pcre2", version = "10.45") | ||
bazel_dep(name = "glib", version = "2.82.2.bcr.1") | ||
|
||
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven") | ||
maven.install( | ||
name = "lcm_maven", | ||
artifacts = [ | ||
"junit:junit:4.11", | ||
"net.sf.jchart2d:jchart2d:3.3.2", | ||
], | ||
) | ||
use_repo(maven, "lcm_maven") | ||
|
||
# Load dev dependencies. | ||
|
||
bazel_dep(name = "googletest", version = "1.15.2", dev_dependency = True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../.bazelversion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# SPDX-License-Identifier: MIT-0 | ||
|
||
bazel-* | ||
MODULE.bazel.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
# SPDX-License-Identifier: MIT-0 | ||
# | ||
# Using LGPL-2.1 for examples leads to unnecessary hassle for users, so this | ||
# example is licensed under the https://spdx.org/licenses/MIT-0.html license, | ||
# except for the exlcm/*.lcm message definitions. | ||
|
||
load("@lcm//lcm-bazel:lcm_c_library_srcs.bzl", "lcm_c_library_srcs") | ||
load("@lcm//lcm-bazel:lcm_cc_library_srcs.bzl", "lcm_cc_library_srcs") | ||
load("@lcm//lcm-bazel:lcm_java_library_srcs.bzl", "lcm_java_library_srcs") | ||
load("@lcm//lcm-bazel:lcm_library.bzl", "lcm_library") | ||
load("@lcm//lcm-bazel:lcm_py_library_srcs.bzl", "lcm_py_library_srcs") | ||
load("@rules_cc//cc:cc_library.bzl", "cc_library") | ||
load("@rules_cc//cc:cc_test.bzl", "cc_test") | ||
load("@rules_java//java:java_binary.bzl", "java_binary") | ||
load("@rules_java//java:java_library.bzl", "java_library") | ||
load("@rules_license//rules:license.bzl", "license") | ||
load("@rules_python//python:py_library.bzl", "py_library") | ||
load("@rules_python//python:py_test.bzl", "py_test") | ||
|
||
package( | ||
default_applicable_licenses = [":license"], | ||
default_visibility = ["//visibility:public"], | ||
) | ||
|
||
exports_files([ | ||
"LICENSE.TXT", | ||
]) | ||
|
||
license( | ||
name = "license", | ||
license_kinds = ["@rules_license//licenses/spdx:MIT-0"], | ||
license_text = "LICENSE.TXT", | ||
) | ||
|
||
# Run lcm-gen on 'exlcm' for C, C++, Java, and Python. | ||
|
||
lcm_library( | ||
name = "exlcm", | ||
srcs = glob(["exlcm/*.lcm"]), | ||
lcm_package = "exlcm", | ||
) | ||
|
||
lcm_c_library_srcs( | ||
name = "exlcm_c_srcs", | ||
src = ":exlcm", | ||
) | ||
|
||
cc_library( | ||
name = "exlcm_c", | ||
srcs = [":exlcm_c_srcs"], | ||
deps = ["@lcm//lcm:lcm-static"], | ||
) | ||
|
||
lcm_cc_library_srcs( | ||
name = "exlcm_cc_srcs", | ||
src = ":exlcm", | ||
) | ||
|
||
cc_library( | ||
name = "exlcm_cc", | ||
srcs = [":exlcm_cc_srcs"], | ||
deps = ["@lcm//lcm:lcm-coretypes"], | ||
) | ||
|
||
lcm_java_library_srcs( | ||
name = "exlcm_java_srcs", | ||
src = ":exlcm", | ||
) | ||
|
||
java_library( | ||
name = "exlcm_java", | ||
srcs = [":exlcm_java_srcs"], | ||
deps = ["@lcm//lcm-java"], | ||
) | ||
|
||
lcm_py_library_srcs( | ||
name = "exlcm_py_srcs", | ||
src = ":exlcm", | ||
) | ||
|
||
py_library( | ||
name = "exlcm_py", | ||
srcs = [":exlcm_py_srcs"], | ||
imports = ["."], | ||
) | ||
|
||
# Perform some basic testing on the generated messages. | ||
|
||
cc_test( | ||
name = "test_c", | ||
srcs = ["test_c.c"], | ||
deps = [ | ||
":exlcm_c", | ||
"@lcm//lcm:lcm-static", | ||
], | ||
) | ||
|
||
cc_test( | ||
name = "test_cc", | ||
srcs = ["test_cc.cc"], | ||
deps = [ | ||
":exlcm_cc", | ||
"@lcm//lcm:lcm-static", | ||
], | ||
) | ||
|
||
py_test( | ||
name = "test_py", | ||
srcs = ["test_py.py"], | ||
deps = [ | ||
":exlcm_py", | ||
"@lcm//lcm-python", | ||
], | ||
) | ||
|
||
# Create aliases for the Java tools, adding our messages to the classpath. | ||
|
||
java_binary( | ||
name = "lcm-spy", | ||
main_class = "lcm.spy.Spy", | ||
runtime_deps = [ | ||
":exlcm_java", | ||
], | ||
) | ||
|
||
java_binary( | ||
name = "lcm-logplayer-gui", | ||
main_class = "lcm.logging.LogPlayer", | ||
runtime_deps = [ | ||
":exlcm_java", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software is furnished to do so. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# SPDX-License-Identifier: MIT-0 | ||
|
||
bazel_dep(name = "lcm", version = "1.5.1") | ||
|
||
# This example uses lcm from our same git checkout. In most cases, you'll want | ||
# to remove this override in your own projects. | ||
local_path_override( | ||
module_name = "lcm", | ||
path = "../..", | ||
) | ||
|
||
bazel_dep(name = "rules_cc", version = "0.0.17") | ||
bazel_dep(name = "rules_java", version = "8.6.1") | ||
bazel_dep(name = "rules_license", version = "1.0.0") | ||
bazel_dep(name = "rules_python", version = "0.40.0") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../types/example_list_t.lcm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../types/example_t.lcm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../types/exampleconst_t.lcm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../types/multidim_array_t.lcm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../types/node_t.lcm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* SPDX-License-Identifier: MIT-0 */ | ||
|
||
#include <lcm/lcm.h> | ||
#include <stdio.h> | ||
|
||
#include "exlcm_example_t.h" | ||
|
||
int main() | ||
{ | ||
exlcm_example_t message = {}; | ||
message.name = ""; | ||
const int size = exlcm_example_t_encoded_size(&message); | ||
if (size != 82) { | ||
fprintf(stderr, "size = %d\n", size); | ||
fflush(stderr); | ||
return 1; | ||
} | ||
|
||
lcm_t *memq = lcm_create("memq://"); | ||
int handled = -1; | ||
if (memq != NULL) { | ||
handled = lcm_handle_timeout(memq, 0); | ||
lcm_destroy(memq); | ||
} | ||
if (handled != 0) { | ||
fprintf(stderr, "memq failure\n"); | ||
fflush(stderr); | ||
return 1; | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* SPDX-License-Identifier: MIT-0 */ | ||
|
||
#include <iostream> | ||
|
||
#include <lcm/lcm-cpp.hpp> | ||
|
||
#include "exlcm/example_t.hpp" | ||
|
||
int main() { | ||
exlcm::example_t message = {}; | ||
const auto size = message.getEncodedSize(); | ||
if (size != 82) { | ||
std::cerr << "size = " << size << "\n"; | ||
return 1; | ||
} | ||
|
||
lcm::LCM memq("memq://"); | ||
if (memq.handleTimeout(0) != 0) { | ||
std::cerr << "memq failure\n"; | ||
return 1; | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# SPDX-License-Identifier: MIT-0 | ||
|
||
import unittest | ||
|
||
import lcm | ||
|
||
from exlcm import example_t | ||
|
||
|
||
class TestPy(unittest.TestCase): | ||
def test_size(self): | ||
message = example_t() | ||
size = len(message.encode()) | ||
self.assertEqual(size, 82) | ||
|
||
def test_memq(self): | ||
memq = lcm.LCM("memq://") | ||
self.assertEqual(memq.handle_timeout(0), 0) | ||
|
||
|
||
def main(): | ||
unittest.main() | ||
|
||
|
||
assert __name__ == '__main__' | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package( | ||
default_applicable_licenses = ["//:license"], | ||
default_visibility = ["//visibility:private"], | ||
) |
Oops, something went wrong.