include bootstrap utilities

This commit is contained in:
dzaima 2023-03-22 18:51:16 +02:00
parent 39a0cb63c6
commit 66e82f078c
2 changed files with 19 additions and 2 deletions

10
build/bootstrap.bqn Normal file
View File

@ -0,0 +1,10 @@
"bootstrap.bqn: requires an argument of the path to mlochbaum/BQN" ! 1=•args
path •args
prims 1¨•primitives # list of primitive values
g 3 (•Type¨ prims) •primitives # ⟨fns, 1-modifiers, 2-modifiers⟩, each being a pair of character & value
b2 •Import path"/src/bootstrap/boot2.bqn" # step 1: load boot2 with native compiler
b1 •CompObj prims B2 •FChars path"/src/bootstrap/boot1.bqn" # step 2: load boot1 with boot2 + •CompObj
c •CompObj prims, (¨¨g)¨ B1 •FChars path"/src/c.bqn" # step 3: load c.bqn with boot1 + •CompObj
1 •CompObj c # step 4: replace global compiler with the gotten c.bqn
path, "build/bytecodeLocal" •Import "genRuntime" # step 5: generate runtime

View File

@ -39,6 +39,8 @@ shared-c:
@"${MAKE}" i_OUTPUT=libcbqn.so i_SHARED=1 custom=1 run_incremental_0
forbuild:
@"${MAKE}" i_singeli=0 i_CC=cc i_t=forbuild i_f="-O2 -DFOR_BUILD" i_FFI=0 i_OUTPUT=build/obj2/for_build run_incremental_0
for-bootstrap:
@"${MAKE}" i_t=for_bootstrap i_f='-DNATIVE_COMPILER -DONLY_NATIVE_COMP -DFORMATTER=0 -DNO_RT -DNO_EXPLAIN' run_incremental_0 i_USE_BC_SUBMODULE=0 BYTECODE_DIR=bytecodeNone
c:
@"${MAKE}" custom=1 run_incremental_0
@ -136,6 +138,11 @@ BYTECODE_DIR = $(shell if [ -d build/bytecodeLocal ]; then echo bytecodeLocal; e
ifeq ($(BYTECODE_DIR),bytecodeLocal)
custom = 1
endif
ifeq ($(BYTECODE_DIR),bytecodeSubmodule)
ifeq ($(i_USE_BC_SUBMODULE),)
i_USE_BC_SUBMODULE=1
endif
endif
i_LD = $(i_CC)
@ -229,7 +236,7 @@ endif
ifeq ($(REPLXX_DIR),build/replxxSubmodule)
@git submodule update --init build/replxxSubmodule
endif
ifeq ($(BYTECODE_DIR),bytecodeSubmodule)
ifeq ($(i_USE_BC_SUBMODULE),1)
@git submodule update --init build/bytecodeSubmodule
endif
@export bd=$$("${MAKE}" builddir); \
@ -285,7 +292,7 @@ ${bd}/%.o: src/builtins/%.c
$(bd)/load.o: bytecodeMessage
bytecodeMessage:
ifeq ($(BYTECODE_DIR),bytecodeSubmodule)
ifeq ($(i_USE_BC_SUBMODULE),1)
@echo "Using precompiled bytecode; see readme for how to build your own"
endif