Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve makefile #488

Merged
merged 6 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 16 additions & 46 deletions .github/workflows/go-c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
runs-on: ubuntu-20.04
name: build on ubuntu-20.04 x86_64
steps:
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: '1.21.0'
- name: Install Compilers
run: |
sudo apt-get update
sudo apt-get install --yes build-essential pkgconf libelf-dev llvm-9 clang-9 linux-tools-common linux-tools-generic
sudo apt-get install --yes build-essential pkgconf libelf-dev llvm-9 clang-9 linux-tools-common linux-tools-generic gcc
for tool in "clang" "llc" "llvm-strip"
do
sudo rm -f /usr/bin/$tool
Expand All @@ -33,30 +33,15 @@ jobs:
make clean
make env
make nocore -j4
cd ./lib/libpcap/ && sudo make install
cd $GITHUB_WORKSPACE
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v4
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
# version: v3.2.0

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
args: --disable-all -E errcheck

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true then the all caching functionality will be complete disabled,
# takes precedence over all other caching options.
# skip-cache: true

# Optional: if set to true then the action don't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# skip-build-cache: true
skip-cache: true
skip-pkg-cache: true
skip-build-cache: true
- name: Build NOCORE
run: |
make clean
Expand All @@ -69,13 +54,13 @@ jobs:
runs-on: ubuntu-22.04
name: build on ubuntu-22.04 x86_64
steps:
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: '1.21.0'
- name: Install Compilers
run: |
sudo apt-get update
sudo apt-get install --yes build-essential pkgconf libelf-dev llvm-14 clang-14 linux-tools-common linux-tools-generic
sudo apt-get install --yes build-essential pkgconf libelf-dev llvm-14 clang-14 linux-tools-common linux-tools-generic gcc
for tool in "clang" "llc" "llvm-strip"
do
sudo rm -f /usr/bin/$tool
Expand All @@ -91,30 +76,15 @@ jobs:
make clean
make env
make -j8
cd ./lib/libpcap/ && sudo make install
cd $GITHUB_WORKSPACE
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v4
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
# version: v3.2.0

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
args: --disable-all -E errcheck

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true then the all caching functionality will be complete disabled,
# takes precedence over all other caching options.
# skip-cache: true

# Optional: if set to true then the action don't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# skip-build-cache: true
skip-cache: true
skip-pkg-cache: true
skip-build-cache: true
- name: Build NOCORE
run: |
make clean
Expand Down
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ clean:
$(CMD_RM) -f assets/ebpf_probe.go
$(CMD_RM) -f bin/ecapture
$(CMD_RM) -f .check*
@if [ -e ./lib/libpcap/Makefile ] ; then \
cd ./lib/libpcap && make clean
fi

.PHONY: $(KERN_OBJECTS)
$(KERN_OBJECTS): %.o: %.c \
Expand Down Expand Up @@ -181,12 +184,12 @@ assets_nocore: \
$(TARGET_LIBPCAP):
test -f ./lib/libpcap/configure || git submodule update --init
cd lib/libpcap && \
CC=$(CMD_CLANG) CFLAGS="-O2 -g -gdwarf-4" ./configure --disable-rdma --disable-shared --disable-usb \
CC=$(CROSS_COMPILE)$(CMD_GCC) AR=$(CROSS_COMPILE)$(CMD_AR) CFLAGS="-O2 -g -gdwarf-4 -static" ./configure --disable-rdma --disable-shared --disable-usb \
--disable-netmap --disable-bluetooth --disable-dbus --without-libnl \
--without-dpdk --without-dag --without-septel --without-snf \
--without-gcc \
--without-gcc --with-pcap=linux --disable-ipv6\
--without-turbocap --host=$(LIBPCAP_ARCH) && \
make && $(SUDO) make install
CC=$(CROSS_COMPILE)gcc AR=$(CROSS_COMPILE)ar make

.PHONY: build
build: \
Expand Down
2 changes: 1 addition & 1 deletion builder/Makefile.release
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ PACKAGE_DESC = eCapture(旁观者): Capture SSL/TLS text content without a CA ce
PACKAGE_HOMEPAGE = https://ecapture.cc
PACKAGE_MAINTAINER = CFC4N <cfc4n.cs@gmail.com>
PACKAGE_VERSION ?= $(shell echo $(SNAPSHOT_VERSION) | $(CMD_SED) 's/v//g' )
OUT_DEB_FILE = $(OUTPUT_DIR)/$(PACKAGE_NAME)_linux_$(SNAPSHOT_VERSION)_$(ARCH).deb
OUT_DEB_FILE = $(OUTPUT_DIR)/$(PACKAGE_NAME)_$(SNAPSHOT_VERSION)_linux_$(ARCH).deb

# 构建目录
BUILD_DIR = build
Expand Down
5 changes: 4 additions & 1 deletion functions.mk
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ define allow-override
endef

define gobuild
CGO_CFLAGS='-O2 -g -gdwarf-4' GOARCH=$(GOARCH) CC=$(CMD_CLANG) $(CMD_GO) build -tags $(TARGET_TAG) -ldflags "-w -s -X 'ecapture/cli/cmd.GitVersion=$(TARGET_TAG)_$(UNAME_M):$(VERSION):$(VERSION_FLAG)' -X 'main.enableCORE=$(ENABLECORE)'" -o $(OUT_BIN)
CGO_CFLAGS='-O2 -g -gdwarf-4 -I$(CURDIR)/lib/libpcap/' \
CGO_LDFLAGS='-O2 -g -L$(CURDIR)/lib/libpcap -lpcap -static' \
GOOS=linux GOARCH=$(GOARCH) CC=$(CMD_CLANG) \
$(CMD_GO) build -tags $(TARGET_TAG) -ldflags "-w -s -X 'ecapture/cli/cmd.GitVersion=$(TARGET_TAG)_$(UNAME_M):$(VERSION):$(VERSION_FLAG)' -X 'main.enableCORE=$(ENABLECORE)'" -o $(OUT_BIN)
$(OUT_BIN) -v
endef
2 changes: 2 additions & 0 deletions variables.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ CMD_AWK ?= awk
CMD_SED ?= sed
CMD_GIT ?= git
CMD_CLANG ?= clang
CMD_GCC ?= gcc
CMD_AR ?= ar
CMD_STRIP ?= llvm-strip
CMD_RM ?= rm
CMD_INSTALL ?= install
Expand Down
Loading