Skip to content

Commit

Permalink
Remove dead special case for defunct branch COBALT (#4850)
Browse files Browse the repository at this point in the history
… and inline local variable gcs_path_suffix.

Issue: 365150653
  • Loading branch information
dahlstrom-g committed Feb 6, 2025
2 parents 76256e5 + f1e841c commit 6d680b8
Show file tree
Hide file tree
Showing 3 changed files with 187 additions and 14 deletions.
65 changes: 51 additions & 14 deletions cobalt/devinfra/kokoro/bin/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -238,32 +238,69 @@ upload_on_device_test_artifacts () {
echo -n "${gcs_archive_path}" > "${KOKORO_ARTIFACTS_DIR}/gcs_archive_path"
}


create_and_upload_nightly_archive () {
if [[ $# -ne 4 ]]; then
echo "Error: Exactly 4 arguments required!"
exit 1
fi

local platform=$1
local package_dir=$2
local local_archive_path=$3
local build_info_path=$4

local gcs_archive_path="gs://$(get_bucket_name)/${platform}_${KOKORO_GOB_BRANCH_src}/$(date +%F)/${KOKORO_ROOT_BUILD_NUMBER}/"

init_gcloud

# Copy everything in package_dir but not its last path segment; gcs_archive_path already exists.
"${GSUTIL}" cp -r "${package_dir}/." "${gcs_archive_path}"
}

run_package_release_pipeline () {
# NOTE: For DinD builds, we only run the GN and Ninja steps in the container.
# Artifacts and build-products from these steps are used in subsequent steps
# for packaging and nightly post-build tasks, and do not need to be run in the
# inner container environment (which has build tools and deps).

local out_dir="${WORKSPACE_COBALT}/out/${TARGET_PLATFORM}_${CONFIG}"

# Package and upload nightly release archive.
if is_release_build && is_release_config; then
local out_dir="${WORKSPACE_COBALT}/out/${TARGET_PLATFORM}_${CONFIG}"
# Setup package dir.
local package_dir="${WORKSPACE_COBALT}/package/${PLATFORM}_${CONFIG}"
mkdir -p "${package_dir}"

# Create reference build_info.json
cp "${out_dir}/gen/build_info.json" "${package_dir}/"
# TODO(b/294130306): Move build_info to gn packaging.
local build_info_path="${out_dir}/gen/build_info.json"
cp "${build_info_path}" "${package_dir}/"

# Create release package
local package_platform="linux"
# Create release package.
export PYTHONPATH="${WORKSPACE_COBALT}"
if [[ "${PLATFORM}" =~ "android" ]]; then
package_platform="android"
python3 "${WORKSPACE_COBALT}/cobalt/build/android/package.py" \
--name="${PLATFORM}_${CONFIG}" "${out_dir}" "${package_dir}"
elif [[ "${PLATFORM}" =~ "evergreen" ]]; then
local bootloader_out_dir=
if [ -n "${BOOTLOADER:-}" ]; then
bootloader_out_dir="${WORKSPACE_COBALT}/out/${BOOTLOADER}_${CONFIG}"
fi
# Creates Evergreen package directory.
python3 "${WORKSPACE_COBALT}/cobalt/devinfra/kokoro/build/evergreen/simple_packager.py" \
"${out_dir}" \
"${package_dir}" \
"${bootloader_out_dir:-}"
else
python3 "${WORKSPACE_COBALT}/cobalt/build/linux/package.py" \
--name="${PLATFORM}_${CONFIG}" "${out_dir}" "${package_dir}"
fi
python3 "${WORKSPACE_COBALT}/cobalt/build/${package_platform}/package.py" \
--name="${PLATFORM}_${CONFIG}" "${out_dir}" "${package_dir}"

# Upload release package
local gcs_archive_path="gs://$(get_bucket_name)/${PLATFORM}_${KOKORO_GOB_BRANCH_src}/$(date +%F)/${KOKORO_ROOT_BUILD_NUMBER}/"
init_gcloud
# Ensure that only package directory contents are uploaded and not the directory itself
"${GSUTIL}" cp -r "${package_dir}/." "${gcs_archive_path}"

# Create and upload nightly archive.
create_and_upload_nightly_archive \
"${PLATFORM}" \
"${package_dir}" \
"${package_dir}.tar.gz" \
"${build_info_path}"
fi
}
51 changes: 51 additions & 0 deletions cobalt/devinfra/kokoro/build/android/simple_packager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env python3
#
# Copyright 2024 The Cobalt Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""Simple Android packager, stopgap until merged into GN."""

import os
import shutil
import sys

out_dir = sys.argv[1] # out directory generated by ninja
package_dir = sys.argv[2] # package directory to be generated
src_dir = sys.argv[3] # root of Cobalt repository

# Creates Android package directory
os.makedirs(package_dir, exist_ok=True)
shutil.copy2(
os.path.join(out_dir, 'cobalt.apk'), os.path.join(package_dir,
'cobalt.apk'))
os.makedirs(os.path.join(package_dir, 'cobalt_package'), exist_ok=True)
shutil.copy2(
os.path.join(out_dir, 'libcobalt.so'),
os.path.join(package_dir, 'cobalt_package', 'libcobalt.so'))
shutil.copytree(
os.path.join(out_dir, 'content'),
os.path.join(package_dir, 'cobalt_package', 'content'))
shutil.copytree(
os.path.join(src_dir, 'starboard', 'android', 'apk', 'app'),
os.path.join(package_dir, 'apk-app-src'))
os.makedirs(os.path.join(package_dir, 'apk-app-src', 'proto'), exist_ok=True)
shutil.copy2(
os.path.join(src_dir, 'cobalt', 'storage', 'store', 'storage.proto'),
os.path.join(package_dir, 'apk-app-src', 'proto', 'storage.proto'))
shutil.copy2(
os.path.join(out_dir, 'gen', 'build_info.json'),
os.path.join(package_dir, 'build_info.json'))
shutil.copy2(
os.path.join(out_dir, 'gen', 'libraries.tsv'),
os.path.join(package_dir, 'libraries.tsv'))
85 changes: 85 additions & 0 deletions cobalt/devinfra/kokoro/build/evergreen/simple_packager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/usr/bin/env python3
#
# Copyright 2024 The Cobalt Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""Simple Evergreen packager, stopgap until merged into GN."""

import os
import shutil
import sys

_TEST_APPS = [
'libone_app_only_sandbox.so', 'libcrash_sandbox.so', 'libnoop_sandbox.so',
'libone_app_only_sandbox.lz4', 'libcrash_sandbox.lz4', 'libnoop_sandbox.lz4'
]

out_dir = sys.argv[1] # out directory generated by ninja
package_dir = sys.argv[2] # package directory to be generated
bootloader_out_dir = sys.argv[3]

# Creates Evergreen package directory
os.makedirs(package_dir, exist_ok=True)
shutil.copy2(
os.path.join(out_dir, 'install', 'lib', 'libcobalt.so'),
os.path.join(package_dir, 'libcobalt.so'))
shutil.copy2(
os.path.join(out_dir, 'install', 'lib', 'libcobalt.lz4'),
os.path.join(package_dir, 'libcobalt.lz4'))
shutil.copytree(
os.path.join(out_dir, 'install', 'usr', 'share', 'cobalt'),
os.path.join(package_dir, 'content'))
shutil.copy2(
os.path.join(out_dir, 'install', 'usr', 'share', 'manifest.json'),
os.path.join(package_dir, 'manifest.json'))
os.makedirs(os.path.join(package_dir, 'symbols'), exist_ok=True)
shutil.copy2(
os.path.join(out_dir, 'libcobalt.so'),
os.path.join(package_dir, 'symbols', 'libcobalt.so'))
for test_app in _TEST_APPS:
test_app_file = os.path.join(out_dir, 'install', 'lib', test_app)
if os.path.exists(test_app_file):
shutil.copy2(test_app_file, os.path.join(package_dir, test_app))
shutil.copy2(
os.path.join(out_dir, 'gen', 'build_info.json'),
os.path.join(package_dir, 'build_info.json'))
shutil.copy2(
os.path.join(out_dir, 'gen', 'libraries.tsv'),
os.path.join(package_dir, 'libraries.tsv'))

if bootloader_out_dir is not None:
# Handle Raspi EG.
if os.path.exists(os.path.join(bootloader_out_dir, 'loader_app')):
shutil.copy2(
os.path.join(bootloader_out_dir, 'loader_app'),
os.path.join(package_dir, 'loader_app'))
# Handle Android EG.
if os.path.exists(os.path.join(bootloader_out_dir, 'loader_app.apk')):
shutil.copy2(
os.path.join(bootloader_out_dir, 'loader_app.apk'),
os.path.join(package_dir, 'loader_app.apk'))
if os.path.exists(
os.path.join(bootloader_out_dir, 'native_target', 'crashpad_handler')):
os.makedirs(os.path.join(package_dir, 'native_target'), exist_ok=True)
shutil.copy2(
os.path.join(bootloader_out_dir, 'native_target', 'crashpad_handler'),
os.path.join(package_dir, 'native_target', 'crashpad_handler'))
if os.path.exists(
os.path.join(bootloader_out_dir, 'install', 'content', 'fonts')):
os.makedirs(
os.path.join(package_dir, 'install', 'content', 'fonts'), exist_ok=True)
shutil.copytree(
os.path.join(bootloader_out_dir, 'install', 'content', 'fonts'),
os.path.join(package_dir, 'content', 'fonts'),
dirs_exist_ok=True)

0 comments on commit 6d680b8

Please sign in to comment.