blob: 0c2c59130b4a92097b4ee5175ffc53c7cf8405a5 [file] [log] [blame] [edit]
#!/bin/bash
# Copyright 2023 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# Generates forwarding headers for Perfetto headers included by base. In
# Chromium, these are found under "third_party/perfetto", but on ChromeOS we
# must use <perfetto/perfetto.h> to use the system-provided implementation.
set -e
cd $(dirname $0)/..
includes=$(find . -name '*.cc' -or -name '*.h' \
| xargs sed -n 's,^#include "\(third_party/perfetto/.*\)".*,\1,p')
# Other headers included by generated protozero (.pbzero.h) headers.
protozero_includes="
third_party/perfetto/include/perfetto/protozero/field_writer.h
third_party/perfetto/include/perfetto/protozero/message.h
third_party/perfetto/include/perfetto/protozero/packed_repeated_fields.h
third_party/perfetto/include/perfetto/protozero/proto_decoder.h
third_party/perfetto/include/perfetto/protozero/proto_utils.h
third_party/perfetto/include/protos/perfetto/trace/track_event/debug_annotation.pbzero.h
third_party/perfetto/include/protos/perfetto/trace/track_event/track_event.pbzero.h"
rm -rf third_party/perfetto
for include in $includes $protozero_includes; do
if [ -f "$include" ]; then continue; fi
echo "Creating $include"
guard=$(echo $include | tr a-z A-Z | tr /. _)_
mkdir -p $(dirname "$include")
cat > "$include" <<EOF
// Copyright 2023 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.
#ifndef $guard
#define $guard
// Automatically generated by $0. Do not edit.
#include <perfetto/perfetto.h>
#endif // $guard
EOF
done