Skip to content

Commit c4ed26c

Browse files
committed
Move common flags to framework build script
1 parent d90b917 commit c4ed26c

File tree

4 files changed

+194
-91
lines changed

4 files changed

+194
-91
lines changed

builder/frameworks/_bare.py

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Copyright 2014-present PlatformIO <[email protected]>
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
#
16+
# Default flags for bare-metal programming (without any framework layers)
17+
#
18+
19+
from os.path import join
20+
21+
from SCons.Script import Import
22+
23+
Import("env")
24+
25+
env.Append(
26+
ASFLAGS=["-x", "assembler-with-cpp"],
27+
28+
CFLAGS=[
29+
"-std=gnu99",
30+
"-Wpointer-arith",
31+
"-Wno-implicit-function-declaration",
32+
"-Wl,-EL",
33+
"-fno-inline-functions",
34+
"-nostdlib"
35+
],
36+
37+
CCFLAGS=[
38+
"-Os", # optimize for size
39+
"-mlongcalls",
40+
"-mtext-section-literals",
41+
"-falign-functions=4",
42+
"-U__STRICT_ANSI__",
43+
"-ffunction-sections",
44+
"-fdata-sections"
45+
],
46+
47+
CXXFLAGS=[
48+
"-fno-rtti",
49+
"-fno-exceptions",
50+
"-std=c++11"
51+
],
52+
53+
CPPDEFINES=[
54+
("F_CPU", "$BOARD_F_CPU"),
55+
"__ets__",
56+
"ICACHE_FLASH"
57+
],
58+
59+
LINKFLAGS=[
60+
"-Os",
61+
"-nostdlib",
62+
"-Wl,--no-check-sections",
63+
"-u", "call_user_start",
64+
"-u", "_printf_float",
65+
"-u", "_scanf_float",
66+
"-Wl,-static",
67+
"-Wl,--gc-sections"
68+
],
69+
70+
CPPPATH=[
71+
join("$SDK_ESP8266_DIR", "include"), "$PROJECTSRC_DIR"
72+
],
73+
74+
LIBPATH=[
75+
join("$SDK_ESP8266_DIR", "lib"),
76+
join("$SDK_ESP8266_DIR", "ld")
77+
],
78+
79+
LIBS=[
80+
"c", "gcc", "phy", "pp", "net80211", "lwip", "wpa", "wpa2",
81+
"main", "wps", "crypto", "json", "ssl", "pwm", "upgrade",
82+
"smartconfig", "airkiss", "at"
83+
]
84+
)
85+
86+
# copy CCFLAGS to ASFLAGS (-x assembler-with-cpp mode)
87+
env.Append(ASFLAGS=env.get("CCFLAGS", [])[:])
88+
89+
env.Replace(
90+
UPLOAD_ADDRESS="0x40000"
91+
)

builder/frameworks/esp8266-nonos-sdk.py

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,52 @@
3030
FRAMEWORK_DIR = platform.get_package_dir("framework-esp8266-nonos-sdk")
3131
assert isdir(FRAMEWORK_DIR)
3232

