summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShenghou Ma <minux.ma@gmail.com>2012-10-12 13:35:05 +0800
committerShenghou Ma <minux.ma@gmail.com>2012-10-12 13:35:05 +0800
commit2c0ab741816f057191641898f20fd91170e6850d (patch)
treefbb0ea8b1d7cfd2498d74155d207f5f2fd4d23a1 /src
parentd79bccf5ed95302fb3216d779df489eed578d6b6 (diff)
downloadgo-2c0ab741816f057191641898f20fd91170e6850d.tar.gz
cmd/dist: fix superfluous and confusing "binaries ... to be copied or moved" message
Also, to aid debugging cmd/dist, make make.bat support --dist-tool flag. Fixes issue 3100. R=alex.brainman CC=golang-dev http://codereview.appspot.com/6637061
Diffstat (limited to 'src')
-rw-r--r--src/cmd/dist/a.h1
-rw-r--r--src/cmd/dist/build.c2
-rw-r--r--src/cmd/dist/plan9.c7
-rw-r--r--src/cmd/dist/unix.c7
-rw-r--r--src/cmd/dist/windows.c37
-rw-r--r--src/make.bat8
6 files changed, 61 insertions, 1 deletions
diff --git a/src/cmd/dist/a.h b/src/cmd/dist/a.h
index b108572c0..ace2ff60a 100644
--- a/src/cmd/dist/a.h
+++ b/src/cmd/dist/a.h
@@ -150,3 +150,4 @@ int xstrlen(char*);
char* xstrrchr(char*, int);
char* xstrstr(char*, char*);
char* xworkdir(void);
+int xsamefile(char*, char*);
diff --git a/src/cmd/dist/build.c b/src/cmd/dist/build.c
index 8c813006e..74100595c 100644
--- a/src/cmd/dist/build.c
+++ b/src/cmd/dist/build.c
@@ -1564,7 +1564,7 @@ cmdbanner(int argc, char **argv)
"Read and run ./sudo.bash to install the debuggers.\n");
}
- if(!streq(goroot_final, goroot)) {
+ if(!xsamefile(goroot_final, goroot)) {
xprintf("\n"
"The binaries expect %s to be copied or moved to %s\n",
goroot, goroot_final);
diff --git a/src/cmd/dist/plan9.c b/src/cmd/dist/plan9.c
index 8bbff1d24..7482d970a 100644
--- a/src/cmd/dist/plan9.c
+++ b/src/cmd/dist/plan9.c
@@ -742,4 +742,11 @@ xstrrchr(char *p, int c)
return strrchr(p, c);
}
+// xsamefile returns whether f1 and f2 are the same file (or dir)
+int
+xsamefile(char *f1, char *f2)
+{
+ return streq(f1, f2); // suffice for now
+}
+
#endif // PLAN9
diff --git a/src/cmd/dist/unix.c b/src/cmd/dist/unix.c
index e38d5bcc0..ff6355612 100644
--- a/src/cmd/dist/unix.c
+++ b/src/cmd/dist/unix.c
@@ -727,5 +727,12 @@ xstrrchr(char *p, int c)
return strrchr(p, c);
}
+// xsamefile returns whether f1 and f2 are the same file (or dir)
+int
+xsamefile(char *f1, char *f2)
+{
+ return streq(f1, f2); // suffice for now
+}
+
#endif // PLAN9
#endif // __WINDOWS__
diff --git a/src/cmd/dist/windows.c b/src/cmd/dist/windows.c
index 90310cd28..5fa963491 100644
--- a/src/cmd/dist/windows.c
+++ b/src/cmd/dist/windows.c
@@ -925,4 +925,41 @@ xstrrchr(char *p, int c)
return nil;
}
+// xsamefile returns whether f1 and f2 are the same file (or dir)
+int
+xsamefile(char *f1, char *f2)
+{
+ Rune *ru;
+ HANDLE fd1, fd2;
+ BY_HANDLE_FILE_INFORMATION fi1, fi2;
+ int r;
+
+ // trivial case
+ if(streq(f1, f2))
+ return 1;
+
+ torune(&ru, f1);
+ // refer to ../../pkg/os/stat_windows.go:/sameFile
+ fd1 = CreateFileW(ru, 0, 0, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
+ xfree(ru);
+ if(fd1 == INVALID_HANDLE_VALUE)
+ return 0;
+ torune(&ru, f2);
+ fd2 = CreateFileW(ru, 0, 0, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
+ xfree(ru);
+ if(fd2 == INVALID_HANDLE_VALUE) {
+ CloseHandle(fd1);
+ return 0;
+ }
+ r = GetFileInformationByHandle(fd1, &fi1) != 0 && GetFileInformationByHandle(fd2, &fi2) != 0;
+ CloseHandle(fd2);
+ CloseHandle(fd1);
+ if(r != 0 &&
+ fi1.dwVolumeSerialNumber == fi2.dwVolumeSerialNumber &&
+ fi1.nFileIndexHigh == fi2.nFileIndexHigh &&
+ fi1.nFileIndexLow == fi2.nFileIndexLow)
+ return 1;
+ return 0;
+}
+
#endif // __WINDOWS__
diff --git a/src/make.bat b/src/make.bat
index ec39392dd..01c2dc457 100644
--- a/src/make.bat
+++ b/src/make.bat
@@ -68,6 +68,9 @@ call env.bat
del env.bat
echo.
+if x%1==x--dist-tool goto copydist
+if x%2==x--dist-tool goto copydist
+
echo # Building compilers and Go bootstrap tool.
set buildall=-a
if x%1==x--no-clean set buildall=
@@ -105,6 +108,11 @@ if x%1==x--no-banner goto nobanner
goto end
+:copydist
+mkdir %GOTOOLDIR% 2>NUL
+copy cmd\dist\dist.exe %GOTOOLDIR%\
+goto end
+
:fail
set GOBUILDFAIL=1