Skip to content

Commit dcc7046

Browse files
committed
Restructure the project for consistency with xamarin-android
`Xamarin.Android.sln` is now a toplevel file, so it's easier to see without navigating into the `src` directory. Add a `Makefile` with three targets of consequence: * `make prepare`: Prepare the project for building, e.g. restore NuGet packages. * `make all`: Build the project. * `make run-all-tests`: Run the NUnit tests. Move unit tests for `Xamarin.Android.Tools` into `src/Xamarin.Android.Tools/Tests` (child, not a peer). Rename the unit test assembly to `Xamarin.Android.Tools-Tests.dll`, and build into `bin/Test$(Configuration)`. Update to use NUnit 3.2.1 packages. Update `README.md` with build instructions. Add a `LICENSE` file. Rename `Xamarin.Android.Tools.dll` to `Xamarin.Android.Tools.AndroidSdk.dll`. Xamarin.Android already has multiple `Xamarin.Android.Tools.*.dll` assemblies, e.g. `Xamarin.Android.Tools.BootstrapTasks.dll`. Naming-wise, `Xamarin.Android.Tools.dll` sounds like it should be *core* to *all* related assemblies, but it isn't, and won't be. Instead, its core responsibility is around the Android SDK, so name it accordingly.
1 parent 6a81bcb commit dcc7046

28 files changed

Lines changed: 204 additions & 14 deletions

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ src/*.dll
1010
.DS_Store
1111
bin
1212
**/obj
13-
packages/
13+
packages/
14+
TestResult-*.xml

LICENSE

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
xamarin-android-tools
2+
3+
The MIT License (MIT)
4+
5+
Copyright (c) .NET Foundation Contributors
6+
7+
All rights reserved.
8+
9+
Permission is hereby granted, free of charge, to any person obtaining a copy
10+
of this software and associated documentation files (the "Software"), to deal
11+
in the Software without restriction, including without limitation the rights
12+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
copies of the Software, and to permit persons to whom the Software is
14+
furnished to do so, subject to the following conditions:
15+
16+
The above copyright notice and this permission notice shall be included in all
17+
copies or substantial portions of the Software.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25+
SOFTWARE.

Makefile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
CONFIGURATION := Debug
2+
NUNIT_CONSOLE := packages/NUnit.ConsoleRunner.3.2.1/tools/nunit3-console.exe
3+
OS := $(shell uname)
4+
RUNTIME := mono --debug=casts
5+
V ?= 0
6+
7+
include build-tools/scripts/msbuild.mk
8+
9+
all:
10+
$(MSBUILD) $(MSBUILD_FLAGS) Xamarin.Android.Tools.sln
11+
12+
clean:
13+
-$(MSBUILD) $(MSBUILD_FLAGS) /t:Clean Xamarin.Android.Tools.sln
14+
15+
prepare:
16+
nuget restore Xamarin.Android.Tools.sln
17+
18+
run-all-tests: run-nunit-tests
19+
20+
# $(call RUN_NUNIT_TEST,filename,log-lref?)
21+
define RUN_NUNIT_TEST
22+
MONO_TRACE_LISTENER=Console.Out \
23+
$(RUNTIME) --runtime=v4.0.0 \
24+
$(NUNIT_CONSOLE) $(NUNIT_EXTRA) $(1) \
25+
$(if $(RUN),-run:$(RUN)) \
26+
--result="TestResult-$(basename $(notdir $(1))).xml;format=nunit2" \
27+
-output=bin/Test$(CONFIGURATION)/TestOutput-$(basename $(notdir $(1))).txt \
28+
|| true ; \
29+
if [ -f "bin/Test$(CONFIGURATION)/TestOutput-$(basename $(notdir $(1))).txt" ] ; then \
30+
cat bin/Test$(CONFIGURATION)/TestOutput-$(basename $(notdir $(1))).txt ; \
31+
fi
32+
endef
33+
34+
$(NUNIT_CONSOLE): prepare
35+
36+
NUNIT_TESTS = \
37+
bin/Test$(CONFIGURATION)/Xamarin.Android.Tools-Tests.dll
38+
39+
run-nunit-tests: $(NUNIT_TESTS)
40+
$(foreach t,$(NUNIT_TESTS), $(call RUN_NUNIT_TEST,$(t),1))

README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,73 @@
11
# xamarin-android-tools
22

3+
**xamarin-android-tools** is a repo to easily share code between the
4+
[xamarin-android][x-a] repo and the Xamarin.Android commercial tooling,
5+
such as IDE extensions, without requiring that the IDE extensions
6+
submodule the entire **xamarin-android** repo, which is gigantic.
37

