-
Notifications
You must be signed in to change notification settings - Fork 326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remote SSH connection support #1898
Changes from 5 commits
bd4ef25
078fb8c
2bd9dc0
ca133e3
bd0fe70
8d8cbb2
d4467ba
f999dd9
29181fc
3d2362d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,15 +49,17 @@ type FileLayout interface { | |
// Gapis returns the path to the gapis binary in this layout. | ||
Gapis(ctx context.Context) (file.Path, error) | ||
// Gapir returns the path to the gapir binary in this layout. | ||
Gapir(ctx context.Context) (file.Path, error) | ||
Gapir(ctx context.Context, abi *device.ABI) (file.Path, error) | ||
// GapidApk returns the path to gapid.apk in this layout. | ||
GapidApk(ctx context.Context, abi *device.ABI) (file.Path, error) | ||
// Library returns the path to the requested library. | ||
Library(ctx context.Context, lib LibraryType) (file.Path, error) | ||
Library(ctx context.Context, lib LibraryType, abi *device.ABI) (file.Path, error) | ||
// Json returns the path to the Vulkan layer JSON definition for the given library. | ||
Json(ctx context.Context, lib LibraryType) (file.Path, error) | ||
// GoArgs returns additional arguments to pass to go binaries. | ||
GoArgs(ctx context.Context) []string | ||
// DeviceInfo returns the device info executable for the given ABI. | ||
DeviceInfo(ctx context.Context, os device.OSKind) (file.Path, error) | ||
} | ||
|
||
func withExecutablePlatformSuffix(exe string, os device.OSKind) string { | ||
|
@@ -88,6 +90,11 @@ func withLibraryPlatformSuffix(lib string, os device.OSKind) string { | |
} | ||
} | ||
|
||
// GetLibraryName returns the filename of the given Library. | ||
func GetLibraryName(lib LibraryType, abi *device.ABI) string { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: Doc strings everywhere There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: drop There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
return withLibraryPlatformSuffix(libTypeToName[lib], abi.OS) | ||
} | ||
|
||
var abiToApk = map[device.Architecture]string{ | ||
device.ARMv7a: "gapid-armeabi.apk", | ||
device.ARMv8a: "gapid-aarch64.apk", | ||
|
@@ -112,8 +119,17 @@ func (l pkgLayout) Gapit(ctx context.Context) (file.Path, error) { | |
return l.root.Join(withExecutablePlatformSuffix("gapit", hostOS(ctx))), nil | ||
} | ||
|
||
func (l pkgLayout) Gapir(ctx context.Context) (file.Path, error) { | ||
return l.root.Join(withExecutablePlatformSuffix("gapir", hostOS(ctx))), nil | ||
var osToDir = map[device.OSKind]string{ | ||
device.Linux: "linux", | ||
device.OSX: "macos", | ||
device.Windows: "windows", | ||
} | ||
|
||
func (l pkgLayout) Gapir(ctx context.Context, abi *device.ABI) (file.Path, error) { | ||
if hostOS(ctx) == abi.OS { | ||
return l.root.Join(withExecutablePlatformSuffix("gapir", hostOS(ctx))), nil | ||
} | ||
return l.root.Join(osToDir[abi.OS], withExecutablePlatformSuffix("gapir", abi.OS)), nil | ||
} | ||
|
||
func (l pkgLayout) Gapis(ctx context.Context) (file.Path, error) { | ||
|
@@ -124,8 +140,11 @@ func (l pkgLayout) GapidApk(ctx context.Context, abi *device.ABI) (file.Path, er | |
return l.root.Join(abiToApk[abi.Architecture]), nil | ||
} | ||
|
||
func (l pkgLayout) Library(ctx context.Context, lib LibraryType) (file.Path, error) { | ||
return l.root.Join("lib", withLibraryPlatformSuffix(libTypeToName[lib], hostOS(ctx))), nil | ||
func (l pkgLayout) Library(ctx context.Context, lib LibraryType, abi *device.ABI) (file.Path, error) { | ||
if hostOS(ctx) == abi.OS { | ||
return l.root.Join("lib", withLibraryPlatformSuffix(libTypeToName[lib], hostOS(ctx))), nil | ||
} | ||
return l.root.Join(osToDir[abi.OS], "lib", withLibraryPlatformSuffix(libTypeToName[lib], abi.OS)), nil | ||
} | ||
|
||
func (l pkgLayout) Json(ctx context.Context, lib LibraryType) (file.Path, error) { | ||
|
@@ -136,6 +155,13 @@ func (l pkgLayout) GoArgs(ctx context.Context) []string { | |
return nil | ||
} | ||
|
||
func (l pkgLayout) DeviceInfo(ctx context.Context, os device.OSKind) (file.Path, error) { | ||
if hostOS(ctx) == os { | ||
return l.root.Join(withExecutablePlatformSuffix("device-info", os)), nil | ||
} | ||
return l.root.Join(osToDir[os], withExecutablePlatformSuffix("device-info", os)), nil | ||
} | ||
|
||
// NewPkgLayout returns a FileLayout rooted at the given directory with the standard package layout. | ||
// If create is true, the package layout is created if it doesn't exist, otherwise an error is returned. | ||
func NewPkgLayout(dir file.Path, create bool) (FileLayout, error) { | ||
|
@@ -220,16 +246,22 @@ func (l *runfilesLayout) Gapis(ctx context.Context) (file.Path, error) { | |
return l.find(withExecutablePlatformSuffix("gapid/cmd/gapis/gapis", hostOS(ctx))) | ||
} | ||
|
||
func (l *runfilesLayout) Gapir(ctx context.Context) (file.Path, error) { | ||
return l.find(withExecutablePlatformSuffix("gapid/cmd/gapir/cc/gapir", hostOS(ctx))) | ||
func (l *runfilesLayout) Gapir(ctx context.Context, abi *device.ABI) (file.Path, error) { | ||
if hostOS(ctx) == abi.OS { | ||
return l.find(withExecutablePlatformSuffix("gapid/cmd/gapir/cc/gapir", hostOS(ctx))) | ||
} | ||
return file.Path{}, ErrCannotFindPackageFiles | ||
} | ||
|
||
func (l *runfilesLayout) GapidApk(ctx context.Context, abi *device.ABI) (file.Path, error) { | ||
return l.find("gapid/gapidapk/android/apk/" + abiToApkPath[abi.Architecture]) | ||
} | ||
|
||
func (l *runfilesLayout) Library(ctx context.Context, lib LibraryType) (file.Path, error) { | ||
return l.find(withLibraryPlatformSuffix(libTypeToLibPath[lib], hostOS(ctx))) | ||
func (l *runfilesLayout) Library(ctx context.Context, lib LibraryType, abi *device.ABI) (file.Path, error) { | ||
if hostOS(ctx) == abi.OS { | ||
return l.find(withLibraryPlatformSuffix(libTypeToLibPath[lib], hostOS(ctx))) | ||
} | ||
return file.Path{}, ErrCannotFindPackageFiles | ||
} | ||
|
||
func (l *runfilesLayout) Json(ctx context.Context, lib LibraryType) (file.Path, error) { | ||
|
@@ -240,6 +272,13 @@ func (l *runfilesLayout) GoArgs(ctx context.Context) []string { | |
return []string{"-runfiles", l.manifest} | ||
} | ||
|
||
func (l *runfilesLayout) DeviceInfo(ctx context.Context, os device.OSKind) (file.Path, error) { | ||
if hostOS(ctx) == os { | ||
return l.find("core/os/device/deviceinfo/exe/" + withExecutablePlatformSuffix("device-info", os)) | ||
} | ||
return file.Path{}, ErrCannotFindPackageFiles | ||
} | ||
|
||
// unknownLayout is the file layout used when no other layout can be discovered. | ||
// All methods will return an error. | ||
type unknownLayout struct{} | ||
|
@@ -256,15 +295,15 @@ func (l unknownLayout) Gapis(ctx context.Context) (file.Path, error) { | |
return file.Path{}, ErrCannotFindPackageFiles | ||
} | ||
|
||
func (l unknownLayout) Gapir(ctx context.Context) (file.Path, error) { | ||
func (l unknownLayout) Gapir(ctx context.Context, abi *device.ABI) (file.Path, error) { | ||
return file.Path{}, ErrCannotFindPackageFiles | ||
} | ||
|
||
func (l unknownLayout) GapidApk(ctx context.Context, abi *device.ABI) (file.Path, error) { | ||
return file.Path{}, ErrCannotFindPackageFiles | ||
} | ||
|
||
func (l unknownLayout) Library(ctx context.Context, lib LibraryType) (file.Path, error) { | ||
func (l unknownLayout) Library(ctx context.Context, lib LibraryType, abi *device.ABI) (file.Path, error) { | ||
return file.Path{}, ErrCannotFindPackageFiles | ||
} | ||
|
||
|
@@ -276,6 +315,10 @@ func (l unknownLayout) GoArgs(ctx context.Context) []string { | |
return nil | ||
} | ||
|
||
func (l unknownLayout) DeviceInfo(ctx context.Context, os device.OSKind) (file.Path, error) { | ||
return file.Path{}, ErrCannotFindPackageFiles | ||
} | ||
|
||
// ZipLayout is a FileLayout view over a ZIP file. | ||
type ZipLayout struct { | ||
f *zip.Reader | ||
|
@@ -317,8 +360,11 @@ func (l *ZipLayout) Gapit(ctx context.Context) (*zip.File, error) { | |
} | ||
|
||
// Gapir returns the path to the gapir binary in this layout. | ||
func (l *ZipLayout) Gapir(ctx context.Context) (*zip.File, error) { | ||
return l.file(withExecutablePlatformSuffix("gapir", l.os)) | ||
func (l *ZipLayout) Gapir(ctx context.Context, abi *device.ABI) (*zip.File, error) { | ||
if l.os == abi.OS { | ||
return l.file(withExecutablePlatformSuffix("gapir", l.os)) | ||
} | ||
return l.file(osToDir[abi.OS] + "/" + withExecutablePlatformSuffix("gapir", abi.OS)) | ||
} | ||
|
||
// Gapis returns the path to the gapis binary in this layout. | ||
|
@@ -332,11 +378,22 @@ func (l *ZipLayout) GapidApk(ctx context.Context, abi *device.ABI) (*zip.File, e | |
} | ||
|
||
// Library returns the path to the requested library. | ||
func (l *ZipLayout) Library(ctx context.Context, lib LibraryType) (*zip.File, error) { | ||
return l.file("lib/" + withLibraryPlatformSuffix(libTypeToName[lib], l.os)) | ||
func (l *ZipLayout) Library(ctx context.Context, lib LibraryType, abi *device.ABI) (*zip.File, error) { | ||
if l.os == abi.OS { | ||
return l.file("lib/" + withLibraryPlatformSuffix(libTypeToName[lib], l.os)) | ||
} | ||
return l.file(osToDir[abi.OS] + "lib/" + withLibraryPlatformSuffix(libTypeToName[lib], abi.OS)) | ||
} | ||
|
||
// Json returns the path to the Vulkan layer JSON definition for the given library. | ||
func (l *ZipLayout) Json(ctx context.Context, lib LibraryType) (*zip.File, error) { | ||
return l.file("lib/" + libTypeToJson[lib]) | ||
} | ||
|
||
// DeviceInfo returns the device info executable for the given ABI. | ||
func (l *ZipLayout) DeviceInfo(ctx context.Context, os device.OSKind) (*zip.File, error) { | ||
if l.os == os { | ||
return l.file(withExecutablePlatformSuffix("device-info", os)) | ||
} | ||
return l.file(osToDir[os] + "/" + withExecutablePlatformSuffix("device-info", os)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the point of this
func
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function was originally longer, so it was for the defer(), but no longer needed.