Skip to content

Commit 141b49d

Browse files
committed
add support for running lcm-spy and lcm-logplayer-gui on windows
1 parent a7da9e6 commit 141b49d

File tree

4 files changed

+89
-15
lines changed

4 files changed

+89
-15
lines changed

lcm-java/CMakeLists.txt

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,45 @@ add_jar(lcm-java
7171

7272
install_jar(lcm-java DESTINATION share/java)
7373

74-
configure_file(
75-
${CMAKE_CURRENT_SOURCE_DIR}/lcm-spy.sh.in
76-
${CMAKE_CURRENT_BINARY_DIR}/lcm-spy
77-
@ONLY
78-
)
74+
if(WIN32)
7975

80-
lcm_copy_file_target(lcm-logplayer-gui-alias
81-
${CMAKE_CURRENT_SOURCE_DIR}/lcm-logplayer-gui.sh
82-
${CMAKE_CURRENT_BINARY_DIR}/lcm-logplayer-gui
83-
)
76+
configure_file(
77+
${CMAKE_CURRENT_SOURCE_DIR}/lcm-spy.bat.in
78+
${CMAKE_CURRENT_BINARY_DIR}/lcm-spy.bat
79+
@ONLY
80+
)
8481

85-
install(PROGRAMS
86-
${CMAKE_CURRENT_BINARY_DIR}/lcm-logplayer-gui
87-
${CMAKE_CURRENT_BINARY_DIR}/lcm-spy
88-
DESTINATION bin
89-
)
82+
lcm_copy_file_target(lcm-logplayer-gui-alias
83+
${CMAKE_CURRENT_SOURCE_DIR}/lcm-logplayer-gui.bat
84+
${CMAKE_CURRENT_BINARY_DIR}/lcm-logplayer-gui.bat
85+
)
86+
87+
install(PROGRAMS
88+
${CMAKE_CURRENT_BINARY_DIR}/lcm-logplayer-gui.bat
89+
${CMAKE_CURRENT_BINARY_DIR}/lcm-spy.bat
90+
DESTINATION bin
91+
)
92+
93+
else()
94+
95+
configure_file(
96+
${CMAKE_CURRENT_SOURCE_DIR}/lcm-spy.sh.in
97+
${CMAKE_CURRENT_BINARY_DIR}/lcm-spy
98+
@ONLY
99+
)
100+
101+
lcm_copy_file_target(lcm-logplayer-gui-alias
102+
${CMAKE_CURRENT_SOURCE_DIR}/lcm-logplayer-gui.sh
103+
${CMAKE_CURRENT_BINARY_DIR}/lcm-logplayer-gui
104+
)
105+
106+
install(PROGRAMS
107+
${CMAKE_CURRENT_BINARY_DIR}/lcm-logplayer-gui
108+
${CMAKE_CURRENT_BINARY_DIR}/lcm-spy
109+
DESTINATION bin
110+
)
111+
112+
endif()
90113

91114
install(FILES
92115
lcm-logplayer-gui.1

lcm-java/lcm-logplayer-gui.bat

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
:: Determine our canonical location
2+
set mydir=%~dp0
3+
4+
:: Find our JAR
5+
if exist %mydir%\lcm.jar (
6+
set jars=%mydir%\lcm.jar
7+
) else (
8+
if exist %mydir%\..\share\java\lcm.jar (
9+
set jars=%mydir%\..\share\java\lcm.jar
10+
) else (
11+
echo "Unable to find 'lcm.jar'; please check your installation"
12+
exit 1
13+
)
14+
)
15+
16+
:: Add user's CLASSPATH, if set
17+
IF NOT "%CLASSPATH%"=="" set jars=%jars%;%CLASSPATH%
18+
19+
:: Launch the applet
20+
java -server -Djava.net.preferIPv4Stack=true -Xmx64m -Xms32m -ea -cp "%jars%" lcm.logging.LogPlayer %*

lcm-java/lcm-spy.bat.in

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
setlocal enableDelayedExpansion
2+
3+
:: Determine our canonical location
4+
set mydir=%~dp0
5+
6+
:: Find dependency JARs
7+
if exist %mydir%\lcm.jar (
8+
set jars=%mydir%\lcm.jar
9+
set jars=!jars!;%mydir%\jchart2d-code\jchart2d-3.2.2.jar
10+
set ext=%mydir%\jchart2d-code\ext
11+
) else (
12+
if exist %mydir%\..\share\java\lcm.jar (
13+
set jars=%mydir%\..\share\java\lcm.jar
14+
set jars=!jars!;%mydir%\..\share\java\jchart2d-3.2.2.jar
15+
set ext=%mydir%\..\share\java
16+
) else (
17+
echo "Unable to find 'lcm.jar'; please check your installation"
18+
exit 1
19+
)
20+
)
21+
22+
set jars=%jars%:@LCM_EXT_XMLGRAPHICS_COMMONS_JAR@
23+
set jars=%jars%:@LCM_EXT_JIDE_OSS_JAR@
24+
25+
:: Add user's CLASSPATH, if set
26+
IF NOT "%CLASSPATH%"=="" set jars=%jars%;%CLASSPATH%
27+
28+
:: Launch the applet
29+
java -server -Djava.net.preferIPv4Stack=true -Xmx128m -Xms64m -ea -cp "%jars%" lcm.spy.Spy %*

lcm-python/lcm/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import sys
33
import subprocess
4+
import platform
45

56
# Attempt to be backwards compatible
67
if sys.version_info >= (3, 6):
@@ -176,8 +177,9 @@ def tell (self):
176177
LCM_BIN_DIR = os.path.join(os.path.dirname(__file__), '..', 'bin')
177178

178179
def run_script(name: str, args) -> int:
180+
file_extension = '.bat' if platform.system() == 'Windows' else ''
179181
try:
180-
return subprocess.call([os.path.join(LCM_BIN_DIR, name), *args], close_fds=False)
182+
return subprocess.call([os.path.join(LCM_BIN_DIR, name + file_extension), *args], close_fds=False)
181183
except KeyboardInterrupt:
182184
return 0
183185

0 commit comments

Comments
 (0)