Skip to content

Commit

Permalink
Update scripts to work with the new engine toolchain.
Browse files Browse the repository at this point in the history
  • Loading branch information
pchote committed Aug 25, 2019
1 parent a216dee commit 5e1de71
Show file tree
Hide file tree
Showing 17 changed files with 319 additions and 340 deletions.
20 changes: 12 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# Travis-CI Build for OpenRAModSDK
# see travis-ci.org for details

dist: xenial
language: csharp
mono: 4.6.1
sudo: false
mono: 5.20.1

addons:
apt:
packages:
- dpkg
- liblua5.1-0
- nsis
- nsis-common

script:
- make
Expand All @@ -20,18 +19,23 @@ script:
if [ "${TRAVIS_TEST_PACKAGING}" == "True" ]; then make check-packaging-scripts && ./packaging/package-all.sh test-0 || travis_terminate 1; fi

before_deploy:
- wget http://mirrors.kernel.org/ubuntu/pool/universe/n/nsis/nsis-common_3.03-2_all.deb
- wget http://mirrors.kernel.org/ubuntu/pool/universe/n/nsis/nsis_3.03-2_amd64.deb
- sudo dpkg -i nsis-common_3.03-2_all.deb
- sudo dpkg -i nsis_3.03-2_amd64.deb
- mkdir build
- make check-packaging-scripts && cd build && ../packaging/package-all.sh ${TRAVIS_TAG} ${PWD} && cd ..
- . mod.config

