mirror of
https://github.com/EyeTrackVR/OpenIris.git
synced 2025-11-04 15:39:42 +08:00
feat: testing createzip script
This commit is contained in:
parent
8d4d5cc170
commit
bcef34014d
12
.github/workflows/build_release_bins.yml
vendored
12
.github/workflows/build_release_bins.yml
vendored
@ -43,15 +43,15 @@ jobs:
|
||||
pip install --upgrade platformio
|
||||
pio upgrade --dev
|
||||
pio pkg update --global
|
||||
- name: Update build command
|
||||
working-directory: ./ESP
|
||||
run: |
|
||||
sed -i '/\[env\]/p; s/\[env\]/upload_protocol = custom/' platformio.ini
|
||||
sed -i '/\[env\]/p; s/\[env\]/upload_command = \$PYTHONEXE .\/tools\/createzip.py \$FLASH_EXTRA_IMAGES \$ESP32_APP_OFFSET \$SOURCE/' platformio.ini
|
||||
#- name: Update build command
|
||||
# working-directory: ./ESP
|
||||
# run: |
|
||||
# sed -i '/\[env\]/p; s/\[env\]/upload_protocol = custom/' platformio.ini
|
||||
# sed -i '/\[env\]/p; s/\[env\]/upload_command = \$PYTHONEXE .\/tools\/createzip.py \$FLASH_EXTRA_IMAGES \$ESP32_APP_OFFSET \$SOURCE/' platformio.ini
|
||||
- name: Build OpenIris Firmware
|
||||
working-directory: ./ESP
|
||||
run: |
|
||||
mkdir build
|
||||
mkdir build/${{ matrix.target_name }}${{ matrix.target_build_type }}
|
||||
echo "::group::platformio.ini"
|
||||
cat platformio.ini
|
||||
echo "::endgroup::"
|
||||
|
||||
@ -6,4 +6,4 @@ StateManager<WebServerState_e> webServerStateManager;
|
||||
StateManager<MDNSState_e> mdnsStateManager;
|
||||
StateManager<CameraState_e> cameraStateManager;
|
||||
StateManager<LEDStates_e> ledStateManager;
|
||||
StateManager<StreamState_e> streamStateManager;
|
||||
StateManager<StreamState_e> streamStateManager;
|
||||
|
||||
@ -149,4 +149,4 @@ extern StateManager<CameraState_e> cameraStateManager;
|
||||
extern StateManager<LEDStates_e> ledStateManager;
|
||||
extern StateManager<StreamState_e> streamStateManager;
|
||||
|
||||
#endif // STATEMANAGER_HPP
|
||||
#endif // STATEMANAGER_HPP
|
||||
|
||||
@ -68,4 +68,6 @@ lib_deps =
|
||||
https://github.com/me-no-dev/AsyncTCP.git
|
||||
|
||||
build_type = debug
|
||||
extra_scripts = pre:tools/customname.py
|
||||
extra_scripts =
|
||||
pre:tools/customname.py
|
||||
post:tools/createzip.py
|
||||
|
||||
@ -2,57 +2,65 @@
|
||||
Import("env")
|
||||
|
||||
import sys
|
||||
from os import getcwd
|
||||
import os
|
||||
from ntpath import basename
|
||||
from zipfile import ZipFile
|
||||
import json
|
||||
|
||||
my_flags = env.ParseFlags(env["BUILD_FLAGS"])
|
||||
defines = dict()
|
||||
for x in my_flags.get("CPPDEFINES"):
|
||||
if type(x) is tuple:
|
||||
(k, v) = x
|
||||
defines[k] = v
|
||||
# print("Type Tuple: %s" % x)
|
||||
elif type(x) is list:
|
||||
k = x[0]
|
||||
v = x[1]
|
||||
defines[k] = v
|
||||
# print("Type List: %s" % x)
|
||||
|
||||
def createZip(source, target, env):
|
||||
if os == "linux":
|
||||
print("Program has been built, creating zip archive!")
|
||||
my_flags = env.ParseFlags(env["BUILD_FLAGS"])
|
||||
defines = dict()
|
||||
for x in my_flags.get("CPPDEFINES"):
|
||||
if type(x) is tuple:
|
||||
(k, v) = x
|
||||
defines[k] = v
|
||||
elif type(x) is list:
|
||||
k = x[0]
|
||||
v = x[1]
|
||||
defines[k] = v
|
||||
else:
|
||||
defines[x] = "" # empty value
|
||||
s = lambda x: x.replace('"', "")
|
||||
|
||||
print("FLASH_EXTRA_IMAGES: %s\n" % env["FLASH_EXTRA_IMAGES"])
|
||||
print("ESP32_APP_OFFSET: %s\n" % env["ESP32_APP_OFFSET"])
|
||||
array_args = [env["FLASH_EXTRA_IMAGES"], env["ESP32_APP_OFFSET"]]
|
||||
|
||||
for (offset, image) in env["FLASH_EXTRA_IMAGES"]:
|
||||
print("\nImage: %s" % str(image))
|
||||
array_args.append(str(image))
|
||||
array_args.append(str(offset))
|
||||
|
||||
for _source in source:
|
||||
print("\nSource: %s" % str(_source))
|
||||
array_args.append(str(_source))
|
||||
n = 2
|
||||
partitions_arg = array_args[1:]
|
||||
partitions = final = [
|
||||
partitions_arg[i * n : (i + 1) * n]
|
||||
for i in range((len(partitions_arg) + n - 1) // n)
|
||||
]
|
||||
file_name = "./build/{0}/{1}.zip".format(str(env["PIOENV"]), env["PROGNAME"])
|
||||
with ZipFile(file_name, "w") as archive:
|
||||
print('\nCreating "' + archive.filename + '"', end="\n")
|
||||
parts = []
|
||||
for [offset, path] in partitions:
|
||||
filename = basename(path)
|
||||
archive.write(path, filename)
|
||||
partition = {
|
||||
"path": filename,
|
||||
"offset": int(offset, 16),
|
||||
}
|
||||
parts.append(partition)
|
||||
manifest = {
|
||||
"chipFamily": "ESP32",
|
||||
"parts": parts,
|
||||
}
|
||||
archive.writestr("manifest.json", json.dumps(manifest))
|
||||
else:
|
||||
defines[x] = "" # empty value
|
||||
# print("Warning: unknown type for %s" % x)
|
||||
print("Not running on Linux, skipping zip creation")
|
||||
|
||||
# strip quotes needed for shell escaping
|
||||
s = lambda x: x.replace('"', "")
|
||||
|
||||
|
||||
n = 2
|
||||
partitions_arg = sys.argv[1:]
|
||||
partitions = final = [
|
||||
partitions_arg[i * n : (i + 1) * n]
|
||||
for i in range((len(partitions_arg) + n - 1) // n)
|
||||
]
|
||||
|
||||
# file_name = "build/" + str(env["PIOENV"]) + "/" + env["PROGNAME"] + ".zip"
|
||||
|
||||
file_name = "build/{1}/{2}.zip".format(str(env["PIOENV"]), env["PROGNAME"])
|
||||
|
||||
with ZipFile(file_name, "w") as archive:
|
||||
print('Creating "' + archive.filename + '"', end="\n")
|
||||
parts = []
|
||||
|
||||
for [offset, path] in partitions:
|
||||
filename = basename(path)
|
||||
archive.write(path, filename)
|
||||
partition = {
|
||||
"path": filename,
|
||||
"offset": int(offset, 16),
|
||||
}
|
||||
parts.append(partition)
|
||||
|
||||
manifest = {
|
||||
"chipFamily": "ESP32",
|
||||
"parts": parts,
|
||||
}
|
||||
archive.writestr("manifest.json", json.dumps(manifest))
|
||||
env.AddPostAction("$PROGPATH", createZip)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user