---
layout: docs
page_title: 'Compiling the Plugin'
description: |-
  How Waypoint plugins work
---

# Compiling the plugin

Video tutorial below:

<iframe
  width="560"
  height="315"
  src="https://www.youtube.com/embed/4zwZCpqo0j8?start=1063&end=1260"
  frameborder="0"
  allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
  allowfullscreen
></iframe>

To compile the plugin, you can use the `Makefile` that the template generated for you. The contents of this file look like:

```makefile
PLUGIN_NAME=template

all: protos build

protos:
	@echo ""
	@echo "Build Protos"

  protoc -I . --go_out=plugins=grpc:builder --go_opt=paths=source_relative ./builder/output.proto
  protoc -I . --go_out=plugins=grpc:registry --go_opt=paths=source_relative ./registry/output.proto
  protoc -I . --go_out=plugins=grpc:platform --go_opt=paths=source_relative ./platform/output.proto
  protoc -I . --go_out=plugins=grpc:release --go_opt=paths=source_relative ./release/output.proto

build:
	@echo ""
	@echo "Compile Plugin"

	go build -o ./bin/waypoint-plugin-${PLUGIN_NAME} ./main.go

# Install the plugin locally
install:
	@echo ""
	@echo "Installing Plugin"

	cp ./bin/waypoint-plugin-${PLUGIN_NAME}* ${HOME}/.config/waypoint/plugins/
```

Let's modify it a little. Edit the `Makefile` and change the `PLUGIN_NAME` to your plugin name `gobuilder`

```makefile
PLUGIN_NAME=gobuilder
```

By default, the templated plugin will generate the Go code for all the different components, since your plugin only
implements the `Builder` component, you can remove all the other `protoc` commands.

```
  protoc -I . --go_out=plugins=grpc:builder --go_opt=paths=source_relative ./builder/output.proto
```

Your `Makefile` should now look like:

```makefile
PLUGIN_NAME=gobuilder

all: protos build

protos:
	@echo ""
	@echo "Build Protos"

  protoc -I . --go_out=plugins=grpc:builder --go_opt=paths=source_relative ./builder/output.proto

build:
	@echo ""
	@echo "Compile Plugin"

	go build -o ./bin/waypoint-plugin-${PLUGIN_NAME} ./main.go
```

With the `Makefile` changed, you can now run `make` to build the plugin.

```shell
make

Build Protos

protoc -I . --go_out=plugins=grpc:builder --go_opt=paths=source_relative ./builder/output.proto

Compile Plugin
go build -o ./bin/waypoint-plugin-gobuilder ./main.go
```

If you look in the ./bin folder, you will see your compile plugin.

```shell
ls ./bin
waypoint-plugin-gobuilder
```

Let's now install the plugin so that it can be used by the Waypoint CLI.

## Installing the plugin

You can install your plugin using the `make install` command. Waypoint will automatically
load plugins from certain know locations, these are:

- Same directory as any `waypoint.hcl`
- <waypoint_app_folder>/.waypoint/plugins/
- \$XDG_CONFIG_HOME/waypoint/plugins/

The `make install` command will copy the plugin to the Waypoint config in your
`$HOME` folder. Note that this may not match your `$XDG_CONFIG_HOME` value so
please double check this is correct for you.

```shell
➜ make install

Installing Plugin
cp ./bin/waypoint-plugin-gobuilder /home/nicj/.config/waypoint/plugins/
```

Now the plugin has been installed, let's create an example application which uses your new plugin.

[Next - Creating an Example Application](/docs/extending-waypoint/creating-plugins/example-application)
