64472442fbd48215ed34fea9fcc7f6f565a07806
[AGL/documentation.git] / docs / ATTIC / 3_Developer_Guides / 4_X(cross)_Development_System:_User's_Guide / 4_X(cross)_Development_System:_ Internals / 3.4.4.3_xds-agent / 3.4.4.3.1_Build.md
1 <!-- WARNING: This file is generated by fetch_docs.js using /home/boron/Documents/AGL/docs-webtemplate/site/_data/tocs/devguides/master/xds-docs-guides-devguides-book.yml -->
2
3 # Build xds-agent from scratch
4
5 ## Dependencies
6
7 Install [Go](https://golang.org/doc/install), [npm](https://www.npmjs.com/),
8 [nodejs](https://nodejs.org/en/) and some other tools.
9
10 Refer to [Prerequisites chapter](../1_Prerequisites.html) for more details.
11
12 ## Building
13
14 Clone sources under `$ROOTDIR/src/gerrit.automotivelinux.org/gerrit/src/xds/xds-agent`
15 in order respect directory hierarchy that match Go package import logic (see
16 [How to Write Go Code](https://golang.org/doc/code.html) for more details).
17
18 Then use delivered Makefile :
19
20 ```bash
21 # Declare ROOTDIR, can be any location (for example xds-build)
22 ROOTDIR=$HOME/xds-build
23
24 # Create directory hierarchy that match Go package import logic
25 mkdir -p $ROOTDIR/src/gerrit.automotivelinux.org/gerrit/src/xds
26 cd $ROOTDIR/src/gerrit.automotivelinux.org/gerrit/src/xds
27
28 # Clone sources
29 git clone https://gerrit.automotivelinux.org/gerrit/src/xds/xds-agent
30 # or git clone ssh://YOUR_USERNAME@gerrit.automotivelinux.org:29418/src/xds/xds-agent
31
32 # Build xds-agent
33 # (note that GOPATH will correctly be set by Makefile)
34 cd xds-agent
35 make all
36 ```
37
38 Generate xds-agent packages / tarballs for Linux, MacOS, Windows
39
40 ```bash
41 make package-all
42 ```
43
44 And to install `xds-agent` (by default in `/opt/AGL/xds/agent`):
45
46 ```bash
47 make install
48 ```
49
50 <!-- section-warning -->
51 **Warning:**
52
53 Makefile install rule and default values in configuration file are set
54 to fit the docker setup.
55
56 So you may need to adapt some settings when you want to install xds-agent natively.
57 <!-- end-section-warning -->
58
59 <!-- section-note -->
60 **Note:**
61
62 Used `DESTDIR` to specify another install directory
63
64 ```bash
65 make install DESTDIR=$HOME/opt/xds-agent
66 ```
67
68 <!-- end-section-note -->
69
70 ### Cross build
71
72 For example on a Linux machine to cross-build for Windows, just follow these steps.
73
74 The first time you need to install all the windows-amd64 standard packages on
75 your system with
76
77 ```bash
78 # List all supported OS / ARCH
79 go tool dist list
80
81 # Install all standard packages for another OS/ARCH (eg. windows amd64)
82 GOOS=windows GOARCH=amd64 go install -v -a std
83 ```
84
85 Then compile and package xds-agent using provided makefile
86
87 ```bash
88 export GOOS=windows
89 export GOARCH=amd64
90 make all
91 make package
92 ```