• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2017 The Wuffs Authors.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//    https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15// wuffs-c handles the C language specific parts of the wuffs tool.
16package main
17
18import (
19	"fmt"
20	"os"
21
22	"github.com/google/wuffs/internal/cgen"
23)
24
25func main() {
26	if err := main1(); err != nil {
27		os.Stderr.WriteString(err.Error() + "\n")
28		os.Exit(1)
29	}
30}
31
32func main1() error {
33	if len(os.Args) < 2 {
34		return fmt.Errorf("no sub-command given")
35	}
36	args := os.Args[2:]
37	switch os.Args[1] {
38	case "bench":
39		return doBench(args)
40	case "gen":
41		return cgen.Do(args)
42	case "genlib":
43		return doGenlib(args)
44	case "genrelease":
45		return doGenrelease(args)
46	case "test":
47		return doTest(args)
48	}
49	return fmt.Errorf("bad sub-command %q", os.Args[1])
50}
51