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

Adding gradle support and CI for android sample project #143

Merged
merged 83 commits into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
3cc0227
adding ci for android
Jul 19, 2021
ce15d9b
removed extra files added to the HelloWorld sample project
Jul 19, 2021
6cd3d62
added configuration for android
Jul 19, 2021
d552583
modified android solution path
Jul 20, 2021
0ac4411
modified start up project for android solution
Jul 20, 2021
d10e76e
modified start build configurations in sharpmake for android solution
Jul 20, 2021
530b674
removed noblob build configurations in sharpmake for android solution
Jul 20, 2021
4fcdd04
added back noblob build configurations in sharpmake for android solution
Jul 20, 2021
644b4af
modified build configurations in sharpmake for android solution
Jul 20, 2021
867bc66
modified build configurations in sharpmake for android solutionagain
Jul 20, 2021
5fa9afe
try to print environment variable for ANT
Jul 21, 2021
5a18225
make import build.xml optional for ANT
Jul 21, 2021
d2801f1
(fixed typo)make import build.xml optional for ANT
Jul 21, 2021
6c60ea6
added build.xml for ANT
Jul 21, 2021
dee2e02
deleted optional for build.xml for ANT
Jul 21, 2021
2b1a0f9
absolute path for build.xml for ANT
Jul 21, 2021
8d506f7
try to print android sdk dir
Jul 22, 2021
817cdaf
try to print all the folders under android sdk dir
Jul 22, 2021
bd20a67
try to print all the folders under android sdk tools dir
Jul 22, 2021
ffd114c
delete the added build.xml for ant
Jul 23, 2021
1a04e00
Merge branch 'ubisoft:dev' into android-sample
dzchen940516 Jul 23, 2021
1816552
Merge branch 'ubisoft:dev' into android-sample
dzchen940516 Aug 26, 2021
ad4337e
adding gradle support for android sample project
Aug 26, 2021
b04173a
fixing helloandroid project in sharpmake compilation error
Aug 30, 2021
1831cc8
android sample project ci changes
Aug 31, 2021
b85f498
update gradle version from 2.8 to 6.5
Aug 31, 2021
9983f5d
try to print exepackaging folder
Sep 1, 2021
f1f2352
try to ls files in exepackaging
Sep 1, 2021
997f297
testing ls on CI
Sep 1, 2021
482a6f9
continue ls exepackaging folder
Sep 1, 2021
0276f4e
testing ci
Sep 1, 2021
a4d4254
check ndk version
Sep 1, 2021
66fd6d3
testing hello android ci
Sep 2, 2021
de39d84
testing hello android ci
Sep 2, 2021
f47eb59
testing hello android ci
Sep 2, 2021
fa41e4d
testing hello android ci
Sep 2, 2021
a6581bb
testing hello android ci
Sep 2, 2021
565d2ef
testing android sample ci
Sep 2, 2021
94001f9
testing android sample ci
Sep 2, 2021
9a47923
testing hello android ci
Sep 3, 2021
0404f3d
testind hello android ci
Sep 3, 2021
abc9423
testing android sample ci
Sep 3, 2021
31ef893
testin android sample ci
Sep 3, 2021
37aa5a8
testing android sample ci
Sep 3, 2021
5af0618
testing android sample ci
Sep 7, 2021
246cee8
testing hello android ci
Sep 7, 2021
e055c3f
testing hello android ci
Sep 7, 2021
9e0f113
testing hello android ci
Sep 8, 2021
27ad57b
testing hello android ci
Sep 8, 2021
8195aa8
Merge branch 'ubisoft:dev' into android-sample
dzchen940516 Sep 8, 2021
048663c
small fixes base on the merge request comments
Sep 28, 2021
3a630b9
testing .yml variables
Sep 28, 2021
8171622
Added some comments to clarify things, and testing defining variables…
Oct 7, 2021
0c51314
testing android sample project ci
Oct 7, 2021
b9bf1b5
testing env variables on the ci
Oct 14, 2021
efb9d35
Testing: move "remove android build tools version" env variable defin…
Oct 19, 2021
72af93d
Testing: moved the definition of the android builld tool version und…
Oct 25, 2021
c3014fa
Testing: moved android build tool versions' definition location in ac…
Oct 25, 2021
c29e055
Added support for IsPublishable C# project config item (#144)
Trithek Sep 15, 2021
f36d27e
Fix xmldoc comment placed on the wrong line
belkiss Sep 15, 2021
a5ff10a
Rename internal method to better match what it does
belkiss Sep 7, 2021
6f80122
Add NMakeForcedIncludes support to MakeFile/FastBuild projects for be…
Sep 23, 2021
751fb49
Add CLanguageStandard/CppLanguageStandard to Linux MakeFile vcxproj f…
Sep 23, 2021
115d28a
Add system includes from ILinuxSystemPathProvider to NMakeIncludeSear…
Sep 23, 2021
645f3ed
Fix concurrency issue in ReportGenerated that could lead to a "key al…
belkiss Sep 27, 2021
7ca150a
Bump version number to 0.17.3
belkiss Sep 28, 2021
b5c1f2b
Make the version unofficial.
belkiss Sep 28, 2021
b607ef0
Prevent the same generation report from being merged from different t…
belkiss Sep 29, 2021
209b66d
[Bff] Move the build only dependencies to the target alias instead of…
belkiss Sep 29, 2021
3e9f721
Bump version number to 0.17.4
belkiss Sep 30, 2021
09ccbd5
Make the version unofficial.
belkiss Sep 30, 2021
48ab0cd
Revert "[Bff] Move the build only dependencies to the target alias in…
belkiss Oct 5, 2021
5e810d2
[Bff] Fix unit-tests step when the target it depends on changes (DLLs…
belkiss Oct 5, 2021
d28015e
Bump version number to 0.17.5
belkiss Oct 6, 2021
9604c6e
Make the version unofficial.
belkiss Oct 6, 2021
355af3d
resolving merge conflicts from dev branch
Oct 26, 2021
ceadea5
resolving merge conflicts from dev
Oct 26, 2021
173afa2
Add support for WinSDK 11 (10.0.22000)
belkiss Oct 14, 2021
af75b98
feat(dotnet): add support for DotNetOSVersion on Configuration to twe…
Oct 18, 2021
2a2d4b6
Fix document format errors
Sep 29, 2021
802045b
resolving merge conflicts from dev branch
Oct 26, 2021
341503c
resolving merge conflicts from dev branch
Oct 26, 2021
c27e97e
Merge branch 'dev' into android-sample
dzchen940516 Oct 26, 2021
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
16 changes: 13 additions & 3 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Sharpmake GitHub Actions CI configuration

name: build
on:
push:
Expand Down Expand Up @@ -249,8 +248,19 @@ jobs:
codebase/temp/bin/mac_${{ matrix.configuration }}_fastbuild/exe
xcodebuild -workspace codebase/temp/solutions/HelloXCode_mac.xcworkspace -configuration ${{ matrix.configuration }} -scheme exe_mac
cd codebase/temp/bin/mac_${{ matrix.configuration }}
DYLD_LIBRARY_PATH=. ./exe

DYLD_LIBRARY_PATH=. ./exe

- name: HelloAndroid ${{ matrix.configuration }}
if: runner.os == 'Windows'
working-directory: 'samples/HelloAndroid'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put the env var here!

env:
REMOVE_ANDROID_BUILD_TOOLS_VERSION: 31.0.0
run: | #Installed Build Tools revision 31.0.0 is corrupted. Need to remove and install again using the SDK Manager.
& $env:SHARPMAKE_EXE "/sources('HelloAndroid.main.sharpmake.cs')"
& $env:ANDROID_HOME/tools/bin/sdkmanager --uninstall "build-tools;${{ env.REMOVE_ANDROID_BUILD_TOOLS_VERSION }}"
& $env:COMPILE_BATCH codebase\temp\solutions\HelloAndroid_android_vs2019.sln "${{ matrix.configuration }}_NoBlob" "arm64_v8a"
& $env:COMPILE_BATCH codebase\temp\solutions\HelloAndroid_android_vs2019.sln "${{ matrix.configuration }}_NoBlob" "x86_64"

- name: NetCore/DotNetCoreFrameworkHelloWorld ${{ matrix.configuration }}
if: runner.os == 'Windows'
working-directory: 'samples/NetCore/DotNetCoreFrameworkHelloWorld'
Expand Down
13 changes: 9 additions & 4 deletions samples/HelloAndroid/HelloAndroid.CommonTarget.sharpmake.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class CommonTarget : Sharpmake.ITarget
public Blob Blob;
public BuildSystem BuildSystem;
public AndroidBuildTargets AndroidBuildTargets = AndroidBuildTargets.arm64_v8a | AndroidBuildTargets.x86_64;
public Android.AndroidBuildType androidBuildType = Android.AndroidBuildType.Ant;
public Android.AndroidBuildType AndroidBuildType = Android.AndroidBuildType.Gradle;

public CommonTarget() { }

Expand All @@ -53,14 +53,16 @@ public class CommonTarget : Sharpmake.ITarget
DevEnv devEnv,
Optimization optimization,
Blob blob,
BuildSystem buildSystem
BuildSystem buildSystem,
Android.AndroidBuildType androidBuildType
)
{
Platform = platform;
DevEnv = devEnv;
Optimization = optimization;
Blob = blob;
BuildSystem = buildSystem;
AndroidBuildType = androidBuildType;
}

