bool rebuildall = 0;
static bool shouldbuild(char*, char*);
-static void copy(char*, char*);
+static void copy(char*, char*, int);
static char *findgoversion(void);
// The known architecture letters.
bwriteb(&b, &bmore);
// Cache version.
- writefile(&b, bstr(&path));
+ writefile(&b, bstr(&path), 0);
done:
p = btake(&b);
// For misc/prof, copy into the tool directory and we're done.
if(hasprefix(dir, "misc/")) {
copy(bpathf(&b, "%s/%s", tooldir, name),
- bpathf(&b1, "%s/misc/%s", goroot, name));
+ bpathf(&b1, "%s/misc/%s", goroot, name), 1);
goto out;
}
// For package runtime, copy some files into the work space.
if(streq(dir, "pkg/runtime")) {
copy(bpathf(&b, "%s/arch_GOARCH.h", workdir),
- bpathf(&b1, "%s/arch_%s.h", bstr(&path), goarch));
+ bpathf(&b1, "%s/arch_%s.h", bstr(&path), goarch), 0);
copy(bpathf(&b, "%s/defs_GOOS_GOARCH.h", workdir),
- bpathf(&b1, "%s/defs_%s_%s.h", bstr(&path), goos, goarch));
+ bpathf(&b1, "%s/defs_%s_%s.h", bstr(&path), goos, goarch), 0);
copy(bpathf(&b, "%s/os_GOOS.h", workdir),
- bpathf(&b1, "%s/os_%s.h", bstr(&path), goos));
+ bpathf(&b1, "%s/os_%s.h", bstr(&path), goos), 0);
copy(bpathf(&b, "%s/signals_GOOS.h", workdir),
- bpathf(&b1, "%s/signals_%s.h", bstr(&path), goos));
+ bpathf(&b1, "%s/signals_%s.h", bstr(&path), goos), 0);
}
// Generate any missing files; regenerate existing ones.
// This one is generated.
if(streq(dir, "pkg/runtime")) {
copy(bpathf(&b, "%s/zasm_GOOS_GOARCH.h", workdir),
- bpathf(&b1, "%s/zasm_%s_%s.h", bstr(&path), goos, goarch));
+ bpathf(&b1, "%s/zasm_%s_%s.h", bstr(&path), goos, goarch), 0);
}
// Generate .c files from .goc files.
// for use by cgo compilation.
if(streq(dir, "pkg/runtime")) {
copy(bpathf(&b, "%s/pkg/%s_%s/cgocall.h", goroot, goos, goarch),
- bpathf(&b1, "%s/src/pkg/runtime/cgocall.h", goroot));
+ bpathf(&b1, "%s/src/pkg/runtime/cgocall.h", goroot), 0);
copy(bpathf(&b, "%s/pkg/%s_%s/runtime.h", goroot, goos, goarch),
- bpathf(&b1, "%s/src/pkg/runtime/runtime.h", goroot));
+ bpathf(&b1, "%s/src/pkg/runtime/runtime.h", goroot), 0);
}
// copy copies the file src to dst, via memory (so only good for small files).
static void
-copy(char *dst, char *src)
+copy(char *dst, char *src, int exec)
{
Buf b;
binit(&b);
readfile(&b, src);
- writefile(&b, dst);
+ writefile(&b, dst, exec);
bfree(&b);
}
"const defaultGoroot = `%s`\n"
"const theVersion = `%s`\n", goroot_final, goversion));
- writefile(&out, file);
+ writefile(&out, file, 0);
bfree(&b);
bfree(&out);
"\n"
"const theGoarch = `%s`\n", goarch));
- writefile(&out, file);
+ writefile(&out, file, 0);
bfree(&b);
bfree(&out);
"\n"
"const theGoos = `%s`\n", goos));
- writefile(&out, file);
+ writefile(&out, file, 0);
bfree(&b);
bfree(&out);
}
// Write both to file and to workdir/zasm_GOOS_GOARCH.h.
- writefile(&out, file);
- writefile(&out, bprintf(&b, "%s/zasm_GOOS_GOARCH.h", workdir));
+ writefile(&out, file, 0);
+ writefile(&out, bprintf(&b, "%s/zasm_GOOS_GOARCH.h", workdir), 0);
bfree(&in);
bfree(&b);
bwritestr(&out, p);
}
- writefile(&out, file);
+ writefile(&out, file, 0);
bfree(&in);
bfree(&b);