Update build toolchain

It now uses cargo zigbuild instead of cross, with a prebuilt image.

Update build to use zigbuild instead of cross

Signed-off-by: Jacob Kiers <code@kiers.eu>
This commit is contained in:
2023-06-10 12:51:32 +02:00
parent 48caa99423
commit 21cbd34f4d

View File

@@ -1,5 +1,5 @@
local executableName = 'newsletter-to-web';
local cross_image = 'img.kie.rs/jjkiers/rust-dind-cross:1.66-full';
local build_image = 'img.kie.rs/jjkiers/rust-crossbuild:rust1.79.0-zig0.11.0-zig';
local archs = [
{ target: 'aarch64-unknown-linux-musl', short: 'arm64-musl' },
@@ -12,26 +12,30 @@ local getStepName(arch) = 'Build for ' + arch.short;
local builtExecutableName(arch) = executableName + if std.length(std.findSubstr(arch.short, 'windows')) > 0 then '.exe' else '';
local targetExecutableName(arch) = executableName + '-' + arch.target + if std.length(std.findSubstr(arch.short, 'windows')) > 0 then '.exe' else '';
local getVolumeName(arch) = 'target-' + arch.target;
local getLocalVolumes(arch) = [
{
name: getVolumeName(arch),
temp: {},
}
for arch in archs
];
local add_build_steps() = [
{
name: getStepName(arch),
image: cross_image,
volumes: [
{
name: 'dockersock',
path: '/var/run',
},
],
image: build_image,
commands: [
'echo Hello World from Jsonnet on ' + arch.target + '!',
'cross build --release --target ' + arch.target,
'cargo zigbuild --release --target ' + arch.target,
'cp target/' + arch.target + '/release/' + builtExecutableName(arch) + ' artifacts/' + targetExecutableName(arch),
'rm -rf target/' + arch.target + '/release/*',
],
environment: {
CROSS_REMOTE: true,
},
depends_on: ['Wait for Docker'],
depends_on: ['Prepare'],
volumes: [{
name: getVolumeName(arch),
path: '/drone/src/target',
}],
}
for arch in archs
];
@@ -45,30 +49,20 @@ local add_build_steps() = [
},
steps:
[{
name: 'Wait for Docker',
image: cross_image,
name: 'Prepare',
image: build_image,
commands: [
'mkdir artifacts',
'echo Using image: ' + cross_image,
'while ! docker image ls; do sleep 1; done',
'echo Using image: ' + build_image,
'cargo --version',
'rustc --version',
'docker info',
'docker pull hello-world:latest',
],
environment: {
CROSS_REMOTE: true,
},
volumes: [{
name: 'dockersock',
path: '/var/run',
}],
}] +
add_build_steps() +
[
{
name: 'Show built artifacts',
image: cross_image,
image: build_image,
commands: [
'ls -lah artifacts',
],
@@ -92,28 +86,7 @@ local add_build_steps() = [
},
],
services: [{
name: 'docker',
image: 'docker:dind',
privileged: true,
volumes: [
{
name: 'dockersock',
path: '/var/run',
},
{
name: 'docker-storage',
path: '/var/lib/docker',
},
],
}],
volumes: [
{
name: 'dockersock',
temp: {},
},
],
volumes: getLocalVolumes(archs),
image_pull_secrets: ['docker_private_repo'],
}