public override string Name
Expand All @@ -79,7 +81,9 @@ public override string Name
nameParts.Add(BuildSystem.ToString());
}

return string.Join(" ", nameParts);
//using underscore to join different name parts because gradle is not able to parse
//the names properly if we use space to join them
return string.Join("_", nameParts);
belkiss marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down Expand Up @@ -142,7 +146,8 @@ public static CommonTarget[] GetAndroidTargets()
DevEnv.vs2019,
Optimization.Debug | Optimization.Release,
Blob.NoBlob,
BuildSystem.Default
BuildSystem.Default,
Android.AndroidBuildType.Gradle
);

// make a fastbuild version of the target
Expand Down
7 changes: 7 additions & 0 deletions samples/HelloAndroid/codebase/HelloAndroid.sharpmake.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,31 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System.IO;
using Sharpmake;

namespace HelloAndroid
{
[Sharpmake.Generate]
public class HelloAndroidSolution : CommonSolution
{
public string GradleRootPath = Path.Combine(Globals.TmpDirectory, @"..\..\gradle\root");

public HelloAndroidSolution()
{
AddTargets(CommonTarget.GetDefaultTargets());
Name = "HelloAndroid";

ExePackaging.DirectoryCopyResourceFiles(GradleRootPath, ExePackaging.AndroidPackageProjectsPath + @"\exepackaging");
}


public override void ConfigureAll(Configuration conf, CommonTarget target)
{
base.ConfigureAll(conf, target);

conf.AddProject<ExePackaging>(target);
conf.SetStartupProject<ExePackaging>();
}
}
}
47 changes: 40 additions & 7 deletions samples/HelloAndroid/codebase/exe/exe.sharpmake.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ public override void ConfigureAll(Configuration conf, CommonTarget target)
public override void ConfigureAndroid(Configuration conf, CommonTarget target)
{
base.ConfigureAndroid(conf, target);

conf.Output = Configuration.OutputType.Dll;

// The short name(libxxx.so, xxx is the short name) of App executable .so has to match the name of the project
// because we use one AndroidManifest.xml for all configuration in the sample.
conf.TargetFileName = Name.ToLowerInvariant();
Expand All @@ -64,7 +62,9 @@ public class ExePackaging : AndroidPackageProject

public string ResourceRootPath = Path.Combine(ProjectRootPath, "resources");

public static readonly string AndroidPackagingPath = Path.Combine(Globals.TmpDirectory, @"projects\exepackaging");
public string GradleAppRootPath = Path.Combine(ProjectRootPath, @"gradle\app");

public static readonly string AndroidPackageProjectsPath = Path.Combine(Globals.TmpDirectory, @"projects");

public ExePackaging() : base(typeof(CommonTarget))
{
Expand All @@ -87,12 +87,26 @@ public ExePackaging() : base(typeof(CommonTarget))
SourceFilesExclude.Add("AndroidManifest.xml", "build.xml");

AddTargets(CommonTarget.GetAndroidTargets());

//the plugin and gradle version are good and stable version to be used with Android libraries,
//we don't want to use the default version on VS(ver. 0.4.0 and 2.8 respectively) since it is quite old
GradlePlugin = "gradle:4.2.0";
GradleVersion = "6.7.1";

// Path to the Gradle template files
GradleTemplateFiles.Add(@"app\src\main\AndroidManifest.xml.template");
GradleTemplateFiles.Add(@"app\build.gradle.template");
GradleTemplateFiles.Add(@"build.gradle.template");
GradleTemplateFiles.Add(@"settings.gradle.template");
GradleTemplateFiles.Add(@"gradle\wrapper\gradle-wrapper.properties.template");

ResourceFiles.Add(@"app\src\main\res\values\strings.xml");
}

[Configure(Platform.android)]
public void ConfigureAndroid(Project.Configuration conf, CommonTarget target)
{
conf.Name = Name + "_[target.Optimization]_[target.AndroidBuildTargets]";
conf.Name = target.Name + "_[target.AndroidBuildTargets]";
conf.ProjectPath = Path.Combine(ProjectRootPath, @"codebase\temp\projects\[project.Name]");
conf.ProjectFileName = "[project.Name]_[target.DevEnv]_[target.Platform]";

Expand All @@ -112,10 +126,29 @@ public void ConfigureAndroid(Project.Configuration conf, CommonTarget target)
public override void PostResolve()
{
base.PostResolve();
DirectoryCopyResourceFiles(ResourceRootPath, AndroidPackagingPath);

DirectoryCopyResourceFiles(GradleAppRootPath, Path.Combine(AndroidPackageProjectsPath, Name + "/app"));

string srcAppGradleFile = Path.Combine(AndroidPackageProjectsPath, Name + "/app/build.app.gradle.template");
string destAppGradleFile = Path.Combine(AndroidPackageProjectsPath, Name + "/app/build.gradle.template");

if (File.Exists(destAppGradleFile))
{
File.Delete(destAppGradleFile);
}

// rename gradle template file in app folder
File.Move(srcAppGradleFile, destAppGradleFile);

string MainFolderPath = Path.Combine(AndroidPackageProjectsPath, Name + "/app/src/main");
if (!Directory.Exists(MainFolderPath))
{
Directory.CreateDirectory(MainFolderPath);
}
DirectoryCopyResourceFiles(ResourceRootPath, MainFolderPath);
}

private void DirectoryCopyResourceFiles(string sourceDirName, string destDirName)
public static void DirectoryCopyResourceFiles(string sourceDirName, string destDirName)
{
// Get the subdirectories for the specified directory.
DirectoryInfo dir = new DirectoryInfo(sourceDirName);
Expand Down Expand Up @@ -144,6 +177,6 @@ private void DirectoryCopyResourceFiles(string sourceDirName, string destDirName
}
Util.ForceCopy(srcFile, destFile);
}
}
}
}
}
80 changes: 80 additions & 0 deletions samples/HelloAndroid/gradle/app/build.app.gradle.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
apply plugin: 'com.android.$(ConfigurationType)'

