Skip to content

Tools - makecorever.py fixed packaging & avoid needless overwrites #9250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package/build_boards_manager_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ $SED -E "s/name=([a-zA-Z0-9\ -]+).*/name=\1(${ver})/g"\
#echo "#define ARDUINO_ESP8266_GIT_DESC `git describe --tags 2>/dev/null`" >>${outdir}/cores/esp8266/core_version.h
#echo "#define ARDUINO_ESP8266_RELEASE_${ver_define}" >>${outdir}/cores/esp8266/core_version.h
#echo "#define ARDUINO_ESP8266_RELEASE \"${ver_define}\"" >>${outdir}/cores/esp8266/core_version.h
python3 ${srcdir}/tools/makecorever.py -b ${outdir} -i cores/esp8266 -p ${srcdir} -v ${plain_ver} -r
python3 ${srcdir}/tools/makecorever.py --git-root ${srcdir} --version ${plain_ver} --release ${outdir}/cores/esp8266/core_version.h

# Zip the package
pushd package/versions/${visiblever}
Expand Down
1 change: 1 addition & 0 deletions tests/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ function install_core()
"compiler.c.extra_flags=-Wall -Wextra $debug_flags" \
"compiler.cpp.extra_flags=-Wall -Wextra $debug_flags" \
"mkbuildoptglobals.extra_flags=--ci --cache_core" \
"recipe.hooks.prebuild.1.pattern=\"{runtime.tools.python3.path}/python3\" -I \"{runtime.tools.makecorever}\" --git-root \"{runtime.platform.path}\" --version \"{version}\" \"{runtime.platform.path}/cores/esp8266/core_version.h\"" \
> ${core_path}/platform.local.txt
echo -e "\n----platform.local.txt----"
cat platform.local.txt
Expand Down
3 changes: 2 additions & 1 deletion tests/sanity_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ source "$root/tests/common.sh"

pushd "$root"/tools
python3 get.py -q

python3 makecorever.py --git-root "$root" "$root/cores/esp8266/core_version.h"
popd

pushd "$cache_dir"

gcc="$root/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc"\
Expand Down
29 changes: 13 additions & 16 deletions tools/makecorever.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def check_git(*args: str, cwd: Optional[str]):


def generate(
out: TextIO,
*,
git_root: pathlib.Path,
hash_length: int = 8,
Expand Down Expand Up @@ -118,7 +117,7 @@ def git(*args):
#define ARDUINO_ESP8266_DEV 1 // development version
"""

out.write(text)
return text


if __name__ == "__main__":
Expand Down Expand Up @@ -158,20 +157,18 @@ def git(*args):

args = parser.parse_args()

def select_output(s: str) -> TextIO:
if not s:
return sys.stdout
contents = generate(
git_root=args.git_root,
hash_length=args.hash_length,
release=args.release,
version=args.version,
)

out = pathlib.Path(s)
if args.output:
out = pathlib.Path(args.output)
out.parent.mkdir(parents=True, exist_ok=True)

return out.open("w", encoding="utf-8")

with select_output(args.output) as out:
generate(
out,
git_root=args.git_root,
hash_length=args.hash_length,
release=args.release,
version=args.version,
)
if not out.exists() or contents != out.read_text(encoding="utf-8"):
out.write_text(contents, encoding="utf-8")
else:
print(contents, file=sys.stdout)