Setup setup ccache.
()
| 22 | |
| 23 | // Setup setup ccache. |
| 24 | func (c CCache) Setup() error { |
| 25 | if c.Enabled { |
| 26 | os.Unsetenv("CCACHE_DISABLE") |
| 27 | } else { |
| 28 | os.Setenv("CCACHE_DISABLE", "1") |
| 29 | } |
| 30 | |
| 31 | // Create ccache dir if not exist. |
| 32 | if err := os.MkdirAll(c.Dir, os.ModePerm); err != nil { |
| 33 | return fmt.Errorf("failed to mkdir ccache dir -> %w", err) |
| 34 | } |
| 35 | |
| 36 | os.Setenv("CCACHE_DIR", c.Dir) |
| 37 | os.Setenv("CCACHE_MAXSIZE", c.MaxSize) |
| 38 | |
| 39 | if c.RemoteStorage != "" { |
| 40 | os.Setenv("CCACHE_REMOTE_STORAGE", c.RemoteStorage) |
| 41 | |
| 42 | if c.RemoteOnly { |
| 43 | os.Setenv("CCACHE_REMOTE_ONLY", "1") |
| 44 | } else { |
| 45 | os.Unsetenv("CCACHE_REMOTE_ONLY") |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | // Default to workspace dir as base dir. |
| 50 | os.Setenv("CCACHE_BASEDIR", dirs.WorkspaceDir) |
| 51 | return nil |
| 52 | } |
| 53 | |
| 54 | func (c *CCache) init() { |
| 55 | c.Enabled = true |