From 3db05c0de934fccfefb0aafe85a3e48df0864807 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 29 Apr 2025 21:56:08 +1200 Subject: [PATCH] Give up on packages for now --- packages/CMakeLists.txt.static | 150 --------------------------------- packages/Dockerfile | 79 ----------------- packages/build_executables.sh | 53 ------------ 3 files changed, 282 deletions(-) delete mode 100644 packages/CMakeLists.txt.static delete mode 100644 packages/Dockerfile delete mode 100755 packages/build_executables.sh diff --git a/packages/CMakeLists.txt.static b/packages/CMakeLists.txt.static deleted file mode 100644 index 63b2deb..0000000 --- a/packages/CMakeLists.txt.static +++ /dev/null @@ -1,150 +0,0 @@ -cmake_minimum_required(VERSION 3.10) -project(dropshell VERSION 1.0.0 LANGUAGES CXX) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -# Force static linking -set(CMAKE_EXE_LINKER_FLAGS "-static") -set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") -set(BUILD_SHARED_LIBS OFF) - -# Set default build type to Release if not specified -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build (Debug or Release)" FORCE) -endif() - -# Configure build-specific compiler flags -set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g") -set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG") - -# Configure version information -string(TIMESTAMP CURRENT_YEAR "%Y") -string(TIMESTAMP CURRENT_MONTH "%m") -string(TIMESTAMP CURRENT_DAY "%d") -set(PROJECT_VERSION "${CURRENT_YEAR}.${CURRENT_MONTH}.${CURRENT_DAY}") -string(TIMESTAMP RELEASE_DATE "%Y-%m-%d") - -# Configure version.hpp file -configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/src/version.hpp.in" - "${CMAKE_CURRENT_BINARY_DIR}/src/version.hpp" - @ONLY -) - -# Set CMAKE_MODULE_PATH to include our custom find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) - -# Find required packages -find_package(Threads REQUIRED) -find_package(TBB REQUIRED) -find_package(xxHash REQUIRED) - -# Auto-detect source files -file(GLOB_RECURSE SOURCES "src/*.cpp") -file(GLOB_RECURSE HEADERS "src/*.hpp") - -# Add executable -add_executable(dropshell ${SOURCES}) - -# Set include directories -target_include_directories(dropshell PRIVATE - src - ${CMAKE_CURRENT_BINARY_DIR}/src - ${xxHash_INCLUDE_DIRS} -) - -# Link libraries statically -target_link_libraries(dropshell PRIVATE - -Wl,--whole-archive - TBB::tbb - ${xxHash_LIBRARIES} - Threads::Threads - -Wl,--no-whole-archive - -static-libgcc - -static-libstdc++ -) - -# Install targets -install(TARGETS dropshell - RUNTIME DESTINATION bin -) - -# Create symbolic link 'ds' pointing to 'dropshell' -install(CODE " - message(STATUS \"Checking if 'ds' command already exists...\") - execute_process( - COMMAND which ds - RESULT_VARIABLE DS_NOT_EXISTS - OUTPUT_QUIET - ERROR_QUIET - ) - if(DS_NOT_EXISTS) - message(STATUS \"Command 'ds' does not exist. Creating symlink.\") - execute_process( - COMMAND ${CMAKE_COMMAND} -E create_symlink - \${CMAKE_INSTALL_PREFIX}/bin/dropshell - \${CMAKE_INSTALL_PREFIX}/bin/ds - ) - else() - message(STATUS \"Command 'ds' already exists. Skipping symlink creation.\") - endif() -") - -# Install completion script -install(FILES src/dropshell-completion.bash - DESTINATION /etc/bash_completion.d - RENAME dropshell -) - -# Create a symlink for the completion script to work with 'ds' command -install(CODE " - # First check if 'ds' command exists after our installation - execute_process( - COMMAND which ds - RESULT_VARIABLE DS_NOT_EXISTS - OUTPUT_VARIABLE DS_PATH - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - - # Only proceed if 'ds' exists - if(NOT DS_NOT_EXISTS) - # Check if 'ds' is a symlink pointing to dropshell - execute_process( - COMMAND readlink -f \${DS_PATH} - RESULT_VARIABLE READLINK_FAILED - OUTPUT_VARIABLE REAL_PATH - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - - # Get the path to our dropshell binary - set(DROPSHELL_PATH \${CMAKE_INSTALL_PREFIX}/bin/dropshell) - - # Check if the real path is our dropshell binary - if(NOT READLINK_FAILED AND \"\${REAL_PATH}\" STREQUAL \"\${DROPSHELL_PATH}\") - message(STATUS \"Command 'ds' exists and points to dropshell. Creating completion script symlink.\") - execute_process( - COMMAND ${CMAKE_COMMAND} -E create_symlink - /etc/bash_completion.d/dropshell - /etc/bash_completion.d/ds - ) - else() - message(STATUS \"Command 'ds' exists but doesn't point to dropshell. Skipping completion symlink.\") - endif() - else() - message(STATUS \"Command 'ds' not found. Skipping completion symlink.\") - endif() -") - -# Create pre-install script to clean old templates -install(CODE " - message(STATUS \"Removing old template files...\") - execute_process(COMMAND rm -rf /opt/dropshell/templates) -") - -# Install templates with pre-install script -install(DIRECTORY templates/ - DESTINATION /opt/dropshell/templates -) \ No newline at end of file diff --git a/packages/Dockerfile b/packages/Dockerfile deleted file mode 100644 index b6818fb..0000000 --- a/packages/Dockerfile +++ /dev/null @@ -1,79 +0,0 @@ -FROM ubuntu:22.04 - -# Set up architectures first -RUN dpkg --add-architecture arm64 && \ - sed -i 's/deb http/deb [arch=amd64] http/g' /etc/apt/sources.list && \ - echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy main restricted universe multiverse" >> /etc/apt/sources.list && \ - echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted universe multiverse" >> /etc/apt/sources.list && \ - echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse" >> /etc/apt/sources.list && \ - echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-backports main restricted universe multiverse" >> /etc/apt/sources.list - -# Install build dependencies for both architectures -RUN apt-get update && \ - apt-get install -y \ - cmake \ - make \ - g++ \ - wget \ - git \ - g++-aarch64-linux-gnu \ - crossbuild-essential-arm64 \ - libtbb-dev \ - libtbb2 \ - libtbb-dev:arm64 \ - libtbb2:arm64 \ - libxxhash-dev \ - libxxhash0 \ - libxxhash-dev:arm64 \ - libxxhash0:arm64 && \ - rm -rf /var/lib/apt/lists/* - -# Build musl cross compilers with C++ support -RUN git clone https://github.com/richfelker/musl-cross-make.git && \ - cd musl-cross-make && \ - echo "TARGET = x86_64-linux-musl" > config.mak && \ - echo "OUTPUT = /opt/cross" >> config.mak && \ - echo "COMMON_CONFIG += CFLAGS=\"-g0 -O2\" CXXFLAGS=\"-g0 -O2\" LDFLAGS=\"-s\"" >> config.mak && \ - echo "GCC_CONFIG += --enable-languages=c,c++" >> config.mak && \ - make -j$(nproc) && \ - make install && \ - cd .. && \ - rm -rf musl-cross-make - -# Build arm64 musl cross compiler -RUN git clone https://github.com/richfelker/musl-cross-make.git && \ - cd musl-cross-make && \ - echo "TARGET = aarch64-linux-musl" > config.mak && \ - echo "OUTPUT = /opt/cross" >> config.mak && \ - echo "COMMON_CONFIG += CFLAGS=\"-g0 -O2\" CXXFLAGS=\"-g0 -O2\" LDFLAGS=\"-s\"" >> config.mak && \ - echo "GCC_CONFIG += --enable-languages=c,c++" >> config.mak && \ - make -j$(nproc) && \ - make install && \ - cd .. && \ - rm -rf musl-cross-make - -# Add cross compilers to PATH -ENV PATH="/opt/cross/bin:${PATH}" - -# Install TBB from source for musl compatibility -RUN wget https://github.com/oneapi-src/oneTBB/archive/refs/tags/v2021.10.0.tar.gz && \ - tar xf v2021.10.0.tar.gz && \ - cd oneTBB-2021.10.0 && \ - mkdir build && \ - cd build && \ - cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF .. && \ - make -j$(nproc) && \ - make install && \ - cd ../.. && \ - rm -rf oneTBB-2021.10.0 v2021.10.0.tar.gz - -# Install xxHash from source for musl compatibility -RUN wget https://github.com/Cyan4973/xxHash/archive/refs/tags/v0.8.2.tar.gz && \ - tar xf v0.8.2.tar.gz && \ - cd xxHash-0.8.2 && \ - make -j$(nproc) && \ - make install && \ - cd .. && \ - rm -rf xxHash-0.8.2 v0.8.2.tar.gz - -WORKDIR /src \ No newline at end of file diff --git a/packages/build_executables.sh b/packages/build_executables.sh deleted file mode 100755 index d735ab0..0000000 --- a/packages/build_executables.sh +++ /dev/null @@ -1,53 +0,0 @@ -# This script uses a pre-built docker container to build two executables: -# 1. dropshell-x86_64, using musl and static linking -# 2. dropshell-arm64, using musl and static linking - -# The executables are copied to ./output, with the ownership changed to current user. - -#!/bin/bash -set -e - -# Get current user's UID and GID -USER_ID=$(id -u) -GROUP_ID=$(id -g) - -# Create output directory if it doesn't exist -mkdir -p output - -# Build Docker image -echo "Building builder image..." -docker build -t dropshell-builder:latest . - -echo "Building x86_64 executable..." -# Build x86_64 executable -docker run --rm -v "$(pwd)/..:/src" -u root dropshell-builder:latest bash -c ' \ - rm -rf build && \ - mkdir -p build && \ - cd build && \ - cp ../packages/CMakeLists.txt.static ../CMakeLists.txt && \ - MUSL_GPP=$(which musl-g++) && \ - cmake -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_CXX_COMPILER=${MUSL_GPP} \ - -DCMAKE_CXX_FLAGS="-static" .. && \ - make && \ - cp dropshell ../packages/output/dropshell-x86_64 && \ - chown '"$USER_ID:$GROUP_ID"' ../packages/output/dropshell-x86_64 && \ - rm -rf build \ -' - -echo "Building arm64 executable..." -# Build arm64 executable -docker run --rm -v "$(pwd)/..:/src" -u root dropshell-builder:latest bash -c ' \ - rm -rf build && \ - mkdir -p build && \ - cd build && \ - cp ../packages/CMakeLists.txt.static ../CMakeLists.txt && \ - MUSL_GPP=$(which aarch64-linux-musl-g++) && \ - cmake -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_CXX_COMPILER=${MUSL_GPP} \ - -DCMAKE_CXX_FLAGS="-static" .. && \ - make && \ - cp dropshell ../packages/output/dropshell-arm64 && \ - chown '"$USER_ID:$GROUP_ID"' ../packages/output/dropshell-arm64 && \ - rm -rf build \ -' \ No newline at end of file