Skip to content

Commit a1e0cfb

Browse files
author
asr
committed
update CI for cross compilation
1 parent 321cba2 commit a1e0cfb

File tree

1 file changed

+67
-24
lines changed

1 file changed

+67
-24
lines changed

.gitlab-ci.yml

+67-24
Original file line numberDiff line numberDiff line change
@@ -4,53 +4,96 @@ stages:
44
- build
55

66
variables:
7-
# LIBPCAP_VERSION: "1.9.1"
7+
LIBPCAP_VERSION: "1.9.1"
8+
LIBPCAP_DIR: "/libpcap"
9+
PACKAGES: "nano bash linux-headers git flex bison wget make bluez-dev bluez"
10+
CGO_ENABLED: 1
11+
CGO_LDFLAGS: "-L$LIBPCAP_DIR/libpcap-$LIBPCAP_VERSION"
12+
CGO_CFLAGS: "-O2 -I$LIBPCAP_DIR/libpcap-$LIBPCAP_VERSION"
13+
GCC_VERSION: "9.2.0"
14+
MUSL_CROSS_MAKE_VERSION: "v15"
815
TZ: "Europe/Paris"
916
ARTIFACT_NAME_TEMPLATE: "$CI_JOB_NAME"
10-
# GO_IMAGE: "golang:1.15.2-buster"
11-
# PACKAGES: "software-properties-common byacc flex dpkg-dev python3 python3-pip debhelper"
1217
BUILD_IMAGE: "golang:1.15.2-alpine"
13-
PACKAGES: "bash linux-headers build-base git flex bison"
14-
15-
16-
# .install-deps: &install-deps
17-
# - apt-get update
18-
# - apt-get install -y software-properties-common gcc bison flex wget make kmod build-essential
18+
1919

2020

2121
.install-deps: &install-deps
2222
- apk update
2323
- apk add $PACKAGES
2424

25+
.get-libpcap-src: &get-libpcap-src
26+
- $CI_PROJECT_DIR/dev/image/get_libpcap_sources.sh
2527

26-
.build-libraries: &build-libraries
27-
- cd /; git clone https://github.com/ntop/PF_RING.git
28-
- mkdir -p /usr/local/include/linux/; cp /PF_RING/kernel/linux/pf_ring.h /usr/local/include/linux/pf_ring.h
29-
- cp /go/src/netspot/extra/strdup.c /PF_RING/userland/lib
30-
- cd /PF_RING/userland/lib; ./configure;
31-
- sed -i 's/pfring_hw_filtering.o/pfring_hw_filtering.o strdup.o/' Makefile;
32-
- make; make install
33-
- cp /go/src/netspot/extra/strdup.c /PF_RING/userland/libpcap
34-
- cd /PF_RING/userland/libpcap; ./configure
35-
- sed -i 's/etherent.c/etherent.c strdup.c/' Makefile;
36-
- make; make install
28+
# .build-libraries: &build-libraries
29+
# - cd /; git clone https://github.com/ntop/PF_RING.git
30+
# - mkdir -p /usr/local/include/linux/; cp /PF_RING/kernel/linux/pf_ring.h /usr/local/include/linux/pf_ring.h
31+
# - cp /go/src/netspot/extra/strdup.c /PF_RING/userland/lib
32+
# - cd /PF_RING/userland/lib; ./configure;
33+
# - sed -i 's/pfring_hw_filtering.o/pfring_hw_filtering.o strdup.o/' Makefile;
34+
# - make; make install
35+
# - cp /go/src/netspot/extra/strdup.c /PF_RING/userland/libpcap
36+
# - cd /PF_RING/userland/libpcap; ./configure
37+
# - sed -i 's/etherent.c/etherent.c strdup.c/' Makefile;
38+
# - make; make install
3739

3840
build_amd64:
3941
stage: build
4042
image: $BUILD_IMAGE
4143
only:
4244
- web
45+
variables:
46+
TARGET_ARCH: x86_64-linux
47+
before_script:
48+
- ln -s /builds/netspot/netspot /go/src/netspot
49+
- *install-deps
50+
- *get-libpcap-src
51+
- $CI_PROJECT_DIR/dev/image/install_toolchain.sh
52+
script:
53+
- $CI_PROJECT_DIR/dev/build/builder.sh $TARGET_ARCH
54+
artifacts:
55+
name: $ARTIFACT_NAME_TEMPLATE
56+
paths:
57+
- bin/netspot-$TARGET_ARCH
58+
59+
build_arm:
60+
stage: build
61+
image: $BUILD_IMAGE
62+
only:
63+
- web
64+
variables:
65+
TARGET_ARCH: arm-linux
66+
before_script:
67+
- ln -s /builds/netspot/netspot /go/src/netspot
68+
- *install-deps
69+
- *get-libpcap-src
70+
- $CI_PROJECT_DIR/dev/image/install_toolchain.sh
71+
script:
72+
- $CI_PROJECT_DIR/dev/build/builder.sh $TARGET_ARCH
73+
artifacts:
74+
name: $ARTIFACT_NAME_TEMPLATE
75+
paths:
76+
- bin/netspot-$TARGET_ARCH
77+
78+
79+
build_aarch64:
80+
stage: build
81+
image: $BUILD_IMAGE
82+
only:
83+
- web
84+
variables:
85+
TARGET_ARCH: aarch64-linux
4386
before_script:
4487
- ln -s /builds/netspot/netspot /go/src/netspot
4588
- *install-deps
46-
- *build-libraries
89+
- *get-libpcap-src
90+
- $CI_PROJECT_DIR/dev/image/install_toolchain.sh
4791
script:
48-
- cd /go/src/netspot
49-
- make build_netspot_musl
92+
- $CI_PROJECT_DIR/dev/build/builder.sh $TARGET_ARCH
5093
artifacts:
5194
name: $ARTIFACT_NAME_TEMPLATE
5295
paths:
53-
- bin/netspot
96+
- bin/netspot-$TARGET_ARCH
5497

5598
# build_armhf:
5699
# stage: build

0 commit comments

Comments
 (0)