forked from facebook/redex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync.py
executable file
·131 lines (122 loc) · 4.88 KB
/
sync.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# This script will copy all the resource parsing files from AOSP to redex
# so that we can easily stay up-to-date if these files change in AOSP.
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import os
import shutil
import sys
# These are files that have been re-implemented rather than copied from
# AOSP for simplicity
FB_REIMPLEMENTED = set([
'./cutils/atomic.h', # ./system/core/include/cutils/atomic.h
'./cutils/log.h', # ./system/core/include/log/log.h (cutils is alias)
'./utils/Atomic.h', # ./system/core/include/utils/Atomic.h
'./utils/Log.h', # ./system/core/include/utils/Log.h
])
# list of (local_path : aosp_path) tuples
FILES = [
('./FileMap.cpp',
'./system/core/libutils/FileMap.cpp'),
('./ResourceTypes.cpp',
'./frameworks/base/libs/androidfw/ResourceTypes.cpp'),
('./SharedBuffer.cpp',
'./system/core/libutils/SharedBuffer.cpp'),
('./Static.cpp',
'./system/core/libutils/Static.cpp'),
('./String16.cpp',
'./system/core/libutils/String16.cpp'),
('./String8.cpp',
'./system/core/libutils/String8.cpp'),
('./TypeWrappers.cpp',
'./frameworks/base/libs/androidfw/TypeWrappers.cpp'),
('./Unicode.cpp',
'./system/core/libutils/Unicode.cpp'),
('./VectorImpl.cpp',
'./system/core/libutils/VectorImpl.cpp'),
('./android/asset_manager.h',
'./frameworks/native/include/android/asset_manager.h'),
('./android/configuration.h',
'./frameworks/native/include/android/configuration.h'),
('./androidfw/Asset.h',
'./frameworks/base/include/androidfw/Asset.h'),
('./androidfw/ByteBucketArray.h',
'./frameworks/base/include/androidfw/ByteBucketArray.h'),
('./androidfw/ResourceTypes.h',
'./frameworks/base/include/androidfw/ResourceTypes.h'),
('./androidfw/TypeWrappers.h',
'./frameworks/base/include/androidfw/TypeWrappers.h'),
('./system/graphics.h',
'./system/core/include/system/graphics.h'),
('./system/thread_defs.h',
'./system/core/include/system/thread_defs.h'),
('./utils/AndroidThreads.h',
'./system/core/include/utils/AndroidThreads.h'),
('./utils/ByteOrder.h',
'./system/core/include/utils/ByteOrder.h'),
('./utils/Compat.h',
'./system/core/include/utils/Compat.h'),
('./utils/Condition.h',
'./system/core/include/utils/Condition.h'),
('./utils/Debug.h',
'./system/core/include/utils/Debug.h'),
('./utils/Errors.h',
'./system/core/include/utils/Errors.h'),
('./utils/FileMap.h',
'./system/core/include/utils/FileMap.h'),
('./utils/KeyedVector.h',
'./system/core/include/utils/KeyedVector.h'),
('./utils/Mutex.h',
'./system/core/include/utils/Mutex.h'),
('./utils/RefBase.h',
'./system/core/include/utils/RefBase.h'),
('./utils/RWLock.h',
'./system/core/include/utils/RWLock.h'),
('./utils/SharedBuffer.h',
'./system/core/include/utils/SharedBuffer.h'),
('./utils/SortedVector.h',
'./system/core/include/utils/SortedVector.h'),
('./utils/String16.h',
'./system/core/include/utils/String16.h'),
('./utils/String8.h',
'./system/core/include/utils/String8.h'),
('./utils/StrongPointer.h',
'./system/core/include/utils/StrongPointer.h'),
('./utils/Thread.h',
'./system/core/include/utils/Thread.h'),
('./utils/ThreadDefs.h',
'./system/core/include/utils/ThreadDefs.h'),
('./utils/threads.h',
'./system/core/include/utils/threads.h'),
('./utils/Timers.h',
'./system/core/include/utils/Timers.h'),
('./utils/TypeHelpers.h',
'./system/core/include/utils/TypeHelpers.h'),
('./utils/Unicode.h',
'./system/core/include/utils/Unicode.h'),
('./utils/Vector.h',
'./system/core/include/utils/Vector.h'),
('./utils/VectorImpl.h',
'./system/core/include/utils/VectorImpl.h')
]
if __name__ == '__main__':
if len(sys.argv) != 2:
sys.exit('Usage: sync.py <aosp_root_dir>')
aosp_root = sys.argv[-1]
# Folder containing the script
redex_root = os.path.dirname(os.path.realpath(__file__))
for local_path, aosp_path in FILES:
if local_path in FB_REIMPLEMENTED:
sys.exit('Refusing to overwrite our {} with AOSP version'.format(
local_path))
aosp_abs_path = os.path.join(aosp_root, aosp_path)
if not os.path.isfile(aosp_abs_path):
sys.exit(aosp_abs_path + ' not found, aborting.')
local_abs_path = os.path.join(redex_root, local_path)
print(aosp_path + ' -> ' + local_path, end='')
dirname = os.path.dirname(local_abs_path)
if not os.path.isdir(dirname):
os.mkdir(dirname)
shutil.copy(aosp_abs_path, dirname)
print(' [done]')