mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-11-22 05:06:07 +03:00
Feat: Using Makefile
to build xray (#2882)
* Feat: Using `Makefile` to build xray * Typo
This commit is contained in:
parent
60f7a03e1b
commit
7b4db50c9d
29
.github/workflows/release.yml
vendored
29
.github/workflows/release.yml
vendored
@ -173,36 +173,11 @@ jobs:
|
|||||||
- name: Get project dependencies
|
- name: Get project dependencies
|
||||||
run: go mod download
|
run: go mod download
|
||||||
|
|
||||||
- name: Replace Custom to Commit ID
|
|
||||||
if: github.event_name != 'release'
|
|
||||||
run: |
|
|
||||||
ID=$(git rev-parse --short ${{ github.sha }})
|
|
||||||
if [ "${{ github.event_name }}" == 'pull_request' ]
|
|
||||||
then
|
|
||||||
ID=$(git rev-parse --short ${{ github.event.pull_request.head.sha }})
|
|
||||||
fi
|
|
||||||
sed -i '/build/ s/Custom/'$ID'/' ./core/core.go
|
|
||||||
|
|
||||||
- name: Build Xray
|
- name: Build Xray
|
||||||
run: |
|
run: |
|
||||||
mkdir -p build_assets
|
mkdir -p build_assets
|
||||||
go build -v -o build_assets/xray -trimpath -ldflags "-s -w -buildid=" ./main
|
make
|
||||||
|
find . -maxdepth 1 -type f -regex '.*\(wxray\|xray\|xray_softfloat\)\(\|.exe\)' -exec mv {} ./build_assets/ \;
|
||||||
- name: Build background Xray on Windows
|
|
||||||
if: matrix.goos == 'windows'
|
|
||||||
run: |
|
|
||||||
go build -v -o build_assets/wxray.exe -trimpath -ldflags "-s -w -H windowsgui -buildid=" ./main
|
|
||||||
|
|
||||||
- name: Build Mips softfloat Xray
|
|
||||||
if: matrix.goarch == 'mips' || matrix.goarch == 'mipsle'
|
|
||||||
run: |
|
|
||||||
GOMIPS=softfloat go build -v -o build_assets/xray_softfloat -trimpath -ldflags "-s -w -buildid=" ./main
|
|
||||||
|
|
||||||
- name: Rename Windows Xray
|
|
||||||
if: matrix.goos == 'windows'
|
|
||||||
run: |
|
|
||||||
cd ./build_assets || exit 1
|
|
||||||
mv xray xray.exe
|
|
||||||
|
|
||||||
- name: Restore Cache
|
- name: Restore Cache
|
||||||
uses: actions/cache/restore@v3
|
uses: actions/cache/restore@v3
|
||||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -19,6 +19,7 @@
|
|||||||
*.zip
|
*.zip
|
||||||
*.tar.gz
|
*.tar.gz
|
||||||
xray
|
xray
|
||||||
|
xray_softfloat
|
||||||
mockgen
|
mockgen
|
||||||
vprotogen
|
vprotogen
|
||||||
!infra/vprotogen/
|
!infra/vprotogen/
|
||||||
@ -26,3 +27,4 @@ errorgen
|
|||||||
!common/errors/errorgen/
|
!common/errors/errorgen/
|
||||||
*.dat
|
*.dat
|
||||||
.vscode
|
.vscode
|
||||||
|
/build_assets
|
||||||
|
29
Makefile
Normal file
29
Makefile
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
NAME = xray
|
||||||
|
|
||||||
|
VERSION=$(shell git describe --always --dirty)
|
||||||
|
|
||||||
|
LDFLAGS = -X github.com/xtls/xray-core/core.build=$(VERSION) -s -w -buildid=
|
||||||
|
PARAMS = -trimpath -ldflags "$(LDFLAGS)" -v
|
||||||
|
MAIN = ./main
|
||||||
|
PREFIX ?= $(shell go env GOPATH)
|
||||||
|
ifeq ($(GOOS),windows)
|
||||||
|
OUTPUT = $(NAME).exe
|
||||||
|
ADDITION = go build -o w$(NAME).exe -trimpath -ldflags "-H windowsgui $(LDFLAGS)" -v $(MAIN)
|
||||||
|
else
|
||||||
|
OUTPUT = $(NAME)
|
||||||
|
endif
|
||||||
|
ifeq ($(shell echo "$(GOARCH)" | grep -Pq "(mips|mipsle)" && echo true),true) #
|
||||||
|
ADDITION = GOMIPS=softfloat go build -o $(NAME)_softfloat -trimpath -ldflags "$(LDFLAGS)" -v $(MAIN)
|
||||||
|
endif
|
||||||
|
.PHONY: clean
|
||||||
|
|
||||||
|
build:
|
||||||
|
go build -o $(OUTPUT) $(PARAMS) $(MAIN)
|
||||||
|
$(ADDITION)
|
||||||
|
|
||||||
|
install:
|
||||||
|
go build -o $(PREFIX)/bin/$(OUTPUT) $(PARAMS) $(MAIN)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
go clean -v -i $(PWD)
|
||||||
|
rm -f xray xray.exe wxray.exe xray_softfloat
|
10
README.md
10
README.md
@ -125,16 +125,8 @@
|
|||||||
|
|
||||||
## Compilation
|
## Compilation
|
||||||
|
|
||||||
### Windows
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
go build -o xray.exe -trimpath -ldflags "-s -w -buildid=" ./main
|
make
|
||||||
```
|
|
||||||
|
|
||||||
### Linux / macOS
|
|
||||||
|
|
||||||
```bash
|
|
||||||
go build -o xray -trimpath -ldflags "-s -w -buildid=" ./main
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Stargazers over time
|
## Stargazers over time
|
||||||
|
Loading…
Reference in New Issue
Block a user