first working

This commit is contained in:
Harvey Fong 2025-04-14 22:22:12 -06:00
parent 7d4d010075
commit eae7e19812
4 changed files with 277 additions and 3 deletions

View File

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2025 oomer Copyright (c) 2025 Harvey Fong
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -1,2 +1,45 @@
# poomer-efsw # poomer-efsw [Work in progress]
Prototype file monitoring and queuing Prototype cross-platform command line file monitoring and queuing
## Usage
poomer-efsw --watchdir:/tmp
poomer-efsw --watchdir:/tmp --ext:zip --ext:bsz
# Build
```
workdir/
├── build_engine_sdk/
├── oom/
├── efsw/
└── poomer-efsw/
```
## MacOS
Install Cmake to /Applications
```
curl -LO https://github.com/Kitware/CMake/releases/download/v3.31.6/cmake-3.31.6-macos-universal.dmg
open cmake-3.31.6-macos-universal.dmg
```
Download SDK for your OS and drag bella_engine_sdk into your workdir. On Windows rename unzipped folder by removing version ie bella_engine_sdk-24.6.0 -> bella_engine_sdk
- [bella_engine_sdk MacOS](https://downloads.bellarender.com/bella_engine_sdk-24.6.0.dmg)
- [bella_engine_sdk Linux](https://downloads.bellarender.com/bella_engine_sdk-24.6.0.tar.gz)
- [bella_engine_sdk Win](https://downloads.bellarender.com/bella_engine_sdk-24.6.0.zip)
```
mkdir workdir
cd workdir
git clone https://github.com/SpartanJ/efsw.git
mkdir -p efsw/build
cd efsw/build
/Applications/CMake.app/Contents/bin/cmake ..
make -j4
cd ../..
git clone https://github.com/oomer/oom.git
git clone https://github.com/oomer/poomer-efsw.git
cd poomer-efsw
make all -j4
```

124
makefile Normal file
View File

@ -0,0 +1,124 @@
BELLA_SDK_NAME = bella_engine_sdk
EXECUTABLE_NAME = poomer-efsw
PLATFORM = $(shell uname)
BUILD_TYPE ?= release# Default to release build if not specified
# Common paths
BELLA_SDK_PATH = ../bella_engine_sdk
LIBEFSW_PATH = ../efsw
OBJ_DIR = obj/$(PLATFORM)/$(BUILD_TYPE)
BIN_DIR = bin/$(PLATFORM)/$(BUILD_TYPE)
OUTPUT_FILE = $(BIN_DIR)/$(EXECUTABLE_NAME)
# Platform-specific configuration
ifeq ($(PLATFORM), Darwin)
# macOS configuration
SDK_LIB_EXT = dylib
EFSW_LIB_NAME = libefsw.$(SDK_LIB_EXT)
MACOS_SDK_PATH = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
# Compiler settings
CC = clang
CXX = clang++
# Architecture flags
ARCH_FLAGS = -arch arm64 -mmacosx-version-min=11.0 -isysroot $(MACOS_SDK_PATH)
# Linking flags - Use multiple rpath entries to look in executable directory
LINKER_FLAGS = $(ARCH_FLAGS) -framework Cocoa -framework IOKit -fvisibility=hidden -O5 \
-rpath @executable_path \
-rpath .
#-rpath @loader_path \
#-Xlinker -rpath -Xlinker @executable_path
else
# Linux configuration
SDK_LIB_EXT = so
EFSW_LIB_NAME = libefsw.$(SDK_LIB_EXT)
# Compiler settings
CC = gcc
CXX = g++
# Architecture flags
ARCH_FLAGS = -m64 -D_FILE_OFFSET_BITS=64
# Linking flags
LINKER_FLAGS = $(ARCH_FLAGS) -fvisibility=hidden -O3 -Wl,-rpath,'$$ORIGIN' -Wl,-rpath,'$$ORIGIN/lib' -weak_library $(LIBDIR)/libvulkan.dylib
# Platform-specific libraries
#PLIST_LIB = -lplist
endif
# Common include and library paths
INCLUDE_PATHS = -I$(BELLA_SDK_PATH)/src -I$(LIBEFSW_PATH)/include -I$(LIBEFSW_PATH)/src
SDK_LIB_PATH = $(BELLA_SDK_PATH)/lib
SDK_LIB_FILE = lib$(BELLA_SDK_NAME).$(SDK_LIB_EXT)
EFSW_LIB_PATH = $(LIBEFSW_PATH)/build
# Library flags
LIB_PATHS = -L$(SDK_LIB_PATH) -L$(EFSW_LIB_PATH)
LIBRARIES = -l$(BELLA_SDK_NAME) -lm -ldl -lefsw
# Build type specific flags
ifeq ($(BUILD_TYPE), debug)
CPP_DEFINES = -D_DEBUG -DDL_USE_SHARED
COMMON_FLAGS = $(ARCH_FLAGS) -fvisibility=hidden -g -O0 $(INCLUDE_PATHS)
else
CPP_DEFINES = -DNDEBUG=1 -DDL_USE_SHARED
COMMON_FLAGS = $(ARCH_FLAGS) -fvisibility=hidden -O3 $(INCLUDE_PATHS)
endif
# Language-specific flags
C_FLAGS = $(COMMON_FLAGS) -std=c17
CXX_FLAGS = $(COMMON_FLAGS) -std=c++17 -Wno-deprecated-declarations
# Objects
OBJECTS = $(EXECUTABLE_NAME).o
OBJECT_FILES = $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS))
# Build rules
$(OBJ_DIR)/$(EXECUTABLE_NAME).o: $(EXECUTABLE_NAME).cpp
@mkdir -p $(@D)
$(CXX) -c -o $@ $< $(CXX_FLAGS) $(CPP_DEFINES)
$(OUTPUT_FILE): $(OBJECT_FILES)
@mkdir -p $(@D)
$(CXX) -o $@ $(OBJECT_FILES) $(LINKER_FLAGS) $(LIB_PATHS) $(LIBRARIES)
@echo "Copying libraries to $(BIN_DIR)..."
@cp $(SDK_LIB_PATH)/$(SDK_LIB_FILE) $(BIN_DIR)/$(SDK_LIB_FILE)
@cp $(EFSW_LIB_PATH)/$(EFSW_LIB_NAME) $(BIN_DIR)/$(EFSW_LIB_NAME)
@echo "Build complete: $(OUTPUT_FILE)"
# Add default target
all: $(OUTPUT_FILE)
.PHONY: clean cleanall all
clean:
rm -f $(OBJ_DIR)/$(EXECUTABLE_NAME).o
rm -f $(OUTPUT_FILE)
rm -f $(BIN_DIR)/$(SDK_LIB_FILE)
rm -f $(BIN_DIR)/*.dylib
rmdir $(OBJ_DIR) 2>/dev/null || true
rmdir $(BIN_DIR) 2>/dev/null || true
cleanall:
rm -f obj/*/release/*.o
rm -f obj/*/debug/*.o
rm -f bin/*/release/$(EXECUTABLE_NAME)
rm -f bin/*/debug/$(EXECUTABLE_NAME)
rm -f bin/*/release/$(SDK_LIB_FILE)
rm -f bin/*/debug/$(SDK_LIB_FILE)
rm -f bin/*/release/*.dylib
rm -f bin/*/debug/*.dylib
rmdir obj/*/release 2>/dev/null || true
rmdir obj/*/debug 2>/dev/null || true
rmdir bin/*/release 2>/dev/null || true
rmdir bin/*/debug 2>/dev/null || true
rmdir obj/* 2>/dev/null || true
rmdir bin/* 2>/dev/null || true
rmdir obj 2>/dev/null || true
rmdir bin 2>/dev/null || true

107
poomer-efsw.cpp Normal file
View File

@ -0,0 +1,107 @@
#include <iostream>
#include <thread>
#include <chrono>
#include <filesystem>
#include <string>
#include <atomic>
#include "../bella_engine_sdk/src/bella_sdk/bella_engine.h" // For rendering
#include "../bella_engine_sdk/src/dl_core/dl_main.inl" // Core functionality from the Diffuse Logic engine
#include "../oom/oom_license.h" // common misc code
#include "../oom/oom_file.h" // common misc code
//==============================================================================
// GLOBAL VARIABLES AND FUNCTIONS
//==============================================================================
// Global flag to indicate program termination
std::atomic<bool> STOP(false);
// Signal handler for clean shutdown
void sigend(int) {
std::cout << std::endl << "Bye bye" << std::endl;
STOP = true;
// Give a short time for cleanup
std::this_thread::sleep_for(std::chrono::milliseconds(100));
exit(0); // Force exit after cleanup
}
//==============================================================================
// MAIN FUNCTION
//==============================================================================
int DL_main(dl::Args& args) {
args.add("wd", "watchdir", "", "watch directory for changes");
args.add("tp", "thirdparty", "", "prints third party licenses");
args.add("li", "licenseinfo", "", "prints license info");
std::string watchPath = ".";
// If --help was requested, print help and exit
if (args.helpRequested()) {
std::cout << args.help("poomer-efsw © 2025 Harvey Fong","", "1.0") << std::endl;
return 0;
}
// Handle other command-line options
if (args.have("--licenseinfo")) {
std::cout << "poomer-efsw © 2025 Harvey Fong" << std::endl;
std::cout << oom::license::printLicense() << std::endl;
return 0;
}
if (args.have("--thirdparty")) {
std::cout << oom::license::printBellaSDK() << "\n====\n" << std::endl;
std::cout << oom::license::printEFSW() << "\n====\n" << std::endl;
return 0;
}
if (args.have("--watchdir")) {
watchPath = args.value("--watchdir").buf();
}
// Set up signal handler for clean shutdown
signal(SIGINT, sigend);
// Create the file watcher to catch when .bsz files or zip files are created
oom::file::Watcher oomWatcher({"bsz", "zip"}, {"download"});
// Start watching the current directory
if (oomWatcher.startWatching(watchPath)) {
std::cout << "File watcher started" << std::endl;
} else {
std::cout << "Failed to start file watcher" << std::endl;
return 1;
}
// Main processing loop
while(!STOP) {
// Check for files to process
std::filesystem::path filePath;
// Check if we have files to delete
while (oomWatcher.getNextFileToDelete(filePath)) {
std::cout << "Processing deletion: " << filePath.string() << std::endl;
// Handle file deletion
// Add your deletion logic here
}
// Check if we have files to render
while (oomWatcher.getNextFileToRender(filePath)) {
std::cout << "Processing render: " << filePath.string() << std::endl;
// Handle file rendering
// Add your rendering logic here
}
// Sleep to avoid busy waiting
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
std::cout << "Running..." << std::endl;
}
// Clean shutdown
std::cout << "Shutting down file watcher..." << std::endl;
oomWatcher.stopWatching();
std::cout << "Shutdown complete" << std::endl;
return 0;
}