瀏覽代碼

Randomize firmware.bin, fix unflag

Scott Lahteine 4 年之前
父節點
當前提交
d0222e5c76

+ 15
- 15
buildroot/share/PlatformIO/scripts/common-dependencies.py 查看文件

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

+ 5
- 4
buildroot/share/PlatformIO/scripts/creality.py 查看文件

5
 for define in env['CPPDEFINES']:
5
 for define in env['CPPDEFINES']:
6
     if define[0] == "VECT_TAB_ADDR":
6
     if define[0] == "VECT_TAB_ADDR":
7
         env['CPPDEFINES'].remove(define)
7
         env['CPPDEFINES'].remove(define)
8
+
8
 env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000"))
9
 env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000"))
9
 
10
 
10
 custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/creality.ld")
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
     if "-Wl,-T" in flag:
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
     elif flag == "-T":
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 查看文件

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 查看文件

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

Loading…
取消
儲存