Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
104 changes: 65 additions & 39 deletions api/csolution-openapi.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
openapi: 3.1.0
info:
title: csolution rpc
version: 0.0.1
version: 0.0.2
description: Specification of remote procedure call methods for CMSIS csolution integration
license:
name: Apache 2.0
Expand Down Expand Up @@ -43,6 +43,17 @@ paths:
'200':
description: OK
content: {application/json: {schema: {$ref: '#/components/schemas/ApplyResponse'}}}
/rpc/Resolve:
post:
summary: Resolve trivial component dependencies
description: Resolve trivial component dependencies for the given context
tags: [/rpc]
requestBody:
content: {application/json: {schema: {$ref: '#/components/schemas/ResolveRequest'}}}
responses:
'200':
description: OK
content: {application/json: {schema: {$ref: '#/components/schemas/ResolveResponse'}}}
/rpc/LoadPacks:
post:
summary: Load installed and local packs
Expand Down Expand Up @@ -120,17 +131,6 @@ paths:
'200':
description: OK
content: {application/json: {schema: {$ref: '#/components/schemas/SelectVariantResponse'}}}
/rpc/SelectVersion:
post:
summary: Select version
description: Select version
tags: [/rpc]
requestBody:
content: {application/json: {schema: {$ref: '#/components/schemas/SelectVersionRequest'}}}
responses:
'200':
description: OK
content: {application/json: {schema: {$ref: '#/components/schemas/SelectVersionResponse'}}}
/rpc/SelectBundle:
post:
summary: Select bundle
Expand Down Expand Up @@ -221,12 +221,27 @@ components:
description: Maximum of supported component instances
required:
- pack
Options:
type: object
properties:
version:
type: string
description: 'Version requirement in SemVer syntax: https://open-cmsis-pack.github.io/cmsis-toolbox/YML-Input-Format/#name-conventions'
fixedVendor:
type: boolean
description: Flag to prefix component ID with vendor when adding component to project or layer
enforced:
type: boolean
description: Flag to enforce exact component vendor, version, condition and originating pack
CtItem:
type: object
properties:
name:
type: string
description: Name of element
result:
type: string
description: 'Condition result: https://github.com/Open-CMSIS-Pack/devtools/blob/tools/projmgr/2.8.0/libs/rtemodel/include/RteItem.h#L78-L95'
required:
- name
ComponentInstance:
Expand All @@ -242,7 +257,9 @@ components:
$ref: '#/components/schemas/Component'
layer:
type: string
description: Layer
description: Absolute path to layer file
options:
$ref: '#/components/schemas/Options'
required:
- id
- selectedCount
Expand Down Expand Up @@ -282,6 +299,8 @@ components:
layer:
type: string
description: Layer
options:
$ref: '#/components/schemas/Options'
required:
- id
- variants
Expand Down Expand Up @@ -470,6 +489,27 @@ components:
- properties:
result:
type: boolean
ResolveRequest:
allOf:
- $ref: '#/x-jsonrpc-envelope-request-with-params'
- properties:
method:
type: string
const: Resolve
params:
type: object
properties:
context:
type: string
required:
- context
ResolveResponse:
allOf:
- $ref: '#/x-jsonrpc-envelope-response'
- properties:
result:
type: boolean
description: true if all dependencies are resolved
LoadPacksRequest:
allOf:
- $ref: '#/x-jsonrpc-envelope-request'
Expand All @@ -483,6 +523,7 @@ components:
- properties:
result:
type: boolean
description: installed packs are loaded successfully
LoadSolutionRequest:
allOf:
- $ref: '#/x-jsonrpc-envelope-request-with-params'
Expand All @@ -503,6 +544,7 @@ components:
- properties:
result:
type: boolean
description: Solution is loaded successfully
GetPacksInfoRequest:
allOf:
- $ref: '#/x-jsonrpc-envelope-request-with-params'
Expand Down Expand Up @@ -580,8 +622,14 @@ components:
type: string
id:
type: string
description: component aggregate ID
count:
type: integer
description: number of instances to select, 0 to select unselect
options:
$ref: '#/components/schemas/Options'
layer:
type: string
required:
- context
- id
Comment thread
edriouk marked this conversation as resolved.
Expand All @@ -592,6 +640,7 @@ components:
- properties:
result:
type: boolean
description: true if selection is changed
SelectVariantRequest:
allOf:
- $ref: '#/x-jsonrpc-envelope-request-with-params'
Expand All @@ -606,6 +655,7 @@ components:
type: string
id:
type: string
description: component aggregate ID
variant:
type: string
required:
Expand All @@ -618,32 +668,7 @@ components:
- properties:
result:
type: boolean
SelectVersionRequest:
allOf:
- $ref: '#/x-jsonrpc-envelope-request-with-params'
- properties:
method:
type: string
const: SelectVersion
params:
type: object
properties:
context:
type: string
id:
type: string
version:
type: string
required:
- context
- id
- version
SelectVersionResponse:
allOf:
- $ref: '#/x-jsonrpc-envelope-response'
- properties:
result:
type: boolean
description: true if selection is changed
SelectBundleRequest:
allOf:
- $ref: '#/x-jsonrpc-envelope-request-with-params'
Expand All @@ -670,6 +695,7 @@ components:
- properties:
result:
type: boolean
description: true if selection is changed
ValidateComponentsRequest:
allOf:
- $ref: '#/x-jsonrpc-envelope-request-with-params'
Expand Down
3 changes: 2 additions & 1 deletion bridge/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"preLaunchTask": "tsc: build - tsconfig.json",
"outFiles": [
"${workspaceFolder}/**/*.js"
]
],
"envFile": "${workspaceFolder}/.env"
}
]
}
24 changes: 23 additions & 1 deletion bridge/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,35 @@
import { ChildProcess, spawn } from "node:child_process";
import express from 'express';
import cors from 'cors';
import path from "node:path";

