Mirror of espurna firmware for wireless switches and more
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.6 KiB

  1. import os
  2. def lwip_inject_patcher(env):
  3. # ignore when building with lwip2
  4. if "lwip_gcc" not in env["LIBS"]:
  5. return
  6. platform = env.PioPlatform()
  7. framework_dir = platform.get_package_dir("framework-arduinoespressif8266")
  8. toolchain_prefix = os.path.join(
  9. platform.get_package_dir("toolchain-xtensa"), "bin", "xtensa-lx106-elf-"
  10. )
  11. patch_action = env.VerboseAction(
  12. " ".join(
  13. [
  14. "-patch",
  15. "-u",
  16. "-N",
  17. "-d",
  18. os.path.join(framework_dir, "tools", "sdk", "lwip"),
  19. os.path.join("src", "core", "tcp_out.c"),
  20. env.subst(
  21. os.path.join(
  22. "$PROJECT_DIR",
  23. "..",
  24. "dist",
  25. "patches",
  26. "lwip_mtu_issue_1610.patch",
  27. )
  28. ),
  29. ]
  30. ),
  31. "Patching lwip source",
  32. )
  33. build_action = env.VerboseAction(
  34. " ".join(
  35. [
  36. "make",
  37. "-C",
  38. os.path.join(framework_dir, "tools", "sdk", "lwip", "src"),
  39. "install",
  40. "TOOLS_PATH={}".format(toolchain_prefix),
  41. "LWIP_LIB=liblwip_gcc.a",
  42. ]
  43. ),
  44. "Rebuilding lwip",
  45. )
  46. patcher = env.Alias("patch-lwip", None, patch_action)
  47. builder = env.Alias("build-lwip", patcher, build_action)
  48. if os.environ.get("ESPURNA_PIO_PATCH_ISSUE_1610"):
  49. env.Depends("$BUILD_DIR/${PROGNAME}.elf", builder)
  50. env.AlwaysBuild(patcher)
  51. env.AlwaysBuild(builder)