Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Add cargo actions #102

Merged
merged 6 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
38 changes: 38 additions & 0 deletions data/macros/actions/cargo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
actions:
# Fetch dependencies
- cargo_fetch:
command: |
cargo fetch -v --locked
dependencies:
- rust

# Build the rust project
- cargo_build:
command: |
cargo build -v -j "%(jobs)" --frozen --release --target %(target_triple) \
--config profile.release.debug=\"full\" \
--config profile.release.split-debuginfo=\"off\" \
--config profile.release.strip=\"none\"
dependencies:
- rust

# Install the built binary
- cargo_install:
command: |
cargo_install(){
if [ $# -eq 1 ]; then
%install_bin target/%(target_triple)/release/"$1"
else
%install_bin target/%(target_triple)/release/%(name)
fi
}
cargo_install
dependencies:
- rust

# Run tests
- cargo_test:
command: |
cargo test -v -j "%(jobs)" --frozen --release --target %(target_triple) --workspace
dependencies:
- rust
1 change: 1 addition & 0 deletions data/macros/arch/aarch64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ definitions:
- cpp : "%(compiler_cpp) -m64"
- march : armv8-a+simd+fp+crypto
- mtune : cortex-a72.cortex-a53
- target_triple : "aarch64-unknown-linux-gnu"

flags:

Expand Down
1 change: 1 addition & 0 deletions data/macros/arch/emul32/x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ definitions:
- cpp : "%(compiler_cpp) -m32"
- march : i686
- mtune : i686
- target_triple : "i686-unknown-linux-gnu"
- pkgconfigpath : "%(libdir)/pkgconfig:/usr/share/pkgconfig:%(prefix)/lib/pkgconfig"

flags:
Expand Down
1 change: 1 addition & 0 deletions data/macros/arch/x86.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ definitions:
- cpp : "%(compiler_cpp) -m32"
- march : i686
- mtune : i686
- target_triple : "i686-unknown-linux-gnu"

flags:

Expand Down
3 changes: 2 additions & 1 deletion data/macros/arch/x86_64-stage1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ definitions:
- cpp : "%(compiler_cpp)"
- march : x86-64-v2
- mtune : ivybridge
- target_triple : "x86_64-unknown-linux-gnu"
- bootstrap_root : /bill

flags:
Expand All @@ -26,4 +27,4 @@ flags:

defaultTuningGroups :
- base
- optimize
- optimize
1 change: 1 addition & 0 deletions data/macros/arch/x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ definitions:
- d : "%(compiler_d)"
- march : x86-64-v2
- mtune : ivybridge
- target_triple : "x86_64-unknown-linux-gnu"

flags:

Expand Down
62 changes: 62 additions & 0 deletions source/drafter/build/cargo.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/* SPDX-License-Identifier: Zlib */

/**
* Drafter - Python integration
*
* Authors: © 2020-2022 Serpent OS Developers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks weird -- as if there's an encoding issue?

Feel free to update Copyright year range as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed 👍

* License: Zlib
*/

module drafter.build.cargo;

import moss.deps.analysis;
import drafter : Drafter;
import drafter.build : BuildType, Build;
import std.path : baseName;

/**
* Discover Cargo projects.
*/
static private AnalysisReturn acceptCargo(scope Analyser an, ref FileInfo inpath)
{
Drafter c = an.userdata!Drafter;

switch (inpath.path.baseName)
{
case "Cargo.toml":
c.incrementBuildConfidence(BuildType.Cargo, 100);
return AnalysisReturn.IncludeFile;
default:
return AnalysisReturn.NextHandler;
}
}

/**
* Handler for Cargo projects.
*/
public static AnalysisChain cargoChain = AnalysisChain("cargo", [&acceptCargo], 20);

public final class CargoBuild : Build
{
override:

string setup()
{
return "%cargo_fetch";
}

string build()
{
return "%cargo_build";
}

string install()
{
return "%cargo_install";
}

string check()
{
return "%cargo_check";
}
}
6 changes: 6 additions & 0 deletions source/drafter/build/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
module drafter.build;

public import drafter.build.autotools;
public import drafter.build.cargo;
public import drafter.build.cmake;
public import drafter.build.meson;
public import drafter.build.python;
Expand Down Expand Up @@ -77,6 +78,11 @@ public enum BuildType : string
*/
PythonSetuptools = "PythonSetuptools",

/**
* Uses cargo.
*/
Cargo = "cargo",

/**
* Unsupported tooling
*/
Expand Down
1 change: 1 addition & 0 deletions source/drafter/meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
libdrafter_sources = [
'package.d',
'build/autotools.d',
'build/cargo.d',
'build/cmake.d',
'build/meson.d',
'build/package.d',
Expand Down
3 changes: 2 additions & 1 deletion source/drafter/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,14 @@ public final class Drafter
analyser.addChain(mesonChain);
analyser.addChain(cmakeChain);
analyser.addChain(pythonChain);
analyser.addChain(cargoChain);
analyser.addChain(licenseChain);
controller.onFail.connect(&onFail);
controller.onComplete.connect(&onComplete);
_licenseEngine = new Engine();

auto licenseDir = thisExePath.dirName.buildNormalizedPath("..",
"share", "boulder", "licenses").absolutePath;
"share", "boulder", "licenses").absolutePath;
_licenseEngine.loadFromDirectory(licenseDir);
_licenses = new RedBlackTree!(string, "a < b", false);
outputFile = File(outputPath, "w");
Expand Down
Loading