forked from unikraft/kraftkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Allow building on Darwin for both arm64 and amd64 architectures
Create darwin specific equivalents of _linux code. If possible, merge common parts into _unix suffixed files. Move others into _linux.go and _darwin.go files. Augment goreleaser's ytt templates to produce two additional targets: - darwin amd64 - darwin arm64 Make it build a binary runnable on the host MacOS machine via make kraft (both with DOCKER variable set and not set) GitHub-Fixes: unikraft#30 GitHub-Fixes: unikraft#266 Signed-off-by: Jakub Ciolek <[email protected]>
- Loading branch information
1 parent
0f3ebc3
commit 27da0d7
Showing
8 changed files
with
146 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. | ||
// Licensed under the BSD-3-Clause License (the "License"). | ||
// You may not use this file except in compliance with the License. | ||
package network | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
|
||
networkv1alpha1 "kraftkit.sh/api/network/v1alpha1" | ||
) | ||
|
||
// hostSupportedStrategies returns the map of known supported drivers for the | ||
// given host. | ||
func hostSupportedStrategies() map[string]*Strategy { | ||
return map[string]*Strategy{ | ||
"bridge": { | ||
NewNetworkV1alpha1: func(ctx context.Context, opts ...any) (networkv1alpha1.NetworkService, error) { | ||
return nil, errors.New("network service is not supported on MacOS") | ||
}, | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//go:build darwin | ||
// +build darwin | ||
|
||
// SPDX-License-Identifier: BSD-3-Clause | ||
// Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. | ||
// Licensed under the BSD-3-Clause License (the "License"). | ||
// You may not use this file except in compliance with the License. | ||
package platform | ||
|
||
func unixVariantStrategies() map[Platform]*Strategy { | ||
// Nothing added for Darwin | ||
return map[Platform]*Strategy{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. | ||
// Licensed under the BSD-3-Clause License (the "License"). | ||
// You may not use this file except in compliance with the License. | ||
package platform | ||
|
||
import ( | ||
"context" | ||
"path/filepath" | ||
|
||
zip "api.zip" | ||
|
||
machinev1alpha1 "kraftkit.sh/api/machine/v1alpha1" | ||
"kraftkit.sh/config" | ||
"kraftkit.sh/machine/qemu" | ||
"kraftkit.sh/machine/store" | ||
) | ||
|
||
var qemuV1alpha1Driver = func(ctx context.Context, opts ...any) (machinev1alpha1.MachineService, error) { | ||
service, err := qemu.NewMachineV1alpha1Service(ctx, opts...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
embeddedStore, err := store.NewEmbeddedStore[machinev1alpha1.MachineSpec, machinev1alpha1.MachineStatus]( | ||
filepath.Join( | ||
config.G[config.KraftKit](ctx).RuntimeDir, | ||
"machinev1alpha1", | ||
), | ||
) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return machinev1alpha1.NewMachineServiceHandler( | ||
ctx, | ||
service, | ||
zip.WithStore[machinev1alpha1.MachineSpec, machinev1alpha1.MachineStatus](embeddedStore, zip.StoreRehydrationSpecNil), | ||
zip.WithBefore(storePlatformFilter(PlatformQEMU)), | ||
) | ||
} | ||
|
||
// hostSupportedStrategies returns the map of known supported drivers for the | ||
// given host. | ||
func hostSupportedStrategies() map[Platform]*Strategy { | ||
s := map[Platform]*Strategy{ | ||
PlatformQEMU: { | ||
NewMachineV1alpha1: qemuV1alpha1Driver, | ||
}, | ||
} | ||
|
||
// Merge OS-specific strategies | ||
for k, v := range unixVariantStrategies() { | ||
s[k] = v | ||
} | ||
|
||
return s | ||
} |
File renamed without changes.