Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Lei Li
agent
Commits
61e3b4c6
Commit
61e3b4c6
authored
Oct 21, 2024
by
Lei Li
Browse files
feat: makefile支持多种编译选项
parent
c99715d2
Changes
1
Show whitespace changes
Inline
Side-by-side
Makefile
View file @
61e3b4c6
.pre-build
:
.pre-build
:
mkdir
-p
bin/
mkdir
-p
bin/
BIN
=
bin/lw_android_agent
# all=表示对所有go包应用后面的表示标志
# all=表示对所有go包应用后面的表示标志
# -N 禁用优化
# -N 禁用优化
...
@@ -7,9 +8,39 @@
...
@@ -7,9 +8,39 @@
# -ldflags 用来设置链接器的标志
# -ldflags 用来设置链接器的标志
# -X 在编译时设置包中的变量的值
# -X 在编译时设置包中的变量的值
build
:
.pre-build
build
:
.pre-build
go build
-gcflags
=
'all=-N -l'
-ldflags
"-X agent/cmd/agent/config.Version=
`
./branch_info.sh get_version
`
-X agent/cmd/agent/config.BuildCommit=
`
git rev-list
-1
HEAD
`
"
-o
bin/linkfog_agent
./cmd/agent
go build
-gcflags
=
'all=-N -l'
-ldflags
"-X agent/cmd/agent/config.Version=
`
./branch_info.sh get_version
`
-X agent/cmd/agent/config.BuildCommit=
`
git rev-list
-1
HEAD
`
"
-o
$(BIN)
./cmd/agent
bin/linkfog_agent
-v
|
tee
version
$(BIN)
-v
|
tee
version
build-dev
:
.pre-build
build-dev
:
.pre-build
go build
-tags
dev
-gcflags
=
'all=-N -l'
-ldflags
"-X agent/cmd/agent/config.Version=
`
./branch_info.sh get_version
`
-X agent/cmd/agent/config.BuildCommit=
`
git rev-list
-1
HEAD
`
"
-o
bin/linkfog_agent ./cmd/agent
go build
-tags
dev
-gcflags
=
'all=-N -l'
-ldflags
"-X agent/cmd/agent/config.Version=
`
./branch_info.sh get_version
`
-X agent/cmd/agent/config.BuildCommit=
`
git rev-list
-1
HEAD
`
"
-o
$(BIN)
./cmd/agent
bin/linkfog_agent
-v
|
tee
version
$(BIN)
-v
|
tee
version
\ No newline at end of file
x86
:
export
GOARCH
=
amd64
GOOS
=
linux
GO111MODULE
=
on
CGO_ENABLED
=
0
&&
go build
-a
-ldflags
'-extldflags "-static"'
-o
$(BIN)
_x86
upx
-9
$(BIN)
_x86
arm
:
export
GOARCH
=
arm
GOOS
=
linux
GO111MODULE
=
on
CGO_ENABLED
=
0
CC
=
arm-linux-gnueabi-gcc
&&
go build
-ldflags
=
"-extldflags '-static' "
-o
$(BIN)
upx
-9
$(BIN)
# ./updateVersion.sh lw_android_agent
android
:
#export GOARCH=arm GOOS=android GO111MODULE=on CGO_ENABLED=1 CC=/usr/local/android-ndk-r14b/android-14-toolchain/bin/arm-linux-androideabi-gcc
export
GOARCH
=
arm
GOOS
=
android
GO111MODULE
=
on
CGO_ENABLED
=
1
CC
=
/usr/local/android-ndk-r19c/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi19-clang
&&
go build
-o
$(BIN)
_ndk
upx
-9
$(BIN)
_ndk
./updateVersion.sh lw_android_agent_ndk
test
:
export
GOARCH
=
arm
GOOS
=
linux
GO111MODULE
=
on
CGO_ENABLED
=
0
CC
=
arm-linux-gnueabi-gcc
&&
go build
-ldflags
=
"-extldflags '-static' "
-o
$(BIN)
.arm
upx
-9
$(BIN)
.arm
test-android
:
#export GOARCH=arm GOOS=android GO111MODULE=on CGO_ENABLED=1 CC=/usr/local/android-ndk-r14b/android-14-toolchain/bin/arm-linux-androideabi-gcc
export
GOARCH
=
arm
GOOS
=
android
GO111MODULE
=
on
CGO_ENABLED
=
1
CC
=
/usr/local/android-ndk-r19c/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi19-clang
&&
go build
-o
$(BIN)
_ndk_test
upx
-9
$(BIN)
_ndk_test
clean
:
$(RM)
-r
$(BIN)
.arm
||
true
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment