diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-05-05 15:40:10 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-05-05 15:40:10 +0200 |
| commit | 31ea20ce83aa7ca21b4d0ef28d8375a058292a5a (patch) | |
| tree | 4df7407aa0bca0fd4caeb65808e899f0c6558e21 /sys/syz-sysgen | |
| parent | 08a0ef9cb0622002a2f9b0aabeab678bee4e0dbf (diff) | |
sys: move generate files to separate packages
Move generated files to gen subdir. This allows to:
1. Rebuild init.go without rebuilding generated code.
2. Excluding generated files from gometalinter checking.
This makes faster and consume less memory.
Update #538
Diffstat (limited to 'sys/syz-sysgen')
| -rw-r--r-- | sys/syz-sysgen/sysgen.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/sys/syz-sysgen/sysgen.go b/sys/syz-sysgen/sysgen.go index 154d6ef9a..cef35ba05 100644 --- a/sys/syz-sysgen/sysgen.go +++ b/sys/syz-sysgen/sysgen.go @@ -22,6 +22,7 @@ import ( "github.com/google/syzkaller/pkg/ast" "github.com/google/syzkaller/pkg/compiler" "github.com/google/syzkaller/pkg/hash" + "github.com/google/syzkaller/pkg/osutil" "github.com/google/syzkaller/pkg/serializer" "github.com/google/syzkaller/prog" "github.com/google/syzkaller/sys/targets" @@ -39,6 +40,7 @@ func main() { if top == nil { os.Exit(1) } + osutil.MkdirAll(filepath.Join("sys", OS, "gen")) type Job struct { Target *targets.Target @@ -76,7 +78,7 @@ func main() { } job.Unsupported = prog.Unsupported - sysFile := filepath.Join("sys", OS, job.Target.Arch+".go") + sysFile := filepath.Join("sys", OS, "gen", job.Target.Arch+".go") out := new(bytes.Buffer) generate(job.Target, prog, consts, out) rev := hash.String(out.Bytes()) @@ -130,18 +132,16 @@ func main() { func generate(target *targets.Target, prg *compiler.Prog, consts map[string]uint64, out io.Writer) { fmt.Fprintf(out, "// AUTOGENERATED FILE\n\n") - fmt.Fprintf(out, "package %v\n\n", target.OS) + fmt.Fprintf(out, "package gen\n\n") fmt.Fprintf(out, "import . \"github.com/google/syzkaller/prog\"\n\n") - fmt.Fprintf(out, "func init() {\n") - fmt.Fprintf(out, "\tRegisterTarget(&Target{OS: %q, Arch: %q, Revision: revision_%v, PtrSize: %v, "+ + fmt.Fprintf(out, "var Target_%v = &Target{"+ + "OS: %q, Arch: %q, Revision: revision_%v, PtrSize: %v, "+ "PageSize: %v, NumPages: %v, DataOffset: %v, Syscalls: syscalls_%v, "+ - "Resources: resources_%v, Structs: structDescs_%v, Consts: consts_%v}, "+ - "initTarget)\n", - target.OS, target.Arch, target.Arch, target.PtrSize, + "Resources: resources_%v, Structs: structDescs_%v, Consts: consts_%v}\n\n", + target.Arch, target.OS, target.Arch, target.Arch, target.PtrSize, target.PageSize, target.NumPages, target.DataOffset, target.Arch, target.Arch, target.Arch, target.Arch) - fmt.Fprintf(out, "}\n\n") fmt.Fprintf(out, "var resources_%v = ", target.Arch) serializer.Write(out, prg.Resources) |
