From eda3130628edf4ce697c7cb46f9e0d68581ac041 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Thu, 30 Nov 2017 16:43:39 +1100 Subject: [PATCH] Rename PUFFS to WUFFS, part 6 of N --- cmd/wuffs/gen.go | 42 +++++++++++++++++++++--------------------- cmd/wuffs/main.go | 26 +++++++++++++------------- cmd/wuffs/test.go | 20 ++++++++++---------- gen/c/std/flate.c | 6 +++--- gen/c/std/gif.c | 6 +++--- gen/h/std/flate.h | 4 ++-- gen/h/std/gif.h | 4 ++-- 7 files changed, 54 insertions(+), 54 deletions(-) diff --git a/cmd/wuffs/gen.go b/cmd/wuffs/gen.go index cbd9708e..45c93604 100644 --- a/cmd/wuffs/gen.go +++ b/cmd/wuffs/gen.go @@ -26,10 +26,10 @@ import ( "strings" ) -func doGen(puffsRoot string, args []string) error { return doGenGenlib(puffsRoot, args, false) } -func doGenlib(puffsRoot string, args []string) error { return doGenGenlib(puffsRoot, args, true) } +func doGen(wuffsRoot string, args []string) error { return doGenGenlib(wuffsRoot, args, false) } +func doGenlib(wuffsRoot string, args []string) error { return doGenGenlib(wuffsRoot, args, true) } -func doGenGenlib(puffsRoot string, args []string, genlib bool) error { +func doGenGenlib(wuffsRoot string, args []string, genlib bool) error { flags := flag.NewFlagSet("gen", flag.ExitOnError) langsFlag := flags.String("langs", langsDefault, langsUsage) if err := flags.Parse(args); err != nil { @@ -51,27 +51,27 @@ func doGenGenlib(puffsRoot string, args []string, genlib bool) error { arg = arg[:len(arg)-4] } var err error - affected, err = gen(affected, puffsRoot, arg, langs, recursive) + affected, err = gen(affected, wuffsRoot, arg, langs, recursive) if err != nil { return err } } if genlib { - if err := genlibAffected(puffsRoot, langs, affected); err != nil { + if err := genlibAffected(wuffsRoot, langs, affected); err != nil { return err } } return nil } -func gen(affected []string, puffsRoot, dirname string, langs []string, recursive bool) (retAffected []string, retErr error) { - filenames, dirnames, err := listDir(puffsRoot, dirname, recursive) +func gen(affected []string, wuffsRoot, dirname string, langs []string, recursive bool) (retAffected []string, retErr error) { + filenames, dirnames, err := listDir(wuffsRoot, dirname, recursive) if err != nil { return nil, err } if len(filenames) > 0 { - if err := genDir(puffsRoot, dirname, filenames, langs); err != nil { + if err := genDir(wuffsRoot, dirname, filenames, langs); err != nil { return nil, err } affected = append(affected, dirname) @@ -79,7 +79,7 @@ func gen(affected []string, puffsRoot, dirname string, langs []string, recursive if len(dirnames) > 0 { for _, d := range dirnames { var err error - affected, err = gen(affected, puffsRoot, dirname+"/"+d, langs, recursive) + affected, err = gen(affected, wuffsRoot, dirname+"/"+d, langs, recursive) if err != nil { return nil, err } @@ -88,9 +88,9 @@ func gen(affected []string, puffsRoot, dirname string, langs []string, recursive return affected, nil } -func genDir(puffsRoot string, dirname string, filenames []string, langs []string) error { +func genDir(wuffsRoot string, dirname string, filenames []string, langs []string) error { // TODO: skip the generation if the output file already exists and its - // mtime is newer than all inputs and the puffs-gen-foo command. + // mtime is newer than all inputs and the wuffs-gen-foo command. packageName := path.Base(dirname) if !validName(packageName) { @@ -99,11 +99,11 @@ func genDir(puffsRoot string, dirname string, filenames []string, langs []string cmdArgs := []string{"gen", "-package_name", packageName} for _, filename := range filenames { cmdArgs = append(cmdArgs, - filepath.Join(puffsRoot, filepath.FromSlash(dirname), filename)) + filepath.Join(wuffsRoot, filepath.FromSlash(dirname), filename)) } for _, lang := range langs { - command := "puffs-" + lang + command := "wuffs-" + lang stdout := &bytes.Buffer{} cmd := exec.Command(command, cmdArgs...) cmd.Stdin = nil @@ -117,7 +117,7 @@ func genDir(puffsRoot string, dirname string, filenames []string, langs []string return err } out := stdout.Bytes() - if err := genFile(puffsRoot, dirname, lang, out); err != nil { + if err := genFile(wuffsRoot, dirname, lang, out); err != nil { return err } @@ -130,7 +130,7 @@ func genDir(puffsRoot string, dirname string, filenames []string, langs []string } else { out = out[:i] } - if err := genFile(puffsRoot, dirname, "h", out); err != nil { + if err := genFile(wuffsRoot, dirname, "h", out); err != nil { return err } } @@ -139,8 +139,8 @@ func genDir(puffsRoot string, dirname string, filenames []string, langs []string var cHeaderEndsHere = []byte("\n// C HEADER ENDS HERE.\n\n") -func genFile(puffsRoot string, dirname string, lang string, out []byte) error { - outFilename := filepath.Join(puffsRoot, "gen", lang, filepath.FromSlash(dirname)+"."+lang) +func genFile(wuffsRoot string, dirname string, lang string, out []byte) error { + outFilename := filepath.Join(wuffsRoot, "gen", lang, filepath.FromSlash(dirname)+"."+lang) if existing, err := ioutil.ReadFile(outFilename); err == nil && bytes.Equal(existing, out) { fmt.Println("gen unchanged: ", outFilename) return nil @@ -155,12 +155,12 @@ func genFile(puffsRoot string, dirname string, lang string, out []byte) error { return nil } -func genlibAffected(puffsRoot string, langs []string, affected []string) error { +func genlibAffected(wuffsRoot string, langs []string, affected []string) error { for _, lang := range langs { - command := "puffs-" + lang + command := "wuffs-" + lang args := []string{"genlib"} - args = append(args, "-dstdir", filepath.Join(puffsRoot, "gen", "lib", lang)) - args = append(args, "-srcdir", filepath.Join(puffsRoot, "gen", lang)) + args = append(args, "-dstdir", filepath.Join(wuffsRoot, "gen", "lib", lang)) + args = append(args, "-srcdir", filepath.Join(wuffsRoot, "gen", lang)) args = append(args, affected...) cmd := exec.Command(command, args...) cmd.Stdout = os.Stdout diff --git a/cmd/wuffs/main.go b/cmd/wuffs/main.go index 2e05446f..9aa1d000 100644 --- a/cmd/wuffs/main.go +++ b/cmd/wuffs/main.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// puffs is a tool for managing Puffs source code. +// wuffs is a tool for managing Wuffs source code. package main import ( @@ -28,7 +28,7 @@ import ( var commands = []struct { name string - do func(puffsRoot string, args []string) error + do func(wuffsRoot string, args []string) error }{ {"bench", doBench}, {"gen", doGen}, @@ -37,11 +37,11 @@ var commands = []struct { } func usage() { - fmt.Fprintf(os.Stderr, `Puffs is a tool for managing Puffs source code. + fmt.Fprintf(os.Stderr, `Wuffs is a tool for managing Wuffs source code. Usage: - puffs command [arguments] + wuffs command [arguments] The commands are: @@ -63,14 +63,14 @@ func main1() error { flag.Usage = usage flag.Parse() - puffsRoot, err := findPuffsRoot() + wuffsRoot, err := findWuffsRoot() if err != nil { return err } if args := flag.Args(); len(args) > 0 { for _, c := range commands { if args[0] == c.name { - return c.do(puffsRoot, args[1:]) + return c.do(wuffsRoot, args[1:]) } } } @@ -79,19 +79,19 @@ func main1() error { return nil } -func findPuffsRoot() (string, error) { - // TODO: look for a PUFFSROOT environment variable? +func findWuffsRoot() (string, error) { + // TODO: look for a WUFFSROOT environment variable? for _, p := range filepath.SplitList(build.Default.GOPATH) { - p = filepath.Join(p, "src", "github.com", "google", "puffs") + p = filepath.Join(p, "src", "github.com", "google", "wuffs") if o, err := os.Stat(p); err == nil && o.IsDir() { return p, nil } } - return "", errors.New("could not find Puffs root directory") + return "", errors.New("could not find Wuffs root directory") } -func listDir(puffsRoot string, dirname string, returnSubdirs bool) (filenames []string, dirnames []string, err error) { - f, err := os.Open(filepath.Join(puffsRoot, filepath.FromSlash(dirname))) +func listDir(wuffsRoot string, dirname string, returnSubdirs bool) (filenames []string, dirnames []string, err error) { + f, err := os.Open(filepath.Join(wuffsRoot, filepath.FromSlash(dirname))) if err != nil { return nil, nil, err } @@ -107,7 +107,7 @@ func listDir(puffsRoot string, dirname string, returnSubdirs bool) (filenames [] if returnSubdirs { dirnames = append(dirnames, name) } - } else if strings.HasSuffix(name, ".puffs") { + } else if strings.HasSuffix(name, ".wuffs") { filenames = append(filenames, name) } } diff --git a/cmd/wuffs/test.go b/cmd/wuffs/test.go index 41cb09c6..3c7f6a47 100644 --- a/cmd/wuffs/test.go +++ b/cmd/wuffs/test.go @@ -25,10 +25,10 @@ import ( cf "github.com/google/wuffs/cmd/commonflags" ) -func doBench(puffsRoot string, args []string) error { return doBenchTest(puffsRoot, args, true) } -func doTest(puffsRoot string, args []string) error { return doBenchTest(puffsRoot, args, false) } +func doBench(wuffsRoot string, args []string) error { return doBenchTest(wuffsRoot, args, true) } +func doTest(wuffsRoot string, args []string) error { return doBenchTest(wuffsRoot, args, false) } -func doBenchTest(puffsRoot string, args []string, bench bool) error { +func doBenchTest(wuffsRoot string, args []string, bench bool) error { flags := flag.NewFlagSet("test", flag.ExitOnError) ccompilersFlag := flags.String("ccompilers", cf.CcompilersDefault, cf.CcompilersUsage) focusFlag := flags.String("focus", cf.FocusDefault, cf.FocusUsage) @@ -74,7 +74,7 @@ func doBenchTest(puffsRoot string, args []string, bench bool) error { } b := btHelper{ - puffsRoot: puffsRoot, + wuffsRoot: wuffsRoot, langs: langs, cmdArgs: cmdArgs, ccompilers: *ccompilersFlag, @@ -89,7 +89,7 @@ func doBenchTest(puffsRoot string, args []string, bench bool) error { // Ensure that we are testing the latest version of the generated code. if !*skipgenFlag { - if _, err := gen(nil, puffsRoot, arg, langs, recursive); err != nil { + if _, err := gen(nil, wuffsRoot, arg, langs, recursive); err != nil { return err } } @@ -106,20 +106,20 @@ func doBenchTest(puffsRoot string, args []string, bench bool) error { if bench { s0, s1 = "bench", "benchmarks" } - return fmt.Errorf("puffs %s: some %s failed", s0, s1) + return fmt.Errorf("wuffs %s: some %s failed", s0, s1) } return nil } type btHelper struct { - puffsRoot string + wuffsRoot string langs []string cmdArgs []string ccompilers string } func (b *btHelper) benchTest(dirname string, recursive bool) (failed bool, err error) { - filenames, dirnames, err := listDir(b.puffsRoot, dirname, recursive) + filenames, dirnames, err := listDir(b.wuffsRoot, dirname, recursive) if err != nil { return false, err } @@ -148,13 +148,13 @@ func (b *btHelper) benchTestDir(dirname string) (failed bool, err error) { } for _, lang := range b.langs { - command := "puffs-" + lang + command := "wuffs-" + lang args := []string(nil) args = append(args, b.cmdArgs...) if lang == "c" { args = append(args, fmt.Sprintf("-ccompilers=%s", b.ccompilers)) } - args = append(args, filepath.Join(b.puffsRoot, "test", lang, filepath.FromSlash(dirname))) + args = append(args, filepath.Join(b.wuffsRoot, "test", lang, filepath.FromSlash(dirname))) cmd := exec.Command(command, args...) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr diff --git a/gen/c/std/flate.c b/gen/c/std/flate.c index e4556d48..a3203a19 100644 --- a/gen/c/std/flate.c +++ b/gen/c/std/flate.c @@ -1,12 +1,12 @@ #ifndef PUFFS_FLATE_H #define PUFFS_FLATE_H -// Code generated by puffs-c. DO NOT EDIT. +// Code generated by wuffs-c. DO NOT EDIT. #ifndef PUFFS_BASE_HEADER_H #define PUFFS_BASE_HEADER_H -// Copyright 2017 The Puffs Authors. +// Copyright 2017 The Wuffs Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -342,7 +342,7 @@ puffs_flate__status puffs_flate__zlib_decoder__decode( #ifndef PUFFS_BASE_IMPL_H #define PUFFS_BASE_IMPL_H -// Copyright 2017 The Puffs Authors. +// Copyright 2017 The Wuffs Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/gen/c/std/gif.c b/gen/c/std/gif.c index 4ea136f0..33bda30c 100644 --- a/gen/c/std/gif.c +++ b/gen/c/std/gif.c @@ -1,12 +1,12 @@ #ifndef PUFFS_GIF_H #define PUFFS_GIF_H -// Code generated by puffs-c. DO NOT EDIT. +// Code generated by wuffs-c. DO NOT EDIT. #ifndef PUFFS_BASE_HEADER_H #define PUFFS_BASE_HEADER_H -// Copyright 2017 The Puffs Authors. +// Copyright 2017 The Wuffs Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -284,7 +284,7 @@ puffs_gif__status puffs_gif__lzw_decoder__decode(puffs_gif__lzw_decoder* self, #ifndef PUFFS_BASE_IMPL_H #define PUFFS_BASE_IMPL_H -// Copyright 2017 The Puffs Authors. +// Copyright 2017 The Wuffs Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/gen/h/std/flate.h b/gen/h/std/flate.h index 5ec9cb9d..85fe6599 100644 --- a/gen/h/std/flate.h +++ b/gen/h/std/flate.h @@ -1,12 +1,12 @@ #ifndef PUFFS_FLATE_H #define PUFFS_FLATE_H -// Code generated by puffs-c. DO NOT EDIT. +// Code generated by wuffs-c. DO NOT EDIT. #ifndef PUFFS_BASE_HEADER_H #define PUFFS_BASE_HEADER_H -// Copyright 2017 The Puffs Authors. +// Copyright 2017 The Wuffs Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/gen/h/std/gif.h b/gen/h/std/gif.h index 38e95865..b83f869d 100644 --- a/gen/h/std/gif.h +++ b/gen/h/std/gif.h @@ -1,12 +1,12 @@ #ifndef PUFFS_GIF_H #define PUFFS_GIF_H -// Code generated by puffs-c. DO NOT EDIT. +// Code generated by wuffs-c. DO NOT EDIT. #ifndef PUFFS_BASE_HEADER_H #define PUFFS_BASE_HEADER_H -// Copyright 2017 The Puffs Authors. +// Copyright 2017 The Wuffs Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License.