From 17682c6cad0f0d38d1295a2af71c5ae685d4cbe0 Mon Sep 17 00:00:00 2001 From: shad0wshayd3 Date: Fri, 3 May 2024 16:14:03 -0600 Subject: [PATCH] reformat project --- .clang-format | 100 ---------- .editorconfig | 15 -- .gitattributes | 3 +- .github/workflows/build.yml | 32 +++ .github/workflows/clang-format.yml | 21 ++ .github/workflows/maintenance.yml | 37 ++-- .gitignore | 7 +- .gitmodules | 6 +- CMakeLists.txt | 74 ------- CMakePresets.json | 65 ------ LICENSE | 2 +- Plugin/!update.ps1 | 263 +++++++++++++++++++++++++ Plugin/.clang-format | 97 +++++++++ Plugin/CMakeLists.txt | 132 +++++++++++++ Plugin/CMakePresets.json | 233 ++++++++++++++++++++++ Plugin/cmake/Plugin.h.in | 12 ++ Plugin/cmake/build_stl_modules.props | 8 + Plugin/cmake/common.cmake | 44 +++++ {cmake => Plugin/cmake}/version.rc.in | 2 +- Plugin/dist/BakaScrapHeap.ini | 3 + Plugin/dist/rules/!base.json | 16 ++ Plugin/dist/rules/bin_copy.json | 16 ++ Plugin/dist/rules/config_copy.json | 23 +++ Plugin/dist/rules/publish_package.json | 54 +++++ Plugin/src/PCH.h | 136 +++++++++++++ Plugin/src/main.cpp | 108 ++++++++++ vcpkg.json => Plugin/vcpkg.json | 9 +- build-clang-cl.bat | 4 + build-msvc.bat | 4 + cmake/Version.h.in | 10 - cmake/ports/autotoml/portfile.cmake | 18 -- cmake/ports/autotoml/vcpkg.json | 17 -- extern/BethesdaCMakeModules | 1 - extern/CommonLibF4 | 2 +- extern/DKUtil | 1 + make-sln-clang-cl.bat | 3 + make-sln-msvc.bat | 3 + res/settings.toml | 4 - src/CMakeLists.txt | 2 - src/c++/CMakeLists.txt | 184 ----------------- src/c++/PCH.cpp | 37 ---- src/c++/PCH.h | 45 ----- src/c++/Settings.h | 48 ----- src/c++/main.cpp | 75 ------- src/papyrus/CMakeLists.txt | 60 ------ update-submodule.bat | 2 + 46 files changed, 1246 insertions(+), 792 deletions(-) delete mode 100644 .clang-format delete mode 100644 .editorconfig create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/clang-format.yml delete mode 100644 CMakeLists.txt delete mode 100644 CMakePresets.json create mode 100644 Plugin/!update.ps1 create mode 100644 Plugin/.clang-format create mode 100644 Plugin/CMakeLists.txt create mode 100644 Plugin/CMakePresets.json create mode 100644 Plugin/cmake/Plugin.h.in create mode 100644 Plugin/cmake/build_stl_modules.props create mode 100644 Plugin/cmake/common.cmake rename {cmake => Plugin/cmake}/version.rc.in (94%) create mode 100644 Plugin/dist/BakaScrapHeap.ini create mode 100644 Plugin/dist/rules/!base.json create mode 100644 Plugin/dist/rules/bin_copy.json create mode 100644 Plugin/dist/rules/config_copy.json create mode 100644 Plugin/dist/rules/publish_package.json create mode 100644 Plugin/src/PCH.h create mode 100644 Plugin/src/main.cpp rename vcpkg.json => Plugin/vcpkg.json (55%) create mode 100644 build-clang-cl.bat create mode 100644 build-msvc.bat delete mode 100644 cmake/Version.h.in delete mode 100644 cmake/ports/autotoml/portfile.cmake delete mode 100644 cmake/ports/autotoml/vcpkg.json delete mode 160000 extern/BethesdaCMakeModules create mode 160000 extern/DKUtil create mode 100644 make-sln-clang-cl.bat create mode 100644 make-sln-msvc.bat delete mode 100644 res/settings.toml delete mode 100644 src/CMakeLists.txt delete mode 100644 src/c++/CMakeLists.txt delete mode 100644 src/c++/PCH.cpp delete mode 100644 src/c++/PCH.h delete mode 100644 src/c++/Settings.h delete mode 100644 src/c++/main.cpp delete mode 100644 src/papyrus/CMakeLists.txt create mode 100644 update-submodule.bat diff --git a/.clang-format b/.clang-format deleted file mode 100644 index ec370f5..0000000 --- a/.clang-format +++ /dev/null @@ -1,100 +0,0 @@ -AccessModifierOffset: -4 -AlignAfterOpenBracket: AlwaysBreak -AlignArrayOfStructures: Left -AlignConsecutiveAssignments: None -AlignConsecutiveBitFields: Consecutive -AlignConsecutiveDeclarations: None -AlignConsecutiveMacros: None -AlignEscapedNewlines: Right -AlignOperands: Align -AllowAllArgumentsOnNextLine: False -AllowAllParametersOfDeclarationOnNextLine: False -AllowShortBlocksOnASingleLine: Never -AllowShortCaseLabelsOnASingleLine: False -AllowShortEnumsOnASingleLine: False -AllowShortFunctionsOnASingleLine: Inline -AllowShortIfStatementsOnASingleLine: Never -AllowShortLambdasOnASingleLine: Inline -AllowShortLoopsOnASingleLine: False -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: False -AlwaysBreakTemplateDeclarations: Yes -BinPackArguments: False -BinPackParameters: False -BitFieldColonSpacing: Both -BraceWrapping: - AfterCaseLabel: True - AfterClass: True - AfterControlStatement: Always - AfterEnum: True - AfterFunction: True - AfterNamespace: True - AfterStruct: True - AfterUnion: True - AfterExternBlock: True - BeforeCatch: True - BeforeElse: True - BeforeLambdaBody: True - BeforeWhile: True - IndentBraces: False - SplitEmptyFunction: False - SplitEmptyRecord: False - SplitEmptyNamespace: False -BreakBeforeBinaryOperators: NonAssignment -BreakBeforeBraces: Custom -BreakBeforeTernaryOperators: True -BreakConstructorInitializers: AfterColon -BreakInheritanceList: AfterColon -BreakStringLiterals: False -ColumnLimit: 0 -CompactNamespaces: False -Cpp11BracedListStyle: False -EmptyLineAfterAccessModifier: Never -EmptyLineBeforeAccessModifier: Always -FixNamespaceComments: False -IncludeBlocks: Preserve -IndentAccessModifiers: False -IndentCaseBlocks: True -IndentCaseLabels: True -IndentExternBlock: AfterExternBlock -IndentGotoLabels: False -IndentPPDirectives: AfterHash -IndentWidth: 4 -IndentWrappedFunctionNames: True -KeepEmptyLinesAtTheStartOfBlocks: False -LambdaBodyIndentation: Signature -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: All -PPIndentWidth: 1 -PackConstructorInitializers: NextLine -PointerAlignment: Left -QualifierAlignment: Custom -QualifierOrder: ['inline', 'static', 'const', 'type'] -ReferenceAlignment: Left -ReflowComments: False -SeparateDefinitionBlocks: Always -SortIncludes: CaseInsensitive -SpaceAfterCStyleCast: False -SpaceAfterLogicalNot: False -SpaceAfterTemplateKeyword: False -SpaceBeforeAssignmentOperators: True -SpaceBeforeCaseColon: False -SpaceBeforeCpp11BracedList: False -SpaceBeforeCtorInitializerColon: True -SpaceBeforeInheritanceColon: True -SpaceBeforeParens: ControlStatements -SpaceBeforeRangeBasedForLoopColon: True -SpaceBeforeSquareBrackets: False -SpaceInEmptyBlock: False -SpaceInEmptyParentheses: False -SpacesBeforeTrailingComments: 2 -SpacesInAngles: Never -SpacesInCStyleCastParentheses: False -SpacesInConditionalStatement: False -SpacesInContainerLiterals: True -SpacesInParentheses: False -SpacesInSquareBrackets: False -Standard: Latest -TabWidth: 4 -UseCRLF: True -UseTab: AlignWithSpaces diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index fb7e6e3..0000000 --- a/.editorconfig +++ /dev/null @@ -1,15 +0,0 @@ -[*] -charset = utf-8 -insert_final_newline = true - -[*.{hpp,cpp}] -indent_style = tab -indent_size = 4 - -[{CMakeLists.txt,*.cmake,*.cmake.in}] -indent_style = tab -indent_size = 4 - -[*.{json,yml}] -indent_style = space -indent_size = 2 diff --git a/.gitattributes b/.gitattributes index dfe0770..cc864ad 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1 @@ -# Auto detect text files and perform LF normalization -* text=auto +*.ps1 linguist-vendored \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..3f65f13 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,32 @@ +name: CI + +on: + push: + paths: + - "Plugin/**" + workflow_dispatch: + +jobs: + run-build: + runs-on: windows-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Dependencies + run: | + git submodule update --init --recursive; + vcpkg integrate install + + - name: Build + run: | + Remove-Item build -Recurse -Force -ErrorAction:SilentlyContinue -Confirm:$False | Out-Null; + cmake -B build -S Plugin --preset=build-release-msvc-msvc -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake; + cmake --build build + + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + name: Release + path: build/Release + retention-days: 30 diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml new file mode 100644 index 0000000..6b2ed65 --- /dev/null +++ b/.github/workflows/clang-format.yml @@ -0,0 +1,21 @@ +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - uses: DoozyX/clang-format-lint-action@v0.16.2 + with: + source: '.' + exclude: './docs' + extensions: 'c,cc,cpp,cxx,h,hpp,hxx,inl,inc,ixx' + clangFormatVersion: 16 + inplace: True + - uses: EndBug/add-and-commit@v9 + with: + author_name: clang-format + message: 'chore: style formatting' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/maintenance.yml b/.github/workflows/maintenance.yml index 9fed75d..24bd4ed 100644 --- a/.github/workflows/maintenance.yml +++ b/.github/workflows/maintenance.yml @@ -1,33 +1,24 @@ -name: Scripted maintenance +name: Maintenance -on: [ push, pull_request_target ] +on: [push] jobs: maintenance: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + + - uses: DoozyX/clang-format-lint-action@v0.16.2 with: - ref: ${{ github.head_ref }} + source: '.' + exclude: './docs' + extensions: 'c,cc,cpp,cppm,cxx,h,hpp,hxx,inl,inc,ixx,mxx' + clangFormatVersion: 16 + inplace: True - - name: Cache LLVM and Clang - id: cache-llvm - uses: actions/cache@v2 + - uses: EndBug/add-and-commit@v9 with: - path: ${{ runner.temp }}/llvm - key: llvm-14 - - - name: Install LLVM and Clang - uses: KyleMayes/install-llvm-action@v1 - with: - version: "14" - directory: ${{ runner.temp }}/llvm - cached: ${{ steps.cache-llvm.outputs.cache-hit }} - - - name: Run clang-format - run: find -type f \( -name *.h -o -name *.cpp \) | xargs clang-format -style=file -i - - - uses: stefanzweifel/git-auto-commit-action@v4 - with: - commit_message: maintenance + committer_name: clang-format + committer_email: 41898282+github-actions[bot]@users.noreply.github.com + message: 'chore: style formatting' diff --git a/.gitignore b/.gitignore index d163863..5c96cd0 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,6 @@ -build/ \ No newline at end of file +[Bb]uild/ +.vs/ +.vscode/ +*.zip +*.timestamp +deploy-*.ps1 diff --git a/.gitmodules b/.gitmodules index 4957572..350cfcd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "extern/CommonLibF4"] path = extern/CommonLibF4 url = https://github.com/shad0wshayd3/CommonLibF4.git -[submodule "extern/BethesdaCMakeModules"] - path = extern/BethesdaCMakeModules - url = https://github.com/shad0wshayd3/BethesdaCMakeModules.git +[submodule "extern/DKUtil"] + path = extern/DKUtil + url = https://github.com/gottyduke/DKUtil.git diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 22dc97c..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,74 +0,0 @@ -cmake_minimum_required(VERSION 3.22) -set(NAME "BakaScrapHeap") -set(VERSION 2.2.0) - -# ---- Options ---- - -option(COPY_BUILD "Copy the build output to the Fallout 4 directory." OFF) - -# ---- Cache build vars ---- - -macro(set_from_environment VARIABLE) - if (NOT DEFINED ${VARIABLE} AND DEFINED ENV{${VARIABLE}}) - set(${VARIABLE} $ENV{${VARIABLE}}) - endif() -endmacro() - -macro(find_commonlib_path) - if (CommonLibName AND NOT ${CommonLibName} STREQUAL "") - # Check extern - find_path(CommonLibPath - NAMES - include/REL/Relocation.h - PATHS - extern/${CommonLibName} - extern/${CommonLibName}/${CommonLibName} - ) - if (${CommonLibName} STREQUAL "CommonLibName-NOTFOUND") - #Check path - set_from_environment(${CommonLibName}Path) - set(CommonLibName ${${CommonLibName}Path}) - endif() - endif() -endmacro() - -set_from_environment(VCPKG_ROOT) -if (NOT DEFINED VCPKG_ROOT) - message( - WARNING - "Variable VCPKG_ROOT is not set. Continuing without vcpkg." - ) -endif() - -set_from_environment(Fallout4Path) -set(CommonLibName "CommonLibF4") -find_commonlib_path("CommonLibF4") - -message( - STATUS - "Building for Fallout 4 at ${Fallout4Path} with ${CommonLibName} at ${CommonLibPath}." -) - -set(Boost_USE_STATIC_RUNTIME OFF CACHE BOOL "") -set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" CACHE STRING "") - -# ---- Project ---- - -project( - ${NAME} - VERSION ${VERSION} - LANGUAGES CXX -) - -# ---- Include guards ---- - -if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) - message( - FATAL_ERROR - "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there." - ) -endif() - -# ---- Subdirectories ---- - -add_subdirectory(src) diff --git a/CMakePresets.json b/CMakePresets.json deleted file mode 100644 index 00350b9..0000000 --- a/CMakePresets.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "configurePresets": [ - { - "binaryDir": "${sourceDir}/build", - "cacheVariables": { - "CMAKE_BUILD_TYPE": { - "type": "STRING", - "value": "Release" - } - }, - "errors": { - "deprecated": true - }, - "hidden": true, - "name": "cmake-dev", - "warnings": { - "deprecated": true, - "dev": true - } - }, - { - "cacheVariables": { - "CMAKE_TOOLCHAIN_FILE": { - "type": "STRING", - "value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" - }, - "VCPKG_OVERLAY_PORTS": { - "type": "STRING", - "value": "${sourceDir}/cmake/ports/" - } - }, - "hidden": true, - "name": "vcpkg" - }, - { - "cacheVariables": { - "CMAKE_MSVC_RUNTIME_LIBRARY": { - "type": "STRING", - "value": "MultiThreaded$<$:Debug>" - }, - "VCPKG_TARGET_TRIPLET": { - "type": "STRING", - "value": "x64-windows-static" - } - }, - "hidden": true, - "name": "windows" - }, - { - "cacheVariables": { - "CMAKE_CXX_FLAGS": "/EHsc /MP /W4 /WX", - "CMAKE_CXX_FLAGS_RELEASE": "/O2 /DNDEBUG" - }, - "generator": "Visual Studio 17 2022", - "inherits": [ - "cmake-dev", - "vcpkg", - "windows" - ], - "name": "vs2022-windows-vcpkg", - "toolset": "v143" - } - ], - "version": 2 -} diff --git a/LICENSE b/LICENSE index 5337fdb..706fe7b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 shad0wshayd3 +Copyright (c) 2023 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Plugin/!update.ps1 b/Plugin/!update.ps1 new file mode 100644 index 0000000..1cbb5df --- /dev/null +++ b/Plugin/!update.ps1 @@ -0,0 +1,263 @@ +#Requires -Version 5 + +# args +param ( + [Parameter(Mandatory)][ValidateSet('SOURCEGEN', 'DISTRIBUTE')][string]$Mode = 'SOURCEGEN', + [string]$Version, + [string]$Path, + [string]$Payload +) + + +$ErrorActionPreference = "Stop" + +$Folder = $PSScriptRoot | Split-Path -Leaf +$SourceExt = @('.asm', '.c', '.cc', '.cpp', '.cxx', '.h', '.hpp', '.hxx', 'inc', '.inl', '.ixx') +$ConfigExt = @('.ini', '.json', '.toml', '.xml') +$DocsExt = @('.md') + +function Normalize-Path { + param ( + [string]$in + ) + + $out = $in -replace '\\', '/' + while ($out.Contains('//')) { + $out = $out -replace '//', '/' + } + return $out +} + +function Resolve-Files { + param ( + [Parameter(ValueFromPipeline)][string]$parent = $PSScriptRoot, + [string[]]$range = @('include', 'src', 'test') + ) + + process { + Push-Location $PSScriptRoot + $_generated = [System.Collections.ArrayList]::new() + + try { + foreach ($directory in $range) { + if (!$env:RebuildInvoke) { + Write-Host "`t[$parent/$directory]" + } + + Get-ChildItem "$parent/$directory" -Recurse -File -ErrorAction SilentlyContinue | Where-Object { + ($_.Extension -in ($SourceExt + $DocsExt)) -and + ($_.Name -notmatch 'Plugin.h|Version.h') + } | Resolve-Path -Relative | ForEach-Object { + if (!$env:RebuildInvoke) { + Write-Host "`t`t<$_>" + } + $_generated.Add("`n`t`"$(Normalize-Path $_.Substring(2))`"") | Out-Null + } + } + + Get-ChildItem "$parent/dist" -Exclude "rules" | Get-ChildItem -File -Recurse -ErrorAction SilentlyContinue | Where-Object { + ($_.Extension -in ($ConfigExt + $DocsExt)) -and + ($_.Name -notmatch 'cmake|vcpkg') + } | Resolve-Path -Relative | ForEach-Object { + if (!$env:RebuildInvoke) { + Write-Host "`t`t<$_>" + } + $_generated.Add("`n`t`"$(Normalize-Path $_.Substring(2))`"") | Out-Null + } + } + finally { + Pop-Location + } + + return $_generated + } +} + + +Write-Host "`n`t<$Folder> [$Mode]" + + +# @@SOURCEGEN +if ($Mode.ToUpper() -eq 'SOURCEGEN') { + Write-Host "`tGenerating CMake sourcelist..." + Remove-Item "$Path/sourcelist.cmake" -Force -Confirm:$false -ErrorAction Ignore + + $generated = 'set(SOURCES' + $generated += $PSScriptRoot | Resolve-Files + if ($Path) { + $generated += $Path | Resolve-Files + } + $generated += "`n)" + [IO.File]::WriteAllText("$Path/sourcelist.cmake", $generated) +} + +$RuleVarTbl = @{ + config = 'debug'; + cmake_output = Normalize-Path ($Path + '/'); + dist = Normalize-Path "$PSScriptRoot/dist/"; + project_name = $Payload; + project_version = $Version; +} +$RuleCmds = @() + +function Resolve-RuleVar { + param ( + [string]$Path + ) + + $Path = $Path.Trim(' ') + $any = [regex]::Matches($Path, '\{.*?\}').Value + $Resolved = $Path + + # env: + foreach ($unset in $any) { + $inner = $unset.Trim('{', '}') + if ($inner.StartsWith('env:')) { + $Resolved = $Resolved -replace $unset, [System.Environment]::GetEnvironmentVariable($inner.TrimStart('env:')) + } + else { + $Resolved = if ($script:RuleVarTbl.Contains($inner)) { + $Resolved -replace $unset, $script:RuleVarTbl[$inner] + } + else { + $Resolved -replace $unset, $inner + } + } + } + + return Normalize-Path $Resolved.Trim('{', '}') +} + +function Resolve-Rules { + param ( + [Object]$Deployee + ) + + switch ($Deployee.action) { + "base" { + $script:RuleVarTbl[($Deployee.params[0].Trim('{', '}'))] = Resolve-RuleVar $Deployee.params[1] + #"setting $($Deployee.params[0]) to $(Resolve-RuleVar $Deployee.params[1])" + break + } + "copy" { + $source = $(Resolve-RuleVar $Deployee.params[0]) + $destination = $(Resolve-RuleVar $Deployee.params[1]) + $dest_path = $destination.Substring(0, $destination.LastIndexOf('/') + 1) + $script:RuleCmds += "New-Item `'$dest_path`' -ItemType Directory -Force -ErrorAction:SilentlyContinue" + $script:RuleCmds += "Copy-Item `'$source`' `'$destination`' -Force -Recurse -ErrorAction:SilentlyContinue" + break + } + "copy_if" { + $source = $(Resolve-RuleVar $Deployee.params[0]) + $destination = $(Resolve-RuleVar $Deployee.params[1]) + $dest_path = $destination.Substring(0, $destination.LastIndexOf('/') + 1) + $script:RuleCmds += "if (Test-Path `'$source`') {" + $script:RuleCmds += "New-Item `'$dest_path`' -ItemType Directory -Force -ErrorAction:SilentlyContinue" + $script:RuleCmds += "Copy-Item `'$source`' `'$destination`' -Force -Recurse -ErrorAction:SilentlyContinue }" + break + } + "package" { + $source_tree = @() + foreach ($source in $Deployee.params[0..($Deployee.params.Length - 2)]) { + $source_tree += , "`'$(Resolve-RuleVar $source)`'" + } + $script:RuleCmds += "Compress-Archive -Path $($source_tree -join ',') -DestinationPath `'$(Resolve-RuleVar $Deployee.params[-1])`' -Force -ErrorAction:SilentlyContinue" + break + } + "remove" { + foreach ($to_remove in $Deployee.params) { + $script:RuleCmds += "Remove-Item `'$(Resolve-RuleVar $to_remove)`' -Force -Recurse -ErrorAction:SilentlyContinue" + } + break + } + "script" { + foreach ($raw_script in $Deployee.params) { + $script:RuleCmds += $raw_script + } + break + } + default { + break + } + } +} + + +# @@DISTRIBUTE +if ($Mode.ToUpper() -eq 'DISTRIBUTE') { + if ($Version.ToUpper() -eq '-1') { + # update script to every project + Get-ChildItem "$PSScriptRoot/$Path" -Directory -Recurse | Where-Object { + $_.Name -notin @('vcpkg', 'build', '.git', '.vs') -and + (Test-Path "$_/CMakeLists.txt" -PathType Leaf) -and + (Test-Path "$_/vcpkg.json" -PathType Leaf) + } | ForEach-Object { + Write-Host "`tUpdated <$_>" + Robocopy.exe "$PSScriptRoot" "$_" '!Update.ps1' /MT /NJS /NFL /NDL /NJH | Out-Null + } + exit + } + + $Path = Normalize-Path $Path + $RuleVarTbl.config = $Path.Split('/')[-1].ToLower() + + $rules = Get-ChildItem "$($RuleVarTbl.dist)/rules" -File *.json + $rule_timestamp = @( "!update : $((Get-Item $MyInvocation.MyCommand.Path).LastWriteTime.Ticks)" ) + + # generate timestamp & distribution step + foreach ($rule in $rules) { + $rule_timestamp += , "$($rule.BaseName) : $($rule.LastWriteTime.Ticks)" + } + + $regenerate = $true + $timestamp = "$($RuleVarTbl.dist)/rules/$($RuleVarTbl.project_version).timestamp" + Write-Host "`tChecking deploy rules..." + + if (Test-Path "$($RuleVarTbl.dist)/deploy.ps1") { + $rule_timestamp += , "deployer : $((Get-Item "$($RuleVarTbl.dist)/deploy.ps1").LastWriteTime.Ticks)" + } + + if (Test-Path $timestamp) { + $old_timestamp = [IO.File]::ReadAllText($timestamp) + + if ($old_timestamp -eq ($rule_timestamp | Out-String)) { + $regenerate = $false + Write-Host "`t...No changes" + } + else { + Write-Host "`t...Pending changes" + } + } + + # parse all rules + if ($regenerate) { + Write-Host "`tRegenerating deploy rules..." + + foreach ($rule in $rules) { + $deployer = [IO.File]::ReadAllText($rule.FullName) | ConvertFrom-Json + + foreach ($deployee in $deployer) { + if (("config" -in $deployee.PSObject.Properties.Name) -and ($deployee.config -ne $RuleVarTbl.config)) { + continue + } + else { + Resolve-Rules $deployee + } + } + } + + $RuleCmds | Out-File "$($RuleVarTbl.dist)/deploy-$($RuleVarTbl.config.ToLower()).ps1" utf8 + + $rule_timestamp[-1] = "deployer : $((Get-Item "$($RuleVarTbl.dist)/deploy-$($RuleVarTbl.config.ToLower()).ps1").LastWriteTime.Ticks)" + Remove-Item "$($RuleVarTbl.dist)/rules/*.timestamp" -Force -ErrorAction:SilentlyContinue | Out-Null + $rule_timestamp | Out-File $timestamp utf8 + + Write-Host "`t...Ok" + } + + # deploy + Write-Host "`tExecuting deploy rules..." + & "$($RuleVarTbl.dist)/deploy-$($RuleVarTbl.config.ToLower()).ps1" + + Write-Host "`t...Ok" +} diff --git a/Plugin/.clang-format b/Plugin/.clang-format new file mode 100644 index 0000000..13a71ee --- /dev/null +++ b/Plugin/.clang-format @@ -0,0 +1,97 @@ +--- +AccessModifierOffset: -4 +AlignAfterOpenBracket: DontAlign +AlignConsecutiveAssignments: false +AlignConsecutiveBitFields: false +AlignConsecutiveDeclarations: true +AlignConsecutiveMacros: false +AlignEscapedNewlines: Left +AlignOperands: Align +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: Empty +AllowShortCaseLabelsOnASingleLine: false +AllowShortEnumsOnASingleLine: true +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: Yes +BinPackArguments: true +BinPackParameters: true +BitFieldColonSpacing: After +BraceWrapping: + AfterCaseLabel: true + AfterClass: true + AfterControlStatement: false + AfterEnum: true + AfterFunction: true + AfterNamespace: true + AfterStruct: true + AfterUnion: true + AfterExternBlock: true + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyRecord: false + SplitEmptyNamespace: false +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Custom +BreakBeforeTernaryOperators: false +BreakConstructorInitializers: AfterColon +BreakInheritanceList: AfterColon +BreakStringLiterals: true +ColumnLimit: 0 +CompactNamespaces: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: false +DerivePointerAlignment: false +DisableFormat: false +FixNamespaceComments: false +IncludeBlocks: Preserve +IndentCaseBlocks: true +IndentCaseLabels: false +IndentExternBlock: Indent +IndentGotoLabels: false +IndentPPDirectives: AfterHash +IndentWidth: 4 +IndentWrappedFunctionNames: true +KeepEmptyLinesAtTheStartOfBlocks: false +Language: Cpp +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: All +PointerAlignment: Left +ReflowComments: false +SortIncludes: true +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: false +SpacesInCStyleCastParentheses: false +SpacesInConditionalStatement: false +SpacesInContainerLiterals: true +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Latest +TabWidth: 4 +UseTab: AlignWithSpaces +LineEnding: CRLF +PackConstructorInitializers: BinPack diff --git a/Plugin/CMakeLists.txt b/Plugin/CMakeLists.txt new file mode 100644 index 0000000..837320a --- /dev/null +++ b/Plugin/CMakeLists.txt @@ -0,0 +1,132 @@ +cmake_minimum_required(VERSION 3.21) + +# info +project( + BakaScrapHeap + VERSION 3.0.0 + LANGUAGES CXX +) + +# boiler +include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/common.cmake) + +# in-place configuration +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Plugin.h.in + ${CMAKE_CURRENT_BINARY_DIR}/include/Plugin.h + @ONLY +) + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/version.rc + @ONLY +) + +# source files +execute_process(COMMAND powershell -ExecutionPolicy Bypass -File "${CMAKE_CURRENT_SOURCE_DIR}/!update.ps1" "SOURCEGEN" "${PROJECT_VERSION}" "${CMAKE_CURRENT_BINARY_DIR}") +include(${CMAKE_CURRENT_BINARY_DIR}/sourcelist.cmake) +source_group( + TREE ${CMAKE_CURRENT_SOURCE_DIR} + FILES ${SOURCES} +) + +source_group( + TREE ${CMAKE_CURRENT_BINARY_DIR} + FILES ${CMAKE_CURRENT_BINARY_DIR}/include/Plugin.h +) + +# dependencies +find_package(spdlog CONFIG REQUIRED) +find_dependency_path(DKUtil include/DKUtil/Logger.hpp) +find_dependency_path(CommonLibF4/CommonLibF4 include/F4SE/F4SE.h) + +# cmake target +# runtime +add_library( + ${PROJECT_NAME} + SHARED + ${SOURCES} + ${CMAKE_CURRENT_BINARY_DIR}/include/Plugin.h + ${CMAKE_CURRENT_BINARY_DIR}/version.rc + .clang-format + vcpkg.json +) + +# include dir +target_include_directories( + ${PROJECT_NAME} + PRIVATE + ${CMAKE_CURRENT_BINARY_DIR}/include + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${CMAKE_CURRENT_SOURCE_DIR}/src +) + +# linkage +target_link_libraries( + ${PROJECT_NAME} + PRIVATE + DKUtil::DKUtil + CommonLibF4::CommonLibF4 + spdlog::spdlog +) + +# compiler def +if (MSVC) + add_compile_definitions(_UNICODE) + + target_compile_options( + ${PROJECT_NAME} + PRIVATE + /MP + /await + /W0 + /WX + /permissive- + /utf-8 + /Zc:alignedNew + /Zc:auto + /Zc:__cplusplus + /Zc:externC + /Zc:externConstexpr + /Zc:forScope + /Zc:hiddenFriend + /Zc:implicitNoexcept + /Zc:lambda + /Zc:noexceptTypes + /Zc:preprocessor + /Zc:referenceBinding + /Zc:rvalueCast + /Zc:sizedDealloc + /Zc:strictStrings + /Zc:ternary + /Zc:threadSafeInit + /Zc:trigraphs + /Zc:wchar_t + /wd4200 # nonstandard extension used : zero-sized array in struct/union + /FI${CMAKE_CURRENT_SOURCE_DIR}/src/PCH.h + ) +endif() + +# PCH +target_precompile_headers( + ${PROJECT_NAME} + PRIVATE + src/PCH.h +) + +set_property( + TARGET + ${PROJECT_NAME} + PROPERTY VS_USER_PROPS + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/build_stl_modules.props" +) + +# update deployments + add_custom_command( + TARGET + ${PROJECT_NAME} + POST_BUILD + COMMAND powershell -NoProfile -ExecutionPolicy Bypass -File + "${CMAKE_CURRENT_SOURCE_DIR}/!update.ps1" "DISTRIBUTE" "${PROJECT_VERSION}" "${CMAKE_CURRENT_BINARY_DIR}/$(ConfigurationName)" "${PROJECT_NAME}" + ) diff --git a/Plugin/CMakePresets.json b/Plugin/CMakePresets.json new file mode 100644 index 0000000..4333c1a --- /dev/null +++ b/Plugin/CMakePresets.json @@ -0,0 +1,233 @@ +{ + "version": 6, + "cmakeMinimumRequired": { + "major": 3, + "minor": 26, + "patch": 0 + }, + "configurePresets": [ + { + "name": "common", + "hidden": true, + "cacheVariables": { + "CMAKE_CXX_FLAGS": "$env{PROJECT_PLATFORM_FLAGS} $env{PROJECT_TEXT_FLAGS} $env{PROJECT_COMPILER_FLAGS} $penv{CXXFLAGS}", + "F4SE_SUPPORT_XBYAK": "ON", + "USING_VCPKG": true + }, + "vendor": { + "microsoft.com/VisualStudioSettings/CMake/1.0": { + "intelliSenseMode": "windows-msvc-x64", + "enableMicrosoftCodeAnalysis": true, + "enableClangTidyCodeAnalysis": true + } + } + }, + { + "name": "packaging-vcpkg", + "hidden": true, + "cacheVariables": { + "CMAKE_TOOLCHAIN_FILE": { + "type": "STRING", + "value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" + }, + "VCPKG_TARGET_TRIPLET": "x64-windows-static-md" + } + }, + { + "name": "buildtype-debug", + "hidden": true, + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + }, + { + "name": "buildtype-release", + "hidden": true, + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } + }, + { + "name": "x64", + "hidden": true, + "architecture": "x64", + "cacheVariables": { + "CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$:Debug>DLL" + } + }, + { + "name": "generator-msvc", + "hidden": true, + "inherits": "x64", + "generator": "Visual Studio 17 2022" + }, + { + "name": "generator-ninja", + "hidden": true, + "generator": "Ninja" + }, + { + "name": "compiler-msvc", + "hidden": true, + "environment": { + "PROJECT_COMPILER_FLAGS": "/cgthreads8 /diagnostics:caret /fp:contract /fp:except- /guard:cf- /permissive- /Zc:__cplusplus /Zc:enumTypes /Zc:lambda /Zc:preprocessor /Zc:referenceBinding /Zc:rvalueCast /Zc:templateScope /Zc:ternary /Zc:preprocessor /EHsc /MP /W4 /WX /external:anglebrackets /external:W0", + "PROJECT_COMPILER": "msvc" + } + }, + { + "name": "compiler-clang", + "hidden": true, + "cacheVariables": { + "CMAKE_C_COMPILER": "clang", + "CMAKE_CXX_COMPILER": "clang++" + }, + "environment": { + "PROJECT_COMPILER": "clang", + "PROJECT_COMPILER_FLAGS": "-Wno-overloaded-virtual -Wno-delete-non-abstract-non-virtual-dtor -Wno-inconsistent-missing-override -Wno-reinterpret-base-class" + }, + "vendor": { + "microsoft.com/VisualStudioSettings/CMake/1.0": { + "intelliSenseMode": "windows-clang-x64" + } + } + }, + { + "name": "compiler-clang-cl", + "hidden": true, + "inherits": "compiler-clang", + "cacheVariables": { + "CMAKE_C_COMPILER": "clang-cl", + "CMAKE_CXX_COMPILER": "clang-cl" + }, + "environment": { + "CC": "clang-cl", + "CXX": "clang-cl", + "PROJECT_COMPILER_FLAGS": "/permissive- /EHsc /W4 /WX -Wno-overloaded-virtual -Wno-delete-non-abstract-non-virtual-dtor -Wno-inconsistent-missing-override -Wno-reinterpret-base-class -D__cpp_consteval" + } + }, + { + "name": "build-debug-msvc-msvc", + "inherits": [ + "common", + "packaging-vcpkg", + "buildtype-debug", + "generator-msvc", + "compiler-msvc" + ] + }, + { + "name": "build-debug-msvc-ninja", + "inherits": [ + "common", + "packaging-vcpkg", + "buildtype-debug", + "generator-ninja", + "compiler-msvc" + ] + }, + { + "name": "build-debug-clang-cl-msvc", + "toolset": "ClangCL", + "inherits": [ + "common", + "packaging-vcpkg", + "buildtype-debug", + "generator-msvc", + "compiler-clang-cl" + ] + }, + { + "name": "build-debug-clang-cl-ninja", + "inherits": [ + "common", + "packaging-vcpkg", + "buildtype-debug", + "generator-ninja", + "compiler-clang-cl" + ] + }, + { + "name": "build-release-msvc-msvc", + "inherits": [ + "common", + "packaging-vcpkg", + "buildtype-release", + "generator-msvc", + "compiler-msvc" + ] + }, + { + "name": "build-release-msvc-ninja", + "inherits": [ + "common", + "packaging-vcpkg", + "buildtype-release", + "generator-ninja", + "compiler-msvc" + ] + }, + { + "name": "build-release-clang-cl-msvc", + "toolset": "ClangCL", + "inherits": [ + "common", + "packaging-vcpkg", + "buildtype-release", + "generator-msvc", + "compiler-clang-cl" + ] + }, + { + "name": "build-release-clang-cl-ninja", + "inherits": [ + "common", + "packaging-vcpkg", + "buildtype-release", + "generator-ninja", + "compiler-clang-cl" + ] + } + ], + "buildPresets": [ + { + "name": "debug-msvc-ninja", + "configurePreset": "build-debug-msvc-ninja", + "displayName": "1. (Debug) MSVC - Ninja" + }, + { + "name": "release-msvc-ninja", + "configurePreset": "build-release-msvc-ninja", + "displayName": "2. (Release) MSVC - Ninja" + }, + { + "name": "debug-msvc-msvc", + "configurePreset": "build-debug-msvc-msvc", + "displayName": "3. (Debug) MSVC - MSVC" + }, + { + "name": "release-msvc-msvc", + "configurePreset": "build-release-msvc-msvc", + "displayName": "4. (Release) MSVC - MSVC" + }, + { + "name": "debug-clang-cl-ninja", + "configurePreset": "build-debug-clang-cl-ninja", + "displayName": "5. (Debug) Clang - Ninja" + }, + { + "name": "release-clang-cl-ninja", + "configurePreset": "build-release-clang-cl-ninja", + "displayName": "6. (Release) Clang - Ninja" + }, + { + "name": "debug-clang-cl-msvc", + "configurePreset": "build-debug-clang-cl-msvc", + "displayName": "7. (Debug) Clang - MSVC" + }, + { + "name": "release-clang-cl-msvc", + "configurePreset": "build-release-clang-cl-msvc", + "displayName": "8. (Release) Clang - MSVC" + } + ] +} diff --git a/Plugin/cmake/Plugin.h.in b/Plugin/cmake/Plugin.h.in new file mode 100644 index 0000000..d3bc623 --- /dev/null +++ b/Plugin/cmake/Plugin.h.in @@ -0,0 +1,12 @@ +#pragma once + + +namespace Plugin +{ + inline constexpr auto NAME = "@PROJECT_NAME@"sv; + inline constexpr auto AUTHOR = "shad0wshayd3"sv; + inline constexpr auto Version = + @PROJECT_VERSION_MAJOR@u * 10000 + + @PROJECT_VERSION_MINOR@u * 100 + + @PROJECT_VERSION_PATCH@u; +} diff --git a/Plugin/cmake/build_stl_modules.props b/Plugin/cmake/build_stl_modules.props new file mode 100644 index 0000000..a8184de --- /dev/null +++ b/Plugin/cmake/build_stl_modules.props @@ -0,0 +1,8 @@ + + + + + false + + + \ No newline at end of file diff --git a/Plugin/cmake/common.cmake b/Plugin/cmake/common.cmake new file mode 100644 index 0000000..22ece50 --- /dev/null +++ b/Plugin/cmake/common.cmake @@ -0,0 +1,44 @@ +# dependency macros +macro(find_dependency_path DEPENDENCY FILE) + # searches extern for dependencies and if not checks the environment variable + if(NOT ${DEPENDENCY} STREQUAL "") + # Check extern + message( + STATUS + "Searching for ${DEPENDENCY} using file ${FILE}" + ) + find_path("${DEPENDENCY}Path" + ${FILE} + PATHS "${CMAKE_CURRENT_SOURCE_DIR}/../extern/${DEPENDENCY}") + + if("${${DEPENDENCY}Path}" STREQUAL "${DEPENDENCY}Path-NOTFOUND") + # Check path + message( + STATUS + "Getting environment for ${DEPENDENCY}Path: $ENV{${DEPENDENCY}Path}" + ) + set("${DEPENDENCY}Path" "$ENV{${DEPENDENCY}Path}") + endif() + + message( + STATUS + "Found ${DEPENDENCY} in ${${DEPENDENCY}Path}; adding" + ) + add_subdirectory("${${DEPENDENCY}Path}" ${DEPENDENCY}) + endif() +endmacro() + + +# standards & flags +set(CMAKE_CXX_STANDARD 23) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) +set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_DEBUG OFF) +set_property(GLOBAL PROPERTY USE_FOLDERS ON) +set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE FILEPATH "") + + +# out-of-source builds only +if(${PROJECT_SOURCE_DIR} STREQUAL ${PROJECT_BINARY_DIR}) + message(FATAL_ERROR "In-source builds are not allowed.") +endif() diff --git a/cmake/version.rc.in b/Plugin/cmake/version.rc.in similarity index 94% rename from cmake/version.rc.in rename to Plugin/cmake/version.rc.in index efbb756..b285c31 100644 --- a/cmake/version.rc.in +++ b/Plugin/cmake/version.rc.in @@ -20,7 +20,7 @@ BEGIN VALUE "FileDescription", "@PROJECT_NAME@" VALUE "FileVersion", "@PROJECT_VERSION@.0" VALUE "InternalName", "@PROJECT_NAME@" - VALUE "LegalCopyright", "MIT License" + VALUE "LegalCopyright", "GPLv3 License" VALUE "ProductName", "@PROJECT_NAME@" VALUE "ProductVersion", "@PROJECT_VERSION@.0" END diff --git a/Plugin/dist/BakaScrapHeap.ini b/Plugin/dist/BakaScrapHeap.ini new file mode 100644 index 0000000..c48f64b --- /dev/null +++ b/Plugin/dist/BakaScrapHeap.ini @@ -0,0 +1,3 @@ +[General] +# Accepted values are 1 (Vanilla: ~70mb), 2 (Default: ~130mb), 3 (Experimental: ~200mb), 4 (Experimental: ~270mb) +iScrapHeapMult = 2 diff --git a/Plugin/dist/rules/!base.json b/Plugin/dist/rules/!base.json new file mode 100644 index 0000000..34490f7 --- /dev/null +++ b/Plugin/dist/rules/!base.json @@ -0,0 +1,16 @@ +[ + { + "action": "base", + "params": [ + "{target_base}", + "{env:Fallout4Path}\\Data\\F4SE\\Plugins\\" + ] + }, + { + "action": "copy", + "params": [ + "{cmake_output}\\*", + "{dist}\\" + ] + } +] \ No newline at end of file diff --git a/Plugin/dist/rules/bin_copy.json b/Plugin/dist/rules/bin_copy.json new file mode 100644 index 0000000..a78daf1 --- /dev/null +++ b/Plugin/dist/rules/bin_copy.json @@ -0,0 +1,16 @@ +[ + { + "action": "copy", + "params": [ + "{dist}\\*.dll", + "{target_base}" + ] + }, + { + "action": "copy_if", + "params": [ + "{dist}\\*.pdb", + "{target_base}" + ] + } +] \ No newline at end of file diff --git a/Plugin/dist/rules/config_copy.json b/Plugin/dist/rules/config_copy.json new file mode 100644 index 0000000..16e0de0 --- /dev/null +++ b/Plugin/dist/rules/config_copy.json @@ -0,0 +1,23 @@ +[ + { + "action": "copy_if", + "params": [ + "{dist}\\*.ini", + "{target_base}" + ] + }, + { + "action": "copy_if", + "params": [ + "{dist}\\*.toml", + "{target_base}" + ] + }, + { + "action": "copy_if", + "params": [ + "{dist}\\*.json", + "{target_base}" + ] + } +] \ No newline at end of file diff --git a/Plugin/dist/rules/publish_package.json b/Plugin/dist/rules/publish_package.json new file mode 100644 index 0000000..0150c3e --- /dev/null +++ b/Plugin/dist/rules/publish_package.json @@ -0,0 +1,54 @@ +[ + { + "action": "copy", + "params": [ + "{dist}\\*.dll", + "{dist}\\Data\\F4SE\\Plugins\\" + ] + }, + { + "action": "copy_if", + "config": "RelWithDebInfo", + "params": [ + "{dist}\\*.pdb", + "{dist}\\Data\\F4SE\\Plugins\\" + ] + }, + { + "action": "copy_if", + "params": [ + "{dist}\\*.ini", + "{dist}\\Data\\F4SE\\Plugins\\" + ] + }, + { + "action": "copy_if", + "params": [ + "{dist}\\*.toml", + "{dist}\\Data\\F4SE\\Plugins\\" + ] + }, + { + "action": "copy_if", + "params": [ + "{dist}\\*.json", + "{dist}\\Data\\F4SE\\Plugins\\" + ] + }, + { + "action": "package", + "config": "Release", + "params": [ + "{dist}\\Data\\", + "{dist}\\{project_name}.v{project_version}.zip" + ] + }, + { + "action": "package", + "config": "RelWithDebInfo", + "params": [ + "{dist}\\Data\\", + "{dist}\\{project_name}.v{project_version}.zip" + ] + } +] \ No newline at end of file diff --git a/Plugin/src/PCH.h b/Plugin/src/PCH.h new file mode 100644 index 0000000..74fa66a --- /dev/null +++ b/Plugin/src/PCH.h @@ -0,0 +1,136 @@ +#pragma once + +// c +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// cxx +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Clib +#include "F4SE/F4SE.h" +#include "RE/Fallout.h" + +// winnt +#include + +#undef min +#undef max + +using namespace std::literals; + +#define DLLEXPORT extern "C" [[maybe_unused]] __declspec(dllexport) + +// Plugin +#include "Plugin.h" + +// DKUtil +#include "DKUtil/Config.hpp" +#include "DKUtil/Hook.hpp" +#include "DKUtil/Logger.hpp" + +// F4SEPlugin_Version +DLLEXPORT constinit auto F4SEPlugin_Version = []() noexcept { + F4SE::PluginVersionData data{}; + + data.PluginVersion(Plugin::Version); + data.PluginName(Plugin::NAME); + data.AuthorName(Plugin::AUTHOR); + data.UsesAddressLibrary(true); + data.UsesSigScanning(false); + data.IsLayoutDependent(true); + data.HasNoStructUse(false); + data.CompatibleVersions({ F4SE::RUNTIME_LATEST }); + + return data; +}(); diff --git a/Plugin/src/main.cpp b/Plugin/src/main.cpp new file mode 100644 index 0000000..ae70670 --- /dev/null +++ b/Plugin/src/main.cpp @@ -0,0 +1,108 @@ +namespace stl +{ + namespace detail + { + struct asm_patch : + Xbyak::CodeGenerator + { + asm_patch(std::uintptr_t a_dst) + { + Xbyak::Label dst; + + jmp(ptr[rip + dst]); + + L(dst); + dq(a_dst); + } + }; + + static void asm_jump(std::uintptr_t a_from, [[maybe_unused]] std::size_t a_size, std::uintptr_t a_to) + { + asm_patch p{ a_to }; + p.ready(); + assert(p.getSize() <= a_size); + REL::safe_write( + a_from, + std::span{ p.getCode(), p.getSize() }); + } + } + + static void asm_replace(std::uintptr_t a_from, std::size_t a_size, std::uintptr_t a_to) + { + REL::safe_fill(a_from, REL::INT3, a_size); + detail::asm_jump(a_from, a_size, a_to); + } +} + +class Config +{ +public: + class General + { + public: + inline static DKUtil::Alias::Integer iScrapHeapMult{ "iScrapHeapMult", "General" }; + }; + + static void Load() + { + static auto Config = COMPILE_PROXY("BakaScrapHeap.ini"); + Config.Bind(General::iScrapHeapMult, 2); + Config.Load(); + } +}; + +class ScrapHeap +{ +public: + static void Install() + { + static REL::Relocation target{ REL::ID(2228361) }; + stl::asm_replace(target.address(), 0x10, reinterpret_cast(QMaxMemory)); + + switch (*Config::General::iScrapHeapMult) { + case 1: + INFO("ScrapHeap default [0x04000000 (~70mb)]"sv); + break; + case 2: + INFO("ScrapHeap patched [0x08000000 (~130mb)]"sv); + MaxMemory = 0x08000000; + break; + case 3: + INFO("ScrapHeap patched [0x0C000000 (~200mb)]"sv); + MaxMemory = 0x0C000000; + break; + case 4: + INFO("ScrapHeap patched [0x0FF00000 (~270mb)]"sv); + MaxMemory = 0x0FF00000; + break; + default: + INFO("ScrapHeapMult invalid: value must be between 1 and 4, is {:d}."sv, *Config::General::iScrapHeapMult); + break; + } + } + +private: + static std::uint32_t QMaxMemory() + { + return MaxMemory; + } + + inline static std::uint32_t MaxMemory{ 0x04000000 }; +}; + +DLLEXPORT bool F4SEAPI F4SEPlugin_Load(const F4SE::LoadInterface* a_F4SE) +{ +#ifndef NDEBUG + MessageBoxA(NULL, "Loaded. You can now attach the debugger or continue execution.", Plugin::NAME.data(), NULL); +#endif + + F4SE::Init(a_F4SE); + + DKUtil::Logger::Init(Plugin::NAME, std::to_string(Plugin::Version)); + INFO("{} v{} loaded."sv, Plugin::NAME, Plugin::Version); + + Config::Load(); + ScrapHeap::Install(); + + return true; +} diff --git a/vcpkg.json b/Plugin/vcpkg.json similarity index 55% rename from vcpkg.json rename to Plugin/vcpkg.json index 6d6b629..fd75500 100644 --- a/vcpkg.json +++ b/Plugin/vcpkg.json @@ -1,15 +1,14 @@ { "name": "bakascrapheap", - "version-string": "2.2.0", - "description": "F4SE plugin to increase Fallout 4's default ScrapHeap memory allocation using CommonLibF4.", - "homepage": "https://github.com/shad0wshayd3/BakaScrapHeap", - "license": "MIT", + "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json", "dependencies": [ - "autotoml", "boost-stl-interfaces", "fmt", + "nlohmann-json", "rsm-mmio", + "simpleini", "spdlog", + "tomlplusplus", "xbyak" ], "builtin-baseline": "a42af01b72c28a8e1d7b48107b33e4f286a55ef6", diff --git a/build-clang-cl.bat b/build-clang-cl.bat new file mode 100644 index 0000000..03b2c01 --- /dev/null +++ b/build-clang-cl.bat @@ -0,0 +1,4 @@ +echo off +rd /s /q "build" +cmake -B "%~dp0/build" -S "%~dp0/Plugin" --preset=build-release-clang-cl-ninja +cmake --build "%~dp0/build" diff --git a/build-msvc.bat b/build-msvc.bat new file mode 100644 index 0000000..f15a7a6 --- /dev/null +++ b/build-msvc.bat @@ -0,0 +1,4 @@ +echo off +rd /s /q "build" +cmake -B "%~dp0/build" -S "%~dp0/Plugin" --preset=build-release-msvc-msvc +cmake --build "%~dp0/build" diff --git a/cmake/Version.h.in b/cmake/Version.h.in deleted file mode 100644 index 0033cc5..0000000 --- a/cmake/Version.h.in +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -namespace Version -{ - inline constexpr std::size_t MAJOR = @PROJECT_VERSION_MAJOR@; - inline constexpr std::size_t MINOR = @PROJECT_VERSION_MINOR@; - inline constexpr std::size_t PATCH = @PROJECT_VERSION_PATCH@; - inline constexpr auto NAME = "@PROJECT_VERSION@"sv; - inline constexpr auto PROJECT = "@PROJECT_NAME@"sv; -} diff --git a/cmake/ports/autotoml/portfile.cmake b/cmake/ports/autotoml/portfile.cmake deleted file mode 100644 index 894eb39..0000000 --- a/cmake/ports/autotoml/portfile.cmake +++ /dev/null @@ -1,18 +0,0 @@ -vcpkg_from_github( - OUT_SOURCE_PATH SOURCE_PATH - REPO shad0wshayd3/AutoTOML - REF fc0ba2364334503684c4d4dbda6bd10c35dde1fb - SHA512 36e8d2d7f042256723b28865067a7317b4783a419c16c62c02a0b5b4ed1e2256d4ed485a0a921bcd5b74ab74007f6d619e1cf06f63eccf386ea56b7d87785a25 - HEAD_REF master -) - -vcpkg_cmake_configure(SOURCE_PATH ${SOURCE_PATH}) -vcpkg_cmake_install() -vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/AutoTOML) - -file(REMOVE_RECURSE - ${CURRENT_PACKAGES_DIR}/debug - ${CURRENT_PACKAGES_DIR}/lib -) - -file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) \ No newline at end of file diff --git a/cmake/ports/autotoml/vcpkg.json b/cmake/ports/autotoml/vcpkg.json deleted file mode 100644 index b31a0ac..0000000 --- a/cmake/ports/autotoml/vcpkg.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "autotoml", - "version-string": "2021-12-18", - "homepage": "https://github.com/shad0wshayd3/AutoTOML", - "license": "MIT", - "dependencies": [ - "tomlplusplus", - { - "name": "vcpkg-cmake", - "host": true - }, - { - "name": "vcpkg-cmake-config", - "host": true - } - ] -} \ No newline at end of file diff --git a/extern/BethesdaCMakeModules b/extern/BethesdaCMakeModules deleted file mode 160000 index 61a7cb9..0000000 --- a/extern/BethesdaCMakeModules +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 61a7cb934ab04c227e08a0660079f86f6c3f956f diff --git a/extern/CommonLibF4 b/extern/CommonLibF4 index 19d2c88..9da1648 160000 --- a/extern/CommonLibF4 +++ b/extern/CommonLibF4 @@ -1 +1 @@ -Subproject commit 19d2c8899e7d3677dff4204e2eb707155413d8d8 +Subproject commit 9da1648df4c48b3076d6b27d8f653367ea895d6a diff --git a/extern/DKUtil b/extern/DKUtil new file mode 160000 index 0000000..883cd0a --- /dev/null +++ b/extern/DKUtil @@ -0,0 +1 @@ +Subproject commit 883cd0a8e627e08d9964a3ae5f0b15a99d1572b6 diff --git a/make-sln-clang-cl.bat b/make-sln-clang-cl.bat new file mode 100644 index 0000000..fa22ad2 --- /dev/null +++ b/make-sln-clang-cl.bat @@ -0,0 +1,3 @@ +echo off +rd /s /q "build" +cmake -B "%~dp0/build" -S "%~dp0/Plugin" --preset=build-debug-clang-cl-msvc diff --git a/make-sln-msvc.bat b/make-sln-msvc.bat new file mode 100644 index 0000000..1bb9d73 --- /dev/null +++ b/make-sln-msvc.bat @@ -0,0 +1,3 @@ +echo off +rd /s /q "build" +cmake -B "%~dp0/build" -S "%~dp0/Plugin" --preset=build-debug-msvc-msvc diff --git a/res/settings.toml b/res/settings.toml deleted file mode 100644 index 9162c12..0000000 --- a/res/settings.toml +++ /dev/null @@ -1,4 +0,0 @@ -[General] -EnableDebugLogging = false # Enable Debug message output -ScrapHeapMult = 2 # ScrapHeap memory multiplier. - # Accepted values are 1 (Vanilla: ~70mb), 2 (Default: ~130mb), 3 (Experimental: ~200mb), 4 (Experimental: ~270mb) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt deleted file mode 100644 index f3bb5c4..0000000 --- a/src/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_subdirectory(c++) -add_subdirectory(papyrus) diff --git a/src/c++/CMakeLists.txt b/src/c++/CMakeLists.txt deleted file mode 100644 index 86ecc3c..0000000 --- a/src/c++/CMakeLists.txt +++ /dev/null @@ -1,184 +0,0 @@ -set(ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../..) - -# ---- Project ---- - -configure_file( - ${ROOT_DIR}/cmake/Version.h.in - ${CMAKE_CURRENT_BINARY_DIR}/include/Version.h - @ONLY -) - -configure_file( - ${ROOT_DIR}/cmake/version.rc.in - ${CMAKE_CURRENT_BINARY_DIR}/version.rc - @ONLY -) - -# ---- Globals ---- - -add_compile_definitions( - F4SE_SUPPORT_XBYAK -) - -if (MSVC) - if (NOT ${CMAKE_GENERATOR} STREQUAL "Ninja") - add_compile_options( - /MP # Build with Multiple Processes - ) - endif () -endif () - -set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) -set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_DEBUG OFF) - -set(Boost_USE_STATIC_LIBS ON) - -# ---- Dependencies ---- - -if (DEFINED CommonLibPath AND NOT ${CommonLibPath} STREQUAL "" AND IS_DIRECTORY ${CommonLibPath}) - add_subdirectory(${CommonLibPath} ${CommonLibName}) -else () - message( - FATAL_ERROR - "Variable ${CommonLibName}Path is not set or in extern/." - ) -endif() - -# ---- Add source files ---- - -file(GLOB_RECURSE SOURCE_FILES - CONFIGURE_DEPENDS - ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/*.h -) - -source_group( - TREE - ${CMAKE_CURRENT_SOURCE_DIR} - PREFIX - "src" - FILES - ${SOURCE_FILES} -) - -source_group( - TREE - ${CMAKE_CURRENT_BINARY_DIR} - FILES - ${CMAKE_CURRENT_BINARY_DIR}/include/Version.h -) - -# ---- Create DLL ---- - -add_library( - ${PROJECT_NAME} - SHARED - ${SOURCE_FILES} - ${CMAKE_CURRENT_BINARY_DIR}/include/Version.h - ${CMAKE_CURRENT_BINARY_DIR}/version.rc - ${ROOT_DIR}/res/settings.toml - ${ROOT_DIR}/.clang-format - ${ROOT_DIR}/.editorconfig -) - -target_compile_features( - ${PROJECT_NAME} - PRIVATE - cxx_std_23 -) - -target_compile_definitions( - ${PROJECT_NAME} - PRIVATE - _UNICODE -) - -target_include_directories( - ${PROJECT_NAME} - PRIVATE - ${CMAKE_CURRENT_BINARY_DIR}/include - ${CMAKE_CURRENT_SOURCE_DIR} -) - -target_link_libraries( - ${PROJECT_NAME} - PRIVATE - ${CommonLibName}::${CommonLibName} -) - -target_precompile_headers( - ${PROJECT_NAME} - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/PCH.h -) - -if (MSVC) - target_compile_options( - ${PROJECT_NAME} - PRIVATE - /sdl # Enable Additional Security Checks - /utf-8 # Set Source and Executable character sets to UTF-8 - /Zi # Debug Information Format - - /permissive- # Standards conformance - - /Zc:alignedNew # C++17 over-aligned allocation - /Zc:auto # Deduce Variable Type - /Zc:char8_t - /Zc:__cplusplus # Enable updated __cplusplus macro - /Zc:externC - /Zc:externConstexpr # Enable extern constexpr variables - /Zc:forScope # Force Conformance in for Loop Scope - /Zc:hiddenFriend - /Zc:implicitNoexcept # Implicit Exception Specifiers - /Zc:lambda - /Zc:noexceptTypes # C++17 noexcept rules - /Zc:preprocessor # Enable preprocessor conformance mode - /Zc:referenceBinding # Enforce reference binding rules - /Zc:rvalueCast # Enforce type conversion rules - /Zc:sizedDealloc # Enable Global Sized Deallocation Functions - /Zc:strictStrings # Disable string literal type conversion - /Zc:ternary # Enforce conditional operator rules - /Zc:threadSafeInit # Thread-safe Local Static Initialization - /Zc:tlsGuards - /Zc:trigraphs # Trigraphs Substitution - /Zc:wchar_t # wchar_t Is Native Type - - /external:anglebrackets - /external:W0 - - /W4 # Warning level - /WX # Warning level (warnings are errors) - - "$<$:>" - "$<$:/Zc:inline;/JMC-;/Ob3>" - ) - - target_link_options( - ${PROJECT_NAME} - PRIVATE - /WX # Treat Linker Warnings as Errors - - "$<$:/INCREMENTAL;/OPT:NOREF;/OPT:NOICF>" - "$<$:/INCREMENTAL:NO;/OPT:REF;/OPT:ICF;/DEBUG:FULL>" - ) -endif() - -# ---- Post build ---- - -if (COPY_BUILD) - if (DEFINED Fallout4Path) - add_custom_command( - TARGET ${PROJECT_NAME} - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ ${Fallout4Path}/Data/F4SE/Plugins/ - COMMAND ${CMAKE_COMMAND} -E copy $ ${Fallout4Path}/Data/F4SE/Plugins/ - COMMAND ${CMAKE_COMMAND} -E copy ${ROOT_DIR}/res/settings.toml ${Fallout4Path}/Data/F4SE/Plugins/${PROJECT_NAME}.toml - ) - else() - message( - WARNING - "Variable ${Fallout4Path} is not defined. Skipping post-build copy command." - ) - endif() -endif() diff --git a/src/c++/PCH.cpp b/src/c++/PCH.cpp deleted file mode 100644 index 8607860..0000000 --- a/src/c++/PCH.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "PCH.h" - -namespace stl -{ - namespace detail - { - struct asm_patch : - Xbyak::CodeGenerator - { - asm_patch(std::uintptr_t a_dst) - { - Xbyak::Label dst; - - jmp(ptr[rip + dst]); - - L(dst); - dq(a_dst); - } - }; - } - - void asm_jump(std::uintptr_t a_from, [[maybe_unused]] std::size_t a_size, std::uintptr_t a_to) - { - detail::asm_patch p{ a_to }; - p.ready(); - assert(p.getSize() <= a_size); - REL::safe_write( - a_from, - std::span{ p.getCode(), p.getSize() }); - } - - void asm_replace(std::uintptr_t a_from, std::size_t a_size, std::uintptr_t a_to) - { - REL::safe_fill(a_from, REL::INT3, a_size); - asm_jump(a_from, a_size, a_to); - } -} diff --git a/src/c++/PCH.h b/src/c++/PCH.h deleted file mode 100644 index 85da0ad..0000000 --- a/src/c++/PCH.h +++ /dev/null @@ -1,45 +0,0 @@ -#pragma once -#pragma warning(disable : 4702) - -#define WIN32_LEAN_AND_MEAN -#define NOMINMAX - -#include "F4SE/F4SE.h" -#include "RE/Fallout.h" - -#include -#include -#include - -#define DLLEXPORT extern "C" [[maybe_unused]] __declspec(dllexport) - -using namespace std::literals; - -namespace logger = F4SE::log; - -namespace stl -{ - using namespace F4SE::stl; - - void asm_replace(std::uintptr_t a_from, std::size_t a_size, std::uintptr_t a_to); -} - -// clang-format off -#include "Version.h" -#include "Settings.h" -// clang-format on - -DLLEXPORT constinit auto F4SEPlugin_Version = []() noexcept { - F4SE::PluginVersionData data{}; - - data.PluginVersion(Version::MAJOR); - data.PluginName(Version::PROJECT); - // data.AuthorName(); - data.UsesAddressLibrary(true); - data.UsesSigScanning(false); - data.IsLayoutDependent(true); - data.HasNoStructUse(false); - data.CompatibleVersions({ F4SE::RUNTIME_LATEST }); - - return data; -}(); diff --git a/src/c++/Settings.h b/src/c++/Settings.h deleted file mode 100644 index 8b396fe..0000000 --- a/src/c++/Settings.h +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once - -namespace Settings -{ - namespace - { - using bSetting = AutoTOML::bSetting; - using iSetting = AutoTOML::iSetting; - using ISetting = AutoTOML::ISetting; - } - - namespace General - { - inline bSetting EnableDebugLogging{ "General"s, "EnableDebugLogging"s, false }; - inline iSetting ScrapHeapMult{ "General"s, "ScrapHeapMult"s, 1 }; - } - - inline void Load() - { - try - { - const auto table = toml::parse_file( - fmt::format(FMT_STRING("Data/F4SE/Plugins/{:s}.toml"sv), Version::PROJECT)); - for (const auto& setting : ISetting::get_settings()) - { - setting->load(table); - } - } - catch (const toml::parse_error& e) - { - std::ostringstream ss; - ss - << "Error parsing file \'" << *e.source().path << "\':\n" - << '\t' << e.description() << '\n' - << "\t\t(" << e.source().begin << ')'; - logger::error(FMT_STRING("{:s}"sv), ss.str()); - stl::report_and_fail("Failed to load settings."sv); - } - catch (const std::exception& e) - { - stl::report_and_fail(e.what()); - } - catch (...) - { - stl::report_and_fail("Unknown failure."sv); - } - } -} diff --git a/src/c++/main.cpp b/src/c++/main.cpp deleted file mode 100644 index 9aa8626..0000000 --- a/src/c++/main.cpp +++ /dev/null @@ -1,75 +0,0 @@ -namespace -{ - void InitializeLog() - { - auto path = logger::log_directory(); - if (!path) - { - stl::report_and_fail("Failed to find standard logging directory"sv); - } - - *path /= fmt::format(FMT_STRING("{:s}.log"sv), Version::PROJECT); - auto sink = std::make_shared(path->string(), true); - - auto log = std::make_shared("global log"s, std::move(sink)); - auto lvl = *Settings::General::EnableDebugLogging - ? spdlog::level::trace - : spdlog::level::info; - - log->set_level(lvl); - log->flush_on(lvl); - - spdlog::set_default_logger(std::move(log)); - spdlog::set_pattern("[%m/%d/%Y - %T] [%^%l%$] %v"s); - - logger::info(FMT_STRING("{:s} v{:s}"sv), Version::PROJECT, Version::NAME); - } -} - -namespace ScrapHeap -{ - std::uint32_t MaxMemory{ 0x04000000 }; - - std::uint32_t QMaxMemory() - { - return MaxMemory; - } -} - -DLLEXPORT bool F4SEAPI F4SEPlugin_Load(const F4SE::LoadInterface* a_F4SE) -{ - Settings::Load(); - InitializeLog(); - - logger::info(FMT_STRING("{:s} loaded."), Version::PROJECT); - logger::debug("Debug logging enabled."); - - F4SE::Init(a_F4SE); - - REL::Relocation target{ REL::ID(2228361) }; - stl::asm_replace(target.address(), 0x10, reinterpret_cast(ScrapHeap::QMaxMemory)); - - switch (*Settings::General::ScrapHeapMult) - { - case 1: - logger::info("ScrapHeap default [0x04000000 (~70mb)]"sv); - break; - case 2: - logger::info("ScrapHeap patched [0x08000000 (~130mb)]"sv); - ScrapHeap::MaxMemory = 0x08000000; - break; - case 3: - logger::info("ScrapHeap patched [0x0C000000 (~200mb)]"sv); - ScrapHeap::MaxMemory = 0x0C000000; - break; - case 4: - logger::info("ScrapHeap patched [0x0FF00000 (~270mb)]"sv); - ScrapHeap::MaxMemory = 0x0FF00000; - break; - default: - logger::warn(FMT_STRING("ScrapHeapMult invalid: value must be between 1 and 4, is {:d}."), *Settings::General::ScrapHeapMult); - break; - } - - return true; -} diff --git a/src/papyrus/CMakeLists.txt b/src/papyrus/CMakeLists.txt deleted file mode 100644 index f4bf091..0000000 --- a/src/papyrus/CMakeLists.txt +++ /dev/null @@ -1,60 +0,0 @@ -set(ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../..) - -include(${ROOT_DIR}/extern/BethesdaCMakeModules/Modules/Papyrus.cmake) - -file(GLOB Papyrus_INPUT - LIST_DIRECTORIES false - CONFIGURE_DEPENDS - ${CMAKE_CURRENT_SOURCE_DIR}/*.psc -) - -add_papyrus( - "Papyrus" - GAME - ${Fallout4Path} - MODE - "Fallout4" - IMPORTS - ${Fallout4Path}/Data/Scripts/Source/User - ${Fallout4Path}/Data/Scripts/Source/CreationClub - ${Fallout4Path}/Data/Scripts/Source/DLC06 - ${Fallout4Path}/Data/Scripts/Source/DLC05 - ${Fallout4Path}/Data/Scripts/Source/DLC04 - ${Fallout4Path}/Data/Scripts/Source/DLC03 - ${Fallout4Path}/Data/Scripts/Source/DLC02 - ${Fallout4Path}/Data/Scripts/Source/DLC01 - ${Fallout4Path}/Data/Scripts/Source/Base - SOURCES - ${Papyrus_INPUT} -) - -source_group( - "Scripts" - FILES - ${Papyrus_INPUT} -) - -if (COPY_BUILD) - if (DEFINED Fallout4Path) - foreach(FILE IN LISTS Papyrus_INPUT) - add_custom_command( - TARGET "Papyrus" - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy ${FILE} ${Fallout4Path}/Data/Scripts/Source/Baka/ - ) - endforeach() - - foreach(FILE IN LISTS Papyrus_OUTPUT) - add_custom_command( - TARGET "Papyrus" - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy ${FILE} ${Fallout4Path}/Data/Scripts/ - ) - endforeach() - else () - message( - WARNING - "Variable ${Fallout4Path} is not defined. Skipping post-build copy command." - ) - endif() -endif() diff --git a/update-submodule.bat b/update-submodule.bat new file mode 100644 index 0000000..f82cf7a --- /dev/null +++ b/update-submodule.bat @@ -0,0 +1,2 @@ +git submodule update --init --recursive -f +git submodule update --remote -f \ No newline at end of file