Skip to content

Commit

Permalink
feat(cmd/rofl): Add support for build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
kostko committed Jan 14, 2025
1 parent 5d8e97d commit 6c8bbdc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions build/rofl/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ const (
TEETypeTDX = "tdx"
)

// Well-known scripts.
const (
ScriptBuildPre = "build-pre"
ScriptBuildPost = "build-post"
)

// Manifest is the ROFL app manifest that configures various aspects of the app in a single place.
type Manifest struct {
// Name is the human readable ROFL app name.
Expand All @@ -50,6 +56,9 @@ type Manifest struct {
// Deployments are the ROFL app deployments.
Deployments map[string]*Deployment `yaml:"deployments" json:"deployments"`

// Scripts are custom scripts that are executed by the build system at specific stages.
Scripts map[string]string `yaml:"scripts,omitempty" json:"scripts,omitempty"`

// sourceFn is the filename from which the manifest has been loaded.
sourceFn string
}
Expand Down
11 changes: 11 additions & 0 deletions cmd/rofl/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ var (
return
}

// Setup some build environment variables.
os.Setenv("ROFL_MANIFEST", manifest.SourceFileName())
os.Setenv("ROFL_DEPLOYMENT", deploymentName)
os.Setenv("ROFL_DEPLOYMENT_NETWORK", deployment.Network)
os.Setenv("ROFL_DEPLOYMENT_PARATIME", deployment.ParaTime)
os.Setenv("ROFL_TMPDIR", tmpDir)

runScript(manifest, buildRofl.ScriptBuildPre)

Check failure on line 86 in cmd/rofl/build/build.go

View workflow job for this annotation

GitHub Actions / lint

undefined: runScript

Check failure on line 86 in cmd/rofl/build/build.go

View workflow job for this annotation

GitHub Actions / lint

undefined: runScript

Check failure on line 86 in cmd/rofl/build/build.go

View workflow job for this annotation

GitHub Actions / tests-ubuntu-latest

undefined: runScript

switch manifest.TEE {
case buildRofl.TEETypeSGX:
// SGX.
Expand All @@ -102,6 +111,8 @@ var (
return
}

runScript(manifest, buildRofl.ScriptBuildPost)

Check failure on line 114 in cmd/rofl/build/build.go

View workflow job for this annotation

GitHub Actions / lint

undefined: runScript (typecheck)

Check failure on line 114 in cmd/rofl/build/build.go

View workflow job for this annotation

GitHub Actions / lint

undefined: runScript) (typecheck)

Check failure on line 114 in cmd/rofl/build/build.go

View workflow job for this annotation

GitHub Actions / tests-ubuntu-latest

undefined: runScript

// Write the bundle out.
outFn := fmt.Sprintf("%s.%s.orc", manifest.Name, deploymentName)
if outputFn != "" {
Expand Down

0 comments on commit 6c8bbdc

Please sign in to comment.