build/build-using makefile targets

This commit is contained in:
dzaima 2023-03-25 00:02:47 +02:00
parent 37a32eb15a
commit b02be62486
2 changed files with 68 additions and 14 deletions

View File

@ -1,11 +1,8 @@
t0g •MonoTime@
#!build/obj2/for_build
# to emulate on makefile transition: NO_LDL → rm_lf=-ldl; no_fPIC → rm_f=-fPIC; something something PIE
# todo:
# clean
# clangd commands generation
# forcing bytecode/singeli/replxx directories to whatever's applicable
# when adding `make forbuild` in build/build, make it run a sanity check of the output before copying to build/obj2/for_build
Spawn, WaitForOne •Import "fork.bqn"
Serialize, Deserialize •Import "serialize.bqn"
@ -15,6 +12,12 @@ t0g ← •MonoTime@
# 1: toggle
# 2: flag list
opts
# makefile compatibility options:
1, "from-makefile", 0, @
2, "LD_LIBS", @, @
1, "NO_LDL", 0, @
1, "no_fPIC", 0, @
0, "j", @, "Number of parallel jobs"
1, "verbose", 0, "Log more things"
1, "rebuild", 0, "Forcibly rebuild everything"
@ -72,6 +75,14 @@ Lowercase ← {𝕩 - (-´"Aa")×(𝕩≥'A')∧𝕩≤'Z'}
getOpt {
args ר/ •args
treq (args¨<"v=") '='=¯1¨args
compat (<"from-makefile") args
{
compat? args (¬treq)/ ; # makefile will leave things like "shared=" if the envvar was empty; build/build by default sees this as "shared=1", but we want to ignore it
{𝕊: "Error: Trailing '=' for an option"} _assert_¬ ´treq
}
[ot, on0, od, oh] >opts
on Lowercase¨ on0
@ -83,12 +94,11 @@ getOpt ← {
whereas 'f+=-a -b' adds one flag that contains a space.
Options:
"∾∾oh {" "∾𝕩∾" "𝕨@+10}¨((´¨)(¨))((@¨oh)/) on0
•Exit 0
•Exit 0
} ´ "help""h""?"'-'/¨ •args
ot1 1=ot
ot2 2=ot
s1 '='¨ args # start of =
hs s1<¨args # has value
fl hs'+'=(0s1-1)¨args # is appended flag, i.e. "f+=a b c"
@ -142,6 +152,7 @@ po ← { # parsed options
CBQNc, ccColor, singeliFlags, REPLXXc, Linker
compat GetOpt "from-makefile"
custom GetOpt "c"
clangd GetOpt "clangd"
DOpt {@,𝕨 GetOpt 𝕩}
@ -159,7 +170,7 @@ po ← { # parsed options
native 0 DOpt "native"
emcc GetOpt "emcc"
wasi GetOpt "wasi"
versionName GetOpt "v"
versionName {compat shared? @; "0"@ GetOpt "v"}
{𝕊: "Error: Specifying version for shared build is useless"}_assert_¬ shared versionName@
wasm wasiemcc
@ -197,8 +208,9 @@ po ← { # parsed options
exportSymbols ffishared
defLibs @GetOpt "LD_LIBS"
GetLibs { 𝕊:
getLibs {
getLibs (1)(¬defLibs) {
¬ffi? ,;
GetOpt "pkgconfig"? 0= •SH1 "pkg-config""--exists""libffi"?
{SepArgs ¯1SH"pkg-config",𝕩,"libffi"}¨ "--cflags", "--libs";
@ -250,7 +262,7 @@ po ← { # parsed options
args ( exportSymbols) / "-DCBQN_EXPORT"
args ( ¬pie) / "-fno-pie"
args ( pie ¬shared) / "-fPIE"
args ( shared) / "-fPIC", "-DCBQN_SHARED"
args ( shared) / "-DCBQN_SHARED" (¬GetOpt"no_fPIC")/"-fPIC"
args ( windows) / "-DNO_MMAP"
args ( replxx windows) / "-DUSE_REPLXX_IO"
args ( @versionName) / "-DHAS_VERSION"
@ -264,7 +276,7 @@ po ← { # parsed options
args GetOpt "REPLXX_FLAGS"
args ( ¬pie) / "-fno-pie"
args (pie ¬shared) / "-fPIE"
args ( shared) / "-fPIC"
args ( shared) / (¬GetOpt"no_fPIC")/"-fPIC"
{"REPLXX C++ compiler: "•Repr 𝕩} _verboseLog args
replxxc args
}
@ -273,9 +285,11 @@ po ← { # parsed options
Linker { 𝕊:
rdynamic exportSymbols ¬windows
args {replxx? cxx; cc} DOpt "LD", "-lm"
args {replxx? cxx; cc} DOpt "LD"
args defLibs / "-lm"
args DOpt "LD_LIBS"
args ((¬GetOpt "NO_LDL") defLibs ffi ¬bsd) / "-ldl"
args 1GetLibs@
args (ffi ¬bsd) / "-ldl"
args GetOpt "lf"
args GetOpt "CCFLAGS"
args GetOpt "LDFLAGS"

View File

@ -1,5 +1,5 @@
SHELL = /usr/bin/env bash
MAKEFLAGS+= --no-print-directory --no-builtin-rules
MAKEFLAGS+= --no-print-directory --no-builtin-rules --no-builtin-variables
# note: do not manually define any i_… arguments, or incremental compiling will not work properly!
# various configurations
@ -38,12 +38,52 @@ shared-o3:
shared-c:
@"${MAKE}" i_OUTPUT=libcbqn.so i_SHARED=1 custom=1 run_incremental_0
for-build:
@"${MAKE}" i_singeli=0 i_CC=cc i_t=forbuild i_f="-O2 -DFOR_BUILD" i_FFI=0 i_OUTPUT=build/obj2/for_build2 run_incremental_0
@"${MAKE}" i_singeli=0 i_CC=cc REPLXX=0 i_t=forbuild i_f="-O2 -DFOR_BUILD" i_FFI=0 i_OUTPUT=build/obj2/for_build2 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
i_notui=0
ifeq ($(origin notui),command line)
i_notui=1
endif
ifeq ($(origin REPLXX),command line)
i_REPLXX_1 = "$(REPLXX)"
else
i_REPLXX_1 = 1
endif
to-bqn-build:
ifeq ($(origin builddir),command line)
@echo "Error: 'builddir' unsupported"; false
endif
ifeq ($(origin clean),command line)
@echo "Error: build-specific 'clean' unsupported"; false
endif
@build/build from-makefile CC="$(CC)" CXX="$(CXX)" PIE="$(ENABLE_PIE)" OUTPUT="$(OUTPUT)" j="$(j)" \
verbose="$(verbose)" notui="$(i_notui)" v="$(version)" \
f="$(f)" lf="$(lf)" CCFLAGS="$(CCFLAGS)" LDFLAGS="$(LDFLAGS)" REPLXX_FLAGS="$(REPLXX_FLAGS)" \
LD_LIBS="$(LD_LIBS)" NO_LDL="$(NO_LDL)" no_fPIC="$(no_fPIC)" \
c="$(build_c)" debug="$(debug)" $(i_build_opts) $(build_opts) \
os="$(target_os)" arch="$(target_arch)" \
shared="$(i_SHARED)" singeli="$(i_singeli)" replxx="$(REPLXX)" FFI="$(FFI)"
o3-temp:
@"${MAKE}" to-bqn-build REPLXX=$(i_REPLXX_1)
o3n-temp:
@"${MAKE}" to-bqn-build REPLXX=$(i_REPLXX_1) i_build_opts="native"
debug-temp:
@"${MAKE}" to-bqn-build REPLXX=$(i_REPLXX_1) build_c=1 i_build_opts="heapverify debug"
heapverify-temp:
@"${MAKE}" to-bqn-build REPLXX=$(i_REPLXX_1) build_c=1 i_build_opts="heapverify debug"
o3n-singeli-temp:
@"${MAKE}" to-bqn-build REPLXX=$(i_REPLXX_1) singeli=1 i_build_opts="native"
o3-singeli:
@"${MAKE}" to-bqn-build REPLXX=$(i_REPLXX_1) singeli=1
shared-o3-temp:
@"${MAKE}" to-bqn-build i_SHARED=1
# compiler setup
i_CC := clang
i_PIE :=
@ -337,7 +377,7 @@ ifeq ($(origin CXX),command line)
i_CXX := $(CXX)
endif
i_LD = $(i_CXX)
REPLXX_FLAGS = -Os -std=c++11
REPLXX_FLAGS = -std=c++11 -Os
ALL_CC_FLAGS += -DUSE_REPLXX -I$(REPLXX_DIR)/include $(i_CC_PIE)