Skip to content
This repository has been archived by the owner on Feb 15, 2023. It is now read-only.

Commit

Permalink
✨ Artifact build support
Browse files Browse the repository at this point in the history
  • Loading branch information
trickypr committed Nov 12, 2021
1 parent 775cf7e commit c0fb0ed
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
16 changes: 15 additions & 1 deletion src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,21 @@ const applyConfig = async (os: string, arch: string) => {
appId: config.appId,
})

const mergedConfig = `# This file is automatically generated. You should only modify this if you know what you are doing!\n\n${commonConfig}\n\n${osConfig}\n\n${customConfig}`
const internalConfig = `# Internally defined by melon\n${
config.buildOptions.artifactBuilds
? '# Artifact builds (buildOptions.artifactBuilds) \nac_add_options --enable-artifact-builds\nmk_add_options MOZ_OBJDIR=./objdir-frontend'
: ''
}`

const mergedConfig =
`# This file is automatically generated. You should only modify this if you know what you are doing!\n\n` +
commonConfig +
'\n\n' +
osConfig +
'\n\n' +
customConfig +
'\n\n' +
internalConfig

writeFileSync(resolve(ENGINE_DIR, 'mozconfig'), mergedConfig)

Expand Down
9 changes: 6 additions & 3 deletions src/commands/setupProject.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { writeFileSync, existsSync, mkdirSync, readFileSync } from 'fs'
import { readdir, stat, copyFile } from 'fs/promises'
import { join, isAbsolute, dirname } from 'path'
import { copyFile } from 'fs/promises'
import { join, dirname } from 'path'

import prompts from 'prompts'

Expand All @@ -17,7 +17,7 @@ import {
// =============================================================================
// User interaction portion

export async function setupProject() {
export async function setupProject(): Promise<void> {
try {
if (existsSync(configPath)) {
log.warning('There is already a config file. This will overwrite it!')
Expand Down Expand Up @@ -118,6 +118,9 @@ export async function setupProject() {
vendor,
appId,
version: { product, version, displayVersion: '1.0.0' },
buildOptions: {
artifactBuilds: ui === 'uc',
},
}

await copyRequired()
Expand Down
18 changes: 18 additions & 0 deletions src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,21 @@ export interface Config {
*/
displayVersion: string
}
buildOptions: {
/**
* Artifact builds are faster builds that only work when modifying a limited
* subset of firefox's source code. They download a majority of the source
* code from mozilla's servers and build the ui locally. Artifact builds work
* with ui changes, however do not work with:
* - C, C++, Rust or other machine code
* - Telemetry histogram definitions
* - Some build system definitions
*
* Additionally, this will not work for other mozilla products like thunderbird
* if we ever provide support for those platforms.
*/
artifactBuilds: boolean
}
}

const defaultConfig: Config = {
Expand All @@ -72,6 +87,9 @@ const defaultConfig: Config = {
product: SupportedProducts.Firefox,
displayVersion: '1.0.0',
},
buildOptions: {
artifactBuilds: false,
},
}

export function hasConfig(): boolean {
Expand Down

0 comments on commit c0fb0ed

Please sign in to comment.