Skip to content

Commit

Permalink
Merge pull request #62 from GoogleChrome/api-and-idl-fixes
Browse files Browse the repository at this point in the history
Use updated API endpoint and compatible compiler version for IDL files
  • Loading branch information
oliverdunk authored Jan 5, 2024
2 parents 00b2318 + 2f91948 commit 650e007
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 25 deletions.
25 changes: 10 additions & 15 deletions tools/lib/chrome-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const tagPrefix = 'refs/tags/';
const repoUrl = 'https://chromium.googlesource.com/chromium/src.git';


const omahaProxyUrl = 'https://omahaproxy.appspot.com/all.json';
const versionHistoryUrl = 'https://versionhistory.googleapis.com/v1/chrome/platforms/all/channels/stable/versions/';


/**
Expand Down Expand Up @@ -136,24 +136,19 @@ export async function chromeVersions() {


/**
* Fetches and finds the current stable version of Chrome via omahaproxy.
* Fetches and finds the current stable version of Chrome.
*
* @return {Promise<number>}
*/
export async function chromePublishedStable() {
const r = await fetch(omahaProxyUrl);
const data = /** @type {chromeTypes.OmahaProxyData} */ (await r.json());

for (const row of data) {
for (const version of row.versions) {
if (version.channel !== 'stable') {
continue;
}

const numericRelease = +version.version.split('.')[0];
if (numericRelease) {
return numericRelease;
}
const r = await fetch(versionHistoryUrl);
const data = /** @type {chromeTypes.VersionHistoryData} */ (await r.json());

for (const version of data.versions) {
const [major] = version.version.split('.');
const numericRelease = parseInt(major);
if (numericRelease) {
return numericRelease;
}
}

Expand Down
20 changes: 16 additions & 4 deletions tools/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,25 @@ const toolsPaths = [

/**
* @param {{
* majorChrome: number | undefined,
* workPath: string,
* headRevision: string,
* definitionsRevision: string,
* cpuLimit: number,
* }} opts
*/
async function prepareInTemp({ workPath, headRevision, definitionsRevision, cpuLimit }) {
async function prepareInTemp({ majorChrome, workPath, headRevision, definitionsRevision, cpuLimit }) {
// In Chrome 121, IDL files were changed to use promises for methods by
// default. This means running newer versions of the tool on older IDL files
// will generate the wrong output. We therefore instead use a known-good
// version of the tool on any IDL files from before Chrome 121.
const toolRevision = typeof majorChrome === "number" && majorChrome < 121
// Last commit before the breaking change in Chrome 121.
? "c279767649d882b71a14697fe9935d3c890a1ec7"
: headRevision;

const defitionsPromise = fetchAllTo(workPath, definitionPaths, definitionsRevision);
const toolsPromise = fetchAllTo(workPath, toolsPaths, headRevision);
const toolsPromise = fetchAllTo(workPath, toolsPaths, toolRevision);
const definitionsFiles = (await defitionsPromise).flatMap(cand => cand ?? []);
const toolsFiles = (await toolsPromise).flatMap(cand => cand ?? []);

Expand Down Expand Up @@ -195,10 +205,11 @@ Options:
const versions = await chromeVersions();
const headRevision = versions.head;

const majorChrome = hasChromeVersion ? Math.ceil(+argv._[0]) : undefined;

/** @type {string} */
let definitionsRevision;
if (hasChromeVersion) {
const majorChrome = Math.ceil(+argv._[0]);
if (typeof majorChrome === "number") {
versionData = versions.releases.get(majorChrome) ?? null;
if (!versionData) {
throw new Error(`unknown Chrome version: ${argv._[0]}`);
Expand All @@ -224,6 +235,7 @@ Options:
let out;
try {
out = await prepareInTemp({
majorChrome,
headRevision,
definitionsRevision,
workPath,
Expand Down
9 changes: 3 additions & 6 deletions types/chrome.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,12 @@ export type SpecCallback = (spec: TypeSpec, id: string) => void;
export type Tag = { name: string, value?: string };


export type OmahaProxyData = {
os: string,
export type VersionHistoryData = {
versions: {
channel: Channel,
name: string,
version: string,
current_reldate: string,
branch_commit: string,
}[],
}[];
};


/**
Expand Down

0 comments on commit 650e007

Please sign in to comment.