Skip to content

Commit

Permalink
Get reproxytool to start building on Windows
Browse files Browse the repository at this point in the history
Bug: n/a

Tested: Ran the build on windows and confirmed it works, also ensured the server works on Windows
Change-Id: Id8ad01f6f4e297e548573beb7fb43300dff202a3
GitOrigin-RevId: 03bf46b20242fe09836396dd92249f0e6623c122
  • Loading branch information
gkousik authored and copybara-github committed Jul 30, 2024
1 parent 2e412dd commit a245c37
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions cmd/reproxytool/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ go_binary(
embed = [":reproxytool_lib"],
target_compatible_with = select({
"@platforms//os:linux": [],
"@platforms//os:windows": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
visibility = ["//visibility:public"],
Expand Down
4 changes: 3 additions & 1 deletion internal/pkg/logrecordserver/logrecordserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"encoding/json"
"io/fs"
"net/http"
"path/filepath"
"sync"

"github.com/bazelbuild/reclient/internal/pkg/logger"
Expand Down Expand Up @@ -127,8 +128,9 @@ func (lr *Server) Start(listenAddr string) {
if err != nil {
log.Fatal(err)
}
basePath := filepath.Join("internal", "pkg", "logrecordserver", "ui", "app", "dist", "reproxyui", "browser")
log.V(1).Infof("Loaded JS app from embedded tar file (size=%v)", len(tarAngularApp))
indexFS, _ := fs.Sub(tarfs, "internal/pkg/logrecordserver/ui/app/dist/reproxyui/browser")
indexFS, _ := fs.Sub(tarfs, basePath)
fs := http.FileServer(http.FS(indexFS))
r.PathPrefix("/").Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fs.ServeHTTP(w, r)
Expand Down
1 change: 1 addition & 0 deletions internal/pkg/logrecordserver/ui/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ genrule(
exec_properties = {"dockerNetwork": "standard"},
target_compatible_with = select({
"@platforms//os:linux": [],
"@platforms//os:windows": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
toolchains = ["@nodejs_toolchains//:resolved_toolchain"],
Expand Down
6 changes: 6 additions & 0 deletions internal/pkg/tarfs/tarfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
"io/fs"
"os"
"path/filepath"
"runtime"
"strings"
"time"

log "github.com/golang/glog"
Expand All @@ -41,10 +43,14 @@ type TarFS struct {

// Open creates a new open file.
func (t *TarFS) Open(name string) (fs.File, error) {
if runtime.GOOS == "windows" {
name = strings.ReplaceAll(name, "/", "\\")
}
log.V(3).Infof("TarFS.Open: %s", name)
if f, ok := t.tarContents[name]; ok {
return f.NewOpenFile(), nil
}
log.V(3).Infof("TarFS.Open: failed to find %v, tar=%v", name, t.tarContents)
return nil, fs.ErrNotExist
}

Expand Down

0 comments on commit a245c37

Please sign in to comment.