cpp

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package cpp provides a C++ builder that uses system-installed g++ and clang++ compilers.

Unlike other builders that download compiler toolchains, this package discovers compilers already present on the host (e.g. /usr/bin/g++-13, /usr/bin/clang++-18) and mounts them into the sandbox for compilation.

Version IDs follow the format "g++<semver>" or "clang++<semver>", for example "g++13.3.0" or "clang++18.1.3". The default version is "g++13.3.0".

Import this package for its side effects to register the builder:

import _ "github.com/Highload-fun/builders/cpp"

Index

Constants

View Source
const BuilderId = "cpp"

BuilderId is the identifier used to register and look up this builder.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cpp

type Cpp struct {
	// contains filtered or unexported fields
}

Cpp implements the builders.Builder interface for C++ using system-installed g++ and clang++ compilers.

func (*Cpp) Build

func (c *Cpp) Build(ctx context.Context, sb *sandbox.Sandbox, version string, flags []string) error

Build compiles main.cpp inside the sandbox using the specified compiler version. If version is empty, "g++13.3.0" is used. If flags is empty, "-O2 -std=c++17" is used. The compiled binary is written to /out/main.

func (*Cpp) GetVersions

func (c *Cpp) GetVersions(_ context.Context) ([]builders.Version, error)

GetVersions discovers available C++ compilers by scanning /usr/bin for g++-* and clang++-* binaries, running --version on each to extract the version string. Results are cached for 1 hour.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL