/// <summary> /// 빌드를 진행합니다. /// </summary> /// <param name="successCallback"></param> public void Build(Config config, Action successCallback) { _config = config; Thread worker = new Thread(new ThreadStart(() => { // 출력 폴더에 APK 파일을 저장합니다. string targetFolder = DataManager.Instance.GetRootDirectory(); string tempDir = Directory.GetCurrentDirectory(); // 타겟 폴더를 현재 경로로 설정합니다. Directory.SetCurrentDirectory(targetFolder); // 폴더를 생성합니다 bool isValid = Create(); isValid = DataManager.Instance.IsValidPath(targetFolder); // 다시 되돌립니다. Directory.SetCurrentDirectory(tempDir); if (isValid) { // [Start Build] //System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); //sw.Start(); Make(filename => { AddAndroidPlatform(); AddPlugins(); WriteConfig(); CreateKeyStore(); Requirements(); if (DataMan.Instance.Use) { ExcludeUnusedFiles(); } else { CopyProjectFiles(); } ModifyHtmlFiles(); // HTML 파일에 cordova 바인드 용 스크립트 문을 추가합니다. ExportBuildJson(filename); Flush(); // 빌드를 시작합니다. successCallback(); }); // [End Build] //sw.Stop(); //AppendText(sw.Elapsed.ToString()); } else { throw new FileNotFoundException("There contains non-ASCII characters in the File Path!"); } })); worker.Start(); }
/// <summary> /// 빌드 처리 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonBuild_Click(object sender, EventArgs e) { if (buttonBuild.Enabled && textBoxPassWord.Text.Length < 6 && !_isWorking) { MessageBox.Show("The password value must enter at least 6 digits.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // 빌드 중이 아닐 때에만 빌드가 가능함 if (buttonBuild.Enabled && !_isWorking) { _isWorking = true; buttonBuild.Enabled = false; var config = new Data.FormData.Config() { folderName = textBoxFolderName.Text, keyPath = textBoxKeyPath.Text, gameName = textBoxGameName.Text, keyAlias = textBoxKeyAlias.Text, passWord = textBoxPassWord.Text, packageName = textBoxPackageName.Text, keyOU = textBox_keyOU.Text, keyO = textBox_keyO.Text, keyL = textBox_keyL.Text, keyS = textBox_keyS.Text, keyC = textBox_keyC.Text, orientation = comboBoxOrientation.SelectedItem.ToString(), fullscreen = comboBoxFullscreen.SelectedItem.ToString(), minSdkVersion = comboBoxMinSdkVersion.SelectedItem.ToString(), targetSdkVersion = comboBoxTargetSdkVersion.SelectedItem.ToString(), settingGameFolder = textBoxSettingGameFolder.Text, buildMode = comboBoxBuildMode.SelectedIndex, compileSdkVersion = comboBoxCompileSdkVersion.SelectedItem.ToString(), plugins = listBoxPlugins.Items.Cast <String>().ToList(), }; // 빌드 후 일부 프로세스가 정리되지 않는 경우가 있다 (JDK 등) // 그때 워커가 종료되고 다시 버튼이 활성화되는 지 여부를 확인하기 위해 토글 처리를 하였다 _cordova.Build(config, () => { Action completeBuild = () => { // 빌드가 끝이 났으므로 빌드 버튼을 다시 활성화 한다. buttonBuild.Enabled = true; _isWorking = false; // TODO: "RPG Maker MV Cordova Builder"/YourApplication/android/app/build/outputs/apk/release/ string buildMode = (config.buildMode == 0) ? "release" : "debug"; string targetPath = System.IO.Path.Combine(DataManager.Instance.GetRootDirectory(), textBoxFolderName.Text, "platforms", "android", "app", "build", "outputs", "apk", buildMode); if (System.IO.Directory.Exists(targetPath)) { System.Diagnostics.Process.Start(targetPath); } }; if (InvokeRequired) { Invoke(completeBuild); } else { completeBuild(); } }); } }