MCPcopy Create free account
hub / github.com/cogentcore/core / ProcessFiles

Function ProcessFiles

vgpu/gosl/process.go:31–166  ·  view source on GitHub ↗

does all the file processing

(paths []string)

Source from the content-addressed store, hash-verified

29
30// does all the file processing
31func ProcessFiles(paths []string) (map[string][]byte, error) {
32 fls := FilesFromPaths(paths)
33 gosls := ExtractGoFiles(fls) // extract Go files to shader/*.go
34
35 hlslFiles := []string{}
36 for _, fn := range fls {
37 if strings.HasSuffix(fn, ".hlsl") {
38 hlslFiles = append(hlslFiles, fn)
39 }
40 }
41
42 pf := "./" + *outDir
43 pkgs, err := packages.Load(&packages.Config{Mode: packages.NeedName | packages.NeedFiles | packages.NeedCompiledGoFiles | packages.NeedTypes | packages.NeedSyntax | packages.NeedTypesInfo | packages.NeedTypesSizes}, pf)
44 if err != nil {
45 log.Println(err)
46 return nil, err
47 }
48 if len(pkgs) != 1 {
49 err := fmt.Errorf("More than one package for path: %v", pf)
50 log.Println(err)
51 return nil, err
52 }
53 pkg := pkgs[0]
54
55 if len(pkg.GoFiles) == 0 {
56 err := fmt.Errorf("No Go files found in package: %+v", pkg)
57 log.Println(err)
58 return nil, err
59 }
60 // fmt.Printf("go files: %+v", pkg.GoFiles)
61 // return nil, err
62
63 // map of files with a main function that needs to be compiled
64 needsCompile := map[string]bool{}
65
66 serr := alignsl.CheckPackage(pkg)
67 if serr != nil {
68 fmt.Println(serr)
69 }
70
71 slrandCopied := false
72 for fn := range gosls {
73 gofn := fn + ".go"
74 if *debug {
75 fmt.Printf("###################################\nProcessing Go file: %s\n", gofn)
76 }
77
78 var afile *ast.File
79 var fpos token.Position
80 for _, sy := range pkg.Syntax {
81 pos := pkg.Fset.Position(sy.Package)
82 _, posfn := filepath.Split(pos.Filename)
83 if posfn == gofn {
84 fpos = pos
85 afile = sy
86 break
87 }
88 }

Callers 2

runTestFunction · 0.85
goslMainFunction · 0.85

Calls 15

FprintMethod · 0.95
CheckPackageFunction · 0.92
FilesFromPathsFunction · 0.85
ExtractGoFilesFunction · 0.85
SlEditsFunction · 0.85
CopySlrandFunction · 0.85
ExtractHLSLFunction · 0.85
CompileFileFunction · 0.85
PrintlnMethod · 0.80
SplitMethod · 0.80
ReadFileMethod · 0.80
CopyFileFunction · 0.70

Tested by 1

runTestFunction · 0.68