let child: ChildProcess|undefined;
const app = express();
const port = 3000;

function launch(): boolean {
child = spawn('csolution', ['rpc'], { cwd: './' });


// Determine platform specifics
const isWindows = process.platform === 'win32';
const binaryName = isWindows ? 'csolution.exe' : 'csolution';

let csolutionBinPath = undefined;
// Override with environment variable if available
if (process.env.CSOLUTION_PATH) {
console.log('Found CSOLUTION_PATH in environment:', process.env.CSOLUTION_PATH);
csolutionBinPath = process.env.CSOLUTION_PATH;
}

// Resolve the final path to the executable
const csolutionBin = csolutionBinPath ? path.resolve(csolutionBinPath, binaryName) : binaryName;
console.log('Running csolution:', csolutionBin);

const csolutionArgs = process.env.CSOLUTION_ARGS ?? '';
const args = csolutionArgs.split(',').map(s => s.trim());
child = spawn(csolutionBin, ['rpc', ...args], // append extra args from env
{ cwd: './' }
);

child.on('error', (err) => {
console.error(err.message);
Expand Down
5 changes: 4 additions & 1 deletion codegen/src/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ using namespace jsonrpccxx;\n`;
public getType(name: string, item: any, suffix?: string, prefix?: string) : { cpp: string, ts: string } {
let cppType = '';
let tsType = '';
if(!item) {
return { cpp: cppType, ts: tsType };
}
if (item.$ref) {
const ref = item.$ref.match(/^#\/components\/schemas\/(.*)/);
tsType = ref ? ref[1] : '';
Expand Down Expand Up @@ -264,7 +267,7 @@ using namespace jsonrpccxx;\n`;
const cppParams: string[] = [];
const cppRegParams: string[] = [];
for (const [param, item] of Object.entries(params.properties)) {
cppParams.push(`const ${this.getType(name, item).cpp}& ${param}`);
cppParams.push(`const ${this.getType(name, item, '', 'RpcArgs::').cpp}& ${param}`);
cppRegParams.push(`"${param}"`);
}
cppFunction += cppParams.join(", ");
Expand Down
15 changes: 15 additions & 0 deletions examples/vscode-extension-client/src/rpc-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,21 @@ export interface Component extends Common {
implements?: string,
maxInstances?: number,
}
export interface Options {
version?: string,
fixedVendor?: boolean,
enforced?: boolean,
}
export interface CtItem {
name: string,
result?: string,
}
export interface ComponentInstance {
id: string,
selectedCount: number,
resolvedComponent?: Component,
layer?: string,
options?: Options,
}
export interface CtVariant extends CtItem {
components: Component[],
Expand All @@ -43,6 +50,7 @@ export interface CtAggregate extends CtItem {
selectedCount?: number,
variants: CtVariant[],
layer?: string,
options?: Options,
}
export interface CtTreeItem extends CtItem {
cgroups?: CtGroup[],
Expand Down Expand Up @@ -91,6 +99,9 @@ export interface LogMessages {
export interface ApplyParams {
context: string,
}
export interface ResolveParams {
context: string,
}
export interface LoadSolutionParams {
solution: string,
}
Expand Down Expand Up @@ -132,6 +143,7 @@ export interface RpcInterface {
getVersion(): Promise<string>;
shutdown(): Promise<boolean>;
apply(args: ApplyParams): Promise<boolean>;
resolve(args: ResolveParams): Promise<boolean>;
loadPacks(): Promise<boolean>;
loadSolution(args: LoadSolutionParams): Promise<boolean>;
getPacksInfo(args: GetPacksInfoParams): Promise<PacksInfo>;
Expand All @@ -158,6 +170,9 @@ export abstract class RpcMethods implements RpcInterface {
public async apply(args: ApplyParams): Promise<boolean> {
return this.get('Apply', args);
}
public async resolve(args: ResolveParams): Promise<boolean> {
return this.get('Resolve', args);
}
public async loadPacks(): Promise<boolean> {
return this.get('LoadPacks');
}
Expand Down