Преглед изворни кода

🔨 Fix a PlatformIO debug issue (#24569)

Ivan Kravets пре 2 година
родитељ
комит
5b4af52d04
No account linked to committer's email address

+ 36
- 29
buildroot/share/PlatformIO/scripts/common-cxxflags.py Прегледај датотеку

@@ -2,38 +2,45 @@
2 2
 # common-cxxflags.py
3 3
 # Convenience script to apply customizations to CPP flags
4 4
 #
5
+
5 6
 import pioutil
6 7
 if pioutil.is_pio_build():
7
-	Import("env")
8
+    Import("env")
9
+
10
+    cxxflags = [
11
+        # "-Wno-incompatible-pointer-types",
12
+        # "-Wno-unused-const-variable",
13
+        # "-Wno-maybe-uninitialized",
14
+        # "-Wno-sign-compare"
15
+    ]
16
+    if "teensy" not in env["PIOENV"]:
17
+        cxxflags += ["-Wno-register"]
18
+    env.Append(CXXFLAGS=cxxflags)
19
+
20
+    #
21
+    # Add CPU frequency as a compile time constant instead of a runtime variable
22
+    #
23
+    def add_cpu_freq():
24
+        if "BOARD_F_CPU" in env:
25
+            env["BUILD_FLAGS"].append("-DBOARD_F_CPU=" + env["BOARD_F_CPU"])
8 26
 
9
-	cxxflags = [
10
-		#"-Wno-incompatible-pointer-types",
11
-		#"-Wno-unused-const-variable",
12
-		#"-Wno-maybe-uninitialized",
13
-		#"-Wno-sign-compare"
14
-	]
15
-	if "teensy" not in env['PIOENV']:
16
-		cxxflags += ["-Wno-register"]
17
-	env.Append(CXXFLAGS=cxxflags)
27
+    # Useful for JTAG debugging
28
+    #
29
+    # It will separate release and debug build folders.
30
+    # It useful to keep two live versions: a debug version for debugging and another for
31
+    # release, for flashing when upload is not done automatically by jlink/stlink.
32
+    # Without this, PIO needs to recompile everything twice for any small change.
33
+    if env.GetBuildType() == "debug" and env.get("UPLOAD_PROTOCOL") not in ["jlink", "stlink", "custom"]:
34
+        env["BUILD_DIR"] = "$PROJECT_BUILD_DIR/$PIOENV/debug"
18 35
 
19
-	#
20
-	# Add CPU frequency as a compile time constant instead of a runtime variable
21
-	#
22
-	def add_cpu_freq():
23
-		if 'BOARD_F_CPU' in env:
24
-			env['BUILD_FLAGS'].append('-DBOARD_F_CPU=' + env['BOARD_F_CPU'])
36
+        def on_program_ready(source, target, env):
37
+            import shutil
38
+            shutil.copy(target[0].get_abspath(), env.subst("$PROJECT_BUILD_DIR/$PIOENV"))
25 39
 
26
-	# Useful for JTAG debugging
27
-	#
28
-	# It will separate release and debug build folders.
29
-	# It useful to keep two live versions: a debug version for debugging and another for
30
-	# release, for flashing when upload is not done automatically by jlink/stlink.
31
-	# Without this, PIO needs to recompile everything twice for any small change.
32
-	if env.GetBuildType() == "debug" and env.get('UPLOAD_PROTOCOL') not in ['jlink', 'stlink', 'custom']:
33
-		env['BUILD_DIR'] = '$PROJECT_BUILD_DIR/$PIOENV/debug'
40
+        env.AddPostAction("$PROGPATH", on_program_ready)
34 41
 
35
-	# On some platform, F_CPU is a runtime variable. Since it's used to convert from ns
36
-	# to CPU cycles, this adds overhead preventing small delay (in the order of less than
37
-	# 30 cycles) to be generated correctly. By using a compile time constant instead
38
-	# the compiler will perform the computation and this overhead will be avoided
39
-	add_cpu_freq()
42
+    # On some platform, F_CPU is a runtime variable. Since it's used to convert from ns
43
+    # to CPU cycles, this adds overhead preventing small delay (in the order of less than
44
+    # 30 cycles) to be generated correctly. By using a compile time constant instead
45
+    # the compiler will perform the computation and this overhead will be avoided
46
+    add_cpu_freq()

+ 1
- 0
buildroot/share/PlatformIO/scripts/simulator.py Прегледај датотеку

@@ -2,6 +2,7 @@
2 2
 # simulator.py
3 3
 # PlatformIO pre: script for simulator builds
4 4
 #
5
+
5 6
 import pioutil
6 7
 if pioutil.is_pio_build():
7 8
 	# Get the environment thus far for the build

Loading…
Откажи
Сачувај