From c2030d676e4fcb4138bccec6bcb27b7edf691739 Mon Sep 17 00:00:00 2001 From: Sayan Date: Wed, 16 Jun 2021 17:45:20 +0530 Subject: [PATCH] Auto install any dependencies (#174) --- .github/workflows/test-push.yml | 9 --------- Makefile | 27 +++++++++++++++++++++++---- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test-push.yml b/.github/workflows/test-push.yml index 838da3d8..8d27e6b4 100644 --- a/.github/workflows/test-push.yml +++ b/.github/workflows/test-push.yml @@ -180,11 +180,6 @@ jobs: rustup target add ${{ matrix.rust }} if: env.IS_MD_FILE == 'false' - - name: Install 32-bit tools (Linux) - run: | - sudo apt update && sudo apt install gcc-multilib -y - if: runner.os == 'Linux' - - name: Run Tests run: make test env: @@ -263,10 +258,6 @@ jobs: ${{ matrix.rust }}-target- if: env.IS_MD_FILE == 'false' - - name: Install MUSL tools - run: sudo apt-get update && sudo apt-get install musl-tools -y - if: runner.os == 'Linux' - - name: Install Rust run: | rustup default stable diff --git a/Makefile b/Makefile index e3402e04..c98aa784 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,20 @@ +ADDITIONAL_SOFTWARE= TARGET_ARG = ifneq ($(origin TARGET),undefined) TARGET_ARG +=--target ${TARGET} +ifeq ($(TARGET),x86_64-unknown-linux-musl) +# we need musl-tools for 64-bit musl targets +ADDITIONAL_SOFTWARE += sudo apt-get update && sudo apt install musl-tools -y +endif +ifeq ($(TARGET),i686-unknown-linux-gnu) +# we need gcc-multilib on 32-bit linux targets +ADDITIONAL_SOFTWARE += sudo apt-get update && sudo apt install gcc-multilib -y +endif +endif + +# display a message if no additional packages are required for this target +ifeq ($(ADDITIONAL_SOFTWARE),) +ADDITIONAL_SOFTWARE += echo "info: No additional software required for this target" endif BUILD_VERBOSE = cargo build --verbose $(TARGET_ARG) @@ -41,22 +55,27 @@ ifneq ($(OS),Windows_NT) START_COMMAND += & endif -build: +.pre: + @echo "====================================================================" + @echo "Installing any additional dependencies" + @echo "====================================================================" + @$(ADDITIONAL_SOFTWARE) +build: .pre @echo "====================================================================" @echo "Building all binaries in debug mode (unoptimized)" @echo "====================================================================" @$(BUILD_COMMAND) -build-server: +.build-server: .pre @echo "====================================================================" @echo "Building server binary in debug mode (unoptimized)" @echo "====================================================================" @$(BUILD_SERVER_COMMAND) -release: +release: .pre @echo "====================================================================" @echo "Building all binaries in release mode (optimized)" @echo "====================================================================" cargo build --release --verbose $(TARGET_ARG) -test: build-server +test: .build-server @echo "====================================================================" @echo "Starting database server in background" @echo "===================================================================="