platformio / platformio-docs

PlatformIO Documentation
https://docs.platformio.org
Apache License 2.0
247 stars 325 forks source link

Overriding package files script doesn't work for me #91

Closed me21 closed 5 years ago

me21 commented 5 years ago

Configuration

Operating system: Windows 10 LTSB 2016

PlatformIO Version (platformio --version): 4.0.3

Description of problem

I have an issue with overriding package files as per https://docs.platformio.org/en/latest/projectconf/advanced_scripting.html#override-package-files

apply_patches.py causes the entire build process to finish with "success" even though no files are built if .patching-done file is present. That is, if I clean intermediate files, they won't be rebuilt.

This is caused by the following lines in the script:

# skip patch process if we did it before
if isfile(join(FRAMEWORK_DIR, ".patching-done")):
    env.Exit(0)

Also, verbose build doesn't show anything neither. The build process just stops with "success". No indication that it's stopped early because of env.Exit(0) call.

Steps to Reproduce

  1. Follow all steps at https://docs.platformio.org/en/latest/projectconf/advanced_scripting.html#override-package-files
  2. Build the project. The framework files are patched.
  3. Clean the project.
  4. Try to build the project again. apply_patches.py script detects that files are already patched and stops the build process entirely.

Actual Results

The build stops immediately with "SUCCESS" status. No files are actually built.

Expected Results

All project files should be rebuilt and firmware file should be generated.

Additional info

The workaround is to alter apply_patches.py script slightly to avoid using env.Exit(0):

from os.path import join, isfile

Import("env")

FRAMEWORK_DIR = env.PioPlatform().get_package_dir("framework-arduinoavr")
patchflag_path = join(FRAMEWORK_DIR, ".patching-done")

# skip patch process if we did it before
if not isfile(join(FRAMEWORK_DIR, ".patching-done")):
    original_file = join(FRAMEWORK_DIR, "variants", "standard", "pins_arduino.h")
    patched_file = join("patches", "1-framework-arduinoavr-add-pin-a8.patch")

    assert isfile(original_file) and isfile(patched_file)

    env.Execute("patch %s %s" % (original_file, patched_file))
    # env.Execute("touch " + patchflag_path)

    def _touch(path):
        with open(path, "w") as fp:
            fp.write("")

    env.Execute(lambda *args, **kwargs: _touch(patchflag_path))
ivankravets commented 5 years ago

@valeros could you check it?

valeros commented 5 years ago

Many thanks!