示例#1
0
        public MergeSet ConvertMergeSet(BuildSet bset)
        {
            MergeSet mset = new MergeSet();
            mset.src_zip = bset.zip_path;
            mset.start_bin = Path.GetFileName(bset.default_python_bin);
            mset.start_src = Path.GetFileNameWithoutExtension(bset.source_path) + bset.default_src_ex;
            mset.start_argv = bset.default_argv;
            mset.version = bset.py_version;
            mset.icon_path = bset.icon_path;
            mset.output_path = bset.output_path;
            mset.use_cache = bset.cache;
            mset.onefile = bset.one_file;
            mset.out_bin = !bset.standalone;
            mset.Decision();

            return mset;
        }
示例#2
0
        /// <summary>
        /// Start Build
        /// </summary>
        /// <param name="args">Default Args</param>
        static void Main_build(string[] args)
        {
            bset = new BuildSet(path);
            if (path.EndsWith(@"\Scripts") & File.Exists(path.Replace(@"\Scripts", "") + @"\python.exe"))
            {
                bset.python_path = path.Replace(@"\Scripts", "");
            }
            for (int i = 0; i < args.Length; i++)
            {
                try
                {
                    if (args[i] == "-src" | args[i] == "-s")
                    {
                        bset.source_path = args[++i];                                      // Set source code file path.
                    }
                    else if (args[i] == "-py" | args[i] == "-p")
                    {
                        bset.python_path = args[++i];                                          // Set Python folder path.
                    }
                    else if (args[i] == "-out" | args[i] == "-o")
                    {
                        bset.output_path = args[++i];                                           // Set binary saving path.
                    }
                    else if (args[i] == "-icon" | args[i] == "-I")
                    {
                        bset.icon_path = args[++i];                                            // Set icon path.
                    }
                    else if (args[i] == "-argv" | args[i] == "-a")
                    {
                        bset.default_argv = args[++i];                                            // Set fixed argv data.
                    }
                    else if (args[i] == "-file" | args[i] == "-f")
                    {
                        bset.module_path.Add(args[++i]);                                            // Set added file path.
                    }
                    else if (args[i] == "-dir" | args[i] == "-d")
                    {
                        bset.add_modules.Add(args[++i]);                                           // Set added folder path.
                    }
                    else if (args[i] == "-import" | args[i] == "-i")
                    {
                        bset.base_module.Add("import " + args[++i]);                                              // Set imported Python modules.
                    }
                    else if (args[i] == "-pyfile" | args[i] == "-pf")
                    {
                        bset.import_pyfile_list.Add(args[++i]);                                               // Set Python file name.
                    }
                    else if (args[i] == "-pydir" | args[i] == "-pd")
                    {
                        bset.import_pydir_list.Add(args[++i]);                                              // Set Python folder name.
                    }
                    else if (args[i] == "-pymodule" | args[i] == "-pm")
                    {
                        bset.add_pymodules_list.AddRange(args[++i].Split(','));                                                 // Set Python module name.
                    }
                    else if (args[i] == "-resfile" | args[i] == "-rf")
                    {
                        bset.resource_file.AddRange(args[++i].Split(','));                                                // Set resource file name.
                    }
                    else if (args[i] == "-resdir" | args[i] == "-rd")
                    {
                        bset.resource_folder.AddRange(args[++i].Split(','));                                               // Set resource folder name.
                    }
                    else if (args[i] == "-exclude" | args[i] == "-e")
                    {
                        bset.except_file_list.Add(args[++i]);                                               // Set excluding Python module file.
                    }
                    else if (args[i] == "-pyver" | args[i] == "-pv")
                    {
                        bset.pyver = args[++i];
                    }
                    else if (args[i].StartsWith("-comp"))
                    {
                        bset.compress = int.Parse(args[i].Split('=')[1]);                                   // Set compression levels.
                    }
                    else if (args[i] == "--no-cache")
                    {
                        bset.cache = false;                               // Do not use cache.
                    }
                    else if (args[i] == "--debug")
                    {
                        bset.debug = true;                            // Use debug mode.
                    }
                    else if (args[i] == "--dll-out")
                    {
                        bset.dll_out = true;                              // Dll file out mode.
                    }
                    else if (args[i] == "--all-includes")
                    {
                        bset.all_imports = true;                                   // Include all python modules.
                    }
                    else if (args[i] == "--hide")
                    {
                        bset.show_window = false;                           // Do not show Console.
                    }
                    else if (args[i] == "--all-search")
                    {
                        bset.all_search = true;                                 // All module search.
                    }
                    else if (args[i] == "--research")
                    {
                        bset.search_files = true;                               // More search modules mode.
                    }
                    else if (args[i] == "--zip-out")
                    {
                        bset.zip_out = true;                              // Only output zip file.
                    }
                    else if (args[i] == "--wait-key")
                    {
                        wait_key = true;                               // Wait for pressed any keys.
                    }
                    else if (args[i] == "--no-rev")
                    {
                        bset.add_fixed = false;                             // Do not fix the file path.
                    }
                    else if (args[i] == "--part-enc")
                    {
                        bset.all_encodes = false;                               // Only use part of encodings.
                    }
                    else if (args[i] == "--no-log")
                    {
                        logger = false;                             // Do not take a log.
                    }
                    else if (args[i] == "--no-hooks")
                    {
                        bset.hooks = false;                               // Do not use module-hooks.
                    }
                    else if (args[i] == "--no-onefile")
                    {
                        bset.one_file = false;                                 // Do not make one file.
                    }
                    else if (args[i] == "--optimize")
                    {
                        bset.optimize = true;                               // Optimize Python files
                    }
                    else if (args[i] == "--check-only")
                    {
                        bset.check_only = true;                                 // Check module list only
                    }
                    else if (args[i] == "--no-standalone")
                    {
                        bset.standalone = false;
                    }
                    else if (args[i] == "-build")
                    {
                    }
                    else
                    {
                        Console.WriteLine("[!] No named command options: " + args[i]);
                    }
                }
                catch (Exception) { }
            }
            bset.Decision(); // Get python version and get any paths.
            Console.Title = "pyDotexe " + version + " - Build: " + bset.source_path;
            if (bset.check_only)
            {
                Console.Title = Console.Title + " (Path)";
            }
            else if (bset.debug)
            {
                Console.Title = Console.Title + " (Debug)";
            }
            else if (bset.zip_out)
            {
                Console.Title = Console.Title + " (ZIP-Out)";
            }
            if (logger)
            {
                Main_make_log(args, "pyDotexe_Build_log.txt");         // Write logs.
            }
            // check data, analysis and build.
            if (!Builder.CheckFiles.Start(ref bset))
            {
                return;
            }
            if (!Builder.Analysis.Start(ref bset))
            {
                return;
            }
            if (!Builder.Build.Start(ref bset))
            {
                return;
            }
            GC.Collect();

            // Build successful.
            Console.WriteLine("\a\r\n[+] Build succeeded! (Python " + bset.py_version_raw + ".x)");
            Console.WriteLine("[*] " + bset.output_path);
            if (bset.copy_error.Count > 0)
            {
                Console.WriteLine("\r\n[-] Some files could not be copied.");
                foreach (string error_data in bset.copy_error)
                {
                    Console.WriteLine(" - " + error_data);
                }
            }
            if (bset.delete_error_list.Count > 0)
            {
                Console.WriteLine("\r\n[-] Some files could not be deleted.");
                foreach (string error_data in bset.copy_error)
                {
                    Console.WriteLine(" - " + error_data);
                }
            }
        }