Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scripts to build from Windows and Linux #114

Merged
merged 16 commits into from
May 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion OpenKh.Command.HdAssets/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace OpenKh.Command.HdAssets
{
[Command("OpenKh.Command.IdxImg")]
[Command("OpenKh.Command.HdAsset")]
[VersionOptionFromMember("--version", MemberName = nameof(GetVersion))]
[Subcommand(
typeof(ExtractCommand),
Expand Down
1 change: 1 addition & 0 deletions OpenKh.Tests/OpenKh.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<TargetFramework>netcoreapp3.1</TargetFramework>

<IsPackable>false</IsPackable>
<IsPublishable>false</IsPublishable>

<AssemblyName>OpenKh.Tests</AssemblyName>
<RootNamespace>OpenKh.Tests</RootNamespace>
Expand Down
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
<img src="./images/OpenKH.png" width="540">
</p>

This is a project aiming to centralize all the technical knowledge of the 'Kingdom Hearts' game series in one place, providing documentation, tools, code libraries, and the foundation for modding the commercial games.
Aims to centralize all the technical knowledge of the 'Kingdom Hearts' game series in one place, providing documentation, tools, code libraries, and the foundation for modding the commercial games.

[![Build Status](https://dev.azure.com/xeeynamo/OpenKH/_apis/build/status/Xeeynamo.OpenKh?branchName=master) ![Tests](https://img.shields.io/azure-devops/tests/xeeynamo/OpenKh/4) ![Coverage](https://img.shields.io/azure-devops/coverage/xeeynamo/OpenKh/4)](https://dev.azure.com/xeeynamo/OpenKH/_build/latest?definitionId=4&branchName=master)


## Documentation

All the documentation is located in the `/docs` folder in its raw form. A more web-friendly version can be accessed at: https://openkh.dev/
Expand All @@ -19,7 +18,11 @@ New builds of OpenKH are automatically generated every time one of the contribut

All the builds from `master` and from pull requestes are generated from [Azure Pipelines](https://dev.azure.com/xeeynamo/OpenKH/_build).

OpenKH tools require the instllation of the [Desktop Runtime 3.1.x](https://dotnet.microsoft.com/download/dotnet-core/3.1) to run all the UI applications on Windows, or [.NET Core Runtime 3.1.x](https://dotnet.microsoft.com/download/dotnet-core/3.1) to run the CLI tools on Linux and macOS.
OpenKH tools require the instllation of the [.NET Core 3.1 Runtime](https://dotnet.microsoft.com/download/dotnet-core/3.1/runtime). All the UI tools are designed to work on Windows, while command line tools will work on any operating system.

## Build from source code

The minimum requirement is [.NET Core 3.1.x](https://dotnet.microsoft.com/download/dotnet-core/3.1). Once the repository is downloaded, `build.ps1` or `build.sh` needs be executed based from the operating system in use. That is all.

## Additional info

Expand All @@ -31,19 +34,17 @@ OpenKH tools require the instllation of the [Desktop Runtime 3.1.x](https://dotn
* Create a community site and forum where users can openly interact with and help one another with modifications using OpenKH tools and documentation.
* Create a custom game engine that is compatible with assets from the retail games.


### Contribution

There is a [guide](CONTRIBUTING.md) describing how to contact the team and contribute to the project.


### License

The entire content of the repository is protected by the GPLv3 license. Some of the key points of the license are:

- You **can** copy, modify, and distribute the software.
- You **must** include the license and copyright notice with each and every distribution.
- You **can** use this software privately.
- You **can** use this software for commercial purposes.
- If you modify it, you **must** indicate changes made to the code.
- Any modifications of this code base **ABSOLUTELY MUST** be distributed with the same license, GPLv3.
* You **can** copy, modify, and distribute the software.
* You **must** include the license and copyright notice with each and every distribution.
* You **can** use this software privately.
* You **can** use this software for commercial purposes.
* If you modify it, you **must** indicate changes made to the code.
* Any modifications of this code base **ABSOLUTELY MUST** be distributed with the same license, GPLv3.
71 changes: 26 additions & 45 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,6 @@ steps:
- powershell: .\pre-build.ps1
displayName: 'Build tools and libraries metadata'

- task: VSBuild@1
displayName: 'Build project'
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
vsVersion: 'latest'
msbuildArgs: '/t:Build'
maximumCpuCount: true

- script: dotnet test --configuration $(buildConfiguration) --logger trx --verbosity normal --collect "Code coverage"
displayName: 'Run tests'

Expand All @@ -62,44 +52,35 @@ steps:
inputs:
summaryFileLocation: '**/*.coverage'

- powershell: gci env:* | sort-object name | Format-Table -AutoSize | Out-File $env:BUILD_ARTIFACTSTAGINGDIRECTORY/environment-variables.txt
displayName: 'List artifacts to publish'

- task: CopyFiles@2
displayName: 'Pack .Net Framework 4 tools and libraries'
inputs:
sourceFolder: '$(Build.SourcesDirectory)'
contents: |
OpenKh*/**/$(BuildConfiguration)/net4**/**/?(*.exe|*.dll|*.json|*.config)
targetFolder: '$(Build.ArtifactStagingDirectory)/net4'
flattenFolders: true

- task: CopyFiles@2
displayName: 'Pack .Net Framework 4 resources'
- task: VSBuild@1
displayName: 'Build project'
inputs:
sourceFolder: '$(Build.SourcesDirectory)'
contents: |
OpenKh*/**/$(BuildConfiguration)/net4**/**/resources/**
targetFolder: '$(Build.ArtifactStagingDirectory)/net4/resources'
flattenFolders: true

- task: CopyFiles@2
displayName: 'Pack .Net Core tools and libraries'
solution: '**/OpenKh.Command.*.csproj'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
vsVersion: 'latest'
msbuildArgs: '/t:Build /p:DebugType=None /p:DebugSymbols=false /p:OutputPath=$(Build.ArtifactStagingDirectory)'
maximumCpuCount: true

- task: VSBuild@1
displayName: 'Build project'
inputs:
sourceFolder: '$(Build.SourcesDirectory)'
contents: |
OpenKh*/**/$(BuildConfiguration)/netcoreapp**/**/?(*.exe|*.dll|*.json|*.config)
targetFolder: '$(Build.ArtifactStagingDirectory)/netcore'
flattenFolders: true

- task: CopyFiles@2
displayName: 'Pack .Net Core resources'
solution: '**/OpenKh.Tools.*.csproj'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
vsVersion: 'latest'
msbuildArgs: '/t:Build /p:DebugType=None /p:DebugSymbols=false /p:OutputPath=$(Build.ArtifactStagingDirectory)'
maximumCpuCount: true

- task: VSBuild@1
displayName: 'Build project'
inputs:
sourceFolder: '$(Build.SourcesDirectory)'
contents: |
OpenKh*/**/$(BuildConfiguration)/netcoreapp**/**/resources/**
targetFolder: '$(Build.ArtifactStagingDirectory)/netcore/resources'
flattenFolders: true
solution: '**/OpenKh.Game*.csproj'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
vsVersion: 'latest'
msbuildArgs: '/t:Build /p:DebugType=None /p:DebugSymbols=false /p:OutputPath=$(Build.ArtifactStagingDirectory)'
maximumCpuCount: true

- task: PublishBuildArtifacts@1
displayName: 'Publish artifacts'
Expand Down
60 changes: 60 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
##############################################################################
# Build the entire solution in a very similar way of Azure Pipelines #
# #
# This script is not meant to create redistributable executables for OpenKH, #
# but they can be used for local usage. #
# #
# The only difference with Azure Pipelines is that this script does not run #
# "pre-build.ps1", which is responsible to assign tags to projects for #
# copyright and versioning. The main reason is because we do not want to #
# modify existing files when compiling. #
##############################################################################

param (
[string] $configuration = "Release",
[string] $verbosity = "minimal",
[string] $output = "bin"
)

$solutionBase = "OpenKh.Windows"
$solution = "${solutionBase}.sln"

function Test-Success([int] $exitCode) {
if ($exitCode -ne 0) {
Write-Error "Last command returned error $exitCode, therefore the build is canceled."
exit
}
}

# Use submodules
git submodule update --init --recursive --depth 1
Test-Success $LASTEXITCODE

# Restore NuGet packages
dotnet restore
Test-Success $LASTEXITCODE

# Run tests
dotnet test --configuration $configuration --verbosity $verbosity
Test-Success $LASTEXITCODE

# Create temporary solution
dotnet new sln -n $solutionBase --force
Test-Success $LASTEXITCODE

# Add items to solution
Get-ChildItem -Filter OpenKh.Command.* | ForEach-Object {
dotnet sln $solution add $_.FullName
Test-Success $LASTEXITCODE
}
Get-ChildItem -Filter OpenKh.Tools.* | ForEach-Object {
dotnet sln $solution add $_.FullName
Test-Success $LASTEXITCODE
}
Get-ChildItem -Filter OpenKh.Game* | ForEach-Object {
dotnet sln $solution add $_.FullName
Test-Success $LASTEXITCODE
}

# Publish solution
dotnet publish $solution --configuration $configuration --verbosity $verbosity --framework netcoreapp3.1 --output $output /p:DebugType=None /p:DebugSymbols=false
75 changes: 75 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/sh

##############################################################################
# Build the entire solution in a very similar way of Azure Pipelines #
# #
# This script is essentially the same exact script of "build.ps1", but it #
# works on both Linux and macOS without necessarly install PowerShell. #
# #
# The only problem here is that .NET Core 3.1 sdk does not allow to build #
# OpenKh.sln because of the Windows-only projects there. So this script #
# temporarly creates a solution that only includes OpenKh.Command.* projects.#
# #
# This also print some configuration to easily access CLI tools from a shell.#
##############################################################################

export configuration="Release"
export verbosity="minimal"
export output="bin"
export solutionBase="OpenKh.Linux"
export solution="$solutionBase.sln"

git submodule update --init --recursive --depth 1
if [ $? -ne 0 ]
then
exit 1
fi

# Create solution for Linux and macOS
dotnet new sln -n $solutionBase --force
if [ $? -ne 0 ]
then
exit 1
fi

# Add only command line tools to the new solution
for project in ./OpenKh.Command.*/*.csproj; do
dotnet sln $solution add "$project"
done
for project in ./OpenKh.Game*/*.csproj; do
dotnet sln $solution add "$project"
done

# Restore NuGet packages
dotnet restore $solution
if [ $? -ne 0 ]
then
rm $solution
exit 1
fi

# Run tests
dotnet test $solution --configuration $configuration --verbosity $verbosity
if [ $? -ne 0 ]
then
rm $solution
exit 1
fi

# Publish solution
dotnet publish $solution --configuration $configuration --verbosity $verbosity --framework netcoreapp3.1 --output $output /p:DebugType=None /p:DebugSymbols=false

rm $solution

# Print some potentially useful info
echo "It is very recommended to append to your '~/.profile' file the path of"
echo "OpenKH binaries and their alias to run them from any folder. You only"
echo "need to do it once per user."
echo "To do so, please execute the following commands:"

awk '{ sub("\r$", ""); print }' ./openkh_alias > ./bin/openkh_alias
chmod +x ./bin/OpenKh.Command.*
export OPENKH_BIN="$(realpath ./bin)"
echo "echo 'export OPENKH_BIN=\"$OPENKH_BIN\"' >> ~/.profile"
echo "echo 'export PATH=\$PATH:\$OPENKH_BIN' >> ~/.profile"
echo "echo 'source \$OPENKH_BIN/openkh_alias' >> ~/.profile"
25 changes: 25 additions & 0 deletions openkh_alias
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
alias khbar='OpenKh.Command.Bar'
alias unbar='OpenKh.Command.Bar unpack'
alias rebar='OpenKh.Command.Bar pack'
alias listbar='OpenKh.Command.Bar list'

alias khbbsa='OpenKh.Command.Bbsa'
alias unbbsa='OpenKh.Command.Bbsa extract'
alias listbbsa='OpenKh.Command.Bbsa list'

alias khasset='OpenKh.Command.HdAssets'
alias unasset='OpenKh.Command.HdAssets extract'
alias listasset='OpenKh.Command.HdAssets list'

alias khidx='OpenKh.Command.IdxImg'
alias unidx='OpenKh.Command.IdxImg extract'
alias listidx='OpenKh.Command.IdxImg list'

alias khlayout='OpenKh.Command.Layout'
alias unlayout='OpenKh.Command.Layout unlayout'
alias relayout='OpenKh.Command.Layout relayout'
alias unsequence='OpenKh.Command.Layout sequence'
alias resequence='OpenKh.Command.Layout sequence'

alias khmsg='OpenKh.Command.MsgTool'
alias unmsg='OpenKh.Command.MsgTool --input'
12 changes: 11 additions & 1 deletion pre-build.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
##############################################################################
# Assign assembly tags to every project #
# #
# This script essentially modifies every *.csproj file to create tags like #
# "company name", "author" and mostly version number. #
# This script is not meant to be run locally, but only to be consumed by #
# Azure Pipelines. It still work locally for the purpose of testing, but #
# otherwise it is quite pointless. #
##############################################################################

# https://docs.microsoft.com/en-us/azure/devops/pipelines/scripts/powershell?view=azure-devops

function Log([string]$text) {
Write-Warning $text
Write-Debug $text
}

# If this script is not running on a build server, remind user to
Expand Down