()
| 95 | } |
| 96 | |
| 97 | func (p Port) buildMeta() (string, error) { |
| 98 | key := fmt.Sprintf("%s|%t|%d|%s", p.NameVersion, p.DevDep || p.HostDev, p.PortType, strings.Join(p.Parents, ">")) |
| 99 | if value, ok := metaCache.Load(key); ok { |
| 100 | result := value.(metaResult) |
| 101 | return result.meta, result.err |
| 102 | } |
| 103 | |
| 104 | var buffer bytes.Buffer |
| 105 | |
| 106 | // Write celer version and platform content for root port only. |
| 107 | if p.PortType == portTypePort { |
| 108 | // Write content of platform toml. |
| 109 | p.writeSectionTitle(&buffer, p.Parents, p.NameVersion, "platform") |
| 110 | platform, err := p.Callbacks.GenPlatformTomlString() |
| 111 | if err != nil { |
| 112 | return "", err |
| 113 | } |
| 114 | fmt.Fprintf(&buffer, "%s\n", platform) |
| 115 | } |
| 116 | |
| 117 | // Write port content. |
| 118 | parts := strings.Split(p.NameVersion, "@") |
| 119 | if len(parts) != 2 { |
| 120 | return "", fmt.Errorf("invalid port name and version: %s", p.NameVersion) |
| 121 | } |
| 122 | |
| 123 | content, err := p.Callbacks.GenPortTomlString(p.NameVersion, p.DevDep) |
| 124 | if err != nil { |
| 125 | return "", fmt.Errorf("generate toml content of port %s -> %w", p.NameVersion, err) |
| 126 | } |
| 127 | p.writeSectionTitle(&buffer, p.Parents, p.NameVersion, "port") |
| 128 | fmt.Fprintf(&buffer, "%s\n", content) |
| 129 | |
| 130 | // Write content of patches. |
| 131 | for _, patch := range p.BuildConfig.Patches { |
| 132 | content, err := p.readPatch(patch) |
| 133 | if err != nil { |
| 134 | return "", fmt.Errorf("read patch %s -> %w", patch, err) |
| 135 | } |
| 136 | p.writeSectionTitle(&buffer, p.Parents, p.NameVersion, fmt.Sprintf("patch: %s", patch)) |
| 137 | fmt.Fprintf(&buffer, "%s\n", content) |
| 138 | } |
| 139 | |
| 140 | // Write content of dev_dependencies. |
| 141 | for _, nameVersion := range p.BuildConfig.DevDependencies { |
| 142 | // Same name, version as parent and they are booth build with native toolchain, so skip. |
| 143 | if (p.DevDep || p.HostDev) && p.NameVersion == nameVersion { |
| 144 | continue |
| 145 | } |
| 146 | |
| 147 | // Skip if not supported. |
| 148 | if !p.Callbacks.CheckHostSupported(nameVersion) { |
| 149 | continue |
| 150 | } |
| 151 | |
| 152 | buildConfig, err := p.Callbacks.GetBuildConfig(nameVersion, true) |
| 153 | if err != nil { |
| 154 | return "", fmt.Errorf("get build config of dependency %s -> %w", nameVersion, err) |
no test coverage detected