Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ distro: all
mrrobot:
@rm -rf *.xml *.html *.log *.zip VCH-0-*

clean:
clean: cleandeps
@echo removing binaries
@rm -rf $(BIN)/*
@echo removing Go object files
Expand Down Expand Up @@ -520,3 +520,7 @@ clean:
distclean: clean
@echo removing binaries
@rm -rf $(BIN)

cleandeps:
@echo removing dependency cache
@rm -rf .godeps_cache
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,22 @@ To run unit tests after a successful build, issue the following:
make test
```

Running "make" every time causes Go dependency regeneration for each component, so that "make" can rebuild only those components that are changed. However, such regeneration may take significant amount of time when it is not really needed. To fight that developers can use cached dependencies that can be enabled by defining the environment variable VIC_CACHE_DEPS. As soon as it is set, infra/scripts/go-deps.sh will read cached version of dependencies if those exist.

```shell
export VIC_CACHE_DEPS=1
```

This is important to note that as soon as you add a new package or an internal project dependency that didn't exist before, those dependencies
should be regenerated to reflect latest changes. It can be done just by running:

```shell
make cleandeps
```

After that next "make" run will regenerate dependencies from scratch.


## Managing vendor/ directory

To build the VIC Engine dependencies, ensure `GOPATH` is set, then issue the following.
Expand Down
26 changes: 21 additions & 5 deletions infra/scripts/go-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,36 @@
#
# pkg This is github.com/vmware/vic/cmd/imagec for example
#
# If VIC_CACHE_DEPS environment variable is defined, this script will attempt to read
# cached dependencies from disk if those exist. If they are not cached, dependencies will be
# regenerated and cached.

cache_dir=.godeps_cache

pkg=$1
flags=$2
cachedname=`echo .$1.godeps_cache | sed 's/\//_/g'`

if [ -d "$pkg" ]; then
if [[ "$flags" == *d* ]]
then

if [[ "$flags" == *d* ]]; then
# Only output if make is given the '-d' flag
echo "Generating deps for $pkg" >&2
fi

go list -f '{{join .Deps "\n"}}' github.com/vmware/vic/"$pkg" 2>/dev/null | \
xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}' 2>/dev/null | \
sed -e 's:github.com/vmware/vic/\(.*\)$:\1/*:'
if [ -n "$VIC_CACHE_DEPS" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we note the export VIC_CACHE_DEPS=1 requirement somewhere in this file? It's only mentioned in the commit message, so having it noted here will help.

mkdir -p $cache_dir
if [ ! -f $cache_dir/$cachedname ]; then
go list -f '{{join .Deps "\n"}}' github.com/vmware/vic/"$pkg" 2>/dev/null | \
xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}' 2>/dev/null | \
sed -e 's:github.com/vmware/vic/\(.*\)$:\1/*:' > "$cache_dir/$cachedname"
fi
cat "$cache_dir/$cachedname"
else
go list -f '{{join .Deps "\n"}}' github.com/vmware/vic/"$pkg" 2>/dev/null | \
xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}' 2>/dev/null | \
sed -e 's:github.com/vmware/vic/\(.*\)$:\1/*:'
fi
else
if [[ "$flags" == *d* ]]
then
Expand Down