Skip to content

Commit 36b9154

Browse files
compnerdkeith
authored andcommitted
tools: port mkdir_and_run to work on Windows
Prefer a cmd script over bash on Windows. This allows this command to be used across platforms.
1 parent f7a4ac5 commit 36b9154

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.cmd text eol=crlf

tools/mkdir_and_run/BUILD

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1+
load("@bazel_skylib//rules:native_binary.bzl", "native_binary")
2+
13
licenses(["notice"])
24

3-
sh_binary(
5+
native_binary(
46
name = "mkdir_and_run",
5-
srcs = ["mkdir_and_run.sh"],
7+
src = select({
8+
"@bazel_tools//src/conditions:host_windows": "mkdir_and_run.cmd",
9+
"//conditions:default": "mkdir_and_run.sh",
10+
}),
11+
out = select({
12+
"@bazel_tools//src/conditions:host_windows": "mkdir_and_run.cmd",
13+
"//conditions:default": "mkdir_and_run.sh",
14+
}),
615
visibility = ["//visibility:public"],
716
)
817

tools/mkdir_and_run/mkdir_and_run.cmd

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
@echo off
3+
4+
setlocal
5+
6+
set argc=0
7+
FOR %%a IN (%*) DO SET /A argc+=1
8+
9+
IF %argc% LSS 2 (
10+
echo ERROR: Need at least two arguments. 1>&2
11+
exit /b 1
12+
)
13+
14+
set location=%1
15+
shift
16+
17+
set executable=%1
18+
shift
19+
20+
md %location:/=\%
21+
"%executable:/=\%" %*
22+
23+
endlocal

0 commit comments

Comments
 (0)