Skip to content
Open
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
29 changes: 29 additions & 0 deletions contrib/nix/bash/gccrs-commit-mklog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

set -e

ROOT_DIR=$(git rev-parse --show-toplevel 2>/dev/null || true)
if [ -z "$ROOT_DIR" ]; then
echo "Warning: You must be inside a git repository to run this command." >&2
exit 1
fi

if git diff --cached --quiet; then
echo "Warning: No staged changes found. Run 'git add' first." >&2
exit 1
fi

TMP_MSG_FILE=$(mktemp -t gccrs-changelog-XXXXXX.txt)
trap 'rm -f "$TMP_MSG_FILE"' EXIT

if ! gmklog > "$TMP_MSG_FILE" && ! gccrs-mklog > "$TMP_MSG_FILE"; then
echo "Warning: Failed to generate ChangeLog template." >&2
exit 1
fi

if [ ! -s "$TMP_MSG_FILE" ]; then
echo "Warning: ChangeLog template is empty. Aborting commit." >&2
exit 1
fi

git commit -t "$TMP_MSG_FILE" "$@"
17 changes: 17 additions & 0 deletions contrib/nix/bash/gccrs-fix-changelog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

ROOT_DIR=$(git rev-parse --show-toplevel 2>/dev/null)

if [ -z "$ROOT_DIR" ]; then
echo "Warning: You must be inside a git repository to run this command." >&2
exit 1
fi

SCRIPT_PATH="$ROOT_DIR/contrib/git-fix-changelog.py"

if [ ! -f "$SCRIPT_PATH" ]; then
echo "Warning: '$SCRIPT_PATH' not found! Are you sure this is the gccrs repository?" >&2
exit 1
fi

python3 "$SCRIPT_PATH" "$@"
17 changes: 17 additions & 0 deletions contrib/nix/bash/gccrs-mklog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

ROOT_DIR=$(git rev-parse --show-toplevel 2>/dev/null)

if [ -z "$ROOT_DIR" ]; then
echo "Warning: You must be inside a git repository to run this command." >&2
exit 1
fi

SCRIPT_PATH="$ROOT_DIR/contrib/mklog.py"

if [ ! -f "$SCRIPT_PATH" ]; then
echo "Warning: '$SCRIPT_PATH' not found! Are you sure this is the gccrs repository?" >&2
exit 1
fi

git diff --cached | python3 "$SCRIPT_PATH" -
28 changes: 28 additions & 0 deletions contrib/nix/bash/gccrs-style.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

ROOT_DIR=$(git rev-parse --show-toplevel 2>/dev/null)

if [ -z "$ROOT_DIR" ]; then
echo "Warning: You must be inside a git repository to run this command." >&2
exit 1
fi

SCRIPT_PATH="$ROOT_DIR/contrib/check_GNU_style.py"

if [ ! -f "$SCRIPT_PATH" ]; then
echo "Warning: '$SCRIPT_PATH' not found! Are you sure this is the gccrs repository?" >&2
exit 1
fi

