Skip to content

Commit edb58eb

Browse files
committed
temp: win
1 parent 5cf6cf7 commit edb58eb

File tree

9 files changed

+187
-18
lines changed

9 files changed

+187
-18
lines changed

.cipd/tagcache.db

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11

2-

2+

33
�
4-
gn/gn/mac-amd645git_revision:b2d77ab1373192d1532af94b68fb8bab727b0e5b,PiVU5JncEO3ip2J59WfZ1zVf3_lvNOkymtuXZGUfXywC"!chrome-infra-packages.appspot.com �0A��%'Zh�;II>j���0��J0��qD
4+
gn/gn/mac-amd645git_revision:b2d77ab1373192d1532af94b68fb8bab727b0e5b,PiVU5JncEO3ip2J59WfZ1zVf3_lvNOkymtuXZGUfXywC"!chrome-infra-packages.appspot.com
5+
�
6+
gn/gn/windows-amd645git_revision:b2d77ab1373192d1532af94b68fb8bab727b0e5b,CU4JzSuuCVoXXiuNLhJnJ5udxTINCVR_0xEdh-xlAcAC"!chrome-infra-packages.appspot.com ?����EeS�Ü�!�VC�m�'���*M}��

.claude/settings.local.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(pnpm run build:devtools-frontend-lynx:*)"
5+
],
6+
"deny": [],
7+
"ask": []
8+
}
9+
}

.gclient_entries

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ entries = {
33
'packages/devtools-frontend-lynx/build': 'https://chromium.googlesource.com/chromium/src/build.git@fd86d60f33cbc794537c4da2ef7e298d7f81138e',
44
'packages/devtools-frontend-lynx/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools.git@37dc929ecb351687006a61744b116cda601753d7',
55
'packages/devtools-frontend-lynx/buildtools/clang_format/script': 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/clang/tools/clang-format.git@99803d74e35962f63a775f29477882afd4d57d94',
6-
'packages/devtools-frontend-lynx/buildtools/mac:gn/gn/mac-amd64': 'https://chrome-infra-packages.appspot.com/gn/gn/mac-amd64@git_revision:b2d77ab1373192d1532af94b68fb8bab727b0e5b',
6+
'packages/devtools-frontend-lynx/buildtools/win:gn/gn/windows-amd64': 'https://chrome-infra-packages.appspot.com/gn/gn/windows-amd64@git_revision:b2d77ab1373192d1532af94b68fb8bab727b0e5b',
77
'packages/devtools-frontend-lynx/third_party/depot_tools': 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@a806594b95a39141fdbf1f359087a44ffb2deaaf',
88
'packages/devtools-frontend-lynx/third_party/inspector_protocol': 'https://chromium.googlesource.com/deps/inspector_protocol@32cf5f2bf4dc20c73ead291e68d2e2f6b638cd57',
99
}

.gclient_previous_sync_commits

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"packages/devtools-frontend-lynx/build": "fd86d60f33cbc794537c4da2ef7e298d7f81138e", "packages/devtools-frontend-lynx/buildtools": "37dc929ecb351687006a61744b116cda601753d7", "packages/devtools-frontend-lynx/buildtools/clang_format/script": "99803d74e35962f63a775f29477882afd4d57d94", "packages/devtools-frontend-lynx/third_party/depot_tools": "a806594b95a39141fdbf1f359087a44ffb2deaaf", "packages/devtools-frontend-lynx/third_party/inspector_protocol": "32cf5f2bf4dc20c73ead291e68d2e2f6b638cd57"}
1+
{"packages/devtools-frontend-lynx/third_party/inspector_protocol": "32cf5f2bf4dc20c73ead291e68d2e2f6b638cd57", "packages/devtools-frontend-lynx/build": "fd86d60f33cbc794537c4da2ef7e298d7f81138e", "packages/devtools-frontend-lynx/third_party/depot_tools": "a806594b95a39141fdbf1f359087a44ffb2deaaf", "packages/devtools-frontend-lynx/buildtools": "37dc929ecb351687006a61744b116cda601753d7", "packages/devtools-frontend-lynx/buildtools/clang_format/script": "99803d74e35962f63a775f29477882afd4d57d94"}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"rsbuild:main": "rsbuild build --config rsbuild.config.ts",
1212
"build:all": "pnpm --filter @lynx-js/* run build && pnpm run build && pnpm run modern:renderer",
1313
"clean": "node -e \"const fs=require('fs'); ['dist', 'packages/devtools-frontend-lynx/out', 'packages/devtools-frontend-lynx/output'].forEach(p => fs.existsSync(p) && fs.rmSync(p, {recursive: true, force: true}))\" && pnpm -r exec node -e \"const fs=require('fs'); fs.existsSync('dist') && fs.rmSync('dist', {recursive: true, force: true})\"",
14-
"build:devtools-frontend-lynx": "pnpm run fetch:depot_tools && export PATH=$(pwd)/packages/devtools-frontend-lynx/buildtools/depot_tools:$PATH && pnpm run sync:devtools-gn && pnpm run build:devtools && pnpm run sync:devtools-dist",
14+
"build:devtools-frontend-lynx": "node scripts/build-devtools-frontend-lynx.js",
1515
"fetch:depot_tools": "node scripts/fetch-depot-tools.js",
1616
"sync:devtools-gn": "gclient sync --gclientfile=.gclient --deps=all",
1717
"build:devtools": "node scripts/build-lynx-devtools.js",

