mirror of
https://github.com/ossrs/srs.git
synced 2025-02-12 11:21:52 +00:00
VSCode: Support IDE vscode to run and debug.
This commit is contained in:
parent
e674f8266a
commit
40e8ed4586
6 changed files with 103 additions and 5 deletions
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -16,8 +16,6 @@
|
|||
*.pyc
|
||||
*.swp
|
||||
.DS_Store
|
||||
.vscode
|
||||
.vscode/*
|
||||
/trunk/Makefile
|
||||
/trunk/objs
|
||||
/trunk/src/build-qt-Desktop-Debug
|
||||
|
@ -42,4 +40,6 @@ cmake-build-debug
|
|||
/trunk/ide/srs_clion/Makefile
|
||||
/trunk/ide/srs_clion/cmake_install.cmake
|
||||
/trunk/ide/srs_clion/srs
|
||||
/trunk/ide/srs_clion/Testing/
|
||||
/trunk/ide/srs_clion/Testing/
|
||||
/trunk/ide/vscode-build
|
||||
|
||||
|
|
38
.vscode/README.md
vendored
Normal file
38
.vscode/README.md
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
# Debug with VSCode
|
||||
|
||||
Support run and debug with VSCode.
|
||||
|
||||
## SRS
|
||||
|
||||
Install the following extensions:
|
||||
|
||||
- CMake Tools
|
||||
- CodeLLDB
|
||||
- C/C++ Extension Pack
|
||||
|
||||
Open the folder like `~/git/srs` in VSCode.
|
||||
Run commmand `> CMake: Configure` to configure the project.
|
||||
|
||||
> Note: You can press `Ctrl+R`, then type `CMake: Configure` then select `Clang` as the toolchain.
|
||||
|
||||
> Note: The `settings.json` is used to configure the cmake. It will use `${workspaceFolder}/trunk/ide/srs_clion/CMakeLists.txt`
|
||||
> and `${workspaceFolder}/trunk/ide/vscode-build` as the source file and build directory.
|
||||
|
||||
Click the `Run > Run Without Debugging` button to start the server.
|
||||
|
||||
> Note: The `launch.json` is used for running and debugging. The build will output the binary to
|
||||
> `${workspaceFolder}/trunk/ide/vscode-build/srs`.
|
||||
|
||||
## Proxy
|
||||
|
||||
Install the following extensions:
|
||||
|
||||
- Go
|
||||
|
||||
Open the folder like `~/git/srs` in VSCode.
|
||||
|
||||
Select the `View > Run` and select `Launch srs-proxy` to start the proxy server.
|
||||
|
||||
Click the `Run > Run Without Debugging` button to start the server.
|
||||
|
||||
> Note: The `launch.json` is used for running and debugging.
|
36
.vscode/launch.json
vendored
Normal file
36
.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Launch SRS",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/trunk/ide/vscode-build/srs",
|
||||
"args": ["-c", "conf/console.conf"],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}/trunk",
|
||||
"environment": [],
|
||||
"externalConsole": false,
|
||||
"MIMode": "lldb",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
],
|
||||
"preLaunchTask": "build",
|
||||
"logging": {
|
||||
"engineLogging": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Launch srs-proxy",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "auto",
|
||||
"cwd": "${workspaceFolder}/proxy",
|
||||
"program": "${workspaceFolder}/proxy"
|
||||
}
|
||||
]
|
||||
}
|
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"cmake.sourceDirectory": "${workspaceFolder}/trunk/ide/srs_clion",
|
||||
"cmake.buildDirectory": "${workspaceFolder}/trunk/ide/vscode-build",
|
||||
"cmake.configureOnOpen": false
|
||||
}
|
17
.vscode/tasks.json
vendored
Normal file
17
.vscode/tasks.json
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "build",
|
||||
"type": "shell",
|
||||
"command": "cmake --build ${workspaceFolder}/trunk/ide/vscode-build",
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"problemMatcher": ["$gcc"],
|
||||
"detail": "Build SRS by cmake."
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@ package main
|
|||
|
||||
import (
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
@ -32,12 +32,14 @@ func loadEnvFile(ctx context.Context) error {
|
|||
}
|
||||
defer file.Close()
|
||||
|
||||
b, err := ioutil.ReadAll(file)
|
||||
b, err := io.ReadAll(file)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "read %v", envFile)
|
||||
}
|
||||
|
||||
lines := strings.Split(strings.Replace(string(b), "\r\n", "\n", -1), "\n")
|
||||
logger.Df(ctx, "load env file %v, lines=%v", envFile, len(lines))
|
||||
|
||||
for _, line := range lines {
|
||||
if strings.HasPrefix(strings.TrimSpace(line), "#") {
|
||||
continue
|
||||
|
|
Loading…
Reference in a new issue