Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
AronHetLam committed Sep 20, 2023
1 parent b83612b commit 6e1988d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 40 deletions.
24 changes: 9 additions & 15 deletions .github/workflows/build_binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ jobs:
- name: Cache PlatformIO
uses: actions/cache@v3
with:
path: ~/.platformio
path: |
~/.platformio
./pio
key: ${{ runner.os }}-pio-${{ matrix.environment }}-${{ hashFiles('**/platformio.ini') }}
- name: Set up Python
uses: actions/setup-python@v4
Expand All @@ -59,7 +61,7 @@ jobs:
run: pip install -r requirements.txt
- name: Build firmware
env:
PLATFORMIO_BUILD_FLAGS: -DPUBLISH
PUBLISH: true
run: pio run -e ${{ matrix.environment }}
- uses: actions/upload-artifact@v3
with:
Expand All @@ -77,26 +79,18 @@ jobs:
- uses: actions/download-artifact@v3
with:
path: ./output
- run: pushd ./output && pwd && ls && popd
- name: merge manifests
run: |
jq -s '[.[] | select(.name == "ATEM_tally_light")] | (.[0] | with_entries(select(.key != "builds"))) + {builds: map(.builds) | add}' output/*/manifest.json > ./output/ATEM_tally_light_manifest.json &&
jq -s '[.[] | select(.name == "ATEM_tally_test_server")] | (.[0] | with_entries(select(.key != "builds"))) + {builds: map(.builds) | add}' output/*/manifest.json > ./output/ATEM_tally_test_server_manifest.json
- uses: actions/configure-pages@v3
- run: pushd ./output && pwd && ls && popd
- uses: actions/jekyll-build-pages@v1
with:
destination: ./output
- run: pushd ./output && pwd && ls && popd
- uses: actions/download-artifact@v3
with:
path: ./output
- run: pushd ./output && pwd && ls && popd
path: ./output/publish
- name: merge manifests
run: |
jq -s '[.[] | select(.name == "ATEM_tally_light")] | (.[0] | with_entries(select(.key != "builds"))) + {builds: map(.builds) | add}' output/*/manifest.json > ./output/ATEM_tally_light_manifest.json &&
jq -s '[.[] | select(.name == "ATEM_tally_test_server")] | (.[0] | with_entries(select(.key != "builds"))) + {builds: map(.builds) | add}' output/*/manifest.json > ./output/ATEM_tally_test_server_manifest.json
- uses: actions/upload-pages-artifact@v2
with:
name: gh-page-mine
path: ./
- uses: actions/upload-artifact@v3
with:
name: gh-mine
path: ./output
53 changes: 29 additions & 24 deletions pio_scripts/export_binaries.py → pio_scripts/publish_binaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
Import('env')

PIOENV = env.get("PIOENV")
VERSION = env.get("VERSION", "")
VERSION = os.getenv("VERSION", "")
BOARD_CONFIG = env.BoardConfig()
APP_BIN = "{}{}{}.bin".format(
env.get("BUILD_DIR"), os.path.sep, env.get("PROGNAME"))
PUBLISH_DIR_BASE = "publish{}".format(os.path.sep)
PUBLISH_DIR_FULL = "{}{}{}".format(PUBLISH_DIR_BASE, PIOENV, os.path.sep)
PUBLISH_BIN = "{}ATEM_tally_light_{}_{}.bin".format(PUBLISH_DIR_FULL, VERSION, PIOENV)

PUBLISH_BIN = "{}ATEM_tally_light_{}_{}.bin".format(
PUBLISH_DIR_FULL, VERSION, PIOENV)

def _get_cpp_define_value(env, define: str):
define_list = [(item[-1] if item[0] == define else "")
Expand All @@ -21,14 +21,16 @@ def _get_cpp_define_value(env, define: str):

return None


def _create_publish_dir():
if not os.path.isdir(PUBLISH_DIR_BASE):
os.mkdir(PUBLISH_DIR_BASE)

if not os.path.isdir(PUBLISH_DIR_FULL):
os.mkdir(PUBLISH_DIR_FULL)

def _esp_webtools_manifest(env, chip_family, flash_images):

def _esp_webtools_manifest(env, chip_family, flash_parts):
is_test_server = _get_cpp_define_value(
env, "TALLY_TEST_SERVER") is not None
manifest = {
Expand All @@ -39,41 +41,44 @@ def _esp_webtools_manifest(env, chip_family, flash_images):
"chipFamily": chip_family,
"parts": [
{
"path": "{}{}".format(PIOENV, os.path.basename(image[1])),
"path": "{}{}".format(PUBLISH_DIR_FULL, os.path.basename(image[1])),
"offset": int(image[0], 16)
} for image in flash_images]
} for image in flash_parts]
}]
}

with open("{}manifest.json".format(PUBLISH_DIR_FULL), "w") as outfile:
json.dump(manifest, outfile)


def bin_rename_copy(source, target, env):
_create_publish_dir()

chip_family = _get_cpp_define_value(env, "CHIP_FAMILY")
flash_images = env.get("FLASH_EXTRA_IMAGES", []) + \
[(env.get("ESP32_APP_OFFSET", "0x00"), str(target[0]))]
flash_images = env.get("FLASH_EXTRA_IMAGES", [])

if (chip_family.startswith("ESP32")):
# Run esptool to merge images into a single binary
env.Execute(" ".join(
[
"esptool",
"--chip", BOARD_CONFIG.get("build.mcu", "esp32"),
"merge_bin",
"-o", PUBLISH_BIN,
*env.Flatten(flash_images)
]
))
# if (chip_family.startswith("ESP32")):
# # Run esptool to merge images into a single binary
# env.Execute(" ".join(
# [
# "esptool",
# "--chip", BOARD_CONFIG.get("build.mcu", "esp32"),
# "merge_bin",
# "-o", PUBLISH_BIN,
# *env.Flatten(flash_images)
# ]
# ))

else: # esp8266
shutil.copy(str(target[0]), PUBLISH_BIN)
# else: # esp8266
for image in flash_images:
shutil.copy(image[1], PUBLISH_DIR_FULL)
shutil.copy(str(target[0]), PUBLISH_BIN)

_esp_webtools_manifest(env, chip_family, flash_images)
_esp_webtools_manifest(env, chip_family, flash_images +
[(env.get("ESP32_APP_OFFSET", "0x00"), PUBLISH_BIN)])


if (_get_cpp_define_value(env, "PUBLISH") is not None):
if (os.getenv("PUBLISH") is not None):
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", [bin_rename_copy])

env.Replace(
Expand Down
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ lib_deps = fastled/FastLED@^3.6.0
monitor_speed = 115200

extra_scripts =
post:pio_scripts/export_binaries.py
post:pio_scripts/publish_binaries.py

[env:esp8266]
build_flags =
Expand Down

0 comments on commit 6e1988d

Please sign in to comment.