MCPcopy Index your code
hub / github.com/celer-pkg/celer / stripDeployed

Method stripDeployed

configs/project.go:154–199  ·  view source on GitHub ↗

stripDeployed walks the per-platform installed tree and runs strip on every ELF file found. Static archives (.a) are intentionally skipped — stripping them removes symbols downstream linking against this deploy still needs.

()

Source from the content-addressed store, hash-verified

152// ELF file found. Static archives (.a) are intentionally skipped — stripping
153// them removes symbols downstream linking against this deploy still needs.
154func (p Project) stripDeployed() error {
155 // Check if strip executable file has been configured.
156 toolchain := p.ctx.Platform().GetToolchain()
157 stripBin := toolchain.GetSTRIP()
158 if stripBin == "" {
159 return fmt.Errorf("strip executable file path is not configured in platform: %s.toml", p.ctx.Platform().GetName())
160 }
161
162 // Resolve target tree: installed/<platform>/<project>/<buildType>/.
163 // Dev/host trees are not stripped — those binaries run on the build host
164 // and people often want their symbols for debugging build issues.
165 installedDir := p.ctx.InstalledDir()
166 if !fileio.PathExists(installedDir) {
167 return nil
168 }
169
170 color.Printf(color.Title, "\n[strip deployed binaries: %s]\n", installedDir)
171 err := filepath.WalkDir(installedDir, func(path string, d fs.DirEntry, walkErr error) error {
172 if walkErr != nil {
173 return walkErr
174 }
175 if d.IsDir() {
176 return nil
177 }
178
179 // Skip anything that is obviously not an ELF binary we want to strip.
180 // Static archives are special: stripping breaks them for downstream linking.
181 if strings.HasSuffix(path, ".a") {
182 return nil
183 }
184 if !fileio.IsELFFile(path) {
185 return nil
186 }
187
188 if _, err := cmd.NewExecutor("", stripBin, path).ExecuteOutput(); err != nil {
189 return nil
190 }
191 color.PrintHint("✔ strip %s", path)
192 return nil
193 })
194 if err != nil {
195 return err
196 }
197
198 return nil
199}

Callers 1

deployMethod · 0.95

Calls 11

PathExistsFunction · 0.92
PrintfFunction · 0.92
IsELFFileFunction · 0.92
NewExecutorFunction · 0.92
PrintHintFunction · 0.92
ExecuteOutputMethod · 0.80
GetToolchainMethod · 0.65
PlatformMethod · 0.65
GetSTRIPMethod · 0.65
GetNameMethod · 0.65
InstalledDirMethod · 0.65

Tested by

no test coverage detected