@@ -813,50 +813,42 @@ def relative_object_path(self, build_path, base_dir, source):
813
813
mkdir (obj_dir )
814
814
return join (obj_dir , name + '.o' )
815
815
816
- # Generate response file for all includes.
817
- # ARM, GCC, IAR cross compatible
816
+ def make_option_file (self , options , naming = ".options_{}.txt" ):
817
+ """ Generate a via file for a pile of defines
818
+ ARM, GCC, IAR cross compatible
819
+ """
820
+ option_md5 = md5 (' ' .join (options ).encode ('utf-8' )).hexdigest ()
821
+ via_file = join (self .build_dir , naming .format (option_md5 ))
822
+ if not exists (via_file ):
823
+ with open (via_file , "w" ) as fd :
824
+ string = " " .join (options )
825
+ fd .write (string )
826
+ return via_file
827
+
818
828
def get_inc_file (self , includes ):
819
- include_file = join (self .build_dir , ".includes_%s.txt" % self .inc_md5 )
820
- if not exists (include_file ):
821
- with open (include_file , "w" ) as f :
822
- cmd_list = []
823
- for c in includes :
824
- if c :
825
- c = c .replace ("\\ " , "/" )
826
- if self .CHROOT :
827
- c = c .replace (self .CHROOT , '' )
828
- cmd_list .append ('"-I%s"' % c )
829
- string = " " .join (cmd_list )
830
- f .write (string )
831
- return include_file
832
-
833
- # Generate response file for all objects when linking.
834
- # ARM, GCC, IAR cross compatible
829
+ """Generate a via file for all includes.
830
+ ARM, GCC, IAR cross compatible
831
+ """
832
+ cmd_list = ("-I{}" .format (c .replace ("\\ " , "/" )) for c in includes if c )
833
+ if self .CHROOT :
834
+ cmd_list = (c .replace (self .CHROOT , '' ) for c in cmd_list )
835
+ return self .make_option_file (list (cmd_list ), naming = ".includes_{}.txt" )
836
+
835
837
def get_link_file (self , cmd ):
836
- link_file = join (self .build_dir , ".link_files.txt" )
837
- with open (link_file , "w" ) as f :
838
- cmd_list = []
839
- for c in cmd :
840
- if c :
841
- c = c .replace ("\\ " , "/" )
842
- if self .CHROOT :
843
- c = c .replace (self .CHROOT , '' )
844
- cmd_list .append (('"%s"' % c ) if not c .startswith ('-' ) else c )
845
- string = " " .join (cmd_list )
846
- f .write (string )
847
- return link_file
848
-
849
- # Generate response file for all objects when archiving.
850
- # ARM, GCC, IAR cross compatible
838
+ """Generate a via file for all objects when linking.
839
+ ARM, GCC, IAR cross compatible
840
+ """
841
+ cmd_list = (c .replace ("\\ " , "/" ) for c in cmd if c )
842
+ if self .CHROOT :
843
+ cmd_list = (c .replace (self .CHROOT , '' ) for c in cmd_list )
844
+ return self .make_option_file (list (cmd_list ), naming = ".link_options.txt" )
845
+
851
846
def get_arch_file (self , objects ):
852
- archive_file = join (self .build_dir , ".archive_files.txt" )
853
- with open (archive_file , "w" ) as f :
854
- o_list = []
855
- for o in objects :
856
- o_list .append ('"%s"' % o )
857
- string = " " .join (o_list ).replace ("\\ " , "/" )
858
- f .write (string )
859
- return archive_file
847
+ """ Generate a via file for all objects when archiving.
848
+ ARM, GCC, IAR cross compatible
849
+ """
850
+ cmd_list = (c .replace ("\\ " , "/" ) for c in objects if c )
851
+ return self .make_option_file (list (cmd_list ), ".archive_files.txt" )
860
852
861
853
# THIS METHOD IS BEING CALLED BY THE MBED ONLINE BUILD SYSTEM
862
854
# ANY CHANGE OF PARAMETERS OR RETURN VALUES WILL BREAK COMPATIBILITY
0 commit comments