diff --git a/docs/visual-studio-setup.md b/docs/visual-studio-setup.md index 3faddbc8..3813e8d0 100644 --- a/docs/visual-studio-setup.md +++ b/docs/visual-studio-setup.md @@ -1,6 +1,6 @@ -# Visual Studio Setup Guide for YAZE +# Visual Studio Setup Guide -This guide will help Visual Studio users set up and build the YAZE project on Windows. +This guide will help Visual Studio users set up and build the yaze project on Windows. ## Prerequisites @@ -51,15 +51,23 @@ vcpkg install abseil:x64-windows vcpkg install gtest:x64-windows ``` -### 3. Configure CMake +### 3. Configure Build System -#### Option A: Using Visual Studio (Recommended) +#### Option A: Using Visual Studio Project File (Easiest) 1. Open Visual Studio 2022 -2. Select "Open a local folder" and navigate to the YAZE project folder +2. Select "Open a project or solution" +3. Navigate to the yaze project folder and open `yaze.sln` +4. The project is pre-configured with vcpkg integration and proper dependencies +5. Select your desired build configuration (Debug/Release) and platform (x64/x86) +6. Press F5 to build and run, or Ctrl+Shift+B to build only + +#### Option B: Using CMake with Visual Studio (Recommended for developers) +1. Open Visual Studio 2022 +2. Select "Open a local folder" and navigate to the yaze project folder 3. Visual Studio will automatically detect the CMake project 4. Wait for CMake configuration to complete (check Output window) -#### Option B: Using Command Line +#### Option C: Using Command Line ```cmd mkdir build cd build @@ -68,18 +76,20 @@ cmake .. -G "Visual Studio 17 2022" -A x64 -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%/s ### 4. Build Configuration -#### For Development (Debug Build) +#### Using Visual Studio Project File (.vcxproj) +- **Debug Build:** Select "Debug" configuration and press F5 or Ctrl+Shift+B +- **Release Build:** Select "Release" configuration and press F5 or Ctrl+Shift+B +- **Platform:** Choose x64 (recommended) or x86 from the platform dropdown + +#### Using CMake (Command Line) ```cmd +# For Development (Debug Build) cmake --build . --config Debug --target yaze -``` -#### For Release Build -```cmd +# For Release Build cmake --build . --config Release --target yaze -``` -#### For Testing (Optional) -```cmd +# For Testing (Optional) cmake --build . --config Debug --target yaze_test ``` @@ -133,9 +143,9 @@ Create or modify `.vscode/settings.json` or use Visual Studio's CMake settings: { "cmake.configureArgs": [ "-DCMAKE_TOOLCHAIN_FILE=${env:VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", - "-DYAZE_BUILD_TESTS=ON", - "-DYAZE_BUILD_APP=ON", - "-DYAZE_BUILD_LIB=ON" + "-Dyaze_BUILD_TESTS=ON", + "-Dyaze_BUILD_APP=ON", + "-Dyaze_BUILD_LIB=ON" ], "cmake.buildDirectory": "${workspaceFolder}/build" } @@ -150,13 +160,20 @@ The project includes CMake presets in `CMakePresets.json`. Use these in Visual S ## Running the Application +### Using Visual Studio Project File +1. Open `yaze.sln` in Visual Studio +2. Set `yaze` as the startup project (should be default) +3. Configure command line arguments in Project Properties > Debugging > Command Arguments + - Example: `--rom_file=C:\path\to\your\zelda3.sfc` +4. Press F5 to build and run, or Ctrl+F5 to run without debugging + ### Command Line ```cmd cd build/bin/Debug # or Release yaze.exe --rom_file=path/to/your/zelda3.sfc ``` -### Visual Studio +### Visual Studio (CMake) 1. Set `yaze` as the startup project 2. Configure command line arguments in Project Properties > Debugging 3. Press F5 to run @@ -200,12 +217,37 @@ del CMakeCache.txt cmake .. -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%/scripts/buildsystems/vcpkg.cmake ``` +## Visual Studio Project File Features + +The included `yaze.vcxproj` and `yaze.sln` files provide: + +### **Automatic Dependency Management** +- **vcpkg Integration:** Automatically installs and links dependencies from `vcpkg.json` +- **Platform Support:** Pre-configured for both x64 and x86 builds +- **Library Linking:** Automatically links SDL2, zlib, libpng, and system libraries + +### **Build Configuration** +- **Debug Configuration:** Includes debugging symbols and runtime checks +- **Release Configuration:** Optimized for performance with full optimizations +- **C++23 Standard:** Uses modern C++ features and standard library + +### **Asset Management** +- **Automatic Asset Copying:** Post-build events copy themes and assets to output directory +- **ROM File Handling:** Automatically copies `zelda3.sfc` if present in project root +- **Resource Organization:** Properly structures output directory for distribution + +### **Development Features** +- **IntelliSense Support:** Full code completion and error detection +- **Debugging Integration:** Native Visual Studio debugging support +- **Project Properties:** Easy access to compiler and linker settings + ## Additional Notes - The project supports both x64 and x86 builds (use appropriate vcpkg triplets) - For ARM64 Windows builds, use `arm64-windows` triplet - The CI/CD pipeline uses minimal builds to avoid dependency issues - Development builds include additional debugging features and ROM testing capabilities +- The `.vcxproj` file provides the easiest setup for Visual Studio users who prefer traditional project files over CMake ## Support diff --git a/scripts/setup-vcpkg-windows.bat b/scripts/setup-vcpkg-windows.bat index 61c8ed9c..96c2368c 100644 --- a/scripts/setup-vcpkg-windows.bat +++ b/scripts/setup-vcpkg-windows.bat @@ -1,54 +1,68 @@ @echo off -REM Setup script for vcpkg on Windows -REM This script helps set up vcpkg for YAZE Windows builds +echo ======================================== +echo yaze Visual Studio Setup Script +echo ======================================== +echo. -echo Setting up vcpkg for YAZE Windows builds... - -REM Check if vcpkg directory exists -if not exist "vcpkg" ( - echo Cloning vcpkg... - git clone https://github.com/Microsoft/vcpkg.git - if errorlevel 1 ( - echo Error: Failed to clone vcpkg repository - pause - exit /b 1 - ) +REM Check if vcpkg is installed +if not exist "%VCPKG_ROOT%" ( + echo ERROR: VCPKG_ROOT environment variable is not set! + echo Please install vcpkg and set the VCPKG_ROOT environment variable. + echo Example: set VCPKG_ROOT=C:\vcpkg + echo. + echo Download vcpkg from: https://github.com/Microsoft/vcpkg + echo After installation, run: .\vcpkg integrate install + pause + exit /b 1 ) -REM Bootstrap vcpkg -cd vcpkg -if not exist "vcpkg.exe" ( - echo Bootstrapping vcpkg... - call bootstrap-vcpkg.bat - if errorlevel 1 ( - echo Error: Failed to bootstrap vcpkg - pause - exit /b 1 - ) +echo VCPKG_ROOT is set to: %VCPKG_ROOT% +echo. + +REM Check if vcpkg.exe exists +if not exist "%VCPKG_ROOT%\vcpkg.exe" ( + echo ERROR: vcpkg.exe not found at %VCPKG_ROOT%\vcpkg.exe + echo Please verify your vcpkg installation. + pause + exit /b 1 ) -REM Integrate vcpkg with Visual Studio (optional) +echo Installing dependencies via vcpkg... +echo This may take several minutes on first run. +echo. + +REM Install dependencies for x64-windows +echo Installing x64-windows dependencies... +"%VCPKG_ROOT%\vcpkg.exe" install zlib:x64-windows +"%VCPKG_ROOT%\vcpkg.exe" install libpng:x64-windows +"%VCPKG_ROOT%\vcpkg.exe" install sdl2[vulkan]:x64-windows +"%VCPKG_ROOT%\vcpkg.exe" install abseil:x64-windows +"%VCPKG_ROOT%\vcpkg.exe" install gtest:x64-windows + +echo. +echo Installing x86-windows dependencies... +"%VCPKG_ROOT%\vcpkg.exe" install zlib:x86-windows +"%VCPKG_ROOT%\vcpkg.exe" install libpng:x86-windows +"%VCPKG_ROOT%\vcpkg.exe" install sdl2[vulkan]:x86-windows +"%VCPKG_ROOT%\vcpkg.exe" install abseil:x86-windows +"%VCPKG_ROOT%\vcpkg.exe" install gtest:x86-windows + +echo. echo Integrating vcpkg with Visual Studio... -vcpkg integrate install - -REM Set environment variable for this session -set VCPKG_ROOT=%CD% -echo VCPKG_ROOT set to: %VCPKG_ROOT% - -cd .. +"%VCPKG_ROOT%\vcpkg.exe" integrate install echo. -echo vcpkg setup complete! +echo ======================================== +echo Setup Complete! +echo ======================================== echo. -echo To use vcpkg with YAZE: -echo 1. Use the Windows presets in CMakePresets.json: -echo - windows-debug (Debug build) -echo - windows-release (Release build) +echo You can now: +echo 1. Open yaze.sln in Visual Studio 2022 +echo 2. Select Debug or Release configuration +echo 3. Choose x64 or x86 platform +echo 4. Press F5 to build and run echo. -echo 2. Or set VCPKG_ROOT environment variable: -echo set VCPKG_ROOT=%CD%\vcpkg +echo If you have a Zelda 3 ROM file, place it in the project root +echo and name it 'zelda3.sfc' for automatic copying. echo. -echo 3. Dependencies will be automatically installed via vcpkg manifest mode -echo. - pause diff --git a/yaze.sln b/yaze.sln new file mode 100644 index 00000000..ef6033f1 --- /dev/null +++ b/yaze.sln @@ -0,0 +1,30 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "YAZE", "YAZE.vcxproj", "{A1B2C3D4-E5F6-7890-ABCD-EF1234567890}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A1B2C3D4-E5F6-7890-ABCD-EF1234567890}.Debug|x64.ActiveCfg = Debug|x64 + {A1B2C3D4-E5F6-7890-ABCD-EF1234567890}.Debug|x64.Build.0 = Debug|x64 + {A1B2C3D4-E5F6-7890-ABCD-EF1234567890}.Debug|x86.ActiveCfg = Debug|x86 + {A1B2C3D4-E5F6-7890-ABCD-EF1234567890}.Debug|x86.Build.0 = Debug|x86 + {A1B2C3D4-E5F6-7890-ABCD-EF1234567890}.Release|x64.ActiveCfg = Release|x64 + {A1B2C3D4-E5F6-7890-ABCD-EF1234567890}.Release|x64.Build.0 = Release|x64 + {A1B2C3D4-E5F6-7890-ABCD-EF1234567890}.Release|x86.ActiveCfg = Release|x86 + {A1B2C3D4-E5F6-7890-ABCD-EF1234567890}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {12345678-1234-5678-9ABC-DEF123456789} + EndGlobalSection +EndGlobal diff --git a/yaze.vcxproj b/yaze.vcxproj new file mode 100644 index 00000000..ac3cb86c --- /dev/null +++ b/yaze.vcxproj @@ -0,0 +1,267 @@ + + + + + Debug + x64 + + + Release + x64 + + + Debug + x86 + + + Release + x86 + + + + + 17.0 + Win32Proj + {A1B2C3D4-E5F6-7890-ABCD-EF1234567890} + YAZE + 10.0 + YAZE + true + true + x86-windows + x64-windows + + + + + + Application + true + v143 + Unicode + true + true + x64-windows + + + + Application + false + v143 + true + Unicode + true + true + x64-windows + + + + Application + true + v143 + Unicode + true + true + x86-windows + + + + Application + false + v143 + true + Unicode + true + true + x86-windows + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)build\bin\$(Configuration)\ + $(SolutionDir)build\obj\$(ProjectName)\$(Configuration)\ + yaze + + + + false + $(SolutionDir)build\bin\$(Configuration)\ + $(SolutionDir)build\obj\$(ProjectName)\$(Configuration)\ + yaze + + + + true + $(SolutionDir)build\bin\$(Configuration)\ + $(SolutionDir)build\obj\$(ProjectName)\$(Configuration)\ + yaze + + + + false + $(SolutionDir)build\bin\$(Configuration)\ + $(SolutionDir)build\obj\$(ProjectName)\$(Configuration)\ + yaze + + + + + Level4 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions);YAZE_BUILD_APP=1;YAZE_BUILD_LIB=1;YAZE_BUILD_EMU=1;YAZE_BUILD_TESTS=0 + true + stdcpp23 + src\lib;src\app;src\lib\asar\src;src\lib\asar\src\asar;src\lib\asar\src\asar-dll-bindings\c;incl;src;src\lib\imgui;$(ProjectDir);%(AdditionalIncludeDirectories) + MultiThreadedDebugDLL + + + Console + true + SDL2.lib;SDL2main.lib;zlibd.lib;libpng16d.lib;ws2_32.lib;winmm.lib;imm32.lib;version.lib;oleaut32.lib;ole32.lib;setupapi.lib;advapi32.lib;%(AdditionalDependencies) + $(VcpkgRoot)installed\x64-windows\debug\lib;%(AdditionalLibraryDirectories) + + + if not exist "$(OutDir)assets" mkdir "$(OutDir)assets" +if not exist "$(OutDir)assets\themes" mkdir "$(OutDir)assets\themes" +xcopy /Y /I "$(ProjectDir)assets\*" "$(OutDir)assets\" +if exist "$(ProjectDir)zelda3.sfc" copy /Y "$(ProjectDir)zelda3.sfc" "$(OutDir)" + Copying assets and ROM file... + + + + + + Level4 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions);YAZE_BUILD_APP=1;YAZE_BUILD_LIB=1;YAZE_BUILD_EMU=1;YAZE_BUILD_TESTS=0 + true + stdcpp23 + src\lib;src\app;src\lib\asar\src;src\lib\asar\src\asar;src\lib\asar\src\asar-dll-bindings\c;incl;src;src\lib\imgui;$(ProjectDir);%(AdditionalIncludeDirectories) + MultiThreadedDLL + + + Console + true + true + true + SDL2.lib;SDL2main.lib;zlib.lib;libpng16.lib;ws2_32.lib;winmm.lib;imm32.lib;version.lib;oleaut32.lib;ole32.lib;setupapi.lib;advapi32.lib;%(AdditionalDependencies) + $(VcpkgRoot)installed\x64-windows\lib;%(AdditionalLibraryDirectories) + + + if not exist "$(OutDir)assets" mkdir "$(OutDir)assets" +if not exist "$(OutDir)assets\themes" mkdir "$(OutDir)assets\themes" +xcopy /Y /I "$(ProjectDir)assets\*" "$(OutDir)assets\" +if exist "$(ProjectDir)zelda3.sfc" copy /Y "$(ProjectDir)zelda3.sfc" "$(OutDir)" + Copying assets and ROM file... + + + + + + Level4 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions);YAZE_BUILD_APP=1;YAZE_BUILD_LIB=1;YAZE_BUILD_EMU=1;YAZE_BUILD_TESTS=0 + true + stdcpp23 + src\lib;src\app;src\lib\asar\src;src\lib\asar\src\asar;src\lib\asar\src\asar-dll-bindings\c;incl;src;src\lib\imgui;$(ProjectDir);%(AdditionalIncludeDirectories) + MultiThreadedDebugDLL + + + Console + true + SDL2.lib;SDL2main.lib;zlibd.lib;libpng16d.lib;ws2_32.lib;winmm.lib;imm32.lib;version.lib;oleaut32.lib;ole32.lib;setupapi.lib;advapi32.lib;%(AdditionalDependencies) + $(VcpkgRoot)installed\x86-windows\debug\lib;%(AdditionalLibraryDirectories) + + + if not exist "$(OutDir)assets" mkdir "$(OutDir)assets" +if not exist "$(OutDir)assets\themes" mkdir "$(OutDir)assets\themes" +xcopy /Y /I "$(ProjectDir)assets\*" "$(OutDir)assets\" +if exist "$(ProjectDir)zelda3.sfc" copy /Y "$(ProjectDir)zelda3.sfc" "$(OutDir)" + Copying assets and ROM file... + + + + + + Level4 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions);YAZE_BUILD_APP=1;YAZE_BUILD_LIB=1;YAZE_BUILD_EMU=1;YAZE_BUILD_TESTS=0 + true + stdcpp23 + src\lib;src\app;src\lib\asar\src;src\lib\asar\src\asar;src\lib\asar\src\asar-dll-bindings\c;incl;src;src\lib\imgui;$(ProjectDir);%(AdditionalIncludeDirectories) + MultiThreadedDLL + + + Console + true + true + true + SDL2.lib;SDL2main.lib;zlib.lib;libpng16.lib;ws2_32.lib;winmm.lib;imm32.lib;version.lib;oleaut32.lib;ole32.lib;setupapi.lib;advapi32.lib;%(AdditionalDependencies) + $(VcpkgRoot)installed\x86-windows\lib;%(AdditionalLibraryDirectories) + + + if not exist "$(OutDir)assets" mkdir "$(OutDir)assets" +if not exist "$(OutDir)assets\themes" mkdir "$(OutDir)assets\themes" +xcopy /Y /I "$(ProjectDir)assets\*" "$(OutDir)assets\" +if exist "$(ProjectDir)zelda3.sfc" copy /Y "$(ProjectDir)zelda3.sfc" "$(OutDir)" + Copying assets and ROM file... + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +