build: change CANTRIP_OUT_DIR pathname construction

Change the output directory pathname to avoid collision between platforms;
specifically the "nexus" and "shodan" platforms. Build artifacts are now
written to:

$OUT/cantrip/<platform>/{debug,release}

with follow-on changes moving build artifacts into this area to (more
correctly) isolate builds.

Bug: 293296515

Change-Id: Ia1f38325c57a656e53d4973734b844fa296e46ec
diff --git a/cantrip.mk b/cantrip.mk
index 138a40f..49b2eed 100644
--- a/cantrip.mk
+++ b/cantrip.mk
@@ -33,7 +33,7 @@
 # Location of seL4 kernel source (for sel4-sys)
 SEL4_KERNEL_DIR  := $(ROOTDIR)/cantrip/kernel
 
-# CANTRIP_OUT_DIR is defined in build/platform/$PLATFORM/setup.sh
+# CANTRIP_OUT_DIR is defined in build/setup.sh
 CANTRIP_OUT_DEBUG   := $(CANTRIP_OUT_DIR)/debug
 CANTRIP_OUT_RELEASE := $(CANTRIP_OUT_DIR)/release
 
diff --git a/platforms/nexus/setup.sh b/platforms/nexus/setup.sh
index 9c02733..1eaa09d 100644
--- a/platforms/nexus/setup.sh
+++ b/platforms/nexus/setup.sh
@@ -29,7 +29,6 @@
 export RUSTUP_HOME="${RUSTDIR}"
 export PATH="${RUSTDIR}/bin:${PATH}"
 
-export CANTRIP_OUT_DIR="${OUT}/cantrip/${CANTRIP_TARGET_ARCH}"
 export OPENTITAN_GEN_DIR="${CANTRIP_OUT_DIR}/opentitan-gen/include/opentitan"
 export OPENTITAN_SOURCE="${ROOTDIR}/hw/opentitan-upstream"
 
diff --git a/platforms/rpi3/setup.sh b/platforms/rpi3/setup.sh
index ea8b0d4..09a0d87 100644
--- a/platforms/rpi3/setup.sh
+++ b/platforms/rpi3/setup.sh
@@ -48,5 +48,3 @@
     export RUSTUP_HOME="${RUSTDIR}"
     export PATH="${RUSTDIR}/bin:${PATH}"
 fi
-
-export CANTRIP_OUT_DIR="${OUT}/cantrip/${CANTRIP_TARGET_ARCH}"
diff --git a/platforms/shodan/setup.sh b/platforms/shodan/setup.sh
index 0711ab0..ff75fac 100644
--- a/platforms/shodan/setup.sh
+++ b/platforms/shodan/setup.sh
@@ -29,7 +29,6 @@
 export RUSTUP_HOME="${RUSTDIR}"
 export PATH="${RUSTDIR}/bin:${PATH}"
 
-export CANTRIP_OUT_DIR="${OUT}/cantrip/${CANTRIP_TARGET_ARCH}"
 export OPENTITAN_GEN_DIR="${CANTRIP_OUT_DIR}/opentitan-gen/include/opentitan"
 export OPENTITAN_SOURCE="${ROOTDIR}/hw/opentitan-upstream"
 
diff --git a/setup.sh b/setup.sh
index d211bd6..add0820 100644
--- a/setup.sh
+++ b/setup.sh
@@ -179,20 +179,19 @@
     fi
 
     export PLATFORM="${platform}"
+    export CANTRIP_OUT_DIR="${OUT}/cantrip/${PLATFORM}"
     source "${ROOTDIR}/build/platforms/${platform}/setup.sh"
 }
 
 function kcargo
 {
-    local CANTRIP_OUT_DIR="${OUT}/cantrip/${CANTRIP_TARGET_ARCH}"
-
     # NB: sel4-config needs a path to the kernel build which could be
     #     in debug or release (for our needs either works)
     local SEL4_OUT_DIR="${CANTRIP_OUT_DIR}/debug/kernel/"
     if [[ ! -d "${SEL4_OUT_DIR}/gen_config" ]]; then
         SEL4_OUT_DIR="${CANTRIP_OUT_DIR}/release/kernel/"
         if [[ ! -d "${SEL4_OUT_DIR}/gen_config" ]]; then
-            echo "No kernel build found at \${SEL4_OUT_DIR}; build a kernel first"
+            echo "No kernel build found at ${SEL4_OUT_DIR}; build a kernel first"
             set +x
             return 1
         fi