keep log record && auto create iso

This commit is contained in:
slore 2018-11-22 02:01:09 +08:00
parent bab2b838e8
commit a36107d78f
10 changed files with 59 additions and 18 deletions

View File

@ -294,11 +294,15 @@ if ($IE_VER == '9+') {
<div>
<button class="pure-button" onclick="cleanup()">0-cleanup</button>
<button class="pure-button" id="build" onclick="run_build()">1-run</button>
<button class="pure-button" id="build" onclick="exec_build()">1-exec</button>
<button class="pure-button" id="build" onclick="exec_build()">1-exec(log)</button>
<button class="pure-button" id="build" onclick="make_iso()">2-make_iso</button>
<input type="checkbox" id="wb_auto_makeiso" /><span class="i18n-text">Create ISO after building</span>
</div>
<div id="build_stdout" style="overflow:scroll;margin-top:10px">stdout</div>
<div>
<button class="pure-button i18n-text" onclick="OpenFolder(_log_path)">Open log folder</button>
<button class="pure-button i18n-text" onclick="OpenFile(_log_path + '\\last_wimbuilder.log')">Open last build log</button>
<div>
<div>
<button class="pure-button pre-button" onclick="$('#menu_patch').click()">&lt;pre</button>
<button class="pure-button next-button" onclick="$('#menu_about').click()">next&gt;</button>

View File

@ -33,7 +33,10 @@ function load_text_file(filename, format) {
if (!fso.FileExists(filename)) return '';
if (format == null) format = TristateFalse;
var objFile = fso.OpenTextFile(filename, ForReading, false, format);
var text = objFile.readall();
var text = '';
if (!objFile.AtEndOfStream) {
text = objFile.ReadAll();
}
objFile.close();
return text;
}

View File

@ -18,5 +18,9 @@ function BrowseFolder(msg) {
}
function OpenFolder(path) {
Run(path);
if (fso.FolderExists(path)) Run(path);
}
function OpenFile(path) {
if (fso.FileExists(path)) Run(path);
}

View File

@ -37,6 +37,8 @@ $i18n = {
"Continue":"继续",
"Cancel":"取消",
"Create ISO after building":" 构建后立即创建ISO",
"Open log folder":"打开日志文件夹",
"Open last build log":"打开最后一次构建日志",
"Please select a project:":"请选择工程:",
"Project Information":"工程信息",
"#LASTDUMMY#":""

View File

@ -1,5 +1,7 @@
var x_auto_drive = '-';
var _in_building = '';
var _stdout_len = 0;
var _log_path = '';
function build_page_init() {
$('#build_stdout').empty();
@ -15,6 +17,8 @@ function build_page_init() {
$("input[name='wb_x_drive'][type='radio'][value='" + $wb_x_drv + "']").prop("checked", true);
x_drive_detect();
$("#wb_auto_makeiso").prop("checked", $wb_auto_makeiso);
var env = wsh.Environment("PROCESS");
_log_path = env('Factory') + '\\log\\' + selected_project;
}
$("input[name='wb_x_drive'][type='radio']").click(function() {
@ -82,8 +86,6 @@ function _cleanup() {
$('#build_stdout').empty();
structure_env(1);
var oExec = wsh.exec('bin\\_cleanup.bat');
var stdout = null;
var b = null;
window.setTimeout(function(){wsh.AppActivate('Wim Builder');}, 500);
update_output(oExec);
}
@ -149,14 +151,21 @@ function run_build(no_confirm) {
}
$('#build_stdout').empty();
structure_env(0);
if ($wb_auto_makeiso) {
structure_env(1);
} else {
structure_env(0);
}
dump_patches_selected();
dump_patches_opt();
var cmd_mode = "/k";
if ($wb_auto_makeiso) cmd_mode = "/c";
_in_building = 'run_build';
wsh.run('cmd ' + cmd_mode + ' \"' + $wb_root + '\\bin\\_process.bat\"', 1, true);
//if ($wb_auto_makeiso) make_iso();
if ($wb_auto_makeiso) {
wsh.run('NSudoC.exe -UseCurrentConsole -Wait -U:T "' + $wb_root + '\\bin\\_process.bat\"', 1, true);
make_iso(true);
} else {
wsh.run('cmd ' + cmd_mode + ' \"' + $wb_root + '\\bin\\_process.bat\"', 1, true);
}
}
function exec_build(no_confirm) {
@ -179,19 +188,20 @@ function exec_build(no_confirm) {
dump_patches_selected();
dump_patches_opt();
_in_building = 'exec_build';
var oExec = wsh.exec($wb_root + '\\bin\\_process.bat');
var stdout = null;
var b = null;
var logfile = _log_path + '\\last_wimbuilder.log';
var oExec = wsh.exec('NSudoC.exe -UseCurrentConsole -Wait -U:T "' + $wb_root + '\\bin\\_process.bat" 1>"' + logfile + '" 2>&1');
window.setTimeout(function(){wsh.AppActivate('Wim Builder');}, 500);
update_output(oExec);
update_output_by_log(oExec);
}
function make_iso() {
function make_iso(keep) {
if (selected_project == null) {
alert('Please select a project for building.');
return;
}
$('#build_stdout').empty();
if (!keep) {
$('#build_stdout').empty();
}
structure_env(0);
wsh.run('cmd /c \"' + $wb_root + '\\bin\\_MakeBootISO.bat\"', 1, true);
}
@ -227,3 +237,19 @@ function update_output(oExec) {
window.setTimeout(function(){update_output(oExec);}, 100);
}
function update_output_by_log(oExec) {
var build_stdout = $('#build_stdout');
var logfile = _log_path + '\\last_wimbuilder.log';
var text = load_text_file(logfile);
text = text.replace(/([\r\n]+)/g, '<br/>');
build_stdout.html(text);
build_stdout.scrollTop(build_stdout[0].scrollHeight);
if (oExec.status != 0) {
if ($wb_auto_makeiso) {
window.setTimeout(function(){make_iso(true);}, 1000);
}
return;
}
window.setTimeout(function(){update_output_by_log(oExec);}, 100);
}

View File

@ -4,10 +4,11 @@ SETLOCAL ENABLEDELAYEDEXPANSION
cd /d "%WB_ROOT%"
title WimBuilder(%cd%)
if "x%_WB_EXEC_MODE%"=="x1" set WB_RUNAS_TI=1
if "x%WB_RUNAS_TI%"=="x" (
set WB_RUNAS_TI=1
call NSudo.exe -U:T "%~0"
exit
NSudoC.exe -UseCurrentConsole -U:T "%~0"
goto :EOF
)
title WimBuilder(%cd%)
@ -48,6 +49,7 @@ if exist "%_WB_TMP_DIR%\_patches_opt.bat" (
call "%_WB_TMP_DIR%\_patches_opt.bat"
)
echo.
rem ";" can't be pass to CALL LABEL, so use a ":" for it
call :CLOG 97:104m "[%WB_PROJECT%] --- build information"
set WB_
@ -189,7 +191,7 @@ rem =========================================================
call :CLEANUP 0
call WIM_Exporter "%_WB_PE_WIM%"
call exit
goto :EOF
rem =========================================================

Binary file not shown.

BIN
bin/x64/NSudoC.exe Normal file

Binary file not shown.

Binary file not shown.

BIN
bin/x86/NSudoC.exe Normal file

Binary file not shown.