Skip to content

Commit d636c7b

Browse files
committed
[build] allow calling go script with arguments that match bazel
1 parent 4fac8eb commit d636c7b

File tree

2 files changed

+58
-4
lines changed

2 files changed

+58
-4
lines changed

go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,23 @@ unset GEM_PATH
66

77
JAVA_OPTS="-client -Xmx4096m -XX:ReservedCodeCacheSize=512m -XX:MetaspaceSize=1024m --add-modules java.se --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/javax.crypto=ALL-UNNAMED"
88

9-
java $JAVA_OPTS -jar third_party/jruby/jruby-complete.jar -X-C -S rake $*
9+
# The first argument is always the Rake task name
10+
task="$1"
11+
12+
# Shift the task off and get the remaining arguments
13+
shift
14+
15+
# Leave task alone if already passing in arguments the normal way
16+
if [[ "$task" != *[*]* ]]; then
17+
# Combine remaining arguments into a single string, clean up spaces after commas, and replace spaces with commas
18+
args=$(IFS=' '; echo "$*" | sed -e 's/,[ ]*/,/g' -e 's/ /,/g')
19+
20+
# If there are any arguments, format them as task[arg1,arg2,...]
21+
if [ -n "$args" ]; then
22+
task="$task[$args]"
23+
echo "Executing rake task: $task"
24+
fi
25+
fi
26+
27+
java $JAVA_OPTS -jar third_party/jruby/jruby-complete.jar -X-C -S rake $task
1028

go.bat

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,46 @@
11
@echo off
2-
SETLOCAL
2+
SETLOCAL EnableDelayedExpansion
33

44
REM we want jruby-complete to take care of all things ruby
55
SET GEM_HOME=
66
SET GEM_PATH=
77

8-
SET JAVA_OPTS=-client -Xmx4096m -XX:ReservedCodeCacheSize=512m --add-modules java.se --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/javax.crypto=ALL-UNNAMED
8+
REM The first argument is always the Rake task name
9+
SET task=%1
910

10-
java %JAVA_OPTS% -jar third_party\jruby\jruby-complete.jar -X-C -S rake %*
11+
REM Check for arguments
12+
IF "%task%"=="" (
13+
echo No task specified
14+
exit /b 1
15+
)
16+
17+
REM Shift the task off and get the remaining arguments
18+
SHIFT
19+
20+
REM Leave task alone if already passing in arguments the normal way
21+
ECHO %task% | FINDSTR /C:"[" >NUL
22+
IF %ERRORLEVEL% EQU 0 (
23+
GOTO execute
24+
)
25+
26+
REM Process remaining arguments
27+
SET args=
28+
:process_args
29+
IF "%1"=="" GOTO done_args
30+
IF "!args!"=="" (
31+
SET args=%1
32+
) ELSE (
33+
SET args=!args!,%1
34+
)
35+
SHIFT
36+
GOTO process_args
37+
38+
:done_args
39+
REM If there are any arguments, format them as task[arg1,arg2,...]
40+
IF NOT "!args!"=="" (
41+
SET task=%task%[!args!]
42+
ECHO Executing rake task: %task%
43+
)
44+
45+
:execute
46+
java %JAVA_OPTS% -jar third_party\jruby\jruby-complete.jar -X-C -S rake %task%

0 commit comments

Comments
 (0)