()
| 205 | } |
| 206 | |
| 207 | func (e *Exporter) exportConf() error { |
| 208 | dstConf := filepath.Join(e.exportDir, "conf") |
| 209 | |
| 210 | // 1. Export only the current platform's .toml file. |
| 211 | platformName := e.celer.Platform().GetName() |
| 212 | srcPlatformFile := filepath.Join(dirs.ConfPlatformsDir, platformName+".toml") |
| 213 | dstPlatformDir := filepath.Join(dstConf, "platforms") |
| 214 | if err := os.MkdirAll(dstPlatformDir, os.ModePerm); err != nil { |
| 215 | return err |
| 216 | } |
| 217 | if err := fileio.CopyFile(srcPlatformFile, filepath.Join(dstPlatformDir, platformName+".toml")); err != nil { |
| 218 | return fmt.Errorf("failed to copy platform file -> %w", err) |
| 219 | } |
| 220 | |
| 221 | // 2. Export only the current project's .toml file and its subdirectory (port overrides). |
| 222 | projectName := e.celer.Project().GetName() |
| 223 | srcProjectFile := filepath.Join(dirs.ConfProjectsDir, projectName+".toml") |
| 224 | dstProjectDir := filepath.Join(dstConf, "projects") |
| 225 | if err := os.MkdirAll(dstProjectDir, os.ModePerm); err != nil { |
| 226 | return err |
| 227 | } |
| 228 | if err := fileio.CopyFile(srcProjectFile, filepath.Join(dstProjectDir, projectName+".toml")); err != nil { |
| 229 | return fmt.Errorf("failed to copy project file -> %w", err) |
| 230 | } |
| 231 | |
| 232 | // Copy project-specific port overrides only for used ports. |
| 233 | srcProjectSubdir := filepath.Join(dirs.ConfProjectsDir, projectName) |
| 234 | for nameVersion := range e.usedPorts { |
| 235 | parts := strings.SplitN(nameVersion, "@", 2) |
| 236 | if len(parts) != 2 { |
| 237 | continue |
| 238 | } |
| 239 | srcPortDir := filepath.Join(srcProjectSubdir, parts[0], parts[1]) |
| 240 | if !fileio.PathExists(srcPortDir) { |
| 241 | continue |
| 242 | } |
| 243 | dstPortDir := filepath.Join(dstProjectDir, projectName, parts[0], parts[1]) |
| 244 | if err := filepath.Walk(srcPortDir, func(srcPath string, info os.FileInfo, err error) error { |
| 245 | if err != nil { |
| 246 | return err |
| 247 | } |
| 248 | relPath, err := filepath.Rel(srcPortDir, srcPath) |
| 249 | if err != nil { |
| 250 | return err |
| 251 | } |
| 252 | dstPath := filepath.Join(dstPortDir, relPath) |
| 253 | if info.IsDir() { |
| 254 | return os.MkdirAll(dstPath, info.Mode()) |
| 255 | } |
| 256 | return fileio.CopyFile(srcPath, dstPath) |
| 257 | }); err != nil { |
| 258 | return fmt.Errorf("failed to copy project overrides for %s -> %w", nameVersion, err) |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | // 3. Export only the host's buildtools .toml file. |
| 263 | hostName := e.celer.Platform().GetHostName() |
| 264 | srcBuildtoolsFile := filepath.Join(dirs.ConfDir, "buildtools", hostName+".toml") |
no test coverage detected