packages/lynx-devtool-cli/scripts/unzip-resources.js

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,35 @@ function extractTarGz(tarFile, destDir) {
6969
}
7070
}
7171

72-
// Function to remove directory recursively
72+
// Function to remove directory recursively with platform-specific handling
7373
function removeDir(dirPath) {
74-
if (fs.existsSync(dirPath)) {
75-
fs.rmSync(dirPath, { recursive: true, force: true });
76-
console.log(`Removed: ${dirPath}`);
74+
if (!fs.existsSync(dirPath)) {
75+
return;
76+
}
77+
78+
try {
79+
// On Windows, use native rmdir command which is more reliable
80+
if (process.platform === 'win32') {
81+
// Use cmd /c to ensure proper command execution
82+
const absPath = path.resolve(dirPath);
83+
runCommand(`cmd /c rmdir /s /q "${absPath}"`, { stdio: 'pipe' });
84+
console.log(`Removed: ${dirPath}`);
85+
} else {
86+
// On Unix-like systems, use rm -rf
87+
runCommand(`rm -rf "${dirPath}"`, { stdio: 'pipe' });
88+
console.log(`Removed: ${dirPath}`);
89+
}
90+
} catch (error) {
91+
// If command fails, try Node.js fs method
92+
console.warn(`Command-based removal failed, trying Node.js fs...`);
93+
try {
94+
fs.rmSync(dirPath, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
95+
console.log(`Removed: ${dirPath}`);
96+
} catch (fsError) {
97+
console.warn(`Could not remove ${dirPath}: ${fsError.message}`);
98+
console.warn(`Continuing anyway...`);
99+
// Don't throw - allow the build to continue
100+
}
77101
}
78102
}
79103

packages/lynx-devtool-cli/src/cli/updator/updator.ts

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,31 @@ function copyDir(src: string, dest: string) {
2727
if (!fs.existsSync(dest)) {
2828
fs.mkdirSync(dest, { recursive: true });
2929
}
30-
const entries = fs.readdirSync(src);
30+
31+
let entries;
32+
try {
33+
entries = fs.readdirSync(src);
34+
} catch (error: any) {
35+
defaultLogger.warn(`Failed to read directory ${src}: ${error.message}`);
36+
return;
37+
}
38+
3139
for (const entry of entries) {
3240
const srcPath = path.join(src, entry);
3341
const destPath = path.join(dest, entry);
34-
const stat = fs.statSync(srcPath);
35-
if (stat.isDirectory()) {
36-
copyDir(srcPath, destPath);
37-
} else {
38-
fs.copyFileSync(srcPath, destPath);
42+
43+
try {
44+
const stat = fs.statSync(srcPath);
45+
if (stat.isDirectory()) {
46+
copyDir(srcPath, destPath);
47+
} else {
48+
fs.copyFileSync(srcPath, destPath);
49+
}
50+
} catch (error: any) {
51+
// On Windows, some files might be locked or have permission issues
52+
// Log the error but continue with other files
53+
defaultLogger.warn(`Failed to copy ${srcPath}: ${error.message}. Skipping...`);
54+
continue;
3955
}
4056
}
4157
}
@@ -107,7 +123,22 @@ export async function setupResource(
107123

108124
// handle the path in dev mode, must copy the resources from the source code
109125
if (!isPackagedApp) {
110-
fs.rmSync(ldtPath, { recursive: true, force: true });
126+
// Clean up the target directory more aggressively on Windows
127+
try {
128+
fs.rmSync(ldtPath, { recursive: true, force: true });
129+
} catch (error: any) {
130+
defaultLogger.warn(`Failed to remove ${ldtPath} via fs.rmSync: ${error.message}`);
131+
// On Windows, try using system command which is more reliable
132+
if (process.platform === 'win32') {
133+
try {
134+
const { execSync } = require('child_process');
135+
execSync(`cmd /c rmdir /s /q "${path.resolve(ldtPath)}"`, { stdio: 'pipe' });
136+
defaultLogger.info(`Removed ${ldtPath} via system command`);
137+
} catch (cmdError: any) {
138+
defaultLogger.warn(`Could not clean ${ldtPath}: ${cmdError.message}`);
139+
}
140+
}
141+
}
111142

112143
defaultLogger.info(`=== updator: Update dev Static Resources ===`);
113144

@@ -195,7 +226,22 @@ export async function setupResource(
195226
(isPackagedApp && resType === "dev") ||
196227
(isPackagedApp && resType === "prod" && resVersion !== innerVersion)
197228
) {
198-
fs.rmSync(ldtPath, { recursive: true, force: true });
229+
// Clean up the target directory more aggressively on Windows
230+
try {
231+
fs.rmSync(ldtPath, { recursive: true, force: true });
232+
} catch (error: any) {
233+
defaultLogger.warn(`Failed to remove ${ldtPath} via fs.rmSync: ${error.message}`);
234+
// On Windows, try using system command which is more reliable
235+
if (process.platform === 'win32') {
236+
try {
237+
const { execSync } = require('child_process');
238+
execSync(`cmd /c rmdir /s /q "${path.resolve(ldtPath)}"`, { stdio: 'pipe' });
239+
defaultLogger.info(`Removed ${ldtPath} via system command`);
240+
} catch (cmdError: any) {
241+
defaultLogger.warn(`Could not clean ${ldtPath}: ${cmdError.message}`);
242+
}
243+
}
244+
}
199245

200246
defaultLogger.info(`=== updator: Update prod Static Resources ===`);
201247
defaultLogger.info(`isPackagedApp: ${isPackagedApp}`);

packages/lynx-trace

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/usr/bin/env node
2+
3+
const fs = require('fs');
4+
const path = require('path');
5+
const { execSync } = require('child_process');
6+
7+
// Get the project root directory
8+
const projectRoot = path.join(__dirname, '..');
9+
process.chdir(projectRoot);
10+
11+
const OS_TYPE = detectOS();
12+
13+
function detectOS() {
14+
const platform = process.platform;
15+
if (platform === 'darwin') return 'darwin';
16+
if (platform === 'linux') return 'linux';
17+
if (platform === 'win32') return 'windows_nt';
18+
throw new Error(`Unsupported platform: ${platform}`);
19+
}
20+
21+
function runCommand(command, options = {}) {
22+
try {
23+
console.log(`Running: ${command}`);
24+
const result = execSync(command, {
25+
stdio: 'inherit',
26+
encoding: 'utf8',
27+
...options
28+
});
29+
return result;
30+
} catch (error) {
31+
console.error(`Command failed: ${command}`);
32+
console.error(error.message);
33+
throw error;
34+
}
35+
}
36+
37+
function main() {
38+
try {
39+
console.log('Starting devtools-frontend-lynx build process...\n');
40+
41+
// Step 1: Fetch depot_tools
42+
console.log('Step 1: Fetching depot_tools...');
43+
runCommand('pnpm run fetch:depot_tools');
44+
45+
// Step 2: Add depot_tools to PATH
46+
console.log('\nStep 2: Setting up PATH...');
47+
const depotToolsPath = path.join(
48+
projectRoot,
49+
'packages',
50+
'devtools-frontend-lynx',
51+
'buildtools',
52+
'depot_tools'
53+
);
54+
55+
if (!fs.existsSync(depotToolsPath)) {
56+
throw new Error(`depot_tools not found at: ${depotToolsPath}`);
57+
}
58+
59+
// Set PATH for child processes
60+
process.env.PATH = `${depotToolsPath}${path.delimiter}${process.env.PATH}`;
61+
console.log(`Added depot_tools to PATH: ${depotToolsPath}`);
62+
63+
// Step 3: Sync devtools-gn
64+
console.log('\nStep 3: Syncing devtools-gn...');
65+
runCommand('pnpm run sync:devtools-gn', {
66+
env: process.env
67+
});
68+
69+
// Step 4: Build devtools
70+
console.log('\nStep 4: Building devtools...');
71+
runCommand('pnpm run build:devtools');
72+
73+
// Step 5: Sync devtools-dist
74+
console.log('\nStep 5: Syncing devtools-dist...');
75+
runCommand('pnpm run sync:devtools-dist');
76+
77+
console.log('\n✓ devtools-frontend-lynx build completed successfully!');
78+
} catch (error) {
79+
console.error('\n✗ devtools-frontend-lynx build failed:', error.message);
80+
process.exit(1);
81+
}
82+
}
83+
84+
if (require.main === module) {
85+
main();
86+
}
87+
88+
module.exports = { main };

0 commit comments

Comments
 (0)