Commit 198562b4 authored by John van Groningen's avatar John van Groningen

port batch build to linux

parent 0601e960
definition module Platform
PlatformDependant win mac :== win
DirSeparator:=='/'
DirSeparatorString:=="/"
application_path :: !{#Char} -> {#Char}
implementation module Platform;
import StdEnv;
application_path :: !{#Char} -> {#Char};
application_path file_name
# s_p = get_appl_path_address;
# end_p = c_string_end s_p;
# s = {c_string_char p \\ p<-[s_p..end_p-1]}
= s+++("/"+++file_name);
c_string_end :: !Int -> Int;
c_string_end p
| c_string_char p<>'\0'
= c_string_end (p+1);
= p;
c_string_char :: !Int -> Char;
c_string_char p = code inline {
load_ui8 0
}
get_appl_path_address :: Int;
get_appl_path_address = code {
pushLc appl_path
}
definition module PmCleanSystem
from StdFile import ::Files
from UtilStrictLists import ::List
from PmTypes import ::CodeGenOptions,::Processor,::ApplicationOptions,::LinkMethod
from PmCompilerOptions import ::CompilerOptions,::ListTypes
import StdOverloaded
import StdPathname
import PmCallBack
:: CompilerProcessIds
:: CompileOrCheckSyntax = SyntaxCheck | Compilation
:: StartedCodeGenerator
:: CompilePollCompletedResult = NoFinishedCompiler | UnknownFinishedCompiler | FinishedCompiler !Int !Int
:: CodeGenerateAsmOrCode = AsmGeneration | CodeGeneration
:: CompilingInfo
:: CompilerMsg
= CompilerOK
| SyntaxError
| Patherror Pathname
:: WindowFun env :== ([String]) -> env -> env
instance == CompileOrCheckSyntax
instance == CodeGenerateAsmOrCode
NoCompilerProcessIds :: CompilerProcessIds
standardStaticLibraries :: !Processor !LinkMethod -> List String
standardObjectFiles :: !Bool !Bool !Processor !Bool -> List String
getLibs :: ![String] !*Files -> (!(![String],![String]),!*Files)
CompileHandleExitCode :: !Int !String !String !Int !(WindowFun *env) !(WindowFun *env) !Pathname
!ListTypes !*env -> (!Pathname,!CompilerMsg,!*env) | FileEnv env
InitCompilingInfo :: *CompilingInfo
Compile :: !String !Bool !Bool !(WindowFun *env) !(WindowFun *env) !CompileOrCheckSyntax !Pathname
!(List Pathname) !Bool !Bool !Bool !CompilerOptions !Pathname !CompilerProcessIds !*env
-> (!Pathname,!CompilerMsg,!CompilerProcessIds,!*env)
| FileEnv env
CompilePersistent ::
!String !Bool !(WindowFun *env) !(WindowFun *env) !CompileOrCheckSyntax !Pathname
!(List Pathname) !Bool !Bool !Bool !CompilerOptions !Pathname !*CompilingInfo !*env
-> (!*CompilingInfo,!(!*env, !Pathname, !CompilerMsg))
| FileEnv env
CompileStartCommand ::
!String !Bool !(WindowFun *env) !CompileOrCheckSyntax !Pathname
!(List Pathname) !Int !Bool !Bool !Bool !CompilerOptions !Pathname !CompilerProcessIds !*env
-> (!Bool,!CompilerProcessIds,!*env)
| FileEnv env
ExitCleanCompiler :: !*(!*CompilingInfo,*env) -> *(!*CompilingInfo,*env)
QuitCleanCompiler :: !Bool !CompilerProcessIds !*World -> *World
CodeGen :: !String !Bool !(WindowFun *GeneralSt) !CodeGenerateAsmOrCode !Pathname !Bool
!CodeGenOptions !Processor !ApplicationOptions !Pathname !CompilerProcessIds !*GeneralSt
-> (!Pathname,!Bool,!CompilerProcessIds,!*GeneralSt)
start_code_generator :: !String !(WindowFun *GeneralSt) !Pathname !Int !Bool !CodeGenOptions !Processor !Pathname !*GeneralSt
-> (!Bool,!Int/*HANDLE*/,!StartedCodeGenerator,!*GeneralSt)
wait_for_finished_code_generator :: !{#Int} !*GeneralSt -> (!Int,!Int,!*GeneralSt)
finish_code_generator :: !Int/*HANDLE*/ !StartedCodeGenerator !Int !(WindowFun *GeneralSt) !*GeneralSt -> (!Bool,!*GeneralSt)
Link :: !String !(WindowFun *GeneralSt) !Pathname !ApplicationOptions
!Pathname !(List Pathname) !(List Pathname) !(List Pathname) !Bool !Bool !Bool !Bool !String
!Bool !String !Pathname !String !Processor !Bool !*GeneralSt
-> (!*GeneralSt,!Bool)
DelayEventLoop :: !.ps -> .ps
CompilePollCompleted :: !CompilerProcessIds !*env -> (!CompilePollCompletedResult, !*env) | FileEnv env
ClearCompilerCache :: .a
ClearCompilerCaches :: .a
SendRepeatResult :: .a
StartCodeGenerator :: .a
Execute` :: .a
This diff is collapsed.
definition module UtilIO
from StdFile import ::Files
from UtilDate import ::DATE
GetFullApplicationPath :: !*Files -> (!{#Char},!*Files)
GetLongPathName :: !{#Char} -> {#Char}
FModified :: !String !Files -> (!DATE, !Files);
FExists :: .a
implementation module UtilIO;
import StdEnv;
from UtilDate import ::DATE(..);
GetFullApplicationPath :: !*Files -> (!{#Char},!*Files);
GetFullApplicationPath files
# s_p = get_appl_path_address;
# (s,s_p) = c_string_to_clean_string s_p;
= (s,files);
c_string_to_clean_string :: !Int -> (!.{#Char},!Int);
c_string_to_clean_string s_p
# end_p = c_string_end s_p;
= ({c_string_char p \\ p<-[s_p..end_p-1]},s_p);
c_string_end :: !Int -> Int;
c_string_end p
| c_string_char p<>'\0'
= c_string_end (p+1);
= p;
c_string_char :: !Int -> Char;
c_string_char p = code inline {
load_ui8 0
}
get_appl_path_address :: Int;
get_appl_path_address = code {
pushLc appl_path
}
GetLongPathName :: !{#Char} -> {#Char};
GetLongPathName p
# s_p = realpath (p+++"\0") 0;
| s_p==0
= p;
# (s,s_p) = c_string_to_clean_string s_p
# r = free s_p
| r>=0
= s;
= s;
FModified :: !String !Files -> (!DATE, !Files);
FModified name files
# s = createArray (IF_INT_64_OR_32 144 88) '\0';
# r = stat (name+++"\0") s;
| r<>0
= ({exists=False, yy=0, mm=0, dd=0, h=0, m=0, s=0}, files);
# struct_tm = localtime (IF_INT_64_OR_32 (s % (88,95)) (s % (64,67)));
| struct_tm==0
= ({exists=False, yy=0, mm=0, dd=0, h=0, m=0, s=0}, files);
= (IF_INT_64_OR_32 (struct_tm_to_DATE_64 struct_tm) (struct_tm_to_DATE_32 struct_tm) , files);
{
struct_tm_to_DATE_64 struct_tm
# sec_min=load_long (struct_tm+0);
# sec=(sec_min<<32)>>32;
# min=sec_min>>32;
# hour_day=load_long (struct_tm+8);
# hour=(hour_day<<32)>>32;
# day=hour_day>>32;
# mon_year=load_long (struct_tm+16);
# mon=((mon_year<<32)>>32)+1;
# year=(mon_year>>32)+1900;
= {exists=True, yy=year, mm=mon, dd=day, h=hour, m=min, s=sec};
struct_tm_to_DATE_32 struct_tm
# sec=load_long (struct_tm+0);
# min=load_long (struct_tm+4);
# hour=load_long (struct_tm+8);
# day=load_long (struct_tm+12);
# mon=load_long (struct_tm+16)+1;
# year=load_long (struct_tm+20)+1900;
= {exists=True, yy=year, mm=mon, dd=day, h=hour, m=min, s=sec};
}
stat :: !{#Char} !{#Char} -> Int;
stat file_name stat_struct
= code {
ccall stat "ss:p"
}
localtime :: !{#Char} -> Int;
localtime time_t_p
= code {
ccall localtime "s:p"
}
load_long :: !Int -> Int;
load_long p = code {
load_i 0
}
realpath :: !{#Char} !Int -> Int;
realpath path resolved_path = code {
ccall realpath "sI:I"
}
free :: !Int -> Int;
free p = code {
ccall free "p:I"
}
FExists :: .a;
FExists = abort "FExists";
definition module UtilNewlinesFile
from StdClass import class ==, class toString
:: NewlineConvention
= NewlineConventionNone | NewlineConventionMac | NewlineConventionUnix | NewlineConventionDos
HostNativeNewlineConvention :== NewlineConventionUnix
instance == NewlineConvention
instance toString NewlineConvention
// read a line with any newline convention
// the file should have been opened with mode FReadData
// the line returned ends with one '\n' (except for the last line)
readAnyLine :: !*File -> (NewlineConvention, !.{#Char}, !*File)
// same as readAnyLine, but discards newline convention (compatible with freadline)
readLine file
:== (line, file`)
where
(_, line, file`)
= readAnyLine file
// write a line with a specified newline convention
// the first argument is the line
// (only the last character of the line is inspected for a newline character,
// their shouldn't be any newlines in the middle of the line)
// the second argument is the newline string
// the file should have been opened with mode FWriteData
writeAnyLine :: !{#Char} !{#Char} !*File -> *File
convertLine :: !*{#Char} -> (NewlineConvention, *{#Char})
readConvLines :: !*File -> (NewlineConvention,[String],*File)
implementation module UtilNewlinesFile
import StdFile, StdInt, StdChar, StdString, StdArray, StdBool, StdClass, StdTuple, StdMisc
// simple sequence operator
(:-) infixl 0
(:-) f a
:== a f
:: NewlineConvention
= NewlineConventionNone
| NewlineConventionMac
| NewlineConventionUnix
| NewlineConventionDos
HostNativeNewlineConvention :== NewlineConventionUnix
instance == NewlineConvention where
(==) NewlineConventionNone NewlineConventionNone
= True
(==) NewlineConventionMac NewlineConventionMac
= True
(==) NewlineConventionUnix NewlineConventionUnix
= True
(==) NewlineConventionDos NewlineConventionDos
= True
(==) _ _
= False
instance toString NewlineConvention where
toString NewlineConventionNone
= ""
toString NewlineConventionMac
= "\xd"
toString NewlineConventionUnix
= "\xa"
toString NewlineConventionDos
= "\xd\xa"
// slice that returns a unique array
(%.) infixl 9 :: !.{#Char} !(!Int,!Int) -> .{#Char}
(%.) string indices
= code
{
.inline %.
.d 1 2 ii
jsr sliceAC
.o 1 0
.end
}
// this should be added to the Clean rts, so that the string doesn't have to be copied
downSize :: Int *{#Char} -> *{#Char}
downSize newSize string
= string %. (0, newSize-1)
convertLine :: !*{#Char} -> (NewlineConvention, *{#Char})
convertLine line
#! maxIndex
= size line - 1
| maxIndex >= 0
#! lastChar
= line.[maxIndex]
| lastChar == '\xa'
| maxIndex >= 1
#! lastButOneChar
= line.[maxIndex-1]
| lastButOneChar == '\xd'
= (NewlineConventionDos, {downSize maxIndex line & [maxIndex-1] = '\n'})
// otherwise
= (NewlineConventionUnix, {line & [maxIndex] = '\n'})
// otherwise
= (NewlineConventionUnix, {line & [maxIndex] = '\n'})
| lastChar == '\xd'
= (NewlineConventionMac, {line & [maxIndex] = '\n'})
// otherwise
= (NewlineConventionNone, line)
// otherwise
= (NewlineConventionNone, line)
readAnyLine :: !*File -> (NewlineConvention, !.{#Char}, !*File)
readAnyLine file
# (line, file)
= freadline file
(convention, line)
= convertLine line
= (convention, line, file)
readLine file
:== (line, file`)
where
(_, line, file`)
= readAnyLine file
writeAnyLine :: !{#Char} !{#Char} !*File -> *File
writeAnyLine line newlineString file
# maxIndex
= size line - 1
lastChar
= line.[maxIndex]
| maxIndex >= 0 && lastChar == '\n'
= file :- fwrites (line %. (0, maxIndex-1)) :- fwrites newlineString
// otherwise
= file :- fwrites line
//--
readConvLines :: !*File -> (NewlineConvention,[String],*File)
readConvLines file
# (conv,line,more,file) = readAnyLine` file
(eof, file) = fend file
| eof
| more // last line ends in a newline?
= (conv,[line,""], file)
= (conv,[line], file)
# (_,lines,file) = readConvLines file
= (conv,[line:lines], file)
//readAnyLine` :: !*File -> (NewlineConvention, !.{#Char}, !*File)
readAnyLine` file
# (line, file) = freadline file
#! maxIndex = size line - 1
| maxIndex >= 0
# lastChar = line.[maxIndex]
| lastChar == '\xa'
| maxIndex >= 1
# lastButOneChar = line.[maxIndex-1]
| lastButOneChar == '\xd'
= (NewlineConventionDos, downSize (dec maxIndex) line, True, file)
= (NewlineConventionUnix, downSize maxIndex line, True, file)
= (NewlineConventionUnix, downSize maxIndex line, True, file)
| lastChar == '\xd'
= (NewlineConventionMac, downSize maxIndex line, True, file)
= (NewlineConventionNone, line, False, file)
= (NewlineConventionNone, line, False, file)
definition module set_return_code
set_return_code_world :: !Int !*World -> *World
implementation module set_return_code
import StdMisc
set_return_code_world :: !Int !*World -> *World
set_return_code_world _ w = abort "set_return_code_world"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment