Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,8 @@ BenchmarkDotNet.Artifacts/
# Clangd uses these common ephemeral files
.cache
compile_commands.json

# Bee build outputs
/artifacts/
/builds/
/build.gen.sln
4 changes: 2 additions & 2 deletions .yamato/build-linux-x64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build protobuf - CentOS 7 x64 with Clang9

agent:
type: Unity::VM
image: platform-foundation/linux-bokken:latest
image: build-system/unity-ubuntu-22.04:v2.9071485
flavor: b1.small

artifacts:
Expand All @@ -13,4 +13,4 @@ artifacts:
# After building, recursively copy .h and .inc files from the source to the destination, then rename the folder.
# This is a superset of what make does, but only a couple of extra test files are included.
commands:
- bash ./bee/bee linux_x64_clang
- bash ./bee/bee linux_x64
6 changes: 3 additions & 3 deletions .yamato/build-windows-all.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
windows-c-libraries:
name: Build protobuf - Windows 10 x64 with VS 2017
name: Build protobuf - Windows x64 and arm64 with VS 2026

agent:
type: Unity::VM
Expand All @@ -12,8 +12,8 @@ windows-c-libraries:
- builds/**

commands:
- .\bee\bee win_x64_vs2017_win7
- .\bee\bee win_arm64_vs2019_win7
- .\bee\bee win_x64
- .\bee\bee win_arm64

csharp-bindings:
name: Build C# Bindings
Expand Down
42 changes: 31 additions & 11 deletions Build.bee.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static NativeProgram SetupLibProtobuf(IEnumerable<ToolChain> toolchains)
var nativeProgramConfiguration = new NativeProgramConfiguration(codegen, toolchain, lump: true);
var format = toolchain.StaticLibraryFormat;
var deployedProgram = np.SetupSpecificConfiguration(nativeProgramConfiguration, format).DeployTo(GetBuildTargetDir(toolchain));
Backend.Current.AddAliasDependency(toolchain.ActionName, deployedProgram.Path);
Backend.Current.AddAliasDependency(AliasFor(toolchain), deployedProgram.Path);

if (toolchain.Platform is LinuxPlatform)
{
Expand Down Expand Up @@ -232,44 +232,64 @@ static NativeProgram SetupProtoc(IEnumerable<ToolChain> toolchains, NativeProgra
np.CompilerSettingsForGccLike().Add(s => s.WithGlibcxxUseCxx11Abi(true));
np.Libraries.Add(libProtobuf);

foreach (var toolchain in toolchains)
// On Windows protoc is built with the dynamic CRT (/MD) only
foreach (var toolchain in toolchains.Where(t => !IsStaticCrtWindows(t)))
{
var nativeProgramConfiguration = new NativeProgramConfiguration(CodeGen.Release, toolchain, lump: true);

var format = toolchain.ExecutableFormat;

var deployedProgram = np.SetupSpecificConfiguration(nativeProgramConfiguration, format).DeployTo(GetBuildTargetDir(toolchain, true));
Backend.Current.AddAliasDependency(toolchain.ActionName, deployedProgram.Path);
Backend.Current.AddAliasDependency(AliasFor(toolchain), deployedProgram.Path);
}

return np;
}

static bool IsStaticCrtWindows(ToolChain toolchain) =>
toolchain is VisualStudioToolchain vs && vs.CompilerRuntimeLibrary == CompilerRuntimeLibrary.Static;

static string AliasFor(ToolChain toolchain)
{
var platform = toolchain.Platform switch
{
WindowsPlatform => "win",
LinuxPlatform => "linux",
MacOSXPlatform => "mac",
_ => throw new ArgumentException($"Don't know alias for toolchain {toolchain.ActionName}")
};
return $"{platform}_{toolchain.Architecture.DisplayName}";
}

static NPath GetBuildTargetDir(ToolChain toolchain, bool isExecutable = false)
{
var mapping = new Dictionary<string, string>
{
{"mac_x64", "macos/x64"},
{"mac_arm64", "macos/arm64"},
{"linux_x64_clang", "linux"},
{"win_x64_vs2017_win7", "win/x64"},
{"win_arm64_vs2019_win7", "win/arm64"},
{"linux_x64", "linux"},
{"win_x64", "win/x64"},
{"win_arm64", "win/arm64"},
};

var name = toolchain.ActionName.ToLowerInvariant();
var name = AliasFor(toolchain);
if (!mapping.ContainsKey(name))
throw new ArgumentException($"Don't know output path for toolchain {name}");

// Windows libraries built with the dynamic CRT (/MD, /MDd in Debug) go in an MD subfolder, for linking into a /MD Unity Editor
var typePath = isExecutable ? "bin" : "lib";
return $"builds/{typePath}/{mapping[name]}";
var crtPath = !isExecutable && toolchain is VisualStudioToolchain { CompilerRuntimeLibrary: CompilerRuntimeLibrary.Dynamic } ? "/MD" : "";
return $"builds/{typePath}/{mapping[name]}{crtPath}";
}

static IEnumerable<ToolChain> GetToolchains()
{
var toolchains = new ToolChain[] {
ToolChain.Store.Windows().VS2017().Sdk_17134().x64(),
ToolChain.Store.Windows().VS2019().Sdk_20348().Arm64(),
ToolChain.Store.Linux().Centos_7_7_1908().Clang_9_0_1().x64(),
ToolChain.Store.Windows().VS2026().Sdk_20348().x64(TargetWindowsVersion.Windows7, CompilerRuntimeLibrary.Static),
ToolChain.Store.Windows().VS2026().Sdk_20348().x64(TargetWindowsVersion.Windows7, CompilerRuntimeLibrary.Dynamic),
ToolChain.Store.Windows().VS2026().Sdk_20348().Arm64(TargetWindowsVersion.Windows7, CompilerRuntimeLibrary.Static),
ToolChain.Store.Windows().VS2026().Sdk_20348().Arm64(TargetWindowsVersion.Windows7, CompilerRuntimeLibrary.Dynamic),
ToolChain.Store.Linux().GLibC_2_35().LLVM_15_0().x64(),
ToolChain.Store.Mac().Sdk_11_0().x64(),
ToolChain.Store.Mac().Sdk_11_0().ARM64(),
}.Where(t => t != null).ToArray();
Expand Down
Loading
Loading