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

Simplify and Enhance Makefile for Better Readability, Compatibility, and Workflow Integration #4384

Closed
wants to merge 62 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
b53966b
Simplify Makefile for Better Readability and Compatibility with Autom…
Feb 11, 2025
cf09382
Update Makefile
Feb 12, 2025
348711e
Update Makefile
Feb 12, 2025
b434d3d
reuses the PARAMS variable
Feb 12, 2025
104a898
Update Makefile
Feb 12, 2025
6cf1579
Update Makefile
Feb 12, 2025
555e572
Update Makefile
Feb 12, 2025
8781cfa
Update Makefile
Feb 12, 2025
5d6e1f3
Update Makefile
Feb 12, 2025
3f4f8af
Merge branch 'XTLS:main' into Simplify-Makefile
Feb 12, 2025
0897041
Combine MIPS architecture handling in Makefile and streamline build p…
Feb 12, 2025
8817334
Update Makefile
Feb 12, 2025
4583dac
Update Makefile
Feb 12, 2025
9e16346
Update Makefile
Feb 12, 2025
12abe0e
Update Makefile
Feb 12, 2025
69175d9
Update Makefile
Feb 12, 2025
2fca726
Update Makefile
Feb 12, 2025
86ccacf
Update Makefile
RPRX Feb 13, 2025
031056d
Update Makefile
RPRX Feb 13, 2025
d2b2b50
Update Makefile
RPRX Feb 13, 2025
6cec651
Update Makefile
Feb 13, 2025
c7ed9ab
Update Makefile
Feb 13, 2025
82c8380
Update Makefile
Feb 13, 2025
38aecb0
Update Makefile
Feb 13, 2025
d7c37d2
Update Makefile
Feb 13, 2025
861904f
Update Makefile
Feb 13, 2025
20943d8
Update release.yml
Feb 13, 2025
3d58d69
Update Makefile
Feb 13, 2025
4fd05d8
Update release.yml
Feb 13, 2025
ce5bb07
Update release.yml
Feb 13, 2025
1cb56e9
Update Makefile
Feb 13, 2025
33b7431
Update release.yml
Feb 13, 2025
e970f70
Update release.yml
Feb 13, 2025
3aeda25
Update Makefile
Feb 13, 2025
f2a3c67
Update Makefile
Feb 13, 2025
88d9640
Update Makefile
Feb 13, 2025
507bf4c
Update Makefile
Feb 13, 2025
4e48407
Update Makefile
Feb 13, 2025
4f17bcd
Update Makefile
Feb 13, 2025
a46eadb
Merge branch 'XTLS:main' into Simplify-Makefile
Feb 13, 2025
19fb6a6
-ldflags is correctly set to strip debug information and reduce the b…
Feb 13, 2025
ce559f1
Update release.yml
Feb 13, 2025
e09f9ef
Update Makefile
Feb 13, 2025
2cf9365
Update Makefile
Feb 13, 2025
4c262a3
Update release.yml
Feb 13, 2025
99719ca
Update release.yml
Feb 13, 2025
d6c407c
Update release.yml
Feb 13, 2025
55f7e80
Update release.yml
Feb 13, 2025
5312d53
Update release.yml
Feb 13, 2025
b6889fd
Update release.yml
Feb 13, 2025
475fa96
Update Makefile
Feb 13, 2025
e708eee
Update Makefile
Feb 13, 2025
7703174
Update Makefile
Feb 13, 2025
d63e1a5
Update Makefile
Feb 13, 2025
cdfc298
Update release.yml
Feb 13, 2025
bcfb7e6
Update release.yml
Feb 14, 2025
284b2a8
Update Makefile
Feb 14, 2025
25dff4f
Update release.yml
Feb 14, 2025
819e54b
Update release.yml
Feb 14, 2025
a9e88a8
Update Makefile
Feb 14, 2025
666663d
Update Makefile
Feb 14, 2025
3785652
Update Makefile
Feb 14, 2025
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
55 changes: 41 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
NAME = xray

VERSION=$(shell git describe --always --dirty)

# NOTE: This MAKEFILE can be used to build Xray-core locally and in Automatic workflows. It is \
provided for convenience in automatic building and functions as a part of it.
# NOTE: If you need to modify this file, please be aware that:\
Expand All @@ -13,25 +9,56 @@ VERSION=$(shell git describe --always --dirty)
.github/workflows/release.yml \
Otherwise it is recommended to contact the project maintainers.

# Define the name of the output binary
NAME = xray

# Define the version using the latest git commit description
VERSION = $(shell git describe --always --dirty)

# Linker flags and build parameters
LDFLAGS = -X github.com/xtls/xray-core/core.build=$(VERSION) -s -w -buildid=
PARAMS = -trimpath -ldflags "$(LDFLAGS)" -v

# Main package to build
MAIN = ./main
PREFIX ?= $(shell go env GOPATH)

# Determine the output file name based on the OS
ifeq ($(GOOS),windows)
OUTPUT = $(NAME).exe
ADDITION = go build -o w$(NAME).exe -trimpath -ldflags "-H windowsgui $(LDFLAGS)" -v $(MAIN)
OUTPUT = $(NAME).exe
WXOUTPUT = w$(NAME).exe
else
This conversation was marked as resolved.
Show resolved Hide resolved
OUTPUT = $(NAME)
OUTPUT = $(NAME)
endif
ifeq ($(shell echo "$(GOARCH)" | grep -Eq "(mips|mipsle)" && echo true),true) #
ADDITION = GOMIPS=softfloat go build -o $(NAME)_softfloat -trimpath -ldflags "$(LDFLAGS)" -v $(MAIN)

# Handle MIPS architectures separately
ifeq ($(GOARCH),mips)
OUTPUT = $(NAME)_softfloat
endif
This conversation was marked as resolved.
Show resolved Hide resolved
.PHONY: clean build
This conversation was marked as resolved.
Show resolved Hide resolved

build:
# Phony targets to avoid conflicts with files named 'clean', 'build', 'test', or 'deps'
.PHONY: clean build test deps

# Install dependencies
deps:
go mod tidy
go mod download

# Build target to compile the binary
build: deps
go build -o $(OUTPUT) $(PARAMS) $(MAIN)
This conversation was marked as resolved.
Show resolved Hide resolved
This conversation was marked as resolved.
Show resolved Hide resolved
$(ADDITION)
# Additional build for wxray.exe on Windows
ifneq ($(WXOUTPUT),)
This conversation was marked as resolved.
Show resolved Hide resolved
go build -o $(WXOUTPUT) -trimpath -ldflags "-H windowsgui $(LDFLAGS)" -v $(MAIN)
endif
This conversation was marked as resolved.
Show resolved Hide resolved

# Run tests
test:
go test ./...

# Clean target to remove generated files
clean:
go clean -v -i $(PWD)
rm -f xray xray.exe wxray.exe xray_softfloat
rm -f $(NAME) $(NAME).exe w$(NAME).exe $(NAME)_softfloat

# Default target
default: build
Loading