From 72e39550f316404a764dd2fa11b00a110ae38c61 Mon Sep 17 00:00:00 2001
From: Mark Farrugia <mark.farrugia@fiberdyne.com.au>
Date: Thu, 13 Dec 2018 17:11:20 +1100
Subject: Add build script for AGL without XDS

This adds the function to build with or without AGL XDS build
system. Functionality is updated to work with vscode.

Signed-off-by: Mark Farrugia <mark.farrugia@fiberdyne.com.au>
---
 .vscode/tasks.json      | 142 +++++++++++++++++++++++++++---------------------
 scripts/make-agl-xds.sh |  14 +++++
 scripts/make-agl.sh     |  22 ++++----
 3 files changed, 106 insertions(+), 72 deletions(-)
 create mode 100755 scripts/make-agl-xds.sh

diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index 999a832..09c6bb5 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -1,63 +1,81 @@
 {
-  // See https://go.microsoft.com/fwlink/?LinkId=733558
-  // for the documentation about the tasks.json format
-  "version": "2.0.0",
-  "type": "shell",
-  "presentation": {
-    "reveal": "always"
-  },
-  "tasks": [
-    {
-      "label": "Make Driver",
-      "command": "make all",
-      "group": "build",
-      "problemMatcher": ["$gcc"]
-    },
-    {
-      "label": "Clean Driver",
-      "command": "make clean",
-      "group": "build",
-      "problemMatcher": ["$gcc"]
-    },
-    {
-      "label": "Deploy Drivers",
-      "command": "sudo sh -c './scripts/unload.sh && ./scripts/load.sh'",
-      "problemMatcher": []
-    },
-    {
-      "label": "Make and Deploy Drivers",
-      "command": "make all && sudo sh -c './scripts/unload.sh && ./scripts/load.sh'",
-      "problemMatcher": []
-    },
-    {
-      "label": "Unload new drivers",
-      "command": "sudo sh ./scripts/unload.sh",
-      "problemMatcher": []
-    },
-    {
-      "label": "Load new drivers",
-      "command": "sudo sh ./scripts/load.sh",
-      "problemMatcher": []
-    },
-    {
-      "label": "Make Driver AGL",
-      "type": "shell",
-      "command": "./scripts/make-agl.sh 6864c558",
-      "group": "build",
-      "problemMatcher": ["$gcc"]
-    },
-    {
-      "label": "Clean Driver AGL",
-      "type": "shell",
-      "command": "./scripts/make-agl.sh 6864c558 clean",
-      "group": "build",
-      "problemMatcher": ["$gcc"]
-    },
-    {
-      "label": "Deploy Driver AGL",
-      "type": "shell",
-      "command": "rsync -av snd-avirt-core.ko dummy/snd-avirt-ap-dummy.ko loopback/snd-avirt-ap-loopback.ko root@192.168.1.193:/lib/modules/4.14.0-yocto-standard/extra",
-      "problemMatcher": ["$gcc"]
-    }
-  ]
-}
+	// See https://go.microsoft.com/fwlink/?LinkId=733558
+	// for the documentation about the tasks.json format
+	"version": "2.0.0",
+	"type": "shell",
+	"presentation": {
+		"reveal": "always"
+	},
+	"tasks": [
+		{
+			"label": "Make Drivers",
+			"command": "make all",
+			"group": "build",
+			"problemMatcher": [
+				"$gcc"
+			]
+		},
+		{
+			"label": "Clean Drivers",
+			"command": "make clean",
+			"group": "build",
+			"problemMatcher": [
+				"$gcc"
+			]
+		},
+		{
+			"label": "Unload Drivers",
+			"command": "sudo sh ./scripts/unload.sh",
+			"problemMatcher": []
+		},
+		{
+			"label": "Load Drivers",
+			"command": "sudo sh ./scripts/load.sh",
+			"problemMatcher": []
+		},
+		{
+			"label": "Make Driver AGL (XDS)",
+			"type": "shell",
+			"command": "./scripts/make-agl-xds.sh 6864c558",
+			"group": "build",
+			"problemMatcher": [
+				"$gcc"
+			]
+		},
+		{
+			"label": "Clean Driver AGL (XDS)",
+			"type": "shell",
+			"command": "./scripts/make-agl-xds.sh 6864c558 clean",
+			"group": "build",
+			"problemMatcher": [
+				"$gcc"
+			]
+		},
+		{
+			"label": "Make Driver AGL",
+			"type": "shell",
+			"command": "./scripts/make-agl.sh",
+			"group": "build",
+			"problemMatcher": [
+				"$gcc"
+			]
+		},
+		{
+			"label": "Clean Driver AGL",
+			"type": "shell",
+			"command": "./scripts/make-agl.sh clean",
+			"group": "build",
+			"problemMatcher": [
+				"$gcc"
+			]
+		},
+		{
+			"label": "Deploy Driver AGL",
+			"type": "shell",
+			"command": "scp snd-avirt-core.ko dummy/snd-avirt-ap-dummy.ko loopback/snd-avirt-ap-loopback.ko root@192.168.1.193:/lib/modules/4.14.35-yocto-standard/extra",
+			"problemMatcher": [
+				"$gcc"
+			]
+		}
+	]
+}
\ No newline at end of file
diff --git a/scripts/make-agl-xds.sh b/scripts/make-agl-xds.sh
new file mode 100755
index 0000000..5cb8048
--- /dev/null
+++ b/scripts/make-agl-xds.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+# Get SDK path
+sdk_id=$1 # first arg must be XDS_SDK_ID
+shift 1
+long_sdkpath=$(xds-cli sdks get $sdk_id | grep Path)
+sdkpath=${long_sdkpath:4}
+
+# Build
+/opt/AGL/bin/xds-cli exec --config xds-project.conf --			\
+	CONFIG_AVIRT=m CONFIG_AVIRT_BUILDLOCAL=y			\
+	CONFIG_AVIRT_AP_DUMMY=m						\
+	CONFIG_AVIRT_AP_LOOPBACK=m					\
+	make -C $sdkpath/sysroots/aarch64-agl-linux/usr/src/kernel M=$(pwd) $@
diff --git a/scripts/make-agl.sh b/scripts/make-agl.sh
index 5cb8048..2f88757 100755
--- a/scripts/make-agl.sh
+++ b/scripts/make-agl.sh
@@ -1,14 +1,16 @@
 #!/bin/bash
 