deploy:
provider: releases
api_key: ${GH_DEPLOY_API_KEY}
file:
- build/${PACKAGING_INSTALLER_NAME}-${TRAVIS_TAG}.exe
- build/${PACKAGING_INSTALLER_NAME}-${TRAVIS_TAG}-x86.exe
- build/${PACKAGING_INSTALLER_NAME}-${TRAVIS_TAG}-x64.exe
- build/${PACKAGING_INSTALLER_NAME}-${TRAVIS_TAG}-x86-winportable.zip
- build/${PACKAGING_INSTALLER_NAME}-${TRAVIS_TAG}-x64-winportable.zip
- build/${PACKAGING_INSTALLER_NAME}-${TRAVIS_TAG}-macOS.zip
- build/${PACKAGING_INSTALLER_NAME}-${TRAVIS_TAG}-winportable.zip
- build/${PACKAGING_INSTALLER_NAME}-${TRAVIS_TAG}.AppImage
- build/${PACKAGING_INSTALLER_NAME}-${TRAVIS_TAG}-x86_64.AppImage
skip_cleanup: true
on:
tags: true
35 changes: 21 additions & 14 deletions ExampleMod.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,28 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.Mods.Common", "engin
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Release-x86|Any CPU = Release-x86|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4E5B38F7-4E99-4C92-BB39-9100CC7F3829}.Debug|x86.ActiveCfg = Debug|x86
{4E5B38F7-4E99-4C92-BB39-9100CC7F3829}.Debug|x86.Build.0 = Debug|x86
{4E5B38F7-4E99-4C92-BB39-9100CC7F3829}.Release|x86.ActiveCfg = Release|x86
{4E5B38F7-4E99-4C92-BB39-9100CC7F3829}.Release|x86.Build.0 = Release|x86
{0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Debug|x86.ActiveCfg = Debug|x86
{0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Debug|x86.Build.0 = Debug|x86
{0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Release|x86.ActiveCfg = Release|x86
{0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Release|x86.Build.0 = Release|x86
{FE6C8CC0-2F07-442A-B29F-17617B3B7FC6}.Debug|x86.ActiveCfg = Debug|x86
{FE6C8CC0-2F07-442A-B29F-17617B3B7FC6}.Debug|x86.Build.0 = Debug|x86
{FE6C8CC0-2F07-442A-B29F-17617B3B7FC6}.Release|x86.ActiveCfg = Release|x86
{FE6C8CC0-2F07-442A-B29F-17617B3B7FC6}.Release|x86.Build.0 = Release|x86
{4E5B38F7-4E99-4C92-BB39-9100CC7F3829}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4E5B38F7-4E99-4C92-BB39-9100CC7F3829}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E5B38F7-4E99-4C92-BB39-9100CC7F3829}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4E5B38F7-4E99-4C92-BB39-9100CC7F3829}.Release|Any CPU.Build.0 = Release|Any CPU
{4E5B38F7-4E99-4C92-BB39-9100CC7F3829}.Release-x86|Any CPU.ActiveCfg = Release|Any CPU
{4E5B38F7-4E99-4C92-BB39-9100CC7F3829}.Release-x86|Any CPU.Build.0 = Release|Any CPU
{0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Release|Any CPU.Build.0 = Release|Any CPU
{0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Release-x86|Any CPU.ActiveCfg = Release-x86|Any CPU
{0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Release-x86|Any CPU.Build.0 = Release-x86|Any CPU
{FE6C8CC0-2F07-442A-B29F-17617B3B7FC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FE6C8CC0-2F07-442A-B29F-17617B3B7FC6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FE6C8CC0-2F07-442A-B29F-17617B3B7FC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FE6C8CC0-2F07-442A-B29F-17617B3B7FC6}.Release|Any CPU.Build.0 = Release|Any CPU
{FE6C8CC0-2F07-442A-B29F-17617B3B7FC6}.Release-x86|Any CPU.ActiveCfg = Release|Any CPU
{FE6C8CC0-2F07-442A-B29F-17617B3B7FC6}.Release-x86|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
60 changes: 36 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,26 @@
# make check-packaging-scripts

.PHONY: utility stylecheck build clean engine version check check-scripts check-sdk-scripts check-packaging-scripts check-variables
.DEFAULT_GOAL := build
.DEFAULT_GOAL := all

VERSION = $(shell git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null || echo git-`git rev-parse --short HEAD`)
MOD_ID = $(shell cat user.config mod.config 2> /dev/null | awk -F= '/MOD_ID/ { print $$2; exit }')
ENGINE_DIRECTORY = $(shell cat user.config mod.config 2> /dev/null | awk -F= '/ENGINE_DIRECTORY/ { print $$2; exit }')
MOD_SEARCH_PATHS = "$(shell python -c "import os; print(os.path.realpath('.'))")/mods,./mods"

MANIFEST_PATH = "mods/$(MOD_ID)/mod.yaml"
WHITELISTED_OPENRA_ASSEMBLIES = "$(shell cat user.config mod.config 2> /dev/null | awk -F= '/WHITELISTED_OPENRA_ASSEMBLIES/ { print $$2; exit }')"
WHITELISTED_THIRDPARTY_ASSEMBLIES = "$(shell cat user.config mod.config 2> /dev/null | awk -F= '/WHITELISTED_THIRDPARTY_ASSEMBLIES/ { print $$2; exit }')"
WHITELISTED_CORE_ASSEMBLIES = "$(shell cat user.config mod.config 2> /dev/null | awk -F= '/WHITELISTED_CORE_ASSEMBLIES/ { print $$2; exit }')"
WHITELISTED_MOD_ASSEMBLIES = "$(shell cat user.config mod.config 2> /dev/null | awk -F= '/WHITELISTED_MOD_ASSEMBLIES/ { print $$2; exit }')"

HAS_MSBUILD = $(shell command -v msbuild 2> /dev/null)
MANIFEST_PATH = "mods/$(MOD_ID)/mod.yaml"
HAS_LUAC = $(shell command -v luac 2> /dev/null)
LUA_FILES = $(shell find mods/*/maps/* -iname '*.lua')
PROJECT_DIRS = $(shell dirname $$(find . -iname "*.csproj" -not -path "$(ENGINE_DIRECTORY)/*"))
LUA_FILES = $(shell find mods/*/maps/* -iname '*.lua' 2> /dev/null)

MSBUILD = msbuild -verbosity:m -nologo

# Enable 32 bit builds while generating the windows installer
WIN32 = false

check-sdk-scripts:
@awk '/\r$$/ { exit(1); }' mod.config || (printf "Invalid mod.config format: file must be saved using unix-style (CR, not CRLF) line endings.\n"; exit 1)
Expand Down Expand Up @@ -94,29 +101,32 @@ check-variables:
exit 1; \
fi

engine-dependencies: check-variables check-sdk-scripts
@./fetch-engine.sh || (printf "Unable to continue without engine files\n"; exit 1)
@cd $(ENGINE_DIRECTORY) && make dependencies WIN32=$(WIN32)

engine: check-variables check-sdk-scripts
@./fetch-engine.sh || (printf "Unable to continue without engine files\n"; exit 1)
@cd $(ENGINE_DIRECTORY) && make core
@cd $(ENGINE_DIRECTORY) && make core WIN32=$(WIN32)

utility: engine
utility: engine-dependencies engine
@test -f "$(ENGINE_DIRECTORY)/OpenRA.Utility.exe" || (printf "OpenRA.Utility.exe not found!\n"; exit 1)

stylecheck: engine
@test -f "$(ENGINE_DIRECTORY)/OpenRA.StyleCheck.exe" || (cd $(ENGINE_DIRECTORY) && make stylecheck)

build: engine
ifeq ("$(HAS_MSBUILD)","")
@find . -maxdepth 1 -name '*.sln' -exec xbuild /nologo /verbosity:quiet /p:TreatWarningsAsErrors=true \;
core:
@command -v $(MSBUILD) >/dev/null || (echo "OpenRA requires the '$(MSBUILD)' tool provided by Mono >= 5.4."; exit 1)
@find . -maxdepth 1 -name '*.sln' -exec $(MSBUILD) -t:restore \;
ifeq ($(WIN32), $(filter $(WIN32),true yes y on 1))
@find . -maxdepth 1 -name '*.sln' -exec $(MSBUILD) -t:build -p:Configuration="Release-x86" \;
else
@find . -maxdepth 1 -name '*.sln' -exec msbuild /t:Rebuild /nr:false \;
@$(MSBUILD) -t:build -p:Configuration=Release
@find . -maxdepth 1 -name '*.sln' -exec $(MSBUILD) -t:build -p:Configuration=Release \;
endif

all: engine-dependencies engine core

clean: engine
ifeq ("$(HAS_MSBUILD)","")
@find . -maxdepth 1 -name '*.sln' -exec xbuild /nologo /verbosity:quiet /p:TreatWarningsAsErrors=true /t:Clean \;
else
@find . -maxdepth 1 -name '*.sln' -exec msbuild /t:Clean /nr:false \;
endif
@command -v $(MSBUILD) >/dev/null || (echo "OpenRA requires the '$(MSBUILD)' tool provided by Mono >= 5.4."; exit 1)
@find . -maxdepth 1 -name '*.sln' -exec $(MSBUILD) -t:clean \;
@cd $(ENGINE_DIRECTORY) && make clean
@printf "The engine has been cleaned.\n"

Expand All @@ -136,13 +146,15 @@ ifneq ("$(LUA_FILES)","")
@luac -p $(LUA_FILES)
endif

check: utility stylecheck
check: utility
@echo "Compiling in debug mode..."
@$(MSBUILD) -t:build -p:Configuration=Debug
@echo "Checking runtime assemblies..."
@MOD_SEARCH_PATHS="$(MOD_SEARCH_PATHS)" mono --debug "$(ENGINE_DIRECTORY)/OpenRA.Utility.exe" $(MOD_ID) --check-runtime-assemblies $(WHITELISTED_OPENRA_ASSEMBLIES) $(WHITELISTED_THIRDPARTY_ASSEMBLIES) $(WHITELISTED_CORE_ASSEMBLIES) $(WHITELISTED_MOD_ASSEMBLIES)
@echo "Checking for explicit interface violations..."
@MOD_SEARCH_PATHS="$(MOD_SEARCH_PATHS)" mono --debug "$(ENGINE_DIRECTORY)/OpenRA.Utility.exe" $(MOD_ID) --check-explicit-interfaces
@for i in $(PROJECT_DIRS) ; do \
echo "Checking for code style violations in $${i}...";\
mono --debug "$(ENGINE_DIRECTORY)/OpenRA.StyleCheck.exe" $${i};\
done
@echo "Checking for incorrect conditional trait interface overrides..."
@MOD_SEARCH_PATHS="$(MOD_SEARCH_PATHS)" mono --debug "$(ENGINE_DIRECTORY)/OpenRA.Utility.exe" $(MOD_ID) --check-conditional-trait-interface-overrides

test: utility
@echo "Testing $(MOD_ID) mod MiniYAML..."
Expand Down
92 changes: 29 additions & 63 deletions OpenRA.Mods.Example/OpenRA.Mods.Example.csproj
Original file line number Diff line number Diff line change
@@ -1,77 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProjectGuid>{4E5B38F7-4E99-4C92-BB39-9100CC7F3829}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>OpenRA.Mods.Example</RootNamespace>
<AssemblyName>OpenRA.Mods.Example</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<OutputPath>bin\Debug\</OutputPath>
<TargetFramework>net461</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<Optimize>true</Optimize>
<LangVersion>5</LangVersion>
<DebugSymbols>true</DebugSymbols>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<OutputPath>../mods/example</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<PlatformTarget>AnyCPU</PlatformTarget>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<CodeAnalysisRuleSet>../engine/OpenRA.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="Eluant">
<HintPath>..\engine\thirdparty\download\Eluant.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Widgets\Logic\TemplateMenuLogic.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Widgets\" />
<Folder Include="Widgets\Logic\" />
<!-- Work around an issue where Rider does not detect files in the project root using the default glob -->
<Compile Include="**/*.cs" Exclude="$(DefaultItemExcludes)" />
</ItemGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<DefineConstants>DEBUG;TRACE</DefineConstants>
<Optimize>false</Optimize>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\engine\OpenRA.Mods.Common\OpenRA.Mods.Common.csproj">
<Project>{FE6C8CC0-2F07-442A-B29F-17617B3B7FC6}</Project>
<Name>OpenRA.Mods.Common</Name>
<Reference Include="Eluant">
<HintPath>../engine/thirdparty/download/Eluant.dll</HintPath>
<Private>False</Private>
</Reference>
<ProjectReference Include="../engine/OpenRA.Game/OpenRA.Game.csproj">
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\engine\OpenRA.Game\OpenRA.Game.csproj">
<Project>{0DFB103F-2962-400F-8C6D-E2C28CCBA633}</Project>
<Name>OpenRA.Game</Name>
<ProjectReference Include="../engine/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj">
<Private>False</Private>
</ProjectReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
<AdditionalFiles Include="../engine/stylecop.json" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Target Name="AfterBuild">
<MakeDir Directories="$(SolutionDir)mods/example/" />
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(SolutionDir)mods/example/" />
<!--
We need to copy OpenRA.Mods.Cnc.pdb (not `.dll.pdb`). This is only necessary on Windows.
Mono outputs a `.dll.mdb` so we can just append `.mdb` directly.
-->
<Copy SourceFiles="$(TargetDir)$(TargetName).pdb" DestinationFolder="$(SolutionDir)mods/example/" Condition="Exists('$(TargetDir)$(TargetName).pdb')" />
<Copy SourceFiles="$(TargetPath).mdb" DestinationFolder="$(SolutionDir)mods/example/" Condition="Exists('$(TargetPath).mdb')" />
<!-- Uncomment these lines when debugging or adding to this target
<Message Text="DEBUG OS: $(OS)"/>
<Message Text="DEBUG SolutionDir: $(SolutionDir)"/>
<Message Text="DEBUG TargetPath: $(TargetPath)"/>
<Message Text="DEBUG TargetDir: $(TargetDir)"/>
<Message Text="DEBUG TargetName: $(TargetName)"/>
-->
<Target Name="DisableAnalyzers" BeforeTargets="CoreCompile" Condition="'$(Configuration)'=='Release'">
<!-- Disable code style analysis on Release builds to improve compile-time performance -->
<ItemGroup Condition="'$(Configuration)'=='Release'">
<Analyzer Remove="@(Analyzer)" />
</ItemGroup>
</Target>
</Project>
Loading

0 comments on commit 5e1de71

Please sign in to comment.