android {
compileSdkVersion = $(AndroidAPILevelNumber)
buildToolsVersion = "$(AndroidBuildToolsVersion)"

defaultConfig.with {
$(ApplicationId)
minSdkVersion = 21
targetSdkVersion = 30
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

flavorDimensions "version"
productFlavors {
create("arm8Debug_NoBlob_arm64_v8a") {
ndk.abiFilters.add("arm64-v8a")
}
create("arm8Release_NoBlob_arm64_v8a") {
ndk.abiFilters.add("arm64-v8a")
}
create("x86-64Debug_NoBlob_x86_64") {
ndk.abiFilters.add("x86_64")
}
create("x86-64Release_NoBlob_x86_64") {
ndk.abiFilters.add("x86_64")
}
create("all")
}

applicationVariants.all { variant ->
variant.outputs.each { output ->
def folder = "${variant.name}"

if(folder.length() > 26) {
def arm8NewName = "app-" + folder.substring(0,4) + "-" + variant.buildType.name + ".apk"
def x86NewName = "app-" + folder.substring(0,6) + "-" + variant.buildType.name + ".apk"
if(folder.substring(0, 9) == "arm8Debug")
{
output.outputFileName = "../../ARM8/Debug_NoBlob_arm64_v8a/" + arm8NewName
}
else if (folder.substring(0, 11) == "arm8Release")
{
output.outputFileName = "../../ARM8/Release_NoBlob_arm64_v8a/" + arm8NewName
}
else if (folder.substring(0, 11) == "x86-64Debug")
{
output.outputFileName = "../../x86-64/Debug_NoBlob_x86_64/" + x86NewName
}
else if (folder.substring(0, 13) == "x86-64Release")
{
output.outputFileName = "../../x86-64/Release_NoBlob_x86_64/" + x86NewName
}
println output.outputFileName
}
}
}
}

repositories {
flatDir {
dirs 'libs'
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
$(AarDependencies)
}
24 changes: 24 additions & 0 deletions samples/HelloAndroid/gradle/root/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apply plugin: 'base'
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:4.2.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
24 changes: 24 additions & 0 deletions samples/HelloAndroid/gradle/root/build.gradle.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apply plugin: 'base'
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:$(GradlePlugin)'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-$(GradleVersion)-all.zip
Loading