diff --git a/.gitignore b/.gitignore index 03d24c5..ea8c4bf 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -libraylib.a +/target diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 4219e8c..0000000 --- a/.gitmodules +++ /dev/null @@ -1,6 +0,0 @@ -[submodule "3rdparty/raylib"] - path = 3rdparty/raylib - url = https://github.com/raysan5/raylib -[submodule "3rdparty/raygui"] - path = 3rdparty/raygui - url = https://github.com/raysan5/raygui.git diff --git a/3rdparty/raygui b/3rdparty/raygui deleted file mode 160000 index 865bb29..0000000 --- a/3rdparty/raygui +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 865bb293764073c01e74314ef647464f1f10fd96 diff --git a/3rdparty/raylib b/3rdparty/raylib deleted file mode 160000 index ca12ef4..0000000 --- a/3rdparty/raylib +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ca12ef48e9e9f4eae03b1ca43ec3eb0a78d63dd3 diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..da7da67 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "doggo" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..0eb72ca --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "doggo" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/build.zig b/build.zig deleted file mode 100644 index bf46761..0000000 --- a/build.zig +++ /dev/null @@ -1,49 +0,0 @@ -const std = @import("std"); -const raylib = @import("./3rdparty/raylib/src/build.zig"); - -pub fn build(b: *std.build.Builder) void { - // Standard target options allows the person running `zig build` to choose - // what target to build for. Here we do not override the defaults, which - // means any target is allowed, and the default is native. Other options - // for restricting supported target set are available. - const target = b.standardTargetOptions(.{}); - - // Standard release options allow the person running `zig build` to select - // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. - const mode = b.standardReleaseOptions(); - - const exe = b.addExecutable("doggo", "src/main.zig"); - exe.setTarget(target); - - const ray = raylib.addRaylib(b, exe.target); - exe.linkLibrary(ray); - exe.addIncludeDir("3rdparty/raylib/src"); - exe.addIncludeDir("3rdparty/raygui/src"); - exe.addIncludeDir("3rdparty/raygui/examples"); - const raylib_flags = &[_][]const u8{ - "-std=gnu99", - "-DPLATFORM_DESKTOP", - "-DGL_SILENCE_DEPRECATION=199309L", - "-fno-sanitize=undefined", - }; - exe.addCSourceFile("src/raylib.c", raylib_flags); - - exe.setBuildMode(mode); - exe.install(); - - const run_cmd = exe.run(); - run_cmd.step.dependOn(b.getInstallStep()); - if (b.args) |args| { - run_cmd.addArgs(args); - } - - const run_step = b.step("run", "Run the app"); - run_step.dependOn(&run_cmd.step); - - const exe_tests = b.addTest("src/main.zig"); - exe_tests.setTarget(target); - exe_tests.setBuildMode(mode); - - const test_step = b.step("test", "Run unit tests"); - test_step.dependOn(&exe_tests.step); -} diff --git a/flake.lock b/flake.lock index 79a3116..7112d9a 100644 --- a/flake.lock +++ b/flake.lock @@ -1,23 +1,63 @@ { "nodes": { + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1712211755, + "narHash": "sha256-KIJA4OvXFDXEeu7wstFDCxqZEfjaPQIowpzNww48TUw=", + "owner": "nix-community", + "repo": "fenix", + "rev": "39763c6e23a8423af316b85a74bad0cc5bc88d86", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1651369430, - "narHash": "sha256-d86uUm0s11exU9zLo2K1AwtJQJDKubFpoF0Iw767uT4=", + "lastModified": 1712163089, + "narHash": "sha256-Um+8kTIrC19vD4/lUCN9/cU9kcOsD1O1m+axJqQPyMM=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b283b64580d1872333a99af2b4cef91bb84580cf", + "rev": "fd281bd6b7d3e32ddfa399853946f782553163b5", "type": "github" }, "original": { "id": "nixpkgs", + "ref": "nixos-unstable", "type": "indirect" } }, "root": { "inputs": { + "fenix": "fenix", "nixpkgs": "nixpkgs" } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1712156296, + "narHash": "sha256-St7ZQrkrr5lmQX9wC1ZJAFxL8W7alswnyZk9d1se3Us=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "8e581ac348e223488622f4d3003cb2bd412bf27e", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index bd43ca3..b458c0f 100644 --- a/flake.nix +++ b/flake.nix @@ -1,41 +1,32 @@ { description = "Doggo flake"; + + inputs = { + fenix = { + url = "github:nix-community/fenix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + nixpkgs.url = "nixpkgs/nixos-unstable"; + }; - outputs = { self, nixpkgs }: + outputs = { self, fenix, nixpkgs }: let pkgs = nixpkgs.legacyPackages.x86_64-linux; - - # godot-alpha = (with pkgs; stdenv.mkDerivation { - # pname = "godot-alpha"; - # version = "4.0.0-a8"; - # src = fetchzip { - # url = "https://downloads.tuxfamily.org/godotengine/4.0/alpha8/Godot_v4.0-alpha8_linux.64.zip"; - # hash = "sha512-qkUpt1reFgVDt5u9zLHYLoJAzC0D/YdtNpQhWLarpTW0e+Vzlqy7kna2plIeddybNsn+tS+QqTmYJExA7aT3zw=="; - # }; - # installPhase = '' - # mkdir -p $out/bin - # mv Godot_v4.0-alpha8_linux.64 $out/bin/godot-v4-alpha - # ''; - # }); in { - devShell.x86_64-linux = with pkgs; - mkShell { - buildInputs = [ - just - # zig - # godot - # godot-alpha - # - # xorg.libX11 - # xorg.libXcursor - # xorg.libXi - # xorg.libXext - # xorg.libXrandr - # xorg.libXinerama - # libGL - # libGLU - ]; - }; + mkShell { + nativeBuildInputs = [ + just + (fenix.packages.x86_64-linux.fromToolchainFile { + dir = ./.; + sha256 = "sha256-3St/9/UKo/6lz2Kfq2VmlzHyufduALpiIKaaKX4Pq0g="; + }) + ]; + + buildInputs = [ + ]; + }; + + formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt; }; } diff --git a/godot-impl/Main.gd b/godot-impl/Main.gd deleted file mode 100644 index fa44d4d..0000000 --- a/godot-impl/Main.gd +++ /dev/null @@ -1,26 +0,0 @@ -extends Control - - -# Called when the node enters the scene tree for the first time. -func _ready(): - $HTTPRequest.connect("request_completed", self._on_request_completed) - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta): - var bodySize = $HTTPRequest.get_body_size() - var downloadedBytes = $HTTPRequest.get_downloaded_bytes() - - var percent = downloadedBytes * 100 / bodySize - $Label.text = "Progress: %d %%" % percent - pass - -func download_cpp_dap(): - var url = "https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.0/clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz" - $HTTPRequest.download_file = "user://lldb.tar.xz" - $HTTPRequest.request(url) - - -func _on_request_completed(result, response_code, headers, body): -# TODO: decompress archive -# OS.execute("") - pass diff --git a/godot-impl/Main.tscn b/godot-impl/Main.tscn deleted file mode 100644 index d2c0b76..0000000 --- a/godot-impl/Main.tscn +++ /dev/null @@ -1,27 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://cirquj62osi4v"] - -[ext_resource type="Script" path="res://Main.gd" id="1_6lnje"] - -[node name="Control" type="Control"] -anchor_right = 1.0 -anchor_bottom = 1.0 -script = ExtResource( "1_6lnje" ) - -[node name="Button" type="Button" parent="."] -offset_left = 148.0 -offset_top = 70.0 -offset_right = 296.0 -offset_bottom = 162.0 -text = "Download C++ DAP (lldb)" - -[node name="HTTPRequest" type="HTTPRequest" parent="."] -use_threads = true - -[node name="Label" type="Label" parent="."] -offset_left = 359.0 -offset_top = 90.0 -offset_right = 598.0 -offset_bottom = 136.0 -text = "Progress: 0%" - -[connection signal="pressed" from="Button" to="." method="download_cpp_dap"] diff --git a/godot-impl/icon.png b/godot-impl/icon.png deleted file mode 100644 index 836bc8b..0000000 Binary files a/godot-impl/icon.png and /dev/null differ diff --git a/godot-impl/icon.png.import b/godot-impl/icon.png.import deleted file mode 100644 index f57c70d..0000000 --- a/godot-impl/icon.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://dda5wstjh822x" -path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://icon.png" -dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"] - -[params] - -compress/mode=0 -compress/lossy_quality=0.7 -compress/hdr_compression=1 -compress/bptc_ldr=0 -compress/normal_map=0 -compress/channel_pack=0 -mipmaps/generate=false -mipmaps/limit=-1 -roughness/mode=0 -roughness/src_normal="" -process/fix_alpha_border=true -process/premult_alpha=false -process/normal_map_invert_y=false -process/hdr_as_srgb=false -process/hdr_clamp_exposure=false -process/size_limit=0 -detect_3d/compress_to=1 diff --git a/godot-impl/project.godot b/godot-impl/project.godot deleted file mode 100644 index 1852a43..0000000 --- a/godot-impl/project.godot +++ /dev/null @@ -1,16 +0,0 @@ -; Engine configuration file. -; It's best edited using the editor UI and not directly, -; since the parameters that go here are not all obvious. -; -; Format: -; [section] ; section goes between [] -; param=value ; assign values to parameters - -config_version=5 - -[application] - -config/name="Doggo" -run/main_scene="res://Main.tscn" -config/icon="res://icon.png" -config/features=PackedStringArray("4.0", "Vulkan Clustered") diff --git a/justfile b/justfile index 4867e8c..c2d78d2 100644 --- a/justfile +++ b/justfile @@ -1,21 +1,7 @@ -godot_project := "./godot-impl/project.godot" -godot_url := "https://downloads.tuxfamily.org/godotengine/4.0/alpha8/Godot_v4.0-alpha8_linux.64.zip" -godot_exe := "Godot_v4.0-alpha8_linux.64" -godot_exe_dir := "~/bin" -godot_path := godot_exe_dir + "/" + godot_exe +alias b := build +build: + cargo build -setup: - #!/usr/bin/env bash - set -euo pipefail - if [ ! -e {{godot_path}} ]; then - curl {{godot_url}} -O - unzip Godot*.zip - mv {{godot_exe}} {{godot_exe_dir}} - rm Godot*.zip - fi - -#run: -# nixGL zig build run - -edit: setup - {{godot_exe}} {{godot_project}} +alias r := run +run: + cargo run diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..02cb8fc --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "stable" +profile = "default" diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/src/main.zig b/src/main.zig deleted file mode 100644 index 9b4a4bc..0000000 --- a/src/main.zig +++ /dev/null @@ -1,40 +0,0 @@ -const std = @import("std"); -const r = @import("raylib.zig"); - -pub fn main() anyerror!void { - r.InitWindow(800, 450, "doggo"); - defer r.CloseWindow(); - - // var selected_filename: [512]u8 = undefined; - var file_dialog_state = r.InitGuiFileDialog(420, 310, r.GetWorkingDirectory(), false); - - while (!r.WindowShouldClose()) { - // Update - if (file_dialog_state.SelectFilePressed) { - std.log.info("{s} / {s}", .{ file_dialog_state.dirPathText, file_dialog_state.fileNameText }); - } - - // Draw - r.BeginDrawing(); - defer r.EndDrawing(); - - r.ClearBackground(r.RAYWHITE); - r.DrawText("Congrats! You created your first window!", 190, 200, 20, r.LIGHTGRAY); - - if (file_dialog_state.fileDialogActive) { - r.GuiLock(); - } - - if (r.GuiButton(r.Rectangle{ .x = 190, .y = 250, .width = 150, .height = 30 }, "Button")) { - std.log.info("Button pressed", .{}); - file_dialog_state.fileDialogActive = true; - } - r.GuiUnlock(); - - r.GuiFileDialog(&file_dialog_state); - } -} - -test "basic test" { - try std.testing.expectEqual(10, 3 + 7); -} diff --git a/src/raylib.c b/src/raylib.c deleted file mode 100644 index 0dec298..0000000 --- a/src/raylib.c +++ /dev/null @@ -1,6 +0,0 @@ -#define RAYGUI_IMPLEMENTATION -#include -#undef RAYGUI_IMPLEMENTATION // Avoid including raygui implementation again - -#define GUI_FILE_DIALOG_IMPLEMENTATION -#include diff --git a/src/raylib.zig b/src/raylib.zig deleted file mode 100644 index 78660e4..0000000 --- a/src/raylib.zig +++ /dev/null @@ -1,5 +0,0 @@ -pub usingnamespace @cImport({ - @cInclude("raylib.h"); - @cInclude("raygui.h"); - @cInclude("custom_file_dialog/gui_file_dialog.h"); -});