diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..56e106e --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,44 @@ +name: Build package + +on: [ push, pull_request, workflow_dispatch ] + +# written referencing apollo save tool psp's CI + +jobs: + build_pkg: + runs-on: ubuntu-22.04 + steps: + + - name: Checkout + uses: actions/checkout@v3 + + - name: Install podman and qemu + run: | + sudo apt update + sudo apt install -y qemu-user-static podman + + - name: Set env vars + run: | + echo "sha_name=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_ENV + + - name: Build + run: | + bash build_podman.sh + + - name: Push package artifact + uses: actions/upload-artifact@v3 + with: + name: lg4ff_userspace_${{ env.sha_name }} + path: | + lg4ff_userspace_386 + lg4ff_userspace_usb_386 + lg4ff_userspace_amd64 + lg4ff_userspace_usb_amd64 + lg4ff_userspace_arm64 + lg4ff_userspace_usb_arm64 + lg4ff_userspace_arm + lg4ff_userspace_usb_arm + 60-lg4ff-userspace.rules + 60-lg4ff-userspace-usb.rules + logitech-hid.conf + if-no-files-found: error diff --git a/build.sh b/build.sh index 8945329..3dc668f 100644 --- a/build.sh +++ b/build.sh @@ -3,14 +3,20 @@ set -xe CC=${CC:-gcc} CPPC=${CC:-g++} -$CC -g -c probe.c -o probe.o -$CC -g -c device_ids.c -o device_ids.o -$CC -g -c driver_loops.c -o driver_loops.o -$CC -g -c switch_mode.c -o switch_mode.o -$CC -g -c configure.c -o configure.o -$CC -g -c force_feedback.c -o force_feedback.o -$CC -g -c main.c -o main.o -$CC probe.o device_ids.o driver_loops.o switch_mode.o configure.o force_feedback.o main.o -o lg4ff_userspace -lhidapi-hidraw -lm -$CC probe.o device_ids.o driver_loops.o switch_mode.o configure.o force_feedback.o main.o -o lg4ff_userspace_usb -lhidapi-libusb -lm +if [ "$DEBUG" == "true" ] +then + $CC -g -c probe.c -o probe.o + $CC -g -c device_ids.c -o device_ids.o + $CC -g -c driver_loops.c -o driver_loops.o + $CC -g -c switch_mode.c -o switch_mode.o + $CC -g -c configure.c -o configure.o + $CC -g -c force_feedback.c -o force_feedback.o + $CC -g -c main.c -o main.o + $CC probe.o device_ids.o driver_loops.o switch_mode.o configure.o force_feedback.o main.o -o lg4ff_userspace -lhidapi-hidraw -lm + $CC probe.o device_ids.o driver_loops.o switch_mode.o configure.o force_feedback.o main.o -o lg4ff_userspace_usb -lhidapi-libusb -lm +else + $CC probe.c device_ids.c driver_loops.c switch_mode.c configure.c force_feedback.c main.c -O2 -o lg4ff_userspace -lhidapi-hidraw -lm + $CC probe.c device_ids.c driver_loops.c switch_mode.c configure.c force_feedback.c main.c -O2 -o lg4ff_userspace_usb -lhidapi-libusb -lm +fi -rm *.o +rm -f *.o diff --git a/build_podman.sh b/build_podman.sh index 550d00d..8affb3f 100644 --- a/build_podman.sh +++ b/build_podman.sh @@ -1,6 +1,6 @@ set -e -for arch in i386 amd64 arm64 arm +for arch in 386 amd64 arm64 arm do podman run --rm -it \ --security-opt label=disable \ @@ -16,6 +16,7 @@ do apt install -y gcc libhidapi-dev bash build.sh ' + arch=$(echo $arch | sed 's#/##g') mv lg4ff_userspace lg4ff_userspace_${arch} mv lg4ff_userspace_usb lg4ff_userspace_usb_${arch} done