Browse Source

Randomize firmware.bin, fix unflag

Scott Lahteine 3 years ago
parent
commit
d0222e5c76

+ 15
- 15
buildroot/share/PlatformIO/scripts/common-dependencies.py View File

@@ -47,22 +47,25 @@ def get_all_known_libs():
47 47
 
48 48
 def get_all_env_libs():
49 49
 	env_libs = []
50
-	lib_deps = env.GetProjectOption("lib_deps")
50
+	lib_deps = env.GetProjectOption('lib_deps')
51 51
 	for dep in lib_deps:
52 52
 		name, _, _ = PackageManager.parse_pkg_uri(dep)
53 53
 		env_libs.append(name)
54 54
 	return env_libs
55 55
 
56
+def set_env_field(field, value):
57
+	proj = env.GetProjectConfig()
58
+	proj.set("env:" + env['PIOENV'], field, value)
59
+
56 60
 # All unused libs should be ignored so that if a library
57 61
 # exists in .pio/lib_deps it will not break compilation.
58 62
 def force_ignore_unused_libs():
59 63
 	env_libs = get_all_env_libs()
60 64
 	known_libs = get_all_known_libs()
61 65
 	diff = (list(set(known_libs) - set(env_libs)))
62
-	lib_ignore = env.GetProjectOption("lib_ignore") + diff
66
+	lib_ignore = env.GetProjectOption('lib_ignore') + diff
63 67
 	print("Ignoring libs:", lib_ignore)
64
-	proj = env.GetProjectConfig()
65
-	proj.set("env:" + env["PIOENV"], "lib_ignore", lib_ignore)
68
+	set_env_field('lib_ignore', lib_ignore)
66 69
 
67 70
 def install_features_dependencies():
68 71
 	load_config()
@@ -80,14 +83,14 @@ def install_features_dependencies():
80 83
 				deps_to_add[name] = dep
81 84
 
82 85
 			# Does the env already have the dependency?
83
-			deps = env.GetProjectOption("lib_deps")
86
+			deps = env.GetProjectOption('lib_deps')
84 87
 			for dep in deps:
85 88
 				name, _, _ = PackageManager.parse_pkg_uri(dep)
86 89
 				if name in deps_to_add:
87 90
 					del deps_to_add[name]
88 91
 
89 92
 			# Are there any libraries that should be ignored?
90
-			lib_ignore = env.GetProjectOption("lib_ignore")
93
+			lib_ignore = env.GetProjectOption('lib_ignore')
91 94
 			for dep in deps:
92 95
 				name, _, _ = PackageManager.parse_pkg_uri(dep)
93 96
 				if name in deps_to_add:
@@ -96,8 +99,7 @@ def install_features_dependencies():
96 99
 			# Is there anything left?
97 100
 			if len(deps_to_add) > 0:
98 101
 				# Only add the missing dependencies
99
-				proj = env.GetProjectConfig()
100
-				proj.set("env:" + env["PIOENV"], "lib_deps", deps + list(deps_to_add.values()))
102
+				set_env_field('lib_deps', deps + list(deps_to_add.values()))
101 103
 
102 104
 		if 'extra_scripts' in FEATURE_DEPENDENCIES[feature]:
103 105
 			print("Executing extra_scripts for %s... " % feature)
@@ -105,8 +107,7 @@ def install_features_dependencies():
105 107
 
106 108
 		if 'src_filter' in FEATURE_DEPENDENCIES[feature]:
107 109
 			print("Adding src_filter for %s... " % feature)
108
-			proj = env.GetProjectConfig()
109
-			src_filter = ' '.join(env.GetProjectOption("src_filter"))
110
+			src_filter = ' '.join(env.GetProjectOption('src_filter'))
110 111
 			# first we need to remove the references to the same folder
111 112
 			my_srcs = re.findall( r'[+-](<.*?>)', FEATURE_DEPENDENCIES[feature]['src_filter'])
112 113
 			cur_srcs = re.findall( r'[+-](<.*?>)', src_filter)
@@ -115,19 +116,18 @@ def install_features_dependencies():
115 116
 					src_filter = re.sub(r'[+-]' + d, '', src_filter)
116 117
 
