如何链接资源

时间:2018-09-22 13:07:49

标签: python-2.7 eclipse-cdt esp8266 platformio

我将Platformio与ESP8266,WiFi板,4M RAM,32位处理器一起使用。

一个网站被嵌入:一个页面,用xxd编码的index.html,这是自定义makefile中的规则:

src/index.html.h: index.html
    xxd -i $<                                                   $@.tmp
    sed 's/unsigned char/static const unsigned char/g' $@.tmp > $@
    sed 's/unsigned int/static const unsigned int/g'   $@     > $@.tmp
    sed 's/};/,0};/g'                                  $@.tmp > $@
    rm -f $@.tmp

makefile仅与模拟器一起用于构建elf x86二进制文件。

当我为ESP8266目标构建时,我想使用platformio构建器自动执行相同的操作。

我在platformio.ini中添加了一个额外的脚本指令:

[env:nodemcuv2]
extra_scripts = pre:generate_index_html_header.py
...

并编写了以下python脚本:

Import("env")

def generate_index_html_header(source, target, env):
    print "Generating index html header"
    env.Execute( "make src/index.html.h" )

env.AddPreAction("generate_index_html_header", generate_index_html_header)

似乎没有执行,因为在构建日志中看不到跟踪“ Generating ...”:

14:57:16 **** Incremental Build of configuration Default for project arrosage ****
platformio -f -c eclipse run 
Processing nodemcuv2 (framework: arduino; platform: espressif8266...)
---------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: Espressif 8266 > NodeMCU 1.0 (ESP-12E Module)
SYSTEM: ESP8266 80MHz 80KB RAM (4MB Flash)
Library Dependency Finder
LDF MODES: FINDER(deep+) COMPATIBILITY(soft)
Collected 28 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <json>
|-- <NTPClient> 3.1.0
|-- <ESP8266WiFi> 1.0
Compiling .pioenvs/nodemcuv2/src/Activite.cpp.o
...
Archiving .pioenvs/nodemcuv2/libFrameworkArduino.a
Indexing .pioenvs/nodemcuv2/libFrameworkArduino.a
Linking .pioenvs/nodemcuv2/firmware.elf
Retrieving maximum program size .pioenvs/nodemcuv2/firmware.elf
Building .pioenvs/nodemcuv2/firmware.bin
Checking size .pioenvs/nodemcuv2/firmware.elf
Memory Usage -> 
DATA:    [======    ]  64.1% (used 52504 bytes from 81920 bytes)
PROGRAM: [===       ]  28.3% (used 295412 bytes from 1044464 bytes)
========================= [SUCCESS] Took 8.55 seconds =========================

14:57:25 Build Finished. 0 errors, 0 warnings. (took 8s.950ms)

我确定没有执行我的python“额外脚本”,因为如果我手动删除生成的文件“ index.html.h”,则生成文件会出现以下错误:

src/Serveur.cpp:3:24: fatal error: index.html.h: No such file or directory

0 个答案:

没有答案