Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: third_party/libadblockplus/prepare_dependencies.py

Issue 29674555: Issue 6273 - Apply eyeo python code style (Closed)
Patch Set: Addressed Vasily's comments Created Jan. 22, 2018, 7:11 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/libadblockplus/prepare_dependencies.py
diff --git a/third_party/libadblockplus/prepare_dependencies.py b/third_party/libadblockplus/prepare_dependencies.py
index 9676c2a238b3677395c725fceae5c729d83e2228..0266490d59a45768e44baaa8f99913367884be16 100644
--- a/third_party/libadblockplus/prepare_dependencies.py
+++ b/third_party/libadblockplus/prepare_dependencies.py
@@ -1,111 +1,90 @@
+from __future__ import print_function
+
import sys
import os
import shutil
+
def duplicate(src, dst, symlink=False):
sergei 2018/01/22 10:08:59 It seems that symlink parameter is not passed, sho
sergei 2018/01/22 10:10:32 BTW, what about moving this function into common f
anton 2018/01/22 10:18:41 Since it's not used anywhere else (and will not be
anton 2018/01/22 10:18:41 Vasily noted it too. Please ready my answer https:
sergei 2018/01/22 12:04:02 Acknowledged, maybe it makes sense.
- if (os.path.exists(dst)):
- if (os.path.isdir(dst)):
- print('Deleting %s' % dst)
- shutil.rmtree(dst);
+ if os.path.exists(dst):
+ if os.path.isdir(dst):
+ print('Deleting {}'.format(dst))
+ shutil.rmtree(dst)
+ else:
+ # symlink
+ os.unlink(dst)
sergei 2018/01/22 12:04:02 Actually, according to the documentation "This fol
+
+ dst_parent = os.path.abspath(os.path.join(dst, os.pardir))
+ if not os.path.exists(dst_parent):
+ print('Creating parent directory {} for {}'.format(dst_parent, dst))
+ os.makedirs(dst_parent)
+
+ if symlink:
+ print('Symlinking {} to {}'.format(src, dst))
+ os.symlink(src, dst)
else:
- # symlink
- os.unlink(dst)
-
- dst_parent = os.path.abspath(os.path.join(dst, os.pardir))
- if not os.path.exists(dst_parent):
- print('Creating parent directory %s for %s' % (dst_parent, dst))
- os.makedirs(dst_parent)
-
- if symlink:
- print('Symlinking %s to %s' % (src, dst))
- os.symlink(src, dst)
- else:
- print('Copying %s to %s' % (src, dst))
- shutil.copytree(src, dst)
+ print('Copying {} to {}'.format(src, dst))
+ shutil.copytree(src, dst)
+
def prepare_deps():
- cwd = os.getcwd()
- libadblockplus_root = os.path.join(cwd, 'src', 'third_party', 'libadblockplus', 'third_party')
-
- # googletest
- # Chromium's googletest has a bit different directories structure ('src' as subdirectory)
- #googletest_src = os.path.join(cwd, 'src', 'third_party', 'googletest')
- #googletest_dst = os.path.join(libadblockplus_root, 'googletest')
- #duplicate(googletest_src, googletest_dst)
-
- # gyp
- # Chromium's gyp can't be used because of compile error:
- # *** No rule to make target `shell/src/Main.cpp', needed by `local/armeabi-v7a/objs/abpshell/shell/src/Main.o'. Stop.
- # See. https://hg.adblockplus.org/gyp/rev/fix-issue-339
- #gyp_src = os.path.join(cwd, 'src', 'tools', 'gyp')
- #gyp_dst = os.path.join(libadblockplus_root, 'gyp')
- #duplicate(gyp_src, gyp_dst)
-
- # back-up /v8/testing/gtest as it will be deleted while preparing v8
- gtest_bak_src = os.path.join(libadblockplus_root, 'v8', 'testing', 'gtest')
- gtest_bak_dst = os.path.join(libadblockplus_root, 'gtest.bak')
- shutil.move(gtest_bak_src, gtest_bak_dst)
-
- # v8
- v8_src = os.path.join(cwd, 'src', 'v8')
- v8_dst = os.path.join(libadblockplus_root, 'v8')
- duplicate(v8_src, v8_dst)
-
- # restore /v8/testing/gtest from backup
- shutil.move(gtest_bak_dst, gtest_bak_src)
-
- # v8/base/trace_event/common
- trace_common_src = os.path.join(cwd, 'src', 'base', 'trace_event', 'common')
- trace_common_dst = os.path.join(libadblockplus_root, 'v8', 'base', 'trace_event', 'common')
- duplicate(trace_common_src, trace_common_dst)
-
- # v8/build
- build_src = os.path.join(cwd, 'src', 'build')
- build_dst = os.path.join(libadblockplus_root, 'v8', 'build')
- duplicate(build_src, build_dst)
-
- # v8/testing/gtest
- # Chromium's gtest can't be used becuase of compile error:
- # fatal error: third_party/googletest/src/googletest/include/gtest/gtest_prod.h: No such file or directory
- # #include "third_party/googletest/src/googletest/include/gtest/gtest_prod.h"
- # so we have to back-up gtest above and restore it after prepring of 'v8' directory
- #gtest_src = os.path.join(cwd, 'src', 'testing', 'gtest')
- #gtest_dst = os.path.join(libadblockplus_root, 'v8', 'testing', 'gtest')
- #duplicate(gtest_src, gtest_dst)
-
- # v8/tools/gyp
- tools_gyp_src = os.path.join(cwd, 'src', 'tools', 'gyp')
- tools_gyp_dst = os.path.join(libadblockplus_root, 'v8', 'tools', 'gyp')
- duplicate(tools_gyp_src, tools_gyp_dst)
-
- # v8/tools/clang
- clang_src = os.path.join(cwd, 'src', 'tools', 'clang')
- clang_dst = os.path.join(libadblockplus_root, 'v8', 'tools', 'clang')
- duplicate(clang_src, clang_dst)
-
- # v8/third_party/icu
- icu_src = os.path.join(cwd, 'src', 'third_party', 'icu')
- icu_dst = os.path.join(libadblockplus_root, 'v8', 'third_party', 'icu')
- duplicate(icu_src, icu_dst)
-
- # v8/third_party/jinja2
- jinja2_src = os.path.join(cwd, 'src', 'third_party', 'jinja2')
- jinja2_dst = os.path.join(libadblockplus_root, 'v8', 'third_party', 'jinja2')
- duplicate(jinja2_src, jinja2_dst)
-
- # v8/third_party/markupsafe
- markupsafe_src = os.path.join(cwd, 'src', 'third_party', 'markupsafe')
- markupsafe_dst = os.path.join(libadblockplus_root, 'v8', 'third_party', 'markupsafe')
- duplicate(markupsafe_src, markupsafe_dst)
-
- return 0
-
-def main(argv):
- return prepare_deps();
-
-if '__main__' == __name__:
- try:
- sys.exit(main(sys.argv[1:]))
- except KeyboardInterrupt:
- sys.stderr.write('interrupted\n')
- sys.exit(1)
+ cwd = os.getcwd()
+ libadblockplus_third_party = os.path.join(cwd,
+ 'src', 'third_party',
+ 'libadblockplus', 'third_party')
+
+ # googletest
+ #
+ # Chromium's googletest has a bit different directories structure
+ # ('src' as subdirectory)
+
+ # gyp
+ #
+ # Chromium's gyp can't be used because of compile error:
+ # *** No rule to make target `shell/src/Main.cpp',
+ # needed by `local/armeabi-v7a/objs/abpshell/shell/src/Main.o'. Stop.
+ # See. https://hg.adblockplus.org/gyp/rev/fix-issue-339
+
+ # back-up /v8/testing/gtest as it will be deleted while preparing v8
+ gtest_bak_src = os.path.join(libadblockplus_third_party,
+ 'v8', 'testing', 'gtest')
+ gtest_bak_dst = os.path.join(libadblockplus_third_party, 'gtest.bak')
+ shutil.move(gtest_bak_src, gtest_bak_dst)
+
+ # v8
+ v8_src = os.path.join(cwd, 'src', 'v8')
+ v8_dst = os.path.join(libadblockplus_third_party, 'v8')
+ duplicate(v8_src, v8_dst)
+
+ # restore /v8/testing/gtest from backup
+ shutil.move(gtest_bak_dst, gtest_bak_src)
+
+ # v8/testing/gtest
sergei 2018/01/22 10:08:59 I thought that v8/testing/gtest is not used in lib
anton 2018/01/22 10:18:41 then why it's listed in dependencies https://githu
+ #
+ # Chromium's gtest can't be used becuase of compile error:
+ # fatal error: third_party/googletest/src/googletest/include/gtest/gtest_prod.h: No such file or directory
+ # #include "third_party/googletest/src/googletest/include/gtest/gtest_prod.h"
+ # so we have to back-up gtest above and restore it
+ # after prepring of 'v8' directory
+
+ for path in [
sergei 2018/01/22 10:08:59 Will it stop working if we remove this for loop? A
anton 2018/01/22 10:18:41 They are copied not from v8_src but from different
sergei 2018/01/22 12:04:02 Acknowledged. I think the comments should be diffe
sergei 2018/01/24 17:23:40 No objections, could you please file an issue for
+ ('base', 'trace_event', 'common'),
+ ('build',),
+ ('tools', 'gyp'),
+ ('tools', 'clang'),
+ ('third_party', 'icu'),
+ ('third_party' , 'jinja2'),
+ ('third_party', 'markupsafe')
+ ]:
+ src = os.path.join(cwd, 'src', *path)
+ dst = os.path.join(libadblockplus_third_party, 'v8', *path)
+ duplicate(src, dst)
+
+ return 0
+
+
+if __name__ == '__main__':
+ try:
+ sys.exit(prepare_deps())
Vasily Kuznetsov 2018/01/29 12:39:12 As I wrote before, you don't really need `sys.exit
anton 2018/01/29 12:52:53 Acknowledged. See patch set #3 (thought i've left
+ except KeyboardInterrupt:
+ sys.exit('interrupted')
« no previous file with comments | « third_party/libadblockplus/download_ndk.py ('k') | third_party/libadblockplus_android/prepare_build_tools.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld