(platformPath string)
| 142 | } |
| 143 | |
| 144 | func (p *Platform) Write(platformPath string) error { |
| 145 | // Create empty platform. |
| 146 | p.RootFS = &RootFS{ |
| 147 | PkgConfigPath: []string{}, |
| 148 | IncludeDirs: []string{}, |
| 149 | LibDirs: []string{}, |
| 150 | } |
| 151 | p.Toolchain = &Toolchain{} |
| 152 | |
| 153 | bytes, err := toml.Marshal(p) |
| 154 | if err != nil { |
| 155 | return err |
| 156 | } |
| 157 | |
| 158 | // Check if conf/celer.toml exists. |
| 159 | if fileio.PathExists(platformPath) { |
| 160 | return fmt.Errorf("%s is already exists", platformPath) |
| 161 | } |
| 162 | |
| 163 | // Make sure the parent directory exists. |
| 164 | parentDir := filepath.Dir(platformPath) |
| 165 | if err := os.MkdirAll(parentDir, os.ModePerm); err != nil { |
| 166 | return err |
| 167 | } |
| 168 | return os.WriteFile(platformPath, bytes, os.ModePerm) |
| 169 | } |
| 170 | |
| 171 | // setup rootfs and toolchain |
| 172 | func (p *Platform) Setup() error { |
no test coverage detected