Skip to content

Commit

Permalink
Keep the same macro name for "COMPONENT_EMBED_TXTFILES" as ESP-IDF
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankravets committed Jul 30, 2018
1 parent 51f82da commit 4bc6283
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
24 changes: 19 additions & 5 deletions builder/frameworks/_embedtxt_files.py
@@ -1,3 +1,17 @@
# Copyright 2014-present PlatformIO <contact@platformio.org>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from os import SEEK_CUR, SEEK_END
from os.path import basename, isfile, join

Expand Down Expand Up @@ -27,17 +41,17 @@ def prepare_files(files):

def extract_files(cppdefines):
for define in cppdefines:
if "EMBED_TXT_FILES" not in define:
if "COMPONENT_EMBED_TXTFILES" not in define:
continue

if not isinstance(define, tuple):
print("Warning! EMBED_TXT_FILES config cannot be empty!")
print("Warning! COMPONENT_EMBED_TXTFILES macro cannot be empty!")
return []

with cd(env.subst("$PROJECT_DIR")):
value = define[1]
if not isinstance(value, str):
print("Warning! EMBED_TXT_FILES config must contain "
print("Warning! COMPONENT_EMBED_TXTFILES macro must contain "
"a list of files separated by ':'")
return []

Expand All @@ -53,7 +67,7 @@ def extract_files(cppdefines):

def remove_config_define(cppdefines):
for define in cppdefines:
if "EMBED_TXT_FILES" in define:
if "COMPONENT_EMBED_TXTFILES" in define:
env.ProcessUnFlags("-D%s" % "=".join(str(d) for d in define))
return

Expand Down Expand Up @@ -81,7 +95,7 @@ def embed_files(files):
)

flags = env.get("CPPDEFINES")
if "EMBED_TXT_FILES" in env.Flatten(flags):
if "COMPONENT_EMBED_TXTFILES" in env.Flatten(flags):
files = extract_files(flags)
prepare_files(files)
embed_files(files)
Expand Down
1 change: 1 addition & 0 deletions builder/frameworks/arduino.py
Expand Up @@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Arduino
Expand Down
2 changes: 1 addition & 1 deletion examples/espidf-aws-iot/platformio.ini
Expand Up @@ -13,6 +13,6 @@ framework = espidf
board = esp32dev
monitor_speed = 115200
build_flags =
-DEMBED_TXT_FILES=src/private.pem.key:src/certificate.pem.crt:src/aws-root-ca.pem
-DCOMPONENT_EMBED_TXTFILES=src/private.pem.key:src/certificate.pem.crt:src/aws-root-ca.pem
-DCONFIG_WIFI_SSID=\"ESP_AP\"
-DCONFIG_WIFI_PASSWORD=\"MYPASS\"

0 comments on commit 4bc6283

Please sign in to comment.