Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…issues) and fake, update to beta001
  • Loading branch information
matthid committed Jul 7, 2018
1 parent 8a75d8e commit 30c1db7
Show file tree
Hide file tree
Showing 13 changed files with 1,697 additions and 1,624 deletions.
50 changes: 35 additions & 15 deletions .paket/Paket.Restore.targets
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,26 @@
<!-- Step 1 Check if lockfile is properly restored -->
<PropertyGroup>
<PaketRestoreRequired>true</PaketRestoreRequired>
<NoWarn>$(NoWarn);NU1603</NoWarn>
<NoWarn>$(NoWarn);NU1603;NU1604;NU1605;NU1608</NoWarn>
</PropertyGroup>

<!-- Because ReadAllText is slow on osx/linux, try to find shasum and awk -->
<PropertyGroup>
<PaketRestoreCachedHasher Condition="'$(OS)' != 'Windows_NT' And '$(PaketRestoreCachedHasher)' == '' And Exists('/usr/bin/shasum') And Exists('/usr/bin/awk')">/usr/bin/shasum $(PaketRestoreCacheFile) | /usr/bin/awk '{ print $1 }'</PaketRestoreCachedHasher>
<PaketRestoreLockFileHasher Condition="'$(OS)' != 'Windows_NT' And '$(PaketRestoreLockFileHash)' == '' And Exists('/usr/bin/shasum') And Exists('/usr/bin/awk')">/usr/bin/shasum $(PaketLockFilePath) | /usr/bin/awk '{ print $1 }'</PaketRestoreLockFileHasher>
<PaketRestoreCachedHasher Condition="'$(OS)' != 'Windows_NT' And '$(PaketRestoreCachedHasher)' == '' And Exists('/usr/bin/shasum') And Exists('/usr/bin/awk')">/usr/bin/shasum "$(PaketRestoreCacheFile)" | /usr/bin/awk '{ print $1 }'</PaketRestoreCachedHasher>
<PaketRestoreLockFileHasher Condition="'$(OS)' != 'Windows_NT' And '$(PaketRestoreLockFileHash)' == '' And Exists('/usr/bin/shasum') And Exists('/usr/bin/awk')">/usr/bin/shasum "$(PaketLockFilePath)" | /usr/bin/awk '{ print $1 }'</PaketRestoreLockFileHasher>
</PropertyGroup>

<!-- If shasum and awk exist get the hashes -->
<Exec StandardOutputImportance="Low" Condition=" '$(PaketRestoreCachedHasher)' != '' " Command="$(PaketRestoreCachedHasher)" ConsoleToMSBuild='true'>
<Output TaskParameter="ConsoleOutput" PropertyName="PaketRestoreCachedHash" />
<Output TaskParameter="ConsoleOutput" PropertyName="PaketRestoreCachedHash" />
</Exec>
<Exec StandardOutputImportance="Low" Condition=" '$(PaketRestoreLockFileHasher)' != '' " Command="$(PaketRestoreLockFileHasher)" ConsoleToMSBuild='true'>
<Output TaskParameter="ConsoleOutput" PropertyName="PaketRestoreLockFileHash" />
<Output TaskParameter="ConsoleOutput" PropertyName="PaketRestoreLockFileHash" />
</Exec>

<!-- Debug whats going on -->
<Message Importance="low" Text="calling paket restore with targetframework=$(TargetFramework) targetframeworks=$(TargetFrameworks)" />

<PropertyGroup Condition="Exists('$(PaketRestoreCacheFile)') ">
<!-- if no hash has been done yet fall back to just reading in the files and comparing them -->
<PaketRestoreCachedHash Condition=" '$(PaketRestoreCachedHash)' == '' ">$([System.IO.File]::ReadAllText('$(PaketRestoreCacheFile)'))</PaketRestoreCachedHash>
Expand All @@ -69,11 +72,19 @@
<PaketRestoreRequired Condition=" '$(PaketRestoreLockFileHash)' == '' ">true</PaketRestoreRequired>
</PropertyGroup>


<!-- Do a global restore if required -->
<Exec Command='$(PaketBootStrapperCommand)' Condition="Exists('$(PaketBootStrapperExePath)') AND !(Exists('$(PaketExePath)'))" ContinueOnError="false" />
<Exec Command='$(PaketCommand) restore' Condition=" '$(PaketRestoreRequired)' == 'true' " ContinueOnError="false" />

<!-- Step 2 Detect project specific changes -->
<ItemGroup>
<MyTargetFrameworks Condition="'$(TargetFramework)' != '' " Include="$(TargetFramework)"></MyTargetFrameworks>
<!-- Don't include all frameworks when msbuild explicitly asks for a single one -->
<MyTargetFrameworks Condition="'$(TargetFrameworks)' != '' AND '$(TargetFramework)' == '' " Include="$(TargetFrameworks)"></MyTargetFrameworks>
<PaketResolvedFilePaths Include="@(MyTargetFrameworks -> '$(MSBuildProjectDirectory)\obj\$(MSBuildProjectFile).%(Identity).paket.resolved')"></PaketResolvedFilePaths>
</ItemGroup>
<Message Importance="low" Text="MyTargetFrameworks=@(MyTargetFrameworks) PaketResolvedFilePaths=@(PaketResolvedFilePaths)" />
<PropertyGroup>
<PaketReferencesCachedFilePath>$(MSBuildProjectDirectory)\obj\$(MSBuildProjectFile).paket.references.cached</PaketReferencesCachedFilePath>
<!-- MyProject.fsproj.paket.references has the highest precedence -->
Expand All @@ -82,7 +93,9 @@
<PaketOriginalReferencesFilePath Condition=" !Exists('$(PaketOriginalReferencesFilePath)')">$(MSBuildProjectDirectory)\$(MSBuildProjectName).paket.references</PaketOriginalReferencesFilePath>
<!-- paket.references -->
<PaketOriginalReferencesFilePath Condition=" !Exists('$(PaketOriginalReferencesFilePath)')">$(MSBuildProjectDirectory)\paket.references</PaketOriginalReferencesFilePath>
<PaketResolvedFilePath>$(MSBuildProjectDirectory)\obj\$(MSBuildProjectFile).$(TargetFramework).paket.resolved</PaketResolvedFilePath>

<DoAllResolvedFilesExist>false</DoAllResolvedFilesExist>
<DoAllResolvedFilesExist Condition="Exists(%(PaketResolvedFilePaths.Identity))">true</DoAllResolvedFilesExist>
<PaketRestoreRequired>true</PaketRestoreRequired>
<PaketRestoreRequiredReason>references-file-or-cache-not-found</PaketRestoreRequiredReason>
</PropertyGroup>
Expand All @@ -101,32 +114,39 @@
</PropertyGroup>

<!-- Step 2 b detect relevant changes in project file (new targetframework) -->
<PropertyGroup Condition=" !Exists('$(PaketResolvedFilePath)') AND '$(TargetFramework)' != '' ">
<PropertyGroup Condition=" '$(DoAllResolvedFilesExist)' != 'true' ">
<PaketRestoreRequired>true</PaketRestoreRequired>
<PaketRestoreRequiredReason>target-framework '$(TargetFramework)'</PaketRestoreRequiredReason>
<PaketRestoreRequiredReason>target-framework '$(TargetFramework)' or '$(TargetFrameworks)' files @(PaketResolvedFilePaths)</PaketRestoreRequiredReason>
</PropertyGroup>

