Commit 19dc7bb1 authored by Shenghou Ma's avatar Shenghou Ma

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 #3100.

R=alex.brainman
CC=golang-dev
https://golang.org/cl/6637061
parent e171b97e
...@@ -150,3 +150,4 @@ int xstrlen(char*); ...@@ -150,3 +150,4 @@ int xstrlen(char*);
char* xstrrchr(char*, int); char* xstrrchr(char*, int);
char* xstrstr(char*, char*); char* xstrstr(char*, char*);
char* xworkdir(void); char* xworkdir(void);
int xsamefile(char*, char*);
...@@ -1564,7 +1564,7 @@ cmdbanner(int argc, char **argv) ...@@ -1564,7 +1564,7 @@ cmdbanner(int argc, char **argv)
"Read and run ./sudo.bash to install the debuggers.\n"); "Read and run ./sudo.bash to install the debuggers.\n");
} }
if(!streq(goroot_final, goroot)) { if(!xsamefile(goroot_final, goroot)) {
xprintf("\n" xprintf("\n"
"The binaries expect %s to be copied or moved to %s\n", "The binaries expect %s to be copied or moved to %s\n",
goroot, goroot_final); goroot, goroot_final);
......
...@@ -742,4 +742,11 @@ xstrrchr(char *p, int c) ...@@ -742,4 +742,11 @@ xstrrchr(char *p, int c)
return strrchr(p, 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 // PLAN9
...@@ -727,5 +727,12 @@ xstrrchr(char *p, int c) ...@@ -727,5 +727,12 @@ xstrrchr(char *p, int c)
return strrchr(p, 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 // PLAN9
#endif // __WINDOWS__ #endif // __WINDOWS__
...@@ -925,4 +925,41 @@ xstrrchr(char *p, int c) ...@@ -925,4 +925,41 @@ xstrrchr(char *p, int c)
return nil; 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__ #endif // __WINDOWS__
...@@ -68,6 +68,9 @@ call env.bat ...@@ -68,6 +68,9 @@ call env.bat
del env.bat del env.bat
echo. echo.
if x%1==x--dist-tool goto copydist
if x%2==x--dist-tool goto copydist
echo # Building compilers and Go bootstrap tool. echo # Building compilers and Go bootstrap tool.
set buildall=-a set buildall=-a
if x%1==x--no-clean set buildall= if x%1==x--no-clean set buildall=
...@@ -105,6 +108,11 @@ if x%1==x--no-banner goto nobanner ...@@ -105,6 +108,11 @@ if x%1==x--no-banner goto nobanner
goto end goto end
:copydist
mkdir %GOTOOLDIR% 2>NUL
copy cmd\dist\dist.exe %GOTOOLDIR%\
goto end
:fail :fail
set GOBUILDFAIL=1 set GOBUILDFAIL=1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment