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

Commit 1a71dc2

Browse files
committed
Mark serial monitor as executable on Mac and Linux
1 parent e0f29b8 commit 1a71dc2

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

0 commit comments

Comments
 (0)