<!-- Step 3 Restore project specific stuff if required -->
<Message Condition=" '$(PaketRestoreRequired)' == 'true' " Importance="low" Text="Detected a change ('$(PaketRestoreRequiredReason)') in the project file '$(MSBuildProjectFullPath)', calling paket restore" />
<Exec Command='$(PaketCommand) restore --project "$(MSBuildProjectFullPath)"' Condition=" '$(PaketRestoreRequired)' == 'true' " ContinueOnError="false" />
<Exec Command='$(PaketCommand) restore --project "$(MSBuildProjectFullPath)" --target-framework "$(TargetFrameworks)"' Condition=" '$(PaketRestoreRequired)' == 'true' AND '$(TargetFramework)' == '' " ContinueOnError="false" />
<Exec Command='$(PaketCommand) restore --project "$(MSBuildProjectFullPath)" --target-framework "$(TargetFramework)"' Condition=" '$(PaketRestoreRequired)' == 'true' AND '$(TargetFramework)' != '' " ContinueOnError="false" />

<!-- This shouldn't actually happen, but just to be sure. -->
<Error Condition=" !Exists('$(PaketResolvedFilePath)') AND '$(TargetFramework)' != '' AND '$(ResolveNuGetPackages)' != 'False' " Text="Paket file '$(PaketResolvedFilePath)' is missing while restoring $(MSBuildProjectFile). Please delete 'paket-files/paket.restore.cached' and call 'paket restore'." />
<PropertyGroup>
<DoAllResolvedFilesExist>false</DoAllResolvedFilesExist>
<DoAllResolvedFilesExist Condition="Exists(%(PaketResolvedFilePaths.Identity))">true</DoAllResolvedFilesExist>
</PropertyGroup>
<Error Condition=" '$(DoAllResolvedFilesExist)' != 'true' AND '$(ResolveNuGetPackages)' != 'False' " Text="One Paket file '@(PaketResolvedFilePaths)' is missing while restoring $(MSBuildProjectFile). Please delete 'paket-files/paket.restore.cached' and call 'paket restore'." />

<!-- Step 4 forward all msbuild properties (PackageReference, DotNetCliToolReference) to msbuild -->
<ReadLinesFromFile Condition="Exists('$(PaketResolvedFilePath)')" File="$(PaketResolvedFilePath)" >
<ReadLinesFromFile Condition="'@(PaketResolvedFilePaths)' != ''" File="%(PaketResolvedFilePaths.Identity)" ><!--Condition="Exists('%(PaketResolvedFilePaths.Identity)')"-->
<Output TaskParameter="Lines" ItemName="PaketReferencesFileLines"/>
</ReadLinesFromFile>

<ItemGroup Condition=" Exists('$(PaketResolvedFilePath)') AND '@(PaketReferencesFileLines)' != '' " >
<ItemGroup Condition=" '@(PaketReferencesFileLines)' != '' " >
<PaketReferencesFileLinesInfo Include="@(PaketReferencesFileLines)" >
<PackageName>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[0])</PackageName>
<PackageVersion>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[1])</PackageVersion>
<AllPrivateAssets>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[4])</AllPrivateAssets>
</PaketReferencesFileLinesInfo>
<PackageReference Include="%(PaketReferencesFileLinesInfo.PackageName)">
<Version>%(PaketReferencesFileLinesInfo.PackageVersion)</Version>
<PrivateAssets Condition="%(PaketReferencesFileLinesInfo.AllPrivateAssets) == 'true'">All</PrivateAssets>
<PrivateAssets Condition=" ('%(PaketReferencesFileLinesInfo.AllPrivateAssets)' == 'true') Or ('$(PackAsTool)' == 'true') ">All</PrivateAssets>
<ExcludeAssets Condition="%(PaketReferencesFileLinesInfo.AllPrivateAssets) == 'exclude'">runtime</ExcludeAssets>
<Publish Condition=" '$(PackAsTool)' == 'true' ">true</Publish>
</PackageReference>
</ItemGroup>

Expand Down Expand Up @@ -183,8 +203,8 @@

