now trying to build

This commit is contained in:
2025-03-14 15:06:27 -05:00
parent bc09e0d79b
commit a8dff07bf1
7 changed files with 86 additions and 29 deletions

View File

@@ -1,5 +1,5 @@
{
description = "Build Project X-001";
description = "Build Project Archimedes";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
@@ -9,23 +9,21 @@
};
};
outputs = { self, nixpkgs, imgui }@inputs: let
outputs = { self, nixpkgs, imgui }: let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
in {
packages.${system}.default = pkgs.stdenv.mkDerivation {
Archimedes = pkgs.stdenv.mkDerivation {
name = "Engine";
name = "Archimedes";
src = ./src;
imgui = inputs.imgui;
#imgui = inputs.imgui;
buildInputs = with pkgs; [
vulkan-headers
vulkan-loader
];
/*buildInputs = with pkgs; [
];*/
buildPhase = ''
g++ *.cpp -o $name
@@ -38,26 +36,48 @@
};
shaders = pkgs.stdenv.mkDerivation {
TestMenu = pkgs.stdenv.mkDerivation {
name = "Engine";
name = "TestMenu";
src = ./modules/shaders;
src = ./.;
buildInputs = with pkgs; [
shaderc
];
/*buildInputs = with pkgs; [
];*/
buildPhase = ''
glslc *.vert -o vert.spv
glslc *.frag -o frag.spv
'';
g++ modules/testMenu/src/*.cpp -fpic -shared -I src -o $name
'';
installPhase = ''
mkdir -p $out/bin
cp *.spv $out/bin
cp $name $out/bin
'';
};
Print = pkgs.stdenv.mkDerivation {
name = "Print";
src = ./.;
/*buildInputs = with pkgs; [
];*/
buildPhase = ''
g++ modules/print/src/*.cpp -fpic -shared -I src -I include -o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
packages.${system}.default = self.Archimedes;
};
}

View File

@@ -0,0 +1,15 @@
#include "print.h"
Print::Print(void* h) {
handle = h;
name = "Print";
}
Print::~Print() {
std::cout << "Print Destroyed!\n";
}
void Print::run() {
std::cout << "Print lib loaded and run!\n";
App::Get().unload(self);
}

16
modules/print/src/print.h Normal file
View File

@@ -0,0 +1,16 @@
#include "../../../include/Archimedes.h"
class Print : public Module {
public:
Print(void*);
~Print();
void run();
};
extern "C" {
Module* create(void* handle) {
return new Print(handle);
}
}

View File

@@ -2,6 +2,7 @@
TestMenu::TestMenu(void* h) {
handle = h;
name = "TestMenu";
}
TestMenu::~TestMenu() {

View File

@@ -50,23 +50,23 @@ void App::load(std::string lib) {
}
Module::create_t* create = (Module::create_t*) dlsym(handle, "create");
if(dlerror()) {
std::cout << "error finding create function in file: " << lib << std::endl;
}
Module::destroy_t* destroy = (Module::destroy_t*) dlsym(handle, "destroy");
if(dlerror()) {
std::cout << "error finding destroy function in file: " << lib << std::endl;
}
Module* m = create(handle);
for(auto it = modules.begin(); it != modules.end(); it++) {
if((*it)->getName() != "") {
if((*it)->getName() != m->getName()) {
std::cout << "Module \"" << m->getName() << "\" is already loaded!\n";
return;
}
}
m->setSelf(modules.end());
modules.push_back(m);
}
void App::unload(std::list<Module*>::iterator it) {
@@ -78,15 +78,15 @@ void App::unload(std::list<Module*>::iterator it) {
void App::handleArgs(const int& argc, char* argv[]) {
int i = 0;
int i = 1;
if(argc == 0) {
if(argc == 1) {
printHelp();
end();
}
while(i < argc) {
if(strcmp(argv[i], "-h") == 0) {
if(strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) {
printHelp();
end();
} else {

View File

@@ -14,6 +14,8 @@ class Module {
virtual void run() = 0;
std::string getName() const { return name; }
void* getHandle() { return handle; }
void setSelf(std::list<Module*>::iterator s) { self = s; }
protected:
std::string name;

View File

@@ -5,6 +5,9 @@
#include <cstring>
#include <list>
//#include <chrono>
//#include <thread>
#include <dlfcn.h>
#endif