forked from JHubi1/ollama-app
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
192 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
// ignore_for_file: avoid_print | ||
|
||
import 'dart:io'; | ||
|
||
void main() async { | ||
if (Directory.current.path.endsWith('scripts')) { | ||
Directory.current = Directory.current.parent; | ||
} | ||
|
||
String flutterExecutable = Platform.isWindows ? 'flutter.bat' : 'flutter'; | ||
|
||
print("Build script for Ollama App by JHubi1"); | ||
print("Report issues at: https://github.com/JHubi1/ollama-app/issues"); | ||
|
||
print('----------'); | ||
|
||
print('Extracting version from pubspec.yaml ...'); | ||
var pubspec = File('pubspec.yaml'); | ||
var versionLine = await pubspec | ||
.readAsLines() | ||
.then((lines) => lines.firstWhere((line) => line.contains('version'))); | ||
var version = versionLine.split(':').last.trim().split('+').first.trim(); | ||
print("Building Ollama App v$version - this may take a while"); | ||
|
||
print('----------'); | ||
|
||
await execute('Android', flutterExecutable, [ | ||
'build', | ||
'apk', | ||
'--obfuscate', | ||
'--split-debug-info=build\\debugAndroid' | ||
]); | ||
|
||
// ---------- | ||
|
||
await execute('Windows x64', flutterExecutable, [ | ||
'build', | ||
'windows', | ||
'--obfuscate', | ||
'--split-debug-info=build\\debugWindows' | ||
]); | ||
|
||
await execute( | ||
'Windows x64 installer', | ||
'iscc.exe', | ||
['windows_installer/x64.iss', '/qp', '/dAppVersion=$version'], | ||
" > Inno Setup is not installed. Please install it from https://www.jrsoftware.org/isdl.php#stable\n Then add the Inno Setup directory to your PATH environment variable."); | ||
|
||
// ---------- | ||
|
||
// not supported by flutter yet | ||
|
||
// await execute('Windows arm64', flutterExecutable, [ | ||
// 'build', | ||
// 'windows', | ||
// '--obfuscate', | ||
// '--split-debug-info=build\\debugWindows' | ||
// ]); | ||
|
||
// await execute( | ||
// 'Windows arm64 installer', | ||
// 'iscc.exe', | ||
// ['windows_installer/arm64.iss', '/qp', '/dAppVersion=$version'], | ||
// " > Inno Setup is not installed. Please install it from https://www.jrsoftware.org/isdl.php#stable\n Then add the Inno Setup directory to your PATH environment variable."); | ||
|
||
print('----------'); | ||
|
||
stdout.write('Copying build output to build\\.output '); | ||
try { | ||
var outputDir = Directory('build\\.output'); | ||
if (await outputDir.exists()) { | ||
await outputDir.delete(recursive: true); | ||
} | ||
await outputDir.create(); | ||
|
||
await copyFile('build\\app\\outputs\\flutter-apk\\app-release.apk', | ||
'build\\.output\\ollama.apk'); | ||
await copyFile('build\\windows\\x64\\runner\\ollama-v$version-x64.exe', | ||
'build\\.output\\ollama-v$version-x64.exe'); | ||
print('- done'); | ||
} catch (_) { | ||
print('- failed'); | ||
} | ||
|
||
print("Output: ${Directory('build\\.output').absolute.path.toString()}"); | ||
|
||
stdout.write('Done. Press Enter to exit. '); | ||
|
||
stdin.readLineSync(); | ||
} | ||
|
||
Future<void> copyFile(String sourcePath, String destinationPath) async { | ||
var sourceFile = File(sourcePath); | ||
if (await sourceFile.exists()) { | ||
await sourceFile.copy(destinationPath); | ||
} | ||
} | ||
|
||
Future<void> execute(String title, String command, List<String> arguments, | ||
[String? errorText]) async { | ||
stdout.write('$title '); | ||
ProcessResult process; | ||
try { | ||
process = await Process.run(command, arguments); | ||
} catch (e) { | ||
print('- failed'); | ||
print("> Errors:"); | ||
stdout.write('\x1B[31m'); | ||
print(e); | ||
stdout.write('\x1B[0m'); | ||
if (errorText != null) { | ||
print(errorText); | ||
} | ||
return; | ||
} | ||
|
||
process.exitCode != 0 ? print('- failed') : print('- done'); | ||
if (process.exitCode != 0) { | ||
print("> Errors:"); | ||
stdout.write('\x1B[31m'); | ||
process.stderr.toString().split('\n').forEach(print); | ||
stdout.write('\x1B[0m'); | ||
if (errorText != null) { | ||
print(errorText); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
; Script generated by the Inno Setup Script Wizard. | ||
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! | ||
|
||
; #define AppVersion "1.0.1" | ||
|
||
#define AppName "Ollama App" | ||
#define AppPublisher "JHubi1" | ||
#define AppURL "https://jhubi1.com" | ||
#define AppExeName "ollama.exe" | ||
#define AppArchitectures "arm64" | ||
|
||
[Setup] | ||
SourceDir=.. | ||
AppId={{4ACF8C84-5D9B-455C-9FED-93D29E2F71DC} | ||
AppName={#AppName} | ||
AppVersion={#AppVersion} | ||
AppVerName={#AppName} v{#AppVersion} | ||
AppPublisher={#AppPublisher} | ||
AppPublisherURL={#AppURL} | ||
ArchitecturesAllowed={#AppArchitectures} | ||
AppSupportURL=https://github.com/JHubi1/ollama-app/issues | ||
AppUpdatesURL=https://github.com/JHubi1/ollama-app/releases | ||
DefaultDirName={autopf}\OllamaApp | ||
DisableProgramGroupPage=yes | ||
LicenseFile=windows_installer\docs\license.txt | ||
InfoBeforeFile=windows_installer\docs\before.txt | ||
InfoAfterFile=windows_installer\docs\after.txt | ||
; Uncomment the following line to run in non administrative install mode (install for current user only.) | ||
;PrivilegesRequired=lowest | ||
PrivilegesRequiredOverridesAllowed=dialog | ||
OutputDir=build\windows\{#AppArchitectures}\runner | ||
OutputBaseFilename=ollama-v{#AppVersion}-{#AppArchitectures} | ||
SetupIconFile=windows\runner\resources\app_icon.ico | ||
;Password=enterPasswordInCaseOfSecretBuild | ||
;Encryption=yes | ||
Compression=lzma | ||
SolidCompression=yes | ||
WizardStyle=modern | ||
|
||
[Languages] | ||
Name: "english"; MessagesFile: "compiler:Default.isl" | ||
Name: "german"; MessagesFile: "compiler:Languages\German.isl" | ||
|
||
[Tasks] | ||
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked | ||
|
||
[Files] | ||
Source: "build\windows\{#AppArchitectures}\runner\Release\{#AppExeName}"; DestDir: "{app}"; Flags: ignoreversion | ||
Source: "build\windows\{#AppArchitectures}\runner\Release\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs | ||
|
||
[Icons] | ||
Name: "{autoprograms}\{#AppName}"; Filename: "{app}\{#AppExeName}" | ||
Name: "{autodesktop}\{#AppName}"; Filename: "{app}\{#AppExeName}"; Tasks: desktopicon | ||
|
||
[Run] | ||
Filename: "{app}\{#AppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(AppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters