about summary refs log tree commit diff stats
path: root/build0
blob: 2cc4766dd55e98b619ae2457d31bd2f7facf5e86 (plain) (blame)
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
#!/bin/sh
# Compile mu from scratch.

set -v
set -e  # stop immediately on error

cd tangle
  # auto-generate various lists (ending in '_list' by convention) {
  # list of types
  {
    grep -h "^struct .* {" [0-9]*.cc  |sed 's/\(struct *[^ ]*\).*/\1;/'
    grep -h "^typedef " [0-9]*.cc
  }  > type_list
  # list of function declarations, so I can define them in any order
  grep -h "^[^ #].*) {" [0-9]*.cc  |sed 's/ {.*/;/'  > function_list
  # list of code files to compile
  ls [0-9]*.cc  |grep -v "\.test\.cc$"  |sed 's/.*/#include "&"/'  > file_list
  # list of test files to compile
  ls [0-9]*.test.cc  |sed 's/.*/#include "&"/'  > test_file_list
  # list of tests to run
  grep -h "^[[:space:]]*void test_" [0-9]*.cc  |sed 's/^\s*void \(.*\)() {$/\1,/'  > test_list
  grep -h "^\s*void test_" [0-9]*.cc  |sed 's/^\s*void \(.*\)() {.*/"\1",/'  > test_name_list
  # }
  # Now that we have all the _lists, compile 'tangle'
  g++ -g -O2 boot.cc -o tangle
  ./tangle test
cd ..

cd termbox
  gcc -g -O2 -c termbox.c
  gcc -g -O2 -c utf8.c
  ar rcs libtermbox.a *.o
cd ..

./tangle/tangle [0-9]*.cc > mu.cc
# auto-generate function declarations, so I can define them in any order
# functions start out unindented, have all args on the same line, and end in ') {'
#
#                                      \/ ignore methods
grep -h "^[^[:space:]#].*) {$" mu.cc  |grep -v ":.*("  |sed 's/ {.*/;/'  > function_list
# auto-generate list of tests to run
grep -h "^\s*void test_" mu.cc  |sed 's/^\s*void \(.*\)() {.*/\1,/'  > test_list
grep -h "^\s*void test_" mu.cc  |sed 's/^\s*void \(.*\)() {.*/"\1",/'  > test_name_list
g++ -g -O2 mu.cc termbox/libtermbox.a -o mu_bin

cat [0-9]*.mu > core.mu
t;pre id='vimCodeElement'> <span class="Comment"># example program: managing the display using 'screen' objects</span> <span class="Comment"># The zero screen below means 'use the real screen'. Tests can also use fake</span> <span class="Comment"># screens.</span> <span class="muRecipe">def</span> main [ open-console <span class="Constant">10</span>:char<span class="Special"> &lt;- </span>copy <span class="Constant">97/a</span> print <span class="Constant">0/screen</span>, <span class="Constant">10</span>:char/a, <span class="Constant">2/red</span> <span class="Constant">1</span>:num/<span class="Special">raw</span>, <span class="Constant">2</span>:num/<span class="Special">raw &lt;- </span>cursor-position <span class="Constant">0/screen</span> wait-for-event <span class="Constant">0/console</span> clear-screen <span class="Constant">0/screen</span> move-cursor <span class="Constant">0/screen</span>, <span class="Constant">0/row</span>, <span class="Constant">4/column</span> <span class="Constant">10</span>:char<span class="Special"> &lt;- </span>copy <span class="Constant">98/b</span> print <span class="Constant">0/screen</span>, <span class="Constant">10</span>:char wait-for-event <span class="Constant">0/console</span> move-cursor <span class="Constant">0/screen</span>, <span class="Constant">0/row</span>, <span class="Constant">0/column</span> clear-line <span class="Constant">0/screen</span> wait-for-event <span class="Constant">0/console</span> cursor-down <span class="Constant">0/screen</span> wait-for-event <span class="Constant">0/console</span> cursor-right <span class="Constant">0/screen</span> wait-for-event <span class="Constant">0/console</span> cursor-left <span class="Constant">0/screen</span> wait-for-event <span class="Constant">0/console</span> cursor-up <span class="Constant">0/screen</span> wait-for-event <span class="Constant">0/console</span> close-console ] </pre> </body> </html> <!-- vim: set foldmethod=manual : -->