| author | traytel | 
| Thu, 11 Mar 2021 10:25:04 +0100 | |
| changeset 73408 | be11fe268b33 | 
| parent 73263 | ad60214bef09 | 
| child 73586 | 76d0b6597c91 | 
| permissions | -rw-r--r-- | 
| 62508 
d0b68218ea55
discontinued RAW session: bootstrap directly from isabelle_process RAW_ML_SYSTEM;
 wenzelm parents: 
62468diff
changeset | 1 | (* Title: Pure/ML/ml_system.ML | 
| 43948 | 2 | Author: Makarius | 
| 3 | ||
| 48416 | 4 | ML system and platform operations. | 
| 43948 | 5 | *) | 
| 6 | ||
| 7 | signature ML_SYSTEM = | |
| 8 | sig | |
| 9 | val name: string | |
| 10 | val platform: string | |
| 60962 
faa452d8e265
basic setup for native Windows (RAW session without image);
 wenzelm parents: 
48416diff
changeset | 11 | val platform_is_windows: bool | 
| 69701 | 12 | val platform_is_64: bool | 
| 72535 | 13 | val platform_is_arm: bool | 
| 62468 | 14 | val platform_path: string -> string | 
| 15 | val standard_path: string -> string | |
| 43948 | 16 | end; | 
| 17 | ||
| 18 | structure ML_System: ML_SYSTEM = | |
| 19 | struct | |
| 20 | ||
| 21 | val SOME name = OS.Process.getEnv "ML_SYSTEM"; | |
| 22 | val SOME platform = OS.Process.getEnv "ML_PLATFORM"; | |
| 60962 
faa452d8e265
basic setup for native Windows (RAW session without image);
 wenzelm parents: 
48416diff
changeset | 23 | val platform_is_windows = String.isSuffix "windows" platform; | 
| 69701 | 24 | val platform_is_64 = String.isPrefix "x86_64-" platform; | 
| 72535 | 25 | val platform_is_arm = String.isPrefix "arm64-" platform; | 
| 43948 | 26 | |
| 62468 | 27 | val platform_path = | 
| 28 | if platform_is_windows then | |
| 29 | fn path => | |
| 30 | if String.isPrefix "/" path andalso not (String.isPrefix "//" path) then | |
| 31 | (case String.tokens (fn c => c = #"/") path of | |
| 32 | "cygdrive" :: drive :: arcs => | |
| 33 | let | |
| 34 | val vol = | |
| 35 | (case Char.fromString drive of | |
| 36 | NONE => drive ^ ":" | |
| 37 | | SOME d => String.str (Char.toUpper d) ^ ":"); | |
| 38 | in String.concatWith "\\" (vol :: arcs) end | |
| 39 | | arcs => | |
| 40 | (case OS.Process.getEnv "CYGWIN_ROOT" of | |
| 41 | SOME root => OS.Path.concat (root, String.concatWith "\\" arcs) | |
| 42 | | NONE => raise Fail "Unknown environment variable CYGWIN_ROOT")) | |
| 43 | else String.translate (fn #"/" => "\\" | c => String.str c) path | |
| 44 | else fn path => path; | |
| 45 | ||
| 46 | val standard_path = | |
| 47 | if platform_is_windows then | |
| 48 | fn path => | |
| 49 | let | |
| 50 |         val {vol, arcs, isAbs} = OS.Path.fromString path;
 | |
| 51 | val path' = String.translate (fn #"\\" => "/" | c => String.str c) path; | |
| 52 | in | |
| 53 | if isAbs then | |
| 54 | (case String.explode vol of | |
| 55 | [d, #":"] => | |
| 56 |               String.concatWith "/" ("/cygdrive" :: String.str (Char.toLower d) :: arcs)
 | |
| 57 | | _ => path') | |
| 58 | else path' | |
| 59 | end | |
| 60 | else fn path => path; | |
| 61 | ||
| 43948 | 62 | end; |