mirror of
https://github.com/RubyMetric/chsrc
synced 2025-07-16 20:27:27 +08:00
Sync with justfile
This commit is contained in:
parent
2e0059978c
commit
90cf624f53
65
Makefile
65
Makefile
@ -9,8 +9,11 @@
|
|||||||
# |
|
# |
|
||||||
# Created On : <2023-08-28>
|
# Created On : <2023-08-28>
|
||||||
# Last Modified : <2025-06-20>
|
# Last Modified : <2025-06-20>
|
||||||
|
#
|
||||||
|
# 请阅读 ./doc/01-Develop.md 来使用
|
||||||
# --------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
|
|
||||||
|
#=========== OS Check ================
|
||||||
On-Linux = 0
|
On-Linux = 0
|
||||||
On-Windows = 0
|
On-Windows = 0
|
||||||
On-macOS = 0
|
On-macOS = 0
|
||||||
@ -19,12 +22,38 @@ ifeq ($(shell uname), Linux)
|
|||||||
On-Linux = 1
|
On-Linux = 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(shell uname), Darwin)
|
||||||
|
On-macOS = 1
|
||||||
|
endif
|
||||||
|
|
||||||
# 只有Windows会定义$(OS)变量
|
# 只有Windows会定义$(OS)变量
|
||||||
ifeq ($(OS), Windows_NT)
|
ifeq ($(OS), Windows_NT)
|
||||||
On-Windows = 1
|
On-Windows = 1
|
||||||
endif
|
endif
|
||||||
#=======================
|
#=====================================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#======== Default Tooling ============
|
||||||
|
ifeq ($(On-Windows), 1)
|
||||||
|
# MSYS2 环境
|
||||||
|
CC = cc
|
||||||
|
else ifeq ($(On-macOS), 1)
|
||||||
|
CC = clang
|
||||||
|
else
|
||||||
|
CC = cc
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(On-macOS), 1)
|
||||||
|
DEBUGGER = lldb
|
||||||
|
else
|
||||||
|
DEBUGGER = gdb
|
||||||
|
endif
|
||||||
|
#=====================================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#======== Compilation Config ==========
|
||||||
CFLAGS += -Iinclude -Ilib
|
CFLAGS += -Iinclude -Ilib
|
||||||
|
|
||||||
ifeq ($(On-Windows), 1)
|
ifeq ($(On-Windows), 1)
|
||||||
@ -39,8 +68,6 @@ override WARN += -Wall -Wextra -Wno-unused-variable -Wno-unused-function -Wno-mi
|
|||||||
-Wno-missing-field-initializers -Wno-unused-parameter -Wno-sign-compare
|
-Wno-missing-field-initializers -Wno-unused-parameter -Wno-sign-compare
|
||||||
_C_Warning_Flags := $(WARN)
|
_C_Warning_Flags := $(WARN)
|
||||||
|
|
||||||
Target-Name = chsrc
|
|
||||||
|
|
||||||
DevMode-Target-Name = chsrc
|
DevMode-Target-Name = chsrc
|
||||||
DebugMode-Target-Name = chsrc-debug
|
DebugMode-Target-Name = chsrc-debug
|
||||||
ReleaseMode-Target-Name = chsrc-release
|
ReleaseMode-Target-Name = chsrc-release
|
||||||
@ -54,13 +81,13 @@ ifdef DEBUG
|
|||||||
CFLAGS += $(CFLAGS_debug)
|
CFLAGS += $(CFLAGS_debug)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
DEBUGGER = gdb
|
|
||||||
|
|
||||||
STATIC = 0
|
STATIC = 0
|
||||||
|
|
||||||
ifeq ($(STATIC), 1)
|
ifeq ($(STATIC), 1)
|
||||||
CFLAGS += $(CFLAGS_static)
|
CFLAGS += $(CFLAGS_static)
|
||||||
endif
|
endif
|
||||||
|
#=====================================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#====== CI release mode 的配置 =======
|
#====== CI release mode 的配置 =======
|
||||||
@ -74,7 +101,8 @@ endif
|
|||||||
#=====================================
|
#=====================================
|
||||||
|
|
||||||
|
|
||||||
#======= Aliases =========
|
|
||||||
|
#============ Aliases ================
|
||||||
all: build
|
all: build
|
||||||
|
|
||||||
b: build-in-dev-mode
|
b: build-in-dev-mode
|
||||||
@ -86,7 +114,9 @@ d: debug
|
|||||||
t: test
|
t: test
|
||||||
check: test
|
check: test
|
||||||
c: clean
|
c: clean
|
||||||
#=======================
|
#=====================================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
build-in-dev-mode:
|
build-in-dev-mode:
|
||||||
@echo Starting: Build in DEV mode: \'$(CC)\' $(CFLAGS) -o $(DevMode-Target-Name)
|
@echo Starting: Build in DEV mode: \'$(CC)\' $(CFLAGS) -o $(DevMode-Target-Name)
|
||||||
@ -111,6 +141,7 @@ build-in-ci-release-mode:
|
|||||||
@$(CC) src/chsrc-main.c $(CFLAGS) $(_C_Warning_Flags) -o $(CIReleaseMode-Target-Name)
|
@$(CC) src/chsrc-main.c $(CFLAGS) $(_C_Warning_Flags) -o $(CIReleaseMode-Target-Name)
|
||||||
@echo Finished: Build in CI-RELEASE mode
|
@echo Finished: Build in CI-RELEASE mode
|
||||||
|
|
||||||
|
# 永远重新编译
|
||||||
debug: build-in-debug-mode
|
debug: build-in-debug-mode
|
||||||
@$(DEBUGGER) $(DebugMode-Target-Name)
|
@$(DEBUGGER) $(DebugMode-Target-Name)
|
||||||
|
|
||||||
@ -122,7 +153,6 @@ test-make-env:
|
|||||||
@echo "On-macOS: $(On-macOS)"
|
@echo "On-macOS: $(On-macOS)"
|
||||||
@echo "CC: $(CC)"
|
@echo "CC: $(CC)"
|
||||||
@echo "CFLAGS: $(CFLAGS)"
|
@echo "CFLAGS: $(CFLAGS)"
|
||||||
@echo "Target-Name: $(Target-Name)"
|
|
||||||
@echo "USER: $$(whoami)"
|
@echo "USER: $$(whoami)"
|
||||||
@echo "PWD: $(shell pwd)"
|
@echo "PWD: $(shell pwd)"
|
||||||
@echo "UID: $$(id -u)"
|
@echo "UID: $$(id -u)"
|
||||||
@ -142,24 +172,25 @@ test-fw:
|
|||||||
@$(CC) test/fw.c $(CFLAGS) -o fw
|
@$(CC) test/fw.c $(CFLAGS) -o fw
|
||||||
@./fw
|
@./fw
|
||||||
|
|
||||||
|
|
||||||
check: test
|
check: test
|
||||||
|
|
||||||
# AUR package 安装时将执行此 target
|
# AUR package 安装时将执行此 target
|
||||||
fastcheck: $(Target-Name)
|
fastcheck: $(DevMode-Target-Name)
|
||||||
@perl ./test/cli.pl fastcheck
|
@perl ./test/cli.pl fastcheck
|
||||||
|
|
||||||
test-cli: $(Target-Name)
|
test-cli: $(DevMode-Target-Name)
|
||||||
@perl ./test/cli.pl
|
@perl ./test/cli.pl
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-@rm *.exe 2>/dev/null
|
-@rm *.exe 2>/dev/null
|
||||||
-@rm xy 2>/dev/null
|
-@rm xy 2>/dev/null
|
||||||
-@rm fw 2>/dev/null
|
-@rm fw 2>/dev/null
|
||||||
-@rm chsrc 2>/dev/null
|
-@rm README.md.bak* 2>/dev/null
|
||||||
-@rm chsrc-debug 2>/dev/null
|
|
||||||
-@rm chsrc-release 2>/dev/null
|
-@rm chsrc 2>/dev/null
|
||||||
-@rm README.md.bak* 2>/dev/null
|
-@rm chsrc-debug 2>/dev/null
|
||||||
|
-@rm chsrc-release 2>/dev/null
|
||||||
|
-@rm chsrc-ci-release 2>/dev/null
|
||||||
|
|
||||||
# -include pkg/deb/Makefile # 不这么做,因为 pkg/deb/Makefile 需要在 pkg/deb 目录下执行
|
# -include pkg/deb/Makefile # 不这么做,因为 pkg/deb/Makefile 需要在 pkg/deb 目录下执行
|
||||||
# 保持动词在前的任务名风格
|
# 保持动词在前的任务名风格
|
||||||
@ -169,8 +200,8 @@ build-deb:
|
|||||||
clean-deb:
|
clean-deb:
|
||||||
@$(MAKE) -C pkg/deb deb-clean
|
@$(MAKE) -C pkg/deb deb-clean
|
||||||
|
|
||||||
install: $(Target-Name)
|
install: build-in-release-mode
|
||||||
install -D -m 755 $(Target-Name) $(DESTDIR)/usr/bin/$(Target-Name)
|
install -D -m 755 $(ReleaseMode-Target-Name) $(DESTDIR)/usr/bin/chsrc
|
||||||
install -D -m 644 doc/chsrc.1 $(DESTDIR)/usr/share/man/man1/chsrc.1
|
install -D -m 644 doc/chsrc.1 $(DESTDIR)/usr/share/man/man1/chsrc.1
|
||||||
|
|
||||||
.PHONY: all build build-in-dev-mode build-in-debug-mode build-in-release-mode build-in-ci-release-mode debug check test test-make-env test-xy test-fw fastcheck test-cli clean install build-deb clean-deb
|
.PHONY: all build build-in-dev-mode build-in-debug-mode build-in-release-mode build-in-ci-release-mode debug check test test-make-env test-xy test-fw fastcheck test-cli clean install build-deb clean-deb
|
||||||
|
@ -47,20 +47,22 @@ $ git clone https://gitee.com/RubyMetric/chsrc.git -b dev
|
|||||||
### 编译运行
|
### 编译运行
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
make # 默认使用 cc 编译
|
make (b) # 在Windows上默认使用 cc 编译,在macOS上默认使用 clang 编译,在其他系统上默认使用 cc 编译
|
||||||
make CC=clang # 使用 clang 编译
|
make CC=clang # 使用 clang 编译
|
||||||
make CC=gcc # 使用 gcc 编译
|
make CC=gcc # 使用 gcc 编译
|
||||||
|
|
||||||
|
# 编译出 debug 版本: chsrc-debug
|
||||||
|
just bd
|
||||||
|
# 编译出 release 版本: chsrc-release
|
||||||
|
just br
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 重新编译并启动 GDB 调试
|
# 重新编译出 ./chsrc-debug,并启动 GDB 调试 (在macOS上启动 LLDB 调试)
|
||||||
$ make debug
|
$ make debug
|
||||||
|
|
||||||
# 重新编译并启动 LLDB 调试
|
# 重新编译出 ./chsrc-debug,并启动 LLDB 调试
|
||||||
$ make debug DEBUGGER=lldb
|
$ make debug DEBUGGER=lldb
|
||||||
|
|
||||||
# 如果需要单独生成含有编译信息的二进制文件(这个不会自己启动debugger)
|
|
||||||
$ make DEBUG=1
|
|
||||||
```
|
```
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
@ -100,7 +102,7 @@ just br
|
|||||||
# 重新编译出 ./chsrc-debug,并启动 GDB 调试 (在macOS上启动 LLDB 调试)
|
# 重新编译出 ./chsrc-debug,并启动 GDB 调试 (在macOS上启动 LLDB 调试)
|
||||||
$ just debug
|
$ just debug
|
||||||
|
|
||||||
# 使用其他调试器,如 LLDB 调试
|
# 重新编译出 ./chsrc-debug,并启动 LLDB 调试
|
||||||
$ just DEBUGGER=lldb debug
|
$ just DEBUGGER=lldb debug
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user