Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
soicode
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Timon Stampfli
soicode
Commits
8e043bcd
Commit
8e043bcd
authored
Nov 05, 2020
by
Timon Stampfli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improved log messages
parent
baf594c0
Pipeline
#5675
passed with stages
in 41 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
165 additions
and
98 deletions
+165
-98
src/extension.ts
src/extension.ts
+1
-1
src/helperBinary.ts
src/helperBinary.ts
+10
-14
src/helperBinaryResultReceiver.ts
src/helperBinaryResultReceiver.ts
+3
-3
src/runner.ts
src/runner.ts
+142
-77
src/store.ts
src/store.ts
+9
-3
No files found.
src/extension.ts
View file @
8e043bcd
...
...
@@ -125,7 +125,7 @@ export async function activate(context: vscode.ExtensionContext) {
// await downloadHelperBinary(store);
await
downloadCompilerBundle
(
store
);
console
.
log
(
"
SOICode has been loaded
"
);
store
.
logInfo
(
"
soicode extension
"
,
"
SOICode has been loaded
"
);
}
async
function
debugSolutionOnSample
()
{
...
...
src/helperBinary.ts
View file @
8e043bcd
...
...
@@ -15,7 +15,10 @@ export function getHelperPath(store: Store): string {
export
async
function
downloadCompilerBundle
(
store
:
Store
)
{
return
new
Promise
(
async
resolve
=>
{
let
platform
=
determinePlatform
();
console
.
log
(
"
Fetching Helper binary for platform
"
+
platform
);
store
.
logInfo
(
"
Download Compiler Bundle
"
,
"
Fetching Helper binary for platform
"
+
platform
);
let
flavor
=
"
soiheaders
"
;
let
url
=
`
https://blob.dolansoft.org/soicode/compilerbundle-
${
platform
}
-
${
flavor
}
.tar.xz
`
;
let
targetDir
=
path
.
join
(
store
.
soicodeExtensionDataPath
,
"
bundle
"
,
flavor
);
...
...
@@ -31,21 +34,14 @@ export async function downloadCompilerBundle(store: Store) {
stdout
+=
chunk
;
});
proc
.
on
(
"
exit
"
,
(
code
,
signal
)
=>
{
console
.
log
(
"
fetching the compilerbundle finished, errorcode:
"
+
code
+
"
stdout:
"
+
stdout
);
const
msg
=
`
fetching the compilerbundle finished, errorcode:
${
code
}
stdout: '
${
stdout
}
'
`
;
console
.
log
(
msg
);
store
.
logInfo
(
"
Download Compiler Bundle
"
,
msg
);
if
(
code
!==
0
)
{
vscode
.
window
.
showErrorMessage
(
"
Error fetching the compilerbundle, errorcode:
"
+
code
+
"
stdout:
"
+
stdout
);
const
msg
=
`
Error fetching the compilerbundle, errorcode:
${
code
}
stdout: '
${
stdout
}
'
`
;
vscode
.
window
.
showErrorMessage
(
msg
);
}
resolve
();
});
resolve
();
});
}
src/helperBinaryResultReceiver.ts
View file @
8e043bcd
...
...
@@ -77,9 +77,9 @@ export class HelperBinaryResultReceiver {
let
parsed
=
checkServerResponseTyped
(
JSON
.
parse
(
res
));
if
(
parsed
===
null
)
{
this
.
store
.
handleError
(
"
Downloading dependencies
"
,
"
Downloaded a invalid compiler bundle
"
,
Error
(
"
invalid
package
received
"
)
"
run task result handler
"
,
"
got unparsable result when executing a task
"
,
Error
(
"
invalid
result
received
"
)
);
}
let
[
binarypath
,
samplename
,
result
]
=
parsed
;
...
...
src/runner.ts
View file @
8e043bcd
...
...
@@ -20,6 +20,21 @@ import {
}
from
"
./storeHelper
"
;
import
{
selectSample
}
from
"
./sample
"
;
class
Timer
extends
vscode
.
Disposable
{
timer
:
Promise
<
{}
>
;
timeout
?:
NodeJS
.
Timeout
;
constructor
(
ms
:
number
)
{
super
(()
=>
{
if
(
this
.
timeout
!==
undefined
)
{
clearTimeout
(
this
.
timeout
);
}
});
this
.
timer
=
new
Promise
(
resolve
=>
{
this
.
timeout
=
setTimeout
(
resolve
,
ms
);
});
}
}
export
class
Runner
{
store
:
Store
;
port
:
Number
;
...
...
@@ -30,92 +45,121 @@ export class Runner {
}
async
compile
(
this
:
Runner
,
taskname
:
string
):
Promise
<
"
Success
"
|
"
Failed
"
>
{
return
new
Promise
(
async
resolve
=>
{
le
t
workspace
=
getWorkspaceOrShowError
(
this
.
store
).
workspaceDir
;
le
t
soitaskFiles
=
getSoitaskFilesOfFulltaskOrError
(
this
.
store
,
taskname
);
this
.
store
.
logInfo
(
"
compiler
"
,
`
starting the compilation of
${
taskname
}
`
);
cons
t
workspace
=
getWorkspaceOrShowError
(
this
.
store
).
workspaceDir
;
cons
t
soitaskFiles
=
getSoitaskFilesOfFulltaskOrError
(
this
.
store
,
taskname
);
le
t
compilerPath
=
getCompilerPath
(
this
.
store
);
cons
t
compilerPath
=
getCompilerPath
(
this
.
store
);
try
{
await
fs
.
readFile
(
compilerPath
);
}
catch
(
err
)
{
vscode
.
window
.
showErrorMessage
(
"
Compiler executable not found at expected path
"
let
finished
:
vscode
.
Disposable
[]
=
[];
let
timer
=
new
Timer
(
10000
);
finished
.
push
(
timer
);
const
cleanup
=
()
=>
{
for
(
let
d
of
finished
)
{
d
.
dispose
();
}
};
try
{
await
fs
.
readFile
(
compilerPath
);
}
catch
(
err
)
{
vscode
.
window
.
showErrorMessage
(
"
Compiler executable not found at expected path
"
);
this
.
store
.
logError
(
"
compilation
"
,
`
file at compilerpath '
${
compilerPath
}
' not found
`
,
err
);
cleanup
();
return
"
Failed
"
;
}
try
{
await
fs
.
unlink
(
soitaskFiles
.
binaryFsPath
);
}
catch
(
err
)
{
if
(
err
.
code
===
"
ENOENT
"
)
{
this
.
store
.
logInfo
(
"
compilation
"
,
`
compiled binary '
${
soitaskFiles
.
binaryFsPath
}
' not found
`
,
err
);
this
.
store
.
logError
(
}
else
{
cleanup
();
this
.
store
.
handleError
(
"
compilation
"
,
`
file at compilerpath '
${
compilerPath
}
' not foun
d
`
,
`
deleting binary '
${
soitaskFiles
.
binaryFsPath
}
' faile
d
`
,
err
);
resolve
(
"
Failed
"
);
}
let
compileTaskDefinition
=
{
label
:
"
build
"
+
taskname
+
"
development
"
,
// "command": "clang++",
// "args": ,
type
:
"
process
"
,
group
:
{
kind
:
"
build
"
,
isDefault
:
true
}
};
let
headerAsFlag
=
(
path
:
string
)
=>
(
path
===
""
?
[]
:
[
"
-I
"
,
path
]);
// Todo: allow customizable flags
let
execute
=
new
vscode
.
ProcessExecution
(
compilerPath
,
[
soitaskFiles
.
solutionWorkspacePath
!
,
...
getCompilationFlags
(
this
.
store
),
...
headerAsFlag
(
getCppHeaderPath
(
this
.
store
)),
...
headerAsFlag
(
getSoiHeaderPath
(
this
.
store
)),
"
-o
"
,
taskname
],
{
cwd
:
workspace
}
);
}
try
{
await
fs
.
unlink
(
soitaskFiles
.
binaryFsPath
);
}
catch
(
err
)
{
if
(
err
.
code
===
"
ENOENT
"
)
{
this
.
store
.
logInfo
(
"
compilation
"
,
`
compiled binary '
${
compilerPath
}
' not found
`
,
err
);
}
else
{
this
.
store
.
handleError
(
"
compilation
"
,
`
deleting binary '
${
soitaskFiles
.
binaryFsPath
}
' failed
`
,
err
);
}
const
compileTaskDefinition
=
{
label
:
"
build
"
+
taskname
+
"
development
"
,
// "command": "clang++",
// "args": ,
type
:
"
process
"
,
group
:
{
kind
:
"
build
"
,
isDefault
:
true
}
};
// let compileTask = new vscode.Task(compileTaskDefinition, vscode.TaskScope.Workspace, "compile" + taskname, "c++", execute, "$gcc");
let
compileTask
=
new
vscode
.
Task
(
compileTaskDefinition
,
vscode
.
TaskScope
.
Workspace
,
"
compile
"
+
taskname
,
"
soic
"
,
execute
);
try
{
await
vscode
.
tasks
.
executeTask
(
compileTask
);
}
catch
(
err
)
{
this
.
store
.
logError
(
"
compilation
"
,
"
executing task failed
"
,
err
);
resolve
(
"
Failed
"
);
const
headerAsFlag
=
(
path
:
string
)
=>
(
path
===
""
?
[]
:
[
"
-I
"
,
path
]);
// Todo: allow customizable flags
const
execute
=
new
vscode
.
ProcessExecution
(
compilerPath
,
[
soitaskFiles
.
solutionWorkspacePath
!
,
...
getCompilationFlags
(
this
.
store
),
...
headerAsFlag
(
getCppHeaderPath
(
this
.
store
)),
...
headerAsFlag
(
getSoiHeaderPath
(
this
.
store
)),
"
-o
"
,
taskname
],
{
cwd
:
workspace
}
);
// let compileTask = new vscode.Task(compileTaskDefinition, vscode.TaskScope.Workspace, "compile" + taskname, "c++", execute, "$gcc");
let
compileTask
=
new
vscode
.
Task
(
compileTaskDefinition
,
vscode
.
TaskScope
.
Workspace
,
"
compile
"
+
taskname
,
"
soic
"
,
execute
);
try
{
let
compileTaskExec
=
vscode
.
tasks
.
executeTask
(
compileTask
);
compileTaskExec
.
then
(
e
=>
{
this
.
store
.
logInfo
(
"
compiler
"
,
`
finished vscode.task.executeTask
`
);
});
finished
.
push
(
new
vscode
.
Disposable
(()
=>
{
this
.
store
.
logError
(
"
compiler
"
,
"
aborted compilation, killing process
"
);
compileTaskExec
.
then
(
e
=>
{
e
.
terminate
();
});
})
);
}
catch
(
err
)
{
this
.
store
.
logError
(
"
compilation
"
,
"
executing task failed
"
,
err
);
cleanup
();
return
"
Failed
"
;
}
finished
.
push
(
vscode
.
tasks
.
onDidEndTask
(
taskEnded
=>
{
if
(
taskEnded
.
execution
.
task
.
name
===
"
compile
"
+
taskname
)
{
try
{
fs
.
readFile
(
soitaskFiles
.
binaryFsPath
).
then
(()
=>
{
resolve
(
"
Success
"
);
cleanup
();
return
"
Success
"
;
});
}
catch
(
err
)
{
this
.
store
.
logError
(
...
...
@@ -124,17 +168,38 @@ export class Runner {
err
);
if
(
err
.
code
!==
"
EEXIST
"
)
{
resolve
(
"
Failed
"
);
cleanup
();
return
"
Failed
"
;
}
}
}
});
})
);
finished
.
push
(
vscode
.
tasks
.
onDidStartTaskProcess
(
evtStartProc
=>
{
if
(
evtStartProc
.
execution
.
task
.
name
===
compileTask
.
name
)
{
this
.
store
.
logInfo
(
"
compiler
"
,
`
compiling started successfully with pid '
${
evtStartProc
.
processId
}
'
`
);
}
})
);
finished
.
push
(
vscode
.
tasks
.
onDidEndTaskProcess
(
evtEndProc
=>
{
if
(
evtEndProc
.
execution
.
task
.
name
===
compileTask
.
name
)
{
this
.
store
.
logInfo
(
"
compiler
"
,
`
compiling ended successfully with exit code '
${
evtEndProc
.
exitCode
}
'
`
);
}
})
);
setTimeout
(()
=>
{
this
.
store
.
logError
(
"
compilation
"
,
`
timed out compilation
`
);
resolve
(
"
Failed
"
);
},
10000
);
});
await
timer
.
timer
;
this
.
store
.
logError
(
"
compilation
"
,
`
timed out compilation
`
);
cleanup
();
return
"
Failed
"
;
}
async
askAndCompile
(
...
...
src/store.ts
View file @
8e043bcd
...
...
@@ -44,7 +44,9 @@ export class Store {
}
handleError
(
this
:
Store
,
location
:
string
,
info
:
string
,
err
:
Error
):
never
{
this
.
channel
.
appendLine
(
`
#### Error
${
location
}
####
`
);
this
.
channel
.
appendLine
(
`
#### [
${
new
Date
().
toISOString
()}
] Error
${
location
}
####
`
);
this
.
channel
.
appendLine
(
info
);
this
.
channel
.
appendLine
(
"
error name:
"
);
this
.
channel
.
appendLine
(
err
.
name
);
...
...
@@ -58,7 +60,9 @@ export class Store {
throw
err
;
}
logInfo
(
this
:
Store
,
location
:
string
,
info
:
string
,
err
?:
Error
)
{
this
.
channel
.
appendLine
(
`
#### info at [
${
location
}
] ####
`
);
this
.
channel
.
appendLine
(
`
#### [
${
new
Date
().
toISOString
()}
] info at [
${
location
}
] ####
`
);
this
.
channel
.
appendLine
(
info
);
if
(
err
!==
undefined
)
{
this
.
channel
.
appendLine
(
err
.
name
);
...
...
@@ -71,7 +75,9 @@ export class Store {
}
}
logError
(
this
:
Store
,
location
:
string
,
info
:
string
,
err
?:
Error
)
{
this
.
channel
.
appendLine
(
`
#### error at [
${
location
}
] ####
`
);
this
.
channel
.
appendLine
(
`
#### [
${
new
Date
().
toISOString
()}
] error at [
${
location
}
] ####
`
);
this
.
channel
.
appendLine
(
info
);
if
(
err
!==
undefined
)
{
this
.
channel
.
appendLine
(
err
.
name
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment