@@ -156,13 +156,13 @@ def project_name(self):
156156 return (self ._project_name or
157157 os .path .basename (os .path .abspath (self .project_dir ())))
158158
159- def sub_output_pattern (self , pattern ):
159+ def sub_output_pattern (self , pattern , tag_dict = None ):
160160 """
161161 Substitute patterns for setting values
162162 """
163163 byte_pattern = bytearray (pattern .encode ())
164164
165- val_dict = self .get_tag_value_dict ()
165+ val_dict = tag_dict or self .get_tag_value_dict ()
166166
167167 start = 0
168168 end = 0
@@ -197,8 +197,7 @@ def sub_output_pattern(self, pattern):
197197
198198 i += 1
199199
200- return str (byte_pattern , 'utf-8' ).replace ('/' , '_' ).replace ('\\ ' , '_' )
201-
200+ return str (byte_pattern , 'utf-8' )
202201
203202 def get_tag_dict (self ):
204203 """
@@ -217,6 +216,10 @@ def get_tag_dict(self):
217216 setting = setting_group [key ]
218217 tag_dict [setting .display_name ] = '%(' + key + ')'
219218
219+ tag_dict ['System' ] = '%(system)'
220+ tag_dict ['Architecture' ] = '%(arch)'
221+ tag_dict ['Short System' ] = '%(sys)'
222+
220223 return tag_dict
221224
222225 def get_tag_value_dict (self ):
@@ -677,7 +680,7 @@ def clean_dirs(self, *dirs):
677680 if not os .path .exists (directory ):
678681 os .makedirs (directory )
679682
680- def get_export_dest (self , ex_setting , output_dir ):
683+ def get_export_path (self , ex_setting , name_pattern ):
681684 """Get the export destination path using the export setting
682685
683686 Args:
@@ -687,9 +690,20 @@ def get_export_dest(self, ex_setting, output_dir):
687690 Returns:
688691 A path to store the output files
689692 """
690- export_dest = utils .path_join (output_dir , ex_setting .name )
691693
692- return export_dest
694+ tag_dict = {
695+ '%(system)' : ex_setting .system ,
696+ '%(sys)' : ex_setting .short_system ,
697+ '%(arch)' : ex_setting .arch ,
698+ '%(platform)' : ex_setting .name
699+ }
700+
701+ dest = self .sub_output_pattern (name_pattern , tag_dict )
702+
703+ if dest == name_pattern :
704+ dest = utils .path_join (name_pattern , ex_setting .name )
705+
706+ return dest
693707
694708 def copy_export_files (self , ex_setting , export_dest ):
695709 """Copy the export files to the destination path
@@ -749,13 +763,12 @@ def replace_plist(self, app_path):
749763 plistlib .writePlist (plist_dict , plist_path )
750764
751765 def process_mac_setting (self , app_loc , export_dest ,
752- ex_setting , uncompressed ):
766+ ex_setting ):
753767 """Process the Mac settings
754768
755769 Args:
756770 app_loc: the app's location
757771 export_dest: the destination to export the app to
758- uncompressed: boolean -> app is compressed or not
759772 """
760773
761774 app_path = utils .path_join (export_dest ,
@@ -775,7 +788,7 @@ def process_mac_setting(self, app_loc, export_dest,
775788
776789 app_nw_res = utils .path_join (resource_path , 'app.nw' )
777790
778- if uncompressed :
791+ if self . uncompressed :
779792 utils .copytree (app_loc , app_nw_res )
780793 else :
781794 utils .copy (app_loc , app_nw_res )
@@ -792,7 +805,7 @@ def process_mac_setting(self, app_loc, export_dest,
792805
793806
794807 def process_win_linux_setting (self , app_loc , export_dest ,
795- ex_setting , uncompressed ):
808+ ex_setting ):
796809 """Processes windows and linux settings
797810
798811 Creates executable, modifies exe icon, and copies to the destination
@@ -801,7 +814,6 @@ def process_win_linux_setting(self, app_loc, export_dest,
801814 app_loc: the location of the app
802815 export_dest: directory to copy app to
803816 ex_setting: the export setting (eg: mac-x32)
804- uncompressed: boolean -> app is compressed or not
805817
806818 """
807819
@@ -822,7 +834,7 @@ def process_win_linux_setting(self, app_loc, export_dest,
822834 self .make_desktop_file (dest_binary_path , export_dest )
823835
824836 self .copy_executable (export_dest , dest_binary_path ,
825- nw_path , app_loc , uncompressed )
837+ nw_path , app_loc )
826838
827839 self .set_executable (dest_binary_path )
828840
@@ -831,8 +843,7 @@ def process_win_linux_setting(self, app_loc, export_dest,
831843 if os .path .exists (nw_path ):
832844 os .remove (nw_path )
833845
834- def process_export_setting (self , ex_setting , output_dir ,
835- temp_dir , app_loc , uncompressed ):
846+ def process_export_setting (self , ex_setting , output_name ):
836847 """Create the executable based on the export setting"""
837848 if ex_setting .value :
838849 self .progress_text = '\n '
@@ -841,45 +852,44 @@ def process_export_setting(self, ex_setting, output_dir,
841852
842853 self .progress_text = 'Making files for {}...' .format (name )
843854
844- export_dest = self .get_export_dest (ex_setting , output_dir )
855+ temp_dir = utils .path_join (config .TEMP_DIR , 'webexectemp' )
856+
857+ name_path = self .get_export_path (ex_setting , output_name )
858+ output_dir = utils .path_join (self .output_dir (), name_path )
859+ self .clean_dirs (temp_dir , output_dir )
860+ app_loc = self .get_app_nw_loc (temp_dir , output_dir )
845861
846- self .copy_export_files (ex_setting , export_dest )
862+ self .copy_export_files (ex_setting , output_dir )
847863
848864 self .progress_text += '.'
849865
850866 if 'mac' in ex_setting .name :
851- self .process_mac_setting (app_loc , export_dest , ex_setting ,
852- uncompressed )
867+ self .process_mac_setting (app_loc , output_dir , ex_setting )
853868 else :
854- self .process_win_linux_setting (app_loc , export_dest ,
855- ex_setting , uncompressed )
869+ self .process_win_linux_setting (app_loc , output_dir ,
870+ ex_setting )
856871
857872
858873 def make_output_dirs (self , write_json = True ):
859874 """Create the output directories for the application to be copied"""
860875
861876 output_name = self .sub_pattern () or self .project_name ()
862877
863- output_dir = utils .path_join (self .output_dir (), output_name )
864- temp_dir = utils .path_join (config .TEMP_DIR , 'webexectemp' )
865-
866878 self .progress_text = 'Making new directories...\n '
867879
868- self .clean_dirs (temp_dir , output_dir )
869-
870880 self .copy_files_to_project_folder ()
871881
872882 if write_json :
873883 self .write_package_json ()
874884
875- app_loc = self .get_app_nw_loc (temp_dir , output_dir )
885+ for ex_setting in self .settings ['export_settings' ].values ():
886+ self .process_export_setting (ex_setting , output_name )
876887
888+ @property
889+ def uncompressed (self ):
890+ """Returns true if the exported app is to be uncompressed"""
877891 uncomp_setting = self .get_setting ('uncompressed_folder' )
878- uncompressed = uncomp_setting .value
879-
880- for ex_setting in self .settings ['export_settings' ].values ():
881- self .process_export_setting (ex_setting , output_dir , temp_dir ,
882- app_loc , uncompressed )
892+ return uncomp_setting .value
883893
884894 def sub_pattern (self ):
885895 """Returns the output pattern substitution or an empty string"""
@@ -903,10 +913,7 @@ def get_app_nw_loc(self, temp_dir, output_dir):
903913 """Copy the temporary app to the output_dir"""
904914 app_file = utils .path_join (temp_dir , self .project_name ()+ '.nw' )
905915
906- uncomp_setting = self .get_setting ('uncompressed_folder' )
907- uncompressed = uncomp_setting .value
908-
909- if uncompressed :
916+ if self .uncompressed :
910917 app_nw_folder = utils .path_join (temp_dir ,
911918 self .project_name ()+ '.nwf' )
912919
@@ -931,12 +938,12 @@ def get_version_tuple(self):
931938 return [int (s ) for s in strs ]
932939
933940 def copy_executable (self , export_path , dest_path ,
934- nw_path , app_loc , uncompressed ):
941+ nw_path , app_loc ):
935942 """
936943 Merge the zip file into the exe and copy it to the destination path
937944 """
938945 package_loc = utils .path_join (export_path , 'package.nw' )
939- if uncompressed :
946+ if self . uncompressed :
940947 utils .copytree (app_loc , package_loc )
941948 utils .copy (nw_path , dest_path )
942949 else :
0 commit comments