Skip to content

Commit 1137f4e

Browse files
committed
fix: optimize build commands and improve CPU utilization in Makefile
1 parent c7d5ded commit 1137f4e

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ jobs:
6666
6767
- name: windows build curl
6868
if: matrix.os == 'windows-latest'
69-
run: make curl/windows/libcurl.a -j4
69+
run: make curl/windows/libcurl.a
7070
shell: msys2 {0}
7171

7272
- name: build sqlite-sync
73-
run: make extension ${{ matrix.make && matrix.make || ''}} -j4
73+
run: make extension ${{ matrix.make && matrix.make || ''}}
7474

7575
- name: windows install sqlite3
7676
if: matrix.os == 'windows-latest'
@@ -100,7 +100,7 @@ jobs:
100100
echo "::endgroup::"
101101
102102
echo "::group::prepare the test script"
103-
make test PLATFORM=$PLATFORM ARCH=$ARCH -j4 || echo "It should fail. Running remaining commands in the emulator"
103+
make test PLATFORM=$PLATFORM ARCH=$ARCH || echo "It should fail. Running remaining commands in the emulator"
104104
cat > commands.sh << EOF
105105
mv -f /data/local/tmp/sqlite3 /system/xbin
106106
cd /data/local/tmp
@@ -125,7 +125,7 @@ jobs:
125125
126126
- name: test sqlite-sync
127127
if: matrix.name == 'linux' || matrix.name == 'windows'
128-
run: make test -j4
128+
run: make test
129129

130130
- name: test sqlite-sync + coverage
131131
if: matrix.name == 'macos'

Makefile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,22 @@ CURL_VERSION ?= 8.12.1
1111
# Set default platform if not specified
1212
ifeq ($(OS),Windows_NT)
1313
PLATFORM := windows
14-
HOST:= windows
14+
HOST := windows
15+
CPUS := $(shell powershell -Command "[Environment]::ProcessorCount")
1516
else
1617
HOST = $(shell uname -s | tr '[:upper:]' '[:lower:]')
1718
ifeq ($(HOST),darwin)
1819
PLATFORM := macos
20+
CPUS := $(shell sysctl -n hw.ncpu)
1921
else
2022
PLATFORM := $(HOST)
23+
CPUS := $(shell nproc)
2124
endif
2225
endif
2326

27+
# Speed up builds by using all available CPU cores
28+
MAKEFLAGS += -j$(CPUS)
29+
2430
# Compiler and flags
2531
CC = gcc
2632
CFLAGS = -Wall -Wextra -Wno-unused-parameter -I$(SRC_DIR) -I$(SQLITE_DIR) -I$(CURL_DIR)/include
@@ -87,7 +93,7 @@ else ifeq ($(PLATFORM),android)
8793

8894
OPENSSL := $(BIN)/../sysroot/usr/include/openssl
8995
CC = $(BIN)/$(ARCH)-linux-android26-clang
90-
CURL_CONFIG = --host $(ARCH)-$(HOST)-android26 --with-openssl=$(BIN)/../sysroot/usr LIBS="-lssl -lcrypto" AR=$(BIN)/llvm-ar AS=$(BIN)/llvm-as CC=$(BIN)/$(ARCH)-linux-android26-clang CXX=$(BIN)/$(ARCH)-linux-android26-clang++ LD=$(BIN)/ld RANLIB=$(BIN)/llvm-ranlib STRIP=$(BIN)/llvm-strip
96+
CURL_CONFIG = --host $(ARCH)-$(HOST)-android26 --with-openssl=$(BIN)/../sysroot/usr LIBS="-lssl -lcrypto" AR=$(BIN)/llvm-ar AS=$(BIN)/llvm-as CC=$(CC) CXX=$(BIN)/$(ARCH)-linux-android26-clang++ LD=$(BIN)/ld RANLIB=$(BIN)/llvm-ranlib STRIP=$(BIN)/llvm-strip
9197
TARGET := $(DIST_DIR)/cloudsync.so
9298
LDFLAGS += -shared -lcrypto -lssl
9399
else ifeq ($(PLATFORM),ios)
@@ -263,7 +269,7 @@ endif
263269

264270
# Clean up generated files
265271
clean:
266-
rm -rf $(BUILD_DIRS) $(DIST_DIR)/* $(COV_DIR) *.gcda *.gcno *.gcov $(CURL_DIR)/src
272+
rm -rf $(BUILD_DIRS) $(DIST_DIR)/* $(COV_DIR) *.gcda *.gcno *.gcov $(CURL_DIR)/src *.sqlite
267273

268274
# Help message
269275
help:

0 commit comments

Comments
 (0)