Skip to content

Commit

Permalink
refactor: Move native debugger and set up CI (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
joelday authored Jan 4, 2023
1 parent e9073a8 commit 7fdccea
Show file tree
Hide file tree
Showing 115 changed files with 23,216 additions and 220 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
72 changes: 58 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,45 +12,89 @@ jobs:
CAKE_SETTINGS_ENABLESCRIPTCACHE: true

steps:
- name: git credentials
uses: oleksiyrudenko/gha-git-credentials@v2-latest
with:
token: '${{ secrets.GH_TOKEN }}'
global: true

- name: Checkout
uses: actions/checkout@v3
working-directory: c:/
run: |
git clone --single-branch --branch $("${{ github.ref }}".Replace('refs/heads/', '')) ${{ github.server_url }}/${{ github.repository }}.git repo
- name: Setup vcpkg
working-directory: c:/
run: |
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
bootstrap-vcpkg.bat
vcpkg.exe integrate install
- name: Cache vcpkg packages
uses: actions/cache@v3
with:
fetch-depth: 0
token: ${{ secrets.GH_TOKEN }}
path: c:/repo/vcpkg_installed
key: ${{ runner.os }}-vcpkg-${{ hashFiles('c:/repo/vcpkg.json') }}
restore-keys: |
${{ runner.os }}-vcpkg-
- name: Cache nuget packages
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('src/*/*.csproj') }}
key: ${{ runner.os }}-nuget-${{ hashFiles('c:/repo/src/*/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Cache dotnet tools
uses: actions/cache@v3
with:
path: tools
key: ${{ runner.os }}-dotnet-tools-${{ hashFiles('build.cake', '.config/dotnet-tools.json') }}
path: c:/repo/tools
key: ${{ runner.os }}-dotnet-tools-${{ hashFiles('build.cake', 'c:/repo/.config/dotnet-tools.json') }}
restore-keys: |
${{ runner.os }}-dotnet-tools-
- name: Restore dotnet tools
working-directory: c:/repo
run: |
dotnet tool restore
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
cache-dependency-path: src/papyrus-lang-vscode/package-lock.json

- name: Get npm cache directory
id: npm-cache-dir
shell: pwsh
run: echo "dir=$(npm config get cache)" >> ${env:GITHUB_OUTPUT}

- name: Cache npm packages
uses: actions/cache@v3
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-npm-${{ hashFiles('c:/repo/src/papyrus-lang-vscode/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Setup Nuget.exe
if: success()
uses: nuget/setup-nuget@v1

- name: Install vcpkg packages
working-directory: c:/repo
run: |
../vcpkg/vcpkg.exe install --x-wait-for-lock --triplet x64-windows-static --x-install-root=c:/repo/vcpkg_installed/skyrim --x-feature=skyrim
../vcpkg/vcpkg.exe install --x-wait-for-lock --triplet x64-windows-static --x-install-root=c:/repo/vcpkg_installed/fallout4 --x-feature=fallout4
- name: Build and Publish
if: success()
uses: ecampidoglio/cake-action@v1
with:
target: default
working-directory: c:/repo
run: |
dotnet cake
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
VSCE_PAT: ${{ secrets.VSCE_TOKEN }}
RELEASE: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/prerelease' }}
PRERELEASE: ${{ github.ref == 'refs/heads/prerelease' }}
# TODO: Rename this stuff for clarity once release build artifacts are being created
# TODO: Cleanup workflows for various event types in general
RELEASE: ${{( github.ref == 'refs/heads/main' || github.ref == 'refs/heads/prerelease') && github.event_name != 'pull_request' && github.event_name != 'pull_request_target' }}
PRERELEASE: ${{ github.ref == 'refs/heads/prerelease' && github.event_name != 'pull_request' && github.event_name != 'pull_request_target' }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,5 @@ ASALocalRun/
tools

send.ps1

vcpkg_installed
55 changes: 55 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"configurations": [
{
"name": "Skyrim",
"includePath": [
"${workspaceFolder}/dependencies/MetaStuff/include",
"${workspaceFolder}/dependencies",
"${workspaceFolder}/src/DarkId.Papyrus.DebugServer",
"${workspaceFolder}/vcpkg_installed/skyrim/x64-windows-static/include"
],
"defines": [
"WIN32",
"SKYRIM",
"_DEBUG",
"_WINDOWS",
"_USRDLL",
"DARKID_PAPYRUS_DEBUGSERVER_EXPORTS",
"SKSE_SUPPORT_XBYAK"
],
"forcedInclude": ["pdsPCH.h"],
"windowsSdkVersion": "10.0.18362.0",
"compilerPath": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe",
"cStandard": "c11",
"cppStandard": "c++20",
"intelliSenseMode": "msvc-x64"
},
{
"name": "Fallout",
"includePath": [
"${workspaceFolder}/dependencies/MetaStuff/include",
"${workspaceFolder}/dependencies",
"${workspaceFolder}/src/DarkId.Papyrus.DebugServer",
"${workspaceFolder}/vcpkg_installed/fallout4/x64-windows-static/include"
],
"defines": [
"WIN32",
"FALLOUT",
"_DEBUG",
"_WINDOWS",
"_USRDLL",
"DARKID_PAPYRUS_DEBUGSERVER_EXPORTS",
"F4SE_SUPPORT_XBYAK"
],
"forcedInclude": [
"${workspaceFolder}/src/DarkId.Papyrus.DebugServer/pdsPCH.h"
],
"windowsSdkVersion": "10.0.18362.0",
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.22.27905/bin/Hostx64/x64/cl.exe",
"cStandard": "c11",
"cppStandard": "c++20",
"intelliSenseMode": "windows-msvc-x64"
}
],
"version": 4
}
130 changes: 2 additions & 128 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,129 +1,3 @@
## Table of Contents
## TODO

1. [About the Project](#about-the-project)
1. [Questions and Help](#questions-and-help)
1. [Getting Started](#getting-started)
1. [Modules and Patterns](#modules-and-patterns)
1. [Useful Resources](#useful-resources)

# About the Project

The VSCode extension is written in TypeScript with C# being used for the language server and debug proxy.

Uses the **[Papyrus Debug Adapter](https://github.com/joelday/papyrus-debug-server) xSE plugin** for live debugging.

Also uses [this fork of **Pyro**](https://github.com/rjstone/pyro) for PPJ builds.

# Questions and Help

Do you have questions or need help? Please come visit the....

[![Discord](https://img.shields.io/discord/558746231665328139.svg?color=%23738ADB) Papyrus Language Tools Discord](https://discord.gg/E4dWujQ)

Even if you don't plan to contribute code, it would be good to hear how you are using the extension and get your feedback.

# Getting Started

## Building

First, you will need Windows with the following installed on your system:

- VSCode [Download and install](https://code.visualstudio.com/)
- Node.js [Download and install](https://nodejs.org/)
- Git for Windows [Download and install](https://git-scm.com/download/win)
- One of the following:
- Minimum: .NET Core 2.1 SDK [Download and install](https://dotnet.microsoft.com/download/dotnet-core)
- Recommended: Microsoft Visual Studio 2019 [Download and install](https://visualstudio.microsoft.com/vs/)

Also, building from the shell will be much easier if you use a **Powershell** (powershell.exe) console because the main build script is written in PS, but if you have Visual Studio installed you should be able to build from the solution file.

### 1

First, Fork the `joelday/papyrus-lang` repo on github. Then clone it:

```powershell
git clone https://github.com/<yourusername>/papyrus-lang.git
cd papyrus-lang
```

### 2

Create a branch for your new development:

```powershell
git checkout -b mynewfeature
```

### 3

Set your upstream remote to help you pull changes from main when needed:

```powershell
git remote add upstream https://github.com/joelday/papyrus-lang.git
```

### 4

Make sure your script execution policy allows running unsigned scripts as long as they're already on disk and not executed from the internet:

```powershell
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Get-ExecutionPolicy -List
```

### 5

Run the build script with default targets:

```powershell
.\build.ps1
```

In the same directory, run this to update the bundled third-party packages (which are provided by separate repos):

```powershell
.\build.ps1 -Script build.cake -Target update-debug-plugin
.\build.ps1 -Script build.cake -Target update-pyro-cli
```

### 6

Run VSCode to open the papyrus-lang directory as a folder. If this is still your current directory then just run:

```powershell
code .
```

Hit **Ctrl-Shift-D** to open the Debug panel. At the top select **Launch (Build Extension Only)**.

Hit **F5** to build and launch the extension with debugging. After a little while you will see another VSCode window open. This is the Extension Development Host version of VSCode running the extension that was just built. Any changes you made to the code would be reflected in the debug/test install of the extension running in this window.

### 7

It is not required that you squash your commits before submitting a pull request, so just commit and push your changes to your fork, then submit the pull request for your branch. Please merge from `upstream/master` to your branch before submitting the pull request though to make sure your changes will merge.

```powershell
git merge upstream/main
```

# Modules and Patterns

This is a brief set of links to more info on modules and patterns used in the code.

- [decoration-ioc](https://github.com/joelday/decoration-ioc) is why `InstantiationService` is used to instantiate services and command handlers based on the Service Locator design pattern. It makes it easy to add references to services in the constructor of a class. For example just put `@IExtensionConfigProvider infoProvider: IExtensionConfigProvider` in the argument list of a constructor and it will magically get called with a reference.
- For a simple example of how to add a command, see `src\papyrus-lang-vscode\src\features\commands\ViewAssemblyCommand.ts`
- [rxjs](https://www.npmjs.com/package/rxjs) is used in many places for the reactive Observer/Observable asynchronous pattern.
- [async/await](https://javascript.info/async-await) is used frequently. If possible try to use async functions and `await` on them because this allows other things to happen while a function is blocked on IO etc.
- [deepmerge](https://www.npmjs.com/package/deepmerge) is used in some places.
- Otherwise most of the code is similar to other vscode extensions.

# Useful Resources

- See the [Project Wiki](https://github.com/joelday/papyrus-lang/wiki)
- [The Typescript Programming Language Documentation](https://www.typescriptlang.org/docs/home.html)
- [VSCode Extension Anatomy](https://code.visualstudio.com/api/get-started/extension-anatomy)
- [VSCode Extension Samples](https://github.com/microsoft/vscode-extension-samples) are useful for learning specific APIs
- [Learn RxJS](https://www.learnrxjs.io/) (Reactive eXtensions for Javascript)
- [JavaScript Promises](https://javascript.info/async)
- The [Pro Git](https://git-scm.com/book/en/v2/) book
- The [Contributing](https://github.com/joelday/papyrus-lang/wiki/Contributing) wiki page
Removing for now since the previous version was very out of date.
37 changes: 37 additions & 0 deletions DarkId.Papyrus.DebugServer.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33110.190
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DarkId.Papyrus.DebugServer.Skyrim", "src\DarkId.Papyrus.DebugServer\DarkId.Papyrus.DebugServer.Skyrim.vcxproj", "{9F44D62A-8A45-4FD3-8142-22A229A8A2F4}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DarkId.Papyrus.DebugServer.Fallout4", "src\DarkId.Papyrus.DebugServer\DarkId.Papyrus.DebugServer.Fallout4.vcxproj", "{69BB4564-BAE0-4D6B-9D36-752C987B1FA6}"
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
{9F44D62A-8A45-4FD3-8142-22A229A8A2F4}.Debug|x64.ActiveCfg = Debug|x64
{9F44D62A-8A45-4FD3-8142-22A229A8A2F4}.Debug|x64.Build.0 = Debug|x64
{9F44D62A-8A45-4FD3-8142-22A229A8A2F4}.Debug|x86.ActiveCfg = Debug|x64
{9F44D62A-8A45-4FD3-8142-22A229A8A2F4}.Release|x64.ActiveCfg = Release|x64
{9F44D62A-8A45-4FD3-8142-22A229A8A2F4}.Release|x64.Build.0 = Release|x64
{9F44D62A-8A45-4FD3-8142-22A229A8A2F4}.Release|x86.ActiveCfg = Release|x64
{69BB4564-BAE0-4D6B-9D36-752C987B1FA6}.Debug|x64.ActiveCfg = Debug|x64
{69BB4564-BAE0-4D6B-9D36-752C987B1FA6}.Debug|x64.Build.0 = Debug|x64
{69BB4564-BAE0-4D6B-9D36-752C987B1FA6}.Debug|x86.ActiveCfg = Debug|x64
{69BB4564-BAE0-4D6B-9D36-752C987B1FA6}.Release|x64.ActiveCfg = Release|x64
{69BB4564-BAE0-4D6B-9D36-752C987B1FA6}.Release|x64.Build.0 = Release|x64
{69BB4564-BAE0-4D6B-9D36-752C987B1FA6}.Release|x86.ActiveCfg = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {10021B3F-6663-4F4D-879E-FB9365290403}
EndGlobalSection
EndGlobal
Loading

0 comments on commit 7fdccea

Please sign in to comment.