Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,25 @@ def clone(self, *, url: str = None, tag: str = None, out: str = None):

def sync(self, *, cfg: str = None, root: str = None):
cfg = cfg or self.gclient
src = root or self.root
src = Path(root or self.root)

shutil.copy(cfg, os.path.join(src, '.gclient'))
shutil.copy(cfg, src/'.gclient')
Comment on lines 118 to +122
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description states that no repository files were modified, but this PR includes source changes (e.g., build.py/sysroot.py), adds a new stub header, and updates engine.patch and depot_tools metadata. Please update the PR description (or split into separate PRs) so reviewers can clearly distinguish compile-verification results from functional changes.

Copilot uses AI. Check for mistakes.
cmd = ['gclient', 'sync', '-DR', '--no-history']
subprocess.run(cmd, cwd=src, check=True, stdout=True, stderr=True)
subprocess.run(cmd, cwd=str(src), check=True)

def patch(self, *, file, path):
repo = git.Repo(path)
repo.git.apply([file])

def find_ndk_root(self, toolchain: str):
path = Path(toolchain).resolve()
for root in (path, *path.parents):
if (root/'source.properties').is_file():
return root
raise ValueError(
f'failed to locate NDK root from toolchain: "{toolchain}" '
f'(searched {path} and its parents)')

