constructor.go 827 B

123456789101112131415161718192021222324252627282930
  1. package aapt
  2. import (
  3. "path/filepath"
  4. "notabug.org/Umnik/GoAndroidSDK/v2/components/misc"
  5. "notabug.org/Umnik/GoAndroidSDK/v2/components/sdk"
  6. )
  7. func aaptFromPath(dirPath string, err error) (*Aapt, error) {
  8. if err != nil {
  9. return nil, err
  10. }
  11. binPath := filepath.Join(dirPath, "aapt")
  12. if err = misc.TestFile(binPath); err != nil {
  13. return nil, err
  14. }
  15. return &Aapt{binPath: binPath}, nil
  16. }
  17. // NewAaptLastVersion creates Aapt from last available version of sdk.SDK "build-tools" dir
  18. func NewAaptLastVersion(sdk sdk.SDK) (*Aapt, error) {
  19. return aaptFromPath(sdk.LastBuildToolsVersion())
  20. }
  21. // NewAaptSpecificVersion creates Aapt from specified version of sdk.SDK "build-tools" dir
  22. func NewAaptSpecificVersion(sdk sdk.SDK, version string) (*Aapt, error) {
  23. return aaptFromPath(sdk.SpecificBuildToolsVersion(version))
  24. }