-
Notifications
You must be signed in to change notification settings - Fork 2
/
shellscript.fs
71 lines (61 loc) · 3.29 KB
/
shellscript.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
(*
Copyright (c) 2022 Jun-ichiro Sugisaka
This software is released under the MIT License.
http://opensource.org/licenses/mit-license.php
*)
namespace Aqualis
module shellscript =
open System.IO
open System.Text
type Shell(dir:string,project:string,nproc:int) =
let mutable id = 0
let mutable w =
[|for i in 1..nproc -> new StreamWriter(dir+"\\shell_"+project+"_"+i.ToString("00")+".sh",false,Encoding.Default) |]
do
for i in 1..nproc do
w.[i-1].Write("#!bin/bash"+"\n\n")
member private this.nextid() =
id <- id + 1
if id = nproc then id <- 0
///<summary>
///<p>ソースファイルのコンパイル・実行するスクリプトファイルを生成</p>
///</summary>
member this.AddProcess() =
match AqualisCompiler.lang with
|F ->
w.[id].Write("sh proc_"+AqualisCompiler.projname+"_F.sh"+"\n")
this.nextid()
|C ->
w.[id].Write("sh proc_"+AqualisCompiler.projname+"_C.sh"+"\n")
this.nextid()
|T ->
()
|H ->
()
///<summary>
///<p>ソースファイルのコンパイル・実行するスクリプトファイルを生成</p>
///<p>エラーがある場合はメール送信</p>
///<p>終了後、実行時間をメール送信</p>
///</summary>
///<param name="address">メールアドレス</param>
member __.AddProcess (address:string) =
match AqualisCompiler.lang with
|F ->
w.[id].Write("echo project "+AqualisCompiler.projname+" started | mail -s ProcessNotification "+address+"\n")
w.[id].Write("(time " + "sh proc_"+AqualisCompiler.projname+".sh" + ") > "+AqualisCompiler.projname+".log "+"&"+"> "+AqualisCompiler.projname+"_time.log\n")
w.[id].Write("(echo project "+AqualisCompiler.projname+" finished | cat - "+AqualisCompiler.projname+"_time.log) | mail -s ProcessNotification "+address+"\n")
|C ->
w.[id].Write("echo project "+AqualisCompiler.projname+" started | mail -s ProcessNotification "+address+"\n")
w.[id].Write("(time " + "sh proc_"+AqualisCompiler.projname+"_C.sh" + ") > "+AqualisCompiler.projname+".log "+"&"+"> "+AqualisCompiler.projname+"_time.log\n")
w.[id].Write("(echo project "+AqualisCompiler.projname+" finished | cat - "+AqualisCompiler.projname+"_time.log) | mail -s ProcessNotification "+address+"\n")
|T ->
()
|H ->
()
member __.Close() =
for i in 1..nproc do
w.[i-1].Close()
let makeShellScript (dir:string) (project:string) (n:int) code =
let proc = new Shell(dir,project,n)
code proc
proc.Close()