DEADSOFTWARE

Remove batch
[gpcp-linux.git] / gpcp / MsilAsmNative.cp
1 (* ============================================================ *)
2 (** Interface to the ILASM Byte-code assembler. *)
3 (* Copyright (c) John Gough 1999 -- 2002. *)
4 (* K John Gough, 10th June 1999 *)
5 (* Modifications: *)
6 (* Version for GPCP V0.3 April 2000 (kjg) *)
7 (* ============================================================ *)
9 MODULE MsilAsm;
10 IMPORT
11 RTS,
12 Console,
13 CompState,
14 GPCPcopyright,
15 Diag := "[System]System.Diagnostics";
17 VAR asm : Diag.Process;
19 PROCEDURE Init*();
20 BEGIN
21 IF asm = NIL THEN
22 NEW(asm);
23 asm.get_StartInfo().set_FileName("ilasm");
24 asm.get_StartInfo().set_CreateNoWindow(TRUE);
25 asm.get_StartInfo().set_UseShellExecute(FALSE);
26 END;
27 END Init;
29 PROCEDURE Assemble*(IN file : ARRAY OF CHAR;
30 IN optn : ARRAY OF CHAR; (* "/debug" or "" *)
31 main : BOOLEAN); (* /exe or /dll *)
32 VAR retCode : INTEGER;
33 optNm : RTS.NativeString;
34 suffx : RTS.NativeString;
35 fName : RTS.NativeString;
36 ignore : BOOLEAN;
37 BEGIN
38 fName := MKSTR(file);
39 IF main THEN
40 optNm := "/exe "; suffx := ".exe";
41 ELSE
42 optNm := "/dll "; suffx := ".dll";
43 END;
44 optNm := optNm + MKSTR(optn) + " ";
45 asm.get_StartInfo().set_Arguments(optNm+"/nologo /quiet "+fName+".il");
46 ignore := asm.Start();
47 asm.WaitForExit();
48 retCode := asm.get_ExitCode();
49 IF retCode # 0 THEN
50 Console.WriteString("#gpcp: ilasm FAILED");
51 Console.WriteInt(retCode, 0);
52 ELSIF ~CompState.quiet THEN
53 Console.WriteString("#gpcp: Created " + fName + suffx);
54 END;
55 Console.WriteLn;
56 END Assemble;
58 PROCEDURE DoAsm*(IN file : ARRAY OF CHAR;
59 IN optn : ARRAY OF CHAR; (* "/debug" or "" *)
60 main : BOOLEAN; (* /exe or /dll *)
61 vbse : BOOLEAN; (* verbose or not *)
62 OUT rslt : INTEGER); (* ilasm ret-code *)
63 VAR optNm : RTS.NativeString;
64 suffx : RTS.NativeString;
65 fName : RTS.NativeString;
66 ignore : BOOLEAN;
67 BEGIN
68 fName := MKSTR(file);
69 IF main THEN
70 optNm := "/exe "; suffx := ".exe";
71 ELSE
72 optNm := "/dll "; suffx := ".dll";
73 END;
74 optNm := optNm + MKSTR(optn) + " ";
75 IF vbse THEN
76 asm.get_StartInfo().set_CreateNoWindow(FALSE);
77 asm.get_StartInfo().set_Arguments(optNm + "/nologo " + fName + ".il");
78 ELSE
79 asm.get_StartInfo().set_CreateNoWindow(TRUE);
80 asm.get_StartInfo().set_Arguments(optNm+"/nologo /quiet "+fName+".il");
81 END;
82 ignore := asm.Start();
83 asm.WaitForExit();
84 rslt := asm.get_ExitCode();
85 IF rslt = 0 THEN
86 Console.WriteString("#gpcp: Created " + fName + suffx); Console.WriteLn;
87 END;
88 END DoAsm;
90 END MsilAsm.