diff --git a/.vscode/launch.json b/.vscode/launch.json index 1defd61d..8271cd05 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -14,11 +14,11 @@ } }, { - "name": "(yarn) Frontend", - "command": "yarn start", + "name": "(bun) Frontend", + "command": "bun run --bun vite-dev", "request": "launch", "type": "node-terminal", - "cwd": "${workspaceFolder}/frontend" + "cwd": "${workspaceFolder}/web" } ] } diff --git a/Dockerfile b/Dockerfile index 058633fb..0ff2478a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,12 +5,10 @@ RUN apt-get update --yes && apt-get install --yes ca-certificates curl gnupg \ && echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main" > /etc/apt/sources.list.d/llvm.list \ && curl --silent --location https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - \ && mkdir -p /etc/apt/keyrings \ - && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \ - && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \ && curl --silent --location https://apt.kitware.com/keys/kitware-archive-latest.asc | gpg --dearmor -o /usr/share/keyrings/kitware-archive-keyring.gpg \ && echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ jammy main' | tee /etc/apt/sources.list.d/kitware.list >/dev/null \ && apt-get update --yes \ - && apt-get install --yes build-essential git cmake libssl-dev pip ninja-build lldb-17 clangd-17 clang-format-17 clang-17 libc++-17-dev libc++abi-17-dev nodejs zstd \ + && apt-get install --yes build-essential git cmake libssl-dev pip ninja-build lldb-17 clangd-17 clang-format-17 clang-17 libc++-17-dev libc++abi-17-dev nodejs zstd unzip \ && rm -rf /var/lib/apt/lists/* RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-17 100 && \ @@ -28,8 +26,9 @@ RUN pip install conan==1.63.0 \ && conan profile update settings.compiler.version=17 default \ && conan profile update settings.compiler.libcxx=libc++ default -RUN corepack enable \ - && corepack prepare yarn@stable --activate +RUN curl -fsSL https://bun.sh/install | bash + +ENV PATH="/root/.bun/bin:${PATH}" COPY conanfile.txt /conan/ diff --git a/cmake/FindBun.cmake b/cmake/FindBun.cmake new file mode 100644 index 00000000..da7ab107 --- /dev/null +++ b/cmake/FindBun.cmake @@ -0,0 +1,51 @@ +set(_prev "${BUN_EXECUTABLE}") +find_program(BUN_EXECUTABLE bun DOC "Path to Bun, the all-in-one JavaScript runtime") + +if(BUN_EXECUTABLE) + if(NOT _prev) + message(STATUS "Found Bun executable: ${BUN_EXECUTABLE}") + endif() + set(Bun_FOUND TRUE CACHE INTERNAL "") +else() + set(Bun_FOUND FALSE CACHE INTERNAL "") + if(Bun_FIND_REQUIRED) + message(FATAL_ERROR "Failed to find a Bun executable") + endif() +endif() + +function(bun_run_command cmd working_dir) + message(STATUS "Running command: ${BUN_EXECUTABLE} ${cmd} at ${working_dir}") + execute_process( + COMMAND ${BUN_EXECUTABLE} ${cmd} + RESULT_VARIABLE result + ERROR_VARIABLE error + WORKING_DIRECTORY ${working_dir} + ) + if (result) + message(FATAL_ERROR "Failed to run command: ${result}") + endif() +endfunction() + +function(bun_add_vite_project package_name working_dir) + bun_run_command(install ${working_dir}) + + add_custom_target("${package_name}_build" ALL + COMMAND ${CMAKE_COMMAND} -E env BUILD_PATH='${CMAKE_CURRENT_BINARY_DIR}' ${BUN_EXECUTABLE} run --bun vite-build + WORKING_DIRECTORY ${working_dir} + COMMENT "Building ${package_name}" + USES_TERMINAL + ) + + add_custom_command( + TARGET "${package_name}_build" POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR}/bin/frontend) + + add_custom_target("${package_name}_install" + COMMAND ${CMAKE_COMMAND} -E env BUILD_PATH='${CMAKE_CURRENT_BINARY_DIR}' ${BUN_EXECUTABLE} install + WORKING_DIRECTORY ${working_dir} + COMMENT "Installing packages for ${package_name}" + USES_TERMINAL + ) +endfunction()