Skip to content
This repository was archived by the owner on Mar 23, 2023. It is now read-only.

Commit bc1976c

Browse files
authored
Merge pull request #67 from vector-im/t3chguy/ia32
Consolidate target handling with element-desktop
2 parents 1f5503d + 21b5905 commit bc1976c

File tree

9 files changed

+1109
-153
lines changed

9 files changed

+1109
-153
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"build": "tsc"
1212
},
1313
"dependencies": {
14-
"rimraf": "^3.0.2"
14+
"rimraf": "^3.0.2",
15+
"element-desktop": "vector-im/element-desktop#develop"
1516
},
1617
"devDependencies": {
1718
"@types/node": "14",

src/desktop_develop.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ limitations under the License.
1616

1717
import { promises as fsProm } from 'fs';
1818
import * as path from 'path';
19+
import { Target, TargetId, UniversalTarget, WindowsTarget } from 'element-desktop/scripts/hak/target';
1920

2021
import getSecret from './get_secret';
2122
import GitRepo from './gitrepo';
2223
import rootLogger, { LoggableError, Logger } from './logger';
2324
import Runner, { IRunner } from './runner';
2425
import DockerRunner from './docker_runner';
2526
import WindowsBuilder from './windows_builder';
26-
import { ENABLED_TARGETS, Target, TargetId, UniversalTarget, WindowsTarget } from './target';
2727
import { setDebVersion, addDeb } from './debian';
2828
import { getMatchingFilesInDir, pushArtifacts, copyAndLog, rm } from './artifacts';
2929

@@ -99,6 +99,7 @@ export default class DesktopDevelopBuilder {
9999
private lastFailTimes: Partial<Record<TargetId, number>> = {};
100100

101101
constructor(
102+
private readonly targets: Target[],
102103
private winVmName: string,
103104
private winUsername: string,
104105
private winPassword: string,
@@ -122,7 +123,7 @@ export default class DesktopDevelopBuilder {
122123

123124
this.lastBuildTimes = {};
124125
this.lastFailTimes = {};
125-
for (const target of ENABLED_TARGETS) {
126+
for (const target of this.targets) {
126127
this.lastBuildTimes[target.id] = await getLastBuildTime(target, logger);
127128
this.lastFailTimes[target.id] = 0;
128129
}
@@ -135,7 +136,7 @@ export default class DesktopDevelopBuilder {
135136
if (this.building) return;
136137

137138
const toBuild: Target[] = [];
138-
for (const target of ENABLED_TARGETS) {
139+
for (const target of this.targets) {
139140
const nextBuildDue = getNextBuildTime(new Date(Math.max(
140141
this.lastBuildTimes[target.id], this.lastFailTimes[target.id],
141142
)));

src/desktop_release.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ limitations under the License.
1616

1717
import { promises as fsProm } from 'fs';
1818
import * as path from 'path';
19+
import { Target, UniversalTarget, WindowsTarget } from 'element-desktop/scripts/hak/target';
1920

2021
import getSecret from './get_secret';
2122
import GitRepo from './gitrepo';
2223
import rootLogger, { LoggableError, Logger } from './logger';
2324
import Runner, { IRunner } from './runner';
2425
import DockerRunner from './docker_runner';
2526
import WindowsBuilder from './windows_builder';
26-
import { ENABLED_TARGETS, Target, UniversalTarget, WindowsTarget } from './target';
2727
import { setDebVersion, addDeb } from './debian';
2828
import { getMatchingFilesInDir, pushArtifacts, copyAndLog, rm } from './artifacts';
2929

@@ -41,6 +41,7 @@ export default class DesktopReleaseBuilder {
4141
private riotSigningKeyContainer: string;
4242

4343
constructor(
44+
private readonly targets: Target[],
4445
private winVmName: string,
4546
private winUsername: string,
4647
private winPassword: string,
@@ -82,8 +83,7 @@ export default class DesktopReleaseBuilder {
8283

8384
if (this.building) return;
8485

85-
const toBuild = ENABLED_TARGETS;
86-
86+
const toBuild = this.targets;
8787
if (toBuild.length === 0) return;
8888

8989
try {

src/index.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ See the License for the specific language governing permissions and
1616
limitations under the License.
1717
*/
1818

19+
import { Target, TARGETS } from 'element-desktop/scripts/hak/target';
20+
1921
import logger from './logger';
2022
import DesktopDevelopBuilder from './desktop_develop';
2123
import DesktopReleaseBuilder from './desktop_release';
@@ -67,12 +69,19 @@ while (process.argv.length > 2) {
6769
process.argv.shift();
6870
}
6971

72+
// The set of targets we build by default, sorted by increasing complexity so
73+
// that we fail fast when the native host target fails.
74+
const targets: Target[] = [
75+
TARGETS['universal-apple-darwin'],
76+
TARGETS['x86_64-unknown-linux-gnu'],
77+
TARGETS['x86_64-pc-windows-msvc'],
78+
TARGETS['i686-pc-windows-msvc'],
79+
];
80+
7081
let builder: DesktopDevelopBuilder | DesktopReleaseBuilder;
7182
if (desktopBranch) {
72-
builder = new DesktopReleaseBuilder(
73-
winVmName, winUsername, winPassword, rsyncServer, desktopBranch);
83+
builder = new DesktopReleaseBuilder(targets, winVmName, winUsername, winPassword, rsyncServer, desktopBranch);
7484
} else {
75-
builder = new DesktopDevelopBuilder(
76-
winVmName, winUsername, winPassword, rsyncServer);
85+
builder = new DesktopDevelopBuilder(targets, winVmName, winUsername, winPassword, rsyncServer);
7786
}
7887
builder.start();

src/spawn.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,29 @@ export async function spawn(
2222
command: string,
2323
args: ReadonlyArray<string>,
2424
options: childProcess.SpawnOptions = {},
25+
captureLog = true,
2526
): Promise<void> {
2627
return new Promise((resolve, reject) => {
2728
const proc = childProcess.spawn(command, args, {
2829
...options,
29-
stdio: ["inherit", "pipe", "pipe"],
30+
stdio: captureLog ? ["inherit", "pipe", "pipe"] : "inherit",
3031
});
3132

32-
proc.stdout.pipe(process.stdout);
33-
proc.stderr.pipe(process.stderr);
34-
3533
let log = "";
36-
proc.stdout.on('data', (chunk) => {
37-
log += chunk.toString();
38-
});
39-
proc.stderr.on('data', (chunk) => {
40-
log += chunk.toString();
41-
});
4234

43-
proc.on('exit', (code) => {
35+
if (captureLog) {
36+
proc.stdout.pipe(process.stdout);
37+
proc.stderr.pipe(process.stderr);
38+
39+
proc.stdout.on('data', (chunk) => {
40+
log += chunk.toString();
41+
});
42+
proc.stderr.on('data', (chunk) => {
43+
log += chunk.toString();
44+
});
45+
}
46+
47+
proc.on('exit', (code?: number) => {
4448
if (!code) {
4549
resolve();
4650
return;

src/target.ts

Lines changed: 0 additions & 126 deletions
This file was deleted.

src/windows_builder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ limitations under the License.
1717
import * as path from 'path';
1818
import { promises as fsProm } from 'fs';
1919
import * as childProcess from 'child_process';
20+
import { WindowsTarget } from 'element-desktop/scripts/hak/target';
2021

21-
import { WindowsTarget } from './target';
2222
import { Logger } from "./logger";
2323
import { spawn } from "./spawn";
2424

@@ -228,7 +228,7 @@ export default class WindowsBuilder {
228228
}
229229

230230
private async vboxManage(cmd: string, ...args: string[]): Promise<void> {
231-
return spawn('VBoxManage', [cmd].concat(args));
231+
return spawn('VBoxManage', [cmd].concat(args), {}, false);
232232
}
233233

234234
public static async setDonglePower(on: boolean): Promise<void> {

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
"include": [
88
".eslintrc.js",
99
"./src/**/*.ts",
10+
"./node_modules/element-desktop/scripts/hak/target.ts"
1011
]
1112
}

0 commit comments

Comments
 (0)