-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathdist.py
73 lines (53 loc) · 1.83 KB
/
dist.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from pathlib import Path
from subprocess import check_call
import markdown2
import os
import zipfile
archive_name = 'Modelica-Arduino.zip'
# remove the archive
if os.path.exists(archive_name):
os.remove(archive_name)
generator = 'Visual Studio 17 2022'
root = Path(__file__).parent
# build the ModelicaFirmata library
for platform in ['x64']:
check_call([
'cmake',
'-G', generator,
'-A', platform,
'-S', (root / 'Arduino' / 'Resources' / 'Source' / 'Firmata').as_posix(),
'-B', (root / 'Arduino' / 'Resources' / 'Source' / 'Firmata' / platform).as_posix(),
])
check_call([
'cmake',
'--build', (root / 'Arduino' / 'Resources' / 'Source' / 'Firmata' / platform).as_posix(),
'--config', 'Release'
])
dist_files = []
input = [('Arduino', ('.mo', '.order', '.png', '.css', '.h', '.c', '.cpp', '.ino', 'ModelicaFirmata.dll', '.wrl', 'CMakeLists.txt'))]
# collect the distribution files
for folder, suffix in input:
for root, dirs, files in os.walk(folder):
for f in files:
if f.endswith(suffix):
dist_files += [os.path.join(root, f)]
dist_files += ['Arduino/Resources/Library/win64', 'LICENSE.txt', 'README.html']
html = """<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="Arduino/Resources/Images/simple.css">
</head>
<body>
"""
with open('README.md', 'r') as md_file:
html += markdown2.markdown(md_file.read(), extras=['fenced-code-blocks', 'tables'])
html += """</body>
</html>
"""
with open('README.html', 'w') as html_file:
html_file.write(html)
# create the archive
with zipfile.ZipFile(archive_name, 'w', zipfile.ZIP_DEFLATED) as zipf:
for name in dist_files:
zipf.write(filename=name)