Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# The CI image (.github/workflows/cibuild.yml) plus a non-root account, which
# the sniper SDK does not ship. Without one, a rootful-docker container writes
# root-owned files into the bind mount. devcontainer.json passes the host
# username, and updateRemoteUserUID rewrites the UID/GID to match at build time.
FROM registry.gitlab.steamos.cloud/steamrt/sniper/sdk:latest

ARG USERNAME=dev
ARG USER_UID=1000
ARG USER_GID=1000

RUN groupadd --gid "${USER_GID}" "${USERNAME}" \
&& useradd --uid "${USER_UID}" --gid "${USER_GID}" -m -s /bin/bash "${USERNAME}" \
&& echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" > "/etc/sudoers.d/${USERNAME}" \
&& chmod 0440 "/etc/sudoers.d/${USERNAME}"
72 changes: 72 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"name": "NT;RE - Steam Runtime 3 (sniper) SDK",
// The CI image (.github/workflows/cibuild.yml) plus a non-root account; see
// the Dockerfile.
"build": {
"dockerfile": "Dockerfile",
"args": {
// Account name only; file ownership comes from updateRemoteUserUID below.
"USERNAME": "${localEnv:USER:dev}"
}
},
// SELinux hosts: without this the bind mount reads as Permission denied.
// Not :Z - that relabels the repo and breaks access from outside.
"runArgs": [
"--security-opt",
"label=disable"
],
// Must match the USERNAME build arg. updateRemoteUserUID rebuilds the image
// with the local UID/GID so bind-mount files stay owned by the host user.
"remoteUser": "${localEnv:USER:dev}",
"updateRemoteUserUID": true,
"postCreateCommand": "bash tools/ntre-dev-setup.sh --editor none",
"remoteEnv": {
"PATH": "${containerWorkspaceFolder}/.ide/bin:${containerEnv:PATH}"
},
"customizations": {
"vscode": {
"extensions": [
"ms-vscode.cmake-tools",
"llvm-vs-code-extensions.vscode-clangd"
],
// Mirrors what tools/ntre-dev-setup.sh writes for non-container users;
// keep in sync. ${workspaceFolder} is VS Code's, not devcontainer.json's.
"settings": {
"cmake.sourceDirectory": "${workspaceFolder}/src",
"cmake.useCMakePresets": "always",
"cmake.configureOnOpen": false,
// Stops the extension downloading its own clangd.
"clangd.path": "${workspaceFolder}/.ide/bin/clangd",
"clangd.checkUpdates": false,
"clangd.onConfigChanged": "restart",
"clangd.arguments": [
// Command-line-only option: reads include paths and predefined
// macros from the compiler that actually builds this tree.
"--query-driver=/usr/bin/g++*,/usr/bin/gcc*,/usr/bin/clang*,/usr/lib/llvm-*/bin/clang*",
"--header-insertion=never",
"--background-index",
"--completion-style=detailed",
"--pch-storage=memory"
],
// clangd provides IntelliSense; stop cpptools double-indexing.
"C_Cpp.intelliSenseEngine": "disabled",
"files.associations": {
"*.h": "cpp",
"*.inc": "cpp"
},
"[cpp]": {
"editor.defaultFormatter": "llvm-vs-code-extensions.vscode-clangd"
},
"files.watcherExclude": {
"**/src/build/**": true,
"**/.cache/**": true,
"**/.ide/**": true
},
"search.exclude": {
"**/src/build/**": true,
"**/.ide/**": true
}
}
}
}
}
4 changes: 2 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
buildallprojects text
vpc binary

*.sh text
# eol=lf: a shell script checked out with CRLF fails to run at all.
*.sh text eol=lf
*.bat text
*.txt text
*.c text
Expand Down
22 changes: 17 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
out

/src/CMakeSettings.json
/src/CMakeUserPresets.json

# Generated by tools/ntre-dev-setup.sh
/.ide/
/.clangd
/compile_commands.json
/.zed/

# Personal devcontainer variants, offered alongside the tracked one
/.devcontainer/local/

# ctest
/src/Testing
Expand Down Expand Up @@ -662,11 +672,6 @@ MigrationBackup/
FodyWeavers.xsd

# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

# Local History for Visual Studio Code
Expand Down Expand Up @@ -699,3 +704,10 @@ FodyWeavers.xsd

# Selected Background
/game/neo/scripts/[Cc]hapter[Bb]ackgrounds.txt

# Share the ntre-dev-setup.sh task entry point; the rest of .vscode stays local.
# Three patterns because *.vscode/ above excludes the directory itself, and git
# cannot re-include a file whose parent directory is excluded.
!/.vscode/
/.vscode/*
!/.vscode/tasks.json
32 changes: 32 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
// The only tracked file under .vscode/ (see the re-include at the end of
// .gitignore); the setup task writes the per-developer settings.json and
// extensions.json.
"version": "2.0.0",
"tasks": [
{
"label": "ntre-dev-setup: Set up VS Code",
"detail": "Installs the pinned clangd, generates the compile database and writes .vscode/settings.json + extensions.json. Linux or macOS shell (WSL on Windows).",
"type": "shell",
"command": "${workspaceFolder}/tools/ntre-dev-setup.sh",
"args": ["--editor", "vscode"],
"problemMatcher": [],
"presentation": {
"reveal": "always",
"panel": "shared"
}
},
{
"label": "ntre-dev-setup: Refresh compile database",
"detail": "Run after adding, removing or renaming sources, or after pulling changes to a CMakeLists.txt.",
"type": "shell",
"command": "${workspaceFolder}/tools/ntre-dev-setup.sh",
"args": ["--reconfigure"],
"problemMatcher": [],
"presentation": {
"reveal": "silent",
"panel": "shared"
}
}
]
}
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,31 @@ $ cmake --build --preset PRESET_NAME

Available PRESET_NAME values: `windows-debug`, `windows-release`, `linux-debug`, `linux-release`.

## Development using Linux

Optional tooling for working on the code, rather than for building it: a dev container definition and a setup script that give you a working C++ IntelliSense index. None of it changes how NT;RE is built. The [Qt Creator](#qt-creator-linux) and [CLI](#cli-with-ninja-windows--linux) workflows above are untouched, and every file the script generates is git-ignored.

### Getting set up

Either entry point is enough:

* **Dev container** - open the repo in an editor that supports [dev containers](https://containers.dev/) (VS Code, the `devcontainer` CLI, JetBrains Gateway) and reopen in the container. It uses the same sniper SDK image as the CI runners and the manual container steps above, and runs the setup script for you on create.
* **Run it yourself** - from inside your own sniper container, or on a native toolchain new enough for C++20:

```bash
$ ./tools/ntre-dev-setup.sh
```

Add `--editor vscode` to also write `.vscode/settings.json` and `extensions.json`; in VS Code, the *"ntre-dev-setup: Set up VS Code"* task does the same. `--editor zed` writes the equivalent `.zed/settings.json`. Run from an editor's own terminal, the default `--editor auto` picks whichever it detects. `--help` lists the rest.

### What it sets up

* A pinned `clangd` under `.ide/`, since distro packages are frequently too old for this tree's C++20. Use `--system-clangd` to keep your own instead, or `source .ide/env.sh` to put the pinned one on `PATH` for editors launched from a shell.
* `compile_commands.json`, symlinked at the repo root where clangd, CLion, Qt Creator and Sublime look for it, alongside a `.clangd` carrying the compile flags that need adjusting for the SteamRT toolchain.
* A `linux-debug-ide` preset in your `src/CMakeUserPresets.json` (per-developer, git-ignored) that generates the database with unity builds off - the header of `tools/ntre-dev-setup.sh` explains why. **Do not build from it** - build with `linux-debug` as documented above.

Re-run `./tools/ntre-dev-setup.sh --reconfigure` after adding, removing or renaming source files, or use the *"ntre-dev-setup: Refresh compile database"* task in VS Code.

## Steam mod setup
To make it appear in Steam, the install files have to appear under the sourcemods directory or
be directed to it.
Expand Down
23 changes: 0 additions & 23 deletions src/.vscode/tasks.json

This file was deleted.

Loading