OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """ | 6 """ |
7 Creates a library loader (a header and implementation file), | 7 Creates a library loader (a header and implementation file), |
8 which is a wrapper for dlopen or direct linking with given library. | 8 which is a wrapper for dlopen or direct linking with given library. |
9 | 9 |
10 The loader makes it possible to have the same client code for both cases, | 10 The loader makes it possible to have the same client code for both cases, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 // Put these sanity checks here so that they fire at most once | 76 // Put these sanity checks here so that they fire at most once |
77 // (to avoid cluttering the build output). | 77 // (to avoid cluttering the build output). |
78 #if !defined(%(unique_prefix)s_DLOPEN) && !defined(%(unique_prefix)s_DT_NEEDED) | 78 #if !defined(%(unique_prefix)s_DLOPEN) && !defined(%(unique_prefix)s_DT_NEEDED) |
79 #error neither %(unique_prefix)s_DLOPEN nor %(unique_prefix)s_DT_NEEDED defined | 79 #error neither %(unique_prefix)s_DLOPEN nor %(unique_prefix)s_DT_NEEDED defined |
80 #endif | 80 #endif |
81 #if defined(%(unique_prefix)s_DLOPEN) && defined(%(unique_prefix)s_DT_NEEDED) | 81 #if defined(%(unique_prefix)s_DLOPEN) && defined(%(unique_prefix)s_DT_NEEDED) |
82 #error both %(unique_prefix)s_DLOPEN and %(unique_prefix)s_DT_NEEDED defined | 82 #error both %(unique_prefix)s_DLOPEN and %(unique_prefix)s_DT_NEEDED defined |
83 #endif | 83 #endif |
84 | 84 |
85 #include "base/file_path.h" | 85 #include "base/files/file_path.h" |
86 #include "base/logging.h" | 86 #include "base/logging.h" |
87 | 87 |
88 %(class_name)s::%(class_name)s() : loaded_(false) { | 88 %(class_name)s::%(class_name)s() : loaded_(false) { |
89 } | 89 } |
90 | 90 |
91 %(class_name)s::~%(class_name)s() { | 91 %(class_name)s::~%(class_name)s() { |
92 CleanUp(loaded_); | 92 CleanUp(loaded_); |
93 } | 93 } |
94 | 94 |
95 bool %(class_name)s::Load(const std::string& library_name) { | 95 bool %(class_name)s::Load(const std::string& library_name) { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 impl_file = open(os.path.join(source_tree_root, options.output_cc), 'w') | 247 impl_file = open(os.path.join(source_tree_root, options.output_cc), 'w') |
248 try: | 248 try: |
249 impl_file.write(impl_contents) | 249 impl_file.write(impl_contents) |
250 finally: | 250 finally: |
251 impl_file.close() | 251 impl_file.close() |
252 | 252 |
253 return 0 | 253 return 0 |
254 | 254 |
255 if __name__ == '__main__': | 255 if __name__ == '__main__': |
256 sys.exit(main()) | 256 sys.exit(main()) |
OLD | NEW |