From b53966bbe072ab79351a820c394b8679496ad627 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Tue, 11 Feb 2025 20:53:22 +0330 Subject: [PATCH 01/60] Simplify Makefile for Better Readability and Compatibility with Automated Builds (#1) * Update Makefile * Update Makefile * Update Makefile * Update Makefile * Update Makefile * Update Makefile * Update Makefile * Update Makefile * Add Environment Variables for Better Configuration, Manage Dependencies, Add Test Targets, Add Documentation * Update Makefile * simplified Makefile * Update Makefile --- Makefile | 55 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 7653e30658cc..ff6518339e13 100644 --- a/Makefile +++ b/Makefile @@ -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:\ @@ -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 -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 -.PHONY: clean build -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) - $(ADDITION) + # Additional build for wxray.exe on Windows +ifneq ($(WXOUTPUT),) + go build -o $(WXOUTPUT) -trimpath -ldflags "-H windowsgui $(LDFLAGS)" -v $(MAIN) +endif + +# 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 From cf09382a6d1f322bafd166a79ccd8d49a41f6105 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Wed, 12 Feb 2025 11:57:04 +0330 Subject: [PATCH 02/60] Update Makefile --- Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index ff6518339e13..eb1a7ebd53b1 100644 --- a/Makefile +++ b/Makefile @@ -40,15 +40,16 @@ endif # Install dependencies deps: - go mod tidy go mod download # Build target to compile the binary build: deps go build -o $(OUTPUT) $(PARAMS) $(MAIN) - # Additional build for wxray.exe on Windows ifneq ($(WXOUTPUT),) - go build -o $(WXOUTPUT) -trimpath -ldflags "-H windowsgui $(LDFLAGS)" -v $(MAIN) + go build -o $(WXOUTPUT) $(PARAMS) $(MAIN) +endif +ifeq ($(GOARCH),mips) + go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) endif # Run tests From 348711eed57f7713fea59a22024306243be4441f Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Wed, 12 Feb 2025 12:02:02 +0330 Subject: [PATCH 03/60] Update Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index eb1a7ebd53b1..21ddc934664f 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ ifneq ($(WXOUTPUT),) go build -o $(WXOUTPUT) $(PARAMS) $(MAIN) endif ifeq ($(GOARCH),mips) - go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) + GOMIPS=softfloat go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) endif # Run tests From b434d3dfc35d0e8a087be2188034f22869a12fea Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Wed, 12 Feb 2025 12:09:00 +0330 Subject: [PATCH 04/60] reuses the PARAMS variable From 104a898e50ad199e67994ed10fb34895a0d0e4a5 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Wed, 12 Feb 2025 14:16:36 +0330 Subject: [PATCH 05/60] Update Makefile --- Makefile | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 21ddc934664f..ce7c52894f67 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,6 @@ MAIN = ./main # Determine the output file name based on the OS ifeq ($(GOOS),windows) OUTPUT = $(NAME).exe - WXOUTPUT = w$(NAME).exe else OUTPUT = $(NAME) endif @@ -34,6 +33,9 @@ endif ifeq ($(GOARCH),mips) OUTPUT = $(NAME)_softfloat endif +ifeq ($(GOARCH),mipsle) + OUTPUT = $(NAME)_softfloat +endif # Phony targets to avoid conflicts with files named 'clean', 'build', 'test', or 'deps' .PHONY: clean build test deps @@ -45,12 +47,15 @@ deps: # Build target to compile the binary build: deps go build -o $(OUTPUT) $(PARAMS) $(MAIN) -ifneq ($(WXOUTPUT),) - go build -o $(WXOUTPUT) $(PARAMS) $(MAIN) +ifeq ($(GOOS),windows) + go build -o w$(NAME).exe -trimpath -ldflags "-H windowsgui $(LDFLAGS)" -v $(MAIN) endif ifeq ($(GOARCH),mips) GOMIPS=softfloat go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) endif +ifeq ($(GOARCH),mipsle) + GOMIPS=softfloat go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) +endif # Run tests test: From 6cf1579ef3a9d244488b31a7c6962321f76317ba Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Wed, 12 Feb 2025 14:28:18 +0330 Subject: [PATCH 06/60] Update Makefile --- Makefile | 3 --- 1 file changed, 3 deletions(-) diff --git a/Makefile b/Makefile index ce7c52894f67..bd4d70369ff8 100644 --- a/Makefile +++ b/Makefile @@ -30,9 +30,6 @@ else endif # Handle MIPS architectures separately -ifeq ($(GOARCH),mips) - OUTPUT = $(NAME)_softfloat -endif ifeq ($(GOARCH),mipsle) OUTPUT = $(NAME)_softfloat endif From 555e57258f50cd84da6af4fcdc128c190dbb688c Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Wed, 12 Feb 2025 19:05:44 +0330 Subject: [PATCH 07/60] Update Makefile --- Makefile | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Makefile b/Makefile index bd4d70369ff8..a0b72b4926dc 100644 --- a/Makefile +++ b/Makefile @@ -29,11 +29,6 @@ else OUTPUT = $(NAME) endif -# Handle MIPS architectures separately -ifeq ($(GOARCH),mipsle) - OUTPUT = $(NAME)_softfloat -endif - # Phony targets to avoid conflicts with files named 'clean', 'build', 'test', or 'deps' .PHONY: clean build test deps From 8781cfaa46815bd67716e3558bd20fd0f06922e1 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Wed, 12 Feb 2025 19:11:05 +0330 Subject: [PATCH 08/60] Update Makefile From 5d6e1f376888fdfc0367c21e759fa78f2691f740 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Wed, 12 Feb 2025 19:12:13 +0330 Subject: [PATCH 09/60] Update Makefile From 0897041df53c873f71225e45de7a959bde0a00c2 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Wed, 12 Feb 2025 19:36:02 +0330 Subject: [PATCH 10/60] Combine MIPS architecture handling in Makefile and streamline build process --- Makefile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Makefile b/Makefile index a0b72b4926dc..720af2545198 100644 --- a/Makefile +++ b/Makefile @@ -42,10 +42,7 @@ build: deps ifeq ($(GOOS),windows) go build -o w$(NAME).exe -trimpath -ldflags "-H windowsgui $(LDFLAGS)" -v $(MAIN) endif -ifeq ($(GOARCH),mips) - GOMIPS=softfloat go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) -endif -ifeq ($(GOARCH),mipsle) +ifneq (,$(findstring mips,$(GOARCH))) GOMIPS=softfloat go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) endif From 8817334d44d7b495dbf0ba531a4fecb7c733fb49 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Wed, 12 Feb 2025 19:43:10 +0330 Subject: [PATCH 11/60] Update Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 720af2545198..f42049839ac4 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,7 @@ build: deps ifeq ($(GOOS),windows) go build -o w$(NAME).exe -trimpath -ldflags "-H windowsgui $(LDFLAGS)" -v $(MAIN) endif -ifneq (,$(findstring mips,$(GOARCH))) +ifeq ($(GOARCH:0:4),mips) GOMIPS=softfloat go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) endif From 4583dacfcf45b07ee915b411007b76000721da13 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Wed, 12 Feb 2025 19:46:04 +0330 Subject: [PATCH 12/60] Update Makefile From 9e1634614ca9c545f610d0fa2e18cb06883f369c Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Wed, 12 Feb 2025 19:55:44 +0330 Subject: [PATCH 13/60] Update Makefile --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index f42049839ac4..4288ddc4ed4d 100644 --- a/Makefile +++ b/Makefile @@ -40,10 +40,10 @@ deps: build: deps go build -o $(OUTPUT) $(PARAMS) $(MAIN) ifeq ($(GOOS),windows) - go build -o w$(NAME).exe -trimpath -ldflags "-H windowsgui $(LDFLAGS)" -v $(MAIN) + go build -o w$(OUTPUT) -trimpath -ldflags "-H windowsgui $(LDFLAGS)" -v $(MAIN) endif ifeq ($(GOARCH:0:4),mips) - GOMIPS=softfloat go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) + GOMIPS=softfloat go build -o $(OUTPUT)_softfloat $(PARAMS) $(MAIN) endif # Run tests @@ -53,7 +53,7 @@ test: # Clean target to remove generated files clean: go clean -v -i $(PWD) - rm -f $(NAME) $(NAME).exe w$(NAME).exe $(NAME)_softfloat + rm -f $(NAME) $(NAME).exe w$(OUTPUT) $(OUTPUT)_softfloat # Default target default: build From 12abe0e70219808b0dd7e06fbe99f975414d6541 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Wed, 12 Feb 2025 19:58:17 +0330 Subject: [PATCH 14/60] Update Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4288ddc4ed4d..24cd6438feec 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,7 @@ build: deps ifeq ($(GOOS),windows) go build -o w$(OUTPUT) -trimpath -ldflags "-H windowsgui $(LDFLAGS)" -v $(MAIN) endif -ifeq ($(GOARCH:0:4),mips) +ifeq ($(word 1, $(GOARCH)),mips) GOMIPS=softfloat go build -o $(OUTPUT)_softfloat $(PARAMS) $(MAIN) endif From 69175d9fbd218918ffa915e3321fe8b35ec06b41 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Wed, 12 Feb 2025 19:59:54 +0330 Subject: [PATCH 15/60] Update Makefile --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 24cd6438feec..994ab08e4aca 100644 --- a/Makefile +++ b/Makefile @@ -38,12 +38,12 @@ deps: # Build target to compile the binary build: deps - go build -o $(OUTPUT) $(PARAMS) $(MAIN) + CGO_ENABLED=0 go build -o $(OUTPUT) $(PARAMS) $(MAIN) ifeq ($(GOOS),windows) - go build -o w$(OUTPUT) -trimpath -ldflags "-H windowsgui $(LDFLAGS)" -v $(MAIN) + CGO_ENABLED=0 go build -o w$(OUTPUT) -trimpath -ldflags "-H windowsgui $(LDFLAGS)" -v $(MAIN) endif ifeq ($(word 1, $(GOARCH)),mips) - GOMIPS=softfloat go build -o $(OUTPUT)_softfloat $(PARAMS) $(MAIN) + GOMIPS=softfloat CGO_ENABLED=0 go build -o $(OUTPUT)_softfloat $(PARAMS) $(MAIN) endif # Run tests From 2fca72665982a0357f08121c673dd78c57f69e7e Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Wed, 12 Feb 2025 20:30:29 +0330 Subject: [PATCH 16/60] Update Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 994ab08e4aca..260ee2f1fdf8 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,7 @@ build: deps ifeq ($(GOOS),windows) CGO_ENABLED=0 go build -o w$(OUTPUT) -trimpath -ldflags "-H windowsgui $(LDFLAGS)" -v $(MAIN) endif -ifeq ($(word 1, $(GOARCH)),mips) +ifeq ($(strip $(GOARCH:0:4)),mips) GOMIPS=softfloat CGO_ENABLED=0 go build -o $(OUTPUT)_softfloat $(PARAMS) $(MAIN) endif From 86ccacff4d732413f76867ce43d7db8b95046216 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Thu, 13 Feb 2025 05:25:13 +0000 Subject: [PATCH 17/60] Update Makefile --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 260ee2f1fdf8..da077dc7312f 100644 --- a/Makefile +++ b/Makefile @@ -41,8 +41,7 @@ build: deps CGO_ENABLED=0 go build -o $(OUTPUT) $(PARAMS) $(MAIN) ifeq ($(GOOS),windows) CGO_ENABLED=0 go build -o w$(OUTPUT) -trimpath -ldflags "-H windowsgui $(LDFLAGS)" -v $(MAIN) -endif -ifeq ($(strip $(GOARCH:0:4)),mips) +else ifeq ($(GOARCH:0:4),mips) GOMIPS=softfloat CGO_ENABLED=0 go build -o $(OUTPUT)_softfloat $(PARAMS) $(MAIN) endif From 031056da15bcd38090349621ae3748c28a889bde Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Thu, 13 Feb 2025 05:34:04 +0000 Subject: [PATCH 18/60] Update Makefile --- Makefile | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index da077dc7312f..b4166690cc67 100644 --- a/Makefile +++ b/Makefile @@ -22,13 +22,6 @@ PARAMS = -trimpath -ldflags "$(LDFLAGS)" -v # Main package to build MAIN = ./main -# Determine the output file name based on the OS -ifeq ($(GOOS),windows) - OUTPUT = $(NAME).exe -else - OUTPUT = $(NAME) -endif - # Phony targets to avoid conflicts with files named 'clean', 'build', 'test', or 'deps' .PHONY: clean build test deps @@ -38,11 +31,12 @@ deps: # Build target to compile the binary build: deps - CGO_ENABLED=0 go build -o $(OUTPUT) $(PARAMS) $(MAIN) + CGO_ENABLED=0 go build -o $(NAME) $(PARAMS) $(MAIN) ifeq ($(GOOS),windows) - CGO_ENABLED=0 go build -o w$(OUTPUT) -trimpath -ldflags "-H windowsgui $(LDFLAGS)" -v $(MAIN) + mv $(NAME) $(NAME).exe + CGO_ENABLED=0 go build -o w$(NAME).exe -trimpath -ldflags "-H windowsgui $(LDFLAGS)" -v $(MAIN) else ifeq ($(GOARCH:0:4),mips) - GOMIPS=softfloat CGO_ENABLED=0 go build -o $(OUTPUT)_softfloat $(PARAMS) $(MAIN) + GOMIPS=softfloat CGO_ENABLED=0 go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) endif # Run tests @@ -52,7 +46,7 @@ test: # Clean target to remove generated files clean: go clean -v -i $(PWD) - rm -f $(NAME) $(NAME).exe w$(OUTPUT) $(OUTPUT)_softfloat + rm -f $(NAME) $(NAME).exe w$(NAME).exe $(NAME)_softfloat # Default target default: build From d2b2b50f13d85eabcf904419e82492a85738ea52 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Thu, 13 Feb 2025 06:11:55 +0000 Subject: [PATCH 19/60] Update Makefile https://github.com/XTLS/Xray-core/issues/28#issuecomment-736589268 --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b4166690cc67..56009d335100 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ build: deps CGO_ENABLED=0 go build -o $(NAME) $(PARAMS) $(MAIN) ifeq ($(GOOS),windows) mv $(NAME) $(NAME).exe - CGO_ENABLED=0 go build -o w$(NAME).exe -trimpath -ldflags "-H windowsgui $(LDFLAGS)" -v $(MAIN) + echo 'CreateObject("Wscript.Shell").Run "$(NAME).exe",0' > $(NAME)_no_window.vps else ifeq ($(GOARCH:0:4),mips) GOMIPS=softfloat CGO_ENABLED=0 go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) endif @@ -46,7 +46,7 @@ test: # Clean target to remove generated files clean: go clean -v -i $(PWD) - rm -f $(NAME) $(NAME).exe w$(NAME).exe $(NAME)_softfloat + rm -f $(NAME) $(NAME).exe $(NAME)_no_window.vps $(NAME)_softfloat # Default target default: build From 6cec65176a86ae319bfc4ce42d367823964c9033 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 10:00:09 +0330 Subject: [PATCH 20/60] Update Makefile --- Makefile | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 56009d335100..8e52f4bd9dfa 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,17 @@ .github/workflows/release.yml \ Otherwise it is recommended to contact the project maintainers. +# 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:\ + - This file is not the main Makefile; it only accepts environment variables and builds the \ + binary.\ + - Automatic building expects the correct binaries to be built by this Makefile. If you \ + intend to propose a change to this Makefile, carefully review the file below and ensure \ + that the change will not accidentally break the automatic building:\ + .github/workflows/release.yml \ + Otherwise it is recommended to contact the project maintainers. + # Define the name of the output binary NAME = xray @@ -35,7 +46,7 @@ build: deps ifeq ($(GOOS),windows) mv $(NAME) $(NAME).exe echo 'CreateObject("Wscript.Shell").Run "$(NAME).exe",0' > $(NAME)_no_window.vps -else ifeq ($(GOARCH:0:4),mips) +else ifeq ($(word 1, $(GOARCH)),mips) GOMIPS=softfloat CGO_ENABLED=0 go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) endif From c7ed9ab4b38da0325b0918eb03f18754adfac033 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 10:31:43 +0330 Subject: [PATCH 21/60] Update Makefile --- Makefile | 48 ++++++++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index 8e52f4bd9dfa..6f4f68c9fc77 100644 --- a/Makefile +++ b/Makefile @@ -1,24 +1,13 @@ # 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. + 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:\ - - This file is not the main Makefile; it only accepts environment variables and builds the \ - binary.\ - - Automatic building expects the correct binaries to be built by this Makefile. If you \ - intend to propose a change to this Makefile, carefully review the file below and ensure \ - that the change will not accidentally break the automatic building:\ - .github/workflows/release.yml \ - Otherwise it is recommended to contact the project maintainers. - -# 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:\ - - This file is not the main Makefile; it only accepts environment variables and builds the \ - binary.\ - - Automatic building expects the correct binaries to be built by this Makefile. If you \ - intend to propose a change to this Makefile, carefully review the file below and ensure \ - that the change will not accidentally break the automatic building:\ - .github/workflows/release.yml \ - Otherwise it is recommended to contact the project maintainers. + - This file is not the main Makefile; it only accepts environment variables and builds the \ + binary.\ + - Automatic building expects the correct binaries to be built by this Makefile. If you \ + intend to propose a change to this Makefile, carefully review the file below and ensure \ + that the change will not accidentally break the automatic building:\ + .github/workflows/release.yml \ + Otherwise it is recommended to contact the project maintainers. # Define the name of the output binary NAME = xray @@ -33,31 +22,34 @@ PARAMS = -trimpath -ldflags "$(LDFLAGS)" -v # Main package to build MAIN = ./main +# Define the prefix for installation +PREFIX ?= $(shell go env GOPATH) + # Phony targets to avoid conflicts with files named 'clean', 'build', 'test', or 'deps' .PHONY: clean build test deps # Install dependencies deps: - go mod download + go mod download # Build target to compile the binary build: deps - CGO_ENABLED=0 go build -o $(NAME) $(PARAMS) $(MAIN) + CGO_ENABLED=0 go build -o $(NAME) $(PARAMS) $(MAIN) ifeq ($(GOOS),windows) - mv $(NAME) $(NAME).exe - echo 'CreateObject("Wscript.Shell").Run "$(NAME).exe",0' > $(NAME)_no_window.vps -else ifeq ($(word 1, $(GOARCH)),mips) - GOMIPS=softfloat CGO_ENABLED=0 go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) + mv $(NAME) $(NAME).exe + echo 'CreateObject("Wscript.Shell").Run "$(NAME).exe",0' > $(NAME)_no_window.vbs +else ifeq ($(GOARCH:0:4),mips) + GOMIPS=softfloat CGO_ENABLED=0 go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) endif # Run tests test: - go test ./... + go test ./... # Clean target to remove generated files clean: - go clean -v -i $(PWD) - rm -f $(NAME) $(NAME).exe $(NAME)_no_window.vps $(NAME)_softfloat + go clean -v -i $(PWD) + rm -f $(NAME) $(NAME).exe $(NAME)_no_window.vbs $(NAME)_softfloat # Default target default: build From 82c8380f330f7ad061e6888ad0ffd537ddbfb3fb Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 10:39:10 +0330 Subject: [PATCH 22/60] Update Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6f4f68c9fc77..b6219e2a8166 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ build: deps ifeq ($(GOOS),windows) mv $(NAME) $(NAME).exe echo 'CreateObject("Wscript.Shell").Run "$(NAME).exe",0' > $(NAME)_no_window.vbs -else ifeq ($(GOARCH:0:4),mips) +else ifeq ($(strip $(GOARCH:0:4)),mips) GOMIPS=softfloat CGO_ENABLED=0 go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) endif From 38aecb068e9691d2d05a3c2f04cb7a9d8836556b Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 10:40:02 +0330 Subject: [PATCH 23/60] Update Makefile --- Makefile | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index b6219e2a8166..edcebad3c428 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,13 @@ # 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. + 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:\ - - This file is not the main Makefile; it only accepts environment variables and builds the \ - binary.\ - - Automatic building expects the correct binaries to be built by this Makefile. If you \ - intend to propose a change to this Makefile, carefully review the file below and ensure \ - that the change will not accidentally break the automatic building:\ - .github/workflows/release.yml \ - Otherwise it is recommended to contact the project maintainers. + - This file is not the main Makefile; it only accepts environment variables and builds the \ + binary.\ + - Automatic building expects the correct binaries to be built by this Makefile. If you \ + intend to propose a change to this Makefile, carefully review the file below and ensure \ + that the change will not accidentally break the automatic building:\ + .github/workflows/release.yml \ + Otherwise it is recommended to contact the project maintainers. # Define the name of the output binary NAME = xray @@ -22,34 +22,31 @@ PARAMS = -trimpath -ldflags "$(LDFLAGS)" -v # Main package to build MAIN = ./main -# Define the prefix for installation -PREFIX ?= $(shell go env GOPATH) - # Phony targets to avoid conflicts with files named 'clean', 'build', 'test', or 'deps' .PHONY: clean build test deps # Install dependencies deps: - go mod download + go mod download # Build target to compile the binary build: deps - CGO_ENABLED=0 go build -o $(NAME) $(PARAMS) $(MAIN) + CGO_ENABLED=0 go build -o $(NAME) $(PARAMS) $(MAIN) ifeq ($(GOOS),windows) - mv $(NAME) $(NAME).exe - echo 'CreateObject("Wscript.Shell").Run "$(NAME).exe",0' > $(NAME)_no_window.vbs -else ifeq ($(strip $(GOARCH:0:4)),mips) - GOMIPS=softfloat CGO_ENABLED=0 go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) + mv $(NAME) $(NAME).exe + echo 'CreateObject("Wscript.Shell").Run "$(NAME).exe",0' > $(NAME)_no_window.vps +else ifeq ($(word 1, $(GOARCH)),mips) + GOMIPS=softfloat CGO_ENABLED=0 go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) endif # Run tests test: - go test ./... + go test ./... # Clean target to remove generated files clean: - go clean -v -i $(PWD) - rm -f $(NAME) $(NAME).exe $(NAME)_no_window.vbs $(NAME)_softfloat + go clean -v -i $(PWD) + rm -f $(NAME) $(NAME).exe $(NAME)_no_window.vps $(NAME)_softfloat # Default target default: build From d7c37d2a052aaa6977ad2d041feaa2e467af9b33 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 10:44:53 +0330 Subject: [PATCH 24/60] Update Makefile From 861904f0e58ca0eae49cef1b9eb2db7df8d78dde Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 10:55:50 +0330 Subject: [PATCH 25/60] Update Makefile --- Makefile | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index edcebad3c428..ee887063144f 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,9 @@ PARAMS = -trimpath -ldflags "$(LDFLAGS)" -v # Main package to build MAIN = ./main +# Prefix for installation +PREFIX ?= /usr/local + # Phony targets to avoid conflicts with files named 'clean', 'build', 'test', or 'deps' .PHONY: clean build test deps @@ -34,8 +37,10 @@ build: deps CGO_ENABLED=0 go build -o $(NAME) $(PARAMS) $(MAIN) ifeq ($(GOOS),windows) mv $(NAME) $(NAME).exe - echo 'CreateObject("Wscript.Shell").Run "$(NAME).exe",0' > $(NAME)_no_window.vps -else ifeq ($(word 1, $(GOARCH)),mips) + echo 'CreateObject("Wscript.Shell").Run "$(NAME).exe",0' > $(NAME)_no_window.vbs +else ifeq ($(GOARCH),mips) + GOMIPS=softfloat CGO_ENABLED=0 go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) +else ifeq ($(GOARCH),mipsle) GOMIPS=softfloat CGO_ENABLED=0 go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) endif @@ -46,7 +51,14 @@ test: # Clean target to remove generated files clean: go clean -v -i $(PWD) - rm -f $(NAME) $(NAME).exe $(NAME)_no_window.vps $(NAME)_softfloat + rm -f $(NAME) $(NAME).exe $(NAME)_no_window.vbs $(NAME)_softfloat # Default target default: build + +# Install target +install: build + install -Dm755 $(NAME) $(PREFIX)/bin/$(NAME) +ifeq ($(GOOS),windows) + install -Dm755 $(NAME)_no_window.vbs $(PREFIX)/bin/$(NAME)_no_window.vbs +endif From 20943d8c7e527805f85a1d0881d909ea99478992 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 11:08:32 +0330 Subject: [PATCH 26/60] Update release.yml --- .github/workflows/release.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7bc8c51d18cd..e21ca2a02f57 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -106,6 +106,7 @@ jobs: GOARCH: ${{ matrix.goarch }} GOARM: ${{ matrix.goarm }} CGO_ENABLED: 0 + PREFIX: /usr/local steps: - name: Checkout codebase uses: actions/checkout@v4 @@ -143,6 +144,9 @@ jobs: mv -f resources/* build_assets cp ${GITHUB_WORKSPACE}/README.md ./build_assets/README.md cp ${GITHUB_WORKSPACE}/LICENSE ./build_assets/LICENSE + if [ "$GOOS" = "windows" ]; then + cp ${GITHUB_WORKSPACE}/xray_no_window.vbs ./build_assets/xray_no_window.vbs + fi - name: Create ZIP archive if: github.event_name == 'release' From 3d58d699b6bb09f2c90337caf7270bc35a38bfb1 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 11:12:36 +0330 Subject: [PATCH 27/60] Update Makefile From 4fd05d8015c82fa221db4a9594d6c073649ed992 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 11:13:03 +0330 Subject: [PATCH 28/60] Update release.yml From ce5bb079c873761d8020728170793307e8b69a66 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 11:15:33 +0330 Subject: [PATCH 29/60] Update release.yml --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e21ca2a02f57..42dc11926efa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -145,7 +145,7 @@ jobs: cp ${GITHUB_WORKSPACE}/README.md ./build_assets/README.md cp ${GITHUB_WORKSPACE}/LICENSE ./build_assets/LICENSE if [ "$GOOS" = "windows" ]; then - cp ${GITHUB_WORKSPACE}/xray_no_window.vbs ./build_assets/xray_no_window.vbs + cp ${GITHUB_WORKSPACE}/xray_no_window.vbs ./build_assets/xray_no_window.vbs || echo "xray_no_window.vbs not found, skipping." fi - name: Create ZIP archive From 1cb56e91eb2f3663c965e55da23b5ac0660923ff Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 11:57:33 +0330 Subject: [PATCH 30/60] Update Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ee887063144f..99654df88362 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ MAIN = ./main PREFIX ?= /usr/local # Phony targets to avoid conflicts with files named 'clean', 'build', 'test', or 'deps' -.PHONY: clean build test deps +.PHONY: clean build test deps install default # Install dependencies deps: From 33b7431355b665e3f484647ac9ca8c7fc083abea Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 11:58:04 +0330 Subject: [PATCH 31/60] Update release.yml --- .github/workflows/release.yml | 73 +++-------------------------------- 1 file changed, 5 insertions(+), 68 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 42dc11926efa..e55ae2d100be 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,11 +1,5 @@ name: Build and Release -# NOTE: This Github Actions file depends on the Makefile. -# Building the correct package requires the correct binaries generated by the Makefile. To -# ensure the correct output, the Makefile must accept the appropriate input and compile the -# correct file with the correct name. If you need to modify this file, please ensure it won't -# disrupt the Makefile. - on: workflow_dispatch: release: @@ -20,91 +14,34 @@ jobs: contents: write strategy: matrix: - # Include amd64 on all platforms. goos: [windows, freebsd, openbsd, linux, darwin] goarch: [amd64, 386] - patch-assetname: [""] exclude: - # Exclude i386 on darwin - goarch: 386 goos: darwin include: - # BEGIN MacOS ARM64 - goos: darwin goarch: arm64 - # END MacOS ARM64 - # BEGIN Linux ARM 5 6 7 - - goos: linux - goarch: arm - goarm: 7 - goos: linux goarch: arm - goarm: 6 - - goos: linux - goarch: arm - goarm: 5 - # END Linux ARM 5 6 7 - # BEGIN Android ARM 8 + goarm: [5, 6, 7] - goos: android goarch: arm64 - # END Android ARM 8 - # Windows ARM - goos: windows - goarch: arm64 - - goos: windows - goarch: arm + goarch: [arm64, arm] goarm: 7 - # BEGIN Other architectures - # BEGIN riscv64 & ARM64 & LOONG64 - - goos: linux - goarch: arm64 - - goos: linux - goarch: riscv64 - - goos: linux - goarch: loong64 - # END riscv64 & ARM64 & LOONG64 - # BEGIN MIPS - goos: linux - goarch: mips64 - - goos: linux - goarch: mips64le - - goos: linux - goarch: mipsle - - goos: linux - goarch: mips - # END MIPS - # BEGIN PPC - - goos: linux - goarch: ppc64 - - goos: linux - goarch: ppc64le - # END PPC - # BEGIN FreeBSD ARM - - goos: freebsd - goarch: arm64 + goarch: [arm64, riscv64, loong64, mips64, mips64le, mipsle, mips, ppc64, ppc64le, s390x] - goos: freebsd - goarch: arm + goarch: [arm64, arm] goarm: 7 - # END FreeBSD ARM - # BEGIN S390X - - goos: linux - goarch: s390x - # END S390X - # END Other architectures - # BEGIN OPENBSD ARM - goos: openbsd - goarch: arm64 - - goos: openbsd - goarch: arm + goarch: [arm64, arm] goarm: 7 - # END OPENBSD ARM fail-fast: false runs-on: ubuntu-latest env: - GOOS: ${{ matrix.goos }} - GOARCH: ${{ matrix.goarch }} - GOARM: ${{ matrix.goarm }} CGO_ENABLED: 0 PREFIX: /usr/local steps: From e970f704ef50c113130e1804a9c65fad26dfb7ba Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 12:02:00 +0330 Subject: [PATCH 32/60] Update release.yml --- .github/workflows/release.yml | 73 ++++++++++++++++++++++++++++++++--- 1 file changed, 68 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e55ae2d100be..42dc11926efa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,5 +1,11 @@ name: Build and Release +# NOTE: This Github Actions file depends on the Makefile. +# Building the correct package requires the correct binaries generated by the Makefile. To +# ensure the correct output, the Makefile must accept the appropriate input and compile the +# correct file with the correct name. If you need to modify this file, please ensure it won't +# disrupt the Makefile. + on: workflow_dispatch: release: @@ -14,34 +20,91 @@ jobs: contents: write strategy: matrix: + # Include amd64 on all platforms. goos: [windows, freebsd, openbsd, linux, darwin] goarch: [amd64, 386] + patch-assetname: [""] exclude: + # Exclude i386 on darwin - goarch: 386 goos: darwin include: + # BEGIN MacOS ARM64 - goos: darwin goarch: arm64 + # END MacOS ARM64 + # BEGIN Linux ARM 5 6 7 + - goos: linux + goarch: arm + goarm: 7 - goos: linux goarch: arm - goarm: [5, 6, 7] + goarm: 6 + - goos: linux + goarch: arm + goarm: 5 + # END Linux ARM 5 6 7 + # BEGIN Android ARM 8 - goos: android goarch: arm64 + # END Android ARM 8 + # Windows ARM - goos: windows - goarch: [arm64, arm] + goarch: arm64 + - goos: windows + goarch: arm goarm: 7 + # BEGIN Other architectures + # BEGIN riscv64 & ARM64 & LOONG64 + - goos: linux + goarch: arm64 + - goos: linux + goarch: riscv64 + - goos: linux + goarch: loong64 + # END riscv64 & ARM64 & LOONG64 + # BEGIN MIPS - goos: linux - goarch: [arm64, riscv64, loong64, mips64, mips64le, mipsle, mips, ppc64, ppc64le, s390x] + goarch: mips64 + - goos: linux + goarch: mips64le + - goos: linux + goarch: mipsle + - goos: linux + goarch: mips + # END MIPS + # BEGIN PPC + - goos: linux + goarch: ppc64 + - goos: linux + goarch: ppc64le + # END PPC + # BEGIN FreeBSD ARM + - goos: freebsd + goarch: arm64 - goos: freebsd - goarch: [arm64, arm] + goarch: arm goarm: 7 + # END FreeBSD ARM + # BEGIN S390X + - goos: linux + goarch: s390x + # END S390X + # END Other architectures + # BEGIN OPENBSD ARM - goos: openbsd - goarch: [arm64, arm] + goarch: arm64 + - goos: openbsd + goarch: arm goarm: 7 + # END OPENBSD ARM fail-fast: false runs-on: ubuntu-latest env: + GOOS: ${{ matrix.goos }} + GOARCH: ${{ matrix.goarch }} + GOARM: ${{ matrix.goarm }} CGO_ENABLED: 0 PREFIX: /usr/local steps: From 3aeda251c60853955767dc679dd70853db397374 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 12:20:30 +0330 Subject: [PATCH 33/60] Update Makefile --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 99654df88362..027a190395fa 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ deps: # Build target to compile the binary build: deps CGO_ENABLED=0 go build -o $(NAME) $(PARAMS) $(MAIN) -ifeq ($(GOOS),windows) +ifneq ($(GOOS),windows) mv $(NAME) $(NAME).exe echo 'CreateObject("Wscript.Shell").Run "$(NAME).exe",0' > $(NAME)_no_window.vbs else ifeq ($(GOARCH),mips) @@ -59,6 +59,6 @@ default: build # Install target install: build install -Dm755 $(NAME) $(PREFIX)/bin/$(NAME) -ifeq ($(GOOS),windows) +ifneq ($(GOOS),windows) install -Dm755 $(NAME)_no_window.vbs $(PREFIX)/bin/$(NAME)_no_window.vbs endif From f2a3c67f8abc7d731214edc8df40baf420402a62 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 12:25:39 +0330 Subject: [PATCH 34/60] Update Makefile --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 027a190395fa..2f9866d233c8 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,9 @@ MAIN = ./main # Prefix for installation PREFIX ?= /usr/local +# Number of parallel jobs +JOBS ?= $(shell nproc) + # Phony targets to avoid conflicts with files named 'clean', 'build', 'test', or 'deps' .PHONY: clean build test deps install default From 88d964083909e76d3b5e00a856275a7a0fd64985 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 12:43:50 +0330 Subject: [PATCH 35/60] Update Makefile From 507bf4c9a166c9073de00bdbe2cf84825842a37c Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 12:45:42 +0330 Subject: [PATCH 36/60] Update Makefile From 4e48407593833ab3eaf54023dbdb93dfe2852d2e Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 13:34:48 +0330 Subject: [PATCH 37/60] Update Makefile --- Makefile | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 2f9866d233c8..3102a4bfe9b9 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ PREFIX ?= /usr/local JOBS ?= $(shell nproc) # Phony targets to avoid conflicts with files named 'clean', 'build', 'test', or 'deps' -.PHONY: clean build test deps install default +.PHONY: clean build test deps default # Install dependencies deps: @@ -58,10 +58,3 @@ clean: # Default target default: build - -# Install target -install: build - install -Dm755 $(NAME) $(PREFIX)/bin/$(NAME) -ifneq ($(GOOS),windows) - install -Dm755 $(NAME)_no_window.vbs $(PREFIX)/bin/$(NAME)_no_window.vbs -endif From 4f17bcdb767a5172ac5a3435dc21ffddc39a3ce1 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 17:54:57 +0330 Subject: [PATCH 38/60] Update Makefile --- Makefile | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 3102a4bfe9b9..57af0106eb49 100644 --- a/Makefile +++ b/Makefile @@ -23,21 +23,30 @@ PARAMS = -trimpath -ldflags "$(LDFLAGS)" -v MAIN = ./main # Prefix for installation -PREFIX ?= /usr/local - -# Number of parallel jobs -JOBS ?= $(shell nproc) +PREFIX ?= $(shell go env GOPATH) # Phony targets to avoid conflicts with files named 'clean', 'build', 'test', or 'deps' .PHONY: clean build test deps default # Install dependencies deps: + @echo "Downloading dependencies..." go mod download + @if [ $$? -ne 0 ]; then \ + echo "Error downloading dependencies"; \ + exit 1; \ + fi + @echo "Dependencies downloaded successfully" # Build target to compile the binary build: deps + @echo "Building the binary..." CGO_ENABLED=0 go build -o $(NAME) $(PARAMS) $(MAIN) + @if [ $$? -ne 0 ]; then \ + echo "Error building the binary"; \ + exit 1; \ + fi + @echo "Binary built successfully" ifneq ($(GOOS),windows) mv $(NAME) $(NAME).exe echo 'CreateObject("Wscript.Shell").Run "$(NAME).exe",0' > $(NAME)_no_window.vbs @@ -45,6 +54,8 @@ else ifeq ($(GOARCH),mips) GOMIPS=softfloat CGO_ENABLED=0 go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) else ifeq ($(GOARCH),mipsle) GOMIPS=softfloat CGO_ENABLED=0 go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) +else + @echo "No special build steps for this architecture." endif # Run tests From 19fb6a6ce805b674d11e0bb4e1c9850f7055e406 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 18:22:10 +0330 Subject: [PATCH 39/60] -ldflags is correctly set to strip debug information and reduce the binary size --- .github/workflows/release.yml | 187 +++++++--------------------------- 1 file changed, 34 insertions(+), 153 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 42dc11926efa..ee086cfbc1bb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,106 +1,19 @@ -name: Build and Release - -# NOTE: This Github Actions file depends on the Makefile. -# Building the correct package requires the correct binaries generated by the Makefile. To -# ensure the correct output, the Makefile must accept the appropriate input and compile the -# correct file with the correct name. If you need to modify this file, please ensure it won't -# disrupt the Makefile. +name: Release on: - workflow_dispatch: - release: - types: [published] push: - pull_request: - types: [opened, synchronize, reopened] + tags: + - 'v*.*.*' + workflow_dispatch: jobs: build: - permissions: - contents: write + runs-on: ${{ matrix.os }} strategy: matrix: - # Include amd64 on all platforms. - goos: [windows, freebsd, openbsd, linux, darwin] - goarch: [amd64, 386] - patch-assetname: [""] - exclude: - # Exclude i386 on darwin - - goarch: 386 - goos: darwin - include: - # BEGIN MacOS ARM64 - - goos: darwin - goarch: arm64 - # END MacOS ARM64 - # BEGIN Linux ARM 5 6 7 - - goos: linux - goarch: arm - goarm: 7 - - goos: linux - goarch: arm - goarm: 6 - - goos: linux - goarch: arm - goarm: 5 - # END Linux ARM 5 6 7 - # BEGIN Android ARM 8 - - goos: android - goarch: arm64 - # END Android ARM 8 - # Windows ARM - - goos: windows - goarch: arm64 - - goos: windows - goarch: arm - goarm: 7 - # BEGIN Other architectures - # BEGIN riscv64 & ARM64 & LOONG64 - - goos: linux - goarch: arm64 - - goos: linux - goarch: riscv64 - - goos: linux - goarch: loong64 - # END riscv64 & ARM64 & LOONG64 - # BEGIN MIPS - - goos: linux - goarch: mips64 - - goos: linux - goarch: mips64le - - goos: linux - goarch: mipsle - - goos: linux - goarch: mips - # END MIPS - # BEGIN PPC - - goos: linux - goarch: ppc64 - - goos: linux - goarch: ppc64le - # END PPC - # BEGIN FreeBSD ARM - - goos: freebsd - goarch: arm64 - - goos: freebsd - goarch: arm - goarm: 7 - # END FreeBSD ARM - # BEGIN S390X - - goos: linux - goarch: s390x - # END S390X - # END Other architectures - # BEGIN OPENBSD ARM - - goos: openbsd - goarch: arm64 - - goos: openbsd - goarch: arm - goarm: 7 - # END OPENBSD ARM - fail-fast: false - - runs-on: ubuntu-latest + goos: [linux, darwin, windows] + goarch: [amd64, arm64] + goarm: [6] env: GOOS: ${{ matrix.goos }} GOARCH: ${{ matrix.goarch }} @@ -110,75 +23,43 @@ jobs: steps: - name: Checkout codebase uses: actions/checkout@v4 - - - name: Show workflow information - run: | - _NAME=${{ matrix.patch-assetname }} - [ -n "$_NAME" ] || _NAME=$(jq ".[\"$GOOS-$GOARCH$GOARM$GOMIPS\"].friendlyName" -r < .github/build/friendly-filenames.json) - echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, GOMIPS: $GOMIPS, RELEASE_NAME: $_NAME" - echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV - - name: Set up Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v4 with: - go-version-file: go.mod - check-latest: true - - - name: Get project dependencies - run: go mod download - - - name: Build Xray - run: | - mkdir -p build_assets - make - find . -maxdepth 1 -type f -regex './\(wxray\|xray\|xray_softfloat\)\(\|.exe\)' -exec mv {} ./build_assets/ \; - - - name: Restore Geodat Cache - uses: actions/cache/restore@v4 + go-version: 1.17 + - name: Cache Go modules + uses: actions/cache@v2 with: - path: resources - key: xray-geodat- - - - name: Copy README.md & LICENSE + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: Build run: | + if [ "$GOOS" = "windows" ]; then + go build -ldflags "-s -w" -o xray.exe ./main + else + go build -ldflags "-s -w" -o xray ./main + fi + - name: Prepare assets + run: | + mkdir -p build_assets mv -f resources/* build_assets cp ${GITHUB_WORKSPACE}/README.md ./build_assets/README.md cp ${GITHUB_WORKSPACE}/LICENSE ./build_assets/LICENSE if [ "$GOOS" = "windows" ]; then cp ${GITHUB_WORKSPACE}/xray_no_window.vbs ./build_assets/xray_no_window.vbs || echo "xray_no_window.vbs not found, skipping." fi - - name: Create ZIP archive if: github.event_name == 'release' - shell: bash - run: | - pushd build_assets || exit 1 - touch -mt $(date +%Y01010000) * - zip -9vr ../Xray-${{ env.ASSET_NAME }}.zip . - popd || exit 1 - FILE=./Xray-${{ env.ASSET_NAME }}.zip - DGST=$FILE.dgst - for METHOD in {"md5","sha1","sha256","sha512"} - do - openssl dgst -$METHOD $FILE | sed 's/([^)]*)//g' >>$DGST - done - - - name: Change the name run: | - mv build_assets Xray-${{ env.ASSET_NAME }} - - - name: Upload files to Artifacts - uses: actions/upload-artifact@v4 - with: - name: Xray-${{ env.ASSET_NAME }} - path: | - ./Xray-${{ env.ASSET_NAME }}/* - - - name: Upload binaries to release - uses: svenstaro/upload-release-action@v2 - if: github.event_name == 'release' + cd build_assets + zip -r ../xray-${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.goarm }}.zip * + cd .. + - name: Upload release asset + uses: actions/upload-artifact@v2 with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: ./Xray-${{ env.ASSET_NAME }}.zip* - tag: ${{ github.ref }} - file_glob: true + name: xray-${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.goarm }}.zip + path: xray-${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.goarm }}.zip From ce559f16b91b22af5345b00de333424152b8e732 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 18:22:48 +0330 Subject: [PATCH 40/60] Update release.yml --- .github/workflows/release.yml | 191 +++++++++++++++++++++++++++------- 1 file changed, 153 insertions(+), 38 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ee086cfbc1bb..7bc8c51d18cd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,65 +1,180 @@ -name: Release +name: Build and Release + +# NOTE: This Github Actions file depends on the Makefile. +# Building the correct package requires the correct binaries generated by the Makefile. To +# ensure the correct output, the Makefile must accept the appropriate input and compile the +# correct file with the correct name. If you need to modify this file, please ensure it won't +# disrupt the Makefile. on: - push: - tags: - - 'v*.*.*' workflow_dispatch: + release: + types: [published] + push: + pull_request: + types: [opened, synchronize, reopened] jobs: build: - runs-on: ${{ matrix.os }} + permissions: + contents: write strategy: matrix: - goos: [linux, darwin, windows] - goarch: [amd64, arm64] - goarm: [6] + # Include amd64 on all platforms. + goos: [windows, freebsd, openbsd, linux, darwin] + goarch: [amd64, 386] + patch-assetname: [""] + exclude: + # Exclude i386 on darwin + - goarch: 386 + goos: darwin + include: + # BEGIN MacOS ARM64 + - goos: darwin + goarch: arm64 + # END MacOS ARM64 + # BEGIN Linux ARM 5 6 7 + - goos: linux + goarch: arm + goarm: 7 + - goos: linux + goarch: arm + goarm: 6 + - goos: linux + goarch: arm + goarm: 5 + # END Linux ARM 5 6 7 + # BEGIN Android ARM 8 + - goos: android + goarch: arm64 + # END Android ARM 8 + # Windows ARM + - goos: windows + goarch: arm64 + - goos: windows + goarch: arm + goarm: 7 + # BEGIN Other architectures + # BEGIN riscv64 & ARM64 & LOONG64 + - goos: linux + goarch: arm64 + - goos: linux + goarch: riscv64 + - goos: linux + goarch: loong64 + # END riscv64 & ARM64 & LOONG64 + # BEGIN MIPS + - goos: linux + goarch: mips64 + - goos: linux + goarch: mips64le + - goos: linux + goarch: mipsle + - goos: linux + goarch: mips + # END MIPS + # BEGIN PPC + - goos: linux + goarch: ppc64 + - goos: linux + goarch: ppc64le + # END PPC + # BEGIN FreeBSD ARM + - goos: freebsd + goarch: arm64 + - goos: freebsd + goarch: arm + goarm: 7 + # END FreeBSD ARM + # BEGIN S390X + - goos: linux + goarch: s390x + # END S390X + # END Other architectures + # BEGIN OPENBSD ARM + - goos: openbsd + goarch: arm64 + - goos: openbsd + goarch: arm + goarm: 7 + # END OPENBSD ARM + fail-fast: false + + runs-on: ubuntu-latest env: GOOS: ${{ matrix.goos }} GOARCH: ${{ matrix.goarch }} GOARM: ${{ matrix.goarm }} CGO_ENABLED: 0 - PREFIX: /usr/local steps: - name: Checkout codebase uses: actions/checkout@v4 + + - name: Show workflow information + run: | + _NAME=${{ matrix.patch-assetname }} + [ -n "$_NAME" ] || _NAME=$(jq ".[\"$GOOS-$GOARCH$GOARM$GOMIPS\"].friendlyName" -r < .github/build/friendly-filenames.json) + echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, GOMIPS: $GOMIPS, RELEASE_NAME: $_NAME" + echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV + - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: 1.17 - - name: Cache Go modules - uses: actions/cache@v2 + uses: actions/setup-go@v5 with: - path: | - ~/.cache/go-build - ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - name: Build - run: | - if [ "$GOOS" = "windows" ]; then - go build -ldflags "-s -w" -o xray.exe ./main - else - go build -ldflags "-s -w" -o xray ./main - fi - - name: Prepare assets + go-version-file: go.mod + check-latest: true + + - name: Get project dependencies + run: go mod download + + - name: Build Xray run: | mkdir -p build_assets + make + find . -maxdepth 1 -type f -regex './\(wxray\|xray\|xray_softfloat\)\(\|.exe\)' -exec mv {} ./build_assets/ \; + + - name: Restore Geodat Cache + uses: actions/cache/restore@v4 + with: + path: resources + key: xray-geodat- + + - name: Copy README.md & LICENSE + run: | mv -f resources/* build_assets cp ${GITHUB_WORKSPACE}/README.md ./build_assets/README.md cp ${GITHUB_WORKSPACE}/LICENSE ./build_assets/LICENSE - if [ "$GOOS" = "windows" ]; then - cp ${GITHUB_WORKSPACE}/xray_no_window.vbs ./build_assets/xray_no_window.vbs || echo "xray_no_window.vbs not found, skipping." - fi + - name: Create ZIP archive if: github.event_name == 'release' + shell: bash + run: | + pushd build_assets || exit 1 + touch -mt $(date +%Y01010000) * + zip -9vr ../Xray-${{ env.ASSET_NAME }}.zip . + popd || exit 1 + FILE=./Xray-${{ env.ASSET_NAME }}.zip + DGST=$FILE.dgst + for METHOD in {"md5","sha1","sha256","sha512"} + do + openssl dgst -$METHOD $FILE | sed 's/([^)]*)//g' >>$DGST + done + + - name: Change the name run: | - cd build_assets - zip -r ../xray-${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.goarm }}.zip * - cd .. - - name: Upload release asset - uses: actions/upload-artifact@v2 + mv build_assets Xray-${{ env.ASSET_NAME }} + + - name: Upload files to Artifacts + uses: actions/upload-artifact@v4 + with: + name: Xray-${{ env.ASSET_NAME }} + path: | + ./Xray-${{ env.ASSET_NAME }}/* + + - name: Upload binaries to release + uses: svenstaro/upload-release-action@v2 + if: github.event_name == 'release' with: - name: xray-${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.goarm }}.zip - path: xray-${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.goarm }}.zip + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ./Xray-${{ env.ASSET_NAME }}.zip* + tag: ${{ github.ref }} + file_glob: true From e09f9efabebe3c7c050f6460e1514cc853d1d3f4 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 18:23:47 +0330 Subject: [PATCH 41/60] Update Makefile --- Makefile | 233 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 173 insertions(+), 60 deletions(-) diff --git a/Makefile b/Makefile index 57af0106eb49..42dc11926efa 100644 --- a/Makefile +++ b/Makefile @@ -1,71 +1,184 @@ -# 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:\ - - This file is not the main Makefile; it only accepts environment variables and builds the \ - binary.\ - - Automatic building expects the correct binaries to be built by this Makefile. If you \ - intend to propose a change to this Makefile, carefully review the file below and ensure \ - that the change will not accidentally break the automatic building:\ - .github/workflows/release.yml \ - Otherwise it is recommended to contact the project maintainers. +name: Build and Release -# Define the name of the output binary -NAME = xray +# NOTE: This Github Actions file depends on the Makefile. +# Building the correct package requires the correct binaries generated by the Makefile. To +# ensure the correct output, the Makefile must accept the appropriate input and compile the +# correct file with the correct name. If you need to modify this file, please ensure it won't +# disrupt the Makefile. -# Define the version using the latest git commit description -VERSION = $(shell git describe --always --dirty) +on: + workflow_dispatch: + release: + types: [published] + push: + pull_request: + types: [opened, synchronize, reopened] -# Linker flags and build parameters -LDFLAGS = -X github.com/xtls/xray-core/core.build=$(VERSION) -s -w -buildid= -PARAMS = -trimpath -ldflags "$(LDFLAGS)" -v +jobs: + build: + permissions: + contents: write + strategy: + matrix: + # Include amd64 on all platforms. + goos: [windows, freebsd, openbsd, linux, darwin] + goarch: [amd64, 386] + patch-assetname: [""] + exclude: + # Exclude i386 on darwin + - goarch: 386 + goos: darwin + include: + # BEGIN MacOS ARM64 + - goos: darwin + goarch: arm64 + # END MacOS ARM64 + # BEGIN Linux ARM 5 6 7 + - goos: linux + goarch: arm + goarm: 7 + - goos: linux + goarch: arm + goarm: 6 + - goos: linux + goarch: arm + goarm: 5 + # END Linux ARM 5 6 7 + # BEGIN Android ARM 8 + - goos: android + goarch: arm64 + # END Android ARM 8 + # Windows ARM + - goos: windows + goarch: arm64 + - goos: windows + goarch: arm + goarm: 7 + # BEGIN Other architectures + # BEGIN riscv64 & ARM64 & LOONG64 + - goos: linux + goarch: arm64 + - goos: linux + goarch: riscv64 + - goos: linux + goarch: loong64 + # END riscv64 & ARM64 & LOONG64 + # BEGIN MIPS + - goos: linux + goarch: mips64 + - goos: linux + goarch: mips64le + - goos: linux + goarch: mipsle + - goos: linux + goarch: mips + # END MIPS + # BEGIN PPC + - goos: linux + goarch: ppc64 + - goos: linux + goarch: ppc64le + # END PPC + # BEGIN FreeBSD ARM + - goos: freebsd + goarch: arm64 + - goos: freebsd + goarch: arm + goarm: 7 + # END FreeBSD ARM + # BEGIN S390X + - goos: linux + goarch: s390x + # END S390X + # END Other architectures + # BEGIN OPENBSD ARM + - goos: openbsd + goarch: arm64 + - goos: openbsd + goarch: arm + goarm: 7 + # END OPENBSD ARM + fail-fast: false -# Main package to build -MAIN = ./main + runs-on: ubuntu-latest + env: + GOOS: ${{ matrix.goos }} + GOARCH: ${{ matrix.goarch }} + GOARM: ${{ matrix.goarm }} + CGO_ENABLED: 0 + PREFIX: /usr/local + steps: + - name: Checkout codebase + uses: actions/checkout@v4 -# Prefix for installation -PREFIX ?= $(shell go env GOPATH) + - name: Show workflow information + run: | + _NAME=${{ matrix.patch-assetname }} + [ -n "$_NAME" ] || _NAME=$(jq ".[\"$GOOS-$GOARCH$GOARM$GOMIPS\"].friendlyName" -r < .github/build/friendly-filenames.json) + echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, GOMIPS: $GOMIPS, RELEASE_NAME: $_NAME" + echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV -# Phony targets to avoid conflicts with files named 'clean', 'build', 'test', or 'deps' -.PHONY: clean build test deps default + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + check-latest: true -# Install dependencies -deps: - @echo "Downloading dependencies..." - go mod download - @if [ $$? -ne 0 ]; then \ - echo "Error downloading dependencies"; \ - exit 1; \ - fi - @echo "Dependencies downloaded successfully" + - name: Get project dependencies + run: go mod download + + - name: Build Xray + run: | + mkdir -p build_assets + make + find . -maxdepth 1 -type f -regex './\(wxray\|xray\|xray_softfloat\)\(\|.exe\)' -exec mv {} ./build_assets/ \; -# Build target to compile the binary -build: deps - @echo "Building the binary..." - CGO_ENABLED=0 go build -o $(NAME) $(PARAMS) $(MAIN) - @if [ $$? -ne 0 ]; then \ - echo "Error building the binary"; \ - exit 1; \ - fi - @echo "Binary built successfully" -ifneq ($(GOOS),windows) - mv $(NAME) $(NAME).exe - echo 'CreateObject("Wscript.Shell").Run "$(NAME).exe",0' > $(NAME)_no_window.vbs -else ifeq ($(GOARCH),mips) - GOMIPS=softfloat CGO_ENABLED=0 go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) -else ifeq ($(GOARCH),mipsle) - GOMIPS=softfloat CGO_ENABLED=0 go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) -else - @echo "No special build steps for this architecture." -endif + - name: Restore Geodat Cache + uses: actions/cache/restore@v4 + with: + path: resources + key: xray-geodat- -# Run tests -test: - go test ./... + - name: Copy README.md & LICENSE + run: | + mv -f resources/* build_assets + cp ${GITHUB_WORKSPACE}/README.md ./build_assets/README.md + cp ${GITHUB_WORKSPACE}/LICENSE ./build_assets/LICENSE + if [ "$GOOS" = "windows" ]; then + cp ${GITHUB_WORKSPACE}/xray_no_window.vbs ./build_assets/xray_no_window.vbs || echo "xray_no_window.vbs not found, skipping." + fi -# Clean target to remove generated files -clean: - go clean -v -i $(PWD) - rm -f $(NAME) $(NAME).exe $(NAME)_no_window.vbs $(NAME)_softfloat + - name: Create ZIP archive + if: github.event_name == 'release' + shell: bash + run: | + pushd build_assets || exit 1 + touch -mt $(date +%Y01010000) * + zip -9vr ../Xray-${{ env.ASSET_NAME }}.zip . + popd || exit 1 + FILE=./Xray-${{ env.ASSET_NAME }}.zip + DGST=$FILE.dgst + for METHOD in {"md5","sha1","sha256","sha512"} + do + openssl dgst -$METHOD $FILE | sed 's/([^)]*)//g' >>$DGST + done -# Default target -default: build + - name: Change the name + run: | + mv build_assets Xray-${{ env.ASSET_NAME }} + + - name: Upload files to Artifacts + uses: actions/upload-artifact@v4 + with: + name: Xray-${{ env.ASSET_NAME }} + path: | + ./Xray-${{ env.ASSET_NAME }}/* + + - name: Upload binaries to release + uses: svenstaro/upload-release-action@v2 + if: github.event_name == 'release' + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ./Xray-${{ env.ASSET_NAME }}.zip* + tag: ${{ github.ref }} + file_glob: true From 2cf93652025b95fd0469df445fef007139ee9892 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 18:24:19 +0330 Subject: [PATCH 42/60] Update Makefile --- Makefile | 233 ++++++++++++++----------------------------------------- 1 file changed, 60 insertions(+), 173 deletions(-) diff --git a/Makefile b/Makefile index 42dc11926efa..57af0106eb49 100644 --- a/Makefile +++ b/Makefile @@ -1,184 +1,71 @@ -name: Build and Release +# 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:\ + - This file is not the main Makefile; it only accepts environment variables and builds the \ + binary.\ + - Automatic building expects the correct binaries to be built by this Makefile. If you \ + intend to propose a change to this Makefile, carefully review the file below and ensure \ + that the change will not accidentally break the automatic building:\ + .github/workflows/release.yml \ + Otherwise it is recommended to contact the project maintainers. -# NOTE: This Github Actions file depends on the Makefile. -# Building the correct package requires the correct binaries generated by the Makefile. To -# ensure the correct output, the Makefile must accept the appropriate input and compile the -# correct file with the correct name. If you need to modify this file, please ensure it won't -# disrupt the Makefile. +# Define the name of the output binary +NAME = xray -on: - workflow_dispatch: - release: - types: [published] - push: - pull_request: - types: [opened, synchronize, reopened] +# Define the version using the latest git commit description +VERSION = $(shell git describe --always --dirty) -jobs: - build: - permissions: - contents: write - strategy: - matrix: - # Include amd64 on all platforms. - goos: [windows, freebsd, openbsd, linux, darwin] - goarch: [amd64, 386] - patch-assetname: [""] - exclude: - # Exclude i386 on darwin - - goarch: 386 - goos: darwin - include: - # BEGIN MacOS ARM64 - - goos: darwin - goarch: arm64 - # END MacOS ARM64 - # BEGIN Linux ARM 5 6 7 - - goos: linux - goarch: arm - goarm: 7 - - goos: linux - goarch: arm - goarm: 6 - - goos: linux - goarch: arm - goarm: 5 - # END Linux ARM 5 6 7 - # BEGIN Android ARM 8 - - goos: android - goarch: arm64 - # END Android ARM 8 - # Windows ARM - - goos: windows - goarch: arm64 - - goos: windows - goarch: arm - goarm: 7 - # BEGIN Other architectures - # BEGIN riscv64 & ARM64 & LOONG64 - - goos: linux - goarch: arm64 - - goos: linux - goarch: riscv64 - - goos: linux - goarch: loong64 - # END riscv64 & ARM64 & LOONG64 - # BEGIN MIPS - - goos: linux - goarch: mips64 - - goos: linux - goarch: mips64le - - goos: linux - goarch: mipsle - - goos: linux - goarch: mips - # END MIPS - # BEGIN PPC - - goos: linux - goarch: ppc64 - - goos: linux - goarch: ppc64le - # END PPC - # BEGIN FreeBSD ARM - - goos: freebsd - goarch: arm64 - - goos: freebsd - goarch: arm - goarm: 7 - # END FreeBSD ARM - # BEGIN S390X - - goos: linux - goarch: s390x - # END S390X - # END Other architectures - # BEGIN OPENBSD ARM - - goos: openbsd - goarch: arm64 - - goos: openbsd - goarch: arm - goarm: 7 - # END OPENBSD ARM - fail-fast: false +# Linker flags and build parameters +LDFLAGS = -X github.com/xtls/xray-core/core.build=$(VERSION) -s -w -buildid= +PARAMS = -trimpath -ldflags "$(LDFLAGS)" -v - runs-on: ubuntu-latest - env: - GOOS: ${{ matrix.goos }} - GOARCH: ${{ matrix.goarch }} - GOARM: ${{ matrix.goarm }} - CGO_ENABLED: 0 - PREFIX: /usr/local - steps: - - name: Checkout codebase - uses: actions/checkout@v4 +# Main package to build +MAIN = ./main - - name: Show workflow information - run: | - _NAME=${{ matrix.patch-assetname }} - [ -n "$_NAME" ] || _NAME=$(jq ".[\"$GOOS-$GOARCH$GOARM$GOMIPS\"].friendlyName" -r < .github/build/friendly-filenames.json) - echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, GOMIPS: $GOMIPS, RELEASE_NAME: $_NAME" - echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV +# Prefix for installation +PREFIX ?= $(shell go env GOPATH) - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - check-latest: true +# Phony targets to avoid conflicts with files named 'clean', 'build', 'test', or 'deps' +.PHONY: clean build test deps default - - name: Get project dependencies - run: go mod download - - - name: Build Xray - run: | - mkdir -p build_assets - make - find . -maxdepth 1 -type f -regex './\(wxray\|xray\|xray_softfloat\)\(\|.exe\)' -exec mv {} ./build_assets/ \; +# Install dependencies +deps: + @echo "Downloading dependencies..." + go mod download + @if [ $$? -ne 0 ]; then \ + echo "Error downloading dependencies"; \ + exit 1; \ + fi + @echo "Dependencies downloaded successfully" - - name: Restore Geodat Cache - uses: actions/cache/restore@v4 - with: - path: resources - key: xray-geodat- +# Build target to compile the binary +build: deps + @echo "Building the binary..." + CGO_ENABLED=0 go build -o $(NAME) $(PARAMS) $(MAIN) + @if [ $$? -ne 0 ]; then \ + echo "Error building the binary"; \ + exit 1; \ + fi + @echo "Binary built successfully" +ifneq ($(GOOS),windows) + mv $(NAME) $(NAME).exe + echo 'CreateObject("Wscript.Shell").Run "$(NAME).exe",0' > $(NAME)_no_window.vbs +else ifeq ($(GOARCH),mips) + GOMIPS=softfloat CGO_ENABLED=0 go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) +else ifeq ($(GOARCH),mipsle) + GOMIPS=softfloat CGO_ENABLED=0 go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) +else + @echo "No special build steps for this architecture." +endif - - name: Copy README.md & LICENSE - run: | - mv -f resources/* build_assets - cp ${GITHUB_WORKSPACE}/README.md ./build_assets/README.md - cp ${GITHUB_WORKSPACE}/LICENSE ./build_assets/LICENSE - if [ "$GOOS" = "windows" ]; then - cp ${GITHUB_WORKSPACE}/xray_no_window.vbs ./build_assets/xray_no_window.vbs || echo "xray_no_window.vbs not found, skipping." - fi +# Run tests +test: + go test ./... - - name: Create ZIP archive - if: github.event_name == 'release' - shell: bash - run: | - pushd build_assets || exit 1 - touch -mt $(date +%Y01010000) * - zip -9vr ../Xray-${{ env.ASSET_NAME }}.zip . - popd || exit 1 - FILE=./Xray-${{ env.ASSET_NAME }}.zip - DGST=$FILE.dgst - for METHOD in {"md5","sha1","sha256","sha512"} - do - openssl dgst -$METHOD $FILE | sed 's/([^)]*)//g' >>$DGST - done +# Clean target to remove generated files +clean: + go clean -v -i $(PWD) + rm -f $(NAME) $(NAME).exe $(NAME)_no_window.vbs $(NAME)_softfloat - - name: Change the name - run: | - mv build_assets Xray-${{ env.ASSET_NAME }} - - - name: Upload files to Artifacts - uses: actions/upload-artifact@v4 - with: - name: Xray-${{ env.ASSET_NAME }} - path: | - ./Xray-${{ env.ASSET_NAME }}/* - - - name: Upload binaries to release - uses: svenstaro/upload-release-action@v2 - if: github.event_name == 'release' - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: ./Xray-${{ env.ASSET_NAME }}.zip* - tag: ${{ github.ref }} - file_glob: true +# Default target +default: build From 4c262a366704c759fa5652dcfc797d1a68553429 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 18:24:44 +0330 Subject: [PATCH 43/60] Update release.yml From 99719ca1bdeabc3cfd6b1d7b5a4ce50dc030058f Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 18:26:20 +0330 Subject: [PATCH 44/60] Update release.yml --- .github/workflows/release.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7bc8c51d18cd..42dc11926efa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -106,6 +106,7 @@ jobs: GOARCH: ${{ matrix.goarch }} GOARM: ${{ matrix.goarm }} CGO_ENABLED: 0 + PREFIX: /usr/local steps: - name: Checkout codebase uses: actions/checkout@v4 @@ -143,6 +144,9 @@ jobs: mv -f resources/* build_assets cp ${GITHUB_WORKSPACE}/README.md ./build_assets/README.md cp ${GITHUB_WORKSPACE}/LICENSE ./build_assets/LICENSE + if [ "$GOOS" = "windows" ]; then + cp ${GITHUB_WORKSPACE}/xray_no_window.vbs ./build_assets/xray_no_window.vbs || echo "xray_no_window.vbs not found, skipping." + fi - name: Create ZIP archive if: github.event_name == 'release' From d6c407c4140be1c590adcec4901fe2b695c53ef2 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 18:36:43 +0330 Subject: [PATCH 45/60] Update release.yml --- .github/workflows/release.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 42dc11926efa..ddea219ebb2d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -125,7 +125,9 @@ jobs: check-latest: true - name: Get project dependencies - run: go mod download + run: + go mod download + go mod tidy - name: Build Xray run: | From 55f7e801d68de3d3e55c64520c10551117d11c39 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 18:42:44 +0330 Subject: [PATCH 46/60] Update release.yml --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ddea219ebb2d..f6c187317830 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -125,7 +125,7 @@ jobs: check-latest: true - name: Get project dependencies - run: + run: | go mod download go mod tidy From 5312d530d396e2dbcc35c4ebc6f99e475aab01ab Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 18:56:29 +0330 Subject: [PATCH 47/60] Update release.yml --- .github/workflows/release.yml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f6c187317830..571fef376961 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -106,24 +106,23 @@ jobs: GOARCH: ${{ matrix.goarch }} GOARM: ${{ matrix.goarm }} CGO_ENABLED: 0 - PREFIX: /usr/local steps: - name: Checkout codebase uses: actions/checkout@v4 - + - name: Show workflow information run: | _NAME=${{ matrix.patch-assetname }} [ -n "$_NAME" ] || _NAME=$(jq ".[\"$GOOS-$GOARCH$GOARM$GOMIPS\"].friendlyName" -r < .github/build/friendly-filenames.json) echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, GOMIPS: $GOMIPS, RELEASE_NAME: $_NAME" echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV - + - name: Set up Go uses: actions/setup-go@v5 with: go-version-file: go.mod check-latest: true - + - name: Get project dependencies run: | go mod download @@ -134,13 +133,13 @@ jobs: mkdir -p build_assets make find . -maxdepth 1 -type f -regex './\(wxray\|xray\|xray_softfloat\)\(\|.exe\)' -exec mv {} ./build_assets/ \; - + - name: Restore Geodat Cache uses: actions/cache/restore@v4 with: path: resources key: xray-geodat- - + - name: Copy README.md & LICENSE run: | mv -f resources/* build_assets @@ -149,7 +148,7 @@ jobs: if [ "$GOOS" = "windows" ]; then cp ${GITHUB_WORKSPACE}/xray_no_window.vbs ./build_assets/xray_no_window.vbs || echo "xray_no_window.vbs not found, skipping." fi - + - name: Create ZIP archive if: github.event_name == 'release' shell: bash @@ -164,18 +163,18 @@ jobs: do openssl dgst -$METHOD $FILE | sed 's/([^)]*)//g' >>$DGST done - + - name: Change the name run: | mv build_assets Xray-${{ env.ASSET_NAME }} - + - name: Upload files to Artifacts uses: actions/upload-artifact@v4 with: name: Xray-${{ env.ASSET_NAME }} path: | ./Xray-${{ env.ASSET_NAME }}/* - + - name: Upload binaries to release uses: svenstaro/upload-release-action@v2 if: github.event_name == 'release' From b6889fd721e03ebe2180a08527890e8703fdfc52 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 18:58:02 +0330 Subject: [PATCH 48/60] Update release.yml From 475fa960910725f42ea7018e763e499a203a3806 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 21:16:03 +0330 Subject: [PATCH 49/60] Update Makefile From e708eee8ce5e132cd139308c975979fb83a7768e Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 21:18:26 +0330 Subject: [PATCH 50/60] Update Makefile From 7703174584fe119463b550e636d2307a4f54b3a7 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 21:20:42 +0330 Subject: [PATCH 51/60] Update Makefile From d63e1a53db00620cca1d10e7c7cf7982b97dcc98 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 21:22:17 +0330 Subject: [PATCH 52/60] Update Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 57af0106eb49..5f622be458f5 100644 --- a/Makefile +++ b/Makefile @@ -47,7 +47,7 @@ build: deps exit 1; \ fi @echo "Binary built successfully" -ifneq ($(GOOS),windows) +ifeq ($(shell go env GOOS), windows) mv $(NAME) $(NAME).exe echo 'CreateObject("Wscript.Shell").Run "$(NAME).exe",0' > $(NAME)_no_window.vbs else ifeq ($(GOARCH),mips) From cdfc2983e530d2750fca3230fd0f93ed54e89236 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Thu, 13 Feb 2025 21:26:29 +0330 Subject: [PATCH 53/60] Update release.yml --- .github/workflows/release.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 571fef376961..f6c187317830 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -106,23 +106,24 @@ jobs: GOARCH: ${{ matrix.goarch }} GOARM: ${{ matrix.goarm }} CGO_ENABLED: 0 + PREFIX: /usr/local steps: - name: Checkout codebase uses: actions/checkout@v4 - + - name: Show workflow information run: | _NAME=${{ matrix.patch-assetname }} [ -n "$_NAME" ] || _NAME=$(jq ".[\"$GOOS-$GOARCH$GOARM$GOMIPS\"].friendlyName" -r < .github/build/friendly-filenames.json) echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, GOMIPS: $GOMIPS, RELEASE_NAME: $_NAME" echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV - + - name: Set up Go uses: actions/setup-go@v5 with: go-version-file: go.mod check-latest: true - + - name: Get project dependencies run: | go mod download @@ -133,13 +134,13 @@ jobs: mkdir -p build_assets make find . -maxdepth 1 -type f -regex './\(wxray\|xray\|xray_softfloat\)\(\|.exe\)' -exec mv {} ./build_assets/ \; - + - name: Restore Geodat Cache uses: actions/cache/restore@v4 with: path: resources key: xray-geodat- - + - name: Copy README.md & LICENSE run: | mv -f resources/* build_assets @@ -148,7 +149,7 @@ jobs: if [ "$GOOS" = "windows" ]; then cp ${GITHUB_WORKSPACE}/xray_no_window.vbs ./build_assets/xray_no_window.vbs || echo "xray_no_window.vbs not found, skipping." fi - + - name: Create ZIP archive if: github.event_name == 'release' shell: bash @@ -163,18 +164,18 @@ jobs: do openssl dgst -$METHOD $FILE | sed 's/([^)]*)//g' >>$DGST done - + - name: Change the name run: | mv build_assets Xray-${{ env.ASSET_NAME }} - + - name: Upload files to Artifacts uses: actions/upload-artifact@v4 with: name: Xray-${{ env.ASSET_NAME }} path: | ./Xray-${{ env.ASSET_NAME }}/* - + - name: Upload binaries to release uses: svenstaro/upload-release-action@v2 if: github.event_name == 'release' From bcfb7e6563e0dff8d6da89fcb21798da6d5b10a0 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Fri, 14 Feb 2025 09:41:10 +0330 Subject: [PATCH 54/60] Update release.yml --- .github/workflows/release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f6c187317830..fd6fea9a4404 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -106,7 +106,6 @@ jobs: GOARCH: ${{ matrix.goarch }} GOARM: ${{ matrix.goarm }} CGO_ENABLED: 0 - PREFIX: /usr/local steps: - name: Checkout codebase uses: actions/checkout@v4 From 284b2a852d1c7c46a186c2c3bbdc2b302082d9b1 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Fri, 14 Feb 2025 11:47:05 +0330 Subject: [PATCH 55/60] Update Makefile --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 5f622be458f5..adae3271ca4f 100644 --- a/Makefile +++ b/Makefile @@ -65,6 +65,7 @@ test: # Clean target to remove generated files clean: go clean -v -i $(PWD) + go clean -modcache rm -f $(NAME) $(NAME).exe $(NAME)_no_window.vbs $(NAME)_softfloat # Default target From 25dff4fc59d33ce298c8e5f75b76acb1439bd689 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Fri, 14 Feb 2025 11:54:04 +0330 Subject: [PATCH 56/60] Update release.yml --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fd6fea9a4404..5bdf4108b6b7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -118,7 +118,7 @@ jobs: echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV - name: Set up Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v5.3.0 with: go-version-file: go.mod check-latest: true From 819e54b0145fd7e2a2c26d0269110aa5dcfd3ef6 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Fri, 14 Feb 2025 12:24:40 +0330 Subject: [PATCH 57/60] Update release.yml --- .github/workflows/release.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5bdf4108b6b7..77f42ecc2edb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -183,3 +183,8 @@ jobs: file: ./Xray-${{ env.ASSET_NAME }}.zip* tag: ${{ github.ref }} file_glob: true + + - name: Clean up + run: | + go clean -v -i $(PWD) + go clean -modcache From a9e88a814f7ec87aec00fbcf6bedf0b1a44f5758 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Fri, 14 Feb 2025 12:49:09 +0330 Subject: [PATCH 58/60] Update Makefile --- Makefile | 62 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/Makefile b/Makefile index adae3271ca4f..afa64806877f 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,13 @@ # 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. + 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:\ - - This file is not the main Makefile; it only accepts environment variables and builds the \ - binary.\ - - Automatic building expects the correct binaries to be built by this Makefile. If you \ - intend to propose a change to this Makefile, carefully review the file below and ensure \ - that the change will not accidentally break the automatic building:\ - .github/workflows/release.yml \ - Otherwise it is recommended to contact the project maintainers. + - This file is not the main Makefile; it only accepts environment variables and builds the \ + binary.\ + - Automatic building expects the correct binaries to be built by this Makefile. If you \ + intend to propose a change to this Makefile, carefully review the file below and ensure \ + that the change will not accidentally break the automatic building:\ + .github/workflows/release.yml \ + Otherwise it is recommended to contact the project maintainers. # Define the name of the output binary NAME = xray @@ -30,43 +30,43 @@ PREFIX ?= $(shell go env GOPATH) # Install dependencies deps: - @echo "Downloading dependencies..." - go mod download - @if [ $$? -ne 0 ]; then \ - echo "Error downloading dependencies"; \ - exit 1; \ - fi - @echo "Dependencies downloaded successfully" + @echo "Downloading dependencies..." + go mod download + @if [ $$? -ne 0 ]; then \ + echo "Error downloading dependencies"; \ + exit 1; \ + fi + @echo "Dependencies downloaded successfully" # Build target to compile the binary build: deps - @echo "Building the binary..." - CGO_ENABLED=0 go build -o $(NAME) $(PARAMS) $(MAIN) - @if [ $$? -ne 0 ]; then \ - echo "Error building the binary"; \ - exit 1; \ - fi - @echo "Binary built successfully" + @echo "Building the binary..." + CGO_ENABLED=0 go build -o $(NAME) $(PARAMS) $(MAIN) + @if [ $$? -ne 0 ]; then \ + echo "Error building the binary"; \ + exit 1; \ + fi + @echo "Binary built successfully" ifeq ($(shell go env GOOS), windows) - mv $(NAME) $(NAME).exe - echo 'CreateObject("Wscript.Shell").Run "$(NAME).exe",0' > $(NAME)_no_window.vbs + mv $(NAME) $(NAME).exe + echo 'CreateObject("Wscript.Shell").Run "$(NAME).exe",0' > $(NAME)_no_window.vbs else ifeq ($(GOARCH),mips) - GOMIPS=softfloat CGO_ENABLED=0 go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) + GOMIPS=softfloat CGO_ENABLED=0 go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) else ifeq ($(GOARCH),mipsle) - GOMIPS=softfloat CGO_ENABLED=0 go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) + GOMIPS=softfloat CGO_ENABLED=0 go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) else - @echo "No special build steps for this architecture." + @echo "No special build steps for this architecture." endif # Run tests test: - go test ./... + go test ./... # Clean target to remove generated files clean: - go clean -v -i $(PWD) - go clean -modcache - rm -f $(NAME) $(NAME).exe $(NAME)_no_window.vbs $(NAME)_softfloat + go clean -v -i $(PWD) + go clean -modcache + rm -f $(NAME) $(NAME).exe $(NAME)_no_window.vbs $(NAME)_softfloat # Default target default: build From 666663d2356dee3202a4c583f82bbe668c934c69 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Fri, 14 Feb 2025 12:51:36 +0330 Subject: [PATCH 59/60] Update Makefile --- Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Makefile b/Makefile index afa64806877f..bcf629a2eb5c 100644 --- a/Makefile +++ b/Makefile @@ -70,3 +70,12 @@ clean: # Default target default: build + +# Clean target to remove generated files +clean: + go clean -v -i $(PWD) + go clean -modcache + rm -f $(NAME) $(NAME).exe $(NAME)_no_window.vbs $(NAME)_softfloat + +# Default target +default: build From 3785652b4d236f253a46e64d12a7e78fc67cf4b1 Mon Sep 17 00:00:00 2001 From: Alphax-Hue3682 <191818854+Alphax-Hue3682@users.noreply.github.com> Date: Fri, 14 Feb 2025 12:52:38 +0330 Subject: [PATCH 60/60] Update Makefile --- Makefile | 71 +++++++++++++++++++++++++------------------------------- 1 file changed, 31 insertions(+), 40 deletions(-) diff --git a/Makefile b/Makefile index bcf629a2eb5c..adae3271ca4f 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,13 @@ # 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. + 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:\ - - This file is not the main Makefile; it only accepts environment variables and builds the \ - binary.\ - - Automatic building expects the correct binaries to be built by this Makefile. If you \ - intend to propose a change to this Makefile, carefully review the file below and ensure \ - that the change will not accidentally break the automatic building:\ - .github/workflows/release.yml \ - Otherwise it is recommended to contact the project maintainers. + - This file is not the main Makefile; it only accepts environment variables and builds the \ + binary.\ + - Automatic building expects the correct binaries to be built by this Makefile. If you \ + intend to propose a change to this Makefile, carefully review the file below and ensure \ + that the change will not accidentally break the automatic building:\ + .github/workflows/release.yml \ + Otherwise it is recommended to contact the project maintainers. # Define the name of the output binary NAME = xray @@ -30,52 +30,43 @@ PREFIX ?= $(shell go env GOPATH) # Install dependencies deps: - @echo "Downloading dependencies..." - go mod download - @if [ $$? -ne 0 ]; then \ - echo "Error downloading dependencies"; \ - exit 1; \ - fi - @echo "Dependencies downloaded successfully" + @echo "Downloading dependencies..." + go mod download + @if [ $$? -ne 0 ]; then \ + echo "Error downloading dependencies"; \ + exit 1; \ + fi + @echo "Dependencies downloaded successfully" # Build target to compile the binary build: deps - @echo "Building the binary..." - CGO_ENABLED=0 go build -o $(NAME) $(PARAMS) $(MAIN) - @if [ $$? -ne 0 ]; then \ - echo "Error building the binary"; \ - exit 1; \ - fi - @echo "Binary built successfully" + @echo "Building the binary..." + CGO_ENABLED=0 go build -o $(NAME) $(PARAMS) $(MAIN) + @if [ $$? -ne 0 ]; then \ + echo "Error building the binary"; \ + exit 1; \ + fi + @echo "Binary built successfully" ifeq ($(shell go env GOOS), windows) - mv $(NAME) $(NAME).exe - echo 'CreateObject("Wscript.Shell").Run "$(NAME).exe",0' > $(NAME)_no_window.vbs + mv $(NAME) $(NAME).exe + echo 'CreateObject("Wscript.Shell").Run "$(NAME).exe",0' > $(NAME)_no_window.vbs else ifeq ($(GOARCH),mips) - GOMIPS=softfloat CGO_ENABLED=0 go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) + GOMIPS=softfloat CGO_ENABLED=0 go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) else ifeq ($(GOARCH),mipsle) - GOMIPS=softfloat CGO_ENABLED=0 go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) + GOMIPS=softfloat CGO_ENABLED=0 go build -o $(NAME)_softfloat $(PARAMS) $(MAIN) else - @echo "No special build steps for this architecture." + @echo "No special build steps for this architecture." endif # Run tests test: - go test ./... + go test ./... # Clean target to remove generated files clean: - go clean -v -i $(PWD) - go clean -modcache - rm -f $(NAME) $(NAME).exe $(NAME)_no_window.vbs $(NAME)_softfloat - -# Default target -default: build - -# Clean target to remove generated files -clean: - go clean -v -i $(PWD) - go clean -modcache - rm -f $(NAME) $(NAME).exe $(NAME)_no_window.vbs $(NAME)_softfloat + go clean -v -i $(PWD) + go clean -modcache + rm -f $(NAME) $(NAME).exe $(NAME)_no_window.vbs $(NAME)_softfloat # Default target default: build