From 861d380a9652f48396a7f86fa60ec646ff9a05f7 Mon Sep 17 00:00:00 2001 From: Alwin Berger Date: Thu, 20 Jun 2024 10:21:42 +0200 Subject: [PATCH] update flake --- .envrc | 2 +- flake.lock | 32 ++++++++++----------- flake.nix | 18 +++++++----- state2gantt/plot.r | 69 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 97 insertions(+), 24 deletions(-) create mode 100644 state2gantt/plot.r diff --git a/.envrc b/.envrc index 9800a71..3550a30 100644 --- a/.envrc +++ b/.envrc @@ -1 +1 @@ -use_nix shell.nix +use flake diff --git a/flake.lock b/flake.lock index 6fb6b4a..18c76dc 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1701680307, - "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "type": "github" }, "original": { @@ -23,11 +23,11 @@ "systems": "systems_2" }, "locked": { - "lastModified": 1681202837, - "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", "owner": "numtide", "repo": "flake-utils", - "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", "type": "github" }, "original": { @@ -38,27 +38,27 @@ }, "nixpkgs": { "locked": { - "lastModified": 1704145853, - "narHash": "sha256-G/1AMt9ibpeMlcxvD1vNaC8imGaK+g7zZ99e29BLgWw=", + "lastModified": 1716509168, + "narHash": "sha256-4zSIhSRRIoEBwjbPm3YiGtbd8HDWzFxJjw5DYSDy1n8=", "owner": "nixos", "repo": "nixpkgs", - "rev": "2d2ea8eab9e400618748ab1a6a108255233b602c", + "rev": "bfb7a882678e518398ce9a31a881538679f6f092", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixos-23.11", + "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } }, "nixpkgs_2": { "locked": { - "lastModified": 1681358109, - "narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=", + "lastModified": 1706487304, + "narHash": "sha256-LE8lVX28MV2jWJsidW13D2qrHU/RUUONendL2Q/WlJg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9", + "rev": "90f456026d284c22b3e3497be980b2e47d0b28ac", "type": "github" }, "original": { @@ -81,11 +81,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1704075545, - "narHash": "sha256-L3zgOuVKhPjKsVLc3yTm2YJ6+BATyZBury7wnhyc8QU=", + "lastModified": 1716862669, + "narHash": "sha256-7oTPM9lcdwiI1cpRC313B+lHawocgpY5F07N+Rbm5Uk=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "a0df72e106322b67e9c6e591fe870380bd0da0d5", + "rev": "47b2d15658b37716393b2463a019000dbd6ce4bc", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index d8a13d6..efb7ead 100644 --- a/flake.nix +++ b/flake.nix @@ -2,7 +2,7 @@ description = "A devShell example"; inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; rust-overlay.url = "github:oxalica/rust-overlay"; flake-utils.url = "github:numtide/flake-utils"; }; @@ -25,9 +25,12 @@ devShell = mkShell.override {stdenv = stdenv;} { # LibAFL needs LLVM buildInputs = [ rust-bin.stable.latest.default - llvmPackages_17.clangUseLLVM - llvmPackages_17.libclang - llvmPackages_17.libllvm + cargo-make + llvmPackages_18.clangUseLLVM + llvmPackages_18.libclang + llvmPackages_18.libllvm + zlib + cargo-flamegraph # für qemu (pkgs.python3.withPackages my-python-packages) meson # unsure @@ -49,8 +52,8 @@ ddd # visualization graphviz - rstudioWrapper - R + #rstudioWrapper # prefer host packages for R + #R # dependencies for mosaic freetype fontconfig @@ -60,7 +63,8 @@ ]; shellHook = '' - export CUSTOM_QEMU_DIR=/home/ab/code/FRET/qemu-libafl-bridge + export CUSTOM_QEMU_DIR=$(pwd)/qemu-libafl-bridge + export LIBAFL_QEMU_DIR=$(pwd)/qemu-libafl-bridge export CUSTOM_QEMU_NO_BUILD=1 export CUSTOM_QEMU_NO_CONFIGURE=1 # export EMULATION_MODE=systemmode diff --git a/state2gantt/plot.r b/state2gantt/plot.r new file mode 100644 index 0000000..d665491 --- /dev/null +++ b/state2gantt/plot.r @@ -0,0 +1,69 @@ +# Load necessary libraries +library(ggplot2) +library(readr) +library(dplyr) +library(plotly) + +# Function to create a Gantt chart with dots on short segments +create_gantt_chart <- function(csv_file, MIN_WIDTH, output_format = NULL) { + # Read the CSV file + df <- read_csv(csv_file) + + # Ensure start and end columns are treated as integers + df <- df %>% + mutate(start = as.integer(start), + end = as.integer(end)) + + # Calculate the segment width + df <- df %>% + mutate(width = end - start) + + # Sort the DataFrame by 'prio' column in descending order + df <- df %>% + arrange(prio) + + # Create the Gantt chart with ggplot2 + p <- ggplot(df, aes(x = start, xend = end, y = reorder(name, prio), yend = name)) + + geom_segment(aes(color = factor(prio)), size = 6) + + labs(title = "Gantt Chart", x = "Time Step", y = "Task", color = "Priority") + + theme_minimal() + + # Add dots on segments shorter than MIN_WIDTH + p <- p + geom_point(data = df %>% filter(width < MIN_WIDTH), + aes(x = start, y = name), + color = "red", size = 1) + + # Convert the ggplot object to a plotly object for interactivity + p_interactive <- ggplotly(p) + + # Handle output format + if (!is.null(output_format)) { + output_file <- sub("\\.csv$", paste0(".", output_format), csv_file) + if (output_format == "html") { + htmlwidgets::saveWidget(p_interactive, output_file) + } else if (output_format == "png") { + ggsave(output_file, plot = p, device = "png") + } else { + stop("Invalid output format. Use 'html' or 'png'.") + } + } else { + # Print the interactive Gantt chart + print(p_interactive) + } +} + +# Main execution +args <- commandArgs(trailingOnly = TRUE) +if (length(args) < 1 || length(args) > 2) { + stop("Usage: Rscript script.R [output_format]") +} else { + csv_file <- args[1] + if (length(args) == 2) { + output_format <- args[2] + } else { + output_format <- NULL + } +} + +MIN_WIDTH <- 100 # You can set your desired minimum width here +create_gantt_chart(csv_file, MIN_WIDTH, output_format)