diff --git a/boards/sim/sim/sim/configs/zig/defconfig b/boards/sim/sim/sim/configs/zig/defconfig new file mode 100644 index 0000000000..6463ef6f50 --- /dev/null +++ b/boards/sim/sim/sim/configs/zig/defconfig @@ -0,0 +1,66 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +CONFIG_ARCH="sim" +CONFIG_ARCH_BOARD="sim" +CONFIG_ARCH_BOARD_SIM=y +CONFIG_ARCH_CHIP="sim" +CONFIG_ARCH_SIM=y +CONFIG_BOARDCTL_APP_SYMTAB=y +CONFIG_BOARDCTL_POWEROFF=y +CONFIG_BOARD_LOOPSPERMSEC=0 +CONFIG_BOOT_RUNFROMEXTSRAM=y +CONFIG_BUILTIN=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEV_GPIO=y +CONFIG_DEV_LOOP=y +CONFIG_DEV_ZERO=y +CONFIG_EXAMPLES_GPIO=y +CONFIG_EXAMPLES_HELLO_ZIG=y +CONFIG_FAT_LCNAMES=y +CONFIG_FAT_LFN=y +CONFIG_FSUTILS_PASSWD=y +CONFIG_FSUTILS_PASSWD_READONLY=y +CONFIG_FS_BINFS=y +CONFIG_FS_FAT=y +CONFIG_FS_PROCFS=y +CONFIG_FS_RAMMAP=y +CONFIG_FS_ROMFS=y +CONFIG_GPIO_LOWER_HALF=y +CONFIG_IDLETHREAD_STACKSIZE=4096 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_IOEXPANDER=y +CONFIG_IOEXPANDER_DUMMY=y +CONFIG_LIBC_ENVPATH=y +CONFIG_LIBC_EXECFUNCS=y +CONFIG_LIBC_LOCALE=y +CONFIG_LIBC_LOCALE_CATALOG=y +CONFIG_LIBC_LOCALE_GETTEXT=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_ARCHROMFS=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_CONSOLE_LOGIN=y +CONFIG_NSH_FATDEVNO=2 +CONFIG_NSH_FILE_APPS=y +CONFIG_NSH_MOTD=y +CONFIG_NSH_MOTD_STRING="MOTD: username=admin password=Administrator" +CONFIG_NSH_READLINE=y +CONFIG_NSH_ROMFSDEVNO=1 +CONFIG_NSH_ROMFSETC=y +CONFIG_PATH_INITIAL="/bin" +CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=2048 +CONFIG_PSEUDOFS_ATTRIBUTES=y +CONFIG_PSEUDOFS_SOFTLINKS=y +CONFIG_READLINE_TABCOMPLETION=y +CONFIG_SCHED_HAVE_PARENT=y +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_ONEXIT=y +CONFIG_SCHED_WAITPID=y +CONFIG_START_MONTH=6 +CONFIG_START_YEAR=2008 +CONFIG_SYSTEM_NSH=y diff --git a/boards/sim/sim/sim/scripts/Make.defs b/boards/sim/sim/sim/scripts/Make.defs index 897dd22bcf..0c58529c86 100644 --- a/boards/sim/sim/sim/scripts/Make.defs +++ b/boards/sim/sim/sim/scripts/Make.defs @@ -103,6 +103,9 @@ NM = $(CROSSDEV)nm OBJCOPY = $(CROSSDEV)objcopy OBJDUMP = $(CROSSDEV)objdump RUSTC = rustc --edition 2021 +ZIG = zig +ZCC = zig cc +ZCXX = zig c++ CFLAGS := $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \ $(ARCHCFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe diff --git a/tools/Config.mk b/tools/Config.mk index 48aa2b3fb0..f8cd1b1625 100644 --- a/tools/Config.mk +++ b/tools/Config.mk @@ -312,6 +312,24 @@ define COMPILERUST $(Q) $(RUSTC) --emit obj $(RUSTFLAGS) $($(strip $1)_RUSTFLAGS) $1 -o $2 endef +# COMPILEZIG - Default macro to compile one Zig file +# Example: $(call COMPILEZIG, in-file, out-file) +# +# Depends on these settings defined in board-specific Make.defs file +# installed at $(TOPDIR)/Make.defs: +# +# ZIG - The command to invoke the Zig compiler +# ZIGFLAGS - Options to pass to the Zig compiler +# +# '.zig_ZIGFLAGS += ' may also be used, as an example, to +# change the options used with the single file .zig. The same +# applies mutatis mutandis. + +define COMPILEZIG + @echo "ZIG: $1" + $(Q) $(ZIG) build-obj $(ZIGFLAGS) $($(strip $1)_ZIGFLAGS) $1 --name $2 +endef + # ASSEMBLE - Default macro to assemble one assembly language file # Example: $(call ASSEMBLE, in-file, out-file) # diff --git a/tools/ci/cibuild.sh b/tools/ci/cibuild.sh index 1e720078c4..838f1959de 100755 --- a/tools/ci/cibuild.sh +++ b/tools/ci/cibuild.sh @@ -381,6 +381,24 @@ function rust { fi } +function zig { + mkdir -p "${prebuilt}"/zig + add_path "${prebuilt}"/zig + + if ! type zig &> /dev/null; then + case ${os} in + Darwin) + brew install zig + ;; + Linux) + # Currently Debian don't install zig (only built) + export ZIG_HOME=${prebuilt}/zig + curl -sL https://ziglang.org/download/0.9.1/zig-linux-x86_64-0.9.1.tar.xz | tar -xJC "${prebuilt}"/zig --strip-components=1 + ;; + esac + fi +} + function usage { echo "" echo "USAGE: $0 [-i] [-s] [-c] [-*] " diff --git a/tools/ci/docker/linux/Dockerfile b/tools/ci/docker/linux/Dockerfile index 7e26869875..8838dee399 100644 --- a/tools/ci/docker/linux/Dockerfile +++ b/tools/ci/docker/linux/Dockerfile @@ -34,6 +34,7 @@ RUN apt-get update -qq && DEBIAN_FRONTEND="noninteractive" apt-get install -y -q cmake \ g++ \ gawk \ + jq \ git RUN mkdir /tools @@ -68,6 +69,12 @@ RUN mkdir -p $CARGO_HOME \ && $CARGO_HOME/bin/rustup target add thumbv6m-none-eabi \ && $CARGO_HOME/bin/rustup target add thumbv7m-none-eabi +# Install Zig from NuttX +ENV ZIG_HOME=/tools/zig + +RUN mkdir -p $ZIG_HOME \ + && curl -sL https://ziglang.org/download/0.9.1/zig-linux-x86_64-0.9.1.tar.xz | tar -xJC $ZIG_HOME --strip-components=1 + CMD [ "/bin/bash" ] ############################################################################### @@ -269,6 +276,10 @@ ENV CARGO_HOME=/tools/rust/cargo ENV RUSTUP_HOME=/tools/rust/rustup ENV PATH="/tools/rust/cargo/bin:$PATH" +# Zig toolchain +COPY --from=nuttx-tools /tools/zig/ /tools/zig/ +ENV PATH="/tools/zig:$PATH" + # ARM toolchain COPY --from=nuttx-toolchain-arm /tools/gcc-arm-none-eabi/ gcc-arm-none-eabi/ ENV PATH="/tools/gcc-arm-none-eabi/bin:$PATH"