Skip to content

Commit

Permalink
Add a Linux build menu (#1830)
Browse files Browse the repository at this point in the history
  • Loading branch information
lillo42 authored and fredericDelaporte committed Oct 15, 2018
1 parent 539a814 commit baee90e
Show file tree
Hide file tree
Showing 15 changed files with 359 additions and 160 deletions.
1 change: 0 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
root=true

[*]
end_of_line = CRLF
insert_final_newline = true

[*.cs]
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ NHibernate.dll
TestResult.xml
.vscode
.DS_Store

.idea/
.vs/
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The main GitHub repository is at [https://github.com/nhibernate/nhibernate-core]

## The Build Menu

**ShowBuildMenu.bat** will be your friend throughout this journey. He's easiest to work with if you make his box bigger by following these steps:
**ShowBuildMenu.bat** will be your friend throughout this journey. A .sh version exists for Linux. It's easiest to work with if you make his box bigger by following these steps:

1. Run ShowBuildMenu.bat.
2. Right click on the title bar of the window.
Expand All @@ -41,6 +41,8 @@ The main GitHub repository is at [https://github.com/nhibernate/nhibernate-core]
4. (Optional) Run all the tests with option C or D and hopefully you will see no failing tests. The build may fail on certain databases; please ask on the mailing list if you are having trouble.
5. Before using the database for unit tests from an IDE, you'll need to create an empty database that matches your connection string. The unit test in NHibernate.TestDatabaseSetup supports some databases. If the one you have configured is supported, it will drop the database if it does already exist, then recreate it.

Compiling the solution under Linux requires installation of the [Mono package mono-complete](https://www.mono-project.com/download/stable) and of the [.NET Core SDK](https://www.microsoft.com/net/download).

## Creating a Test Case to Verify the Issue

In most cases, you will be adding your test to the NHibernate.Test project. If there is a test that only works with VisualBasic, then add it to the NHibernate.Test.VisualBasic project instead.
Expand Down
7 changes: 6 additions & 1 deletion ShowBuildMenu.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@
pushd %~dp0

set NANT="%~dp0Tools\nant\bin\NAnt.exe" -t:net-4.0
set BUILDTOOL="%~dp0Tools\BuildTool\bin\Release\BuildTool.exe"
set BUILD_TOOL_PATH=%~dp0Tools\BuildTool\bin\BuildTool.dll
set BUILDTOOL=dotnet %BUILD_TOOL_PATH%
set AVAILABLE_CONFIGURATIONS=%~dp0available-test-configurations
set CURRENT_CONFIGURATION=%~dp0current-test-configuration
set NUNIT="%~dp0Tools\NUnit.ConsoleRunner.3.7.0\tools\nunit3-console.exe"

if not exist %BUILD_TOOL_PATH% (
dotnet build %~dp0Tools\BuildTool\BuildTool.sln -c Release -o bin
)

:main-menu
echo ========================= NHIBERNATE BUILD MENU ==========================
echo --- TESTING ---
Expand Down
261 changes: 261 additions & 0 deletions ShowBuildMenu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
#!/bin/sh

BUILD_TOOL_PATH="./Tools/BuildTool/bin/BuildTool.dll"
BUILD_TOOL="dotnet $BUILD_TOOL_PATH"
AVAILABLE_CONFIGURATIONS="available-test-configurations"
CONFIG_NAME=""
TEST_PLATFORM=""
LIB_FILES=""
LIB_FILES2=""
CURRENT_CONFIGURATION="./current-test-configuration"
OPTION=0
async_generator_path=""

if [ ! -f $BUILD_TOOL_PATH ]
then
dotnet build ./Tools/BuildTool/BuildTool.sln -c Release -o bin
fi

buildDebug(){
dotnet build ./src/NHibernate.sln
echo "."
echo "Assuming the build succeeded, your results will be in the build folder."
echo "."
mainMenu
}

buildRelease(){
dotnet build ./src/NHibernate.sln -c Release
echo "."
echo "Assuming the build succeeded, your results will be in the build folder."
echo "."
mainMenu
}

testActivate(){
FILE_TEMP="folder.tmp"

$BUILD_TOOL pick-folder $AVAILABLE_CONFIGURATIONS $FILE_TEMP "Which test configuration should be activated?"

if [ -d $CURRENT_CONFIGURATION ]
then
rm -r $CURRENT_CONFIGURATION/
fi

CURRENT_FOLDER=$(pwd)
INFORMATION=$(cat $CURRENT_FOLDER/$FILE_TEMP)
cp -r $INFORMATION/ $CURRENT_CONFIGURATION

rm $FILE_TEMP

echo "Configuration activated."

mainMenu
}

testSetupGeneric() {
echo "Enter a name for your test configuration or press enter to use default name:"
read CFGNAME
if [ $CFGNAME = ""]
then
CFGNAME="$CONFIG_NAME-$TEST_PLATFORM"
echo $CFGNAME
fi

mkdir -p $AVAILABLE_CONFIGURATIONS/$CFGNAME

if [ ! "$LIB_FILES" ]
then
cp $LIB_FILES $AVAILABLE_CONFIGURATIONS/$CFGNAME

if [ ! "$LIB_FILES2" ]
then
cp $LIB_FILES2 $AVAILABLE_CONFIGURATIONS/$CFGNAME
fi
fi

cp "src/NHibernate.Config.Templates/$CONFIG_NAME.cfg.xml" "$AVAILABLE_CONFIGURATIONS/$CFGNAME/hibernate.cfg.xml"
echo "Done setting up files. Please edit the connection string in file:"
echo "$AVAILABLE_CONFIGURATIONS/$CFGNAME/hibernate.cfg.xml"
echo "When you're done, don't forget to activate the configuration through the menu."
mainMenu
}

testSetupSqlServer() {
CONFIG_NAME="MSSQL"
TEST_PLATFORM="AnyCPU"
LIB_FILES=""
LIB_FILES2=""
testSetupGeneric
}

testSetupFirebird() {
CONFIG_NAME="FireBird"
TEST_PLATFORM="AnyCPU"
LIB_FILES=""
LIB_FILES2=""
testSetupGeneric
}

testSetupSqlite() {
CONFIG_NAME="SQLite"
TEST_PLATFORM="AnyCPU"
LIB_FILES=""
LIB_FILES2=""e
testSetupGeneric
}

testSetupPostgresql() {
CONFIG_NAME="PostgreSQL"
TEST_PLATFORM="AnyCPU"
LIB_FILES=""
LIB_FILES2=""
testSetupGeneric
}

testSetupMysql() {
CONFIG_NAME="MySql"
TEST_PLATFORM="AnyCPU"
LIB_FILES=""
LIB_FILES2=""
testSetupGeneric
}

testSetupMenu() {
echo "A. Add a test configuration for SQL Server."
echo "B. Add a test configuration for Firebird."
echo "C. Add a test configuration for SQLite."
echo "D. Add a test configuration for PostgreSQL."
echo "E. Add a test configuration for MySql."
echo "."
echo "X. Exit to main menu."
echo "."

$BUILD_TOOL prompt ABCDEX

OPTION=$?
if [ $OPTION -eq 5 ]
then
echo "Main menu"
mainMenu
elif [ $OPTION -eq 4 ]
then
echo "MySQL"
testSetupMysql
mainMenu
elif [ $OPTION -eq 3 ]
then
echo "PostgreSQL"
testSetupPostgresql
mainMenu
elif [ $OPTION -eq 2 ]
then
echo "Sqlite"
testSetupSqlite
mainMenu
elif [ $OPTION -eq 1 ]
then
echo "Firebird"
testSetupFirebird
mainMenu
elif [ $OPTION -eq 0 ]
then
echo "SQL Server"
testSetupSqlServer
mainMenu
fi
}

testRun(){
dotnet test ./src/NHibernate.Test/NHibernate.Test.csproj -f netcoreapp2.0
dotnet test ./src/NHibernate.Test.VisualBasic/NHibernate.Test.VisualBasic.vbproj -f netcoreapp2.0
mainMenu
}

generateAsync(){
dotnet msbuild /t:Restore ./src/NHibernate.sln

getAsyncGeneratorPath
cd src
mono ../"$async_generator_path"
cd ..

mainMenu
}

getAsyncGeneratorPath(){
if [ "$async_generator_path" ]
then
return
fi

cd Tools

if [ ! -f nuget.exe ]
then
wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
fi

async_generator_path="CSharpAsyncGenerator.CommandLine.$(cat packages.config | grep id=\"CSharpAsyncGenerator.CommandLine | cut -d\" -f4)/tools"

if [ ! -d $async_generator_path ]
then
mono nuget.exe install
fi

if [ ! -f $async_generator_path/SQLitePCLRaw.core.dll ]
then
# This "hidden" dependency causes a failure under some Mono setup, add it explicitly
mono nuget.exe install SQLitePCLRaw.core -Version 1.0.0
cp SQLitePCLRaw.core.1.0.0/lib/net45/SQLitePCLRaw.core.dll $async_generator_path/
fi

async_generator_path="Tools/$async_generator_path/AsyncGenerator.CommandLine.exe"

cd ..
}

mainMenu() {
echo "========================= NHIBERNATE BUILD MENU =========================="
echo "--- TESTING ---"
echo "A. (Step 1) Set up a new test configuration for a particular database."
echo "B. (Step 2) Activate a test configuration."
echo "C. (Step 3) Run tests."
echo "."
echo "--- BUILD ---"
echo "E. Build NHibernate (Debug)"
echo "F. Build NHibernate (Release)"
echo "."
echo "--- Code generation ---"
echo "H. Generate async code (Generates files in Async sub-folders)"
echo "."
echo "--- Exit ---"
echo "X. Make the beautiful build menu go away."
echo "."

$BUILD_TOOL prompt ABCEFHX

OPTION=$?

if [ $OPTION -eq 5 ]
then
generateAsync
elif [ $OPTION -eq 4 ]
then
buildRelease
elif [ $OPTION -eq 3 ]
then
buildDebug
elif [ $OPTION -eq 2 ]
then
testRun
elif [ $OPTION -eq 1 ]
then
testActivate
elif [ $OPTION -eq 0 ]
then
testSetupMenu
fi
}

mainMenu
3 changes: 2 additions & 1 deletion Tools/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ nuget.exe
NUnit.*
vswhere.*
CSharpAsyncGenerator.CommandLine.*
gitreleasemanager.*
gitreleasemanager.*
SQLitePCLRaw.core.*
6 changes: 4 additions & 2 deletions Tools/BuildTool/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
*.user
*.suo
.vs/
bin/Debug/
bin/
obj/
*.vshost.*
*.vshost.*
.idea/
.vs/
57 changes: 2 additions & 55 deletions Tools/BuildTool/BuildTool.csproj
Original file line number Diff line number Diff line change
@@ -1,59 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{9F599EF4-F977-4063-9141-3D95359EE076}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BuildTool</RootNamespace>
<AssemblyName>BuildTool</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
Loading

0 comments on commit baee90e

Please sign in to comment.