Fix ssh command when execited with a wget pipe
[src/xds/xds-server.git] / webapp / src / app / devel / build / build.component.ts
index b7003b1..48a5824 100644 (file)
@@ -23,10 +23,10 @@ export class BuildComponent implements OnInit, AfterViewChecked {
 
     @Input() curProject: IProject;
 
-    buildForm: FormGroup;
-    subpathCtrl = new FormControl("", Validators.required);
-    debugEnable: boolean = false;
-
+    public buildForm: FormGroup;
+    public subpathCtrl = new FormControl("", Validators.required);
+    public debugEnable: boolean = false;
+    public buildIsCollapsed: boolean = false;
     public cmdOutput: string;
     public cmdInfo: string;
 
@@ -43,15 +43,32 @@ export class BuildComponent implements OnInit, AfterViewChecked {
         this.cmdInfo = "";      // TODO: to be remove (only for debug)
         this.buildForm = fb.group({
             subpath: this.subpathCtrl,
+            cmdClean: ["", Validators.nullValidator],
+            cmdPrebuild: ["", Validators.nullValidator],
+            cmdBuild: ["", Validators.nullValidator],
+            cmdPopulate: ["", Validators.nullValidator],
             cmdArgs: ["", Validators.nullValidator],
             envVars: ["", Validators.nullValidator],
         });
     }
 
     ngOnInit() {
+        // Set default settings
+        // TODO save & restore values from cookies
+        this.buildForm.patchValue({
+            subpath: "",
+            cmdClean: "rm -rf build",
+            cmdPrebuild: "mkdir -p build && cd build && cmake ..",
+            cmdBuild: "cd build && make",
+            cmdPopulate: "cd build && make remote-target-populate",
+            cmdArgs: "",
+            envVars: "",
+        });
+
         // Command output data tunneling
         this.xdsSvr.CmdOutput$.subscribe(data => {
-            this.cmdOutput += data.stdout + "\n";
+            this.cmdOutput += data.stdout;
+            this.cmdOutput += data.stderr;
         });
 
         // Command exit
@@ -69,7 +86,7 @@ export class BuildComponent implements OnInit, AfterViewChecked {
         this._scrollToBottom();
 
         // only use for debug
-        this.debugEnable = (this.cookie.get("debug_build") !== "");
+        this.debugEnable = (this.cookie.get("debug_build") === "1");
     }
 
     ngAfterViewChecked() {
@@ -80,9 +97,17 @@ export class BuildComponent implements OnInit, AfterViewChecked {
         this.cmdOutput = '';
     }
 
+    clean() {
+        this._exec(
+            this.buildForm.value.cmdClean,
+            this.buildForm.value.subpath,
+            [],
+            this.buildForm.value.envVars);
+    }
+
     preBuild() {
         this._exec(
-            "mkdir -p build && cd build && cmake ..",
+            this.buildForm.value.cmdPrebuild,
             this.buildForm.value.subpath,
             [],
             this.buildForm.value.envVars);
@@ -90,16 +115,16 @@ export class BuildComponent implements OnInit, AfterViewChecked {
 
     build() {
         this._exec(
-            "cd build && make",
+            this.buildForm.value.cmdBuild,
             this.buildForm.value.subpath,
-            this.buildForm.value.cmdArgs,
+            [],
             this.buildForm.value.envVars
         );
     }
 
     populate() {
         this._exec(
-            "SEB_TODO_script_populate",
+            this.buildForm.value.cmdPopulate,
             this.buildForm.value.subpath,
             [], // args
             this.buildForm.value.envVars
@@ -195,4 +220,4 @@ export class BuildComponent implements OnInit, AfterViewChecked {
     private _outputFooter(): string {
         return "\n";
     }
-}
\ No newline at end of file
+}