diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..23a6f1f --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +## NOTHING IN HERE FOR NOW + +/build-steps/local-build-steps-windows.txt +/outputs +/godot-rj-nuget-package +/godot/modules/rokojori_action_library + diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..810e7d2 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "godot"] + path = godot + url = https://github.com/godotengine/godot.git +[submodule "rokojori-action-library"] + path = rokojori-action-library + url = git@community.rokojori.com:Rokojori/rj-action-library-cpp.git diff --git a/build-steps/build-steps-windows.txt b/build-steps/build-steps-windows.txt index 5831031..e80acaa 100644 --- a/build-steps/build-steps-windows.txt +++ b/build-steps/build-steps-windows.txt @@ -4,7 +4,12 @@ ================================================ -[ Build Cpp] +[ Copy C++] +cd {ROOT-PATH} +node copy-cpp-source.js + +[ Build C++ ] +cd {GODOT-EDITOR-PATH} "{SCONS-INSTALLATION-PATH}\scons" platform=windows module_mono_enabled=yes [ Create Mono Glue ] @@ -13,4 +18,8 @@ cd {GODOT-EDITOR-PATH} [ Build Assemblies ] cd {GODOT-EDITOR-PATH} -"modules/mono/build_scripts/build_assemblies.py" --godot-output-dir=./bin +"modules/mono/build_scripts/build_assemblies.py" --godot-output-dir=./bin --push-nupkgs-local "{ROOT-PATH}/godot-rj-nuget-package" + +[ Create Output Directory ] +cd {ROOT-PATH} +node create-output.js windows \ No newline at end of file diff --git a/copy-cpp-source.js b/copy-cpp-source.js new file mode 100644 index 0000000..f22d2de --- /dev/null +++ b/copy-cpp-source.js @@ -0,0 +1,88 @@ +const { spawn } = require("node:child_process"); +const fs = require( "node:fs/promises" ); +const path = require( "path" ); +const { loadJSON } = require( "./library.js" ); + +let from = "rokojori-action-library"; +let to = "godot/modules/rokojori_action_library" + +async function main() +{ + console.log( "Copying C++ source" ); + + await deleteOldDirectory(); + await copyToModules(); + // await runBuild(); + + console.log( "Copying C++ source" ); +} + +async function deleteOldDirectory() +{ + let stats = await fs.stat( to ); + + if ( stats ) + { + console.log( `deleting previous directory: "${to}"` ); + await fs.rm( to, { recursive: true } ); + } + + return Promise.resolve(); +} + +async function copyToModules() +{ + console.log( "copying:", `"${from}" >> "${to}"` ); + await fs.cp( from, to, { recursive : true } ); + + return Promise.resolve(); +} + +async function runBuild() +{ + let { exec } = require( "child_process"); + + let settingsFileName = "build-settings.json"; + + let settings = await loadJSON( "build-settings.json" ); + + if ( ! settings ) + { + console.error( `Build Settings missing... Add a json-file '${settingsFileName}' with a member 'sconsPath'` ) + return Promise.reject(); + } + + let command = `${settings.sconsPath}/scons platform=windows module_mono_enabled=yes`; + let executionDirectory = path.join( __dirname, "godot" ); + + let options = { cwd: executionDirectory }; + + console.log( "Starting build:", command, "Options:", JSON.stringify( options ) ); + let process = exec( command, options ); + + + process.stdout.on( "data", + ( data ) => + { + console.log( `${data}` ); + } + ); + + process.stderr.on( "data", + ( data ) => + { + console.error( `${data}` ); + } + ); + + process.on( "close", + ( code ) => + { + console.log( `child process exited with code ${code} `); + } + ); +} + + + +main(); \ No newline at end of file diff --git a/create-output.js b/create-output.js new file mode 100644 index 0000000..2b73642 --- /dev/null +++ b/create-output.js @@ -0,0 +1,90 @@ +const { argv } = require("process"); +const path = require( "path" ); +const fs = require( "node:fs/promises" ); +const { exists } = require( "./library.js" ); + +if ( argv.length !== 3 ) +{ + let platforms = [ "windows" ]; + + console.error( "Platform missing in the command. Add one of these to the command line:", platforms.join( ", " ) ); + + return; +} + +let targetDirectory = "outputs"; +let godotName = "godot-4.3-dev-rokojori"; +let platform = argv[ 2 ]; +let godotPlatformName = godotName + "-" + argv[ 2 ]; + +let platformTargetDirectory = path.join( targetDirectory, godotPlatformName ); + +async function main() +{ + console.log( "Creating output" ); + + await deleteOldDirectory(); + await createDirectory(); + + + console.log( "Output done" ); +} + + +async function deleteOldDirectory() +{ + + let directoryExists = await exists( platformTargetDirectory ); + + console.log( "checking if old directory exists", directoryExists ); + + if ( directoryExists ) + { + console.log( `deleting previous directory: "${platformTargetDirectory}"` ); + await fs.rm( platformTargetDirectory, { recursive: true } ); + } + + return Promise.resolve(); +} + +async function createDirectory() +{ + console.log( `creating directory: "${platformTargetDirectory}"` ); + await fs.mkdir( platformTargetDirectory, { recursive: true } ); + + + + let godotFrom = "godot/bin"; + let godotTo = path.join( platformTargetDirectory, "godot" ); + + console.log( `copying godot: "${godotFrom}" >> "${godotTo}"` ); + + await fs.cp( godotFrom, godotTo, { recursive : true } ); + + + + let npFrom = "godot-rj-nuget-package"; + let npTo = path.join( platformTargetDirectory, npFrom ); + + console.log( `copying nupkg: "${npFrom}" >> "${npTo}"` ); + + await fs.cp( npFrom, npTo, { recursive : true } ); + + + let installers = + { + "windows" : "install-godot-windows.bat" + }; + + let installer = installers[ platform ]; + let installFrom = "install-scripts/" + installer; + + let installTo = path.join( platformTargetDirectory, installer ); + + console.log( `copying installer: "${installFrom}" >> "${installTo}"` ); + + await fs.cp( installFrom, installTo, { recursive : true } ); +} + + +main(); diff --git a/godot b/godot new file mode 160000 index 0000000..11d3768 --- /dev/null +++ b/godot @@ -0,0 +1 @@ +Subproject commit 11d3768132582d192b8464769f26b493ae822321 diff --git a/install-scripts/install-godot-windows.bat b/install-scripts/install-godot-windows.bat new file mode 100644 index 0000000..8d096cb --- /dev/null +++ b/install-scripts/install-godot-windows.bat @@ -0,0 +1 @@ +dotnet nuget add source "godot-rj-nuget-package" --name RokojoriGodot \ No newline at end of file diff --git a/library.js b/library.js new file mode 100644 index 0000000..fabffe0 --- /dev/null +++ b/library.js @@ -0,0 +1,65 @@ +const { stat } = require("node:fs"); +const fs = require( "node:fs/promises" ); + +async function exists( filePath ) +{ + try + { + let stats = await fs.stat( filePath ); + let exists = stats !== undefined && stats !== null; + return Promise.resolve( exists ); + } + catch( e ) + { + + } + + return Promise.resolve( false ); +} + +async function loadUTF8( filePath ) +{ + try + { + let data = await fs.readFile( filePath ); + let stringData = data.toString(); + return Promise.resolve( stringData ); + } + catch ( exception ) + { + console.warn( exception ); + } + + return Promise.resolve( null ); + +} + +async function loadJSON( filePath ) +{ + let text = await loadUTF8( filePath ); + + if ( text === null ) + { + return Promise.resolve( null ); + } + + try + { + let jsonObject = JSON.parse( text ); + + return Promise.resolve( jsonObject ); + } + catch ( exception ) + { + console.warn( exception ); + } + + return Promise.resolve( null ); +} + +module.exports = +{ + exists, + loadUTF8, + loadJSON +} \ No newline at end of file diff --git a/rokojori-action-library b/rokojori-action-library new file mode 160000 index 0000000..88c864a --- /dev/null +++ b/rokojori-action-library @@ -0,0 +1 @@ +Subproject commit 88c864ac6a6c90d63774e8f7b13eb8dcb1db56e5