117 118
 			src_filter = FEATURE_DEPENDENCIES[feature]['src_filter'] + ' ' + src_filter
118
-			proj.set("env:" + env["PIOENV"], "src_filter", [src_filter])
119
+			set_env_field('src_filter', [src_filter])
119 120
 			env.Replace(SRC_FILTER=src_filter)
120 121
 
121 122
 		if 'lib_ignore' in FEATURE_DEPENDENCIES[feature]:
122 123
 			print("Ignoring libs for %s... " % feature)
123
-			lib_ignore = env.GetProjectOption("lib_ignore") + [FEATURE_DEPENDENCIES[feature]['lib_ignore']]
124
-			proj = env.GetProjectConfig()
125
-			proj.set("env:" + env["PIOENV"], "lib_ignore", lib_ignore)
124
+			lib_ignore = env.GetProjectOption('lib_ignore') + [FEATURE_DEPENDENCIES[feature]['lib_ignore']]
125
+			set_env_field('lib_ignore', lib_ignore)
126 126
 
127 127
 #
128 128
 # Find a compiler, considering the OS
129 129
 #
130
-ENV_BUILD_PATH = os.path.join(env.Dictionary("PROJECT_BUILD_DIR"), env["PIOENV"])
130
+ENV_BUILD_PATH = os.path.join(env.Dictionary('PROJECT_BUILD_DIR'), env['PIOENV'])
131 131
 GCC_PATH_CACHE = os.path.join(ENV_BUILD_PATH, ".gcc_path")
132 132
 def search_compiler():
133 133
 	if os.path.exists(GCC_PATH_CACHE):

+ 5
- 4
buildroot/share/PlatformIO/scripts/creality.py View File

@@ -5,12 +5,13 @@ Import("env")
5 5
 for define in env['CPPDEFINES']:
6 6
     if define[0] == "VECT_TAB_ADDR":
7 7
         env['CPPDEFINES'].remove(define)
8
+
8 9
 env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000"))
9 10
 
10 11
 custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/creality.ld")
11
-for i, flag in enumerate(env["LINKFLAGS"]):
12
+
13
+for i, flag in enumerate(env['LINKFLAGS']):
12 14
     if "-Wl,-T" in flag:
13
-        env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script
15
+        env['LINKFLAGS'][i] = "-Wl,-T" + custom_ld_script
14 16
     elif flag == "-T":
15
-        env["LINKFLAGS"][i + 1] = custom_ld_script
16
-
17
+        env['LINKFLAGS'][i + 1] = custom_ld_script

+ 5
- 0
buildroot/share/PlatformIO/scripts/random-bin.py View File

@@ -0,0 +1,5 @@
1
+Import("env")
2
+
3
+from datetime import datetime
4
+
5
+env['PROGNAME'] = datetime.now().strftime("firmware-%Y%m%d-%H%M%S")

+ 2
- 1
platformio.ini View File

@@ -380,7 +380,7 @@ src_filter    = ${common.default_src_filter} +<src/HAL/STM32>
380 380
 platform      = ${common_stm32.platform}
381 381
 build_flags   = !python Marlin/src/HAL/STM32F1/build_flags.py
382 382
   ${common.build_flags} -std=gnu++14 -DHAVE_SW_SERIAL
383
-build_unflags = -std=gnu++11
383
+build_unflags = -std=gnu11
384 384
 src_filter    = ${common.default_src_filter} +<src/HAL/STM32F1>
385 385
 lib_ignore    = SPI
386 386
 lib_deps      = ${common.lib_deps}
@@ -744,6 +744,7 @@ board           = genericSTM32F103RC
744 744
 build_flags     = !python Marlin/src/HAL/STM32F1/build_flags.py
745 745
   ${common.build_flags} -std=gnu++14 -DSTM32_XL_DENSITY -DTEMP_TIMER_CHAN=4
746 746
 extra_scripts   = ${common.extra_scripts}
747
+  pre:buildroot/share/PlatformIO/scripts/random-bin.py
747 748
   buildroot/share/PlatformIO/scripts/creality.py
748 749
 lib_ignore      = ${common_stm32f1.lib_ignore}
749 750
 debug_tool      = jlink

Loading…
Cancel
Save