Skip to content

Commit

Permalink
tools/ci: add zig, ldc and swift
Browse files Browse the repository at this point in the history
The main objective is to determine if the examples really work or if they have been obsoleted.
The languages included in the list promote good interoperability with the NuttX API (C predominant).

This will show if they are worth integrating in NuttX.

**FFI method**

- Rust: bindgen or c2rust
- D: importC
- Swift: Bridging header or clang modulemap.
- Zig: `@cImport/@cInclude` or translate-c
  • Loading branch information
kassane authored and xiaoxiang781216 committed Aug 26, 2024
1 parent 282cf2f commit 25bd3be
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 2 deletions.
40 changes: 40 additions & 0 deletions tools/ci/docker/linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,34 @@ RUN mkdir -p $CARGO_HOME \
&& $CARGO_HOME/bin/rustup target add thumbv7m-none-eabi \
&& $CARGO_HOME/bin/rustup target add riscv64gc-unknown-none-elf

# Install Swift
ENV SWIFT_VERSION=6.0-DEVELOPMENT-SNAPSHOT-2024-08-22-a
ENV SWIFT_HOME=/tools/swift
RUN mkdir -p ${SWIFT_HOME} \
&& curl -s -O -L https://download.swift.org/swift-6.0-branch/ubuntu2204/swift-${SWIFT_VERSION}/swift-${SWIFT_VERSION}-ubuntu22.04.tar.gz \
&& tar xzf swift-${SWIFT_VERSION}-ubuntu22.04.tar.gz -C ${SWIFT_HOME} \
&& rm swift-${SWIFT_VERSION}-ubuntu22.04.tar.gz

# Install Zig latest release
ENV ZIG_VERSION=0.13.0
ENV ZIG_HOME=/tools/zig
RUN mkdir -p ${ZIG_HOME} \
&& curl -s -O -L https://github.com/marler8997/zigup/releases/download/v2024_05_05/zigup-x86_64-linux.tar.gz \
&& tar xzf zigup-x86_64-linux.tar.gz -C ${ZIG_HOME} \
&& rm zigup-x86_64-linux.tar.gz \
&& chmod +x ${ZIG_HOME}/zigup \
&& ${ZIG_HOME}/zigup fetch --install-dir ${ZIG_HOME} ${ZIG_VERSION} \
&& chmod +x ${ZIG_HOME}/${ZIG_VERSION}/files/zig


# Install LDC2 latest release
ENV LDC_VERSION=1.39.0
ENV D_HOME=/tools/ldc2
RUN mkdir -p ${D_HOME} \
&& curl -s -O -L https://github.com/ldc-developers/ldc/releases/download/v${LDC_VERSION}/ldc2-${LDC_VERSION}-linux-x86_64.tar.xz \
&& tar xf ldc2-${LDC_VERSION}-linux-x86_64.tar.xz -C ${D_HOME} \
&& rm ldc2-${LDC_VERSION}-linux-x86_64.tar.xz

RUN mkdir /tools/gn -p \
&& cd /tools/gn \
&& git clone https://gn.googlesource.com/gn gn \
Expand Down Expand Up @@ -383,6 +411,18 @@ ENV CARGO_HOME=/tools/rust/cargo
ENV RUSTUP_HOME=/tools/rust/rustup
ENV PATH="/tools/rust/cargo/bin:$PATH"

# Pull in the Zig v0.13.0 toolchain
COPY --from=nuttx-tools /tools/zig/ /tools/zig/
ENV PATH="/tools/zig/0.13.0/files:$PATH"

# Pull in the ldc2 1.39.0 toolchain
COPY --from=nuttx-tools /tools/ldc2/ /tools/ldc2/
ENV PATH="/tools/ldc2/ldc2-1.39.0-linux-x86_64/bin:$PATH"

# Pull in the swift 6.0 toolchain
COPY --from=nuttx-tools /tools/swift/ /tools/swift/
ENV PATH="/tools/swift/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-08-22-a/bin:$PATH"

# ARM toolchain
COPY --from=nuttx-toolchain-arm /tools/clang-arm-none-eabi/ clang-arm-none-eabi/
# RUN cp /usr/bin/clang-extdef-mapping-10 clang-arm-none-eabi/bin/clang-extdef-mapping
Expand Down
16 changes: 15 additions & 1 deletion tools/ci/platforms/darwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,20 @@ rust() {
command rustc --version
}

dlang() {
if ! type ldc2 > /dev/null 2>&1; then
brew install ldc
fi

command ldc2 --version | head -n 5
}

zig() {
brew install zig

command zig cc --version
}

xtensa_esp32_gcc_toolchain() {
add_path "${NUTTXTOOLS}"/xtensa-esp32-elf/bin

Expand Down Expand Up @@ -334,7 +348,7 @@ install_build_tools() {
mkdir -p "${NUTTXTOOLS}"
echo "#!/usr/bin/env sh" > "${NUTTXTOOLS}"/env.sh

install="arm_gcc_toolchain arm64_gcc_toolchain avr_gcc_toolchain binutils bloaty elf_toolchain gen_romfs gperf kconfig_frontends mips_gcc_toolchain python_tools riscv_gcc_toolchain rust xtensa_esp32_gcc_toolchain u_boot_tools util_linux wasi_sdk c_cache"
install="arm_gcc_toolchain arm64_gcc_toolchain avr_gcc_toolchain binutils bloaty elf_toolchain gen_romfs gperf kconfig_frontends mips_gcc_toolchain python_tools riscv_gcc_toolchain rust dlang zig xtensa_esp32_gcc_toolchain u_boot_tools util_linux wasi_sdk c_cache"

mkdir -p "${NUTTXTOOLS}"/homebrew
export HOMEBREW_CACHE=${NUTTXTOOLS}/homebrew
Expand Down
10 changes: 9 additions & 1 deletion tools/ci/platforms/ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,14 @@ rust() {
command rustc --version
}

dlang() {
if ! type ldc2 > /dev/null 2>&1; then
sudo apt-get install ldc
fi

command ldc2 --version | head -n 5
}

rx_gcc_toolchain() {
add_path "${NUTTXTOOLS}"/renesas-toolchain/rx-elf-gcc/bin

Expand Down Expand Up @@ -436,7 +444,7 @@ install_build_tools() {
mkdir -p "${NUTTXTOOLS}"
echo "#!/usr/bin/env sh" > "${NUTTXTOOLS}"/env.sh

install="arm_clang_toolchain arm_gcc_toolchain arm64_gcc_toolchain avr_gcc_toolchain binutils bloaty clang_tidy gen_romfs gperf kconfig_frontends mips_gcc_toolchain python_tools riscv_gcc_toolchain rust rx_gcc_toolchain sparc_gcc_toolchain xtensa_esp32_gcc_toolchain u_boot_tools util_linux wasi_sdk c_cache"
install="arm_clang_toolchain arm_gcc_toolchain arm64_gcc_toolchain avr_gcc_toolchain binutils bloaty clang_tidy gen_romfs gperf kconfig_frontends mips_gcc_toolchain python_tools riscv_gcc_toolchain rust dlang rx_gcc_toolchain sparc_gcc_toolchain xtensa_esp32_gcc_toolchain u_boot_tools util_linux wasi_sdk c_cache"

oldpath=$(cd . && pwd -P)
for func in ${install}; do
Expand Down

0 comments on commit 25bd3be

Please sign in to comment.