兵法云,知己知彼,百战不殆。对于使用开源项目的开发者而言,在掌握这些开源项目之前,它们就是作战的敌人。对于一个开源项目,可以从多个角度来认识它,如开源项目的整体设计框架,开源项目实现所基于的基本原理,开源项目所使用的编程语言及编程语言的版本,开源项目所使用的重要的它库及库的用法等。
但关于开源项目最最基本的一项信息即是它的代码规模,代码规模常常与它的复杂度紧密相关。了解了一个开源项目的规模,常常可以使我们在学习掌握它时,心中更加有底。
Anbox 是 Android 虚拟化的一项非常有价值的技术,它基于由 LXC 创建的容器及模拟器客户 Android 系统的一些关键技术构建。LXC 为 Anbox 中的 Android 容器提供支持。Anbox 和 LXC 的代码规模如下。
Anbox 核心源码:
anbox/src/anbox/android/intent.cpp : 53
anbox/src/anbox/android/intent.h : 42
anbox/src/anbox/android/ip_config_builder.cpp : 114
anbox/src/anbox/android/ip_config_builder.h : 66
anbox/src/anbox/application/database.cpp : 58
anbox/src/anbox/application/database.h : 58
anbox/src/anbox/application/launcher_storage.cpp : 118
anbox/src/anbox/application/launcher_storage.h : 50
anbox/src/anbox/application/manager.h : 71
anbox/src/anbox/audio/client_info.h : 36
anbox/src/anbox/audio/server.cpp : 109
anbox/src/anbox/audio/server.h : 56
anbox/src/anbox/audio/sink.h : 35
anbox/src/anbox/audio/source.h : 36
anbox/src/anbox/bridge/android_api_stub.cpp : 223
anbox/src/anbox/bridge/android_api_stub.h : 84
anbox/src/anbox/bridge/platform_api_skeleton.cpp : 144
anbox/src/anbox/bridge/platform_api_skeleton.h : 90
anbox/src/anbox/bridge/platform_message_processor.cpp : 61
anbox/src/anbox/bridge/platform_message_processor.h : 43
anbox/src/anbox/build/config.h : 37
anbox/src/anbox/cli.cpp : 249
anbox/src/anbox/cli.h : 386
anbox/src/anbox/cmds/container_manager.cpp : 220
anbox/src/anbox/cmds/container_manager.h : 50
anbox/src/anbox/cmds/install.cpp : 51
anbox/src/anbox/cmds/install.h : 39
anbox/src/anbox/cmds/launch.cpp : 247
anbox/src/anbox/cmds/launch.h : 46
anbox/src/anbox/cmds/session_manager.cpp : 288
anbox/src/anbox/cmds/session_manager.h : 59
anbox/src/anbox/cmds/system_info.cpp : 213
anbox/src/anbox/cmds/system_info.h : 36
anbox/src/anbox/cmds/version.cpp : 32
anbox/src/anbox/cmds/version.h : 38
anbox/src/anbox/common/binary_writer.cpp : 105
anbox/src/anbox/common/binary_writer.h : 57
anbox/src/anbox/common/dispatcher.cpp : 40
anbox/src/anbox/common/dispatcher.h : 44
anbox/src/anbox/common/fd.cpp : 47
anbox/src/anbox/common/fd.h : 50
anbox/src/anbox/common/fd_sets.h : 31
anbox/src/anbox/common/loop_device_allocator.cpp : 55
anbox/src/anbox/common/loop_device_allocator.h : 33
anbox/src/anbox/common/loop_device.cpp : 65
anbox/src/anbox/common/loop_device.h : 46
anbox/src/anbox/common/message_channel.cpp : 64
anbox/src/anbox/common/message_channel.h : 99
anbox/src/anbox/common/mount_entry.cpp : 74
anbox/src/anbox/common/mount_entry.h : 48
anbox/src/anbox/common/scope_ptr.h : 99
anbox/src/anbox/common/small_vector.h : 376
anbox/src/anbox/common/type_traits.h : 124
anbox/src/anbox/common/variable_length_array.h : 58
anbox/src/anbox/common/wait_handle.cpp : 79
anbox/src/anbox/common/wait_handle.h : 53
anbox/src/anbox/container/client.cpp : 83
anbox/src/anbox/container/client.h : 63
anbox/src/anbox/container/configuration.h : 32
anbox/src/anbox/container/container.cpp : 24
anbox/src/anbox/container/container.h : 49
anbox/src/anbox/container/lxc_container.cpp : 300
anbox/src/anbox/container/lxc_container.h : 52
anbox/src/anbox/container/management_api_message_processor.cpp : 45
anbox/src/anbox/container/management_api_message_processor.h : 43
anbox/src/anbox/container/management_api_skeleton.cpp : 85
anbox/src/anbox/container/management_api_skeleton.h : 66
anbox/src/anbox/container/management_api_stub.cpp : 88
anbox/src/anbox/container/management_api_stub.h : 63
anbox/src/anbox/container/service.cpp : 93
anbox/src/anbox/container/service.h : 54
anbox/src/anbox/daemon.cpp : 62
anbox/src/anbox/daemon.h : 39
anbox/src/anbox/dbus/codecs.h : 47
anbox/src/anbox/dbus/interface.h : 68
anbox/src/anbox/dbus/skeleton/application_manager.cpp : 106
anbox/src/anbox/dbus/skeleton/application_manager.h : 66
anbox/src/anbox/dbus/skeleton/service.cpp : 45
anbox/src/anbox/dbus/skeleton/service.h : 54
anbox/src/anbox/dbus/stub/application_manager.cpp : 63
anbox/src/anbox/dbus/stub/application_manager.h : 61
anbox/src/anbox/defer_action.h : 41
anbox/src/anbox/do_not_copy_or_move.h : 36
anbox/src/anbox/graphics/buffered_io_stream.cpp : 137
anbox/src/anbox/graphics/buffered_io_stream.h : 65
anbox/src/anbox/graphics/buffer_queue.cpp : 104
anbox/src/anbox/graphics/buffer_queue.h : 58
anbox/src/anbox/graphics/density.h : 41
anbox/src/anbox/graphics/emugl/ColorBuffer.cpp : 342
anbox/src/anbox/graphics/emugl/ColorBuffer.h : 139
anbox/src/anbox/graphics/emugl/DispatchTables.h : 22
anbox/src/anbox/graphics/emugl/DisplayManager.cpp : 38
anbox/src/anbox/graphics/emugl/DisplayManager.h : 46
anbox/src/anbox/graphics/emugl/ReadBuffer.cpp : 69
anbox/src/anbox/graphics/emugl/ReadBuffer.h : 38
anbox/src/anbox/graphics/emugl/Renderable.cpp : 55
anbox/src/anbox/graphics/emugl/Renderable.h : 69
anbox/src/anbox/graphics/emugl/RenderApi.cpp : 85
anbox/src/anbox/graphics/emugl/RenderApi.h : 47
anbox/src/anbox/graphics/emugl/RenderContext.cpp : 41
anbox/src/anbox/graphics/emugl/RenderContext.h : 67
anbox/src/anbox/graphics/emugl/RenderControl.cpp : 456
anbox/src/anbox/graphics/emugl/RenderControl.h : 38
anbox/src/anbox/graphics/emugl/RendererConfig.cpp : 238
anbox/src/anbox/graphics/emugl/RendererConfig.h : 162
anbox/src/anbox/graphics/emugl/Renderer.cpp : 964
anbox/src/anbox/graphics/emugl/Renderer.h : 313
anbox/src/anbox/graphics/emugl/RenderThread.cpp : 98
anbox/src/anbox/graphics/emugl/RenderThread.h : 64
anbox/src/anbox/graphics/emugl/RenderThreadInfo.cpp : 40
anbox/src/anbox/graphics/emugl/RenderThreadInfo.h : 64
anbox/src/anbox/graphics/emugl/TextureDraw.cpp : 229
anbox/src/anbox/graphics/emugl/TextureDraw.h : 55
anbox/src/anbox/graphics/emugl/TextureResize.cpp : 355
anbox/src/anbox/graphics/emugl/TextureResize.h : 52
anbox/src/anbox/graphics/emugl/TimeUtils.cpp : 31
anbox/src/anbox/graphics/emugl/TimeUtils.h : 23
anbox/src/anbox/graphics/emugl/WindowSurface.cpp : 171
anbox/src/anbox/graphics/emugl/WindowSurface.h : 97
anbox/src/anbox/graphics/gl_extensions.h : 52
anbox/src/anbox/graphics/gl_renderer_server.cpp : 104
anbox/src/anbox/graphics/gl_renderer_server.h : 57
anbox/src/anbox/graphics/layer_composer.cpp : 39
anbox/src/anbox/graphics/layer_composer.h : 55
anbox/src/anbox/graphics/multi_window_composer_strategy.cpp : 86
anbox/src/anbox/graphics/multi_window_composer_strategy.h : 40
anbox/src/anbox/graphics/opengles_message_processor.cpp : 65
anbox/src/anbox/graphics/opengles_message_processor.h : 56
anbox/src/anbox/graphics/primitives.h : 47
anbox/src/anbox/graphics/program_family.cpp : 93
anbox/src/anbox/graphics/program_family.h : 65
anbox/src/anbox/graphics/rect.cpp : 87
anbox/src/anbox/graphics/rect.h : 82
anbox/src/anbox/graphics/renderer.h : 38
anbox/src/anbox/graphics/single_window_composer_strategy.cpp : 50
anbox/src/anbox/graphics/single_window_composer_strategy.h : 40
anbox/src/anbox/input/device.cpp : 168
anbox/src/anbox/input/device.h : 103
anbox/src/anbox/input/manager.cpp : 52
anbox/src/anbox/input/manager.h : 45
anbox/src/anbox/logger.cpp : 208
anbox/src/anbox/logger.h : 150
anbox/src/anbox/network/base_socket_messenger.cpp : 157
anbox/src/anbox/network/base_socket_messenger.h : 65
anbox/src/anbox/network/connection_context.cpp : 28
anbox/src/anbox/network/connection_context.h : 46
anbox/src/anbox/network/connection_creator.cpp : 16
anbox/src/anbox/network/connection_creator.h : 37
anbox/src/anbox/network/connections.h : 68
anbox/src/anbox/network/connector.h : 29
anbox/src/anbox/network/credentials.cpp : 31
anbox/src/anbox/network/credentials.h : 43
anbox/src/anbox/network/delegate_connection_creator.h : 54
anbox/src/anbox/network/delegate_message_processor.cpp : 35
anbox/src/anbox/network/delegate_message_processor.h : 41
anbox/src/anbox/network/fd_socket_transmission.cpp : 181
anbox/src/anbox/network/fd_socket_transmission.h : 47
anbox/src/anbox/network/local_socket_messenger.cpp : 48
anbox/src/anbox/network/local_socket_messenger.h : 44
anbox/src/anbox/network/message_processor.h : 34
anbox/src/anbox/network/message_receiver.h : 52
anbox/src/anbox/network/message_sender.h : 41
anbox/src/anbox/network/published_socket_connector.cpp : 58
anbox/src/anbox/network/published_socket_connector.h : 56
anbox/src/anbox/network/socket_connection.cpp : 75
anbox/src/anbox/network/socket_connection.h : 65
anbox/src/anbox/network/socket_helper.cpp : 76
anbox/src/anbox/network/socket_helper.h : 31
anbox/src/anbox/network/socket_messenger.cpp : 0
anbox/src/anbox/network/socket_messenger.h : 40
anbox/src/anbox/network/stream_socket_transport.cpp : 68
anbox/src/anbox/network/stream_socket_transport.h : 65
anbox/src/anbox/network/tcp_socket_connector.cpp : 65
anbox/src/anbox/network/tcp_socket_connector.h : 57
anbox/src/anbox/network/tcp_socket_messenger.cpp : 40
anbox/src/anbox/network/tcp_socket_messenger.h : 44
anbox/src/anbox/not_reachable.cpp : 35
anbox/src/anbox/not_reachable.h : 42
anbox/src/anbox/optional.h : 31
anbox/src/anbox/platform/base_platform.cpp : 40
anbox/src/anbox/platform/base_platform.h : 69
anbox/src/anbox/platform/null/platform.cpp : 75
anbox/src/anbox/platform/null/platform.h : 43
anbox/src/anbox/platform/sdl/audio_sink.cpp : 119
anbox/src/anbox/platform/sdl/audio_sink.h : 55
anbox/src/anbox/platform/sdl/keycode_converter.cpp : 295
anbox/src/anbox/platform/sdl/keycode_converter.h : 41
anbox/src/anbox/platform/sdl/mir_display_connection.cpp : 123
anbox/src/anbox/platform/sdl/mir_display_connection.h : 52
anbox/src/anbox/platform/sdl/platform.cpp : 321
anbox/src/anbox/platform/sdl/platform.h : 97
anbox/src/anbox/platform/sdl/sdl_wrapper.h : 29
anbox/src/anbox/platform/sdl/window.cpp : 130
anbox/src/anbox/platform/sdl/window.h : 75
anbox/src/anbox/protobuf/google_protobuf_guard.cpp : 38
anbox/src/anbox/qemu/adb_message_processor.cpp : 210
anbox/src/anbox/qemu/adb_message_processor.h : 77
anbox/src/anbox/qemu/at_parser.cpp : 76
anbox/src/anbox/qemu/at_parser.h : 49
anbox/src/anbox/qemu/bootanimation_message_processor.cpp : 48
anbox/src/anbox/qemu/bootanimation_message_processor.h : 43
anbox/src/anbox/qemu/boot_properties_message_processor.cpp : 52
anbox/src/anbox/qemu/boot_properties_message_processor.h : 40
anbox/src/anbox/qemu/camera_message_processor.cpp : 64
anbox/src/anbox/qemu/camera_message_processor.h : 46
anbox/src/anbox/qemu/fingerprint_message_processor.cpp : 41
anbox/src/anbox/qemu/fingerprint_message_processor.h : 40
anbox/src/anbox/qemu/gsm_message_processor.cpp : 112
anbox/src/anbox/qemu/gsm_message_processor.h : 60
anbox/src/anbox/qemu/hwcontrol_message_processor.cpp : 44
anbox/src/anbox/qemu/hwcontrol_message_processor.h : 37
anbox/src/anbox/qemu/null_message_processor.cpp : 35
anbox/src/anbox/qemu/null_message_processor.h : 35
anbox/src/anbox/qemu/pipe_connection_creator.cpp : 167
anbox/src/anbox/qemu/pipe_connection_creator.h : 76
anbox/src/anbox/qemu/qemud_message_processor.cpp : 82
anbox/src/anbox/qemu/qemud_message_processor.h : 50
anbox/src/anbox/qemu/sensors_message_processor.cpp : 43
anbox/src/anbox/qemu/sensors_message_processor.h : 40
anbox/src/anbox/qemu/telephony_manager.cpp : 40
anbox/src/anbox/qemu/telephony_manager.h : 40
anbox/src/anbox/rpc/channel.cpp : 103
anbox/src/anbox/rpc/channel.h : 72
anbox/src/anbox/rpc/connection_creator.cpp : 64
anbox/src/anbox/rpc/connection_creator.h : 61
anbox/src/anbox/rpc/constants.h : 33
anbox/src/anbox/rpc/make_protobuf_object.h : 40
anbox/src/anbox/rpc/message_processor.cpp : 119
anbox/src/anbox/rpc/message_processor.h : 72
anbox/src/anbox/rpc/pending_call_cache.cpp : 72
anbox/src/anbox/rpc/pending_call_cache.h : 74
anbox/src/anbox/rpc/template_message_processor.h : 72
anbox/src/anbox/runtime.cpp : 90
anbox/src/anbox/runtime.h : 77
anbox/src/anbox/system_configuration.cpp : 101
anbox/src/anbox/system_configuration.h : 53
anbox/src/anbox/ui/splash_screen.cpp : 97
anbox/src/anbox/ui/splash_screen.h : 42
anbox/src/anbox/utils.cpp : 210
anbox/src/anbox/utils/environment_file.cpp : 43
anbox/src/anbox/utils/environment_file.h : 40
anbox/src/anbox/utils.h : 84
anbox/src/anbox/wm/display.cpp : 25
anbox/src/anbox/wm/display.h : 38
anbox/src/anbox/wm/manager.cpp : 24
anbox/src/anbox/wm/manager.h : 49
anbox/src/anbox/wm/multi_window_manager.cpp : 128
anbox/src/anbox/wm/multi_window_manager.h : 64
anbox/src/anbox/wm/single_window_manager.cpp : 79
anbox/src/anbox/wm/single_window_manager.h : 63
anbox/src/anbox/wm/stack.cpp : 51
anbox/src/anbox/wm/stack.h : 45
anbox/src/anbox/wm/task.cpp : 24
anbox/src/anbox/wm/task.h : 37
anbox/src/anbox/wm/window.cpp : 62
anbox/src/anbox/wm/window.h : 72
anbox/src/anbox/wm/window_state.cpp : 43
anbox/src/anbox/wm/window_state.h : 59
anbox/src/main.cpp : 24
total line num = 21408
LXC 核心源码:
lxc/src/config.h : 245
lxc/src/include/getline.c : 60
lxc/src/include/getline.h : 37
lxc/src/include/getsubopt.c : 89
lxc/src/include/getsubopt.h : 4
lxc/src/include/ifaddrs.c : 599
lxc/src/include/ifaddrs.h : 54
lxc/src/include/lxcmntent.c : 193
lxc/src/include/lxcmntent.h : 51
lxc/src/include/openpty.c : 76
lxc/src/include/openpty.h : 37
lxc/src/lua-lxc/core.c : 614
lxc/src/lxc/af_unix.c : 273
lxc/src/lxc/af_unix.h : 35
lxc/src/lxc/arguments.c : 272
lxc/src/lxc/arguments.h : 167
lxc/src/lxc/attach.c : 1328
lxc/src/lxc/attach.h : 41
lxc/src/lxc/attach_options.h : 179
lxc/src/lxc/bdev/bdev.c : 988
lxc/src/lxc/bdev/bdev.h : 151
lxc/src/lxc/bdev/lxcaufs.c : 420
lxc/src/lxc/bdev/lxcaufs.h : 73
lxc/src/lxc/bdev/lxcbtrfs.c : 750
lxc/src/lxc/bdev/lxcbtrfs.h : 416
lxc/src/lxc/bdev/lxcdir.c : 134
lxc/src/lxc/bdev/lxcdir.h : 52
lxc/src/lxc/bdev/lxcloop.c : 328
lxc/src/lxc/bdev/lxcloop.h : 52
lxc/src/lxc/bdev/lxclvm.c : 435
lxc/src/lxc/bdev/lxclvm.h : 56
lxc/src/lxc/bdev/lxcnbd.c : 311
lxc/src/lxc/bdev/lxcnbd.h : 58
lxc/src/lxc/bdev/lxcoverlay.c : 767
lxc/src/lxc/bdev/lxcoverlay.h : 93
lxc/src/lxc/bdev/lxcrbd.c : 181
lxc/src/lxc/bdev/lxcrbd.h : 52
lxc/src/lxc/bdev/lxcrsync.c : 142
lxc/src/lxc/bdev/lxcrsync.h : 46
lxc/src/lxc/bdev/lxczfs.c : 300
lxc/src/lxc/bdev/lxczfs.h : 61
lxc/src/lxc/caps.c : 235
lxc/src/lxc/caps.h : 89
lxc/src/lxc/cgroups/cgfs.c : 2708
lxc/src/lxc/cgroups/cgfsng.c : 1990
lxc/src/lxc/cgroups/cgmanager.c : 1676
lxc/src/lxc/cgroups/cgroup.c : 248
lxc/src/lxc/cgroups/cgroup.h : 87
lxc/src/lxc/commands.c : 1021
lxc/src/lxc/commands.h : 97
lxc/src/lxc/conf.c : 4658
lxc/src/lxc/conf.h : 450
lxc/src/lxc/confile.c : 2968
lxc/src/lxc/confile.h : 68
lxc/src/lxc/console.c : 732
lxc/src/lxc/console.h : 218
lxc/src/lxc/criu.c : 1223
lxc/src/lxc/criu.h : 34
lxc/src/lxc/error.c : 58
lxc/src/lxc/error.h : 28
lxc/src/lxc/execute.c : 126
lxc/src/lxc/freezer.c : 87
lxc/src/lxc/genl.c : 150
lxc/src/lxc/genl.h : 121
lxc/src/lxc/initutils.c : 298
lxc/src/lxc/initutils.h : 54
lxc/src/lxc/list.h : 170
lxc/src/lxc/log.c : 581
lxc/src/lxc/log.h : 328
lxc/src/lxc/lsm/apparmor.c : 255
lxc/src/lxc/lsm/lsm.c : 98
lxc/src/lxc/lsm/lsm.h : 56
lxc/src/lxc/lsm/nop.c : 53
lxc/src/lxc/lsm/selinux.c : 115
lxc/src/lxc/lxccontainer.c : 4526
lxc/src/lxc/lxccontainer.h : 1029
lxc/src/lxc/lxc.h : 154
lxc/src/lxc/lxclock.c : 369
lxc/src/lxc/lxclock.h : 159
lxc/src/lxc/lxc_monitord.c : 440
lxc/src/lxc/lxcseccomp.h : 50
lxc/src/lxc/lxc_user_nic.c : 854
lxc/src/lxc/lxcutmp.c : 489
lxc/src/lxc/lxcutmp.h : 34
lxc/src/lxc/mainloop.c : 163
lxc/src/lxc/mainloop.h : 50
lxc/src/lxc/monitor.c : 372
lxc/src/lxc/monitor.h : 94
lxc/src/lxc/namespace.c : 131
lxc/src/lxc/namespace.h : 87
lxc/src/lxc/network.c : 1592
lxc/src/lxc/network.h : 144
lxc/src/lxc/nl.c : 323
lxc/src/lxc/nl.h : 259
lxc/src/lxc/parse.c : 104
lxc/src/lxc/parse.h : 40
lxc/src/lxc/rtnl.c : 73
lxc/src/lxc/rtnl.h : 110
lxc/src/lxc/seccomp.c : 758
lxc/src/lxc/start.c : 1518
lxc/src/lxc/start.h : 78
lxc/src/lxc/state.c : 197
lxc/src/lxc/state.h : 38
lxc/src/lxc/sync.c : 153
lxc/src/lxc/sync.h : 50
lxc/src/lxc/utils.c : 2085
lxc/src/lxc/utils.h : 334
lxc/src/lxc/version.h : 33
lxc/src/python-lxc/lxc.c : 1908
total line num = 50098
Anbox 的核心代码大概 21408 行。这个代码量实在算不上规模很大的项目,但客户 Android 系统中的设备虚拟化,以及它所使用的 boost 库,说明这个项目还是有着相当高的复杂性。
LXC 的代码量也不是很大,核心代码大概 50098 行。但 LXC 所基于的基本原理,也就是 Linux 内核的 namespace 和 control group 等,还是处处显示着这个项目的复杂度。
Done。
网友评论