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

Commit 0d85734

Browse files
authored
Merge pull request #1420 from microsoft/dev/bemcmorr/executable-serial-monitor
Mark serial monitor as executable on Mac and Linux
2 parents e0f29b8 + 152e989 commit 0d85734

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

azure-pipelines.yml

+2
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ steps:
115115
includeRootFolder: false
116116
archiveType: zip
117117
archiveFile: $(Build.StagingDirectory)\vscode-arduino.vsix
118+
- script: python .\build\markExecutableFiles.py
119+
displayName: Make serial monitor executable
118120
- task: MSBuild@1
119121
displayName: Sign VSIX
120122
inputs:

build/markExecutableFiles.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import os
2+
import zipfile
3+
4+
staging_directory = os.getenv('BUILD_STAGINGDIRECTORY')
5+
input_archive_path = f"{staging_directory}/vscode-arduino.vsix"
6+
output_archive_path = f"{staging_directory}/vscode-arduino-out.vsix"
7+
8+
filenames = [
9+
"extension/out/serial-monitor-cli/darwin/main",
10+
"extension/out/serial-monitor-cli/linux/main"
11+
]
12+
13+
input_archive = zipfile.ZipFile(input_archive_path, 'r')
14+
output_archive = zipfile.ZipFile(output_archive_path, 'w')
15+
16+
executable_count = 0
17+
for info in input_archive.infolist():
18+
data = input_archive.read(info)
19+
if info.filename in filenames:
20+
# Magic number from from https://stackoverflow.com/a/48435482
21+
info.external_attr = 0o100755 << 16
22+
executable_count += 1
23+
output_archive.writestr(info, data)
24+
25+
if executable_count != len(filenames):
26+
raise Exception(f'Expected to find {len(filenames)} executables but only found {executable_count}')
27+
28+
input_archive.close()
29+
output_archive.close()
30+
31+
os.replace(output_archive_path, input_archive_path)

0 commit comments

Comments
 (0)