Browse Source

ci: rework build.sh & release.sh generator

- don't depend on TRAVIS environment variables
- depend on CI flag to add release variables
- chmod +x
mcspr-patch-1
Maxim Prokhorov 4 years ago
committed by Max Prokhorov
parent
commit
492a35926f
5 changed files with 47 additions and 15 deletions
  1. +4
    -1
      code/build.sh
  2. +4
    -4
      code/scripts/espurna_utils/release.py
  3. +23
    -4
      code/scripts/generate_release_sh.py
  4. +5
    -1
      code/scripts/pio_main.py
  5. +11
    -5
      code/scripts/pio_pre.py

+ 4
- 1
code/build.sh View File

@ -96,7 +96,10 @@ build_webui() {
build_release() {
echo "--------------------------------------------------------------"
echo "Building release images..."
python scripts/generate_release_sh.py --ignore secure-client $version > release.sh
python scripts/generate_release_sh.py \
--ignore secure-client \
--version $version \
--destination $destination/espurna-$version > release.sh
bash release.sh
echo "--------------------------------------------------------------"
}


+ 4
- 4
code/scripts/espurna_utils/release.py View File

@ -3,13 +3,13 @@ import shutil
def copy_release(target, source, env):
# target filename and subdir for release files
name = env["ESPURNA_NAME"]
version = env["ESPURNA_VERSION"]
name = env["ESPURNA_RELEASE_NAME"]
version = env["ESPURNA_RELEASE_VERSION"]
destdir = env["ESPURNA_RELEASE_DESTINATION"]
if not name or not version:
if not name or not version or not destdir:
raise ValueError("Cannot set up release without release variables present")
destdir = os.path.join(env.subst("$PROJECT_DIR"), "..", "firmware", version)
if not os.path.exists(destdir):
os.makedirs(destdir)


+ 23
- 4
code/scripts/generate_release_sh.py View File

@ -1,3 +1,20 @@
#!/usr/bin/env python
#
# Copyright (C) 2020 by Maxim Prokhorov <prokhorov dot max at outlook dot com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import argparse
import re
@ -79,7 +96,7 @@ def generate_lines(builds, ignore):
flags.append('PLATFORMIO_BUILD_FLAGS="{}"'.format(build.build_flags))
if build.src_build_flags:
flags.append('ESPURNA_FLAGS="{}"'.format(build.src_build_flags))
flags.append('ESPURNA_NAME="{env}"'.format(env=build.env))
flags.append('ESPURNA_RELEASE_NAME="{env}"'.format(env=build.env))
cmd = ["env"]
cmd.extend(flags)
@ -110,7 +127,8 @@ if __name__ == "__main__":
raise ValueError("* Not in CI *")
parser = argparse.ArgumentParser()
parser.add_argument("version")
parser.add_argument("--version", required=True)
parser.add_argument("--destination", required=True)
parser.add_argument("--ignore", action="append")
args = parser.parse_args()
@ -127,8 +145,9 @@ if __name__ == "__main__":
print("#!/bin/bash")
print("set -e -x")
print('export ESPURNA_VERSION="{}"'.format(args.version))
print('trap "ls -l ${TRAVIS_BUILD_DIR}/firmware/${ESPURNA_VERSION}" EXIT')
print('export ESPURNA_RELEASE_VERSION="{}"'.format(args.version))
print('export ESPURNA_RELEASE_DESTINATION="{}"'.format(args.destination))
print('trap "ls -l ${ESPURNA_RELEASE_DESTINATION}" EXIT')
print(
'echo "Selected thread #{} out of {}"'.format(
builder_thread + 1, builder_total_threads


+ 5
- 1
code/scripts/pio_main.py View File

@ -22,6 +22,9 @@ from espurna_utils import (
Import("env", "projenv")
import os
CI = any([os.environ.get("TRAVIS"), os.environ.get("CI")])
# Always show warnings for project code
projenv.ProcessUnFlags("-w")
@ -31,7 +34,8 @@ remove_float_support(env)
ldscripts_inject_libpath(env)
# two-step update hint when using 1MB boards
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", check_printsize)
if not CI:
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", check_printsize)
# disable postmortem printing to the uart. another one is in eboot, but this is what causes the most harm
if "DISABLE_POSTMORTEM_STACKDUMP" in env["CPPFLAGS"]:


+ 11
- 5
code/scripts/pio_pre.py View File

@ -20,7 +20,7 @@ import sys
from SCons.Script import ARGUMENTS
TRAVIS = os.environ.get("TRAVIS")
CI = any([os.environ.get("TRAVIS"), os.environ.get("CI")])
PIO_PLATFORM = env.PioPlatform()
CONFIG = env.GetProjectConfig()
VERBOSE = "1" == ARGUMENTS.get("PIOVERBOSE", "0")
@ -97,8 +97,6 @@ def ensure_platform_updated():
# handle build flags through os environment.
# using env instead of ini to avoid platformio ini changing hash on every change
env.Append(
ESPURNA_VERSION=os.environ.get("ESPURNA_VERSION", ""),
ESPURNA_NAME=os.environ.get("ESPURNA_NAME", ""),
ESPURNA_BOARD=os.environ.get("ESPURNA_BOARD", ""),
ESPURNA_AUTH=os.environ.get("ESPURNA_AUTH", ""),
ESPURNA_FLAGS=os.environ.get("ESPURNA_FLAGS", "")
@ -112,8 +110,16 @@ if ESPURNA_OTA_PORT:
else:
env.Replace(UPLOAD_PROTOCOL="esptool")
# handle `-t release` parameters
if CI:
env.Append(
ESPURNA_RELEASE_NAME=os.environ.get("ESPURNA_RELEASE_NAME", ""),
ESPURNA_RELEASE_VERSION=os.environ.get("ESPURNA_RELEASE_VERSION", ""),
ESPURNA_RELEASE_DESTINATION=os.environ.get("ESPURNA_RELEASE_DESTINATION", "")
)
# updates arduino core git to the latest master commit
if TRAVIS:
if CI:
package_overrides = env.GetProjectOption("platform_packages")
for package in package_overrides:
if "https://github.com/esp8266/Arduino.git" in package:
@ -122,7 +128,7 @@ if TRAVIS:
# to speed-up build process, install libraries in either global or local shared storage
if os.environ.get("ESPURNA_PIO_SHARED_LIBRARIES"):
if TRAVIS:
if CI:
storage = None
log("using global library storage")
else:


Loading…
Cancel
Save