Skip to content

Commit

Permalink
Fix Windows compatibility with ROS TypeScript generator (#541)
Browse files Browse the repository at this point in the history
* Fix

* Add npx (?)

* Fix foxglove clean

* Remove npm

* Add docstring
  • Loading branch information
maxwellmlin authored Apr 21, 2024
1 parent c61ba6c commit 5e2ffab
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
10 changes: 6 additions & 4 deletions foxglove/foxglove.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@
LAYOUTS_PATH = FOXGLOVE_PATH / "layouts"


def run_at_path(command: Union[str, Sequence[str]], directory: pathlib.Path, system: str = SYSTEM):
def run_at_path(command: Union[str, Sequence[str]], directory: pathlib.Path, system: str = SYSTEM,
windows_append_cmd: bool = True):
"""
Run a command at a given path.
Args:
command: Command to run.
directory: Path to run command at.
system: If "Windows", run command with .cmd extension. Defaults to platform.system().
system: Can be "Linux", "Darwin", or "Windows". Defaults to platform.system().
windows_append_cmd: If True, append ".cmd" to command on Windows systems.
Raises:
ValueError: If command empty.
Expand All @@ -65,7 +67,7 @@ def run_at_path(command: Union[str, Sequence[str]], directory: pathlib.Path, sys
else:
args = list(command)

if system == "Windows":
if system == "Windows" and windows_append_cmd:
args[0] += ".cmd"

print(f"{directory.name}: {command}")
Expand Down Expand Up @@ -278,7 +280,7 @@ def clean_foxglove():
"""
Clean up the foxglove monorepo.
"""
run_at_path("git clean -fdx", FOXGLOVE_PATH)
run_at_path("git clean -fdx", FOXGLOVE_PATH, windows_append_cmd=False)


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion foxglove/shared/defs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"scripts": {
"clean": "rimraf --glob custom_msg_defs/dist datatype_maps/dist types/dist/* && mkdirp types/dist",
"build-ts": "npx ts-node src/index.ts",
"generate-types": "npx ros-typescript-generator --config ros_ts_generator_configs/custom-msgs.json",
"generate-types": "cd ros_ts_generator_configs && ros-typescript-generator",
"concatenate-types": "concat-cli -f types/dist/customMsgs.ts types/ros1Msgs.ts -o types/dist/types.ts",
"build": "npm run clean && npm run build-ts && npm run generate-types && npm run concatenate-types"
},
Expand Down
10 changes: 0 additions & 10 deletions foxglove/shared/defs/ros_ts_generator_configs/custom-msgs.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"output": "../types/dist/customMsgs.ts",
"rosVersion": 1,
"input": [
{
"namespace": "custom_msgs",
"path": "../../../../core/catkin_ws/src/custom_msgs"
}
]
}

0 comments on commit 5e2ffab

Please sign in to comment.