From 6c8bbdced667d5c005c685110a4d2072c87e0f14 Mon Sep 17 00:00:00 2001 From: Jernej Kos Date: Tue, 14 Jan 2025 12:21:01 +0100 Subject: [PATCH] feat(cmd/rofl): Add support for build scripts --- build/rofl/manifest.go | 9 +++++++++ cmd/rofl/build/build.go | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/build/rofl/manifest.go b/build/rofl/manifest.go index d4d9487..01b63de 100644 --- a/build/rofl/manifest.go +++ b/build/rofl/manifest.go @@ -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. @@ -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 } diff --git a/cmd/rofl/build/build.go b/cmd/rofl/build/build.go index cf341a2..a716835 100644 --- a/cmd/rofl/build/build.go +++ b/cmd/rofl/build/build.go @@ -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) + switch manifest.TEE { case buildRofl.TEETypeSGX: // SGX. @@ -102,6 +111,8 @@ var ( return } + runScript(manifest, buildRofl.ScriptBuildPost) + // Write the bundle out. outFn := fmt.Sprintf("%s.%s.orc", manifest.Name, deploymentName) if outputFn != "" {