forked from Tzarnal/New-Promotion-Screen-by-Default
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit '006dc256ca772ed837496f81b55d15038924b679' as '.scripts/…
…X2ModBuildCommon'
- Loading branch information
Showing
9 changed files
with
2,069 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
## Next | ||
|
||
## 1.1.1 (2021-08-11) | ||
|
||
* Support Rebuild ModBuddy target | ||
* Internal improvements and fixes to asset cooking functionality | ||
* Support projects with spaces in path (#55) | ||
* Fix cryptic error about `SteamPublishID` for some projects (#56) | ||
* Fail the build in case cooking cleanup fails, preventing silent SDK corruption (#54) | ||
* Properly rewrite error messages originating from `IncludeSrc`-ed files (#45) | ||
|
||
|
||
## 1.1.0 (2021-06-15) | ||
|
||
* Remove compiled script packages when switching between debug and release mode to prevent compiler error (#16) | ||
* Remove compiled script packages when modifying macros (#20) | ||
* Overridden Steam UGC IDs can now be `long` (`int64`) (#22) | ||
* Use error syntax `file(line)` for compiler errors to be compatible with both ModBuddy and VS Code (#26) | ||
* Add a `clean.ps1` script, ModBuddy configuration and VS Code example task to remove all cached build artifacts (#24) | ||
* Remove project file verification. Consider using [Xymanek/X2ProjectGenerator](https://github.com/Xymanek/X2ProjectGenerator) instead (#28) | ||
* Catch macro name clashes through `extra_globals.uci` (#30) | ||
* Add debugging option to profile build times (#35) | ||
|
||
## 1.0.0 (2021-05-22) | ||
|
||
* Initial release |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
using System; | ||
using System.IO; | ||
using System.Threading; | ||
using System.Management.Automation; | ||
|
||
using Microsoft.Build.Framework; | ||
using Microsoft.Build.Utilities; | ||
|
||
public class InvokePowershellTask : Task, ICancelableTask | ||
{ | ||
[Required] public string EntryPs1 { get; set; } | ||
[Required] public string SolutionRoot { get; set; } | ||
[Required] public string SdkInstallPath { get; set; } | ||
[Required] public string GameInstallPath { get; set; } | ||
[Required] public ITaskItem[] AdditionalArgs { get; set; } | ||
|
||
private PowerShell _ps; | ||
|
||
private ManualResetEventSlim _startingMre = new ManualResetEventSlim(false); | ||
|
||
public override bool Execute() | ||
{ | ||
bool isSuccess = false; | ||
|
||
try | ||
{ | ||
_ps = PowerShell.Create(); | ||
|
||
_ps | ||
.AddCommand("Set-ExecutionPolicy") | ||
.AddArgument("Unrestricted") | ||
.AddParameter("Scope","CurrentUser"); | ||
|
||
_ps | ||
.AddStatement() | ||
.AddCommand(EntryPs1) | ||
.AddParameter("srcDirectory", TrimEndingDirectorySeparator(SolutionRoot)) | ||
.AddParameter("sdkPath", TrimEndingDirectorySeparator(SdkInstallPath)) | ||
.AddParameter("gamePath", TrimEndingDirectorySeparator(GameInstallPath)); | ||
|
||
foreach (ITaskItem Arg in AdditionalArgs) | ||
{ | ||
string Val = Arg.GetMetadata("Value"); | ||
if (string.IsNullOrEmpty(Val)) | ||
{ | ||
_ps.AddParameter(Arg.ItemSpec); | ||
} | ||
else | ||
{ | ||
_ps.AddParameter(Arg.ItemSpec, Val); | ||
} | ||
} | ||
|
||
BindStreamEntryCallback(_ps.Streams.Debug, record => LogOutput(record.ToString())); | ||
BindStreamEntryCallback(_ps.Streams.Information, record => LogOutput(record.ToString())); | ||
BindStreamEntryCallback(_ps.Streams.Verbose, record => LogOutput(record.ToString())); | ||
BindStreamEntryCallback(_ps.Streams.Warning, record => LogOutput(record.ToString())); // TODO: More flashy output? | ||
|
||
BindStreamEntryCallback(_ps.Streams.Error, record => | ||
{ | ||
// TODO: Less info than when from console | ||
// TODO: More flashy output? | ||
LogOutput(record.ToString()); | ||
Log.LogError(record.ToString()); | ||
isSuccess = false; | ||
}); | ||
|
||
_ps.InvocationStateChanged += (sender, args) => | ||
{ | ||
if (args.InvocationStateInfo.State == PSInvocationState.Running) | ||
{ | ||
_startingMre.Set(); | ||
} | ||
}; | ||
|
||
isSuccess = true; | ||
_ps.Invoke(); | ||
} | ||
catch (System.Exception e) | ||
{ | ||
Log.LogError(e.Message); | ||
isSuccess = false; | ||
} | ||
|
||
return isSuccess; | ||
} | ||
|
||
public void Cancel() | ||
{ | ||
// Log.LogMessage(MessageImportance.High, "Got cancel"); | ||
|
||
// Do not call Stop() until we know that we've actually started | ||
// This could be more elaborate, but the time interval between Execute() and Invoke() being called is extremely small | ||
|
||
_startingMre.Wait(); | ||
_ps.Stop(); | ||
} | ||
|
||
private void LogOutput (string output) | ||
{ | ||
// This is required to keep the empty lines in the output | ||
if (string.IsNullOrEmpty(output)) output = " "; | ||
|
||
Log.LogMessage(MessageImportance.High, output); | ||
} | ||
|
||
private static readonly char[] DirectorySeparatorsForTrimming = new char[] | ||
{ | ||
Path.DirectorySeparatorChar, | ||
Path.AltDirectorySeparatorChar | ||
}; | ||
|
||
private static string TrimEndingDirectorySeparator(string path) | ||
{ | ||
return path.TrimEnd(DirectorySeparatorsForTrimming); | ||
} | ||
|
||
private static void BindStreamEntryCallback<T>(PSDataCollection<T> stream, Action<T> handler) | ||
{ | ||
stream.DataAdded += (object sender, DataAddedEventArgs e) => handler(stream[e.Index]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 X2CommunityCore | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Oops, something went wrong.