arg=""
if [ $# -ge 1 ] && [ "$1" != "-f" ]; then
arg="$1"
shift
elif [ $# -eq 3 ]; then
arg="$3"
set -- "$1" "$2"
fi

TARGET_COMMIT="${arg:-HEAD}"

git show "$TARGET_COMMIT" | python3 "$SCRIPT_PATH" "$@" -
20 changes: 20 additions & 0 deletions contrib/nix/bash/gccrs-verify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

ROOT_DIR=$(git rev-parse --show-toplevel 2>/dev/null || true)

if [ -z "$ROOT_DIR" ]; then
echo "Warning: You must be inside a git repository to run this command." >&2
exit 1
fi

SCRIPT_PATH="$ROOT_DIR/contrib/gcc-changelog/git_check_commit.py"

if [ ! -f "$SCRIPT_PATH" ]; then
echo "Warning: '$SCRIPT_PATH' not found! Are you sure this is the gccrs repository?" >&2
exit 1
fi

cd "$ROOT_DIR"

TARGET_COMMIT="${1:-HEAD}"
python3 "$SCRIPT_PATH" "$TARGET_COMMIT"
27 changes: 27 additions & 0 deletions contrib/nix/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

109 changes: 109 additions & 0 deletions contrib/nix/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
{
description = "Reproducible Nix environment for GCC Rust (gccrs) development";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};

outputs =
{ self, nixpkgs }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
pkgs32 = pkgs.pkgsi686Linux;


mkGccrsEnv =
{ is32Bit ? false, useShortPrefix ? false }:
let
targetPkgs = if is32Bit then pkgs32 else pkgs;

gccrs-env-tools = targetPkgs.callPackage ./packages/gccrs-env-tools.nix {
inherit is32Bit useShortPrefix;
};

gccrs-contrib-tools = pkgs.callPackage ./packages/gccrs-contrib-tools.nix {
inherit useShortPrefix;
};
in
targetPkgs.mkShell.override { stdenv = targetPkgs.ccacheStdenv; } {
name = "gccrs-dev${if is32Bit then "-32" else "-64"}";

packages = [
gccrs-env-tools
gccrs-contrib-tools
];

nativeBuildInputs = with targetPkgs; [
# compile dependices
gnumake
pkg-config
autoconf
automake
m4
flex
bison
texinfo
ccache
mold

# test dependencies
dejagnu
expect
tcl
autogen
check

# debug dependencies
gdb
valgrind
strace
uftrace

# rust dependencies
cargo
rustc

# format dependencies
pkgs.bear
pkgs.clang-tools
pkgs.rustfmt
];

buildInputs = with targetPkgs; [
gmp
mpfr
libmpc
isl
zlib
zstd
gettext
];

shellHook = ''
export NIX_CFLAGS_LINK="-fuse-ld=mold"
export GCCRS_INCOMPLETE_AND_EXPERIMENTAL_COMPILER_DO_NOT_USE="1"
export NIX_GLIBC_INCLUDE="${targetPkgs.glibc.dev}/include"
export LIBRARY_PATH="${targetPkgs.glibc}/lib"

echo "🦀 GCC Rust (gccrs) ${if is32Bit then "32-bit" else "64-bit"} Development Environment"
echo "Run '${if useShortPrefix then "g" else "gccrs-"}help' to see all available commands"
'';

};

in
{
devShells.${system} = {

default = mkGccrsEnv {};

gcc32 = mkGccrsEnv { is32Bit = true; };

gprefix = mkGccrsEnv { useShortPrefix = true; };

gprefix32 = mkGccrsEnv { is32Bit = true; useShortPrefix = true; };

};
};
}
76 changes: 76 additions & 0 deletions contrib/nix/packages/gccrs-contrib-tools.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
writeShellApplication,
symlinkJoin,
python3,
git,
useShortPrefix,
}:

let
prefix = if useShortPrefix then "g" else "gccrs-";

pythonEnv = python3.withPackages (
ps: with ps; [
requests
unidiff
gitpython
termcolor # for gccrs-style
]
);

gccrs-mklog = writeShellApplication {
name = "${prefix}mklog";
runtimeInputs = [
git
pythonEnv
];
text = builtins.readFile ../bash/gccrs-mklog.sh;
};

gccrs-commit-mklog = writeShellApplication {
name = "${prefix}commit-mklog";
runtimeInputs = [
git
pythonEnv
];
text = builtins.readFile ../bash/gccrs-commit-mklog.sh;
};

gccrs-verify = writeShellApplication {
name = "${prefix}verify";
runtimeInputs = [
git
pythonEnv
];
text = builtins.readFile ../bash/gccrs-verify.sh;
};

gccrs-fix-changelog = writeShellApplication {
name = "${prefix}fix-changelog";
runtimeInputs = [
git
pythonEnv
];
text = builtins.readFile ../bash/gccrs-fix-changelog.sh;
};

gccrs-style = writeShellApplication {
name = "${prefix}style";
runtimeInputs = [
git
pythonEnv
];
text = builtins.readFile ../bash/gccrs-style.sh;
};

in
symlinkJoin {
name = "gccrs-contrib-tools";
paths = [
gccrs-mklog
gccrs-commit-mklog
gccrs-verify
gccrs-fix-changelog
gccrs-style
];
}
Loading
Loading