Allow projects to define their own build.

To create a new project, add a directory under `project` and pass the
project name to `make`:

    mkdir project/my_project
    # Describe the build for the project.
    PROJECT=my_project make

Projects can be maintained separately from the main repository.

Change-Id: I33a9d7ca801e2fb3dd9795ece44577b3b565e913
diff --git a/build/toolchain/BUILD.gn b/build/toolchain/BUILD.gn
index 344d30e..916c1c7 100644
--- a/build/toolchain/BUILD.gn
+++ b/build/toolchain/BUILD.gn
@@ -12,42 +12,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import("//build/toolchain/embedded.gni")
 import("//build/toolchain/host.gni")
 
 host_toolchain("host") {
-  use_fake_arch = false
-}
-
-host_toolchain("host_fake") {
-  use_fake_arch = true
-  max_cpus = 4
-  max_vms = 6
-}
-
-aarch64_toolchain("qemu_aarch64") {
-  cpu = "cortex-a57+nofp"
-  origin_address = "0x40001000"
-  use_pl011 = true
-  pl011_base_address = "0x09000000"
-  max_cpus = 8
-  max_vms = 16
-}
-
-aarch64_toolchain("hikey") {
-  cpu = "cortex-a53+nofp"
-  origin_address = "0x01000000"
-  use_pl011 = true
-  pl011_base_address = "0xf8015000"
-  max_cpus = 8
-  max_vms = 16
-}
-
-aarch64_toolchain("aem_v8a_fvp") {
-  cpu = "cortex-a57+nofp"
-  origin_address = "0x88000000"
-  use_pl011 = true
-  pl011_base_address = "0x1c090000"
-  max_cpus = 8
-  max_vms = 16
+  use_platform = false
 }
diff --git a/build/toolchain/embedded.gni b/build/toolchain/embedded.gni
index b9a5cdd..290f163 100644
--- a/build/toolchain/embedded.gni
+++ b/build/toolchain/embedded.gni
@@ -185,9 +185,11 @@
     extra_cflags = cflags
     extra_ldflags = ldflags
     toolchain_args = {
-      platform_max_cpus = invoker.max_cpus
-      platform_max_vms = invoker.max_vms
-      arch = invoker.arch
+      use_platform = true
+      plat_name = invoker.target_name
+      plat_arch = invoker.arch
+      plat_max_cpus = invoker.max_cpus
+      plat_max_vms = invoker.max_vms
       if (defined(invoker.toolchain_args)) {
         forward_variables_from(invoker.toolchain_args, "*")
       }
@@ -200,9 +202,11 @@
     extra_cflags = cflags
     extra_ldflags = ldflags
     toolchain_args = {
-      platform_max_cpus = invoker.max_cpus
-      platform_max_vms = invoker.max_vms
-      arch = invoker.arch
+      use_platform = true
+      plat_name = invoker.target_name
+      plat_arch = invoker.arch
+      plat_max_cpus = invoker.max_cpus
+      plat_max_vms = invoker.max_vms
       if (defined(invoker.toolchain_args)) {
         forward_variables_from(invoker.toolchain_args, "*")
       }
diff --git a/build/toolchain/host.gni b/build/toolchain/host.gni
index 8b39a77..11bf388 100644
--- a/build/toolchain/host.gni
+++ b/build/toolchain/host.gni
@@ -123,9 +123,9 @@
 }
 
 template("host_toolchain") {
-  assert(defined(invoker.use_fake_arch),
-         "\"use_fake_arch\" must be defined for ${target_name}.")
-  if (invoker.use_fake_arch) {
+  assert(defined(invoker.use_platform),
+         "\"use_platform\" must be defined for ${target_name}.")
+  if (invoker.use_platform) {
     assert(defined(invoker.max_cpus),
            "\"max_cpus\" must be defined for ${target_name}.")
     assert(defined(invoker.max_vms),
@@ -141,14 +141,15 @@
     # TODO: remove the need for this
     extra_defines = "-DPL011_BASE=0"
 
-    if (invoker.use_fake_arch) {
+    if (invoker.use_platform) {
       toolchain_args = {
-        platform_max_cpus = invoker.max_cpus
-        platform_max_vms = invoker.max_vms
+        use_platform = true
 
         # When building for the ${target_name}, use the fake architecture to make things
         # testable.
-        arch = "fake"
+        plat_arch = "fake"
+        plat_max_cpus = invoker.max_cpus
+        plat_max_vms = invoker.max_vms
       }
     }
   }
@@ -162,14 +163,15 @@
     # TODO: remove the need for this
     extra_defines = "-DPL011_BASE=0"
 
-    if (invoker.use_fake_arch) {
+    if (invoker.use_platform) {
       toolchain_args = {
-        platform_max_cpus = invoker.max_cpus
-        platform_max_vms = invoker.max_vms
+        use_platform = true
 
         # When building for the ${target_name}, use the fake architecture to make things
         # testable.
-        arch = "fake"
+        plat_arch = "fake"
+        plat_max_cpus = invoker.max_cpus
+        plat_max_vms = invoker.max_vms
       }
     }
   }
diff --git a/build/toolchain/platform.gni b/build/toolchain/platform.gni
index 7a1c8a9..4bcfdc3 100644
--- a/build/toolchain/platform.gni
+++ b/build/toolchain/platform.gni
@@ -14,9 +14,15 @@
 
 # Configuration of the build for the platform.
 declare_args() {
+  # The name of the platform.
+  plat_name = ""
+
+  # The architecture of the platform.
+  plat_arch = ""
+
   # The maximum number of CPUs available on the platform.
-  platform_max_cpus = 0
+  plat_max_cpus = 0
 
   # The maximum number of VMs required for the platform.
-  platform_max_vms = 0
+  plat_max_vms = 0
 }