diff --git a/Makefile b/Makefile index 17eaed7..d17e416 100644 --- a/Makefile +++ b/Makefile @@ -3,96 +3,78 @@ PREFIX ?= $(HOME)/.local BINDIR := $(PREFIX)/bin LIBDIR := $(PREFIX)/lib -INCDIR := $(PREFIX)/include CONFIG_DIR ?= $(HOME)/.config/ollie DATA_DIR ?= $(HOME)/.local/share/ollie +BUILD_DIR := build JOBS ?= $(shell nproc 2>/dev/null || echo 2) -.PHONY: all build build-kf5 core gofmt ninep client tools kde kde-kf5 \ - install install-kf5 install-data test test-core test-9p clean help +.PHONY: all build go tools kde install install-data test clean uninstall help -all: build install +# Build everything, run tests, then install +all: build test install -build: core ninep client tools kde -build-kf5: core ninep client kde-kf5 +# Build all components to $(BUILD_DIR), no install +build: go tools kde -core: - go build ./... +# Go binaries: olliesrv, ollie-9p, toolsrv +go: + mkdir -p $(BUILD_DIR)/bin $(BUILD_DIR)/tools + go build -o $(BUILD_DIR)/bin/olliesrv ./cmd/olliesrv/ + go build -o $(BUILD_DIR)/bin/ollie-9p ./cmd/ollie-9p/ + go build -ldflags="-s -w" -o $(BUILD_DIR)/tools/toolsrv ./cmd/toolsrv/ -gofmt: - gofmt -w $$(find . -name '*.go' -not -path './vendor/*') - -ninep: - mkdir -p $(BINDIR) - go build -o $(BINDIR)/olliesrv ./cmd/olliesrv/ - go build -o $(BINDIR)/ollie-9p ./cmd/ollie-9p/ - -client: - mkdir -p $(LIBDIR) $(INCDIR) - cd kde/lib9p && go build -buildmode=c-shared -o libollie9p.so - install -m755 kde/lib9p/libollie9p.so $(LIBDIR)/libollie9p.so - install -m644 kde/lib9p/libollie9p.h $(INCDIR)/libollie9p.h - -tools: - mkdir -p $(CONFIG_DIR)/tools - go build -ldflags="-s -w" -o $(CONFIG_DIR)/tools/toolsrv ./cmd/toolsrv/ - go build -ldflags="-s -w" -o $(CONFIG_DIR)/tools/codeintel ./tools/codeintel/ - go build -ldflags="-s -w" -o $(CONFIG_DIR)/tools/filetools ./tools/filetools/ - go build -ldflags="-s -w" -o $(CONFIG_DIR)/tools/lsptools ./tools/lsp/ - go build -ldflags="-s -w" -o $(CONFIG_DIR)/tools/web_fetch ./tools/web/cmd/web_fetch/ - cd $(CONFIG_DIR)/tools && for name in code_outline code_query code_rewrite code_symbols code_dependencies codebase_overview; do \ +# Compiled tools + script tools +tools: go + go build -ldflags="-s -w" -o $(BUILD_DIR)/tools/codeintel ./tools/codeintel/ + go build -ldflags="-s -w" -o $(BUILD_DIR)/tools/filetools ./tools/filetools/ + go build -ldflags="-s -w" -o $(BUILD_DIR)/tools/lsptools ./tools/lsp/ + go build -ldflags="-s -w" -o $(BUILD_DIR)/tools/web_fetch ./tools/web/cmd/web_fetch/ + cd $(BUILD_DIR)/tools && for name in code_outline code_query code_rewrite code_symbols code_dependencies codebase_overview; do \ ln -sf codeintel $$name; \ done - cd $(CONFIG_DIR)/tools && for name in file_read file_write file_edit file_grep file_glob; do \ + cd $(BUILD_DIR)/tools && for name in file_read file_write file_edit file_grep file_glob; do \ ln -sf filetools $$name; \ done - cd $(CONFIG_DIR)/tools && for name in lsp_hover lsp_definition lsp_references lsp_completion lsp_diagnostics lsp_symbols lsp_rename; do \ + cd $(BUILD_DIR)/tools && for name in lsp_hover lsp_definition lsp_references lsp_completion lsp_diagnostics lsp_symbols lsp_rename; do \ ln -sf lsptools $$name; \ done - install -m644 data/tools/*.meta $(CONFIG_DIR)/tools/ - for f in data/tools/*; do [ -f "$$f" ] && [ -x "$$f" ] && install -m755 "$$f" $(CONFIG_DIR)/tools/; done; true - cp -a data/tools/_lib $(CONFIG_DIR)/tools/ + cp data/tools/*.meta $(BUILD_DIR)/tools/ + for f in data/tools/*; do [ -f "$$f" ] && [ -x "$$f" ] && cp "$$f" $(BUILD_DIR)/tools/; done; true + cp -a data/tools/_lib $(BUILD_DIR)/tools/ +# KDE components (auto-detects KF6/KF5, builds lib9p internally) kde: - @rm -f kde/build/.ollie-built - @if cmake -S kde -B kde/build -DCMAKE_INSTALL_PREFIX=$(PREFIX); then \ - if cmake --build kde/build -j$(JOBS); then \ - touch kde/build/.ollie-built; \ - else \ - echo "KDE build failed" >&2; \ - exit 1; \ - fi; \ + @if cmake -S kde -B kde/build -DCMAKE_INSTALL_PREFIX=$(PREFIX) 2>/dev/null; then \ + cmake --build kde/build -j$(JOBS) || { echo "KDE build failed" >&2; exit 1; }; \ else \ - rm -f kde/build/.ollie-built; \ echo "KDE dependencies not available; skipping KDE build"; \ fi -kde-kf5: - cmake -S kde -B kde/build-kf5 -DOLLIE_KF5=ON -DCMAKE_INSTALL_PREFIX=$(PREFIX) - cmake --build kde/build-kf5 -j$(JOBS) +# Run tests (does not install anything) +test: + go test ./... -install: build test install-data - @if test -f kde/build/.ollie-built; then \ +# Install everything from build dir +install: install-data + mkdir -p $(BINDIR) $(LIBDIR) + install -m755 $(BUILD_DIR)/bin/olliesrv $(BINDIR)/olliesrv + install -m755 $(BUILD_DIR)/bin/ollie-9p $(BINDIR)/ollie-9p + mkdir -p $(CONFIG_DIR)/tools + cp -a $(BUILD_DIR)/tools/. $(CONFIG_DIR)/tools/ + @if [ -d kde/build ] && cmake --build kde/build --target help 2>/dev/null | grep -q install; then \ cmake --install kde/build; \ install -Dm644 kde/gui/org.ollie.gui.desktop $(PREFIX)/share/applications/org.ollie.gui.desktop; \ install -Dm644 kde/gui/ollie.svg $(PREFIX)/share/icons/hicolor/scalable/apps/ollie.svg; \ - install -Dm755 kde/dolphin/ollie-actions.desktop $(PREFIX)/share/kio/servicemenus/ollie-actions.desktop; \ + install -Dm755 kde/dolphin/ollie-actions.desktop $(PREFIX)/share/kio/servicemenus/ollie-actions.desktop 2>/dev/null || \ + install -Dm755 kde/dolphin/ollie-actions-kf5.desktop $(PREFIX)/share/kio/servicemenus/ollie-actions.desktop; \ install -Dm755 kde/dolphin/ollie-ask $(BINDIR)/ollie-ask; \ install -Dm755 kde/dolphin/ollie-session-here $(BINDIR)/ollie-session-here; \ - else \ - echo "KDE build not available; skipping KDE install"; \ + install -m755 kde/lib9p/libollie9p.so $(LIBDIR)/libollie9p.so; \ fi -install-kf5: build-kf5 test install-data - cmake --install kde/build-kf5 - install -Dm644 kde/gui/org.ollie.gui.desktop $(PREFIX)/share/applications/org.ollie.gui.desktop - install -Dm644 kde/gui/ollie.svg $(PREFIX)/share/icons/hicolor/scalable/apps/ollie.svg - install -Dm755 kde/dolphin/ollie-actions-kf5.desktop $(PREFIX)/share/kio/servicemenus/ollie-actions.desktop - install -Dm755 kde/dolphin/ollie-ask $(BINDIR)/ollie-ask - install -Dm755 kde/dolphin/ollie-session-here $(BINDIR)/ollie-session-here - +# Install data files (agents, prompts, skills, workflows, scripts) install-data: - mkdir -p $(CONFIG_DIR)/agents $(CONFIG_DIR)/prompts $(CONFIG_DIR)/skills $(CONFIG_DIR)/tools $(CONFIG_DIR)/workflows $(CONFIG_DIR)/optmem + mkdir -p $(CONFIG_DIR)/agents $(CONFIG_DIR)/prompts $(CONFIG_DIR)/skills $(CONFIG_DIR)/workflows $(CONFIG_DIR)/optmem @test -f $(CONFIG_DIR)/backends.conf || install -Dm600 data/backends.conf $(CONFIG_DIR)/backends.conf install -Dm755 third_party/optmem/memo $(CONFIG_DIR)/optmem/memo cp -a data/agents/. $(CONFIG_DIR)/agents/ @@ -104,25 +86,36 @@ install-data: install -Dm755 data/scripts/logseq-cli $(BINDIR)/logseq-cli install -Dm755 data/scripts/o $(BINDIR)/o -# The GUI/KDE build is intentionally delegated to kde/CMakeLists.txt. It -# detects KF6 first and falls back to KF5; kde-kf5 forces the KF5 path. -test: test-core test-9p - -test-core: - go test ./cmd/olliesrv/... ./cmd/toolsrv/... ./log/... ./toolsrv/... ./util/... ./tools/... - -test-9p: - go test ./cmd/ollie-9p/... ./kde/lib9p/... +# Remove installed files +uninstall: + rm -f $(BINDIR)/olliesrv $(BINDIR)/ollie-9p + rm -f $(BINDIR)/ollie-gui $(BINDIR)/ollie-ask $(BINDIR)/ollie-session-here + rm -f $(BINDIR)/ollie-remount $(BINDIR)/logseq-cli $(BINDIR)/o + rm -f $(LIBDIR)/libollie9p.so + rm -f $(PREFIX)/share/applications/org.ollie.gui.desktop + rm -f $(PREFIX)/share/icons/hicolor/scalable/apps/ollie.svg + rm -f $(PREFIX)/share/kio/servicemenus/ollie-actions.desktop + rm -rf $(CONFIG_DIR)/tools + @echo "Note: $(CONFIG_DIR)/{agents,prompts,skills,workflows,backends.conf} preserved" + @echo " Remove manually if desired: rm -rf $(CONFIG_DIR)" +# Remove build artifacts clean: + rm -rf $(BUILD_DIR) + rm -rf kde/build + rm -f kde/lib9p/libollie9p.so kde/lib9p/libollie9p.h go clean ./... - rm -rf kde/build kde/build-kf5 help: - @echo 'make Build and install (automatic KF6/KF5 detection)' - @echo 'make build Build without installing' - @echo 'make kde Build KDE using automatic detection' - @echo 'make kde-kf5 Build KDE against KF5/Qt5' - @echo 'make test Run tests' - @echo 'make install Install the automatic-detection build' - @echo 'make clean Remove build artifacts' + @echo 'Targets:' + @echo ' make Build, test, and install' + @echo ' make build Build without installing' + @echo ' make test Run tests' + @echo ' make install Install (requires build first)' + @echo ' make uninstall Remove installed files' + @echo ' make clean Remove build artifacts' + @echo '' + @echo 'Components:' + @echo ' make go Build Go binaries (olliesrv, ollie-9p, toolsrv)' + @echo ' make tools Build compiled tools' + @echo ' make kde Build KDE components (auto-detects KF6/KF5)' diff --git a/kde/CMakeLists.txt b/kde/CMakeLists.txt index 334d48e..8dc6930 100644 --- a/kde/CMakeLists.txt +++ b/kde/CMakeLists.txt @@ -17,13 +17,19 @@ if(NOT DEFINED OLLIE_KF5 OR NOT OLLIE_KF5) endif() endif() +# Build lib9p (Go shared library) as part of the cmake build. set(OLLIE9P_LIBRARY "${CMAKE_CURRENT_SOURCE_DIR}/lib9p/libollie9p.so") +set(OLLIE9P_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/lib9p/libollie9p.h") set(OLLIE9P_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib9p") -if(NOT EXISTS "${OLLIE9P_LIBRARY}") - message(FATAL_ERROR - "Missing ${OLLIE9P_LIBRARY}. Build it with: " - "go build -buildmode=c-shared -o ${OLLIE9P_LIBRARY} ./lib9p") -endif() + +add_custom_command( + OUTPUT "${OLLIE9P_LIBRARY}" "${OLLIE9P_HEADER}" + COMMAND go build -buildmode=c-shared -o "${OLLIE9P_LIBRARY}" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/lib9p" + COMMENT "Building lib9p (Go shared library)" + VERBATIM +) +add_custom_target(lib9p_build DEPENDS "${OLLIE9P_LIBRARY}" "${OLLIE9P_HEADER}") # The native clients link against the bundled C ABI library. Install it as a # normal runtime library beside the executable, not in the Qt plugin tree. @@ -85,6 +91,7 @@ if(OLLIE_KF5) gui/lib9pclient.cpp INSTALL_NAMESPACE "ktexteditor" ) + add_dependencies(ollie_kate lib9p_build) target_include_directories(ollie_kate PRIVATE ${CMAKE_SOURCE_DIR}/gui $ENV{HOME}/.local/include @@ -103,6 +110,7 @@ if(OLLIE_KF5) gui/lib9pclient.cpp INSTALL_NAMESPACE "kf5/kio" ) + add_dependencies(kio_ollie lib9p_build) target_include_directories(kio_ollie PRIVATE ${CMAKE_SOURCE_DIR}/gui ${CMAKE_SOURCE_DIR}/kio @@ -146,6 +154,7 @@ if(OLLIE_KF5) gui/clipboardhelper.cpp ${GUI_KF5_QRC} ) + add_dependencies(ollie-gui lib9p_build) target_include_directories(ollie-gui PRIVATE ${CMAKE_SOURCE_DIR}/gui $ENV{HOME}/.local/include @@ -192,6 +201,7 @@ else() gui/lib9pclient.cpp INSTALL_NAMESPACE "kf6/ktexteditor" ) + add_dependencies(ollie_kate lib9p_build) target_include_directories(ollie_kate PRIVATE ${CMAKE_SOURCE_DIR}/gui $ENV{HOME}/.local/include @@ -210,6 +220,7 @@ else() gui/lib9pclient.cpp INSTALL_NAMESPACE "kf6/kio" ) + add_dependencies(kio_ollie lib9p_build) target_include_directories(kio_ollie PRIVATE ${CMAKE_SOURCE_DIR}/gui ${CMAKE_SOURCE_DIR}/kio @@ -234,6 +245,7 @@ else() gui/thememanager.cpp gui/clipboardhelper.cpp ) + add_dependencies(ollie-gui lib9p_build) target_include_directories(ollie-gui PRIVATE ${CMAKE_SOURCE_DIR}/gui $ENV{HOME}/.local/include