From db9b8cc9248463b9106d918c592f5683c120ba71 Mon Sep 17 00:00:00 2001 From: Nathan Date: Sat, 29 Mar 2025 15:37:27 -0500 Subject: [PATCH] make entryPoint a header --- flake.nix | 47 +++++++++++-------- include/Archimedes.h | 2 + include/entryPoint.h | 9 ++++ {src => include}/pch.hpp | 0 include/utils/GuiModule/GuiModule.h | 4 +- .../example_apps}/MinimalApp/MinimalApp.cpp | 0 .../example_apps}/MinimalApp/MinimalApp.h | 0 src/main.cpp | 7 --- 8 files changed, 40 insertions(+), 29 deletions(-) create mode 100644 include/entryPoint.h rename {src => include}/pch.hpp (100%) rename {example_apps => src/example_apps}/MinimalApp/MinimalApp.cpp (100%) rename {example_apps => src/example_apps}/MinimalApp/MinimalApp.h (100%) delete mode 100644 src/main.cpp diff --git a/flake.nix b/flake.nix index ee5a199..eaaa8cd 100755 --- a/flake.nix +++ b/flake.nix @@ -18,32 +18,38 @@ pkgs = import nixpkgs { inherit system; }; in { - Archimedes = pkgs.stdenvNoCC.mkDerivation { + Archimedes = { + examples = { + minimal = pkgs.stdenvNoCC.mkDerivation { - name = "Archimedes"; + name = "Archimedes"; - src = ./.; + src = ./.; - nativeBuildInputs = with pkgs; [ - clang - ]; + nativeBuildInputs = with pkgs; [ + clang + ]; - /*buildInputs = with pkgs; [ - ];*/ + /*buildInputs = with pkgs; [ + ];*/ - buildPhase = '' - clang++ \ - src/*.cpp \ - -I src -I include \ - -Wall \ - -o $name - ''; + buildPhase = '' + clang++ \ + src/*.cpp \ + example_apps/MinimalApp/MinimalApp.cpp \ + include/utils/App/*.cpp \ + -I src -I include \ + -Wall \ + -o $name + ''; - installPhase = '' - mkdir -p $out/bin - cp $name $out/bin - ''; + installPhase = '' + mkdir -p $out/bin + cp $name $out/bin + ''; + }; + }; }; TestMenu = pkgs.stdenvNoCC.mkDerivation { @@ -85,10 +91,11 @@ buildPhase = '' clang++ \ modules/Print/src/*.cpp \ - utils/App/App.cpp \ + include/utils/App/App.cpp \ -fpic -shared \ -I src -I include \ -Wall \ + -DGUIMODULE_H \ -o $name ''; diff --git a/include/Archimedes.h b/include/Archimedes.h index 8560f5a..5734b7d 100644 --- a/include/Archimedes.h +++ b/include/Archimedes.h @@ -5,4 +5,6 @@ #include "utils/GuiModule/GuiModule.h" #include "utils/App/App.h" +#include "entryPoint.h" + #endif diff --git a/include/entryPoint.h b/include/entryPoint.h new file mode 100644 index 0000000..3213dbc --- /dev/null +++ b/include/entryPoint.h @@ -0,0 +1,9 @@ +#ifdef APP_TYPE + +int main(int argc, char* argv[]) { + APP_TYPE app; + app.handleArgs(argc, argv); + app.run(); +} + +#endif diff --git a/src/pch.hpp b/include/pch.hpp similarity index 100% rename from src/pch.hpp rename to include/pch.hpp diff --git a/include/utils/GuiModule/GuiModule.h b/include/utils/GuiModule/GuiModule.h index f90a12f..5fcb1b5 100644 --- a/include/utils/GuiModule/GuiModule.h +++ b/include/utils/GuiModule/GuiModule.h @@ -1,5 +1,5 @@ -#ifndef GUIMODULE_H -#define GUIMODULE_H +#ifdef GUIMODULE +#undef GUIMODULE #include "utils/Module/Module.h" #include "utils/Window/Window.h" diff --git a/example_apps/MinimalApp/MinimalApp.cpp b/src/example_apps/MinimalApp/MinimalApp.cpp similarity index 100% rename from example_apps/MinimalApp/MinimalApp.cpp rename to src/example_apps/MinimalApp/MinimalApp.cpp diff --git a/example_apps/MinimalApp/MinimalApp.h b/src/example_apps/MinimalApp/MinimalApp.h similarity index 100% rename from example_apps/MinimalApp/MinimalApp.h rename to src/example_apps/MinimalApp/MinimalApp.h diff --git a/src/main.cpp b/src/main.cpp deleted file mode 100644 index bed3777..0000000 --- a/src/main.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "pch.hpp" -#include "utils/App/App.h" - -int main(int argc, char* argv[]) { - Archimedes::App app(argc, argv); - app.run(); -}