-# Get SDK path
-sdk_id=$1 # first arg must be XDS_SDK_ID
-shift 1
-long_sdkpath=$(xds-cli sdks get $sdk_id | grep Path)
-sdkpath=${long_sdkpath:4}
+SDK_ROOT=/opt/agl-sdk
+SDK_VERSION=6.99.1+snapshot
+SDK_VAR=aarch64
+
+# Source environment
+unset LD_LIBRARY_PATH
+source $SDK_ROOT/$SDK_VERSION-$SDK_VAR/environment-setup-aarch64-agl-linux
 
 # Build
-/opt/AGL/bin/xds-cli exec --config xds-project.conf --			\
-	CONFIG_AVIRT=m CONFIG_AVIRT_BUILDLOCAL=y			\
-	CONFIG_AVIRT_AP_DUMMY=m						\
-	CONFIG_AVIRT_AP_LOOPBACK=m					\
-	make -C $sdkpath/sysroots/aarch64-agl-linux/usr/src/kernel M=$(pwd) $@
+LDFLAGS= \
+CONFIG_AVIRT=m CONFIG_AVIRT_BUILDLOCAL=y			\
+CONFIG_AVIRT_AP_DUMMY=m						\
+CONFIG_AVIRT_AP_LOOPBACK=m					\
+make -C $SDK_ROOT/$SDK_VERSION-$SDK_VAR/sysroots/$SDK_VAR-agl-linux/usr/src/kernel M=$(pwd) $@
-- 
cgit