8+
[x-a]: https://github.com/xamarin/xamarin-android
9+
10+
# Build Requirements
11+
12+
**xamarin-android-tools** requires Mono 4.8 or later and `nuget`.
13+
14+
# Build Configuration
15+
16+
The default `make all` target accepts the following optional
17+
**make**(1) variables:
18+
19+
* `$(CONFIGURATION)`: The configuration to build.
20+
Possible values include `Debug` and `Release`.
21+
The default value is `Debug`.
22+
* `$(V)`: Controls build verbosity. When set to a non-zero value,
23+
The build is built with `/v:diag` logging.
24+
25+
# Build
26+
27+
To build **xamarin-android-tools**, first prepare the project:
28+
29+
make prepare
30+
31+
This will perform `nuget restore` and any other pre-build tasks
32+
that need to be performed.
33+
34+
Next, run `make`:
35+
36+
make
37+
38+
# Tests
39+
40+
To run the unit tests:
41+
42+
make run-all-tests
43+
44+
# Build Output Directory Structure
45+
46+
There are two configurations, `Debug` and `Release`, controlled by the
47+
`$(Configuration)` MSBuild property or the `$(CONFIGURATION)` make variable.
48+
49+
The `bin\$(Configuration)` directory, e.g. `bin\Debug`, contains
50+
*redistributable* artifacts. The `bin\Test$(Configuration)` directory,
51+
e.g. `bin\TestDebug`, contains unit tests and related files.
52+
53+
* `bin\$(Configuration)`: redistributable build artifacts.
54+
* `bin\Test$(Configuration)`: Unit tests and related files.
55+
56+
# Contributing
57+
58+
This project has adopted the code of conduct defined by the Contributor Covenant
59+
to clarify expected behavior in our community. For more information, see the
60+
[.NET Foundation Code of Conduct](http://www.dotnetfoundation.org/code-of-conduct).
61+
62+
# Mailing Lists
63+
64+
To discuss this project, and participate in the design, we use the
65+
[android-devel@lists.xamarin.com](http://lists.xamarin.com/mailman/listinfo/android-devel) mailing list.
66+
67+
# Coding Guidelines
68+
69+
We use [Mono's Coding Guidelines](http://www.mono-project.com/community/contributing/coding-guidelines/).
70+
71+
# Reporting Bugs
72+
73+
We use [GitHub](https://github.com/xamarin/xamarin-android-tools/issues) to track issues.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Microsoft Visual Studio Solution File, Format Version 12.00
22
# Visual Studio 2012
3-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Android.Tools", "Xamarin.Android.Tools\Xamarin.Android.Tools.csproj", "{E34BCFA0-CAA4-412C-AA1C-75DB8D67D157}"
3+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Android.Tools.AndroidSdk", "src\Xamarin.Android.Tools.AndroidSdk\Xamarin.Android.Tools.AndroidSdk.csproj", "{E34BCFA0-CAA4-412C-AA1C-75DB8D67D157}"
44
EndProject
5-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Android.Tools.Tests", "Xamarin.Android.Tools.Tests\Xamarin.Android.Tools.Tests.csproj", "{1E5501E8-49C1-4659-838D-CC9720C5208F}"
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Android.Tools.AndroidSdk-Tests", "src\Xamarin.Android.Tools.AndroidSdk\Tests\Xamarin.Android.Tools.AndroidSdk-Tests.csproj", "{1E5501E8-49C1-4659-838D-CC9720C5208F}"
66
EndProject
77
Global
88
GlobalSection(SolutionConfigurationPlatforms) = preSolution

build-tools/scripts/msbuild.mk

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#
2+
# MSBuild Abstraction.
3+
#
4+
# Makefile targets which need to invoke MSBuild should use `$(MSBUILD)`,
5+
# not some specific MSBuild program such as `xbuild` or `msbuild`.
6+
#
7+
# Typical use will also include `$(MSBUILD_FLAGS)`, which provides the
8+
# Configuration and logging verbosity, as per $(CONFIGURATION) and $(V):
9+
#
10+
# $(MSBUILD) $(MSBUILD_FLAGS) path/to/Project.csproj
11+
#
12+
# Inputs:
13+
#
14+
# $(CONFIGURATION): Build configuration name, e.g. Debug or Release
15+
# $(MSBUILD): The MSBuild program to use.
16+
# $(MSBUILD_ARGS): Extra arguments to pass to $(MSBUILD); embedded into $(MSBUILD_FLAGS)
17+
# $(OS): Operating system; used to determine `pkg-config` location
18+
# $(V): Build verbosity
19+
#
20+
# Outputs:
21+
#
22+
# $(MSBUILD): The MSBuild program to use. Defaults to `xbuild` unless overridden.
23+
# $(MSBUILD_FLAGS): Additional MSBuild flags; contains $(CONFIGURATION), $(V), $(MSBUILD_ARGS).
24+
25+
MSBUILD = msbuild
26+
MSBUILD_FLAGS = /p:Configuration=$(CONFIGURATION) $(MSBUILD_ARGS)
27+
28+
ifeq ($(OS),Darwin)
29+
_PKG_CONFIG = /Library/Frameworks/Mono.framework/Commands/pkg-config
30+
else # $(OS) != Darwin
31+
_PKG_CONFIG = pkg-config
32+
endif # $(OS) == Darwin
33+
34+
ifneq ($(V),0)
35+
MSBUILD_FLAGS += /v:diag
36+
endif # $(V) != 0
37+
38+
ifeq ($(MSBUILD),msbuild)
39+
USE_MSBUILD = 1
40+
endif # $(MSBUILD) == msbuild
41+
42+
ifeq ($(USE_MSBUILD),1)
43+
else # $(MSBUILD) != 1
44+
_CSC_EMITS_PDB := $(shell if $(_PKG_CONFIG) --atleast-version=4.9 mono ; then echo Pdb; fi )
45+
ifeq ($(_CSC_EMITS_PDB),Pdb)
46+
MSBUILD_FLAGS += /p:_DebugFileExt=.pdb
47+
else # $(_CSC_EMITS_PDB) == ''
48+
MSBUILD_FLAGS += /p:_DebugFileExt=.mdb
49+
endif # $(_CSC_EMITS_PDB) == Pdb
50+
endif # $(USE_MSBUILD) == 1
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)