What directory does homebrew use to build programs? I would like to change the directory that homebrew uses when it builds programs

Is that possible? I didn't find such option in brew command
When you install a Homebrew package, if it needs to compile it from source, it will extract the files to /tmp/package-XXXXXX and compile them there before installing to /usr/local/Cellar/package.

You can specify a different temp folder by setting an environment variable...

export HOMEBREW_TEMP=/Users/USERNAME/Desktop/temp