forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b19d3d
commit 780e5fe
Showing
2 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Check Symbols | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["Build"] | ||
types: [completed] | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Dump GitHub context | ||
env: | ||
GITHUB_CONTEXT: ${{ toJSON(github) }} | ||
run: echo "$GITHUB_CONTEXT" | ||
|
||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v2 | ||
with: | ||
repository: flutter-tizen/tizen_allowlist | ||
token: ${{ secrets.MY_PAT }} | ||
path: tizen_allowlist | ||
- uses: TizenAPI/tizenfx-build-actions/download-workflow-artifacts@master | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
run-id: ${{ github.event.workflow_run.id }} | ||
path: artifacts | ||
- run: | | ||
ls -al artifacts | ||
ls -al tizen_allowlist | ||
ls -al ci/docker/tizen/tools/ | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/usr/bin/env python | ||
# Copyright 2021 Samsung Electronics Co., Ltd. All rights reserved. | ||
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
|
||
import os | ||
import subprocess | ||
import sys | ||
|
||
|
||
class Symbol: | ||
def __init__(self, addr, type, name): | ||
self.addr = addr | ||
self.type = type | ||
self.name = name | ||
|
||
def __str__(self): | ||
return '{} {} {}'.format(self.addr, self.type, self.name) | ||
|
||
@staticmethod | ||
def parse(line): | ||
return Symbol(line[:8].strip(), line[9], line[11:].strip()) | ||
|
||
|
||
def check_symbol(sofile, allowlist): | ||
if not os.access(sofile, os.R_OK): | ||
raise Exception('{} is not readable'.format(sofile)) | ||
if not os.access(allowlist, os.R_OK): | ||
raise Exception('{} is not readable'.format(allowlist)) | ||
|
||
try: | ||
symbols_raw = subprocess.check_output( | ||
['nm', '-gDC', sofile]).decode('utf-8').splitlines() | ||
symbols = [Symbol.parse(line) for line in symbols_raw] | ||
except subprocess.CalledProcessError as e: | ||
raise Exception('nm failed: {}'.format(e)) | ||
|
||
with open(allowlist, 'r') as f: | ||
allowlist = [line.strip() for line in f.readlines()] | ||
|
||
not_allowed = [] | ||
for symbol in symbols: | ||
if symbol.addr: | ||
continue | ||
if symbol.name.startswith('FlutterEngine'): | ||
continue | ||
if symbol.name in allowlist: | ||
continue | ||
not_allowed.append(symbol) | ||
|
||
if not_allowed: | ||
print('Symbols not allowed ({}):'.format(sofile)) | ||
for symbol in not_allowed: | ||
print(symbol) | ||
return False | ||
|
||
return True | ||
|
||
|
||
def main(): | ||
import optparse | ||
parser = optparse.OptionParser(usage='%prog [options] [sofile ..]') | ||
parser.add_option('--allowlist', dest='allowlist', | ||
help='Path to the allowlist file') | ||
(options, args) = parser.parse_args() | ||
|
||
if not options.allowlist: | ||
print('--allowlist is required') | ||
return 1 | ||
if not args: | ||
print('sofile is required') | ||
return 1 | ||
|
||
for sofile in args: | ||
if not check_symbol(sofile, options.allowlist): | ||
return 1 | ||
|
||
return 0 | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(main()) |