Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreOlivierBrillant committed Oct 16, 2024
2 parents 5ba16ec + 5679d7a commit 7a13906
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 15 deletions.
22 changes: 21 additions & 1 deletion scriptsharp/ScriptSharp/CacheCreation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,27 @@ namespace ScriptSharp;

public class CacheCreation
{

/**
* 2 ensembles de sdk / .gradle pour android studio kotlin ET android studio flutter
*
* Une fois une version de Android Studio, on va
* - créer un projet avec le wizard
* - le partir sur un émulateur
* - quand tout est beau on ferme Android Studio et on supprime le .gradle puis le Sdk
* - on ouvre le projet et on crée un émulateur avec la version Android de notre choix
* - on laisse le SDK et le .gradle se remplir en sync compile execute
* - on fait le .gradle.7z et le Sdk.7z
* - on dépose le tout sur ##ed5depinfo
*
* Pour Flutter:
* - on crée un projet et on l'exécute
* - on ferme l'IDE
* - on supprime le .gradle
* - on ouvre le projet et on laisse flutter run
* - on fait .gradle-flutter.7z et Sdk-Android-Flutter.7z
* - hop sur \\ed5depinfo
*
*/
public static async Task HandleCache()
{
Utils.LogAndWriteLine("Creation de la cache ...");
Expand Down
13 changes: 8 additions & 5 deletions scriptsharp/ScriptSharp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ await Utils.CopyFileFromNetworkShareAsync(
DirectoryInfo jdkDirectory = new DirectoryInfo(jdkPath);
string jdkVersion = jdkDirectory.GetDirectories()[0].Name;
string javaHome = Path.Combine(jdkPath, jdkVersion);
Environment.SetEnvironmentVariable("JAVA_HOME", javaHome, EnvironmentVariableTarget.User);
Utils.AddToPath(Path.Combine(javaHome, "bin"));
Environment.SetEnvironmentVariable("JAVA_HOME", javaHome, EnvironmentVariableTarget.User);

Utils.LogAndWriteLine(" FAIT Installation Java");
}

Expand All @@ -153,28 +154,30 @@ public static async Task InstallAndroidSDK()
// fix ANDROID_SDK_ROOT and ANDROID_HOME with GetSDKPath
Utils.LogAndWriteLine("Installation Android SDK démarré");
string sdkPath = Utils.GetSDKPath();
string androidSdkRoot = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Android", "Sdk");
Utils.AddToPath(Path.Combine(androidSdkRoot, "cmdline-tools", "latest", "bin"));
Utils.AddToPath(Path.Combine(androidSdkRoot, "emulator"));
// get the parent directory of the SDK path
string sdkParentPath = Directory.GetParent(sdkPath).FullName;
await Utils.Unzip7zFileAsync(Path.Combine(Config.localTemp,"Sdk.7z"), sdkParentPath);
// Add environment variables
string androidSdkRoot = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Android", "Sdk");
SetEnvironmentVariable("ANDROID_SDK_ROOT", androidSdkRoot);
SetEnvironmentVariable("ANDROID_HOME", androidSdkRoot);

// Append to PATH
Utils.AddToPath(Path.Combine(androidSdkRoot, "cmdline-tools", "latest", "bin"));
Utils.AddToPath(Path.Combine(androidSdkRoot, "emulator"));

Utils.LogAndWriteLine(" FAIT Installation Android SDK complet");
}

public static async Task InstallAndroidStudio()
{
Utils.LogAndWriteLine("Installation Android Studio démarré");
string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
Utils.AddToPath(Path.Combine(desktopPath, "android-studio", "bin"));
string destinationFolder = Path.Combine(desktopPath);
await Utils.Unzip7zFileAsync(Path.Combine(Config.localTemp,"android-studio.7z"), destinationFolder);
// TODO add shortcut
Utils.AddToPath(Path.Combine(desktopPath, "android-studio", "bin"));

Utils.LogAndWriteLine(" FAIT Installation Android Studio fini");
}

Expand Down
2 changes: 1 addition & 1 deletion scriptsharp/ScriptSharp/Script3N5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public static async Task DownloadRepo3N5()
public static async Task Handle3N5KotlinConsoleAsync()
{
Utils.LogAndWriteLine("Installation de kotlin (console) 3N5...");
Utils.AddToPath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "idea", "bin"));
await Task.WhenAll(
Utils.CopyFileFromNetworkShareAsync(
Path.Combine(Config.localCache, "idea.7z"),
Expand All @@ -70,7 +71,6 @@ await Task.WhenAll(
"idea")
),
Program.InstallJava() );
Utils.AddToPath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "idea", "bin"));
Utils.LogAndWriteLine("Premier gradle build pour constituer le .gradle");
// install plugins TODO ? one day?
// Utils.RunCommand("idea64.exe installPlugins io.flutter");
Expand Down
4 changes: 2 additions & 2 deletions scriptsharp/ScriptSharp/Script4N6.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class Script4N6
public static async Task Handle4N6AndroidSpringAsync()
{
Utils.LogAndWriteLine("Installation pour 4N6 Android + serveur Spring ...");
Utils.AddToPath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "idea", "bin"));
await Utils.CopyFileFromNetworkShareAsync(
Path.Combine(Config.localCache, "Sdk.7z"),
Path.Combine(Config.localTemp,"Sdk.7z"));
Expand Down Expand Up @@ -36,8 +37,7 @@ await Task.WhenAll(
DownloadRepo4N6());
// start android studio
Utils.CreateDesktopShortcut("IntelliJ", Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "idea", "bin", "idea64.exe"));
Utils.AddToPath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "idea", "bin"));


