Skip to content
This repository was archived by the owner on Jun 22, 2024. It is now read-only.

Commit 7e2fa0c

Browse files
committed
Allow different commands to be run when building
1 parent 24038ec commit 7e2fa0c

File tree

5 files changed

+265
-588
lines changed

5 files changed

+265
-588
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Changelog
22

3+
## 2.4.0
4+
* Bumped internal dependencies to be more reliable on newer vscode versions
5+
* New setting `sde.swiftBuildingParams` allows run other commands than `swift build` #24 jinmingjian/sde#32
6+
7+
### Building Params
8+
It is now possible to run different commands when building swift code.
9+
* `"sde.swiftBuildingParams": ["build"]`: default setting
10+
* `"sde.swiftBuildingParams": ["build", "--build-path", ".vscode-build"]`: build in different directory, see #24
11+
* `"sde.swiftBuildingParams": ["build", "--build-tests"]`: compile tests, but do not run them
12+
* `"sde.swiftBuildingParams": ["test"]`: runs unit tests jinmingjian/sde#32
13+
314
## 2.3.2
415
* Code format did fail #19
516
* Code format always indented by 4 spaces. Now configurable.

package.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@
9999
"default": true,
100100
"description": "Indicates wether SDE shall build the project on save."
101101
},
102+
"sde.swiftBuildingParams": {
103+
"type": "array",
104+
"description": "The params that shall be passed to the swift command.",
105+
"default": ["build"],
106+
"items": {
107+
"type": "string"
108+
}
109+
},
102110
"swift.diagnosis.max_num_problems": {
103111
"type": "number",
104112
"default": 100,
@@ -145,9 +153,9 @@
145153
"postinstall": "node ./node_modules/vscode/bin/install"
146154
},
147155
"devDependencies": {
148-
"@types/bunyan": "latest",
156+
"@types/bunyan": "^1.8.4",
149157
"@types/js-yaml": "^3.11.1",
150-
"@types/node": "latest",
158+
"@types/node": "^10.1.2",
151159
"@types/xml-js": "^1.0.0",
152160
"js-yaml": "^3.11.0",
153161
"mocha": "^2.3.3",

src/SwiftTools.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@ import {
1616

1717
let stdout: string, stderr: string, error: Error;
1818
///managed build now only support to invoke on save
19-
//ignore options
20-
export function buildPackage(swiftBinPath: string, pkgPath: string, options: string) {
19+
export function buildPackage(swiftBinPath: string, pkgPath: string, params: string[]) {
2120
stdout = null
2221
stderr = null
2322
error = null
24-
const sb = cp.spawn(swiftBinPath, ["build"], { cwd: pkgPath });
23+
const sb = cp.spawn(swiftBinPath, params, { cwd: pkgPath });
2524
sb.stdout.on('data', (data) => {
2625
stdout += data
2726
dumpInConsole("" + data)
@@ -59,7 +58,7 @@ function dumpDiagnostics() {
5958
let diags: Array<string[]> = []
6059
const lines = stdout.split("\n")
6160

62-
function isDiagStartLine(line: string) {//FIXME
61+
function isDiagStartLine(line: string) {//FIXME
6362
const sa = line.split(":")
6463
if (sa.length > 4) {
6564
const sev = sa[3].trim();

src/clientMain.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const LENGTH_PKG_FILE_NAME: number = "Package.swift".length
1919
const PUBLISHER_NAME = "jinmingjian.sde"
2020

2121
let swiftBinPath: string | null = null
22+
let swiftBuildParams: string[] = ['build']
2223
let swiftPackageManifestPath: string | null = null
2324
let skProtocolProcess: string | null = null
2425
let skProtocolProcessAsShellCmd: string | null = null
@@ -90,7 +91,8 @@ export function activate(context: ExtensionContext) {
9091
tools.buildPackage(
9192
swiftBinPath,
9293
workspace.rootPath,
93-
null)
94+
swiftBuildParams
95+
)
9496
}
9597
}
9698
//commands
@@ -195,6 +197,7 @@ export function dumpInConsole(msg: string) {
195197

196198
function checkToolsAvailability() {
197199
swiftBinPath = <string>workspace.getConfiguration().get('swift.path.swift_driver_bin')
200+
swiftBuildParams = <string[]>workspace.getConfiguration().get('sde.swiftBuildingParams') || ['build']
198201
const sourcekitePath = <string>workspace.getConfiguration().get('swift.path.sourcekite')
199202
const sourcekitePathEnableShCmd = <string>workspace.getConfiguration().get('swift.path.sourcekiteDockerMode')
200203
const shellPath = <string>workspace.getConfiguration().get('swift.path.shell')

0 commit comments

Comments
 (0)