From f1526d8c2449aa61abafb00f8370721aa93c8053 Mon Sep 17 00:00:00 2001 From: Viktor Vaczi Date: Wed, 26 Nov 2025 16:33:48 +0100 Subject: [PATCH] Complete Phase 1: Build KiCad with optional dependencies disabled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add CMake override modules, stub implementations, and patches to build KiCad without CURL, libgit2, OpenCASCADE, and ngspice dependencies. - cmake/: Find modules that provide stub targets when deps disabled - stubs/include/: Header stubs for curl, git2, ngspice, OCC - stubs/src/: Implementation stubs for disabled features - patches/: Consolidated patch for KiCad source modifications - scripts/: Build helper scripts Verified full native build on macOS with all optional deps disabled. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- CMakeLists.txt | 51 ++ README.md | 128 ++++- cmake/FindCURL.cmake | 34 ++ cmake/FindOCC.cmake | 41 ++ cmake/Findlibgit2.cmake | 64 +++ cmake/Findngspice.cmake | 56 ++ cmake/KicadWasmOptions.cmake | 84 +++ patches/0001-wasm-optional-deps.patch | 358 ++++++++++++ scripts/build.sh | 162 ++++++ scripts/prepare.sh | 120 ++++ scripts/update-kicad.sh | 137 +++++ stubs/include/Standard_Version.hxx | 23 + stubs/include/curl/curl.h | 149 +++++ stubs/include/curl/easy.h | 12 + stubs/include/git2.h | 587 +++++++++++++++++++ stubs/include/git2/sys/errors.h | 27 + stubs/include/git2/sys/merge.h | 39 ++ stubs/include/ngspice/sharedspice.h | 90 +++ stubs/src/disabled_features_stubs.cpp | 205 +++++++ stubs/src/kicad_git_all_stubs.cpp | 787 ++++++++++++++++++++++++++ stubs/src/kicad_git_stubs.cpp | 339 +++++++++++ stubs/src/occ_stubs.cpp | 172 ++++++ stubs/src/panel_git_repos_stub.cpp | 36 ++ 23 files changed, 3688 insertions(+), 13 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 cmake/FindCURL.cmake create mode 100644 cmake/FindOCC.cmake create mode 100644 cmake/Findlibgit2.cmake create mode 100644 cmake/Findngspice.cmake create mode 100644 cmake/KicadWasmOptions.cmake create mode 100644 patches/0001-wasm-optional-deps.patch create mode 100755 scripts/build.sh create mode 100755 scripts/prepare.sh create mode 100755 scripts/update-kicad.sh create mode 100644 stubs/include/Standard_Version.hxx create mode 100644 stubs/include/curl/curl.h create mode 100644 stubs/include/curl/easy.h create mode 100644 stubs/include/git2.h create mode 100644 stubs/include/git2/sys/errors.h create mode 100644 stubs/include/git2/sys/merge.h create mode 100644 stubs/include/ngspice/sharedspice.h create mode 100644 stubs/src/disabled_features_stubs.cpp create mode 100644 stubs/src/kicad_git_all_stubs.cpp create mode 100644 stubs/src/kicad_git_stubs.cpp create mode 100644 stubs/src/occ_stubs.cpp create mode 100644 stubs/src/panel_git_repos_stub.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..4919afd --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,51 @@ +# +# KiCad WebAssembly Port - Root Build Configuration +# +# This is a wrapper CMakeLists.txt that configures optional dependencies +# before building KiCad. Use this for building with features disabled. +# +# Usage: +# mkdir build && cd build +# cmake .. -DKICAD_USE_CURL=OFF -DKICAD_USE_GIT=OFF -DKICAD_USE_OCC=OFF +# make -j$(nproc) +# + +cmake_minimum_required(VERSION 3.22) +project(kicad-wasm-wrapper) + +# Add our stubs to the include path when dependencies are disabled +set(KICAD_WASM_STUBS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/stubs/include") + +# Include our options module +include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/KicadWasmOptions.cmake") + +# Add stubs to include path when features are disabled +if(NOT KICAD_USE_CURL OR NOT KICAD_USE_GIT) + message(STATUS "Adding stub headers to include path: ${KICAD_WASM_STUBS_DIR}") + include_directories(BEFORE SYSTEM "${KICAD_WASM_STUBS_DIR}") +endif() + +# For now, we need to build KiCad from its directory directly +# because it expects to be the root project. +# +# This wrapper is mainly for documentation and can be extended later. +message(STATUS "") +message(STATUS "=== KiCad Wasm Build Configuration ===") +message(STATUS "") +message(STATUS "Note: KiCad must be built from its source directory.") +message(STATUS "") +message(STATUS "To build with features disabled, use:") +message(STATUS "") +message(STATUS " cd kicad") +message(STATUS " mkdir build && cd build") +message(STATUS " cmake .. \\") +message(STATUS " -DCMAKE_MODULE_PATH=${CMAKE_CURRENT_SOURCE_DIR}/cmake \\") +message(STATUS " -DKICAD_USE_CURL=${KICAD_USE_CURL} \\") +message(STATUS " -DKICAD_USE_GIT=${KICAD_USE_GIT} \\") +message(STATUS " -DKICAD_USE_OCC=${KICAD_USE_OCC} \\") +message(STATUS " -DKICAD_USE_NGSPICE=${KICAD_USE_NGSPICE}") +message(STATUS "") +message(STATUS "Or use the helper script:") +message(STATUS " ./scripts/build.sh") +message(STATUS "") +message(FATAL_ERROR "Please build from kicad/ directory as described above") diff --git a/README.md b/README.md index abab26a..4760217 100644 --- a/README.md +++ b/README.md @@ -6,18 +6,32 @@ Experimental project to run KiCad's core logic in WebAssembly. ``` kicad-wasm/ -├── kicad/ # KiCad source (git submodule) -├── patches/ # Patches to make deps optional -├── stubs/ # Stub headers for disabled deps -├── cmake/ # CMake modules -├── scripts/ # Build and maintenance scripts -├── core/ # Extracted core library for Wasm -└── docs/ # Knowledge base and plans +├── kicad/ # KiCad source (git submodule) +├── patches/ # Patches for KiCad source +│ └── 0001-wasm-optional-deps.patch +├── stubs/ # Stub implementations for disabled deps +│ ├── include/ # Stub headers +│ │ ├── curl/ # CURL stub headers +│ │ ├── git2.h # libgit2 stub header +│ │ ├── ngspice/ # ngspice stub headers +│ │ └── Standard_Version.hxx # OCC stub header +│ └── src/ # Stub source files +│ ├── disabled_features_stubs.cpp +│ ├── occ_stubs.cpp +│ ├── panel_git_repos_stub.cpp +│ └── kicad_git_all_stubs.cpp +├── cmake/ # CMake override modules +│ ├── FindCURL.cmake +│ ├── Findlibgit2.cmake +│ ├── Findngspice.cmake +│ └── FindOCC.cmake +├── scripts/ # Build scripts +└── docs/ # Documentation ``` ## Goals -1. **Phase 1**: Build KiCad with optional deps disabled (curl, git, OCC, ngspice) +1. **Phase 1**: Build KiCad with optional deps disabled (curl, git, OCC, ngspice) ✅ **Complete** 2. **Phase 2**: Extract core computation code as standalone library 3. **Phase 3**: Compile core to WebAssembly 4. **Phase 4**: Run native GUI with Wasm worker backend @@ -37,19 +51,107 @@ kicad-wasm/ ## Getting Started +### Prerequisites + +- CMake 3.22+ +- C++20 compiler (GCC 10+, Clang 12+, or MSVC 2019+) +- wxWidgets 3.2+ +- Required libraries + +#### macOS (Homebrew) + +```bash +brew install cmake wxwidgets boost cairo pixman freetype harfbuzz fontconfig \ + glm glew swig protobuf pkg-config nng python@3.14 zstd unixodbc +``` + +#### Ubuntu/Debian + +```bash +sudo apt install cmake build-essential libwxgtk3.2-dev libboost-all-dev \ + libcairo2-dev libpixman-1-dev libfreetype-dev libharfbuzz-dev \ + libfontconfig-dev libglm-dev libglew-dev swig libprotobuf-dev \ + protobuf-compiler libnng-dev python3-dev libzstd-dev +``` + +### Quick Start (with dependencies disabled) + ```bash # Clone with submodules git clone --recursive +cd kicad-wasm -# Apply patches -./scripts/prepare.sh +# Apply patches to KiCad source +cd kicad +git apply ../patches/0001-wasm-optional-deps.patch +cd .. -# Build with optional deps disabled +# Build mkdir build && cd build -cmake .. -DKICAD_USE_CURL=OFF -DKICAD_USE_GIT=OFF -DKICAD_USE_OCC=OFF +cmake ../kicad \ + -DCMAKE_MODULE_PATH="$(pwd)/../cmake" \ + -DKICAD_USE_CURL=OFF \ + -DKICAD_USE_GIT=OFF \ + -DKICAD_USE_OCC=OFF \ + -DKICAD_USE_NGSPICE=OFF \ + -DKICAD_SCRIPTING_WXPYTHON=OFF make -j$(nproc) ``` +### Build Options + +| Option | Default | Description | +|--------|---------|-------------| +| `KICAD_USE_CURL` | ON | Enable network features (PCM, update check) | +| `KICAD_USE_GIT` | ON | Enable git integration | +| `KICAD_USE_OCC` | ON | Enable OpenCASCADE (STEP import/export) | +| `KICAD_USE_NGSPICE` | ON | Enable SPICE simulation | +| `KICAD_USE_DATABASE` | ON | Enable database libraries (ODBC) | + +### Using the Build Script + +```bash +# Build with all optional deps disabled (default) +./scripts/build.sh + +# Build with specific features enabled +./scripts/build.sh --with-curl --with-git + +# Clean build +./scripts/build.sh --clean + +# Debug build +./scripts/build.sh --debug + +# Just configure, don't build +./scripts/build.sh --configure-only + +# See all options +./scripts/build.sh --help +``` + +## Current Status + +### Phase 1 Complete +- CMake override modules for optional dependencies (FindOCC, Findngspice, FindCURL, Findlibgit2) +- Stub headers and implementations for disabled features +- KiCad source patches (`patches/0001-wasm-optional-deps.patch`) +- Full native build verified on macOS with all optional deps disabled + +### Built Components +- `kicad` - Main application +- `kicad-cli` - Command line interface +- `_pcbnew.kiface` - PCB editor +- `_eeschema.kiface` - Schematic editor +- `_cvpcb.kiface` - Component to footprint association +- `_gerbview.kiface` - Gerber viewer +- `_pl_editor.kiface` - Page layout editor +- `_pcb_calculator.kiface` - PCB calculator + +### Next Steps +- Verify build on Linux/Windows +- Begin Phase 2 (core library extraction) + ## License -KiCad is GPL-3.0. This wrapper/tooling follows the same license. \ No newline at end of file +KiCad is GPL-3.0. This wrapper/tooling follows the same license. diff --git a/cmake/FindCURL.cmake b/cmake/FindCURL.cmake new file mode 100644 index 0000000..2a7383e --- /dev/null +++ b/cmake/FindCURL.cmake @@ -0,0 +1,34 @@ +# +# KiCad Wasm Port - CURL Find Module Override +# +# When KICAD_USE_CURL=OFF, this module provides stub values +# so the build can proceed without libcurl. +# + +# Check if curl is disabled +if(DEFINED KICAD_USE_CURL AND NOT KICAD_USE_CURL) + message(STATUS "CURL: DISABLED (KICAD_USE_CURL=OFF)") + + # Set variables that KiCad expects + set(CURL_FOUND TRUE) + set(CURL_INCLUDE_DIRS "") + set(CURL_LIBRARIES "") + set(CURL_VERSION_STRING "stub") + + # Create an imported target that does nothing + if(NOT TARGET CURL::libcurl) + add_library(CURL::libcurl INTERFACE IMPORTED) + endif() + + return() +endif() + +# Otherwise, use CMake's built-in FindCURL +# Remove our path to avoid recursion +list(REMOVE_ITEM CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") + +# Use built-in module +include(${CMAKE_ROOT}/Modules/FindCURL.cmake) + +# Restore module path +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") diff --git a/cmake/FindOCC.cmake b/cmake/FindOCC.cmake new file mode 100644 index 0000000..f828fb8 --- /dev/null +++ b/cmake/FindOCC.cmake @@ -0,0 +1,41 @@ +# +# KiCad Wasm Port - OpenCASCADE Find Module Override +# +# When KICAD_USE_OCC=OFF, this module provides stub values +# so the build can proceed without OpenCASCADE. +# + +# Check if OCC is disabled +if(DEFINED KICAD_USE_OCC AND NOT KICAD_USE_OCC) + message(STATUS "OpenCASCADE: DISABLED (KICAD_USE_OCC=OFF)") + + # Set stubs include directory + set(STUBS_INCLUDE_DIR "${CMAKE_CURRENT_LIST_DIR}/../stubs/include") + + # Set variables that KiCad expects + set(OCC_FOUND TRUE) + set(OCC_INCLUDE_DIR "${STUBS_INCLUDE_DIR}") + set(OCC_INCLUDE_DIRS "${STUBS_INCLUDE_DIR}") + set(OCC_LIBRARIES "") + set(OCC_VERSION_STRING "7.5.0") # Fake version to pass version check + set(OCC_VERSION_MAJOR 7) + set(OCC_VERSION_MINOR 5) + set(OCC_VERSION_PATCH 0) + + # Add stub includes globally + include_directories("${STUBS_INCLUDE_DIR}") + + return() +endif() + +# Otherwise, use the original find module from KiCad +list(REMOVE_ITEM CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") + +set(_KICAD_CMAKE_DIR "${CMAKE_SOURCE_DIR}/cmake") +if(EXISTS "${_KICAD_CMAKE_DIR}/FindOCC.cmake") + include("${_KICAD_CMAKE_DIR}/FindOCC.cmake") +else() + message(FATAL_ERROR "Cannot find OpenCASCADE find module") +endif() + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") diff --git a/cmake/Findlibgit2.cmake b/cmake/Findlibgit2.cmake new file mode 100644 index 0000000..b0db1f3 --- /dev/null +++ b/cmake/Findlibgit2.cmake @@ -0,0 +1,64 @@ +# +# KiCad Wasm Port - libgit2 Find Module Override +# +# When KICAD_USE_GIT=OFF, this module provides stub values +# so the build can proceed without libgit2. +# + +# Check if git is disabled +if(DEFINED KICAD_USE_GIT AND NOT KICAD_USE_GIT) + message(STATUS "libgit2: DISABLED (KICAD_USE_GIT=OFF)") + + # Set variables that KiCad expects + set(LIBGIT2_FOUND TRUE) + set(LIBGIT2_INCLUDE_DIR "") + set(LIBGIT2_INCLUDE_DIRS "") + set(LIBGIT2_LIBRARIES "") + set(LIBGIT2_DEFINITIONS "") + set(LIBGIT2_VERSION_STRING "stub") + + # Mark as found + set(libgit2_FOUND TRUE) + + return() +endif() + +# Otherwise, use the original find module from KiCad +# First, remove our cmake dir from the module path to avoid recursion +list(REMOVE_ITEM CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") + +# Look for the original module in KiCad's cmake dir +set(_KICAD_CMAKE_DIR "${CMAKE_SOURCE_DIR}/cmake") +if(EXISTS "${_KICAD_CMAKE_DIR}/Findlibgit2.cmake") + include("${_KICAD_CMAKE_DIR}/Findlibgit2.cmake") +else() + # Fallback: Use pkg-config + find_package(PkgConfig) + pkg_search_module(PC_LIBGIT2 libgit2) + + set(LIBGIT2_DEFINITIONS ${PC_LIBGIT2_CFLAGS_OTHER}) + + find_path(LIBGIT2_INCLUDE_DIR NAMES git2.h + HINTS + ${PC_LIBGIT2_INCLUDEDIR} + ${PC_LIBGIT2_INCLUDE_DIRS} + ) + + find_library(LIBGIT2_LIBRARY NAMES git2 + HINTS + ${PC_LIBGIT2_LIBDIR} + ${PC_LIBGIT2_LIBRARY_DIRS} + ) + + set(LIBGIT2_LIBRARIES ${LIBGIT2_LIBRARY}) + set(LIBGIT2_INCLUDE_DIRS ${LIBGIT2_INCLUDE_DIR}) + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(libgit2 DEFAULT_MSG + LIBGIT2_LIBRARY LIBGIT2_INCLUDE_DIR) + + mark_as_advanced(LIBGIT2_INCLUDE_DIR LIBGIT2_LIBRARY) +endif() + +# Restore module path +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") diff --git a/cmake/Findngspice.cmake b/cmake/Findngspice.cmake new file mode 100644 index 0000000..6991271 --- /dev/null +++ b/cmake/Findngspice.cmake @@ -0,0 +1,56 @@ +# +# KiCad Wasm Port - ngspice Find Module Override +# +# When KICAD_USE_NGSPICE=OFF, this module provides stub values +# so the build can proceed without ngspice. +# + +# Check if ngspice is disabled +if(DEFINED KICAD_USE_NGSPICE AND NOT KICAD_USE_NGSPICE) + message(STATUS "ngspice: DISABLED (KICAD_USE_NGSPICE=OFF)") + + # Set stubs include directory + set(STUBS_INCLUDE_DIR "${CMAKE_CURRENT_LIST_DIR}/../stubs/include") + + # Set variables that KiCad expects + # ngspice is dynamically loaded via dlopen, so we don't need to link against it. + # Set library variables to empty to prevent linking. + set(ngspice_FOUND TRUE) + set(NGSPICE_FOUND TRUE) + set(NGSPICE_INCLUDE_DIR "${STUBS_INCLUDE_DIR}") + set(NGSPICE_INCLUDE_DIRS "${STUBS_INCLUDE_DIR}") + # Empty library - ngspice is loaded dynamically, not linked + set(NGSPICE_LIBRARY "" CACHE STRING "ngspice library (disabled)") + set(NGSPICE_LIBRARIES "") + set(NGSPICE_VERSION "disabled") + # NGSPICE_DLL is used by eeschema at runtime, not link time + set(NGSPICE_DLL "") + + # Add stub includes globally + include_directories("${STUBS_INCLUDE_DIR}") + + return() +endif() + +# Otherwise, use the original find module from KiCad +list(REMOVE_ITEM CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") + +set(_KICAD_CMAKE_DIR "${CMAKE_SOURCE_DIR}/cmake") +if(EXISTS "${_KICAD_CMAKE_DIR}/Findngspice.cmake") + include("${_KICAD_CMAKE_DIR}/Findngspice.cmake") +else() + # Fallback search + find_path(NGSPICE_INCLUDE_DIR NAMES ngspice/sharedspice.h) + find_library(NGSPICE_LIBRARY NAMES ngspice) + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(ngspice DEFAULT_MSG + NGSPICE_LIBRARY NGSPICE_INCLUDE_DIR) + + set(NGSPICE_LIBRARIES ${NGSPICE_LIBRARY}) + set(NGSPICE_INCLUDE_DIRS ${NGSPICE_INCLUDE_DIR}) + + mark_as_advanced(NGSPICE_INCLUDE_DIR NGSPICE_LIBRARY) +endif() + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") diff --git a/cmake/KicadWasmOptions.cmake b/cmake/KicadWasmOptions.cmake new file mode 100644 index 0000000..d368d24 --- /dev/null +++ b/cmake/KicadWasmOptions.cmake @@ -0,0 +1,84 @@ +# +# KiCad WebAssembly Port - Optional Dependency Configuration +# +# This module defines options to disable optional dependencies for Wasm builds. +# Include this BEFORE processing KiCad's CMakeLists.txt +# + +# Optional dependency flags +option( KICAD_USE_CURL "Enable network features (curl)" ON ) +option( KICAD_USE_GIT "Enable git integration (libgit2)" ON ) +option( KICAD_USE_OCC "Enable STEP/3D via OpenCASCADE" ON ) +option( KICAD_USE_NGSPICE "Enable SPICE simulation" ON ) +option( KICAD_USE_DATABASE "Enable database libraries (ODBC)" ON ) + +# When building for Wasm, disable all optional deps by default +option( KICAD_WASM_BUILD "Building for WebAssembly target" OFF ) + +if( KICAD_WASM_BUILD ) + message( STATUS "KiCad Wasm build: Disabling optional dependencies" ) + set( KICAD_USE_CURL OFF CACHE BOOL "" FORCE ) + set( KICAD_USE_GIT OFF CACHE BOOL "" FORCE ) + set( KICAD_USE_OCC OFF CACHE BOOL "" FORCE ) + set( KICAD_USE_NGSPICE OFF CACHE BOOL "" FORCE ) + set( KICAD_USE_DATABASE OFF CACHE BOOL "" FORCE ) +endif() + +# Report status +message( STATUS "KICAD_USE_CURL: ${KICAD_USE_CURL}" ) +message( STATUS "KICAD_USE_GIT: ${KICAD_USE_GIT}" ) +message( STATUS "KICAD_USE_OCC: ${KICAD_USE_OCC}" ) +message( STATUS "KICAD_USE_NGSPICE: ${KICAD_USE_NGSPICE}" ) +message( STATUS "KICAD_USE_DATABASE: ${KICAD_USE_DATABASE}" ) + +# +# Create stub/dummy targets for disabled dependencies +# + +# CURL stub +if( NOT KICAD_USE_CURL ) + if( NOT TARGET CURL::libcurl ) + add_library( CURL::libcurl INTERFACE IMPORTED ) + endif() + add_compile_definitions( KICAD_USE_CURL=0 ) +else() + add_compile_definitions( KICAD_USE_CURL=1 ) +endif() + +# libgit2 stub +if( NOT KICAD_USE_GIT ) + set( LIBGIT2_FOUND TRUE ) + set( LIBGIT2_LIBRARIES "" ) + set( LIBGIT2_INCLUDE_DIRS "" ) + add_compile_definitions( KICAD_USE_GIT=0 ) +else() + add_compile_definitions( KICAD_USE_GIT=1 ) +endif() + +# OpenCASCADE stub +if( NOT KICAD_USE_OCC ) + set( OCC_FOUND TRUE ) + set( OCC_VERSION_STRING "7.5.0" ) + set( OCC_INCLUDE_DIR "" ) + set( OCC_LIBRARIES "" ) + add_compile_definitions( KICAD_USE_OCC=0 ) +else() + add_compile_definitions( KICAD_USE_OCC=1 ) +endif() + +# ngspice stub +if( NOT KICAD_USE_NGSPICE ) + set( ngspice_FOUND TRUE ) + set( NGSPICE_LIBRARY "" ) + set( NGSPICE_INCLUDE_DIR "" ) + add_compile_definitions( KICAD_USE_NGSPICE=0 ) +else() + add_compile_definitions( KICAD_USE_NGSPICE=1 ) +endif() + +# Database (ODBC) - affects boost::locale requirement +if( NOT KICAD_USE_DATABASE ) + add_compile_definitions( KICAD_USE_DATABASE=0 ) +else() + add_compile_definitions( KICAD_USE_DATABASE=1 ) +endif() diff --git a/patches/0001-wasm-optional-deps.patch b/patches/0001-wasm-optional-deps.patch new file mode 100644 index 0000000..af81193 --- /dev/null +++ b/patches/0001-wasm-optional-deps.patch @@ -0,0 +1,358 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index fd20af211f..a8e2ea34b2 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -64,7 +64,13 @@ set( CMAKE_EXPORT_COMPILE_COMMANDS ON ) + + # Path to KiCad's CMake modules. + set( KICAD_CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ) +-set( CMAKE_MODULE_PATH "${KICAD_CMAKE_MODULE_PATH}" ) ++ ++# Preserve any user-provided CMAKE_MODULE_PATH (e.g. for kicad-wasm overrides) ++if(CMAKE_MODULE_PATH) ++ set( CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${KICAD_CMAKE_MODULE_PATH}" ) ++else() ++ set( CMAKE_MODULE_PATH "${KICAD_CMAKE_MODULE_PATH}" ) ++endif() + + include( ConfigurePlatform ) + +diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt +index 56e516acad..f29ae853ef 100644 +--- a/common/CMakeLists.txt ++++ b/common/CMakeLists.txt +@@ -71,29 +71,6 @@ set( KICOMMON_SRCS + gal/color4d.cpp + gal/opengl/gl_context_mgr.cpp + +- # Git +- git/git_add_to_index_handler.cpp +- git/git_branch_handler.cpp +- git/git_clone_handler.cpp +- git/git_commit_handler.cpp +- git/git_config_handler.cpp +- git/git_compare_handler.cpp +- git/git_init_handler.cpp +- git/project_git_utils.cpp +- git/git_pull_handler.cpp +- git/git_push_handler.cpp +- git/git_remove_from_index_handler.cpp +- git/git_remove_vcs_handler.cpp +- git/git_resolve_conflict_handler.cpp +- git/git_revert_handler.cpp +- git/git_status_handler.cpp +- git/git_switch_branch_handler.cpp +- git/git_sync_handler.cpp +- git/kicad_git_common.cpp +- git/kicad_git_errors.cpp +- git/git_backend.cpp +- git/libgit_backend.cpp +- + # Jobs + jobs/job.cpp + jobs/job_dispatcher.cpp +@@ -134,12 +111,6 @@ set( KICOMMON_SRCS + jobs/job_pcb_upgrade.cpp + jobs/job_sch_upgrade.cpp + +- local_history.cpp +- history_lock.cpp +- +- kicad_curl/kicad_curl.cpp +- kicad_curl/kicad_curl_easy.cpp +- + libraries/library_manager.cpp + libraries/library_table.cpp + libraries/library_table_parser.cpp +@@ -280,6 +251,54 @@ if( UNIX AND NOT APPLE ) + ) + endif() + ++# Git files - only include when git support is enabled ++if( KICAD_USE_GIT ) ++ list( APPEND KICOMMON_SRCS ++ local_history.cpp ++ history_lock.cpp ++ git/git_add_to_index_handler.cpp ++ git/git_branch_handler.cpp ++ git/git_clone_handler.cpp ++ git/git_commit_handler.cpp ++ git/git_config_handler.cpp ++ git/git_compare_handler.cpp ++ git/git_init_handler.cpp ++ git/project_git_utils.cpp ++ git/git_pull_handler.cpp ++ git/git_push_handler.cpp ++ git/git_remove_from_index_handler.cpp ++ git/git_remove_vcs_handler.cpp ++ git/git_resolve_conflict_handler.cpp ++ git/git_revert_handler.cpp ++ git/git_status_handler.cpp ++ git/git_switch_branch_handler.cpp ++ git/git_sync_handler.cpp ++ git/kicad_git_common.cpp ++ git/kicad_git_errors.cpp ++ git/git_backend.cpp ++ git/libgit_backend.cpp ++ ) ++endif() ++ ++# CURL files - only include when curl support is enabled ++if( KICAD_USE_CURL ) ++ list( APPEND KICOMMON_SRCS ++ kicad_curl/kicad_curl.cpp ++ kicad_curl/kicad_curl_easy.cpp ++ ) ++endif() ++ ++# Stub implementations for disabled features ++if( NOT KICAD_USE_GIT OR NOT KICAD_USE_CURL ) ++ # Use absolute path to stub implementations ++ set( STUBS_SRC_DIR "${CMAKE_SOURCE_DIR}/../stubs/src" ) ++ if( EXISTS "${STUBS_SRC_DIR}/disabled_features_stubs.cpp" ) ++ list( APPEND KICOMMON_SRCS ++ "${STUBS_SRC_DIR}/disabled_features_stubs.cpp" ++ ) ++ endif() ++endif() ++ + if( KICAD_IPC_API ) + set( KICOMMON_SRCS + ${KICOMMON_SRCS} +@@ -322,12 +341,10 @@ target_link_libraries( kicommon + nlohmann_json_schema_validator + FastFloat::fast_float + fmt::fmt +- CURL::libcurl + picosha2 + rapidcsv + ${ZSTD_LIBRARY} + ${wxWidgets_LIBRARIES} +- ${LIBGIT2_LIBRARIES} + ${SPNAV_LIBRARIES} + + # needed by kiid to allow linking for Boost for the UUID against bcrypt (msys2 only) +@@ -342,6 +359,15 @@ target_link_libraries( kicommon + ${PYTHON_LIBRARIES} + ) + ++# Conditional library links for optional features ++if( KICAD_USE_CURL ) ++ target_link_libraries( kicommon CURL::libcurl ) ++endif() ++ ++if( KICAD_USE_GIT ) ++ target_link_libraries( kicommon ${LIBGIT2_LIBRARIES} ) ++endif() ++ + + if( KICAD_USE_SENTRY ) + target_link_libraries( kicommon +@@ -417,16 +443,30 @@ set( COMMON_ABOUT_DLG_SRCS + dialog_about/dialog_about_base.cpp + ) + ++# Git dialog sources - only include when git support is enabled ++# panel_git_repos_base.cpp has no git dependencies, so it's always compiled + set( COMMON_GIT_DLG_SRCS +- dialogs/git/dialog_git_commit.cpp +- dialogs/git/dialog_git_switch.cpp +- dialogs/git/dialog_git_auth.cpp +- dialogs/git/dialog_git_repository.cpp +- dialogs/git/dialog_git_repository_base.cpp +- dialogs/git/panel_git_repos.cpp + dialogs/git/panel_git_repos_base.cpp ++) + ++if( KICAD_USE_GIT ) ++ list( APPEND COMMON_GIT_DLG_SRCS ++ dialogs/git/dialog_git_commit.cpp ++ dialogs/git/dialog_git_switch.cpp ++ dialogs/git/dialog_git_auth.cpp ++ dialogs/git/dialog_git_repository.cpp ++ dialogs/git/dialog_git_repository_base.cpp ++ dialogs/git/panel_git_repos.cpp + ) ++else() ++ # Add stub implementation for PANEL_GIT_REPOS when git is disabled ++ set( STUBS_SRC_DIR "${CMAKE_SOURCE_DIR}/../stubs/src" ) ++ if( EXISTS "${STUBS_SRC_DIR}/panel_git_repos_stub.cpp" ) ++ list( APPEND COMMON_GIT_DLG_SRCS ++ "${STUBS_SRC_DIR}/panel_git_repos_stub.cpp" ++ ) ++ endif() ++endif() + + set( COMMON_DLG_SRCS + ${COMMON_GIT_DLG_SRCS} +diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt +index 1be2c291d1..bca563201a 100644 +--- a/eeschema/CMakeLists.txt ++++ b/eeschema/CMakeLists.txt +@@ -697,15 +697,17 @@ if( APPLE ) + set( OSX_BUNDLE_BUILD_KIFACE_DIR \"${OSX_BUNDLE_BUILD_KIFACE_DIR}\" ) + " ) + +- # bundle libngspice and codemodels +- get_filename_component( ABS_LIBNGSPICE ${NGSPICE_LIBRARY} ABSOLUTE ) +- get_filename_component( LIBNGSPICE_PATH ${ABS_LIBNGSPICE} DIRECTORY ) +- +- install( DIRECTORY "${LIBNGSPICE_PATH}/" +- DESTINATION "${OSX_BUNDLE_INSTALL_PLUGIN_DIR}/sim" +- FILES_MATCHING PATTERN "*.dylib") +- install( DIRECTORY "${LIBNGSPICE_PATH}/ngspice" +- DESTINATION "${OSX_BUNDLE_INSTALL_PLUGIN_DIR}/sim" ) ++ # bundle libngspice and codemodels (only when ngspice is enabled) ++ if( KICAD_USE_NGSPICE AND NGSPICE_LIBRARY ) ++ get_filename_component( ABS_LIBNGSPICE ${NGSPICE_LIBRARY} ABSOLUTE ) ++ get_filename_component( LIBNGSPICE_PATH ${ABS_LIBNGSPICE} DIRECTORY ) ++ ++ install( DIRECTORY "${LIBNGSPICE_PATH}/" ++ DESTINATION "${OSX_BUNDLE_INSTALL_PLUGIN_DIR}/sim" ++ FILES_MATCHING PATTERN "*.dylib") ++ install( DIRECTORY "${LIBNGSPICE_PATH}/ngspice" ++ DESTINATION "${OSX_BUNDLE_INSTALL_PLUGIN_DIR}/sim" ) ++ endif() + + install( CODE [[ + include( ${KICAD_CMAKE_MODULE_PATH}/InstallSteps/InstallMacOS.cmake ) +diff --git a/kicad/CMakeLists.txt b/kicad/CMakeLists.txt +index b7e78725d0..c615c9022c 100644 +--- a/kicad/CMakeLists.txt ++++ b/kicad/CMakeLists.txt +@@ -37,7 +37,6 @@ set( KICAD_SRCS + import_proj.cpp + import_project.cpp + kicad_manager_frame.cpp +- local_history_pane.cpp + menubar.cpp + project_template.cpp + project_tree_pane.cpp +@@ -50,6 +49,21 @@ set( KICAD_SRCS + tools/kicad_manager_control.cpp + ) + ++# Local history pane requires git support ++if( KICAD_USE_GIT ) ++ list( APPEND KICAD_SRCS ++ local_history_pane.cpp ++ ) ++else() ++ # Add comprehensive git stubs when git is disabled ++ set( STUBS_SRC_DIR "${CMAKE_SOURCE_DIR}/../stubs/src" ) ++ if( EXISTS "${STUBS_SRC_DIR}/kicad_git_all_stubs.cpp" ) ++ list( APPEND KICAD_SRCS ++ "${STUBS_SRC_DIR}/kicad_git_all_stubs.cpp" ++ ) ++ endif() ++endif() ++ + set( KICAD_CLI_SRCS + cli/command.cpp + cli/command_jobset_run.cpp +diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt +index 7ea9bdcda5..ba0be19156 100644 +--- a/pcbnew/CMakeLists.txt ++++ b/pcbnew/CMakeLists.txt +@@ -248,15 +248,6 @@ set( PCBNEW_EXPORTERS + exporters/export_gencad.cpp + exporters/export_gencad_writer.cpp + exporters/export_idf.cpp +- exporters/step/exporter_step.cpp +- exporters/step/kicad3d_info.cpp +- exporters/step/step_pcb_model.cpp +- exporters/step/KI_XCAFDoc_AssemblyGraph.cxx +- exporters/u3d/bit_stream_writer.cpp +- exporters/u3d/constants.cpp +- exporters/u3d/context_manager.cpp +- exporters/u3d/data_block.cpp +- exporters/u3d/writer.cpp + exporters/exporter_vrml.cpp + exporters/place_file_exporter.cpp + exporters/gen_drill_report_files.cpp +@@ -267,6 +258,24 @@ set( PCBNEW_EXPORTERS + exporters/gerber_placefile_writer.cpp + ) + ++# STEP and U3D exporter files - require OpenCASCADE ++if( KICAD_USE_OCC ) ++ list( APPEND PCBNEW_SRCS ++ exporters/step/exporter_step.cpp ++ exporters/step/kicad3d_info.cpp ++ exporters/step/step_pcb_model.cpp ++ exporters/step/KI_XCAFDoc_AssemblyGraph.cxx ++ exporters/u3d/bit_stream_writer.cpp ++ exporters/u3d/constants.cpp ++ exporters/u3d/context_manager.cpp ++ exporters/u3d/data_block.cpp ++ exporters/u3d/writer.cpp ++ ) ++else() ++ # OCC is disabled - stubs will be added to PCBNEW_SRCS after it is defined (around line 491) ++ message(STATUS "PCBNEW: KICAD_USE_OCC is OFF") ++endif() ++ + set( PCBNEW_MICROWAVE_SRCS + microwave/microwave_footprint.cpp + microwave/microwave_inductor.cpp +@@ -459,9 +468,14 @@ set( PCBNEW_CLASS_SRCS + + ) + +-set( PCBNEW_GIT_SRCS +- git/kigit_pcb_merge.cpp ++# Git sources - only include when git support is enabled ++if( KICAD_USE_GIT ) ++ set( PCBNEW_GIT_SRCS ++ git/kigit_pcb_merge.cpp + ) ++else() ++ set( PCBNEW_GIT_SRCS "" ) ++endif() + + set( PCBNEW_SRCS + ${PCBNEW_MICROWAVE_SRCS} +@@ -480,10 +494,27 @@ set( PCBNEW_SCRIPTING_PYTHON_HELPERS + python/scripting/pcbnew_footprint_wizards.cpp + python/scripting/pcbnew_scripting_helpers.cpp + python/scripting/pcbnew_scripting.cpp +- python/scripting/pcbnew_utils_3d.cpp + python/scripting/pcb_scripting_tool.cpp + ) + ++# 3D utils require OpenCASCADE ++if( KICAD_USE_OCC ) ++ list( APPEND PCBNEW_SCRIPTING_PYTHON_HELPERS ++ python/scripting/pcbnew_utils_3d.cpp ++ ) ++else() ++ # Add OCC stub implementations when OCC is disabled ++ set( STUBS_SRC_DIR "${CMAKE_SOURCE_DIR}/../stubs/src" ) ++ if( EXISTS "${STUBS_SRC_DIR}/occ_stubs.cpp" ) ++ message(STATUS "PCBNEW: Adding occ_stubs.cpp to PCBNEW_SRCS") ++ list( APPEND PCBNEW_SRCS ++ "${STUBS_SRC_DIR}/occ_stubs.cpp" ++ ) ++ else() ++ message(WARNING "PCBNEW: occ_stubs.cpp NOT FOUND at ${STUBS_SRC_DIR}/occ_stubs.cpp") ++ endif() ++endif() ++ + if( KICAD_IPC_API ) + set( PCBNEW_SRCS ${PCBNEW_SRCS} + api/api_handler_pcb.cpp +diff --git a/plugins/3d/CMakeLists.txt b/plugins/3d/CMakeLists.txt +index 9c5e4095ae..ceda7f3aae 100644 +--- a/plugins/3d/CMakeLists.txt ++++ b/plugins/3d/CMakeLists.txt +@@ -1,3 +1,7 @@ + add_subdirectory( idf ) + add_subdirectory( vrml ) +-add_subdirectory( oce ) +\ No newline at end of file ++ ++# OCC plugin requires OpenCASCADE ++if( KICAD_USE_OCC ) ++ add_subdirectory( oce ) ++endif() +\ No newline at end of file diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 0000000..192048f --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,162 @@ +#!/bin/bash +# +# KiCad Wasm Port - Build Script +# +# This script builds KiCad with optional dependencies disabled. +# + +set -e + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" +KICAD_DIR="$PROJECT_ROOT/kicad" +BUILD_DIR="$PROJECT_ROOT/build" +CMAKE_MODULE_PATH="$PROJECT_ROOT/cmake" +STUBS_DIR="$PROJECT_ROOT/stubs/include" + +# Default options +USE_CURL="${KICAD_USE_CURL:-OFF}" +USE_GIT="${KICAD_USE_GIT:-OFF}" +USE_OCC="${KICAD_USE_OCC:-OFF}" +USE_NGSPICE="${KICAD_USE_NGSPICE:-OFF}" +BUILD_TYPE="${CMAKE_BUILD_TYPE:-Release}" +PARALLEL_JOBS="${PARALLEL_JOBS:-$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 4)}" + +show_help() { + echo "KiCad Wasm Port - Build Script" + echo "" + echo "Usage: $0 [options]" + echo "" + echo "Options:" + echo " --with-curl Enable CURL (network features)" + echo " --with-git Enable libgit2 (git integration)" + echo " --with-occ Enable OpenCASCADE (STEP/3D)" + echo " --with-ngspice Enable ngspice (SPICE simulation)" + echo " --debug Build in Debug mode" + echo " --clean Clean build directory first" + echo " -j N Number of parallel jobs (default: $PARALLEL_JOBS)" + echo " --configure-only Only run cmake, don't build" + echo " -h, --help Show this help" + echo "" + echo "Environment variables:" + echo " KICAD_USE_CURL=ON|OFF (default: OFF)" + echo " KICAD_USE_GIT=ON|OFF (default: OFF)" + echo " KICAD_USE_OCC=ON|OFF (default: OFF)" + echo " KICAD_USE_NGSPICE=ON|OFF (default: OFF)" + echo " CMAKE_BUILD_TYPE=Release|Debug" + echo "" +} + +CLEAN_BUILD=0 +CONFIGURE_ONLY=0 + +# Parse arguments +while [[ $# -gt 0 ]]; do + case $1 in + --with-curl) + USE_CURL=ON + shift + ;; + --with-git) + USE_GIT=ON + shift + ;; + --with-occ) + USE_OCC=ON + shift + ;; + --with-ngspice) + USE_NGSPICE=ON + shift + ;; + --debug) + BUILD_TYPE=Debug + shift + ;; + --clean) + CLEAN_BUILD=1 + shift + ;; + -j) + PARALLEL_JOBS="$2" + shift 2 + ;; + --configure-only) + CONFIGURE_ONLY=1 + shift + ;; + -h|--help) + show_help + exit 0 + ;; + *) + echo "Unknown option: $1" + show_help + exit 1 + ;; + esac +done + +echo "=== KiCad Wasm Port - Build ===" +echo "" +echo "Configuration:" +echo " Build type: $BUILD_TYPE" +echo " CURL: $USE_CURL" +echo " Git: $USE_GIT" +echo " OpenCASCADE: $USE_OCC" +echo " ngspice: $USE_NGSPICE" +echo " Parallel jobs: $PARALLEL_JOBS" +echo "" + +# Check if kicad exists +if [ ! -f "$KICAD_DIR/CMakeLists.txt" ]; then + echo "Error: KiCad source not found at $KICAD_DIR" + echo "Run: git submodule update --init --recursive" + exit 1 +fi + +# Clean if requested +if [ $CLEAN_BUILD -eq 1 ] && [ -d "$BUILD_DIR" ]; then + echo "Cleaning build directory..." + rm -rf "$BUILD_DIR" +fi + +# Create build directory +mkdir -p "$BUILD_DIR" +cd "$BUILD_DIR" + +# Additional include paths for stubs +EXTRA_INCLUDES="" +if [ "$USE_CURL" = "OFF" ] || [ "$USE_GIT" = "OFF" ]; then + EXTRA_INCLUDES="-DCMAKE_CXX_FLAGS=-I$STUBS_DIR" +fi + +# Configure +echo "Running CMake..." +cmake "$KICAD_DIR" \ + -DCMAKE_BUILD_TYPE="$BUILD_TYPE" \ + -DCMAKE_MODULE_PATH="$CMAKE_MODULE_PATH" \ + -DKICAD_USE_CURL="$USE_CURL" \ + -DKICAD_USE_GIT="$USE_GIT" \ + -DKICAD_USE_OCC="$USE_OCC" \ + -DKICAD_USE_NGSPICE="$USE_NGSPICE" \ + -DKICAD_SCRIPTING_WXPYTHON=OFF \ + -DKICAD_BUILD_QA_TESTS=OFF \ + -DKICAD_BUILD_I18N=OFF \ + $EXTRA_INCLUDES + +if [ $CONFIGURE_ONLY -eq 1 ]; then + echo "" + echo "Configuration complete. Run 'make -j$PARALLEL_JOBS' in $BUILD_DIR to build." + exit 0 +fi + +# Build +echo "" +echo "Building..." +cmake --build . --parallel "$PARALLEL_JOBS" + +echo "" +echo "=== Build Complete ===" +echo "" +echo "Binaries are in: $BUILD_DIR" diff --git a/scripts/prepare.sh b/scripts/prepare.sh new file mode 100755 index 0000000..588f2b6 --- /dev/null +++ b/scripts/prepare.sh @@ -0,0 +1,120 @@ +#!/bin/bash +# +# KiCad Wasm Port - Prepare Script +# +# This script applies patches to the KiCad source code to enable +# building with optional dependencies disabled. +# + +set -e + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" +KICAD_DIR="$PROJECT_ROOT/kicad" +PATCHES_DIR="$PROJECT_ROOT/patches" + +echo "=== KiCad Wasm Port - Prepare ===" +echo "Project root: $PROJECT_ROOT" +echo "KiCad source: $KICAD_DIR" +echo "" + +# Check if kicad submodule is initialized +if [ ! -f "$KICAD_DIR/CMakeLists.txt" ]; then + echo "Error: KiCad submodule not initialized." + echo "Run: git submodule update --init --recursive" + exit 1 +fi + +# Check if patches directory exists +if [ ! -d "$PATCHES_DIR" ]; then + echo "Error: Patches directory not found: $PATCHES_DIR" + exit 1 +fi + +# Function to check if a patch is already applied +patch_already_applied() { + local patch_file="$1" + # Try to reverse-apply the patch (dry run) + # If it succeeds, the patch is already applied + cd "$KICAD_DIR" + if git apply --reverse --check "$patch_file" 2>/dev/null; then + return 0 + else + return 1 + fi +} + +# Function to apply a patch +apply_patch() { + local patch_file="$1" + local patch_name="$(basename "$patch_file")" + + echo "Checking patch: $patch_name" + + if patch_already_applied "$patch_file"; then + echo " -> Already applied, skipping" + return 0 + fi + + echo " -> Applying..." + cd "$KICAD_DIR" + + # Try to apply the patch + if git apply --check "$patch_file" 2>/dev/null; then + git apply "$patch_file" + echo " -> Success" + else + echo " -> Warning: Patch may not apply cleanly, trying with -3 (three-way merge)" + if git apply -3 "$patch_file" 2>/dev/null; then + echo " -> Success with three-way merge" + else + echo " -> Error: Patch failed to apply" + echo " You may need to manually resolve conflicts or update the patch" + return 1 + fi + fi +} + +# Apply all patches in order +echo "Applying patches..." +echo "" + +patch_count=0 +patch_failed=0 + +for patch_file in "$PATCHES_DIR"/*.patch; do + if [ -f "$patch_file" ]; then + if apply_patch "$patch_file"; then + ((patch_count++)) + else + ((patch_failed++)) + fi + echo "" + fi +done + +echo "=== Summary ===" +echo "Patches applied: $patch_count" +echo "Patches failed: $patch_failed" + +if [ $patch_failed -gt 0 ]; then + echo "" + echo "Some patches failed to apply. Please check the errors above." + exit 1 +fi + +echo "" +echo "=== Next Steps ===" +echo "" +echo "Build with optional dependencies disabled:" +echo "" +echo " mkdir build && cd build" +echo " cmake ../kicad \\" +echo " -DKICAD_USE_CURL=OFF \\" +echo " -DKICAD_USE_GIT=OFF \\" +echo " -DKICAD_USE_OCC=OFF \\" +echo " -DKICAD_USE_NGSPICE=OFF \\" +echo " -DCMAKE_PREFIX_PATH=\"\$(pwd)/../stubs/include\"" +echo " make -j\$(nproc)" +echo "" +echo "Done!" diff --git a/scripts/update-kicad.sh b/scripts/update-kicad.sh new file mode 100755 index 0000000..1f7987c --- /dev/null +++ b/scripts/update-kicad.sh @@ -0,0 +1,137 @@ +#!/bin/bash +# +# KiCad Wasm Port - Update KiCad Submodule +# +# This script updates the KiCad submodule to a new version and +# helps regenerate patches if needed. +# + +set -e + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" +KICAD_DIR="$PROJECT_ROOT/kicad" +PATCHES_DIR="$PROJECT_ROOT/patches" + +echo "=== KiCad Wasm Port - Update KiCad ===" +echo "" + +# Check if kicad submodule exists +if [ ! -d "$KICAD_DIR/.git" ] && [ ! -f "$KICAD_DIR/.git" ]; then + echo "Error: KiCad submodule not initialized." + echo "Run: git submodule update --init --recursive" + exit 1 +fi + +# Parse arguments +TARGET_REF="${1:-}" +FORCE_UPDATE=0 + +if [ "$1" = "--force" ] || [ "$2" = "--force" ]; then + FORCE_UPDATE=1 +fi + +show_usage() { + echo "Usage: $0 [] [--force]" + echo "" + echo "Arguments:" + echo " Git reference (branch, tag, or commit) to update to" + echo " Examples: 8.0, master, v8.0.0, abc1234" + echo " --force Force update even if patches need manual intervention" + echo "" + echo "If no ref is provided, shows current KiCad version." +} + +# Show current version +show_current_version() { + cd "$KICAD_DIR" + echo "Current KiCad version:" + echo " Branch: $(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo 'detached')" + echo " Commit: $(git rev-parse --short HEAD)" + echo " Date: $(git log -1 --format=%ci)" + + # Check if there are local modifications + if ! git diff --quiet; then + echo "" + echo "Warning: There are uncommitted changes in the KiCad directory" + git status --short + fi +} + +# Revert patches before update +revert_patches() { + echo "Reverting existing patches..." + cd "$KICAD_DIR" + + for patch_file in "$PATCHES_DIR"/*.patch; do + if [ -f "$patch_file" ]; then + patch_name="$(basename "$patch_file")" + # Try to reverse the patch + if git apply --reverse --check "$patch_file" 2>/dev/null; then + echo " Reverting: $patch_name" + git apply --reverse "$patch_file" + else + echo " Skipping (not applied): $patch_name" + fi + fi + done +} + +# Update submodule +update_submodule() { + local ref="$1" + echo "" + echo "Updating KiCad to: $ref" + + cd "$KICAD_DIR" + + # Fetch latest + echo "Fetching from origin..." + git fetch origin + + # Checkout the target ref + echo "Checking out $ref..." + git checkout "$ref" + + # If it's a branch, pull latest + if git rev-parse --verify "origin/$ref" >/dev/null 2>&1; then + echo "Pulling latest from origin/$ref..." + git pull origin "$ref" + fi + + echo "" + show_current_version +} + +# Main logic +if [ -z "$TARGET_REF" ] || [ "$TARGET_REF" = "--force" ]; then + show_current_version + echo "" + show_usage + exit 0 +fi + +echo "Preparing to update KiCad..." +echo "" + +# Show current version +show_current_version +echo "" + +# Revert patches first +revert_patches +echo "" + +# Update submodule +update_submodule "$TARGET_REF" +echo "" + +# Re-apply patches +echo "Re-applying patches..." +"$SCRIPT_DIR/prepare.sh" + +echo "" +echo "=== Update Complete ===" +echo "" +echo "Don't forget to test the build:" +echo " cd build && cmake --build . --clean-first" diff --git a/stubs/include/Standard_Version.hxx b/stubs/include/Standard_Version.hxx new file mode 100644 index 0000000..6aaf37b --- /dev/null +++ b/stubs/include/Standard_Version.hxx @@ -0,0 +1,23 @@ +/* + * KiCad Wasm Port - OpenCASCADE Standard_Version stub + * + * Provides stub version macros when OCC is disabled. + */ + +#ifndef _Standard_Version_HeaderFile +#define _Standard_Version_HeaderFile + +// Stub version when OCC is disabled +#define OCC_VERSION_MAJOR 0 +#define OCC_VERSION_MINOR 0 +#define OCC_VERSION_MAINTENANCE 0 +#define OCC_VERSION_DEVELOPMENT "N/A" + +#define OCC_VERSION_STRING "0.0.0" +#define OCC_VERSION_STRING_EXT "0.0.0 (disabled)" +#define OCC_VERSION_COMPLETE "disabled" + +#define OCC_VERSION 0 +#define OCC_VERSION_HEX 0x000000 + +#endif // _Standard_Version_HeaderFile diff --git a/stubs/include/curl/curl.h b/stubs/include/curl/curl.h new file mode 100644 index 0000000..8b3d7be --- /dev/null +++ b/stubs/include/curl/curl.h @@ -0,0 +1,149 @@ +/* + * KiCad Wasm Port - CURL Stub Header + * + * This is a minimal stub header for when KICAD_USE_CURL=0. + * It provides just enough type definitions to let the code compile + * without the actual libcurl library. + */ + +#ifndef KICAD_WASM_CURL_STUB_H +#define KICAD_WASM_CURL_STUB_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* CURL handle type */ +typedef void CURL; + +/* CURL multi handle */ +typedef void CURLM; + +/* CURL share handle */ +typedef void CURLSH; + +/* Linked list for headers */ +struct curl_slist { + char *data; + struct curl_slist *next; +}; + +/* Error codes */ +typedef enum { + CURLE_OK = 0, + CURLE_UNSUPPORTED_PROTOCOL, + CURLE_FAILED_INIT, + CURLE_URL_MALFORMAT, + CURLE_NOT_BUILT_IN, + CURLE_COULDNT_RESOLVE_PROXY, + CURLE_COULDNT_RESOLVE_HOST, + CURLE_COULDNT_CONNECT, + CURLE_REMOTE_ACCESS_DENIED = 9, + CURLE_HTTP_RETURNED_ERROR = 22, + CURLE_WRITE_ERROR = 23, + CURLE_READ_ERROR = 26, + CURLE_OUT_OF_MEMORY = 27, + CURLE_OPERATION_TIMEDOUT = 28, + CURLE_SSL_CONNECT_ERROR = 35, + CURLE_ABORTED_BY_CALLBACK = 42, + CURLE_GOT_NOTHING = 52, + CURLE_SSL_ENGINE_NOTFOUND = 53, + CURLE_SSL_ENGINE_SETFAILED = 54, + CURLE_SEND_ERROR = 55, + CURLE_RECV_ERROR = 56, + CURLE_SSL_CERTPROBLEM = 58, + CURLE_SSL_CIPHER = 59, + CURLE_PEER_FAILED_VERIFICATION = 60, + CURLE_BAD_CONTENT_ENCODING = 61, + CURLE_FILESIZE_EXCEEDED = 63, + CURLE_SEND_FAIL_REWIND = 65, + CURLE_LOGIN_DENIED = 67, + CURLE_REMOTE_DISK_FULL = 70, + CURLE_REMOTE_FILE_EXISTS = 73, + CURLE_SSH = 79, + CURLE_AGAIN = 81, + CURLE_SSL_CRL_BADFILE = 82, + CURLE_SSL_ISSUER_ERROR = 83, + CURLE_CHUNK_FAILED = 88, + CURLE_NO_CONNECTION_AVAILABLE = 89, + CURLE_SSL_PINNEDPUBKEYNOTMATCH = 90, + CURLE_SSL_INVALIDCERTSTATUS = 91, + CURLE_HTTP2_STREAM = 92, + CURL_LAST +} CURLcode; + +/* CURL options (minimal subset) */ +typedef enum { + CURLOPT_URL = 10002, + CURLOPT_WRITEFUNCTION = 20011, + CURLOPT_WRITEDATA = 10001, + CURLOPT_USERAGENT = 10018, + CURLOPT_HTTPHEADER = 10023, + CURLOPT_POSTFIELDS = 10015, + CURLOPT_FOLLOWLOCATION = 52, + CURLOPT_SSL_VERIFYPEER = 64, + CURLOPT_SSL_VERIFYHOST = 81, + CURLOPT_TIMEOUT = 13, + CURLOPT_CONNECTTIMEOUT = 78, + CURLOPT_NOPROGRESS = 43, + CURLOPT_PROGRESSFUNCTION = 20056, + CURLOPT_PROGRESSDATA = 10057, + CURLOPT_XFERINFOFUNCTION = 20219, + CURLOPT_XFERINFODATA = 10057 +} CURLoption; + +/* CURL info types */ +typedef enum { + CURLINFO_RESPONSE_CODE = 0x200002, + CURLINFO_CONTENT_LENGTH_DOWNLOAD = 0x300015, + CURLINFO_SIZE_DOWNLOAD = 0x300008 +} CURLINFO; + +/* Global flags */ +#define CURL_GLOBAL_DEFAULT 3 +#define CURL_GLOBAL_SSL 1 +#define CURL_GLOBAL_WIN32 2 +#define CURL_GLOBAL_ALL 3 + +/* Stub function declarations - all return error or NULL */ +static inline CURL* curl_easy_init(void) { return NULL; } +static inline void curl_easy_cleanup(CURL* curl) { (void)curl; } +static inline CURLcode curl_easy_setopt(CURL* curl, CURLoption option, ...) { + (void)curl; (void)option; + return CURLE_NOT_BUILT_IN; +} +static inline CURLcode curl_easy_perform(CURL* curl) { + (void)curl; + return CURLE_NOT_BUILT_IN; +} +static inline CURLcode curl_easy_getinfo(CURL* curl, CURLINFO info, ...) { + (void)curl; (void)info; + return CURLE_NOT_BUILT_IN; +} +static inline const char* curl_easy_strerror(CURLcode error) { + (void)error; + return "CURL support not built in"; +} +static inline char* curl_easy_escape(CURL* curl, const char* string, int length) { + (void)curl; (void)string; (void)length; + return NULL; +} +static inline void curl_free(void* p) { (void)p; } + +static inline struct curl_slist* curl_slist_append(struct curl_slist* list, const char* string) { + (void)list; (void)string; + return NULL; +} +static inline void curl_slist_free_all(struct curl_slist* list) { (void)list; } + +static inline CURLcode curl_global_init(long flags) { (void)flags; return CURLE_OK; } +static inline void curl_global_cleanup(void) { } +static inline const char* curl_version(void) { return "curl-stub/0.0 (KICAD_USE_CURL=0)"; } + +#ifdef __cplusplus +} +#endif + +#endif /* KICAD_WASM_CURL_STUB_H */ diff --git a/stubs/include/curl/easy.h b/stubs/include/curl/easy.h new file mode 100644 index 0000000..61b28a3 --- /dev/null +++ b/stubs/include/curl/easy.h @@ -0,0 +1,12 @@ +/* + * KiCad Wasm Port - CURL Easy API Stub Header + * + * This stub is empty because curl.h includes all the easy API. + */ + +#ifndef KICAD_WASM_CURL_EASY_STUB_H +#define KICAD_WASM_CURL_EASY_STUB_H + +#include "curl.h" + +#endif /* KICAD_WASM_CURL_EASY_STUB_H */ diff --git a/stubs/include/git2.h b/stubs/include/git2.h new file mode 100644 index 0000000..6a3fcfe --- /dev/null +++ b/stubs/include/git2.h @@ -0,0 +1,587 @@ +/* + * KiCad Wasm Port - libgit2 Stub Header + * + * This is a minimal stub header for when KICAD_USE_GIT=0. + * It provides just enough type definitions to let the code compile + * without the actual libgit2 library. + */ + +#ifndef KICAD_WASM_GIT2_STUB_H +#define KICAD_WASM_GIT2_STUB_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Basic types + */ +typedef int64_t git_off_t; +typedef int64_t git_time_t; + +typedef struct git_repository git_repository; +typedef struct git_reference git_reference; +typedef struct git_commit git_commit; +typedef struct git_tree git_tree; +typedef struct git_tree_entry git_tree_entry; +typedef struct git_index git_index; +typedef struct git_index_entry git_index_entry; +typedef struct git_config git_config; +typedef struct git_remote git_remote; +typedef struct git_signature git_signature; +typedef struct git_revwalk git_revwalk; +typedef struct git_diff git_diff; +typedef struct git_diff_delta git_diff_delta; +typedef struct git_diff_file git_diff_file; +typedef struct git_diff_options git_diff_options; +typedef struct git_status_list git_status_list; +typedef struct git_status_entry git_status_entry; +typedef struct git_branch_iterator git_branch_iterator; +typedef struct git_annotated_commit git_annotated_commit; +typedef struct git_rebase git_rebase; +typedef struct git_rebase_operation git_rebase_operation; +typedef struct git_merge_options git_merge_options; +typedef struct git_checkout_options git_checkout_options; +typedef struct git_fetch_options git_fetch_options; +typedef struct git_push_options git_push_options; +typedef struct git_clone_options git_clone_options; +typedef struct git_credential git_credential; +typedef struct git_credential git_cred; /* Alias for older API */ +typedef struct git_blob git_blob; +typedef struct git_object git_object; +typedef struct git_buf git_buf; +typedef struct git_strarray git_strarray; +typedef struct git_odb git_odb; +typedef struct git_odb_backend git_odb_backend; +typedef struct git_refdb git_refdb; +typedef struct git_refdb_backend git_refdb_backend; +typedef struct git_indexer_progress git_indexer_progress; +typedef struct git_blame git_blame; +typedef struct git_blame_options git_blame_options; +typedef struct git_blame_hunk git_blame_hunk; +typedef struct git_config_entry git_config_entry; +typedef struct git_config_iterator git_config_iterator; +typedef struct git_patch git_patch; +typedef struct git_oidarray git_oidarray; +typedef struct git_describe_result git_describe_result; +typedef struct git_diff_stats git_diff_stats; +typedef struct git_filter_list git_filter_list; +typedef struct git_transfer_progress git_transfer_progress; +typedef git_transfer_progress git_indexer_progress_alias; /* Alias in newer libgit2 */ +typedef struct git_note git_note; +typedef struct git_note_iterator git_note_iterator; +typedef struct git_status_options git_status_options; +typedef struct git_submodule git_submodule; +typedef struct git_worktree git_worktree; +typedef struct git_tag git_tag; +typedef struct git_indexer git_indexer; +typedef struct git_index_iterator git_index_iterator; +typedef struct git_index_conflict_iterator git_index_conflict_iterator; + +/* git_oid - 20 byte SHA1 */ +#define GIT_OID_RAWSZ 20 +#define GIT_OID_HEXSZ 40 + +typedef struct git_oid { + unsigned char id[GIT_OID_RAWSZ]; +} git_oid; + +/* git_time */ +typedef struct git_time { + git_time_t time; + int offset; + char sign; +} git_time; + +/* git_signature */ +struct git_signature { + char *name; + char *email; + git_time when; +}; + +/* git_strarray */ +struct git_strarray { + char **strings; + size_t count; +}; + +/* git_buf */ +struct git_buf { + char *ptr; + size_t reserved; + size_t size; +}; + +/* Error codes */ +/* Error class enum */ +typedef enum { + GIT_ERROR_NONE = 0, + GIT_ERROR_NOMEMORY = 1, + GIT_ERROR_OS = 2, + GIT_ERROR_INVALID = 3, + GIT_ERROR_REFERENCE = 4, + GIT_ERROR_ZLIB = 5, + GIT_ERROR_REPOSITORY = 6, + GIT_ERROR_CONFIG = 7, + GIT_ERROR_REGEX = 8, + GIT_ERROR_ODB = 9, + GIT_ERROR_INDEX = 10, + GIT_ERROR_OBJECT = 11, + GIT_ERROR_NET = 12, + GIT_ERROR_TAG = 13, + GIT_ERROR_TREE = 14, + GIT_ERROR_INDEXER = 15, + GIT_ERROR_SSL = 16, + GIT_ERROR_SUBMODULE = 17, + GIT_ERROR_THREAD = 18, + GIT_ERROR_STASH = 19, + GIT_ERROR_CHECKOUT = 20, + GIT_ERROR_FETCHHEAD = 21, + GIT_ERROR_MERGE = 22, + GIT_ERROR_SSH = 23, + GIT_ERROR_FILTER = 24, + GIT_ERROR_REVERT = 25, + GIT_ERROR_CALLBACK = 26, + GIT_ERROR_CHERRYPICK = 27, + GIT_ERROR_DESCRIBE = 28, + GIT_ERROR_REBASE = 29, + GIT_ERROR_FILESYSTEM = 30, + GIT_ERROR_PATCH = 31, + GIT_ERROR_WORKTREE = 32, + GIT_ERROR_SHA1 = 33, + GIT_ERROR_HTTP = 34, + GIT_ERROR_INTERNAL = 35 +} git_error_t; + +/* Error codes */ +typedef enum { + GIT_OK = 0, + GIT_ERROR = -1, + GIT_ENOTFOUND = -3, + GIT_EEXISTS = -4, + GIT_EAMBIGUOUS = -5, + GIT_EBUFS = -6, + GIT_EUSER = -7, + GIT_EBAREREPO = -8, + GIT_EUNBORNBRANCH = -9, + GIT_EUNMERGED = -10, + GIT_ENONFASTFORWARD = -11, + GIT_EINVALIDSPEC = -12, + GIT_ECONFLICT = -13, + GIT_ELOCKED = -14, + GIT_EMODIFIED = -15, + GIT_EAUTH = -16, + GIT_ECERTIFICATE = -17, + GIT_EAPPLIED = -18, + GIT_EPEEL = -19, + GIT_EEOF = -20, + GIT_EINVALID = -21, + GIT_EUNCOMMITTED = -22, + GIT_EDIRECTORY = -23, + GIT_EMERGECONFLICT = -24, + GIT_PASSTHROUGH = -30, + GIT_ITEROVER = -31, + GIT_RETRY = -32, + GIT_EMISMATCH = -33, + GIT_EINDEXDIRTY = -34, + GIT_EAPPLYFAIL = -35 +} git_error_code; + +/* Object types */ +typedef enum { + GIT_OBJECT_ANY = -2, + GIT_OBJECT_INVALID = -1, + GIT_OBJECT_COMMIT = 1, + GIT_OBJECT_TREE = 2, + GIT_OBJECT_BLOB = 3, + GIT_OBJECT_TAG = 4, + GIT_OBJECT_OFS_DELTA = 6, + GIT_OBJECT_REF_DELTA = 7 +} git_object_t; + +/* Branch types */ +typedef enum { + GIT_BRANCH_LOCAL = 1, + GIT_BRANCH_REMOTE = 2, + GIT_BRANCH_ALL = GIT_BRANCH_LOCAL | GIT_BRANCH_REMOTE +} git_branch_t; + +/* Status flags */ +typedef enum { + GIT_STATUS_CURRENT = 0, + GIT_STATUS_INDEX_NEW = (1u << 0), + GIT_STATUS_INDEX_MODIFIED = (1u << 1), + GIT_STATUS_INDEX_DELETED = (1u << 2), + GIT_STATUS_INDEX_RENAMED = (1u << 3), + GIT_STATUS_INDEX_TYPECHANGE = (1u << 4), + GIT_STATUS_WT_NEW = (1u << 7), + GIT_STATUS_WT_MODIFIED = (1u << 8), + GIT_STATUS_WT_DELETED = (1u << 9), + GIT_STATUS_WT_TYPECHANGE = (1u << 10), + GIT_STATUS_WT_RENAMED = (1u << 11), + GIT_STATUS_WT_UNREADABLE = (1u << 12), + GIT_STATUS_IGNORED = (1u << 14), + GIT_STATUS_CONFLICTED = (1u << 15) +} git_status_t; + +/* Delta types */ +typedef enum { + GIT_DELTA_UNMODIFIED = 0, + GIT_DELTA_ADDED = 1, + GIT_DELTA_DELETED = 2, + GIT_DELTA_MODIFIED = 3, + GIT_DELTA_RENAMED = 4, + GIT_DELTA_COPIED = 5, + GIT_DELTA_IGNORED = 6, + GIT_DELTA_UNTRACKED = 7, + GIT_DELTA_TYPECHANGE = 8, + GIT_DELTA_UNREADABLE = 9, + GIT_DELTA_CONFLICTED = 10 +} git_delta_t; + +/* Credential types */ +typedef enum { + GIT_CREDENTIAL_USERPASS_PLAINTEXT = (1u << 0), + GIT_CREDENTIAL_SSH_KEY = (1u << 1), + GIT_CREDENTIAL_SSH_CUSTOM = (1u << 2), + GIT_CREDENTIAL_DEFAULT = (1u << 3), + GIT_CREDENTIAL_SSH_INTERACTIVE = (1u << 4), + GIT_CREDENTIAL_USERNAME = (1u << 5), + GIT_CREDENTIAL_SSH_MEMORY = (1u << 6) +} git_credential_t; + +/* git_error */ +typedef struct git_error { + char *message; + int klass; +} git_error; + +/* + * Stub functions - all return error + */ + +/* Global */ +static inline int git_libgit2_init(void) { return 1; } +static inline int git_libgit2_shutdown(void) { return 0; } +static inline const git_error* git_error_last(void) { return NULL; } +static inline void git_error_clear(void) {} + +/* Repository */ +static inline int git_repository_open(git_repository **out, const char *path) { + (void)out; (void)path; + return GIT_ENOTFOUND; +} +static inline int git_repository_open_ext(git_repository **out, const char *path, + unsigned int flags, const char *ceiling_dirs) { + (void)out; (void)path; (void)flags; (void)ceiling_dirs; + return GIT_ENOTFOUND; +} +static inline int git_repository_init(git_repository **out, const char *path, unsigned is_bare) { + (void)out; (void)path; (void)is_bare; + return GIT_ERROR; +} +static inline void git_repository_free(git_repository *repo) { (void)repo; } +static inline int git_repository_head(git_reference **out, git_repository *repo) { + (void)out; (void)repo; + return GIT_ERROR; +} +static inline int git_repository_index(git_index **out, git_repository *repo) { + (void)out; (void)repo; + return GIT_ERROR; +} +static inline int git_repository_config(git_config **out, git_repository *repo) { + (void)out; (void)repo; + return GIT_ERROR; +} +static inline const char* git_repository_path(const git_repository *repo) { + (void)repo; + return NULL; +} +static inline const char* git_repository_workdir(const git_repository *repo) { + (void)repo; + return NULL; +} +static inline int git_repository_discover(git_buf *out, const char *start_path, + int across_fs, const char *ceiling_dirs) { + (void)out; (void)start_path; (void)across_fs; (void)ceiling_dirs; + return GIT_ENOTFOUND; +} + +/* Reference */ +static inline int git_reference_resolve(git_reference **out, const git_reference *ref) { + (void)out; (void)ref; + return GIT_ERROR; +} +static inline void git_reference_free(git_reference *ref) { (void)ref; } +static inline const git_oid* git_reference_target(const git_reference *ref) { + (void)ref; + return NULL; +} +static inline const char* git_reference_name(const git_reference *ref) { + (void)ref; + return NULL; +} +static inline int git_reference_name_to_id(git_oid *out, git_repository *repo, const char *name) { + (void)out; (void)repo; (void)name; + return GIT_ERROR; +} + +/* Branch */ +static inline int git_branch_name(const char **out, const git_reference *ref) { + (void)out; (void)ref; + return GIT_ERROR; +} +static inline int git_branch_is_head(const git_reference *branch) { + (void)branch; + return 0; +} +static inline int git_branch_iterator_new(git_branch_iterator **out, git_repository *repo, + git_branch_t list_flags) { + (void)out; (void)repo; (void)list_flags; + return GIT_ERROR; +} +static inline int git_branch_next(git_reference **out, git_branch_t *out_type, + git_branch_iterator *iter) { + (void)out; (void)out_type; (void)iter; + return GIT_ITEROVER; +} +static inline void git_branch_iterator_free(git_branch_iterator *iter) { (void)iter; } +static inline int git_branch_create(git_reference **out, git_repository *repo, + const char *branch_name, const git_commit *target, int force) { + (void)out; (void)repo; (void)branch_name; (void)target; (void)force; + return GIT_ERROR; +} + +/* Commit */ +static inline int git_commit_lookup(git_commit **commit, git_repository *repo, const git_oid *id) { + (void)commit; (void)repo; (void)id; + return GIT_ERROR; +} +static inline void git_commit_free(git_commit *commit) { (void)commit; } +static inline git_time_t git_commit_time(const git_commit *commit) { + (void)commit; + return 0; +} +static inline int git_commit_tree(git_tree **tree_out, const git_commit *commit) { + (void)tree_out; (void)commit; + return GIT_ERROR; +} +static inline const git_signature* git_commit_author(const git_commit *commit) { + (void)commit; + return NULL; +} +static inline const char* git_commit_message(const git_commit *commit) { + (void)commit; + return NULL; +} +static inline const char* git_commit_summary(const git_commit *commit) { + (void)commit; + return ""; +} +static inline unsigned int git_commit_parentcount(const git_commit *commit) { + (void)commit; + return 0; +} +static inline int git_commit_parent(git_commit **out, const git_commit *commit, unsigned int n) { + (void)out; (void)commit; (void)n; + return GIT_ERROR; +} + +/* Tree */ +static inline void git_tree_free(git_tree *tree) { (void)tree; } +static inline int git_tree_walk(const git_tree *tree, int mode, + int (*callback)(const char*, const git_tree_entry*, void*), void *payload) { + (void)tree; (void)mode; (void)callback; (void)payload; + return GIT_ERROR; +} +static inline const char* git_tree_entry_name(const git_tree_entry *entry) { + (void)entry; + return NULL; +} +static inline git_object_t git_tree_entry_type(const git_tree_entry *entry) { + (void)entry; + return GIT_OBJECT_INVALID; +} + +/* Index */ +static inline void git_index_free(git_index *index) { (void)index; } +static inline int git_index_add_bypath(git_index *index, const char *path) { + (void)index; (void)path; + return GIT_ERROR; +} +static inline int git_index_remove_bypath(git_index *index, const char *path) { + (void)index; (void)path; + return GIT_ERROR; +} +static inline int git_index_write(git_index *index) { + (void)index; + return GIT_ERROR; +} + +/* Revwalk */ +static inline int git_revwalk_new(git_revwalk **out, git_repository *repo) { + (void)out; (void)repo; + return GIT_ERROR; +} +static inline void git_revwalk_free(git_revwalk *walk) { (void)walk; } +static inline int git_revwalk_push(git_revwalk *walk, const git_oid *id) { + (void)walk; (void)id; + return GIT_ERROR; +} +static inline int git_revwalk_hide(git_revwalk *walk, const git_oid *id) { + (void)walk; (void)id; + return GIT_ERROR; +} +static inline int git_revwalk_next(git_oid *out, git_revwalk *walk) { + (void)out; (void)walk; + return GIT_ITEROVER; +} +static inline int git_revwalk_push_head(git_revwalk *walk) { + (void)walk; + return GIT_ERROR; +} +static inline void git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode) { + (void)walk; (void)sort_mode; +} + +/* Status */ +static inline int git_status_list_new(git_status_list **out, git_repository *repo, + const void *opts) { + (void)out; (void)repo; (void)opts; + return GIT_ERROR; +} +static inline void git_status_list_free(git_status_list *list) { (void)list; } + +/* Clone */ +static inline int git_clone(git_repository **out, const char *url, const char *local_path, + const git_clone_options *options) { + (void)out; (void)url; (void)local_path; (void)options; + return GIT_ERROR; +} + +/* Remote */ +static inline int git_remote_lookup(git_remote **out, git_repository *repo, const char *name) { + (void)out; (void)repo; (void)name; + return GIT_ERROR; +} +static inline void git_remote_free(git_remote *remote) { (void)remote; } + +/* Diff */ +static inline void git_diff_free(git_diff *diff) { (void)diff; } + +/* Signature */ +static inline void git_signature_free(git_signature *sig) { (void)sig; } + +/* Buffer */ +static inline void git_buf_dispose(git_buf *buffer) { + if (buffer) buffer->ptr = NULL; +} +static inline void git_buf_free(git_buf *buffer) { + if (buffer) buffer->ptr = NULL; +} + +/* Blob */ +static inline void git_blob_free(git_blob *blob) { (void)blob; } +static inline const void* git_blob_rawcontent(const git_blob *blob) { (void)blob; return NULL; } +static inline git_off_t git_blob_rawsize(const git_blob *blob) { (void)blob; return 0; } + +/* Blame */ +static inline void git_blame_free(git_blame *blame) { (void)blame; } + +/* Config entry/iterator */ +static inline void git_config_entry_free(git_config_entry *entry) { (void)entry; } +static inline void git_config_iterator_free(git_config_iterator *iter) { (void)iter; } + +/* Patch */ +static inline void git_patch_free(git_patch *patch) { (void)patch; } + +/* Config */ +static inline void git_config_free(git_config *cfg) { (void)cfg; } +static inline int git_config_get_entry(git_config_entry **out, const git_config *cfg, const char *name) { + (void)out; (void)cfg; (void)name; + return GIT_ENOTFOUND; +} + +/* Annotated commit */ +static inline void git_annotated_commit_free(git_annotated_commit *commit) { (void)commit; } + +/* Credential */ +static inline void git_credential_free(git_credential *cred) { (void)cred; } + +/* OID array */ +static inline void git_oidarray_free(git_oidarray *array) { (void)array; } + +/* Str array */ +static inline void git_strarray_free(git_strarray *array) { (void)array; } + +/* Describe result */ +static inline void git_describe_result_free(git_describe_result *result) { (void)result; } + +/* Diff stats */ +static inline void git_diff_stats_free(git_diff_stats *stats) { (void)stats; } + +/* Filter list */ +static inline void git_filter_list_free(git_filter_list *list) { (void)list; } + +/* Object */ +static inline void git_object_free(git_object *object) { (void)object; } +static inline int git_object_lookup(git_object **object, git_repository *repo, + const git_oid *id, git_object_t type) { + (void)object; (void)repo; (void)id; (void)type; + return GIT_ERROR; +} +static inline git_object_t git_object_type(const git_object *obj) { + (void)obj; + return GIT_OBJECT_INVALID; +} + +/* Note */ +static inline void git_note_free(git_note *note) { (void)note; } +static inline void git_note_iterator_free(git_note_iterator *it) { (void)it; } + +/* Submodule */ +static inline void git_submodule_free(git_submodule *submodule) { (void)submodule; } + +/* Worktree */ +static inline void git_worktree_free(git_worktree *wt) { (void)wt; } + +/* Tag */ +static inline void git_tag_free(git_tag *tag) { (void)tag; } + +/* Rebase */ +static inline void git_rebase_free(git_rebase *rebase) { (void)rebase; } + +/* Indexer */ +static inline void git_indexer_free(git_indexer *idx) { (void)idx; } + +/* Index iterator */ +static inline void git_index_iterator_free(git_index_iterator *iterator) { (void)iterator; } + +/* Index conflict iterator */ +static inline void git_index_conflict_iterator_free(git_index_conflict_iterator *iterator) { (void)iterator; } + +/* OID */ +static inline int git_oid_cmp(const git_oid *a, const git_oid *b) { + (void)a; (void)b; + return 0; +} +static inline char* git_oid_tostr_s(const git_oid *id) { + (void)id; + return (char*)""; +} +static inline char* git_oid_tostr(char *out, size_t n, const git_oid *id) { + (void)out; (void)n; (void)id; + if (out && n > 0) out[0] = '\0'; + return out; +} + +#ifdef __cplusplus +} +#endif + +#endif /* KICAD_WASM_GIT2_STUB_H */ diff --git a/stubs/include/git2/sys/errors.h b/stubs/include/git2/sys/errors.h new file mode 100644 index 0000000..86cc44a --- /dev/null +++ b/stubs/include/git2/sys/errors.h @@ -0,0 +1,27 @@ +/* + * KiCad Wasm Port - libgit2 sys/errors.h Stub Header + */ + +#ifndef KICAD_WASM_GIT2_SYS_ERRORS_STUB_H +#define KICAD_WASM_GIT2_SYS_ERRORS_STUB_H + +#include "../git2.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Error setting functions - stubs */ +static inline void git_error_set_str(int error_class, const char *string) { + (void)error_class; (void)string; +} + +static inline void git_error_set(int error_class, const char *fmt, ...) { + (void)error_class; (void)fmt; +} + +#ifdef __cplusplus +} +#endif + +#endif /* KICAD_WASM_GIT2_SYS_ERRORS_STUB_H */ diff --git a/stubs/include/git2/sys/merge.h b/stubs/include/git2/sys/merge.h new file mode 100644 index 0000000..620e1e0 --- /dev/null +++ b/stubs/include/git2/sys/merge.h @@ -0,0 +1,39 @@ +/* + * KiCad Wasm Port - libgit2 sys/merge.h Stub Header + */ + +#ifndef KICAD_WASM_GIT2_SYS_MERGE_STUB_H +#define KICAD_WASM_GIT2_SYS_MERGE_STUB_H + +#include "../git2.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Merge driver structures - minimal stubs */ +typedef struct git_merge_driver git_merge_driver; +typedef struct git_merge_driver_source git_merge_driver_source; + +typedef enum { + GIT_MERGE_DRIVER_BINARY = 0, + GIT_MERGE_DRIVER_TEXT = 1, + GIT_MERGE_DRIVER_UNION = 2 +} git_merge_driver_t; + +/* Registration functions - stubs */ +static inline int git_merge_driver_register(const char *name, git_merge_driver *driver) { + (void)name; (void)driver; + return GIT_ERROR; +} + +static inline int git_merge_driver_unregister(const char *name) { + (void)name; + return GIT_ERROR; +} + +#ifdef __cplusplus +} +#endif + +#endif /* KICAD_WASM_GIT2_SYS_MERGE_STUB_H */ diff --git a/stubs/include/ngspice/sharedspice.h b/stubs/include/ngspice/sharedspice.h new file mode 100644 index 0000000..c3687ad --- /dev/null +++ b/stubs/include/ngspice/sharedspice.h @@ -0,0 +1,90 @@ +/* + * KiCad Wasm Port - ngspice sharedspice.h stub + * + * Provides stub declarations when ngspice is disabled. + */ + +#ifndef NGSPICE_SHAREDSPICE_H +#define NGSPICE_SHAREDSPICE_H + +// Version information (stub) +#define NGSPICE_PACKAGE_VERSION "disabled" + +// ngspice types +typedef int NG_BOOL; + +// Callback function types (as used by ngspice) +// These are function types, not function pointer types. +// So SendChar* is a function pointer type. +typedef int SendChar(char*, int, void*); +typedef int SendStat(char*, int, void*); +typedef int ControlledExit(int, NG_BOOL, NG_BOOL, int, void*); +typedef int SendData(void*, int, int, void*); +typedef int SendInitData(void*, int, void*); +typedef int BGThreadRunning(NG_BOOL, int, void*); +typedef int GetVSRCData(double*, double, char*, int, void*); +typedef int GetISRCData(double*, double, char*, int, void*); +typedef int GetSyncData(double, double*, double, int, int, int, void*); + +// ngspice is loaded dynamically via dlopen/GetSymbol, so we don't need to +// provide stub implementations for the functions. KiCad will get nullptr +// from GetSymbol when ngspice is not available, and handle it appropriately. + +// However, we do need to provide the vector_info struct since it's used +// when processing data from ngspice. +struct vector_info; +typedef struct vector_info* pvector_info; + +// Basic type definitions that might be used +typedef struct { + char* name; + char* type; + void* data; +} vecvalues; + +typedef struct { + char* name; + int veccount; + vecvalues* vecarray; +} vecvaluesall; + +typedef struct { + char* name; + char* type; + int length; +} vecinfo; + +typedef struct { + char* name; + char* title; + char* date; + char* type; + int veccount; + vecinfo** vecs; +} vecinfosall; + +typedef struct { + double progress; + double value; +} plotmsg; + +// ngcomplex_t is a complex number with cx_real and cx_imag +typedef struct ngcomplex { + double cx_real; + double cx_imag; +} ngcomplex_t; + +// vector_info struct - matches the real ngspice definition +// Note: pvector_info is forward-declared above as struct vector_info* +struct vector_info { + char* v_name; // name of the vector + int v_type; // type of vector + short v_flags; // various flags + double* v_realdata; // real data (if real vector) + ngcomplex_t* v_compdata; // complex data (if complex vector) + int v_length; // length of the vector + int v_numdims; // number of dimensions (1 for scalar/vector) + int v_dims[8]; // dimension sizes +}; + +#endif // NGSPICE_SHAREDSPICE_H diff --git a/stubs/src/disabled_features_stubs.cpp b/stubs/src/disabled_features_stubs.cpp new file mode 100644 index 0000000..7869d66 --- /dev/null +++ b/stubs/src/disabled_features_stubs.cpp @@ -0,0 +1,205 @@ +/* + * KiCad Wasm Port - Stub implementations for disabled features + * + * Provides empty/stub implementations for functions from optional + * dependencies (curl, git, ngspice, OCC) when they are disabled. + */ + +#include +#include +#include +#include +#include +#include +#include + +// ============================================================================= +// CURL stubs (when KICAD_USE_CURL=OFF) +// ============================================================================= + +std::string GetKicadCurlVersion() +{ + return "disabled"; +} + +std::string GetCurlLibVersion() +{ + return "disabled"; +} + +static std::shared_mutex s_curlMutex; +static bool s_shuttingDown = false; + +void KICAD_CURL::Init() +{ + // No-op when curl is disabled +} + +void KICAD_CURL::Cleanup() +{ + // No-op when curl is disabled +} + +std::shared_mutex& KICAD_CURL::Mutex() +{ + return s_curlMutex; +} + +bool KICAD_CURL::IsShuttingDown() +{ + return s_shuttingDown; +} + +// ============================================================================= +// Local History stubs (when KICAD_USE_GIT=OFF) +// ============================================================================= + +LOCAL_HISTORY::LOCAL_HISTORY() {} +LOCAL_HISTORY::~LOCAL_HISTORY() {} + +bool LOCAL_HISTORY::Init( const wxString& aProjectPath ) { return false; } +bool LOCAL_HISTORY::CommitSnapshot( const std::vector& aFiles, const wxString& aTitle ) { return false; } +bool LOCAL_HISTORY::CommitFullProjectSnapshot( const wxString& aProjectPath, const wxString& aTitle ) { return false; } +void LOCAL_HISTORY::RegisterSaver( const void* aSaverObject, const std::function&)>& aSaver ) {} +void LOCAL_HISTORY::UnregisterSaver( const void* aSaverObject ) {} +void LOCAL_HISTORY::ClearAllSavers() {} +bool LOCAL_HISTORY::RunRegisteredSaversAndCommit( const wxString& aProjectPath, const wxString& aTitle ) { return false; } +void LOCAL_HISTORY::NoteFileChange( const wxString& aFile ) {} +bool LOCAL_HISTORY::CommitPending() { return false; } +bool LOCAL_HISTORY::HistoryExists( const wxString& aProjectPath ) { return false; } +bool LOCAL_HISTORY::TagSave( const wxString& aProjectPath, const wxString& aFileType ) { return false; } +bool LOCAL_HISTORY::CommitDuplicateOfLastSave( const wxString& aProjectPath, const wxString& aFileType, const wxString& aMessage ) { return false; } +bool LOCAL_HISTORY::EnforceSizeLimit( const wxString& aProjectPath, size_t aMaxBytes ) { return false; } +bool LOCAL_HISTORY::HeadNewerThanLastSave( const wxString& aProjectPath ) { return false; } +wxString LOCAL_HISTORY::GetHeadHash( const wxString& aProjectPath ) { return wxEmptyString; } +bool LOCAL_HISTORY::RestoreCommit( const wxString& aProjectPath, const wxString& aHash, wxWindow* aParent ) { return false; } +void LOCAL_HISTORY::ShowRestoreDialog( const wxString& aProjectPath, wxWindow* aParent ) {} + +// ============================================================================= +// Git utils stubs (when KICAD_USE_GIT=OFF) +// ============================================================================= + +namespace KIGIT +{ + +git_repository* PROJECT_GIT_UTILS::GetRepositoryForFile( const char* aFilename ) +{ + return nullptr; +} + +int PROJECT_GIT_UTILS::CreateBranch( git_repository* aRepo, const wxString& aBranchName ) +{ + return -1; // Error: git disabled +} + +wxString PROJECT_GIT_UTILS::GetCurrentHash( const wxString& aProjectFile, bool aShort ) +{ + return wxEmptyString; +} + +bool PROJECT_GIT_UTILS::RemoveVCS( git_repository*& aRepo, const wxString& aProjectPath, + bool aRemoveGitDir, wxString* aErrors ) +{ + return false; +} + +} // namespace KIGIT + +// ============================================================================= +// KICAD_CURL_EASY stubs (when KICAD_USE_CURL=OFF) +// ============================================================================= + +// Need to define CURL_PROGRESS before including the header +struct CURL_PROGRESS +{ + size_t dltotal; + size_t dlnow; + size_t ultotal; + size_t ulnow; +}; + +#include + +KICAD_CURL_EASY::KICAD_CURL_EASY() + : m_CURL( nullptr ) + , m_headers( nullptr ) + , progress( std::make_unique() ) +{ +} + +KICAD_CURL_EASY::~KICAD_CURL_EASY() {} + +int KICAD_CURL_EASY::Perform() { return -1; } + +bool KICAD_CURL_EASY::SetURL( const std::string& aURL ) +{ + (void)aURL; + return false; +} + +bool KICAD_CURL_EASY::SetFollowRedirects( bool aFollow ) +{ + (void)aFollow; + return false; +} + +void KICAD_CURL_EASY::SetHeader( const std::string& aName, const std::string& aValue ) +{ + (void)aName; (void)aValue; +} + +bool KICAD_CURL_EASY::SetUserAgent( const std::string& aAgent ) +{ + (void)aAgent; + return false; +} + +bool KICAD_CURL_EASY::SetPostFields( const std::vector>& aFields ) +{ + (void)aFields; + return false; +} + +bool KICAD_CURL_EASY::SetPostFields( const std::string& aField ) +{ + (void)aField; + return false; +} + +bool KICAD_CURL_EASY::SetOutputStream( const std::ostream* aOutput ) +{ + (void)aOutput; + return false; +} + +bool KICAD_CURL_EASY::SetTransferCallback( const TRANSFER_CALLBACK& aCallback, size_t aInterval ) +{ + (void)aCallback; (void)aInterval; + return false; +} + +int KICAD_CURL_EASY::GetTransferTotal( uint64_t& aDownloadedBytes ) const +{ + aDownloadedBytes = 0; + return -1; +} + +const std::string KICAD_CURL_EASY::GetErrorText( int aCode ) +{ + (void)aCode; + return "CURL disabled"; +} + +std::string KICAD_CURL_EASY::Escape( const std::string& aUrl ) +{ + return aUrl; // Return unescaped +} + +int KICAD_CURL_EASY::GetResponseStatusCode() +{ + return 0; +} + +// ============================================================================= +// PANEL_GIT_REPOS stub is in panel_git_repos_stub.cpp (common library) +// ============================================================================= diff --git a/stubs/src/kicad_git_all_stubs.cpp b/stubs/src/kicad_git_all_stubs.cpp new file mode 100644 index 0000000..a271f59 --- /dev/null +++ b/stubs/src/kicad_git_all_stubs.cpp @@ -0,0 +1,787 @@ +/* + * KiCad Wasm Port - Comprehensive stub implementations for git-disabled builds + * + * Provides stub implementations for all git-related classes when KICAD_USE_GIT=OFF. + * These stubs allow the kicad app to link without libgit2. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +// Include git2 stub header for types +#include + +// Include KiCad headers for proper class declarations +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Forward declare classes we'll stub +class KICAD_MANAGER_FRAME; + +// ============================================================================= +// KIGIT_COMMON stub implementations +// ============================================================================= + +KIGIT_COMMON::KIGIT_COMMON( git_repository* aRepo ) : + m_repo( aRepo ), + m_connType( GIT_CONN_TYPE::GIT_CONN_LOCAL ), + m_testedTypes( 0 ), + m_nextPublicKey( 0 ), + m_secretFetched( false ), + m_cancel( false ) +{} + +KIGIT_COMMON::KIGIT_COMMON( const KIGIT_COMMON& aOther ) : + m_repo( aOther.m_repo ), + m_connType( aOther.m_connType ), + m_remote( aOther.m_remote ), + m_hostname( aOther.m_hostname ), + m_username( aOther.m_username ), + m_password( aOther.m_password ), + m_testedTypes( aOther.m_testedTypes ), + m_publicKeys( aOther.m_publicKeys ), + m_nextPublicKey( aOther.m_nextPublicKey ), + m_secretFetched( aOther.m_secretFetched ), + m_cancel( aOther.m_cancel.load() ) +{} + +KIGIT_COMMON::~KIGIT_COMMON() {} + +git_repository* KIGIT_COMMON::GetRepo() const { return m_repo; } +wxString KIGIT_COMMON::GetGitRootDirectory() const { return wxEmptyString; } +std::vector KIGIT_COMMON::GetBranchNames() const { return {}; } +std::vector KIGIT_COMMON::GetProjectDirs() { return {}; } +bool KIGIT_COMMON::HasLocalCommits() const { return false; } +bool KIGIT_COMMON::HasPushAndPullRemote() const { return false; } + +std::pair, std::set> KIGIT_COMMON::GetDifferentFiles() const +{ + return std::make_pair( std::set(), std::set() ); +} + +wxString KIGIT_COMMON::GetCurrentBranchName() const { return wxEmptyString; } +wxString KIGIT_COMMON::GetRemotename() const { return wxEmptyString; } +wxString KIGIT_COMMON::GetPassword() { return wxEmptyString; } +KIGIT_COMMON::GIT_CONN_TYPE KIGIT_COMMON::GetConnType() const { return m_connType; } +void KIGIT_COMMON::SetSSHKey( const wxString& aSSHKey ) { (void)aSSHKey; } +void KIGIT_COMMON::UpdateCurrentBranchInfo() {} + +int KIGIT_COMMON::HandleSSHKeyAuthentication( git_cred** aOut, const wxString& aUsername ) +{ + (void)aOut; (void)aUsername; + return -1; +} + +int KIGIT_COMMON::HandlePlaintextAuthentication( git_cred** aOut, const wxString& aUsername ) +{ + (void)aOut; (void)aUsername; + return -1; +} + +int KIGIT_COMMON::HandleSSHAgentAuthentication( git_cred** aOut, const wxString& aUsername ) +{ + (void)aOut; (void)aUsername; + return -1; +} + +void KIGIT_COMMON::updatePublicKeys() {} +void KIGIT_COMMON::updateConnectionType() {} + +// ============================================================================= +// GIT_STATUS_HANDLER stub implementations (inherits from KIGIT_REPO_MIXIN) +// ============================================================================= + +GIT_STATUS_HANDLER::GIT_STATUS_HANDLER( KIGIT_COMMON* aCommon ) : KIGIT_REPO_MIXIN( aCommon ) +{ +} +GIT_STATUS_HANDLER::~GIT_STATUS_HANDLER() {} + +bool GIT_STATUS_HANDLER::HasChangedFiles() { return false; } +std::map GIT_STATUS_HANDLER::GetFileStatus( const wxString& aPathspec ) +{ + (void)aPathspec; + return {}; +} +wxString GIT_STATUS_HANDLER::GetCurrentBranchName() { return wxEmptyString; } +void GIT_STATUS_HANDLER::UpdateRemoteStatus( const std::set& aLocalChanges, + const std::set& aRemoteChanges, + std::map& aFileStatus ) +{ + (void)aLocalChanges; (void)aRemoteChanges; (void)aFileStatus; +} +wxString GIT_STATUS_HANDLER::GetWorkingDirectory() { return wxEmptyString; } +KIGIT_COMMON::GIT_STATUS GIT_STATUS_HANDLER::ConvertStatus( unsigned int aGitStatus ) +{ + (void)aGitStatus; + return KIGIT_COMMON::GIT_STATUS::GIT_STATUS_CURRENT; +} +void GIT_STATUS_HANDLER::UpdateProgress( int aCurrent, int aTotal, const wxString& aMessage ) +{ + (void)aCurrent; (void)aTotal; (void)aMessage; +} + +// ============================================================================= +// GIT_RESOLVE_CONFLICT_HANDLER stub implementations (no base class) +// ============================================================================= + +GIT_RESOLVE_CONFLICT_HANDLER::GIT_RESOLVE_CONFLICT_HANDLER( git_repository* aRepo ) + : m_repository( aRepo ) +{ +} +GIT_RESOLVE_CONFLICT_HANDLER::~GIT_RESOLVE_CONFLICT_HANDLER() {} + +bool GIT_RESOLVE_CONFLICT_HANDLER::PerformResolveConflict() { return false; } + +// ============================================================================= +// GIT_REMOVE_FROM_INDEX_HANDLER stub implementations (inherits from KIGIT_COMMON) +// ============================================================================= + +GIT_REMOVE_FROM_INDEX_HANDLER::GIT_REMOVE_FROM_INDEX_HANDLER( git_repository* aRepo ) + : KIGIT_COMMON( aRepo ) +{ +} +GIT_REMOVE_FROM_INDEX_HANDLER::~GIT_REMOVE_FROM_INDEX_HANDLER() {} + +bool GIT_REMOVE_FROM_INDEX_HANDLER::RemoveFromIndex( const wxString& aFilePath ) +{ + (void)aFilePath; + return false; +} + +void GIT_REMOVE_FROM_INDEX_HANDLER::PerformRemoveFromIndex() {} + +// ============================================================================= +// GIT_ADD_TO_INDEX_HANDLER stub implementations (inherits from KIGIT_COMMON) +// ============================================================================= + +GIT_ADD_TO_INDEX_HANDLER::GIT_ADD_TO_INDEX_HANDLER( git_repository* aRepo ) + : KIGIT_COMMON( aRepo ) +{ +} +GIT_ADD_TO_INDEX_HANDLER::~GIT_ADD_TO_INDEX_HANDLER() {} + +bool GIT_ADD_TO_INDEX_HANDLER::AddToIndex( const wxString& aFilePath ) +{ + (void)aFilePath; + return false; +} + +bool GIT_ADD_TO_INDEX_HANDLER::PerformAddToIndex() { return false; } + +// ============================================================================= +// GIT_COMMIT_HANDLER stub implementations (inherits from KIGIT_COMMON) +// ============================================================================= + +GIT_COMMIT_HANDLER::GIT_COMMIT_HANDLER( git_repository* aRepo ) + : KIGIT_COMMON( aRepo ) +{ +} +GIT_COMMIT_HANDLER::~GIT_COMMIT_HANDLER() {} + +CommitResult GIT_COMMIT_HANDLER::PerformCommit( const std::vector& aFiles, + const wxString& aMessage, + const wxString& aAuthorName, + const wxString& aAuthorEmail ) +{ + (void)aFiles; (void)aMessage; (void)aAuthorName; (void)aAuthorEmail; + return CommitResult::Error; +} + +wxString GIT_COMMIT_HANDLER::GetErrorString() const { return wxT("Git support is disabled"); } + +void GIT_COMMIT_HANDLER::AddErrorString( const wxString& aErrorString ) +{ + (void)aErrorString; +} + +// ============================================================================= +// GIT_PULL_HANDLER stub implementations (inherits from KIGIT_REPO_MIXIN) +// ============================================================================= + +GIT_PULL_HANDLER::GIT_PULL_HANDLER( KIGIT_COMMON* aCommon ) : KIGIT_REPO_MIXIN( aCommon ) +{ +} +GIT_PULL_HANDLER::~GIT_PULL_HANDLER() {} + +bool GIT_PULL_HANDLER::PerformFetch( bool aSkipLock ) +{ + (void)aSkipLock; + return false; +} + +PullResult GIT_PULL_HANDLER::PerformPull() { return PullResult::Error; } + +const std::vector>>& GIT_PULL_HANDLER::GetFetchResults() const +{ + return m_fetchResults; +} + +void GIT_PULL_HANDLER::UpdateProgress( int aCurrent, int aTotal, const wxString& aMessage ) +{ + (void)aCurrent; (void)aTotal; (void)aMessage; +} + +// ============================================================================= +// GIT_PUSH_HANDLER stub implementations (inherits from KIGIT_REPO_MIXIN) +// ============================================================================= + +GIT_PUSH_HANDLER::GIT_PUSH_HANDLER( KIGIT_COMMON* aCommon ) : KIGIT_REPO_MIXIN( aCommon ) +{ +} +GIT_PUSH_HANDLER::~GIT_PUSH_HANDLER() {} + +PushResult GIT_PUSH_HANDLER::PerformPush() { return PushResult::Error; } + +void GIT_PUSH_HANDLER::UpdateProgress( int aCurrent, int aTotal, const wxString& aMessage ) +{ + (void)aCurrent; (void)aTotal; (void)aMessage; +} + +// ============================================================================= +// GIT_BRANCH_HANDLER stub implementations (inherits from KIGIT_REPO_MIXIN) +// ============================================================================= + +GIT_BRANCH_HANDLER::GIT_BRANCH_HANDLER( KIGIT_COMMON* aCommon ) : KIGIT_REPO_MIXIN( aCommon ) +{ +} +GIT_BRANCH_HANDLER::~GIT_BRANCH_HANDLER() {} + +BranchResult GIT_BRANCH_HANDLER::SwitchToBranch( const wxString& aBranchName ) +{ + (void)aBranchName; + return BranchResult::Error; +} + +bool GIT_BRANCH_HANDLER::BranchExists( const wxString& aBranchName ) +{ + (void)aBranchName; + return false; +} + +void GIT_BRANCH_HANDLER::UpdateProgress( int aCurrent, int aTotal, const wxString& aMessage ) +{ + (void)aCurrent; (void)aTotal; (void)aMessage; +} + +// ============================================================================= +// GIT_REVERT_HANDLER stub implementations (no base class) +// ============================================================================= + +GIT_REVERT_HANDLER::GIT_REVERT_HANDLER( git_repository* aRepo ) + : m_repository( aRepo ) +{ +} +GIT_REVERT_HANDLER::~GIT_REVERT_HANDLER() {} + +bool GIT_REVERT_HANDLER::Revert( const wxString& aFilePath ) +{ + (void)aFilePath; + return false; +} + +void GIT_REVERT_HANDLER::PerformRevert() {} + +// ============================================================================= +// GIT_INIT_HANDLER stub implementations (inherits from KIGIT_REPO_MIXIN) +// ============================================================================= + +GIT_INIT_HANDLER::GIT_INIT_HANDLER( KIGIT_COMMON* aCommon ) : KIGIT_REPO_MIXIN( aCommon ) +{ +} +GIT_INIT_HANDLER::~GIT_INIT_HANDLER() {} + +bool GIT_INIT_HANDLER::IsRepository( const wxString& aPath ) +{ + (void)aPath; + return false; +} + +InitResult GIT_INIT_HANDLER::InitializeRepository( const wxString& aPath ) +{ + (void)aPath; + return InitResult::Error; +} + +bool GIT_INIT_HANDLER::SetupRemote( const RemoteConfig& aConfig ) +{ + (void)aConfig; + return false; +} + +void GIT_INIT_HANDLER::UpdateProgress( int aCurrent, int aTotal, const wxString& aMessage ) +{ + (void)aCurrent; (void)aTotal; (void)aMessage; +} + +// ============================================================================= +// GIT_CLONE_HANDLER stub implementations (inherits from KIGIT_REPO_MIXIN) +// ============================================================================= + +GIT_CLONE_HANDLER::GIT_CLONE_HANDLER( KIGIT_COMMON* aCommon ) : KIGIT_REPO_MIXIN( aCommon ) +{ +} +GIT_CLONE_HANDLER::~GIT_CLONE_HANDLER() {} + +bool GIT_CLONE_HANDLER::PerformClone() { return false; } + +void GIT_CLONE_HANDLER::UpdateProgress( int aCurrent, int aTotal, const wxString& aMessage ) +{ + (void)aCurrent; (void)aTotal; (void)aMessage; +} + +// ============================================================================= +// GIT_CONFIG_HANDLER stub implementations (inherits from KIGIT_REPO_MIXIN) +// ============================================================================= + +GIT_CONFIG_HANDLER::GIT_CONFIG_HANDLER( KIGIT_COMMON* aCommon ) : KIGIT_REPO_MIXIN( aCommon ) +{ +} +GIT_CONFIG_HANDLER::~GIT_CONFIG_HANDLER() {} + +GitUserConfig GIT_CONFIG_HANDLER::GetUserConfig() +{ + return GitUserConfig(); +} + +wxString GIT_CONFIG_HANDLER::GetWorkingDirectory() { return wxEmptyString; } + +bool GIT_CONFIG_HANDLER::GetConfigString( const wxString& aKey, wxString& aValue ) +{ + (void)aKey; (void)aValue; + return false; +} + +void GIT_CONFIG_HANDLER::UpdateProgress( int aCurrent, int aTotal, const wxString& aMessage ) +{ + (void)aCurrent; (void)aTotal; (void)aMessage; +} + +// ============================================================================= +// GIT_SYNC_HANDLER stub implementations (no base class) +// ============================================================================= + +GIT_SYNC_HANDLER::GIT_SYNC_HANDLER( git_repository* aRepository ) + : m_repository( aRepository ) +{ +} +GIT_SYNC_HANDLER::~GIT_SYNC_HANDLER() {} + +bool GIT_SYNC_HANDLER::PerformSync() { return false; } + +// ============================================================================= +// LIBGIT_BACKEND stub implementations +// ============================================================================= + +void LIBGIT_BACKEND::Init() {} +void LIBGIT_BACKEND::Shutdown() {} +bool LIBGIT_BACKEND::IsLibraryAvailable() { return false; } + +bool LIBGIT_BACKEND::Clone( GIT_CLONE_HANDLER* aHandler ) +{ + (void)aHandler; + return false; +} + +CommitResult LIBGIT_BACKEND::Commit( GIT_COMMIT_HANDLER* aHandler, + const std::vector& aFiles, + const wxString& aMessage, + const wxString& aAuthorName, + const wxString& aAuthorEmail ) +{ + (void)aHandler; (void)aFiles; (void)aMessage; (void)aAuthorName; (void)aAuthorEmail; + return CommitResult::Error; +} + +PushResult LIBGIT_BACKEND::Push( GIT_PUSH_HANDLER* aHandler ) +{ + (void)aHandler; + return PushResult::Error; +} + +bool LIBGIT_BACKEND::HasChangedFiles( GIT_STATUS_HANDLER* aHandler ) +{ + (void)aHandler; + return false; +} + +std::map LIBGIT_BACKEND::GetFileStatus( GIT_STATUS_HANDLER* aHandler, + const wxString& aPathspec ) +{ + (void)aHandler; (void)aPathspec; + return {}; +} + +wxString LIBGIT_BACKEND::GetCurrentBranchName( GIT_STATUS_HANDLER* aHandler ) +{ + (void)aHandler; + return wxEmptyString; +} + +void LIBGIT_BACKEND::UpdateRemoteStatus( GIT_STATUS_HANDLER* aHandler, + const std::set& aLocalChanges, + const std::set& aRemoteChanges, + std::map& aFileStatus ) +{ + (void)aHandler; (void)aLocalChanges; (void)aRemoteChanges; (void)aFileStatus; +} + +wxString LIBGIT_BACKEND::GetWorkingDirectory( GIT_STATUS_HANDLER* aHandler ) +{ + (void)aHandler; + return wxEmptyString; +} + +wxString LIBGIT_BACKEND::GetWorkingDirectory( GIT_CONFIG_HANDLER* aHandler ) +{ + (void)aHandler; + return wxEmptyString; +} + +bool LIBGIT_BACKEND::GetConfigString( GIT_CONFIG_HANDLER* aHandler, const wxString& aKey, + wxString& aValue ) +{ + (void)aHandler; (void)aKey; (void)aValue; + return false; +} + +bool LIBGIT_BACKEND::IsRepository( GIT_INIT_HANDLER* aHandler, const wxString& aPath ) +{ + (void)aHandler; (void)aPath; + return false; +} + +InitResult LIBGIT_BACKEND::InitializeRepository( GIT_INIT_HANDLER* aHandler, const wxString& aPath ) +{ + (void)aHandler; (void)aPath; + return InitResult::Error; +} + +bool LIBGIT_BACKEND::SetupRemote( GIT_INIT_HANDLER* aHandler, const RemoteConfig& aConfig ) +{ + (void)aHandler; (void)aConfig; + return false; +} + +BranchResult LIBGIT_BACKEND::SwitchToBranch( GIT_BRANCH_HANDLER* aHandler, const wxString& aBranchName ) +{ + (void)aHandler; (void)aBranchName; + return BranchResult::Error; +} + +bool LIBGIT_BACKEND::BranchExists( GIT_BRANCH_HANDLER* aHandler, const wxString& aBranchName ) +{ + (void)aHandler; (void)aBranchName; + return false; +} + +bool LIBGIT_BACKEND::PerformFetch( GIT_PULL_HANDLER* aHandler, bool aSkipLock ) +{ + (void)aHandler; (void)aSkipLock; + return false; +} + +PullResult LIBGIT_BACKEND::PerformPull( GIT_PULL_HANDLER* aHandler ) +{ + (void)aHandler; + return PullResult::Error; +} + +void LIBGIT_BACKEND::PerformRevert( GIT_REVERT_HANDLER* aHandler ) +{ + (void)aHandler; +} + +git_repository* LIBGIT_BACKEND::GetRepositoryForFile( const char* aFilename ) +{ + (void)aFilename; + return nullptr; +} + +int LIBGIT_BACKEND::CreateBranch( git_repository* aRepo, const wxString& aBranchName ) +{ + (void)aRepo; (void)aBranchName; + return -1; +} + +bool LIBGIT_BACKEND::RemoveVCS( git_repository*& aRepo, const wxString& aProjectPath, + bool aRemoveGitDir, wxString* aErrors ) +{ + (void)aRepo; (void)aProjectPath; (void)aRemoveGitDir; (void)aErrors; + return false; +} + +bool LIBGIT_BACKEND::AddToIndex( GIT_ADD_TO_INDEX_HANDLER* aHandler, const wxString& aFilePath ) +{ + (void)aHandler; (void)aFilePath; + return false; +} + +bool LIBGIT_BACKEND::PerformAddToIndex( GIT_ADD_TO_INDEX_HANDLER* aHandler ) +{ + (void)aHandler; + return false; +} + +bool LIBGIT_BACKEND::RemoveFromIndex( GIT_REMOVE_FROM_INDEX_HANDLER* aHandler, const wxString& aFilePath ) +{ + (void)aHandler; (void)aFilePath; + return false; +} + +void LIBGIT_BACKEND::PerformRemoveFromIndex( GIT_REMOVE_FROM_INDEX_HANDLER* aHandler ) +{ + (void)aHandler; +} + +// Private methods +PullResult LIBGIT_BACKEND::handleFastForward( GIT_PULL_HANDLER* aHandler ) +{ + (void)aHandler; + return PullResult::Error; +} + +PullResult LIBGIT_BACKEND::handleMerge( GIT_PULL_HANDLER* aHandler, + const git_annotated_commit** aMergeHeads, + size_t aMergeHeadsCount ) +{ + (void)aHandler; (void)aMergeHeads; (void)aMergeHeadsCount; + return PullResult::Error; +} + +PullResult LIBGIT_BACKEND::handleRebase( GIT_PULL_HANDLER* aHandler, + const git_annotated_commit** aMergeHeads, + size_t aMergeHeadsCount ) +{ + (void)aHandler; (void)aMergeHeads; (void)aMergeHeadsCount; + return PullResult::Error; +} + +// Global backend pointer +static GIT_BACKEND* s_gitBackend = nullptr; + +GIT_BACKEND* GetGitBackend() +{ + return s_gitBackend; +} + +void SetGitBackend( GIT_BACKEND* aBackend ) +{ + s_gitBackend = aBackend; +} + +// ============================================================================= +// LOCAL_HISTORY_PANE stub - for kicad main app +// ============================================================================= + +class LOCAL_HISTORY_PANE : public wxPanel +{ +public: + LOCAL_HISTORY_PANE( KICAD_MANAGER_FRAME* aParent ); + ~LOCAL_HISTORY_PANE(); + void RefreshHistory( const wxString& aProjectPath ); +}; + +LOCAL_HISTORY_PANE::LOCAL_HISTORY_PANE( KICAD_MANAGER_FRAME* aParent ) + : wxPanel( reinterpret_cast(aParent), wxID_ANY ) +{ +} + +LOCAL_HISTORY_PANE::~LOCAL_HISTORY_PANE() {} + +void LOCAL_HISTORY_PANE::RefreshHistory( const wxString& aProjectPath ) +{ + (void)aProjectPath; +} + +// ============================================================================= +// Git dialog stubs +// ============================================================================= + +#include +#include +#include + +DIALOG_GIT_COMMIT::DIALOG_GIT_COMMIT( wxWindow* parent, git_repository* repo, + const wxString& defaultAuthorName, + const wxString& defaultAuthorEmail, + const std::map& filesToCommit ) + : DIALOG_SHIM( parent, wxID_ANY, wxT("Git Commit (disabled)") ), + m_commitMessageTextCtrl( nullptr ), + m_authorTextCtrl( nullptr ), + m_listCtrl( nullptr ), + m_okButton( nullptr ), + m_repo( repo ), + m_defaultAuthorName( defaultAuthorName ), + m_defaultAuthorEmail( defaultAuthorEmail ) +{ + (void)filesToCommit; +} + +wxString DIALOG_GIT_COMMIT::GetCommitMessage() const { return wxEmptyString; } +wxString DIALOG_GIT_COMMIT::GetAuthorName() const { return wxEmptyString; } +wxString DIALOG_GIT_COMMIT::GetAuthorEmail() const { return wxEmptyString; } +std::vector DIALOG_GIT_COMMIT::GetSelectedFiles() const { return {}; } +void DIALOG_GIT_COMMIT::OnTextChanged( wxCommandEvent& event ) { (void)event; } + +DIALOG_GIT_SWITCH::DIALOG_GIT_SWITCH( wxWindow* aParent, git_repository* aRepository ) + : DIALOG_SHIM( aParent, wxID_ANY, wxT("Git Switch Branch (disabled)") ), + m_branchList( nullptr ), + m_branchNameText( nullptr ), + m_switchButton( nullptr ), + m_repository( aRepository ), + m_existingBranch( false ) +{ +} + +DIALOG_GIT_SWITCH::~DIALOG_GIT_SWITCH() {} + +wxString DIALOG_GIT_SWITCH::GetBranchName() const { return wxEmptyString; } +void DIALOG_GIT_SWITCH::PopulateBranchList() {} +void DIALOG_GIT_SWITCH::OnBranchListSelection( wxListEvent& event ) { (void)event; } +void DIALOG_GIT_SWITCH::OnBranchListDClick( wxListEvent& event ) { (void)event; } +void DIALOG_GIT_SWITCH::OnSwitchButton( wxCommandEvent& event ) { (void)event; } +void DIALOG_GIT_SWITCH::OnCancelButton( wxCommandEvent& event ) { (void)event; } +void DIALOG_GIT_SWITCH::OnTextChanged( wxCommandEvent& event ) { (void)event; } +void DIALOG_GIT_SWITCH::OnTimer( wxTimerEvent& event ) { (void)event; } +void DIALOG_GIT_SWITCH::GetBranches() {} +void DIALOG_GIT_SWITCH::StartTimer() {} +void DIALOG_GIT_SWITCH::StopTimer() {} + +// DIALOG_GIT_REPOSITORY inherits from DIALOG_GIT_REPOSITORY_BASE +// We need the base class first +#include + +// Base class constructor stub +DIALOG_GIT_REPOSITORY_BASE::DIALOG_GIT_REPOSITORY_BASE( wxWindow* parent, wxWindowID id, + const wxString& title, + const wxPoint& pos, + const wxSize& size, + long style ) + : DIALOG_SHIM( parent, id, title, pos, size, style ) +{ + m_ConnType = nullptr; + m_txtName = nullptr; + m_txtURL = nullptr; + m_txtUsername = nullptr; + m_txtPassword = nullptr; + m_fpSSHKey = nullptr; + m_sdbSizerCancel = nullptr; +} + +DIALOG_GIT_REPOSITORY_BASE::~DIALOG_GIT_REPOSITORY_BASE() {} + +// Now the derived class +DIALOG_GIT_REPOSITORY::DIALOG_GIT_REPOSITORY( wxWindow* aParent, git_repository* aRepository, + wxString aURL ) + : DIALOG_GIT_REPOSITORY_BASE( aParent ), + m_repository( aRepository ), + m_fullURL( aURL ), + m_tempRepo( false ) +{ +} + +DIALOG_GIT_REPOSITORY::~DIALOG_GIT_REPOSITORY() {} + +void DIALOG_GIT_REPOSITORY::SetEncrypted( bool aEncrypted ) { (void)aEncrypted; } +void DIALOG_GIT_REPOSITORY::OnUpdateUI( wxUpdateUIEvent& event ) { (void)event; } +void DIALOG_GIT_REPOSITORY::OnLocationExit( wxFocusEvent& event ) { (void)event; } +void DIALOG_GIT_REPOSITORY::OnOKClick( wxCommandEvent& event ) { (void)event; } +void DIALOG_GIT_REPOSITORY::OnSelectConnType( wxCommandEvent& event ) { (void)event; } +void DIALOG_GIT_REPOSITORY::OnTestClick( wxCommandEvent& event ) { (void)event; } +void DIALOG_GIT_REPOSITORY::OnFileUpdated( wxFileDirPickerEvent& event ) { (void)event; } +void DIALOG_GIT_REPOSITORY::onCbCustom( wxCommandEvent& event ) { (void)event; } +void DIALOG_GIT_REPOSITORY::setDefaultSSHKey() {} +void DIALOG_GIT_REPOSITORY::updateAuthControls() {} +void DIALOG_GIT_REPOSITORY::updateURLData() {} +bool DIALOG_GIT_REPOSITORY::extractClipboardData() { return false; } + +std::tuple DIALOG_GIT_REPOSITORY::isValidHTTPS( const wxString& url ) +{ + (void)url; + return std::make_tuple( false, wxEmptyString, wxEmptyString, wxEmptyString ); +} + +std::tuple DIALOG_GIT_REPOSITORY::isValidSSH( const wxString& url ) +{ + (void)url; + return std::make_tuple( false, wxEmptyString, wxEmptyString ); +} + +// ============================================================================= +// Extern "C" callbacks (declared in kicad_git_common.h) +// ============================================================================= + +extern "C" { + int progress_cb( const char* str, int len, void* data ) + { + (void)str; (void)len; (void)data; + return 0; + } + + void clone_progress_cb( const char* str, size_t len, size_t total, void* data ) + { + (void)str; (void)len; (void)total; (void)data; + } + + int transfer_progress_cb( const git_transfer_progress* aStats, void* aPayload ) + { + (void)aStats; (void)aPayload; + return 0; + } + + int update_cb( const char* aRefname, const git_oid* aFirst, const git_oid* aSecond, + void* aPayload ) + { + (void)aRefname; (void)aFirst; (void)aSecond; (void)aPayload; + return 0; + } + + int push_transfer_progress_cb( unsigned int aCurrent, unsigned int aTotal, + size_t aBytes, void* aPayload ) + { + (void)aCurrent; (void)aTotal; (void)aBytes; (void)aPayload; + return 0; + } + + int push_update_reference_cb( const char* aRefname, const char* aStatus, + void* aPayload ) + { + (void)aRefname; (void)aStatus; (void)aPayload; + return 0; + } + + int fetchhead_foreach_cb( const char* aRefname, const char* aRemoteUrl, + const git_oid* aOID, unsigned int aIsMerge, void* aPayload ) + { + (void)aRefname; (void)aRemoteUrl; (void)aOID; (void)aIsMerge; (void)aPayload; + return 0; + } + + int credentials_cb( git_cred** aOut, const char* aUrl, const char* aUsername, + unsigned int aAllowedTypes, void* aPayload ) + { + (void)aOut; (void)aUrl; (void)aUsername; (void)aAllowedTypes; (void)aPayload; + return -1; + } +} diff --git a/stubs/src/kicad_git_stubs.cpp b/stubs/src/kicad_git_stubs.cpp new file mode 100644 index 0000000..560517a --- /dev/null +++ b/stubs/src/kicad_git_stubs.cpp @@ -0,0 +1,339 @@ +/* + * KiCad Wasm Port - Stub implementations for KiCad git classes + * + * Provides empty/stub implementations for KiCad git-related classes + * when KICAD_USE_GIT=OFF. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +// Include KiCad headers to get proper class declarations +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Forward declare KICAD_MANAGER_FRAME for LOCAL_HISTORY_PANE +class KICAD_MANAGER_FRAME; + +// ============================================================================= +// KIGIT_COMMON stub implementations +// ============================================================================= + +KIGIT_COMMON::KIGIT_COMMON( git_repository* aRepo ) : + m_repo( aRepo ), + m_connType( GIT_CONN_TYPE::GIT_CONN_LOCAL ), + m_testedTypes( 0 ), + m_nextPublicKey( 0 ), + m_secretFetched( false ), + m_cancel( false ) +{} + +KIGIT_COMMON::KIGIT_COMMON( const KIGIT_COMMON& aOther ) : + m_repo( aOther.m_repo ), + m_connType( aOther.m_connType ), + m_remote( aOther.m_remote ), + m_hostname( aOther.m_hostname ), + m_username( aOther.m_username ), + m_password( aOther.m_password ), + m_testedTypes( aOther.m_testedTypes ), + m_publicKeys( aOther.m_publicKeys ), + m_nextPublicKey( aOther.m_nextPublicKey ), + m_secretFetched( aOther.m_secretFetched ), + m_cancel( aOther.m_cancel.load() ) +{} + +KIGIT_COMMON::~KIGIT_COMMON() {} + +git_repository* KIGIT_COMMON::GetRepo() const { return m_repo; } +wxString KIGIT_COMMON::GetGitRootDirectory() const { return wxEmptyString; } +std::vector KIGIT_COMMON::GetBranchNames() const { return {}; } +std::vector KIGIT_COMMON::GetProjectDirs() { return {}; } +bool KIGIT_COMMON::HasLocalCommits() const { return false; } +bool KIGIT_COMMON::HasPushAndPullRemote() const { return false; } + +std::pair, std::set> KIGIT_COMMON::GetDifferentFiles() const +{ + return std::make_pair( std::set(), std::set() ); +} + +wxString KIGIT_COMMON::GetCurrentBranchName() const { return wxEmptyString; } +wxString KIGIT_COMMON::GetRemotename() const { return wxEmptyString; } +wxString KIGIT_COMMON::GetPassword() { return wxEmptyString; } +KIGIT_COMMON::GIT_CONN_TYPE KIGIT_COMMON::GetConnType() const { return m_connType; } +void KIGIT_COMMON::SetSSHKey( const wxString& aSSHKey ) { (void)aSSHKey; } +void KIGIT_COMMON::UpdateCurrentBranchInfo() {} + +int KIGIT_COMMON::HandleSSHKeyAuthentication( git_cred** aOut, const wxString& aUsername ) +{ + (void)aOut; (void)aUsername; + return -1; +} + +int KIGIT_COMMON::HandlePlaintextAuthentication( git_cred** aOut, const wxString& aUsername ) +{ + (void)aOut; (void)aUsername; + return -1; +} + +int KIGIT_COMMON::HandleSSHAgentAuthentication( git_cred** aOut, const wxString& aUsername ) +{ + (void)aOut; (void)aUsername; + return -1; +} + +// Private methods +void KIGIT_COMMON::updatePublicKeys() {} +void KIGIT_COMMON::updateConnectionType() {} + +// ============================================================================= +// KIGIT_REPO_MIXIN - all methods are inline in the header, no stubs needed +// ============================================================================= + +// ============================================================================= +// GIT_STATUS_HANDLER stub implementations +// ============================================================================= + +GIT_STATUS_HANDLER::GIT_STATUS_HANDLER( KIGIT_COMMON* aCommon ) : KIGIT_REPO_MIXIN( aCommon ) {} +GIT_STATUS_HANDLER::~GIT_STATUS_HANDLER() {} + +bool GIT_STATUS_HANDLER::HasChangedFiles() { return false; } +std::map GIT_STATUS_HANDLER::GetFileStatus( const wxString& aPathspec ) +{ + (void)aPathspec; + return {}; +} +wxString GIT_STATUS_HANDLER::GetCurrentBranchName() { return wxEmptyString; } +void GIT_STATUS_HANDLER::UpdateRemoteStatus( const std::set& aLocalChanges, + const std::set& aRemoteChanges, + std::map& aFileStatus ) +{ + (void)aLocalChanges; (void)aRemoteChanges; (void)aFileStatus; +} +wxString GIT_STATUS_HANDLER::GetWorkingDirectory() { return wxEmptyString; } +KIGIT_COMMON::GIT_STATUS GIT_STATUS_HANDLER::ConvertStatus( unsigned int aGitStatus ) +{ + (void)aGitStatus; + return KIGIT_COMMON::GIT_STATUS::GIT_STATUS_CURRENT; +} + +// ============================================================================= +// GIT_RESOLVE_CONFLICT_HANDLER stub implementations +// ============================================================================= + +GIT_RESOLVE_CONFLICT_HANDLER::GIT_RESOLVE_CONFLICT_HANDLER( git_repository* aRepo ) + : KIGIT_REPO_MIXIN( nullptr ) +{ + (void)aRepo; +} +GIT_RESOLVE_CONFLICT_HANDLER::~GIT_RESOLVE_CONFLICT_HANDLER() {} + +bool GIT_RESOLVE_CONFLICT_HANDLER::PerformResolveConflict() { return false; } + +// ============================================================================= +// GIT_REMOVE_FROM_INDEX_HANDLER stub implementations +// ============================================================================= + +GIT_REMOVE_FROM_INDEX_HANDLER::GIT_REMOVE_FROM_INDEX_HANDLER( git_repository* aRepo ) + : KIGIT_REPO_MIXIN( nullptr ) +{ + (void)aRepo; +} +GIT_REMOVE_FROM_INDEX_HANDLER::~GIT_REMOVE_FROM_INDEX_HANDLER() {} + +bool GIT_REMOVE_FROM_INDEX_HANDLER::PerformRemoveFromIndex() { return false; } +void GIT_REMOVE_FROM_INDEX_HANDLER::SetFilePaths( const std::vector& aPaths ) +{ + (void)aPaths; +} + +// ============================================================================= +// GIT_ADD_TO_INDEX_HANDLER stub implementations +// ============================================================================= + +GIT_ADD_TO_INDEX_HANDLER::GIT_ADD_TO_INDEX_HANDLER( git_repository* aRepo ) + : KIGIT_REPO_MIXIN( nullptr ) +{ + (void)aRepo; +} +GIT_ADD_TO_INDEX_HANDLER::~GIT_ADD_TO_INDEX_HANDLER() {} + +bool GIT_ADD_TO_INDEX_HANDLER::PerformAddToIndex() { return false; } +void GIT_ADD_TO_INDEX_HANDLER::SetFilePaths( const std::vector& aPaths ) +{ + (void)aPaths; +} + +// ============================================================================= +// GIT_COMMIT_HANDLER stub implementations +// ============================================================================= + +GIT_COMMIT_HANDLER::GIT_COMMIT_HANDLER( git_repository* aRepo ) + : KIGIT_REPO_MIXIN( nullptr ) +{ + (void)aRepo; +} +GIT_COMMIT_HANDLER::~GIT_COMMIT_HANDLER() {} + +bool GIT_COMMIT_HANDLER::PerformCommit() { return false; } +void GIT_COMMIT_HANDLER::SetAuthorName( const wxString& aName ) { (void)aName; } +void GIT_COMMIT_HANDLER::SetAuthorEmail( const wxString& aEmail ) { (void)aEmail; } +void GIT_COMMIT_HANDLER::SetCommitMessage( const wxString& aMessage ) { (void)aMessage; } +void GIT_COMMIT_HANDLER::SetFilePaths( const std::vector& aPaths ) { (void)aPaths; } + +// ============================================================================= +// GIT_PULL_HANDLER stub implementations +// ============================================================================= + +GIT_PULL_HANDLER::GIT_PULL_HANDLER( KIGIT_COMMON* aCommon ) : KIGIT_REPO_MIXIN( aCommon ) {} +GIT_PULL_HANDLER::~GIT_PULL_HANDLER() {} + +bool GIT_PULL_HANDLER::PerformPull() { return false; } + +// ============================================================================= +// GIT_PUSH_HANDLER stub implementations +// ============================================================================= + +GIT_PUSH_HANDLER::GIT_PUSH_HANDLER( KIGIT_COMMON* aCommon ) : KIGIT_REPO_MIXIN( aCommon ) {} +GIT_PUSH_HANDLER::~GIT_PUSH_HANDLER() {} + +bool GIT_PUSH_HANDLER::PerformPush() { return false; } + +// ============================================================================= +// GIT_SYNC_HANDLER stub implementations +// ============================================================================= + +GIT_SYNC_HANDLER::GIT_SYNC_HANDLER( KIGIT_COMMON* aCommon ) : KIGIT_REPO_MIXIN( aCommon ) {} +GIT_SYNC_HANDLER::~GIT_SYNC_HANDLER() {} + +bool GIT_SYNC_HANDLER::PerformSync() { return false; } + +// ============================================================================= +// GIT_SWITCH_BRANCH_HANDLER stub implementations +// ============================================================================= + +GIT_SWITCH_BRANCH_HANDLER::GIT_SWITCH_BRANCH_HANDLER( KIGIT_COMMON* aCommon ) + : KIGIT_REPO_MIXIN( aCommon ) +{ +} +GIT_SWITCH_BRANCH_HANDLER::~GIT_SWITCH_BRANCH_HANDLER() {} + +bool GIT_SWITCH_BRANCH_HANDLER::PerformSwitchBranch() { return false; } +void GIT_SWITCH_BRANCH_HANDLER::SetBranchName( const wxString& aName ) { (void)aName; } + +// ============================================================================= +// GIT_REVERT_HANDLER stub implementations +// ============================================================================= + +GIT_REVERT_HANDLER::GIT_REVERT_HANDLER( KIGIT_COMMON* aCommon ) : KIGIT_REPO_MIXIN( aCommon ) {} +GIT_REVERT_HANDLER::~GIT_REVERT_HANDLER() {} + +bool GIT_REVERT_HANDLER::PerformRevert() { return false; } +void GIT_REVERT_HANDLER::SetFilePaths( const std::vector& aPaths ) { (void)aPaths; } + +// ============================================================================= +// LIBGIT_BACKEND stub implementations +// ============================================================================= + +LIBGIT_BACKEND::LIBGIT_BACKEND() {} +LIBGIT_BACKEND::~LIBGIT_BACKEND() {} + +void LIBGIT_BACKEND::Init() {} +void LIBGIT_BACKEND::Cleanup() {} + +// ============================================================================= +// LOCAL_HISTORY_PANE stub - declared here since we excluded the cpp file +// ============================================================================= + +class LOCAL_HISTORY_PANE : public wxPanel +{ +public: + LOCAL_HISTORY_PANE( KICAD_MANAGER_FRAME* aParent ); + ~LOCAL_HISTORY_PANE(); + void RefreshHistory( const wxString& aProjectPath ); +}; + +LOCAL_HISTORY_PANE::LOCAL_HISTORY_PANE( KICAD_MANAGER_FRAME* aParent ) + : wxPanel( reinterpret_cast(aParent), wxID_ANY ) +{ +} + +LOCAL_HISTORY_PANE::~LOCAL_HISTORY_PANE() {} + +void LOCAL_HISTORY_PANE::RefreshHistory( const wxString& aProjectPath ) +{ + (void)aProjectPath; +} + +// ============================================================================= +// Extern "C" callbacks (declared in kicad_git_common.h) +// ============================================================================= + +extern "C" { + int progress_cb( const char* str, int len, void* data ) + { + (void)str; (void)len; (void)data; + return 0; + } + + void clone_progress_cb( const char* str, size_t len, size_t total, void* data ) + { + (void)str; (void)len; (void)total; (void)data; + } + + int transfer_progress_cb( const git_transfer_progress* aStats, void* aPayload ) + { + (void)aStats; (void)aPayload; + return 0; + } + + int update_cb( const char* aRefname, const git_oid* aFirst, const git_oid* aSecond, + void* aPayload ) + { + (void)aRefname; (void)aFirst; (void)aSecond; (void)aPayload; + return 0; + } + + int push_transfer_progress_cb( unsigned int aCurrent, unsigned int aTotal, + size_t aBytes, void* aPayload ) + { + (void)aCurrent; (void)aTotal; (void)aBytes; (void)aPayload; + return 0; + } + + int push_update_reference_cb( const char* aRefname, const char* aStatus, + void* aPayload ) + { + (void)aRefname; (void)aStatus; (void)aPayload; + return 0; + } + + int fetchhead_foreach_cb( const char* aRefname, const char* aRemoteUrl, + const git_oid* aOID, unsigned int aIsMerge, void* aPayload ) + { + (void)aRefname; (void)aRemoteUrl; (void)aOID; (void)aIsMerge; (void)aPayload; + return 0; + } + + int credentials_cb( git_cred** aOut, const char* aUrl, const char* aUsername, + unsigned int aAllowedTypes, void* aPayload ) + { + (void)aOut; (void)aUrl; (void)aUsername; (void)aAllowedTypes; (void)aPayload; + return -1; + } +} diff --git a/stubs/src/occ_stubs.cpp b/stubs/src/occ_stubs.cpp new file mode 100644 index 0000000..b6d5e81 --- /dev/null +++ b/stubs/src/occ_stubs.cpp @@ -0,0 +1,172 @@ +/* + * KiCad Wasm Port - OCC stub implementations + * + * Provides stub implementations for OpenCASCADE-related classes when KICAD_USE_OCC=OFF. + * Uses the clean pcbnew_utils_3d.h header which has no OCC dependencies. + * EXPORTER_STEP is implemented separately without including its header to avoid OCC deps. + */ + +#include +#include +#include +#include // For EXPORTER_STEP_PARAMS + +// Include the actual header for UTILS classes (no OCC dependency) +#include + +// ============================================================================= +// UTILS_BOX3D stub implementations +// ============================================================================= + +VECTOR3D& UTILS_BOX3D::Min() +{ + return m_min; +} + +VECTOR3D& UTILS_BOX3D::Max() +{ + return m_max; +} + +VECTOR3D UTILS_BOX3D::GetCenter() +{ + return VECTOR3D( 0, 0, 0 ); +} + +VECTOR3D UTILS_BOX3D::GetSize() +{ + return VECTOR3D( 0, 0, 0 ); +} + +// ============================================================================= +// UTILS_STEP_MODEL stub implementations +// ============================================================================= + +struct UTILS_STEP_MODEL::DATA +{ + // Empty stub data +}; + +UTILS_STEP_MODEL::~UTILS_STEP_MODEL() +{ + delete m_data; +} + +UTILS_BOX3D UTILS_STEP_MODEL::GetBoundingBox() +{ + return UTILS_BOX3D(); +} + +void UTILS_STEP_MODEL::Translate( double aX, double aY, double aZ ) +{ + (void)aX; (void)aY; (void)aZ; +} + +void UTILS_STEP_MODEL::Scale( double aScale ) +{ + (void)aScale; +} + +bool UTILS_STEP_MODEL::SaveSTEP( const wxString& aFileName ) +{ + (void)aFileName; + return false; +} + +UTILS_STEP_MODEL* UTILS_STEP_MODEL::LoadSTEP( const wxString& aFileName ) +{ + (void)aFileName; + return nullptr; +} + +// ============================================================================= +// EXPORTER_STEP stub implementations +// We can't include exporter_step.h because it has OCC-dependent members. +// Instead, we declare the class matching the header's interface and implement stubs. +// ============================================================================= + +// Forward declarations +class BOARD; +class BOARD_ITEM; +class FOOTPRINT; +class PCB_TRACK; +class SHAPE_POLY_SET; + +// EXPORTER_STEP class definition matching the header +// Must match the declaration in exporters/step/exporter_step.h exactly +class EXPORTER_STEP +{ +public: + EXPORTER_STEP( BOARD* aBoard, const EXPORTER_STEP_PARAMS& aParams, REPORTER* aReporter ); + ~EXPORTER_STEP(); + + bool Export(); + + wxString m_outputFile; + +private: + bool buildBoard3DShapes(); + bool buildFootprint3DShapes( FOOTPRINT* aFootprint, const VECTOR2D& aOrigin, SHAPE_POLY_SET* aClipPolygon ); + bool buildTrack3DShape( PCB_TRACK* aTrack, const VECTOR2D& aOrigin ); + void buildZones3DShape( VECTOR2D aOrigin ); + bool buildGraphic3DShape( BOARD_ITEM* aItem, const VECTOR2D& aOrigin ); + void initOutputVariant(); + + // Member variables - simplified stubs without the actual OCC-dependent types + EXPORTER_STEP_PARAMS m_params; + REPORTER* m_reporter; + BOARD* m_board; +}; + +EXPORTER_STEP::EXPORTER_STEP( BOARD* aBoard, const EXPORTER_STEP_PARAMS& aParams, REPORTER* aReporter ) + : m_params( aParams ), + m_reporter( aReporter ), + m_board( aBoard ) +{ +} + +EXPORTER_STEP::~EXPORTER_STEP() +{ +} + +bool EXPORTER_STEP::Export() +{ + if( m_reporter ) + { + m_reporter->Report( wxT( "STEP export is not available (OCC support disabled)" ), + RPT_SEVERITY_ERROR ); + } + return false; +} + +bool EXPORTER_STEP::buildBoard3DShapes() +{ + return false; +} + +bool EXPORTER_STEP::buildFootprint3DShapes( FOOTPRINT* aFootprint, const VECTOR2D& aOrigin, SHAPE_POLY_SET* aClipPolygon ) +{ + (void)aFootprint; (void)aOrigin; (void)aClipPolygon; + return false; +} + +bool EXPORTER_STEP::buildTrack3DShape( PCB_TRACK* aTrack, const VECTOR2D& aOrigin ) +{ + (void)aTrack; (void)aOrigin; + return false; +} + +void EXPORTER_STEP::buildZones3DShape( VECTOR2D aOrigin ) +{ + (void)aOrigin; +} + +bool EXPORTER_STEP::buildGraphic3DShape( BOARD_ITEM* aItem, const VECTOR2D& aOrigin ) +{ + (void)aItem; (void)aOrigin; + return false; +} + +void EXPORTER_STEP::initOutputVariant() +{ +} diff --git a/stubs/src/panel_git_repos_stub.cpp b/stubs/src/panel_git_repos_stub.cpp new file mode 100644 index 0000000..4bb6435 --- /dev/null +++ b/stubs/src/panel_git_repos_stub.cpp @@ -0,0 +1,36 @@ +/* + * KiCad Wasm Port - Stub implementation for PANEL_GIT_REPOS + * + * Provides empty/stub implementation for PANEL_GIT_REPOS when KICAD_USE_GIT=OFF. + * This file is added to the common library sources. + */ + +#include +#include +#include + +PANEL_GIT_REPOS::PANEL_GIT_REPOS( wxWindow* aParent ) + : PANEL_GIT_REPOS_BASE( aParent ) +{ + // Hide all the git-related controls since git is disabled + m_gitSizer->Show( false ); + + // Add a message saying git is disabled + wxBoxSizer* msgSizer = new wxBoxSizer( wxVERTICAL ); + wxStaticText* text = new wxStaticText( this, wxID_ANY, + wxT("Git support is disabled in this build.") ); + msgSizer->Add( text, 0, wxALL | wxALIGN_CENTER_HORIZONTAL, 20 ); + GetSizer()->Add( msgSizer, 1, wxEXPAND | wxALL, 5 ); +} + +PANEL_GIT_REPOS::~PANEL_GIT_REPOS() {} + +void PANEL_GIT_REPOS::ResetPanel() {} + +bool PANEL_GIT_REPOS::TransferDataFromWindow() { return true; } + +bool PANEL_GIT_REPOS::TransferDataToWindow() { return true; } + +void PANEL_GIT_REPOS::onDefaultClick( wxCommandEvent& event ) { (void)event; } + +void PANEL_GIT_REPOS::onEnableGitClick( wxCommandEvent& event ) { (void)event; }