<ConvertToAbsolutePath Condition="@(_NuspecFiles) != ''" Paths="@(_NuspecFiles)">
<Output TaskParameter="AbsolutePaths" PropertyName="NuspecFileAbsolutePath" />
</ConvertToAbsolutePath>
</ConvertToAbsolutePath>


<!-- Call Pack -->
<PackTask Condition="$(UseNewPack)"
Expand Down
Binary file modified .paket/paket.exe
Binary file not shown.
6 changes: 4 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ If you use the library don't hesitate to let me know ;)
## Building

Requirements:
- Fake 5 (install via [chocolatey](https://chocolatey.org/packages/fake) `choco install fake --pre` or unzip [and add to path](https://github.com/fsharp/FAKE/releases))
- Fake 5 (install via [chocolatey](https://chocolatey.org/packages/fake) `choco install fake` or unzip [and add to path](https://github.com/fsharp/FAKE/releases))
- Install [Dotnet SDK 2](https://www.microsoft.com/net/download/core) (only required for running tests as of today)


Expand All @@ -97,6 +97,8 @@ Requirements:
Now the `release/nuget` folder contains the packages.

2. Run the test projects
- Download and extract the "Ladder 2017 Season 1" pack from https://github.com/Blizzard/s2client-proto

- `dotnet run --project src/s2client-testCSharp/s2client-testCSharp.csproj`
- `dotnet run --project src/s2client-test/s2client-test.csproj`
- `dotnet run --project src/s2client-test/s2client-test.fsproj`

78 changes: 28 additions & 50 deletions build.fsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
#if !DOTNETCORE
#I @"C:\Users\matth\.nuget\packages\FAKE\5.0.0-alpha018\tools"
#r @"FakeLib.dll"
#I @"C:\Users\matth\.nuget\packages\System.Net.Http\4.3.2\lib\net46"
#r "System.Net.Http.dll"
#I @"C:\Users\matth\.nuget\packages\Chessie\0.6.0\lib\net40"
#I @"C:\Users\matth\.nuget\packages\Paket.Core\5.92.100\lib\net45"
#r @"Chessie.dll"
#r @"Paket.Core.dll"
#endif
#load ".fake/build.fsx/intellisense.fsx"

open Paket
open System
open System.IO
open System.Reflection
open Fake.Core
open Fake.Api
open Fake.IO
open Fake.IO.FileSystemOperators
open Fake.Core.Globbing.Operators
open Fake.IO.Globbing.Operators
open Fake.DotNet
open Fake.Tools
let projectName = "s2client-dotnet"
Expand All @@ -25,7 +17,7 @@ let projectDescription = "s2client-dotnet - Starcraft 2 Client API for .NET - si

let authors = ["Matthias Dittrich"]

let release = ReleaseNotes.LoadReleaseNotes "docs/RELEASE_NOTES.md"
let release = ReleaseNotes.load "docs/RELEASE_NOTES.md"

let gitRaw = Environment.environVarOrDefault "gitRaw" "https://raw.github.com/matthid"

Expand All @@ -43,38 +35,26 @@ let gitHome = "https://github.com/" + gitOwner
let gitRepositoryUrl = gitHome + "/" + gitName

module PaketHelper =
open Paket
let getFolder root groupName (p : Paket.PackageResolver.PackageInfo) =
p.Folder root groupName

let cache = Paket.Constants.UserNuGetPackagesFolder
let deps = Paket.Dependencies.Locate()
let lock = deps.GetLockFile()

Target.Create "Clean" (fun _ ->
Target.create "Clean" (fun _ ->
!! "src/**/bin"
|> Shell.CleanDirs
|> Shell.cleanDirs

!! "src/**/obj"
|> Shell.CleanDirs
|> Shell.cleanDirs

Shell.CleanDirs [releaseNugetDir]
)
let Release_2_0_2 options =
{ options with
Cli.InstallerOptions = (fun io ->
{ io with
Branch = "release/2.0.0"
})
Cli.Channel = None
Cli.Version = Cli.Version "2.0.2"
}

Target.Create "InstallDotNetSdk" (fun _ ->
Cli.DotnetCliInstall Release_2_0_2
Shell.cleanDirs [releaseNugetDir]
)

Target.Create "DotnetPackage" (fun _ ->
let dotnetSdk = lazy DotNet.install DotNet.Release_2_1_300

Target.create "DotnetPackage" (fun _ ->

let nugetDir = System.IO.Path.GetFullPath releaseNugetDir

Expand All @@ -88,19 +68,19 @@ Target.Create "DotnetPackage" (fun _ ->
Environment.setEnvironVar "PackageLicenseUrl" (gitRepositoryUrl + "/blob/ae301a8af0b596b55b4d1f9a60e1197f66af9437/LICENSE.txt")

// dotnet pack
Cli.DotnetPack (fun c ->
DotNet.pack (fun c ->
{ c with
Configuration = Cli.Release
Configuration = DotNet.Release
OutputPath = Some nugetDir
}) "src/s2client-dotnet.sln"
} |> DotNet.Options.lift dotnetSdk.Value) "src/s2client-dotnet.sln"

!! (nugetDir + "/*.nupkg")
-- (nugetDir + "/s2client-dotnet*.nupkg")
-- (nugetDir + "/s2client-proto*.nupkg")
|> Seq.iter (Shell.rm_rf)
)

Target.Create "CreateProtobuf" (fun _ ->
Target.create "CreateProtobuf" (fun _ ->
let groupName = Paket.Constants.MainDependencyGroup
let packageName = Paket.Domain.PackageName "Google.Protobuf.Tools"
let group = lock.GetGroup(groupName)
Expand Down Expand Up @@ -128,7 +108,7 @@ Target.Create "CreateProtobuf" (fun _ ->
let protocArgs =
sprintf "%s %s %s" protoPathArgs csharpOpts protoArgs
let exitCode =
Process.ExecProcess (fun conf ->
Process.execSimple (fun conf ->
{ conf with
Arguments = protocArgs
FileName = protoTools @@ "tools/windows_x64/protoc.exe"})
Expand All @@ -138,21 +118,21 @@ Target.Create "CreateProtobuf" (fun _ ->
)


Target.Create "PublishNuget" (fun _ ->
Target.create "PublishNuget" (fun _ ->
// uses NugetKey environment variable.
// Timeout atm
Paket.Push(fun p ->
Paket.push(fun p ->
{ p with
DegreeOfParallelism = 2
WorkingDir = releaseNugetDir })
//!! (nugetLegacyDir </> "**/*.nupkg")
//|> Seq.iter nugetPush
)

Target.Create "FastRelease" (fun _ ->
Target.create "FastRelease" (fun _ ->

Git.Staging.StageAll ""
Git.Commit.Commit "" (sprintf "Bump version to %s" release.NugetVersion)
Git.Staging.stageAll ""
Git.Commit.exec "" (sprintf "Bump version to %s" release.NugetVersion)
let branch = Git.Information.getBranchName ""
Git.Branches.pushBranch "" "origin" branch

Expand All @@ -166,25 +146,23 @@ Target.Create "FastRelease" (fun _ ->

let files = !! (releaseNugetDir + "/*.nupkg")

GitHub.CreateClientWithToken token
|> GitHub.DraftNewRelease gitOwner gitName release.NugetVersion (release.SemVer.PreRelease <> None) release.Notes
|> GitHub.UploadFiles files
|> GitHub.PublishDraft
GitHub.createClientWithToken token
|> GitHub.draftNewRelease gitOwner gitName release.NugetVersion (release.SemVer.PreRelease <> None) release.Notes
|> GitHub.uploadFiles files
|> GitHub.publishDraft
|> Async.RunSynchronously
)

Target.Create "Default" ignore
Target.Create "Release" ignore
Target.create "Default" ignore
Target.create "Release" ignore

open Fake.Core.TargetOperators

"Clean" ==> "Default"
"InstallDotNetSdk" ==> "Default"
"CreateProtobuf" ==> "Default"
"DotnetPackage" ==> "Default"

"Clean"
?=> "InstallDotNetSdk"
?=> "DotnetPackage"
"Clean"
?=> "CreateProtobuf"
Expand All @@ -200,4 +178,4 @@ open Fake.Core.TargetOperators
"FastRelease"
==> "Release"

Target.RunOrDefault "Default"
Target.runOrDefault "Default"
3 changes: 3 additions & 0 deletions docs/RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#### 1.0.0-beta001 - 2018-07-07
* Update protobufs, fixes https://github.com/matthid/s2client-dotnet/issues/7

#### 1.0.0-alpha004 - 2018-03-11
* Static GameInfo data can now be accessed from the GameState - https://github.com/matthid/s2client-dotnet/pull/5

Expand Down
15 changes: 11 additions & 4 deletions external/s2client-proto/s2clientprotocol/data.proto
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ message AbilityData {
float footprint_radius = 13; // Estimation of the footprint size. Need a better footprint.
bool is_instant_placement = 14; // Placement next to an existing structure, e.g., an add-on like a Tech Lab.
float cast_range = 15; // Range unit can cast ability without needing to approach target.

}

enum Attribute {
Expand Down Expand Up @@ -82,14 +81,15 @@ message UnitTypeData {
uint32 vespene_cost = 13;
float food_required = 14;
float food_provided = 18;
uint32 ability_id = 15; // This is the ability the builds the unit
uint32 ability_id = 15; // The ability that builds this unit.
Race race = 16;
float build_time = 17;
bool has_vespene = 19;
bool has_minerals = 20;
float sight_range = 25; // Range unit reveals vision.

repeated uint32 tech_alias = 21; // Units this is equivalent to in terms of satisfying tech requirement.
uint32 unit_alias = 22; // Units that are morphed variants of the same unit.
repeated uint32 tech_alias = 21; // Other units that satisfy the same tech requirement.
uint32 unit_alias = 22; // The morphed variant of this unit.

uint32 tech_requirement = 23; // Structure required to build this unit. (Or any with the same tech_alias)
bool require_attached = 24; // Whether tech_requirement is an add-on.
Expand All @@ -114,3 +114,10 @@ message BuffData {
uint32 buff_id = 1; // Stable ID.
string name = 2;
}

message EffectData {
uint32 effect_id = 1; // Stable ID.
string name = 2;
string friendly_name = 3;
float radius = 4;
}
7 changes: 2 additions & 5 deletions external/s2client-proto/s2clientprotocol/debug.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ message DebugCommand {
DebugSetScore score = 6; // Useful only for single-player "curriculum" maps.
DebugEndGame end_game = 7;
DebugSetUnitValue unit_value = 8;
DebugChat chat = 9; // TODO.
}
}

Expand Down Expand Up @@ -44,6 +43,7 @@ message DebugText {
string text = 2; // Text to display.
Point virtual_pos = 3; // Virtualized position in 2D (the screen is 0..1, 0..1 for any resolution).
Point world_pos = 4; // Position in the world.
uint32 size = 5; // Pixel height of the text. Defaults to 8px.
}

// Display debug lines on screen.
Expand Down Expand Up @@ -95,7 +95,7 @@ message DebugKillUnit {

message DebugTestProcess {
enum Test {
UNSET = 0;
Test_UNSET = 0;
hang = 1;
crash = 2;
exit = 3;
Expand Down Expand Up @@ -129,6 +129,3 @@ message DebugSetUnitValue {
uint64 unit_tag = 3;
}

message DebugChat {
string message = 1;
}
Loading

0 comments on commit 30c1db7

Please sign in to comment.