f6f1ebdd05
To allow more build-time configuration: - `Makefile` will now pick up `LDFLAGS` from environment variables, and - locations of configuration files can now be overridden with linker options. These are not used for regular Flamenco builds, but do allow studios to customize where configuration files are stored. Review: https://projects.blender.org/studio/flamenco/pulls/104200
33 lines
867 B
Go
33 lines
867 B
Go
package appinfo
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
import (
|
|
"os"
|
|
"path"
|
|
"path/filepath"
|
|
|
|
"github.com/adrg/xdg"
|
|
)
|
|
|
|
// customHome can be set at link time to specify the home directory for the worker.
|
|
// This can be overruled at runtime by setting the FLAMENCO_HOME enviroment variable.
|
|
// Only used in InFlamencoHome() function.
|
|
var customHome = ""
|
|
|
|
// InFlamencoHome returns the filename in the 'flamenco home' dir, and ensures
|
|
// that the directory exists.
|
|
func InFlamencoHome(filename string) (string, error) {
|
|
flamencoHome := customHome
|
|
if envHome, ok := os.LookupEnv("FLAMENCO_HOME"); ok {
|
|
flamencoHome = envHome
|
|
}
|
|
if flamencoHome == "" {
|
|
return xdg.DataFile(path.Join(xdgApplicationName, filename))
|
|
}
|
|
if err := os.MkdirAll(flamencoHome, os.ModePerm); err != nil {
|
|
return "", err
|
|
}
|
|
return filepath.Join(flamencoHome, filename), nil
|
|
}
|