From b0f8efb90deb93af46870ae7561e6f82a0141b05 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Sat, 27 Jul 2019 21:12:49 +0200 Subject: [PATCH] ci: Use improved build scripts --- appveyor.yml | 4 +- ci/appveyor-build.js | 98 ------------------------------------ ci/appveyor-package.bat | 10 +--- ci/builder.js | 109 ++++++++++++++++++++++++++++++++++++++++ ci/runner.js | 51 +++++++++++++++++++ 5 files changed, 164 insertions(+), 108 deletions(-) delete mode 100644 ci/appveyor-build.js create mode 100644 ci/builder.js create mode 100644 ci/runner.js diff --git a/appveyor.yml b/appveyor.yml index 0fba6964..5ebee235 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -12,7 +12,7 @@ image: environment: CMAKE_SYSTEM_VERSION: 10.0.17134.0 - PACKAGE_PREFIX: amd-encoder-for-obs-studio + PACKAGE_PREFIX: obs-stream-effects INNOSETUP_URL: http://www.jrsoftware.org/download.php/is.exe CURL_VERSION: 7.39.0 @@ -39,7 +39,7 @@ install: - cmd: ci/appveyor-install.bat build_script: -- cmd: node ci/appveyor-build.js +- cmd: node ci/builder.js after_build: - cmd: ci/appveyor-package.bat diff --git a/ci/appveyor-build.js b/ci/appveyor-build.js deleted file mode 100644 index f43946c3..00000000 --- a/ci/appveyor-build.js +++ /dev/null @@ -1,98 +0,0 @@ -const cp = require('child_process'); - -var config32 = cp.spawn( - "cmake", [ - '-H.', - '-B"build/32"', - '-G"Visual Studio 15 2017"', - '-DCMAKE_INSTALL_PREFIX="build/distrib"', - '-DCMAKE_PACKAGE_PREFIX="build"', - '-DCMAKE_PACKAGE_NAME="obs-stream-effects"' - ], { - windowsVerbatimArguments: true, - windowsHide: true - } -); -config32.stdout.on('data', (data) => { - process.stdout.write(`[32:Out] ${data}`); -}); -config32.stderr.on('data', (data) => { - console.log(`[32:Err] ${data}`); -}); -config32.on('exit', (code, signal) => { - if (code != 0) { - process.exit(code) - } - var build32 = cp.spawn( - "cmake", [ - '--build build/32', - '--target INSTALL', - '--config RelWithDebInfo', - '--', - '/logger:"C:\\Program Files\\AppVeyor\\BuildAgent\\Appveyor.MSBuildLogger.dll"' - ], { - windowsVerbatimArguments: true, - windowsHide: true - } - ); - build32.stdout.on('data', (data) => { - process.stdout.write(`[32:Out] ${data}`); - }); - build32.stderr.on('data', (data) => { - process.stderr.write(`[32:Err] ${data}`); - }); - build32.on('exit', (code, signal) => { - if (code != 0) { - process.exit(code) - } - }); -}); - -var config64 = cp.spawn( - "cmake", [ - '-H.', - '-B"build/64"', - '-G"Visual Studio 15 2017 Win64"', - '-DCMAKE_INSTALL_PREFIX="build/distrib"', - '-DCMAKE_PACKAGE_PREFIX="build"', - '-DCMAKE_PACKAGE_NAME="obs-stream-effects"' - ], { - windowsVerbatimArguments: true, - windowsHide: true - } -); -config64.stdout.on('data', (data) => { - process.stdout.write(`[64:Out] ${data}`); -}); -config64.stderr.on('data', (data) => { - console.log(`[64:Err] ${data}`); -}); -config64.on('exit', (code, signal) => { - if (code != 0) { - process.exit(code) - } - var build64 = cp.spawn( - "cmake", [ - '--build build/64', - '--target INSTALL', - '--config RelWithDebInfo', - '--', - '/logger:"C:\\Program Files\\AppVeyor\\BuildAgent\\Appveyor.MSBuildLogger.dll"' - ], { - windowsVerbatimArguments: true, - windowsHide: true - } - ); - build64.stdout.on('data', (data) => { - process.stdout.write(`[32:Out] ${data}`); - }); - build64.stderr.on('data', (data) => { - process.stderr.write(`[32:Err] ${data}`); - }); - build64.on('exit', (code, signal) => { - if (code != 0) { - process.exit(code) - } - }); -}); - diff --git a/ci/appveyor-package.bat b/ci/appveyor-package.bat index ebf2cb3a..def1417e 100644 --- a/ci/appveyor-package.bat +++ b/ci/appveyor-package.bat @@ -1,9 +1,3 @@ @ECHO OFF -IF "%APPVEYOR_REPO_TAG%"=="true" ( - ECHO -- Building 7z Archive -- - cmake --build build/64 --target PACKAGE_7Z --config RelWithDebInfo - ECHO -- Building Zip Archive -- - cmake --build build/64 --target PACKAGE_ZIP --config RelWithDebInfo - ECHO -- Building Installer -- - "C:\Program Files (x86)\Inno Setup 5\ISCC.exe" /Qp ".\build\64\installer.iss" > nul -) \ No newline at end of file +ECHO -- Building Installer -- +"C:\Program Files (x86)\Inno Setup 5\ISCC.exe" /Qp ".\build\64\installer.iss" > nul diff --git a/ci/builder.js b/ci/builder.js new file mode 100644 index 00000000..99fa40b4 --- /dev/null +++ b/ci/builder.js @@ -0,0 +1,109 @@ +"use strict"; + +const process = require('process'); +const runner = require('./runner.js'); + +// Steps +let configure_runners = []; +let build_runners = []; +let package_runners = []; + +{ + let cmake_configure_extra = [ + `-DCMAKE_SYSTEM_VERSION=${process.env.CMAKE_SYSTEM_VERSION}`, + '-DCMAKE_INSTALL_PREFIX="build/distrib/"', + '-DCMAKE_PACKAGE_PREFIX="build/"', + `-DCMAKE_PACKAGE_NAME="${process.env.PACKAGE_PREFIX}"`, + ]; + let cmake_build_extra = [ + ]; + + // Configuration depends on platform + if (process.platform == "win32" || process.platform == "win64") { + configure_runners.push(new runner('32-bit', 'cmake', [ + '-H.', + '-Bbuild/32', + `-G"Visual Studio 15 2017"`, + ].concat(cmake_configure_extra))); + configure_runners.push(new runner('64-bit', 'cmake', [ + '-H.', + '-Bbuild/64', + `-G"Visual Studio 15 2017 Win64"`, + '-T"host=x64"', + ].concat(cmake_configure_extra))); + + // Extra build steps for AppVeyor on Windows for Logging purposes. + if(process.env.APPVEYOR) { + cmake_build_extra.concat(['--', '/logger:"C:\\Program Files\\AppVeyor\\BuildAgent\\Appveyor.MSBuildLogger.dll"']); + } + } else if (process.platform == "linux") { + configure_runners.push(new runner('32-bit', 'cmake', [ + '-H.', + '-Bbuild32', + `-G"Unix Makefiles"`, + `-DCOPIED_DEPENDENCIES=false`, + ].concat(cmake_configure_extra), + { ...process.env, ...{ + CFLAGS: `${process.env.COMPILER_FLAGS_32}`, + CXXFLAGS: `${process.env.COMPILER_FLAGS_32}`, + }})); + configure_runners.push(new runner('64-bit', 'cmake', [ + '-H.', + '-Bbuild64', + `-G"Unix Makefiles"`, + `-DCOPIED_DEPENDENCIES=false`, + ].concat(cmake_configure_extra), + { ...process.env, ...{ + CFLAGS: `${process.env.COMPILER_FLAGS_64}`, + CXXFLAGS: `${process.env.COMPILER_FLAGS_64}`, + }})); + } + + build_runners.push(new runner('32-bit', 'cmake', [ + '--build', 'build/32', + '--config', 'RelWithDebInfo', + '--target', 'INSTALL' + ].concat(cmake_build_extra))); + build_runners.push(new runner('64-bit', 'cmake', [ + '--build', 'build/64', + '--config', 'RelWithDebInfo', + '--target', 'INSTALL' + ].concat(cmake_build_extra))); + package_runners.push(new runner('64-bit', 'cmake', [ + '--build', 'build/64', + '--target', 'PACKAGE_7Z', + '--config', 'RelWithDebInfo' + ].concat(cmake_build_extra))); + package_runners.push(new runner('64-bit', 'cmake', [ + '--build', 'build/64', + '--target', 'PACKAGE_ZIP', + '--config', 'RelWithDebInfo' + ].concat(cmake_build_extra))); +} + +// Run Configure steps. +let configure_promises = []; +for (let config of configure_runners) { + configure_promises.push(config.run()); +} +Promise.all(configure_promises).then(function(result) { + let build_promises = []; + for (let build of build_runners) { + build_promises.push(build.run()); + } + Promise.all(build_promises).then(function(result) { + let package_promises = []; + for (let pack of package_runners) { + package_promises.push(pack.run()); + } + Promise.all(package_promises).then(function(result) { + process.exit(result); + }).catch(function(result) { + process.exit(result); + }); + }).catch(function(result) { + process.exit(result); + }); +}).catch(function(result) { + process.exit(result); +}); diff --git a/ci/runner.js b/ci/runner.js new file mode 100644 index 00000000..744002f5 --- /dev/null +++ b/ci/runner.js @@ -0,0 +1,51 @@ +"use strict"; + +const process = require('process'); +const cp = require('child_process'); + +class Runner { + constructor(name, cmd, args, env) { + this.name = name; + this.cmd = cmd; + if (args == undefined) + args = []; + this.args = args; + if (env == undefined) + env = process.env; + this.env = env; + } + + run() { + let self = this; + return new Promise(function(resolve, reject) { + console.log(self.cmd, self.args); + self.proc = cp.spawn( + self.cmd, self.args, { + windowsVerbatimArguments: true, + windowsHide: true, + env: self.env, + } + ); + self.proc.stdout.on('data', (data) => { + process.stdout.write(`[${self.name}:Out] ${data}`); + }); + self.proc.stderr.on('data', (data) => { + process.stderr.write(`[${self.name}:Err] ${data}`); + }); + self.proc.on('exit', (code, signal) => { + if (code != 0) { + reject(code); + return; + } + resolve(code); + return; + }); + }); + } + + execute() { + return this.run(); + } +} + +module.exports = Runner; \ No newline at end of file