aboutsummaryrefslogtreecommitdiffstats
path: root/sys/fuchsia/layout/fidl_mappings.go
blob: 44fb308e1114d201d56c311165c5769096109ca3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright 2019 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

package layout

import (
	"fmt"
	"path/filepath"
	"strings"
)

// FidlLibrary is the fully-qualified name of a FIDL library.
type FidlLibrary []string

// AllFidlLibraries lists all FIDL libraries.
var AllFidlLibraries = []FidlLibrary{
	{"fuchsia", "cobalt"},
	{"fuchsia", "devicesettings"},
	{"fuchsia", "hardware", "ethernet"},
	{"fuchsia", "io"},
	{"fuchsia", "ldsvc"},
	{"fuchsia", "mem"},
	{"fuchsia", "net"},
	{"fuchsia", "process"},
	{"fuchsia", "scpi"},
}

func (fidlLib FidlLibrary) dirName() string {
	return strings.Join(fidlLib, ".")
}

// PathToJSONIr provides the path to the JSON IR, relative to the out/<arch>
// directory.
func (fidlLib FidlLibrary) PathToJSONIr() string {
	return filepath.Join(
		fidlLib.PathToCompiledDir(),
		fmt.Sprintf("%s.fidl.json", fidlLib.dirName()))
}

// PathToCompiledDir provides the path to compiled headers, relative to the
// out/<arch> directory.
func (fidlLib FidlLibrary) PathToCompiledDir() string {
	return filepath.Join("fidling", "gen", "sdk", "fidl", fidlLib.dirName())
}