diff --git a/build.pl b/build.pl index 43a7f8bc5..da0d633fc 100755 --- a/build.pl +++ b/build.pl @@ -359,6 +359,19 @@ sub build { v("Built '$target'"); } +sub filter_go_os { + my @good; + my $is_windows = $^O eq "msys" || $^O eq "MSWin32"; + foreach my $f (@_) { + my $for_unix = $f =~ /_unix\.go$/; + my $for_windows = $f =~ /_windows\.go$/; + next if $for_unix && $is_windows; + next if $for_windows && !$is_windows; + push @good, $f; + } + return @good; +} + sub find_go_camli_deps { my $target = shift; if ($target =~ /\bthird_party\b/) { @@ -375,6 +388,7 @@ sub find_go_camli_deps { my $target_dir = dir($target); opendir(my $dh, $target_dir) or die "Failed to open directory: $target\n"; my @go_files = grep { !m!^\.\#! } grep { !/_testmain\.go$/ } grep { /\.go$/ } readdir($dh); + @go_files = filter_go_os(@go_files); closedir($dh); # TODO: just stat the files first and keep a cache file of the @@ -439,6 +453,7 @@ sub gen_target_makefile { opendir(my $dh, $target_dir) or die; my @dir_files = readdir($dh); my @go_files = grep { !m!^\.\#! } grep { !/_testmain\.go$/ } grep { /\.go$/ } @dir_files; + @go_files = filter_go_os(@go_files); closedir($dh); if ($t->{tags}{fileembed}) { diff --git a/lib/go/camli/webserver/envpipe_unix.go b/lib/go/camli/webserver/envpipe_unix.go new file mode 100644 index 000000000..cba422314 --- /dev/null +++ b/lib/go/camli/webserver/envpipe_unix.go @@ -0,0 +1,36 @@ +/* +Copyright 2011 Google Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package webserver + +import ( + "fmt" + "log" + "os" + "strconv" +) + +func pipeFromEnvFd(env string) (*os.File, os.Error) { + fdStr := os.Getenv(env) + if fdStr == "" { + return nil, fmt.Errorf("Environment variable %q was blank", env) + } + fd, err := strconv.Atoi(fdStr) + if err != nil { + log.Fatalf("Bogus test harness fd '%s': %v", fdStr, err) + } + return os.NewFile(fd, "testingpipe-"+env), nil +} diff --git a/lib/go/camli/webserver/envpipe_windows.go b/lib/go/camli/webserver/envpipe_windows.go new file mode 100644 index 000000000..f44da5942 --- /dev/null +++ b/lib/go/camli/webserver/envpipe_windows.go @@ -0,0 +1,25 @@ +/* +Copyright 2011 Google Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package webserver + +import ( + "os" +) + +func pipeFromEnvFd(env string) (*os.File, os.Error) { + return nil, os.NewError("not implemented") +} diff --git a/lib/go/camli/webserver/webserver.go b/lib/go/camli/webserver/webserver.go index a4c78b263..646d6830f 100644 --- a/lib/go/camli/webserver/webserver.go +++ b/lib/go/camli/webserver/webserver.go @@ -25,7 +25,6 @@ import ( "log" "net" "os" - "strconv" "strings" "time" ) @@ -135,24 +134,16 @@ func (s *Server) Serve() { } -func pipeFromEnvFd(env string) *os.File { - fdStr := os.Getenv(env) - if fdStr == "" { - return nil - } - fd, err := strconv.Atoi(fdStr) - if err != nil { - log.Fatalf("Bogus test harness fd '%s': %v", fdStr, err) - } - return os.NewFile(fd, "testingpipe-"+env) -} // Signals the test harness that we've started listening. // TODO: write back the port number that we randomly selected? // For now just writes back a single byte. func runTestHarnessIntegration(listener net.Listener) { - writePipe := pipeFromEnvFd("TESTING_PORT_WRITE_FD") - readPipe := pipeFromEnvFd("TESTING_CONTROL_READ_FD") + writePipe, err := pipeFromEnvFd("TESTING_PORT_WRITE_FD") + if err != nil { + return + } + readPipe, _ := pipeFromEnvFd("TESTING_CONTROL_READ_FD") if writePipe != nil { writePipe.Write([]byte(listener.Addr().String() + "\n"))