Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Side by Side Diff: mojom/generators/c/c_generator.go

Issue 2069943003: Mojom target for generating & building C bindings. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/public/tools/bindings/run_code_generators.py ('k') | mojom/generators/common/cli.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package main 5 package main
6 6
7 import ( 7 import (
8 "log" 8 "log"
9 "os" 9 "os"
10 "text/template" 10 "text/template"
11 11
12 "mojom/generators/c/cgen" 12 "mojom/generators/c/cgen"
13 "mojom/generators/c/templates" 13 "mojom/generators/c/templates"
14 "mojom/generators/common" 14 "mojom/generators/common"
15 ) 15 )
16 16
17 func main() { 17 func main() {
18 tmpls := template.New("CTemplates") 18 tmpls := template.New("CTemplates")
19 template.Must(tmpls.Parse(templates.GenerateHeaderFile)) 19 template.Must(tmpls.Parse(templates.GenerateHeaderFile))
20 template.Must(tmpls.Parse(templates.GenerateSourceFile)) 20 template.Must(tmpls.Parse(templates.GenerateSourceFile))
21 template.Must(tmpls.Parse(templates.GenerateEnum)) 21 template.Must(tmpls.Parse(templates.GenerateEnum))
22 template.Must(tmpls.Parse(templates.GenerateStruct)) 22 template.Must(tmpls.Parse(templates.GenerateStruct))
23 template.Must(tmpls.Parse(templates.GenerateUnion)) 23 template.Must(tmpls.Parse(templates.GenerateUnion))
24 template.Must(tmpls.Parse(templates.GenerateInterface)) 24 template.Must(tmpls.Parse(templates.GenerateInterface))
25 template.Must(tmpls.Parse(templates.GenerateTypeTableDeclarations)) 25 template.Must(tmpls.Parse(templates.GenerateTypeTableDeclarations))
26 template.Must(tmpls.Parse(templates.GenerateTypeTableDefinitions)) 26 template.Must(tmpls.Parse(templates.GenerateTypeTableDefinitions))
27 27
28 config := common.GetCliConfig(os.Args) 28 config := common.GetCliConfig(os.Args)
29 common.GenerateOutput(func(fileName string, config common.GeneratorConfi g) { 29 common.GenerateOutput(func(fileName string, config common.GeneratorConfi g) {
30 » » headerWriter := common.OutputWriterByFilePath(fileName, config, ".mojom.c.h") 30 » » headerWriter := common.OutputWriterByFilePath(fileName, config, ".mojom-c.h")
31 » » sourceWriter := common.OutputWriterByFilePath(fileName, config, ".mojom.c") 31 » » sourceWriter := common.OutputWriterByFilePath(fileName, config, ".mojom-c.c")
32 mojomFile := config.FileGraph().Files[fileName] 32 mojomFile := config.FileGraph().Files[fileName]
33 headerInfo := cgen.NewHeaderTemplate(config.FileGraph(), &mojomF ile, config.SrcRootPath()) 33 headerInfo := cgen.NewHeaderTemplate(config.FileGraph(), &mojomF ile, config.SrcRootPath())
34 sourceInfo := cgen.NewSourceTemplate(config.FileGraph(), &mojomF ile, config.SrcRootPath(), &headerInfo) 34 sourceInfo := cgen.NewSourceTemplate(config.FileGraph(), &mojomF ile, config.SrcRootPath(), &headerInfo)
35 35
36 if err := tmpls.ExecuteTemplate(headerWriter, "GenerateHeaderFil e", headerInfo); err != nil { 36 if err := tmpls.ExecuteTemplate(headerWriter, "GenerateHeaderFil e", headerInfo); err != nil {
37 log.Fatal(err) 37 log.Fatal(err)
38 } 38 }
39 if err := tmpls.ExecuteTemplate(sourceWriter, "GenerateSourceFil e", sourceInfo); err != nil { 39 if err := tmpls.ExecuteTemplate(sourceWriter, "GenerateSourceFil e", sourceInfo); err != nil {
40 log.Fatal(err) 40 log.Fatal(err)
41 } 41 }
42 42
43 log.Printf("Processed %s", fileName) 43 log.Printf("Processed %s", fileName)
44 }, config) 44 }, config)
45 } 45 }
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/run_code_generators.py ('k') | mojom/generators/common/cli.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698