adde Makefile

This commit is contained in:
Geir Okkenhaug Jerstad 2024-08-18 11:55:13 +02:00
parent 719a91ab24
commit 22391994a3
6 changed files with 50 additions and 25 deletions

View file

@ -1 +1 @@
flake-profile-1-link flake-profile-18-link

View file

@ -1 +0,0 @@
/nix/store/ml5jibqk9rhd8gfps532ry58njp2j5sd-nix-shell-env

View file

@ -0,0 +1 @@
/nix/store/d9kjbddwp2dsiwpvdvmaff9lpgy5rhsv-nix-shell-env

View file

@ -1,23 +1,37 @@
{ {
description = "A Nix-flake-based Guile development environment"; description = "A Nix-flake-based C/C++ development environment";
inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz"; inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz";
outputs = { self, nixpkgs }: outputs = { self, nixpkgs }:
let let
supportedSystems = supportedSystems = [ "x86_64-linux" ];
[ "x86_64-linux" ]; forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
forEachSupportedSystem = f: pkgs = import nixpkgs { inherit system; };
nixpkgs.lib.genAttrs supportedSystems });
(system: f { pkgs = import nixpkgs { inherit system; }; }); in
in { {
devShells = forEachSupportedSystem ({ pkgs }: { devShells = forEachSupportedSystem ({ pkgs }: {
default = pkgs.mkShell { default = pkgs.mkShell.override
packages = with pkgs; [ {
gnuplot # Override stdenv in order to change compiler:
guile stdenv = pkgs.clangStdenv;
gcc }
]; {
}; packages = with pkgs; [
clang-tools
cmake
codespell
conan
cppcheck
doxygen
gtest
lcov
vcpkg
vcpkg-tool
] ++ (if system == "aarch64-darwin" then [ ] else [ gdb ]);
};
}); });
}; };
} }

Binary file not shown.

View file

@ -24,7 +24,7 @@ start_gnuplot() {
if (!pid) { if (!pid) {
dup2 (pipes[0], STDIN_FILENO); dup2 (pipes[0], STDIN_FILENO);
execlp ("gnuplot", NULL); execlp ("gnuplot", NULL);
return; /* Not reached. */ return 0; /* Not reached. */
} }
output = fdopen(pipes[1], "w"); output = fdopen(pipes[1], "w");
@ -51,14 +51,6 @@ static void tortoise_reset () {
fprintf(global_output, "clear\n"); fprintf(global_output, "clear\n");
fflush(global_output); fflush(global_output);
} }
int main(int argc, char *argv[]) {
global_output = start_gnuplot();
tortoise_reset ();
return EXIT_SUCCESS;
}
static void draw_line(FILE *output, double x1, double y1, double x2, static void draw_line(FILE *output, double x1, double y1, double x2,
double y2) { double y2) {
fprintf(output, "plot [0:1] %f + %f * t, %f + %f * t notitle\n", fprintf(output, "plot [0:1] %f + %f * t, %f + %f * t notitle\n",
@ -74,6 +66,11 @@ static void tortoise_penup() {
pendown = 0; pendown = 0;
} }
static void tortoise_turn (double degrees)
{
direction += M_PI / 180.0 * degrees;
}
static void tortoise_move(double length) { static void tortoise_move(double length) {
double newX, newY; double newX, newY;
@ -86,3 +83,17 @@ static void tortoise_move(double length) {
x = newX; x = newX;
y = newY; y = newY;
} }
int main(int argc, char *argv[]) {
global_output = start_gnuplot();
tortoise_reset ();
int i;
tortoise_pendown();
for (i = 1; i <= 4; ++i) {
tortoise_move(3.0);
tortoise_turn(90.0);
};
return EXIT_SUCCESS;
}