33-
env.Prepend(
33+
env.Append(
34+
ASFLAGS=["-x", "assembler-with-cpp"],
35+
36+
CFLAGS=[
37+
"-std=gnu99",
38+
"-Wpointer-arith",
39+
"-Wno-implicit-function-declaration",
40+
"-Wl,-EL",
41+
"-fno-inline-functions",
42+
"-nostdlib"
43+
],
44+
45+
CCFLAGS=[
46+
"-Os", # optimize for size
47+
"-mlongcalls",
48+
"-mtext-section-literals",
49+
"-falign-functions=4",
50+
"-U__STRICT_ANSI__",
51+
"-ffunction-sections",
52+
"-fdata-sections",
53+
"-fno-builtin-printf"
54+
],
55+
56+
CXXFLAGS=[
57+
"-fno-rtti",
58+
"-fno-exceptions",
59+
"-std=c++11"
60+
],
61+
62+
LINKFLAGS=[
63+
"-Os",
64+
"-nostdlib",
65+
"-Wl,--no-check-sections",
66+
"-Wl,-static",
67+
"-Wl,--gc-sections",
68+
"-u", "call_user_start",
69+
"-u", "_printf_float",
70+
"-u", "_scanf_float"
71+
],
72+
73+
CPPDEFINES=[
74+
("F_CPU", "$BOARD_F_CPU"),
75+
"__ets__",
76+
"ICACHE_FLASH"
77+
],
78+
3479
CPPPATH=[
3580
join(FRAMEWORK_DIR, "include"),
3681
join(FRAMEWORK_DIR, "extra_include"),
@@ -43,6 +88,7 @@
4388
join(FRAMEWORK_DIR, "include", "ssl"),
4489
join(FRAMEWORK_DIR, "include", "json"),
4590
join(FRAMEWORK_DIR, "include", "openssl"),
91+
join("$SDK_ESP8266_DIR", "include"), "$PROJECTSRC_DIR"
4692
],
4793

4894
LIBPATH=[
@@ -56,8 +102,12 @@
56102
]
57103
)
58104

105+
# copy CCFLAGS to ASFLAGS (-x assembler-with-cpp mode)
106+
env.Append(ASFLAGS=env.get("CCFLAGS", [])[:])
107+
59108
env.Replace(
60109
LDSCRIPT_PATH=[join(FRAMEWORK_DIR, "ld", "eagle.app.v6.ld")],
110+
UPLOAD_ADDRESS="0x10000"
61111
)
62112

63113
#

builder/frameworks/esp8266-rtos-sdk.py

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,51 @@
3131
FRAMEWORK_DIR = platform.get_package_dir("framework-esp8266-rtos-sdk")
3232
assert isdir(FRAMEWORK_DIR)
3333

34-
env.Prepend(
34+
env.Append(
35+
ASFLAGS=["-x", "assembler-with-cpp"],
36+
37+
CFLAGS=[
38+
"-std=gnu99",
39+
"-Wpointer-arith",
40+
"-Wno-implicit-function-declaration",
41+
"-Wl,-EL",
42+
"-fno-inline-functions",
43+
"-nostdlib"
44+
],
45+
46+
CCFLAGS=[
47+
"-Os", # optimize for size
48+
"-mlongcalls",
49+
"-mtext-section-literals",
50+
"-falign-functions=4",
51+
"-U__STRICT_ANSI__",
52+
"-ffunction-sections",
53+
"-fdata-sections"
54+
],
55+
56+
CXXFLAGS=[
57+
"-fno-rtti",
58+
"-fno-exceptions",
59+
"-std=c++11"
60+
],
61+
62+
LINKFLAGS=[
63+
"-Os",
64+
"-nostdlib",
65+
"-Wl,--no-check-sections",
66+
"-Wl,-static",
67+
"-Wl,--gc-sections",
68+
"-u", "call_user_start",
69+
"-u", "_printf_float",
70+
"-u", "_scanf_float"
71+
],
72+
73+
CPPDEFINES=[
74+
("F_CPU", "$BOARD_F_CPU"),
75+
"__ets__",
76+
"ICACHE_FLASH"
77+
],
78+
3579
CPPPATH=[
3680
join(FRAMEWORK_DIR, "include"),
3781
join(FRAMEWORK_DIR, "extra_include"),
@@ -58,8 +102,12 @@
58102
]
59103
)
60104

105+
# copy CCFLAGS to ASFLAGS (-x assembler-with-cpp mode)
106+
env.Append(ASFLAGS=env.get("CCFLAGS", [])[:])
107+
61108
env.Replace(
62109
LDSCRIPT_PATH=[join(FRAMEWORK_DIR, "ld", "eagle.app.v6.ld")],
110+
UPLOAD_ADDRESS="0x20000"
63111
)
64112

65113
#

builder/main.py

Lines changed: 3 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -141,50 +141,6 @@ def _update_max_upload_size(env):
141141

142142
ARFLAGS=["rc"],
143143

144-
ASFLAGS=["-x", "assembler-with-cpp"],
145-
146-
CFLAGS=[
147-
"-std=gnu99",
148-
"-Wpointer-arith",
149-
"-Wno-implicit-function-declaration",
150-
"-Wl,-EL",
151-
"-fno-inline-functions",
152-
"-nostdlib"
153-
],
154-
155-
CCFLAGS=[
156-
"-Os", # optimize for size
157-
"-mlongcalls",
158-
"-mtext-section-literals",
159-
"-falign-functions=4",
160-
"-U__STRICT_ANSI__",
161-
"-ffunction-sections",
162-
"-fdata-sections"
163-
],
164-
165-
CXXFLAGS=[
166-
"-fno-rtti",
167-
"-fno-exceptions",
168-
"-std=c++11"
169-
],
170-
171-
CPPDEFINES=[
172-
("F_CPU", "$BOARD_F_CPU"),
173-
"__ets__",
174-
"ICACHE_FLASH"
175-
],
176-
177-
LINKFLAGS=[
178-
"-Os",
179-
"-nostdlib",
180-
"-Wl,--no-check-sections",
181-
"-u", "call_user_start",
182-
"-u", "_printf_float",
183-
"-u", "_scanf_float",
184-
"-Wl,-static",
185-
"-Wl,--gc-sections"
186-
],
187-
188144
#
189145
# Packages
190146
#
@@ -230,10 +186,6 @@ def _update_max_upload_size(env):
230186
PROGSUFFIX=".elf"
231187
)
232188

233-
env.Append(
234-
ASFLAGS=env.get("CCFLAGS", [])[:]
235-
)
236-
237189
if int(ARGUMENTS.get("PIOVERBOSE", 0)):
238190
env.Prepend(UPLOADERFLAGS=["-vv"])
239191

@@ -316,47 +268,6 @@ def _update_max_upload_size(env):
316268
env.Replace(UPLOADCMD="$UPLOADOTACMD")
317269

318270
else:
319-
upload_address = None
320-
if env.subst("$PIOFRAMEWORK") == "esp8266-rtos-sdk":
321-
env.Replace(
322-
UPLOAD_ADDRESS="0x20000",
323-
)
324-
325-
# Configure NONOS SDK
326-
elif env.subst("$PIOFRAMEWORK") == "esp8266-nonos-sdk":
327-
env.Append(
328-
CPPPATH=[
329-
join("$SDK_ESP8266_DIR", "include"), "$PROJECTSRC_DIR"
330-
],
331-
CCFLAGS=[
332-
"-fno-builtin-printf",
333-
]
334-
)
335-
env.Replace(
336-
UPLOAD_ADDRESS="0x10000",
337-
)
338-
339-
# Configure Native SDK
340-
else:
341-
env.Append(
342-
CPPPATH=[
343-
join("$SDK_ESP8266_DIR", "include"), "$PROJECTSRC_DIR"
344-
],
345-
346-
LIBPATH=[
347-
join("$SDK_ESP8266_DIR", "lib"),
348-
join("$SDK_ESP8266_DIR", "ld")
349-
],
350-
)
351-
env.Replace(
352-
LIBS=[
353-
"c", "gcc", "phy", "pp", "net80211", "lwip", "wpa", "wpa2",
354-
"main", "wps", "crypto", "json", "ssl", "pwm", "upgrade",
355-
"smartconfig", "airkiss", "at"
356-
],
357-
UPLOAD_ADDRESS="0X40000"
358-
)
359-
360271
# ESP8266 RTOS SDK and Native SDK common configuration
361272
env.Append(
362273
BUILDERS=dict(
@@ -395,6 +306,9 @@ def _update_max_upload_size(env):
395306
UPLOADCMD='$UPLOADER $UPLOADERFLAGS',
396307
)
397308

309+
if not env.get("PIOFRAMEWORK"):
310+
env.SConscript("frameworks/_bare.py", exports="env")
311+
398312
#
399313
# Target: Build executable and linkable firmware or SPIFFS image
400314
#

0 commit comments

Comments
 (0)