ssh_client: split depot_tools & webports out into dedicated third_party/ dirs

This makes the two projects follow Google guidelines for keeping
3rd party code in separate dedicated paths.

Change-Id: I0c075c1c28e22cacdadc48e1d3e31c32f5f29e1a
Reviewed-on: https://chromium-review.googlesource.com/c/1268876
Reviewed-by: Vitaliy Shipitsyn <vsh@google.com>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/ssh_client/README.md b/ssh_client/README.md
index 8f853ec..42d96d7 100644
--- a/ssh_client/README.md
+++ b/ssh_client/README.md
@@ -72,7 +72,9 @@
   See the next section for more in-depth coverage.
 * [third_party/]: All third party projects have a unique subdir.
   Do not try to run these directly as they rely on settings in [build.sh].
+  * [depot_tools/]: Tools used by webports.
   * [mandoc/]: Tools to generate html from man pages.
+  * [webports/]: SDK for cross-compiling some third party libs for NaCl.
 
 Here are the rest of the files, but most likely you don't need to touch these:
 
@@ -233,7 +235,9 @@
 [ssh_client.nmf]: ./ssh_client.nmf
 [third_party/]: ./third_party/
 
+[depot_tools/]: ./third_party/depot_tools/
 [mandoc/]: ./third_party/mandoc/
+[webports/]: ./third_party/webports/
 
 [dev_null.cc]: ./src/dev_null.cc
 [dev_null.h]: ./src/dev_null.h
diff --git a/ssh_client/build.sh b/ssh_client/build.sh
index 4059dc1..b5b10c6 100755
--- a/ssh_client/build.sh
+++ b/ssh_client/build.sh
@@ -10,7 +10,6 @@
 DEBUG=0
 
 NACLSDK_VERSION=49.0.2623.87
-WEBPORTS_REVISION=${NACLSDK_VERSION%%.*}
 
 CDS_ROOT="https://commondatastorage.googleapis.com"
 SDK_ROOT="$CDS_ROOT/nativeclient-mirror/nacl/nacl_sdk"
@@ -46,32 +45,12 @@
   popd
 fi
 
-if [[ ($WEB_PORTS == "") || !(-d $WEB_PORTS) ]]; then
-  pushd output
-  if [[ !(-d webports/src) ]]; then
-    # Get own copy of depot_tools for gclient.
-    if [[ ! -d depot_tools ]]; then
-      git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
-    fi
-    PATH="${PWD}/depot_tools:${PATH}"
-
-    rm -rf webports && mkdir webports
-    cd webports
-    gclient config --name=src https://chromium.googlesource.com/webports.git
-    gclient sync --jobs=8 -r src@pepper_$WEBPORTS_REVISION
-    cd ..
-  fi
-  export WEB_PORTS=$PWD/webports
-  popd
-fi
+./third_party/webports/build.sh
+export WEB_PORTS="${PWD}/output/webports"
 
 ./third_party/mandoc/build.sh
 
 build() {
-  pushd $WEB_PORTS/src
-  make openssl zlib jsoncpp
-  popd
-
   pushd output
   if [[ ! -f libopenssh-pnacl.a ]]; then
     ../nacl-openssh.sh
diff --git a/ssh_client/third_party/depot_tools/LICENSE b/ssh_client/third_party/depot_tools/LICENSE
new file mode 100644
index 0000000..a7531cf
--- /dev/null
+++ b/ssh_client/third_party/depot_tools/LICENSE
@@ -0,0 +1,27 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//    * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//    * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//    * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/ssh_client/third_party/depot_tools/METADATA b/ssh_client/third_party/depot_tools/METADATA
new file mode 100644
index 0000000..b60c337
--- /dev/null
+++ b/ssh_client/third_party/depot_tools/METADATA
@@ -0,0 +1,9 @@
+name: "depot_tools"
+description: "Tools for working with Chromium development"
+
+third_party {
+  url {
+    type: HOMEPAGE
+    value: "http://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up"
+  }
+}
diff --git a/ssh_client/third_party/depot_tools/build.sh b/ssh_client/third_party/depot_tools/build.sh
new file mode 100755
index 0000000..a8a52d1
--- /dev/null
+++ b/ssh_client/third_party/depot_tools/build.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+# Copyright 2018 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+GIT_URI="https://chromium.googlesource.com/chromium/tools/depot_tools.git"
+
+if [[ ! -d depot_tools ]]; then
+  git clone --depth=1 "${GIT_URI}"
+fi
diff --git a/ssh_client/third_party/webports/LICENSE b/ssh_client/third_party/webports/LICENSE
new file mode 100644
index 0000000..1941a11
--- /dev/null
+++ b/ssh_client/third_party/webports/LICENSE
@@ -0,0 +1,28 @@
+Copyright 2008, Google Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+    * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+    * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/ssh_client/third_party/webports/METADATA b/ssh_client/third_party/webports/METADATA
new file mode 100644
index 0000000..e2d9c0d
--- /dev/null
+++ b/ssh_client/third_party/webports/METADATA
@@ -0,0 +1,10 @@
+name: "webports"
+description: "Tools for building and maintaining Native Client ports"
+
+third_party {
+  url {
+    type: HOMEPAGE
+    value: "https://chromium.googlesource.com/webports.git"
+  }
+  version: "49"
+}
diff --git a/ssh_client/third_party/webports/build.sh b/ssh_client/third_party/webports/build.sh
new file mode 100755
index 0000000..91aa8a6
--- /dev/null
+++ b/ssh_client/third_party/webports/build.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+# Copyright 2018 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+PV="49"
+
+GIR_URI="https://chromium.googlesource.com/webports.git"
+
+pushd output >/dev/null
+
+if [[ ! -d webports/src ]]; then
+  # Get own copy of depot_tools for gclient.
+  ../third_party/depot_tools/build.sh
+  PATH="${PWD}/depot_tools:${PATH}"
+
+  rm -rf webports && mkdir webports
+  pushd webports >/dev/null
+  gclient config --name=src "${GIR_URI}"
+  gclient sync --jobs=8 -r "src@pepper_${PV}"
+  popd >/dev/null
+fi
+
+make -C webports/src openssl zlib jsoncpp
+
+popd >/dev/null