Skip to content

Instantly share code, notes, and snippets.

@ufna
Forked from norlin/UE5-Project.sublime-build
Created October 10, 2018 08:04
Show Gist options
  • Save ufna/dea6489d92bd4be194acf8237b82aea6 to your computer and use it in GitHub Desktop.
Save ufna/dea6489d92bd4be194acf8237b82aea6 to your computer and use it in GitHub Desktop.
Build system for ue4 projects for Sublime Text 3
#!/usr/bin/env node
const { spawn } = require('child_process');
const path = require('path');
// Set the paths where your UE4 is located
const UE4Source = {
Win: 'D:/Work/github/UnrealEngine',
Mac: '/Users/Shared/Epic Games/UE_4.20'
};
const isWin = /^win/.test(process.platform);
let example = `${isWin ? 'X:' : ''}/Path/To/MyProjectName/MyProjectName.uproject`;
let args = process.argv.slice(2);
if (args.length != 2) {
process.stdout.write(`Usage example:\n node build.js MyProjectName ${example}\n`);
return;
}
let project = args[0];
let projectPath = path.resolve(args[1]);
let cwd = process.cwd();
if (!project || project == '--help' || project == '/?' || project == '-h') {
process.stdout.write(`Usage example:\n node build.js MyProjectName ${example}\n`);
return;
}
let build;
if (isWin) {
let cmd_args = [
'/c',
'd:', '&', 'cd', `"${cwd}"`,'&',
path.join(UE4Source.Win, 'Engine/Binaries/DotNET/UnrealBuildTool.exe'),
'Development',
'Win64',
`-Project="${projectPath}"`,
'-TargetType=Editor',
'-Progress',
'-NoHotReloadFromIDE',
];
console.log(`build.js command: ${cmd_args.join(' ')}`);
build = spawn('cmd.exe', cmd_args);
} else /* if (isMac) */ {
let cmd_args = [
project,
'Development',
'Mac',
`-project="${projectPath}"`,
'-editorrecompile',
'-progress',
'NoHotReloadFromIDE',
];
// TODO: find the reason why this thing is crashing Sublime Text 3 plugin_host process
build = spawn('Engine/Build/BatchFiles/Mac/Build.sh', cmd_args, {
cwd: UE4Source.Mac
});
}
build.stdout.on('data', (data) => {
process.stdout.write(data);
});
build.stderr.on('data', (data) => {
process.stderr.write(data);
});
build.on('close', (code) => {
console.log(`build process exited with code ${code}`);
});
{
"cmd": [
"node",
"build.js",
"ProjectName",
"D:/Path/To/YourProject/ProjectName.uproject",
],
"shell": true,
"working_dir": "D:/Path/To/YourProject",
"file_regex": "^(D:[^\\(]+)\\((\\d+)\\)"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment