| # Copyright (C) 2019 The Android Open Source Project |
| # 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. |
| print('Usage: %s output_file.h' % argv[0]) |
| script_dir = os.path.dirname(os.path.realpath(__file__)) |
| revision = subprocess.check_output( |
| ['git', '-C', script_dir, 'rev-parse', 'HEAD']).strip() |
| new_contents = '#define PERFETTO_GET_GIT_REVISION() "%s"\n' % revision |
| if os.path.isfile(out_file): |
| with open(out_file) as f: |
| if old_contents == new_contents: |
| with open(out_file, 'w') as f: |
| if __name__ == '__main__': |