def configure(
self,
arch: str,
Expand All @@ -136,9 +145,12 @@ def configure(
sysroot: str = None,
toolchain: str = None,
):
root = root or self.root
sysroot = os.path.abspath(sysroot or self.sysroot.path)
toolchain = os.path.abspath(toolchain or self.toolchain)
root = Path(root or self.root)
sysroot = Path(sysroot or self.sysroot.path).resolve()
toolchain = Path(toolchain or self.toolchain).resolve()
ndk_root = self.find_ndk_root(toolchain)
stubs = Path(__file__).parent.resolve() / 'stubs'
vulkan = ndk_root / 'sources/third_party/vulkan/include'
cmd = [
'vpython3',
'engine/src/flutter/tools/gn',
Expand All @@ -152,7 +164,7 @@ def configure(
'--no-enable-unittests',
'--no-build-embedder-examples',
'--no-prebuilt-dart-sdk',
'--target-toolchain', toolchain,
'--target-toolchain', str(toolchain),
'--runtime-mode', mode,
'--no-build-glfw-shell',
'--gn-args', 'symbol_level=0',
Expand All @@ -170,12 +182,13 @@ def configure(
'--gn-args', f'termux_api_level={api}',
'--gn-args', f'termux_enabled_archs=["{arch}"]',
'--gn-args', 'extra_ldflags=["-lEGL", "-lGLESv2"]',
'--gn-args', f'extra_cflags_cc=["-I{toolchain}/../../../sources/third_party/vulkan/include"]',
'--gn-args', f'extra_cflags=["-Wno-newline-eof", "-I{stubs}", "-I{vulkan}"]',
'--gn-args', f'extra_cflags_cc=["-Wno-newline-eof", "-I{stubs}", "-I{vulkan}"]',
]
subprocess.run(cmd, cwd=root, check=True, stdout=True, stderr=True)
subprocess.run(cmd, cwd=str(root), check=True)

def build(self, arch: str, mode: str, root: str = None, jobs: int = None):
root = root or self.root
root = Path(root or self.root)
cmd = [
'ninja', '-C', utils.target_output(root, arch, mode),
'flutter',
Expand All @@ -188,7 +201,7 @@ def build(self, arch: str, mode: str, root: str = None, jobs: int = None):
]
if jobs:
cmd.append(f'-j{jobs}')
subprocess.run(cmd, check=True, stdout=True, stderr=True)
subprocess.run(cmd, check=True)

def debuild(self, arch: str, output: str = None, root: str = None, **conf):
conf = conf or self.package
Expand Down
Binary file modified depot_tools/.cipd_client
Binary file not shown.
11 changes: 6 additions & 5 deletions depot_tools/.cipd_client_cache/tagcache.db
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@



�
infra/tools/cipd/linux-arm645git_revision:6e9be28a4c4e3a804f400dc6c2ed08b866f0a38b,P-Sa7N5op5oQeEjE7nj42X4UXkqwBm_1N7H2iFylKCsC"!chrome-infra-packages.appspot.com�
infra/tools/cipd/linux-arm64,P-Sa7N5op5oQeEjE7nj42X4UXkqwBm_1N7H2iFylKCsCcipd",aX2UAsXYzhdiTRlLHrmgXG5iH95D9AC44xAFlZaoWK0C*!chrome-infra-packages.appspot.com
�h�Z�|�7��#Leb��n���
XB���
infra/tools/cipd/linux-arm645git_revision:6e9be28a4c4e3a804f400dc6c2ed08b866f0a38b,P-Sa7N5op5oQeEjE7nj42X4UXkqwBm_1N7H2iFylKCsC"!chrome-infra-packages.appspot.com
�
infra/tools/cipd/linux-amd645git_revision:6e9be28a4c4e3a804f400dc6c2ed08b866f0a38b,k8_bNGkgtL0T5V1umBGC2uvsOZH0qkghVPg0SFqKrpQC"!chrome-infra-packages.appspot.com�
infra/tools/cipd/linux-arm64,P-Sa7N5op5oQeEjE7nj42X4UXkqwBm_1N7H2iFylKCsCcipd",aX2UAsXYzhdiTRlLHrmgXG5iH95D9AC44xAFlZaoWK0C*!chrome-infra-packages.appspot.com�
infra/tools/cipd/linux-amd64,k8_bNGkgtL0T5V1umBGC2uvsOZH0qkghVPg0SFqKrpQCcipd",I3ybbUmeCUuiDryUqLpTDfDKwVqKZg0wIKRh8556HwUC*!chrome-infra-packages.appspot.com �R�IE�M3������ITp��F;�f���M�&
Comment on lines +4 to +8
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

depot_tools/.cipd_client_cache/tagcache.db appears to be a machine-generated CIPD cache artifact. Committing it will cause frequent noisy diffs and can bloat the repo; it should typically be removed from version control and ignored (e.g., ignore depot_tools/.cipd_client_cache/).

Copilot uses AI. Check for mistakes.
2 changes: 1 addition & 1 deletion depot_tools/.versions/.cipd_client.cipd_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"package_name":"infra/tools/cipd/linux-arm64","instance_id":"P-Sa7N5op5oQeEjE7nj42X4UXkqwBm_1N7H2iFylKCsC"}
{"package_name":"infra/tools/cipd/linux-amd64","instance_id":"k8_bNGkgtL0T5V1umBGC2uvsOZH0qkghVPg0SFqKrpQC"}
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change pins depot_tools' CIPD client to the linux-amd64 package. That makes the repo’s bundled depot_tools host-architecture-specific and can break usage on linux-arm64 hosts. Consider avoiding committing this pin change (or managing CIPD client selection per-host) so depot_tools works consistently across supported environments.

Copilot uses AI. Check for mistakes.
9 changes: 8 additions & 1 deletion patches/engine.patch
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ new file mode 100644
index 0000000..8208b13
--- /dev/null
+++ b/engine/src/build/config/termux/BUILD.gn
@@ -0,0 +1,181 @@
@@ -0,0 +1,188 @@
+import("//build/config/termux/termux.gni")
+import("//build/config/sysroot.gni")
+import("//build/config/profiler.gni")
Expand All @@ -198,6 +198,9 @@ index 0000000..8208b13
+ angle_build_all = false
+ angle_enable_commit_id = false
+ angle_has_astc_encoder = false
+ extra_cflags = []
+ extra_cflags_cc = []
+ extra_ldflags = []
+}
+
+config("compiler") {
Expand All @@ -216,6 +219,9 @@ index 0000000..8208b13
+ ]
+ cflags_cc = ["-fvisibility-inlines-hidden"]
+ cflags_objcc = ["-fvisibility-inlines-hidden"]
+ cflags += extra_cflags
+ cflags_cc += extra_cflags_cc
+ cflags_objcc += extra_cflags_cc
+ ldflags = [
+ "-Wl,--fatal-warnings",
+ "-fPIC",
Expand Down Expand Up @@ -317,6 +323,7 @@ index 0000000..8208b13
+ cflags += [ "--target=x86_64-linux-androideabi${termux_api_level}" ]
+ ldflags += [ "--target=x86_64-linux-androideabi${termux_api_level}" ]
+ }
+ ldflags += extra_ldflags
+ asmflags = cflags
+ } else {
+ configs = ["//build/config/compiler:compiler"]
Expand Down
90 changes: 90 additions & 0 deletions stubs/vulkan/vk_android_native_buffer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#ifndef VULKAN_VK_ANDROID_NATIVE_BUFFER_H_
#define VULKAN_VK_ANDROID_NATIVE_BUFFER_H_ 1

#include <stdint.h>
#include <vulkan/vulkan.h>

#ifdef __cplusplus
extern "C" {
#endif

struct native_handle;
struct AHardwareBuffer;

typedef const struct native_handle* buffer_handle_t;

#define VK_ANDROID_native_buffer 1
#define VK_ANDROID_NATIVE_BUFFER_EXTENSION_NUMBER 11
#define VK_ANDROID_NATIVE_BUFFER_SPEC_VERSION 11
#define VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME "VK_ANDROID_native_buffer"

#define VK_ANDROID_NATIVE_BUFFER_ENUM(type, id) \
((type)(1000000000 + (1000 * (VK_ANDROID_NATIVE_BUFFER_EXTENSION_NUMBER - 1)) + (id)))

#define VK_STRUCTURE_TYPE_NATIVE_BUFFER_ANDROID \
VK_ANDROID_NATIVE_BUFFER_ENUM(VkStructureType, 0)
#define VK_STRUCTURE_TYPE_SWAPCHAIN_IMAGE_CREATE_INFO_ANDROID \
VK_ANDROID_NATIVE_BUFFER_ENUM(VkStructureType, 1)
#define VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENTATION_PROPERTIES_ANDROID \
VK_ANDROID_NATIVE_BUFFER_ENUM(VkStructureType, 2)
#define VK_STRUCTURE_TYPE_GRALLOC_USAGE_INFO_ANDROID \
VK_ANDROID_NATIVE_BUFFER_ENUM(VkStructureType, 3)
#define VK_STRUCTURE_TYPE_GRALLOC_USAGE_INFO_2_ANDROID \
VK_ANDROID_NATIVE_BUFFER_ENUM(VkStructureType, 4)

typedef enum VkSwapchainImageUsageFlagBitsANDROID {
VK_SWAPCHAIN_IMAGE_USAGE_SHARED_BIT_ANDROID = 0x00000001,
VK_SWAPCHAIN_IMAGE_USAGE_FLAG_BITS_MAX_ENUM_ANDROID = 0x7FFFFFFF,
} VkSwapchainImageUsageFlagBitsANDROID;

typedef VkFlags VkSwapchainImageUsageFlagsANDROID;

typedef struct VkNativeBufferUsage2ANDROID {
uint64_t consumer;
uint64_t producer;
} VkNativeBufferUsage2ANDROID;

typedef struct VkNativeBufferANDROID {
VkStructureType sType;
const void* pNext;
buffer_handle_t handle;
int stride;
int format;
int usage;
VkNativeBufferUsage2ANDROID usage2;
uint64_t usage3;
struct AHardwareBuffer* ahb;
} VkNativeBufferANDROID;

typedef struct VkSwapchainImageCreateInfoANDROID {
VkStructureType sType;
const void* pNext;
VkSwapchainImageUsageFlagsANDROID usage;
} VkSwapchainImageCreateInfoANDROID;

typedef struct VkPhysicalDevicePresentationPropertiesANDROID {
VkStructureType sType;
const void* pNext;
VkBool32 sharedImage;
} VkPhysicalDevicePresentationPropertiesANDROID;

typedef struct VkGrallocUsageInfoANDROID {
VkStructureType sType;
const void* pNext;
VkFormat format;
VkImageUsageFlags imageUsage;
} VkGrallocUsageInfoANDROID;

typedef struct VkGrallocUsageInfo2ANDROID {
VkStructureType sType;
const void* pNext;
VkFormat format;
VkImageUsageFlags imageUsage;
VkSwapchainImageUsageFlagsANDROID swapchainImageUsage;
} VkGrallocUsageInfo2ANDROID;

#ifdef __cplusplus
}
#endif

#endif
2 changes: 1 addition & 1 deletion sysroot.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ async def _resolve_packages(sess, arch, repo, dist, pkgs):


def _extract(out, deb):
subprocess.run(['dpkg', '-x', str(deb), str(out)], check=True, stderr=True)
subprocess.run(['dpkg', '-x', str(deb), str(out)], check=True)
logger.info(f'✓ 成功安装 {deb.name}')


Expand Down