]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/dist: fix GOROOT_FINAL
authorGustavo Niemeyer <gustavo@niemeyer.net>
Thu, 9 Feb 2012 22:47:12 +0000 (20:47 -0200)
committerGustavo Niemeyer <gustavo@niemeyer.net>
Thu, 9 Feb 2012 22:47:12 +0000 (20:47 -0200)
R=rsc, gustavo
CC=golang-dev
https://golang.org/cl/5642045

src/cmd/dist/a.h
src/cmd/dist/build.c
src/cmd/dist/buildruntime.c
src/make.bash
src/make.bat

index 39048e37d710380bc14efa6c2ba38db9ae603c55..e90f7fe65d8008634aa250af371ccab1d5346e97 100644 (file)
@@ -62,7 +62,6 @@ void  splitlines(Vec*, char*);
 void   splitfields(Vec*, char*);
 
 // build.c
-extern char *default_goroot;
 extern char *goarch;
 extern char *gobin;
 extern char *gochar;
@@ -70,6 +69,7 @@ extern char *gohostarch;
 extern char *gohostos;
 extern char *goos;
 extern char *goroot;
+extern char *goroot_final;
 extern char *goversion;
 extern char *workdir;
 extern char *slash;
index c84a7ec7f6a28a54a2e2dea389e05fe3d8297c86..1067ce16e8aad173a327d7f0ecfaa0041340e3e3 100644 (file)
@@ -15,13 +15,12 @@ char *gobin;
 char *gohostarch;
 char *gohostos;
 char *goos;
-char *goroot;
+char *goroot = GOROOT_FINAL;
+char *goroot_final = GOROOT_FINAL;
 char *workdir;
 char *gochar;
-char *goroot_final;
 char *goversion;
 char *slash;   // / for unix, \ for windows
-char *default_goroot = DEFAULT_GOROOT;
 
 static bool shouldbuild(char*, char*);
 static void copy(char*, char*);
@@ -74,12 +73,8 @@ init(void)
        binit(&b);
 
        xgetenv(&b, "GOROOT");
-       if(b.len == 0) {
-               if(default_goroot == nil)
-                       fatal("$GOROOT not set and not available");
-               bwritestr(&b, default_goroot);
-       }
-       goroot = btake(&b);
+       if(b.len > 0)
+               goroot = btake(&b);
 
        xgetenv(&b, "GOBIN");
        if(b.len == 0)
@@ -116,12 +111,6 @@ init(void)
        bprintf(&b, "%c", gochars[i]);
        gochar = btake(&b);
 
-       xgetenv(&b, "GOROOT_FINAL");
-       if(b.len > 0)
-               goroot_final = btake(&b);
-       else
-               goroot_final = goroot;
-       
        xsetenv("GOROOT", goroot);
        xsetenv("GOARCH", goarch);
        xsetenv("GOOS", goos);
@@ -777,7 +766,7 @@ install(char *dir)
                        if(streq(name, "goos.c")) {
                                vadd(&compile, bprintf(&b, "-DGOOS=\"%s\"", goos));
                                vadd(&compile, bprintf(&b, "-DGOARCH=\"%s\"", goarch));
-                               bprintf(&b1, "%s", goroot);
+                               bprintf(&b1, "%s", goroot_final);
                                bsubst(&b1, "\\", "\\\\");  // turn into C string
                                vadd(&compile, bprintf(&b, "-DGOROOT=\"%s\"", bstr(&b1)));
                                vadd(&compile, bprintf(&b, "-DGOVERSION=\"%s\"", goversion));
index 7cbff3fb87c1be324914138d9347fee3460987d7..dfecc2be0d6252e5ac9ea84c4b324d84a7e72d71 100644 (file)
@@ -29,7 +29,7 @@ mkzversion(char *dir, char *file)
                "package runtime\n"
                "\n"
                "const defaultGoroot = `%s`\n"
-               "const theVersion = `%s`\n", goroot, goversion));
+               "const theVersion = `%s`\n", goroot_final, goversion));
 
        writefile(&out, file);
        
index 32a91a2fc9d6fcb5fa5a23d4a0c452cb3fd65954..55a292eba42886ad4fae318a61a99bfd83d35e37 100755 (executable)
@@ -47,7 +47,9 @@ done
 
 echo '# Building C bootstrap tool.'
 mkdir -p ../bin/tool
-DEFGOROOT='-DDEFAULT_GOROOT="'"$(cd .. && pwd)"'"'
+export GOROOT="$(cd .. && pwd)"
+GOROOT_FINAL="${GOROOT_FINAL:-$GOROOT}"
+DEFGOROOT='-DGOROOT_FINAL="'"$GOROOT_FINAL"'"'
 gcc -O2 -Wall -Werror -o ../bin/tool/dist -Icmd/dist "$DEFGOROOT" cmd/dist/*.c
 echo
 
index 34f43615069336f4534c382103bd397cb34b1d4e..804c35ad048e9351bf83a16eee2d01fe51b82e51 100644 (file)
@@ -10,14 +10,16 @@ echo Must run make.bat from Go src directory.
 goto fail 
 :ok
 
-:: Grab default $GOROOT, escape \ for C string.
-:: The expression %CD:\=\\% means to take %CD%
+:: Grab default GOROOT_FINAL and set GOROOT for build.
+:: The expression %VAR:\=\\% means to take %VAR%
 :: and apply the substitution \ = \\, escaping the
 :: backslashes.  Then we wrap that in quotes to create
 :: a C string.
 cd ..
-set DEFGOROOT=-DDEFAULT_GOROOT="\"%CD:\=\\%\""
+set GOROOT="%CD%"
 cd src
+if "x%GOROOT_FINAL%"=="x" set GOROOT_FINAL="%GOROOT%"
+set DEFGOROOT=-DGOROOT_FINAL="\"%GOROOT_FINAL:\=\\%\""
 
 echo # Building C bootstrap tool.
 if not exist ..\bin\tool mkdir ..\bin\tool
@@ -40,7 +42,7 @@ if errorlevel 1 goto fail
 del ..\bin\tool\go_bootstrap.exe
 echo .
 
-if x%1==x--no-banner goto nobanner
+if "x%1"=="x--no-banner" goto nobanner
 ..\bin\tool\dist banner
 :nobanner