* fix corner cases in luna_build.py when no LConfig is used
* add back the missing arch_bits_* flags
* fix sometimes the shconfig being triggered multiple times
15 files changed:
@flag
def arch_x86_32() -> bool:
@flag
def arch_x86_32() -> bool:
@flag
def arch_x86_64() -> bool:
@flag
def arch_x86_64() -> bool:
+ when (arch is "x86_64")
@flag
def arch_x86() -> bool:
@flag
def arch_x86() -> bool:
- when(arch is "i386")
- when(arch is "x86_64")
+ when (arch is "i386")
+ when (arch is "x86_64")
+
+ @flag
+ def arch_bits_64() -> bool:
+ when (arch_bits is 64)
+
+ @flag
+ def arch_bits_32() -> bool:
+ when (arch_bits is 32)
@"Architecture"
def arch() -> "i386" | "x86_64":
@"Architecture"
def arch() -> "i386" | "x86_64":
$(error "Must specify PREFIX to header install location")
endif
$(error "Must specify PREFIX to header install location")
endif
USR_HEADER := includes/usr
HEADERS := $(shell cat $(USR_HEADER)/headers)
USR_HEADER := includes/usr
HEADERS := $(shell cat $(USR_HEADER)/headers)
@$(MAKE) -f kernel.mk clean -I $(mkinc_dir)
@rm -rf $(kbuild_dir) || exit 1
@$(MAKE) -f kernel.mk clean -I $(mkinc_dir)
@rm -rf $(kbuild_dir) || exit 1
- @rm -rf .builder || exit 1
define __gen_build
@echo restarting configuration...
define __gen_build
@echo restarting configuration...
- @$(LBUILD) --gen-config $(lbuild_dir)
+ @$(LBUILD) --gen-build $(lbuild_dir)
import ast
import textwrap
import ast
import textwrap
from lib.utils import ConfigAST, ConfigASTVisitor
from .common import NodeProperty, ConfigNodeError, ValueTypeConstrain
from lib.utils import ConfigAST, ConfigASTVisitor
from .common import NodeProperty, ConfigNodeError, ValueTypeConstrain
@staticmethod
def build(env, rootfile):
@staticmethod
def build(env, rootfile):
+ if not os.path.exists(rootfile):
+ print(f"warning: config file '{rootfile}' not detected, skipped")
+ return
+
build = NodeBuilder(env)
ast = ConfigAST(rootfile)
build = NodeBuilder(env)
ast = ConfigAST(rootfile)
return self.__globals
def refresh(self):
return self.__globals
def refresh(self):
+ if not self.__exec:
+ return
+
self.__update_globals()
for name, node in self.__node_table.items():
self.__update_globals()
for name, node in self.__node_table.items():
def terms(self):
for node in self.__node_table.values():
if isinstance(node, TermNode):
def terms(self):
for node in self.__node_table.values():
if isinstance(node, TermNode):
- yield node
\ No newline at end of file
+ yield node
+
+ def loaded(self):
+ return self.__exec is not None
\ No newline at end of file
from shared.export import ExportHeaderFile
from shared.export import ExportMakefileRules
from shared.export import restore_config_value
from shared.export import ExportHeaderFile
from shared.export import ExportMakefileRules
from shared.export import restore_config_value
-from shared.scopes import ConfigScope
+from shared.scopes import ConfigScope, EnvScope
from shared.build_gen import BuildScriptGenerator
from shared.shconfig import shconfig
from shared.build_gen import BuildScriptGenerator
from shared.shconfig import shconfig
scope.subscope("ld")
self.__lbuilder.register_scope(scope)
scope.subscope("ld")
self.__lbuilder.register_scope(scope)
+ self.__lbuilder.register_scope(EnvScope())
+
self.__json = ExportJsonFile(self.__lconfig)
self.__make = ExportMakefileRules(self.__lconfig)
self.__headr = ExportHeaderFile(self.__lconfig)
self.__json = ExportJsonFile(self.__lconfig)
self.__make = ExportMakefileRules(self.__lconfig)
self.__headr = ExportHeaderFile(self.__lconfig)
self.__headr.export(outdir / "config.h")
def visual_config(self):
self.__headr.export(outdir / "config.h")
def visual_config(self):
+ if not self.__lconfig.loaded():
+ print("no config file loaded, skipped interactive config")
+ return
+
+ if not self.__opt.gen_config:
+ return
+
if not shconfig(self.__lconfig):
print("configuration process aborted")
exit(1)
if not shconfig(self.__lconfig):
print("configuration process aborted")
exit(1)
from lbuild.scope import ScopeProvider
from lcfg2.common import NodeProperty
from lbuild.scope import ScopeProvider
from lcfg2.common import NodeProperty
if node is None:
raise Exception(f"config '{name}' not exists")
if node is None:
raise Exception(f"config '{name}' not exists")
- return NodeProperty.Value[node]
\ No newline at end of file
+ if not NodeProperty.Enabled[node]:
+ return None
+
+ return NodeProperty.Value[node]
+
+class EnvScope(ScopeProvider):
+ def __init__(self):
+ super().__init__("env")
+
+ def __getitem__(self, name):
+ return os.environ.get(name)
\ No newline at end of file
"testp",
"ls",
"signal_demo",
"testp",
"ls",
"signal_demo",
"mkdir",
"rm",
"fragfile",
"mkdir",
"rm",
"fragfile",
+ "-fno-pie",
+ "-Werror"
+)
"-nostdlib",
"-nolibc",
"-z noexecstack",
"-no-pie",
"-nostdlib",
"-nolibc",
"-z noexecstack",
"-no-pie",
-if config("arch") == "x86_64":
- compile_opts([
- "-m64",
- "-fno-unwind-tables",
- "-fno-asynchronous-unwind-tables",
- "-mcmodel=large"
- ])
- linking_opts([
- "-m64",
- ])
-else:
- compile_opts("-m32")
- linking_opts("-m32")
+match env.ARCH:
+ case "x86_64":
+ flag.cc += (
+ "-m64",
+ "-fno-unwind-tables",
+ "-fno-asynchronous-unwind-tables",
+ "-mcmodel=large",
+ "-DCONFIG_ARCH_X86_64"
+ )
+ flag.ld += (
+ "-m64",
+ )
+ case "i386":
+ flag.cc += "-m32", "-DCONFIG_ARCH_X86_32"
+ flag.ld += "-m32"
-compile_opts("-mno-sse")
\ No newline at end of file
+flag.cc += "-mno-sse"
+
+flag.cc += (
+ "-Wno-discarded-qualifiers"
+)
\ No newline at end of file
+++ /dev/null
-@"Architecture"
-def arch() -> "i386" | "x86_64" | "aarch64" | "rv64":
- """
- set the ISA target
- """
-
- _arch = env("ARCH")
- return _arch if _arch else "x86_64"
"src/string.c",
"src/termios.c",
"src/itoa.c",
"src/string.c",
"src/termios.c",
"src/itoa.c",
"src/readdir.c",
"src/pthread.c",
"src/printf.c"
"src/readdir.c",
"src/pthread.c",
"src/printf.c"
"src/posix/signal.c",
"src/posix/mount.c",
"src/posix/errno.c",
"src/posix/signal.c",
"src/posix/mount.c",
"src/posix/errno.c",
"src/posix/unistd.c",
"src/posix/mann.c",
"src/posix/lunaix.c"
"src/posix/unistd.c",
"src/posix/mann.c",
"src/posix/lunaix.c"
-use({
- env("ARCH"): {
- "i386": "arch/i386",
- "x86_64": "arch/x86_64",
- }
-})
\ No newline at end of file
+match env.ARCH:
+ case "i386":
+ from .arch import i386
+ case "x86_64":
+ from .arch import x86_64
"crt0.S",
"syscall.S",
"trampoline.S",
"crt0.S",
"syscall.S",
"trampoline.S",
-compile_opts("-m32")
-linking_opts("-m32")
\ No newline at end of file
+flag.cc += "-m32"
+flag.ld += "-m32"
\ No newline at end of file
"crt0.S",
"syscall.S",
"trampoline.S",
"crt0.S",
"syscall.S",
"trampoline.S",
-compile_opts("-m64")
-linking_opts("-m64")
\ No newline at end of file
+flag.cc += "-m64"
+flag.ld += "-m64"
\ No newline at end of file
src_dirs := src
src_dirs += arch/$(ARCH)
src_dirs := src
src_dirs += arch/$(ARCH)
-obj_files := $(addsuffix .o, $(_LBUILD_SRCS))
+obj_files := $(addsuffix .o, $(BUILD_SRCS))
build_lib := $(BUILD_DIR)/lib
libc_include_opt = $(addprefix -I, $(libc_include))
build_lib := $(BUILD_DIR)/lib
libc_include_opt = $(addprefix -I, $(libc_include))
-global_include_opt = $(addprefix -I, $(INCLUDES) $(_LBUILD_INCS))
+global_include_opt = $(addprefix -I, $(INCLUDES) $(BUILD_INC))
check_folders := $(src_dirs)
check_folders += $(build_lib) $(LIBC_INCLUDE)
check_folders := $(src_dirs)
check_folders += $(build_lib) $(LIBC_INCLUDE)
include utils.mkinc
include toolchain.mkinc
include utils.mkinc
include toolchain.mkinc
-LCONFIG_FLAGS := --quiet
-
include lunabuild.mkinc
include $(lbuild_mkinc)
include lunabuild.mkinc
include $(lbuild_mkinc)
$(error ARCH is not set)
endif
$(error ARCH is not set)
endif
+CFLAGS += $(BUILD_CFLAGS)
+LDFLAGS += $(BUILD_LDFLAGS)
+
task := all
sys_include := $(CURDIR)/includes
task := all
sys_include := $(CURDIR)/includes
LIBC_INCLUDE := $(build_dir)/usr/includes
mkapp-list := $(addprefix app-, $(shell cat apps.list))
LIBC_INCLUDE := $(build_dir)/usr/includes
mkapp-list := $(addprefix app-, $(shell cat apps.list))
-mkexec-list := $(addprefix $(build_dir)/bin/, $(_LBUILD_SRCS))
+mkexec-list := $(addprefix $(build_dir)/bin/, $(BUILD_SRCS))
uexec_ld := $(CURDIR)/uexec.ld
uexec_ld := $(CURDIR)/uexec.ld
@$(MAKE) $(MKFLAGS) -C libc/ $(task)
$(uexec_ld): $(uexec_ld)x
@$(MAKE) $(MKFLAGS) -C libc/ $(task)
$(uexec_ld): $(uexec_ld)x
- @$(CC) -include $(lbuild_config_h) -x c -P -E $< -o $@
+ @$(CC) $(CFLAGS) -x c -P -E $< -o $@
# Application (with standalone makefile)
export LD_SCRIPT := $(uexec_ld)
# Application (with standalone makefile)
export LD_SCRIPT := $(uexec_ld)