await Utils.StartAndroidStudio();
Utils.StartKMB();
Utils.LogAndWriteLine(" FAIT Installation 4N6 Android + serveur Spring ");
Expand Down
13 changes: 7 additions & 6 deletions scriptsharp/ScriptSharp/Script5N6.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ public class Script5N6
public static async Task Handle5N6FlutterAsync()
{
Utils.LogAndWriteLine("Installation de 5N6 flutter (et Android Studio plus Intellij)...");
Utils.AddToPath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "idea", "bin"));
await Utils.CopyFileFromNetworkShareAsync(
Path.Combine(Config.localCache, "Sdk-Android-Flutter.7z"),
Path.Combine(Config.localTemp, "Sdk.7z") );
await Task.WhenAll(
Program.InstallAndroidSDK(),
Utils.CopyFileFromNetworkShareAsync(
Path.Combine(Config.localCache, ".gradle.7z"),
Path.Combine(Config.localCache, ".gradle-Android-Flutter.7z"),
Path.Combine(Config.localTemp, ".gradle.7z")),
Program.InstallJava(),
Utils.CopyFileFromNetworkShareAsync(
Expand All @@ -34,29 +35,29 @@ await Task.WhenAll(
Program.InstallAndroidStudio(),
Program.DownloadRepoKMB(),
DownloadRepo5N6());
Utils.CreateDesktopShortcut("IntelliJ", Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "idea", "bin", "idea64.exe"));
Utils.AddToPath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "idea", "bin"));

Utils.RunCommand("studio64.exe installPlugins io.flutter");
Utils.RunCommand("studio64.exe installPlugins com.github.copilot");
Utils.RunCommand("studio64.exe installPlugins com.localizely.flutter-intl");
await InstallFlutter();
Utils.StartKMB();
await Utils.StartAndroidStudio();
Utils.CreateDesktopShortcut("IntelliJ", Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "idea", "bin", "idea64.exe"));
Utils.LogAndWriteLine(" FAIT 5N6 Flutter complet");
}

private static async Task InstallFlutter()
{
Utils.LogAndWriteLine("Installation Flutter démarré");
// ajouter flutter au path
Utils.AddToPath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "flutter", "bin"));
// TODO remove this in favor of cache flutter
await Utils.CopyFileFromNetworkShareAsync(
Path.Combine(Config.localCache, "flutter.7z"),
Path.Combine(Config.localTemp, "flutter.7z"));
await Utils.Unzip7zFileAsync(
Path.Combine(Config.localTemp, "flutter.7z"),
Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
// ajouter flutter au path
Utils.AddToPath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "flutter", "bin"));
// execute "flutter doctor --android-licenses"
Utils.RunCommand("flutter config --android-sdk "+Utils.GetSDKPath());
Utils.RunCommand("flutter config --android-studio-dir "+Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "android-studio"));
Expand All @@ -78,7 +79,7 @@ await Utils.CopyFileFromNetworkShareAsync(
await Task.WhenAll(
Program.InstallAndroidSDK(),
Utils.CopyFileFromNetworkShareAsync(
Path.Combine(Config.localCache, ".gradle.7z"),
Path.Combine(Config.localCache, ".gradle-Android-Flutter.7z"),
Path.Combine(Config.localTemp, ".gradle.7z")),
Program.InstallJava(),
Utils.CopyFileFromNetworkShareAsync(
Expand Down

0 comments on commit 7a13906

Please sign in to comment.