From 76f3c26714c4b366f36c05cf0cbbf1fa7bdab329 Mon Sep 17 00:00:00 2001 From: onefang Date: Sat, 4 Sep 2021 12:20:46 +1000 Subject: Self build, part 1 - build opensim-SC if it doesn't exist. --- src/sledjchisl/sledjchisl.c | 358 ++++++++++++++++++++++++-------------------- 1 file changed, 193 insertions(+), 165 deletions(-) diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c index aa40936..a869647 100644 --- a/src/sledjchisl/sledjchisl.c +++ b/src/sledjchisl/sledjchisl.c @@ -1250,6 +1250,184 @@ struct _simList }; simList *ourSims = NULL; +static void copyOpenSim(char *t) +{ + if (shellMeFail("rm -fr ", t)) E("Failed to rm!"); + if ((! qfile_exist(t)) && (! qfile_mkdir(t, S_IRWXU | S_IRGRP | S_IXGRP, true))) C("Unable to create path %s", t); +// TODO - have to make sure it's all owned by opensimsc. + if (shellMeFail("cd %s; cp -al %s/current/* -t %s ", scRoot, scRoot, t)) C("Failed to cp!"); + if (shellMeFail("cd %s; cp -al %s/current/.??* -t %s ", scRoot, scRoot, t)) C("Failed to cp!"); +} + +static void buildOpensim() +{ + char *t = xmprintf("%s/current_NEW", scRoot); + + I("Building opensim-SC in %s", t); + copyOpenSim(t); + + if (shellMeFail("chmod -R a+x %s/*.sh", t)) C("Can't set proper permissions for %s/*.sh", t); + if (shellMeFail("chmod -R a+x %s/scripts/*.sh", t)) C("Can't set proper permissions for %s/scripts/*.sh", t); + if (shellMeFail("chmod -R a+x %s/scripts/install/*.sh", t)) C("Can't set proper permissions for %s/scripts/install/*.sh", t); + if (shellMeFail("chmod a+x %s/scripts/show-console", t)) C("Can't set proper permissions for %s/scripts/show-console", t); + if (shellMeFail("chmod a+x %s/scripts/start-sim", t)) C("Can't set proper permissions for %s/scripts/start-sim", t); + +/* +# Poor mans git sub modules / subtrees, coz otherwise it gets complex. +#if [ ! -d git-sub-modules/opensim-moneymodule-gloebit ]; then +# pushd git-sub-modules >/dev/null +# git clone https://github.com/gloebit/opensim-moneymodule-gloebit.git +# popd >/dev/null +#else +# pushd git-sub-modules/opensim-moneymodule-gloebit >/dev/null +# git pull +# popd >/dev/null +#fi +#rm -rf addon-modules/Gloebit/GloebitMoneyModule +#cp -r git-sub-modules/opensim-moneymodule-gloebit/addon-modules/Gloebit/GloebitMoneyModule addon-modules/Gloebit/ +*/ + if (shellMeFail("cd %s; ./runprebuild.sh autoclean | grep -v '...Cleaning project:'", t)) E("Failed to autoclean!"); + // Clean the stuff autoclean forgets to clean. I feel so dirty. + if (shellMeFail("cd %s; find -name obj -type d -print | xargs /bin/rm -fr", t)) E("Failed to rm obj!"); + if (shellMeFail("cd %s; find -name *.csproj -type f -print | xargs /bin/rm -fr", t)) E("Failed to rm obj!"); + if (shellMeFail("cd %s; find -name *.csproj.* -type f -print | xargs /bin/rm -fr", t)) E("Failed to rm obj!"); + if (shellMeFail("cd %s; find -name *.pdb -type f -print | xargs /bin/rm -fr", t)) E("Failed to rm obj!"); + if (shellMeFail("cd %s; rm -fr bin/ScriptEngines", t)) E("Failed to rm ScriptEngines!"); + // Clean the stuff the tests created. + if (shellMeFail("cd %s; rm Test*.txt", t)) E("Failed to Test results!"); +/* +# Prebuild converts Microsoft.CSharp.targets to Microsoft.CSHARP.Targets, which case sensitive file systems fail to find. +#find -name *.csproj | xargs sed -i "s@Microsoft.CSHARP.Targets@Microsoft.CSharp.targets@g" + +# Debian no longer provides nant. +#./nant-color + +if [ "4" == $(mono -V | head -n 1 | cut -d ' ' -f 5 | cut -d '.' -f 1) ]; then + export XBUILD_COLORS=errors=brightred,warnings=yellow,events=blue + xbuild /target:clean + xbuild /p:TargetFrameworkVersion="v4.5"xbuild /p:TargetFrameworkVersion="v4.5" +else + # Use this for Mono 5 and later. + msbuild /p:Configuration=Release +# msbuild /p:Configuration=Debug +fi +*/ + // Use this for Mono 5 and later. + if (shellMeFail("cd %s; ./runprebuild.sh vs2015 | grep -v '...Creating project:'", t)) C("Failed to prebuild!"); + // msbuild has a /maxcpucount option, but it takes longer to count the CPUs than it takes to compile, so ends up taking MORE time. Pffft. + if (shellMeFail("cd %s; msbuild /p:Configuration=Debug /verbosity:minimal", t)) C("Failed to msbuild!"); +// if (shellMeFail("cd %s; msbuild /p:Configuration=Release /verbosity:minimal", t)) C("Failed to msbuild!"); +// #cp -f addon-modules/Gloebit/GloebitMoneyModule/bin/Gloebit.dll bin + if (shellMeFail("cd %s/src; ./BuildIt.sh", t)) C("Failed to compile sledjchisl!"); + free(t); + t = xmprintf("%s/current", scRoot); + if (readlink0(t, toybuf, sizeof(toybuf))) + { + I("Making a backup of %s", toybuf); + if (shellMeFail("rm -fr %s_BACKUP", toybuf)) W("Failed to remove old backup."); + if (shellMeFail("mv %s %s_BACKUP", toybuf, toybuf)) C("Failed to create backup!"); + } + free(t); + snprintf(toybuf, sizeof(toybuf), "%s/current", scRoot); + t = xmprintf("%s/current_NEW", scRoot); + if (shellMeFail("rm -fr %s", toybuf)) C("Failed to remove old symlink."); + if (0 != symlink(t, toybuf)) perror_msg("Symlinking %s to %s", t, toybuf); + I("Done building opensim-SC in %s", t); + free(t); +} + +static void runTests(char *tests[], char *title, char* file) +{ + char *t = "export MONO_THREADS_PER_CPU=100;"; + int i = 0; + + // For printing out line numbers use "exec /usr/bin/cli --debug /usr/lib/nunit/nunit-console.exe" instead of "nunit-console". + if (FLAG(v)) + snprintf(toybuf, sizeof(toybuf), "echo '%s tests.'; cd %s; %s exec /usr/bin/cli --debug /usr/lib/nunit/nunit-console.exe ", title, scTemp, t); + else + snprintf(toybuf, sizeof(toybuf), "echo '%s tests.'; cd %s; %s nunit-console ", title, scTemp, t); + while(NULL != tests[i]) + { + t = xmprintf("%s/current/bin/%s.dll ", scRoot, tests[i++]); + strcat(toybuf, t); + free(t); + } + t = xmprintf("-nologo -output=Test%sOutput.txt -err=Test%sError.txt -labels -noxml ", file, file); + strcat(toybuf, t); + free(t); + I(toybuf); + shellMe(toybuf); +} +static void testOpenSim(simData *simd, char *sim, char *type, int count, int window, int panes, int pane) +{ + char *t = xmprintf("%s/../db", scTemp); + + if ((! qfile_exist(t)) && (! qfile_mkdir(t, S_IRWXU | S_IRGRP | S_IXGRP, true))) C("Unable to create path %s", t); + free(t); + char *standard0[] = + { + "OpenSim.Tests", + "OpenSim.Framework.Tests", + "OpenSim.Framework.Servers.Tests", + "OpenSim.Framework.Serialization.Tests", + "OpenSim.Region.ClientStack.LindenCaps.Tests", + "OpenSim.Region.ClientStack.LindenUDP.Tests", + "OpenSim.Region.ScriptEngine.Tests", + "OpenSim.Region.CoreModules.Tests", + "OpenSim.Region.Framework.Tests", + NULL + }; + runTests(standard0, "Standard", ""); + char *SQL[] = + { + "OpenSim.Data.Tests", + NULL + }; + runTests(SQL, "SQL", "SQL"); + char *standard1[] = + { + "OpenSim.Capabilities.Handlers.Tests", + "OpenSim.Server.Handlers.Tests", + "OpenSim.Services.InventoryService.Tests", + "OpenSim.Tests.Permissions", // Naturally OpenSim can't be consistent. + NULL + }; + runTests(standard1, "Standard part 2", "1"); + char *Physics[] = + { + "OpenSim.Region.PhysicsModule.BulletS.Tests", + "OpenSim.Region.PhysicsModule.Ode.Tests", + NULL + }; + runTests(Physics, "Physics", "Physics"); + char *Stress[] = + { + "OpenSim.Tests.Stress", + NULL + }; + runTests(Stress, "Stress", "Stress"); + char *Performance[] = + { + "OpenSim.Tests.Performance", + NULL + }; + runTests(Performance, "Performance", "Perf"); + char *Optional[] = + { + "OpenSim.Region.OptionalModules", + NULL + }; + runTests(Optional, "Optional", "Opt"); + char *Robust[] = + { + "Robust.Tests", + NULL + }; + runTests(Robust, "Robust", "Robust"); +} + + + static int getIntFromIni(qlisttbl_t *ini, char *name) { @@ -1915,6 +2093,10 @@ void startSim(simData *simd, char *sim, char *type, int count, int window, int p { if (!checkSimIsRunning(simd->tab)) { + // If OpenSim.exe doesn't exist, start a BUILD. + snprintf(toybuf, sizeof(toybuf), "%s/current/bin/OpenSim.exe", scRoot); + if (! qfile_exist(toybuf)) + buildOpensim(); I("Tmux tab [%d:%s](pane %d) tmux ID %s, from %s/sim%d - %s is starting.", window, type, pane, simd->paneID, scTemp, count, simd->name); // NOTE - earlier versions of tmux that are still in use don't have the '-T pane title' option, so do it with a printf command. // doTmuxCmd("select-pane -t %s:%s -T '%s'", Tconsole, simd->paneID, simd->tab); @@ -2018,104 +2200,6 @@ static int filterARs(struct dirtree *node) return 0; } -static void copyOpenSim(char *t) -{ - if (shellMeFail("rm -fr ", t)) E("Failed to rm!"); - if ((! qfile_exist(t)) && (! qfile_mkdir(t, S_IRWXU | S_IRGRP | S_IXGRP, true))) C("Unable to create path %s", t); -// TODO - have to make sure it's all owned by opensimsc. - if (shellMeFail("cd %s; cp -al %s/current/* -t %s ", scRoot, scRoot, t)) C("Failed to cp!"); - if (shellMeFail("cd %s; cp -al %s/current/.??* -t %s ", scRoot, scRoot, t)) C("Failed to cp!"); -} - -static void runTests(char *tests[], char *title, char* file) -{ - char *t = "export MONO_THREADS_PER_CPU=100;"; - int i = 0; - - // For printing out line numbers use "exec /usr/bin/cli --debug /usr/lib/nunit/nunit-console.exe" instead of "nunit-console". - if (FLAG(v)) - snprintf(toybuf, sizeof(toybuf), "echo '%s tests.'; cd %s; %s exec /usr/bin/cli --debug /usr/lib/nunit/nunit-console.exe ", title, scTemp, t); - else - snprintf(toybuf, sizeof(toybuf), "echo '%s tests.'; cd %s; %s nunit-console ", title, scTemp, t); - while(NULL != tests[i]) - { - t = xmprintf("%s/current/bin/%s.dll ", scRoot, tests[i++]); - strcat(toybuf, t); - free(t); - } - t = xmprintf("-nologo -output=Test%sOutput.txt -err=Test%sError.txt -labels -noxml ", file, file); - strcat(toybuf, t); - free(t); - I(toybuf); - shellMe(toybuf); -} -static void testOpenSim(simData *simd, char *sim, char *type, int count, int window, int panes, int pane) -{ - char *t = xmprintf("%s/../db", scTemp); - - if ((! qfile_exist(t)) && (! qfile_mkdir(t, S_IRWXU | S_IRGRP | S_IXGRP, true))) C("Unable to create path %s", t); - free(t); - char *standard0[] = - { - "OpenSim.Tests", - "OpenSim.Framework.Tests", - "OpenSim.Framework.Servers.Tests", - "OpenSim.Framework.Serialization.Tests", - "OpenSim.Region.ClientStack.LindenCaps.Tests", - "OpenSim.Region.ClientStack.LindenUDP.Tests", - "OpenSim.Region.ScriptEngine.Tests", - "OpenSim.Region.CoreModules.Tests", - "OpenSim.Region.Framework.Tests", - NULL - }; - runTests(standard0, "Standard", ""); - char *SQL[] = - { - "OpenSim.Data.Tests", - NULL - }; - runTests(SQL, "SQL", "SQL"); - char *standard1[] = - { - "OpenSim.Capabilities.Handlers.Tests", - "OpenSim.Server.Handlers.Tests", - "OpenSim.Services.InventoryService.Tests", - "OpenSim.Tests.Permissions", // Naturally OpenSim can't be consistent. - NULL - }; - runTests(standard1, "Standard part 2", "1"); - char *Physics[] = - { - "OpenSim.Region.PhysicsModule.BulletS.Tests", - "OpenSim.Region.PhysicsModule.Ode.Tests", - NULL - }; - runTests(Physics, "Physics", "Physics"); - char *Stress[] = - { - "OpenSim.Tests.Stress", - NULL - }; - runTests(Stress, "Stress", "Stress"); - char *Performance[] = - { - "OpenSim.Tests.Performance", - NULL - }; - runTests(Performance, "Performance", "Perf"); - char *Optional[] = - { - "OpenSim.Region.OptionalModules", - NULL - }; - runTests(Optional, "Optional", "Opt"); - char *Robust[] = - { - "Robust.Tests", - NULL - }; - runTests(Robust, "Robust", "Robust"); -} // Forward declare this. my_ulonglong dbCount(char *table, char *where); @@ -8656,72 +8740,7 @@ Create the /opt/opensim-SC directory structure. //////////////////////////////////////////////////////////////////////////////////////////////////// if (BUILD == currentMode) { - char *t = xmprintf("%s/current_NEW", scRoot); - - I("Building opensim-SC."); - copyOpenSim(t); - - if (shellMeFail("chmod -R a+x %s/*.sh", t)) C("Can't set proper permissions for %s/*.sh", t); - if (shellMeFail("chmod -R a+x %s/scripts/*.sh", t)) C("Can't set proper permissions for %s/scripts/*.sh", t); - if (shellMeFail("chmod -R a+x %s/scripts/install/*.sh", t)) C("Can't set proper permissions for %s/scripts/install/*.sh", t); - if (shellMeFail("chmod a+x %s/scripts/show-console", t)) C("Can't set proper permissions for %s/scripts/show-console", t); - if (shellMeFail("chmod a+x %s/scripts/start-sim", t)) C("Can't set proper permissions for %s/scripts/start-sim", t); - -/* -# Poor mans git sub modules / subtrees, coz otherwise it gets complex. -#if [ ! -d git-sub-modules/opensim-moneymodule-gloebit ]; then -# pushd git-sub-modules >/dev/null -# git clone https://github.com/gloebit/opensim-moneymodule-gloebit.git -# popd >/dev/null -#else -# pushd git-sub-modules/opensim-moneymodule-gloebit >/dev/null -# git pull -# popd >/dev/null -#fi -#rm -rf addon-modules/Gloebit/GloebitMoneyModule -#cp -r git-sub-modules/opensim-moneymodule-gloebit/addon-modules/Gloebit/GloebitMoneyModule addon-modules/Gloebit/ -*/ - if (shellMeFail("cd %s; ./runprebuild.sh autoclean | grep -v '...Cleaning project:'", t)) E("Failed to autoclean!"); - // Clean the stuff autoclean forgets to clean. I feel so dirty. - if (shellMeFail("cd %s; find -name obj -type d -print | xargs /bin/rm -fr", t)) E("Failed to rm obj!"); - if (shellMeFail("cd %s; find -name *.csproj -type f -print | xargs /bin/rm -fr", t)) E("Failed to rm obj!"); - if (shellMeFail("cd %s; find -name *.csproj.* -type f -print | xargs /bin/rm -fr", t)) E("Failed to rm obj!"); - if (shellMeFail("cd %s; find -name *.pdb -type f -print | xargs /bin/rm -fr", t)) E("Failed to rm obj!"); - if (shellMeFail("cd %s; rm -fr bin/ScriptEngines", t)) E("Failed to rm ScriptEngines!"); - // Clean the stuff the tests created. - if (shellMeFail("cd %s; rm Test*.txt", t)) E("Failed to Test results!"); -/* -# Prebuild converts Microsoft.CSharp.targets to Microsoft.CSHARP.Targets, which case sensitive file systems fail to find. -#find -name *.csproj | xargs sed -i "s@Microsoft.CSHARP.Targets@Microsoft.CSharp.targets@g" - -# Debian no longer provides nant. -#./nant-color - -if [ "4" == $(mono -V | head -n 1 | cut -d ' ' -f 5 | cut -d '.' -f 1) ]; then - export XBUILD_COLORS=errors=brightred,warnings=yellow,events=blue - xbuild /target:clean - xbuild /p:TargetFrameworkVersion="v4.5"xbuild /p:TargetFrameworkVersion="v4.5" -else - # Use this for Mono 5 and later. - msbuild /p:Configuration=Release -# msbuild /p:Configuration=Debug -fi -*/ - // Use this for Mono 5 and later. - if (shellMeFail("cd %s; ./runprebuild.sh vs2015 | grep -v '...Creating project:'", t)) C("Failed to prebuild!"); - // msbuild has a /maxcpucount option, but it takes longer to count the CPUs than it takes to compile, so ends up taking MORE time. Pffft. - if (shellMeFail("cd %s; msbuild /p:Configuration=Debug /verbosity:minimal", t)) C("Failed to msbuild!"); -// if (shellMeFail("cd %s; msbuild /p:Configuration=Release /verbosity:minimal", t)) C("Failed to msbuild!"); -// #cp -f addon-modules/Gloebit/GloebitMoneyModule/bin/Gloebit.dll bin - if (shellMeFail("cd %s/src; ./BuildIt.sh", t)) C("Failed to compile sledjchisl!"); -/* TODO - - figure out what current symlink currently points to - delete that_BACKUP - copy that to that_BACKUP - point the symlink to this -*/ - free(t); - I("Done building opensim-SC."); + buildOpensim(); goto finished; } } @@ -8866,7 +8885,16 @@ fi // Start ROBUST or join the tmux session, or just figure out where the sims are running in tmux. if ((START == currentMode) && !checkSimIsRunning("ROBUST")) { - char *c = xmprintf("cd %s", scRoot); + char *c = xmprintf("%s/current/bin/Robust.exe", scRoot); + + // If Robust.exe doesn't exist, start a BUILD. + if (! qfile_exist(c)) + { + W("Need to build Robust.exe."); + buildOpensim(); + } + free(c); + c = xmprintf("cd %s", scRoot); I("ROBUST is starting up."); sendTmuxCmd("@0.%1", c); free(c); -- cgit v1.1