|
1 | 1 | ## Instructions to build a DLL |
2 | 2 |
|
3 | | -1. Check out `git` to a new folder |
4 | | -2. Open Visual Studio 2019 |
5 | | -3. Choose the "Open a folder" option and choose the git checkout |
6 | | -4. In the configurations dropdown, choose "Manage configurations..." |
7 | | -5. Add a new "Release|x86" configuration and save the `CMakeSettings.json` file |
8 | | -6. Choose this new "Release|x86" configuration in the configurations dropdown |
9 | | -7. Go to "Build" > "Build All" and wait for the build to complete without errors |
10 | | -8. Find the new DLL in `out\build\x86-Release\SimpleGraphic.dll` |
11 | | - |
12 | | -To use this DLL, simply copy it to your Path Of Building install location and |
13 | | -restart Path Of Building. |
| 3 | +The directory names and locations chosen for your environment are flexible, below we use the following: |
| 4 | + |
| 5 | +* source directory - `PoB-SimpleGraphic` |
| 6 | +* build directory - `build-SimpleGraphic` |
| 7 | +* Path of Building dev tree - `PoB` |
| 8 | +* install directory - `PoB\runtime` |
| 9 | + |
| 10 | +Try to avoid paths with spaces, some of our dependencies are brittle and won't build properly then. |
| 11 | + |
| 12 | +1. Clone the repository with `git clone --recursive` to obtain the sources and the submodules for dependencies, like: |
| 13 | + ```powershell |
| 14 | + git clone --recursive "https://github.com/PathOfBuildingCommunity/PathOfBuilding-SimpleGraphic" "PoB-SimpleGraphic" |
| 15 | + ``` |
| 16 | +
|
| 17 | +2. Configure a build directory for the sources with CMake generating Visual Studio build files: |
| 18 | + ```powershell |
| 19 | + cmake -B "build-SimpleGraphic" -S "PoB-SimpleGraphic" -A x64 -G "Visual Studio 17 2022" --toolchain "vcpkg\scripts\buildsystems\vcpkg.cmake" -DCMAKE_INSTALL_PREFIX="PoB\runtime" |
| 20 | + ``` |
| 21 | +
|
| 22 | +3. Open the generated `build-SimpleGraphic\SimpleGraphic.sln` file in Visual Studio. |
| 23 | +
|
| 24 | +4. There's three primary build configurations of interest for development largely aligning with the CMake configurations of the same name: |
| 25 | +
|
| 26 | + * `Debug`: Low optimization, easy to step through logic and inspect values without it being all optimized out; |
| 27 | + * `RelWithDebInfo`: Medium optimization, still somewhat debuggable but also better performance; |
| 28 | + * `Release`: Full optimization - modified from the stock CMake configuration to still generate debug symbols. |
| 29 | +
|
| 30 | +5. Build the solution to compile the dependencies and SimpleGraphic itself, the DLL and some of the dependencies can be found in the build directory in a directory named after the configuration. |
| 31 | +
|
| 32 | +6. Build the `INSTALL` target to install the SimpleGraphic DLL and the dependencies to the install directory, here `PoB\runtime`. |
| 33 | +
|
| 34 | +
|
| 35 | +## Debugging SimpleGraphic |
| 36 | +
|
| 37 | +The debugger settings in Visual Studio can't quite be communicated through CMake scripts so we have to do some manual setup to point out which executable and what working directory and command line arguments we wish to use to debug the DLL. |
| 38 | +
|
| 39 | +1. In Visual Studio open the Project Properties for the SimpleGraphic project. |
| 40 | +
|
| 41 | +2. Go to the Debugging page and set the following fields, either for each configuration or once for "All Configurations": |
| 42 | +
|
| 43 | + * "Debugger to launch" - `Local Windows Debugger` |
| 44 | + * "Command" - `$(ProjectDir)..\PoB\runtime\Path{space}of{space}Building.exe` |
| 45 | + * "Command Arguments" - leave this empty unless you wish to launch a specific Lua entrypoint or test something like URLs on the command line |
| 46 | + * "Working Directory" - `$(ProjectDir)..\PoB\runtime` |
| 47 | +
|
| 48 | +3. This debugger configuration will use the DLL file that is in the PoB install directory, so remember to build the `INSTALL` target before debugging to deploy the DLL and its dependencies. |
| 49 | +
|
| 50 | +4. Set breakpoints and launch new debug sessions from inside Visual Studio or attach to an existing process, as long as the sources match the debug information in the DLL it'll all work fine. |
| 51 | +
|
| 52 | +
|
| 53 | +## Development tricks |
| 54 | +
|
| 55 | +A PowerShell script like the following can be run with Administrator rights to link a DLL file in the build directory into a PoB runtime tree to avoid having to build the `INSTALL` target for every change: |
| 56 | +
|
| 57 | +```powershell |
| 58 | +param ($Config="RelWithDebInfo") |
| 59 | +$BuildTree = "..\..\build-SimpleGraphic" |
| 60 | +$BuildDir = "${BuildTree}\$Config" |
| 61 | +$RunDir = ".\PoB\runtime" |
| 62 | +$VcpkgBinDir = "${BuildTree}\vcpkg_installed\x64-windows\bin" |
| 63 | +
|
| 64 | +$Suffix = "" |
| 65 | +if ($Config -eq "Debug") |
| 66 | +{ |
| 67 | + $Suffix = "d" |
| 68 | +} |
| 69 | +
|
| 70 | +New-Item -ItemType SymbolicLink -Force -Path "${RunDir}\SimpleGraphic.dll" -Target "${BuildDir}\SimpleGraphic.dll" |
| 71 | +``` |
| 72 | + |
| 73 | +Don't forget to re-run the script if you change the configuration so that the correct DLL is used by the application. |
0 commit comments