Skip to content

Commit baee90e

Browse files
lillo42fredericDelaporte
authored andcommitted
Add a Linux build menu (#1830)
1 parent 539a814 commit baee90e

15 files changed

+359
-160
lines changed

.editorconfig

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
root=true
22

33
[*]
4-
end_of_line = CRLF
54
insert_final_newline = true
65

76
[*.cs]

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ NHibernate.dll
1414
TestResult.xml
1515
.vscode
1616
.DS_Store
17+
18+
.idea/
19+
.vs/

CONTRIBUTING.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The main GitHub repository is at [https://github.com/nhibernate/nhibernate-core]
2020

2121
## The Build Menu
2222

23-
**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:
23+
**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:
2424

2525
1. Run ShowBuildMenu.bat.
2626
2. Right click on the title bar of the window.
@@ -41,6 +41,8 @@ The main GitHub repository is at [https://github.com/nhibernate/nhibernate-core]
4141
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.
4242
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.
4343

44+
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).
45+
4446
## Creating a Test Case to Verify the Issue
4547

4648
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.

ShowBuildMenu.bat

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22
pushd %~dp0
33

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

11+
if not exist %BUILD_TOOL_PATH% (
12+
dotnet build %~dp0Tools\BuildTool\BuildTool.sln -c Release -o bin
13+
)
14+
1015
:main-menu
1116
echo ========================= NHIBERNATE BUILD MENU ==========================
1217
echo --- TESTING ---

ShowBuildMenu.sh

+261
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,261 @@
1+
#!/bin/sh
2+
3+
BUILD_TOOL_PATH="./Tools/BuildTool/bin/BuildTool.dll"
4+
BUILD_TOOL="dotnet $BUILD_TOOL_PATH"
5+
AVAILABLE_CONFIGURATIONS="available-test-configurations"
6+
CONFIG_NAME=""
7+
TEST_PLATFORM=""
8+
LIB_FILES=""
9+
LIB_FILES2=""
10+
CURRENT_CONFIGURATION="./current-test-configuration"
11+
OPTION=0
12+
async_generator_path=""
13+
14+
if [ ! -f $BUILD_TOOL_PATH ]
15+
then
16+
dotnet build ./Tools/BuildTool/BuildTool.sln -c Release -o bin
17+
fi
18+
19+
buildDebug(){
20+
dotnet build ./src/NHibernate.sln
21+
echo "."
22+
echo "Assuming the build succeeded, your results will be in the build folder."
23+
echo "."
24+
mainMenu
25+
}
26+
27+
buildRelease(){
28+
dotnet build ./src/NHibernate.sln -c Release
29+
echo "."
30+
echo "Assuming the build succeeded, your results will be in the build folder."
31+
echo "."
32+
mainMenu
33+
}
34+
35+
testActivate(){
36+
FILE_TEMP="folder.tmp"
37+
38+
$BUILD_TOOL pick-folder $AVAILABLE_CONFIGURATIONS $FILE_TEMP "Which test configuration should be activated?"
39+
40+
if [ -d $CURRENT_CONFIGURATION ]
41+
then
42+
rm -r $CURRENT_CONFIGURATION/
43+
fi
44+
45+
CURRENT_FOLDER=$(pwd)
46+
INFORMATION=$(cat $CURRENT_FOLDER/$FILE_TEMP)
47+
cp -r $INFORMATION/ $CURRENT_CONFIGURATION
48+
49+
rm $FILE_TEMP
50+
51+
echo "Configuration activated."
52+
53+
mainMenu
54+
}
55+
56+
testSetupGeneric() {
57+
echo "Enter a name for your test configuration or press enter to use default name:"
58+
read CFGNAME
59+
if [ $CFGNAME = ""]
60+
then
61+
CFGNAME="$CONFIG_NAME-$TEST_PLATFORM"
62+
echo $CFGNAME
63+
fi
64+
65+
mkdir -p $AVAILABLE_CONFIGURATIONS/$CFGNAME
66+
67+
if [ ! "$LIB_FILES" ]
68+
then
69+
cp $LIB_FILES $AVAILABLE_CONFIGURATIONS/$CFGNAME
70+
71+
if [ ! "$LIB_FILES2" ]
72+
then
73+
cp $LIB_FILES2 $AVAILABLE_CONFIGURATIONS/$CFGNAME
74+
fi
75+
fi
76+
77+
cp "src/NHibernate.Config.Templates/$CONFIG_NAME.cfg.xml" "$AVAILABLE_CONFIGURATIONS/$CFGNAME/hibernate.cfg.xml"
78+
echo "Done setting up files. Please edit the connection string in file:"
79+
echo "$AVAILABLE_CONFIGURATIONS/$CFGNAME/hibernate.cfg.xml"
80+
echo "When you're done, don't forget to activate the configuration through the menu."
81+
mainMenu
82+
}
83+
84+
testSetupSqlServer() {
85+
CONFIG_NAME="MSSQL"
86+
TEST_PLATFORM="AnyCPU"
87+
LIB_FILES=""
88+
LIB_FILES2=""
89+
testSetupGeneric
90+
}
91+
92+
testSetupFirebird() {
93+
CONFIG_NAME="FireBird"
94+
TEST_PLATFORM="AnyCPU"
95+
LIB_FILES=""
96+
LIB_FILES2=""
97+
testSetupGeneric
98+
}
99+
100+
testSetupSqlite() {
101+
CONFIG_NAME="SQLite"
102+
TEST_PLATFORM="AnyCPU"
103+
LIB_FILES=""
104+
LIB_FILES2=""e
105+
testSetupGeneric
106+
}
107+
108+
testSetupPostgresql() {
109+
CONFIG_NAME="PostgreSQL"
110+
TEST_PLATFORM="AnyCPU"
111+
LIB_FILES=""
112+
LIB_FILES2=""
113+
testSetupGeneric
114+
}
115+
116+
testSetupMysql() {
117+
CONFIG_NAME="MySql"
118+
TEST_PLATFORM="AnyCPU"
119+
LIB_FILES=""
120+
LIB_FILES2=""
121+
testSetupGeneric
122+
}
123+
124+
testSetupMenu() {
125+
echo "A. Add a test configuration for SQL Server."
126+
echo "B. Add a test configuration for Firebird."
127+
echo "C. Add a test configuration for SQLite."
128+
echo "D. Add a test configuration for PostgreSQL."
129+
echo "E. Add a test configuration for MySql."
130+
echo "."
131+
echo "X. Exit to main menu."
132+
echo "."
133+
134+
$BUILD_TOOL prompt ABCDEX
135+
136+
OPTION=$?
137+
if [ $OPTION -eq 5 ]
138+
then
139+
echo "Main menu"
140+
mainMenu
141+
elif [ $OPTION -eq 4 ]
142+
then
143+
echo "MySQL"
144+
testSetupMysql
145+
mainMenu
146+
elif [ $OPTION -eq 3 ]
147+
then
148+
echo "PostgreSQL"
149+
testSetupPostgresql
150+
mainMenu
151+
elif [ $OPTION -eq 2 ]
152+
then
153+
echo "Sqlite"
154+
testSetupSqlite
155+
mainMenu
156+
elif [ $OPTION -eq 1 ]
157+
then
158+
echo "Firebird"
159+
testSetupFirebird
160+
mainMenu
161+
elif [ $OPTION -eq 0 ]
162+
then
163+
echo "SQL Server"
164+
testSetupSqlServer
165+
mainMenu
166+
fi
167+
}
168+
169+
testRun(){
170+
dotnet test ./src/NHibernate.Test/NHibernate.Test.csproj -f netcoreapp2.0
171+
dotnet test ./src/NHibernate.Test.VisualBasic/NHibernate.Test.VisualBasic.vbproj -f netcoreapp2.0
172+
mainMenu
173+
}
174+
175+
generateAsync(){
176+
dotnet msbuild /t:Restore ./src/NHibernate.sln
177+
178+
getAsyncGeneratorPath
179+
cd src
180+
mono ../"$async_generator_path"
181+
cd ..
182+
183+
mainMenu
184+
}
185+
186+
getAsyncGeneratorPath(){
187+
if [ "$async_generator_path" ]
188+
then
189+
return
190+
fi
191+
192+
cd Tools
193+
194+
if [ ! -f nuget.exe ]
195+
then
196+
wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
197+
fi
198+
199+
async_generator_path="CSharpAsyncGenerator.CommandLine.$(cat packages.config | grep id=\"CSharpAsyncGenerator.CommandLine | cut -d\" -f4)/tools"
200+
201+
if [ ! -d $async_generator_path ]
202+
then
203+
mono nuget.exe install
204+
fi
205+
206+
if [ ! -f $async_generator_path/SQLitePCLRaw.core.dll ]
207+
then
208+
# This "hidden" dependency causes a failure under some Mono setup, add it explicitly
209+
mono nuget.exe install SQLitePCLRaw.core -Version 1.0.0
210+
cp SQLitePCLRaw.core.1.0.0/lib/net45/SQLitePCLRaw.core.dll $async_generator_path/
211+
fi
212+
213+
async_generator_path="Tools/$async_generator_path/AsyncGenerator.CommandLine.exe"
214+
215+
cd ..
216+
}
217+
218+
mainMenu() {
219+
echo "========================= NHIBERNATE BUILD MENU =========================="
220+
echo "--- TESTING ---"
221+
echo "A. (Step 1) Set up a new test configuration for a particular database."
222+
echo "B. (Step 2) Activate a test configuration."
223+
echo "C. (Step 3) Run tests."
224+
echo "."
225+
echo "--- BUILD ---"
226+
echo "E. Build NHibernate (Debug)"
227+
echo "F. Build NHibernate (Release)"
228+
echo "."
229+
echo "--- Code generation ---"
230+
echo "H. Generate async code (Generates files in Async sub-folders)"
231+
echo "."
232+
echo "--- Exit ---"
233+
echo "X. Make the beautiful build menu go away."
234+
echo "."
235+
236+
$BUILD_TOOL prompt ABCEFHX
237+
238+
OPTION=$?
239+
240+
if [ $OPTION -eq 5 ]
241+
then
242+
generateAsync
243+
elif [ $OPTION -eq 4 ]
244+
then
245+
buildRelease
246+
elif [ $OPTION -eq 3 ]
247+
then
248+
buildDebug
249+
elif [ $OPTION -eq 2 ]
250+
then
251+
testRun
252+
elif [ $OPTION -eq 1 ]
253+
then
254+
testActivate
255+
elif [ $OPTION -eq 0 ]
256+
then
257+
testSetupMenu
258+
fi
259+
}
260+
261+
mainMenu

Tools/.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ nuget.exe
22
NUnit.*
33
vswhere.*
44
CSharpAsyncGenerator.CommandLine.*
5-
gitreleasemanager.*
5+
gitreleasemanager.*
6+
SQLitePCLRaw.core.*

Tools/BuildTool/.gitignore

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
*.user
44
*.suo
55
.vs/
6-
bin/Debug/
6+
bin/
77
obj/
8-
*.vshost.*
8+
*.vshost.*
9+
.idea/
10+
.vs/

Tools/BuildTool/BuildTool.csproj

+2-55
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,6 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
1+
<Project Sdk="Microsoft.NET.Sdk">
32
<PropertyGroup>
4-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5-
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
6-
<ProductVersion>8.0.30703</ProductVersion>
7-
<SchemaVersion>2.0</SchemaVersion>
8-
<ProjectGuid>{9F599EF4-F977-4063-9141-3D95359EE076}</ProjectGuid>
93
<OutputType>Exe</OutputType>
10-
<AppDesignerFolder>Properties</AppDesignerFolder>
11-
<RootNamespace>BuildTool</RootNamespace>
12-
<AssemblyName>BuildTool</AssemblyName>
13-
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
14-
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
15-
<FileAlignment>512</FileAlignment>
4+
<TargetFramework>netcoreapp2.0</TargetFramework>
165
</PropertyGroup>
17-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
18-
<PlatformTarget>x86</PlatformTarget>
19-
<DebugSymbols>true</DebugSymbols>
20-
<DebugType>full</DebugType>
21-
<Optimize>false</Optimize>
22-
<OutputPath>bin\Debug\</OutputPath>
23-
<DefineConstants>DEBUG;TRACE</DefineConstants>
24-
<ErrorReport>prompt</ErrorReport>
25-
<WarningLevel>4</WarningLevel>
26-
</PropertyGroup>
27-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
28-
<PlatformTarget>x86</PlatformTarget>
29-
<DebugType>pdbonly</DebugType>
30-
<Optimize>true</Optimize>
31-
<OutputPath>bin\Release\</OutputPath>
32-
<DefineConstants>TRACE</DefineConstants>
33-
<ErrorReport>prompt</ErrorReport>
34-
<WarningLevel>4</WarningLevel>
35-
</PropertyGroup>
36-
<ItemGroup>
37-
<Reference Include="System" />
38-
<Reference Include="System.Core" />
39-
<Reference Include="System.Xml.Linq" />
40-
<Reference Include="System.Data.DataSetExtensions" />
41-
<Reference Include="System.Data" />
42-
<Reference Include="System.Xml" />
43-
</ItemGroup>
44-
<ItemGroup>
45-
<Compile Include="Program.cs" />
46-
<Compile Include="Properties\AssemblyInfo.cs" />
47-
</ItemGroup>
48-
<ItemGroup>
49-
<None Include="app.config" />
50-
</ItemGroup>
51-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
52-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
53-
Other similar extension points exist, see Microsoft.Common.targets.
54-
<Target Name="BeforeBuild">
55-
</Target>
56-
<Target Name="AfterBuild">
57-
</Target>
58-
-->
596
</Project>

0 commit comments

Comments
 (0)