Подготовить автономную сборку и запуск перед разделением проектов
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Sprinter C Compiler contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -30,7 +30,7 @@ function projectForLaunch(configuration, workspace) {
|
||||
|
||||
function isSprinterMakefile(filename) {
|
||||
try {
|
||||
return /include\s+\$\(PROJ_ROOT\)\/app\.mk/.test(
|
||||
return /include\s+(?:\$\((?:PROJ_ROOT|SPRINTER_ROOT)\)\/app\.mk|\$\(CURDIR\)\/(?:\.\.\/){0,2}sdk\.mk)/.test(
|
||||
fs.readFileSync(filename, 'utf8'));
|
||||
} catch (_) {
|
||||
return false;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const path = require('path');
|
||||
const vscode = require('vscode');
|
||||
const {resolvePython, pyenvEnvironment} = require('./runtime');
|
||||
const {resolvePython, pyenvEnvironment, resolveSdkRoot} = require('./runtime');
|
||||
const {projectForLaunch, isSprinterMakefile, taskLabel, makeCommand} =
|
||||
require('./build');
|
||||
|
||||
@@ -13,10 +13,9 @@ class SprinterAdapterFactory {
|
||||
const settings = vscode.workspace.getConfiguration('sprinterDebugger');
|
||||
const folder = session.workspaceFolder || vscode.workspace.workspaceFolders?.[0];
|
||||
const configured = session.configuration.adapterPath;
|
||||
if (!configured && !folder) {
|
||||
throw new Error('Откройте workspace C-Compiler или задайте adapterPath');
|
||||
}
|
||||
const adapter = configured || path.join(folder.uri.fsPath, 'toolchain', 'sdbg_dap.py');
|
||||
const sdk = configured ? null : resolveSdkRoot(
|
||||
settings.get('sdkRoot'), folder?.uri.fsPath);
|
||||
const adapter = configured || path.join(sdk, 'toolchain', 'sdbg_dap.py');
|
||||
const runtime = resolvePython({
|
||||
command: settings.get('pythonCommand', 'auto'),
|
||||
args: settings.get('pythonArguments', []),
|
||||
@@ -45,8 +44,10 @@ class SprinterTaskProvider {
|
||||
const definition = definitionOverride ||
|
||||
{type: 'sprinter', project: relative || '.'};
|
||||
const options = {cwd: project};
|
||||
const env = pyenvEnvironment(runtime.command, project) ||
|
||||
pyenvEnvironment(runtime.command, folder.uri.fsPath);
|
||||
const sdk = resolveSdkRoot(settings.get('sdkRoot'), folder.uri.fsPath);
|
||||
const env = {SPRINTER_ROOT: sdk, ...(
|
||||
pyenvEnvironment(runtime.command, project) ||
|
||||
pyenvEnvironment(runtime.command, folder.uri.fsPath) || {})};
|
||||
if (env) options.env = env;
|
||||
const task = new vscode.Task(
|
||||
definition, folder, taskLabel(project, folder.uri.fsPath), 'sprinter',
|
||||
@@ -134,6 +135,9 @@ class SprinterConfigurationProvider {
|
||||
const workspace = folder?.uri.fsPath ||
|
||||
vscode.workspace.workspaceFolders?.[0]?.uri.fsPath;
|
||||
if (!workspace) return configuration;
|
||||
const mameHome = vscode.workspace.getConfiguration('sprinterDebugger')
|
||||
.get('mameHome');
|
||||
if (!configuration.mameHome && mameHome) configuration.mameHome = mameHome;
|
||||
try {
|
||||
const project = projectForLaunch(configuration, workspace);
|
||||
if (project && isSprinterMakefile(path.join(project, 'Makefile'))) {
|
||||
|
||||
@@ -52,6 +52,16 @@
|
||||
"items": {"type": "string"},
|
||||
"default": [],
|
||||
"description": "Аргументы пользовательской Python-команды перед путём DAP-адаптера"
|
||||
},
|
||||
"sprinterDebugger.sdkRoot": {
|
||||
"type": "string",
|
||||
"default": "",
|
||||
"description": "Путь к Sprinter-CC для внешнего проекта; можно задать SPRINTER_ROOT"
|
||||
},
|
||||
"sprinterDebugger.mameHome": {
|
||||
"type": "string",
|
||||
"default": "",
|
||||
"description": "Подготовленная среда MAME для launch, если не указана в launch.json"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -84,7 +94,32 @@
|
||||
},
|
||||
"mame": {
|
||||
"type": "string",
|
||||
"description": "Путь к mame.arm"
|
||||
"description": "Совместимый alias пути к mame.arm"
|
||||
},
|
||||
"mameHome": {
|
||||
"type": "string",
|
||||
"description": "Среда MAME: стандартные пути к бинарнику, ROM и DSS"
|
||||
},
|
||||
"mameBin": {
|
||||
"type": "string",
|
||||
"description": "Переопределить бинарник MAME (stock или sdbg)"
|
||||
},
|
||||
"mameRompath": {
|
||||
"type": "string",
|
||||
"description": "Переопределить каталог ROM/BIOS MAME"
|
||||
},
|
||||
"mameDssImage": {
|
||||
"type": "string",
|
||||
"description": "Переопределить образ DSS-дискеты"
|
||||
},
|
||||
"mameSystemHddImage": {
|
||||
"type": "string",
|
||||
"description": "Переопределить системный HDD-образ Sprinter"
|
||||
},
|
||||
"mameBios": {
|
||||
"type": "string",
|
||||
"default": "v3.06",
|
||||
"description": "Имя варианта BIOS для -bios"
|
||||
},
|
||||
"debugger": {
|
||||
"type": "string",
|
||||
@@ -166,5 +201,5 @@
|
||||
"check": "node --check extension.js && node --check build.js && node --test runtime.test.js build.test.js extension.test.js"
|
||||
},
|
||||
"files": ["extension.js", "runtime.js", "build.js", "README.md"],
|
||||
"license": "BSD-3-Clause"
|
||||
"license": "MIT"
|
||||
}
|
||||
|
||||
@@ -80,5 +80,18 @@ function pyenvEnvironment(command, workspace, home = os.homedir()) {
|
||||
return version ? {PYENV_VERSION: version} : undefined;
|
||||
}
|
||||
|
||||
function resolveSdkRoot(configured, workspace, environment = process.env) {
|
||||
const candidates = [configured, environment.SPRINTER_ROOT, workspace]
|
||||
.filter(Boolean).map(value => path.resolve(value));
|
||||
const found = candidates.find(root =>
|
||||
fs.existsSync(path.join(root, 'toolchain', 'sdbg_dap.py')) &&
|
||||
fs.existsSync(path.join(root, 'bin', 'sprinter-cc')));
|
||||
if (!found) {
|
||||
throw new Error('Не найден Sprinter-CC: задайте sprinterDebugger.sdkRoot ' +
|
||||
'или SPRINTER_ROOT');
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
module.exports = {resolvePython, localPythonVersion, installedPyenvPythons,
|
||||
pyenvEnvironment};
|
||||
pyenvEnvironment, resolveSdkRoot};
|
||||
|
||||
Reference in New Issue
Block a user