add native library to make build process faster

This commit is contained in:
Siyuan Miao 2025-09-24 09:48:20 +00:00 committed by Siyuan
parent 1ca576176a
commit ace2934111
8 changed files with 31 additions and 27 deletions

View File

@ -16,8 +16,15 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Set up build dependencies
run: |
apt-get update && apt-get install -y \
build-essential \
cmake \
libusb-1.0-0-dev \
libudev-dev
- name: Set up Cmake cache
uses: buildjet/cache@v4
uses: actions/cache@v4
with:
path: internal/native/cgo/build
key: jetkvm-cgo-${{ hashFiles('internal/native/cgo/**/*.c', 'internal/native/cgo/**/*.h', 'internal/native/cgo/**/*.patch', 'internal/native/cgo/**/*.txt', 'internal/native/cgo/**/*.sh', '!internal/native/cgo/build/**') }}

4
.gitignore vendored
View File

@ -7,5 +7,5 @@ device-tests.tar.gz
node_modules
# generated during the build process
internal/native/include
internal/native/lib
#internal/native/include
#internal/native/lib

View File

@ -1,26 +1,12 @@
# syntax=docker/dockerfile:1
FROM golang:1.24.4-bookworm
FROM golang:1.25.1-trixie
ENV GOTOOLCHAIN=local
ENV GOPATH /go
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
device-tree-compiler \
gperf g++-multilib gcc-multilib \
libnl-3-dev libdbus-1-dev libelf-dev libmpc-dev dwarves \
bc openssl flex bison libssl-dev python3 python-is-python3 texinfo kmod cmake \
wget zstd \
&& rm -rf /var/lib/apt/lists/*
# Install buildkit
ENV BUILDKIT_VERSION="v0.2.2"
RUN wget https://github.com/jetkvm/rv1106-system/releases/download/${BUILDKIT_VERSION}/buildkit.tar.zst && \
mkdir -p /opt/jetkvm-native-buildkit && \
tar --use-compress-program="unzstd --long=31" -xvf buildkit.tar.zst -C /opt/jetkvm-native-buildkit && \
rm buildkit.tar.zst
ADD .devcontainer/install-deps.sh /install-deps.sh
RUN /install-deps.sh
# Create build directory
RUN mkdir -p /build/

View File

@ -10,6 +10,7 @@ KVM_PKG_NAME := github.com/jetkvm/kvm
BUILDKIT_FLAVOR := arm-rockchip830-linux-uclibcgnueabihf
BUILDKIT_PATH ?= /opt/jetkvm-native-buildkit
SKIP_NATIVE_IF_EXISTS ?= 1
GO_BUILD_ARGS := -tags netgo -tags timetzdata
@ -40,11 +41,15 @@ BIN_DIR := $(shell pwd)/bin
TEST_DIRS := $(shell find . -name "*_test.go" -type f -exec dirname {} \; | sort -u)
build_native:
@echo "Building native..."
cd internal/native/cgo && ./ui_index.gen.sh && \
CC="$(BUILDKIT_PATH)/bin/$(BUILDKIT_FLAVOR)-gcc" \
LD="$(BUILDKIT_PATH)/bin/$(BUILDKIT_FLAVOR)-ld" \
./build.sh
@if [ "$(SKIP_NATIVE_IF_EXISTS)" = "1" ] && [ -f "internal/native/lib/libjknative.a" ]; then \
echo "libjknative.a already exists, skipping native build..."; \
else \
echo "Building native..."; \
cd internal/native/cgo && ./ui_index.gen.sh && \
CC="$(BUILDKIT_PATH)/bin/$(BUILDKIT_FLAVOR)-gcc" \
LD="$(BUILDKIT_PATH)/bin/$(BUILDKIT_FLAVOR)-ld" \
./build.sh; \
fi
build_dev: build_native
@echo "Building..."

View File

@ -28,6 +28,7 @@ show_help() {
echo " --run-go-tests Run go tests"
echo " --run-go-tests-only Run go tests and exit"
echo " --skip-ui-build Skip frontend/UI build"
echo " --skip-native-build Skip native build"
echo " -i, --install Build for release and install the app"
echo " --help Display this help message"
echo
@ -40,6 +41,7 @@ show_help() {
REMOTE_USER="root"
REMOTE_PATH="/userdata/jetkvm/bin"
SKIP_UI_BUILD=false
SKIP_NATIVE_BUILD=0
RESET_USB_HID_DEVICE=false
LOG_TRACE_SCOPES="${LOG_TRACE_SCOPES:-jetkvm,cloud,websocket,native,jsonrpc}"
RUN_GO_TESTS=false
@ -61,6 +63,10 @@ while [[ $# -gt 0 ]]; do
SKIP_UI_BUILD=true
shift
;;
--skip-native-build)
SKIP_NATIVE_BUILD=1
shift
;;
--reset-usb-hid)
RESET_USB_HID_DEVICE=true
shift
@ -148,7 +154,7 @@ fi
if [ "$INSTALL_APP" = true ]
then
msg_info "▶ Building release binary"
make build_release
make build_release SKIP_NATIVE_IF_EXISTS=${SKIP_NATIVE_BUILD}
# Copy the binary to the remote host as if we were the OTA updater.
ssh "${REMOTE_USER}@${REMOTE_HOST}" "cat > /userdata/jetkvm/jetkvm_app.update" < bin/jetkvm_app
@ -157,7 +163,7 @@ then
ssh "${REMOTE_USER}@${REMOTE_HOST}" "reboot"
else
msg_info "▶ Building development binary"
make build_dev
make build_dev SKIP_NATIVE_IF_EXISTS=${SKIP_NATIVE_BUILD}
# Kill any existing instances of the application
ssh "${REMOTE_USER}@${REMOTE_HOST}" "killall jetkvm_app_debug || true"

Binary file not shown.

Binary file not shown.

Binary file not shown.