| 85 | } |
| 86 | |
| 87 | func (p *prebuilt) Install(options []string) error { |
| 88 | // If CMakeLists.txt exists, use CMake to install. |
| 89 | if fileio.PathExists(filepath.Join(p.PortConfig.RepoDir, "CMakeLists.txt")) { |
| 90 | return p.cmakeInside.Install(options) |
| 91 | } else { |
| 92 | // For pure prebuilt without CMakeLists.txt, just copy files from repo dir to package dir. |
| 93 | if err := os.MkdirAll(p.PortConfig.PackageDir, os.ModePerm); err != nil { |
| 94 | return err |
| 95 | } |
| 96 | |
| 97 | entities, err := os.ReadDir(p.PortConfig.RepoDir) |
| 98 | if err != nil { |
| 99 | return err |
| 100 | } |
| 101 | |
| 102 | for _, entity := range entities { |
| 103 | // .git should not be the installed files. |
| 104 | if entity.Name() == ".git" { |
| 105 | continue |
| 106 | } |
| 107 | |
| 108 | srcPath := filepath.Join(p.PortConfig.RepoDir, entity.Name()) |
| 109 | destPath := filepath.Join(p.PortConfig.PackageDir, entity.Name()) |
| 110 | if entity.IsDir() { |
| 111 | if err := fileio.CopyDir(srcPath, destPath); err != nil { |
| 112 | return err |
| 113 | } |
| 114 | } else { |
| 115 | if err := fileio.CopyFile(srcPath, destPath); err != nil { |
| 116 | return err |
| 117 | } |
| 118 | } |
| 119 | } |
| 120 | return nil |
| 121 | } |
| 122 | } |