mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-05 22:38:44 +00:00
Dunify tutorial
Signed-off-by: Kakadu <Kakadu@pm.me>
This commit is contained in:
parent
3f7f51b2f0
commit
a91f4824c4
6 changed files with 262 additions and 51 deletions
44
tutorial/gen.ml
Normal file
44
tutorial/gen.ml
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
#use "topfind";;
|
||||
#require "str";;
|
||||
let demos = ["Expressions"; "Functions"; "Hello"; "PatternMatching"; "Values"]
|
||||
|
||||
let template = {|
|
||||
(rule
|
||||
(targets %DEMO%.exe)
|
||||
(deps (:lama %DEMOSRC%.lama) %RUNTIME%/runtime.a)
|
||||
(mode
|
||||
(promote (until-clean)))
|
||||
(action
|
||||
(setenv
|
||||
LAMA
|
||||
"%RUNTIME%"
|
||||
(run
|
||||
%{project_root}/src/Driver.exe
|
||||
%EXTRASWITCHES%
|
||||
%{lama}
|
||||
-I
|
||||
%STDLIB%
|
||||
-I
|
||||
%RUNTIME%
|
||||
-o
|
||||
%{targets}))))
|
||||
|}
|
||||
|
||||
let () =
|
||||
Out_channel.with_open_text "dune" (fun ch ->
|
||||
List.iter (fun demo ->
|
||||
template
|
||||
|> Str.global_replace (Str.regexp "%DEMO%") (demo^".x32")
|
||||
|> Str.global_replace (Str.regexp "%DEMOSRC%") demo
|
||||
|> Str.global_replace (Str.regexp "%RUNTIME%") "../runtime32"
|
||||
|> Str.global_replace (Str.regexp "%STDLIB%") "../stdlib/x32"
|
||||
|> Str.global_replace (Str.regexp "%EXTRASWITCHES%") "-march=x86"
|
||||
|> output_string ch;
|
||||
template
|
||||
|> Str.global_replace (Str.regexp "%DEMO%") (demo^".x64")
|
||||
|> Str.global_replace (Str.regexp "%DEMOSRC%") demo
|
||||
|> Str.global_replace (Str.regexp "%RUNTIME%") "../runtime"
|
||||
|> Str.global_replace (Str.regexp "%STDLIB%") "../stdlib/x64"
|
||||
|> Str.global_replace (Str.regexp "%EXTRASWITCHES%") "-march=x86_64"
|
||||
|> output_string ch;
|
||||
) demos)
|
||||
Loading…
Add table
Add a link
Reference in a new issue