add buildtime injectable build version and date
This commit is contained in:
parent
acd7fc8259
commit
40bc2a46e3
|
@ -0,0 +1,6 @@
|
||||||
|
const dev_version = "development";
|
||||||
|
|
||||||
|
class EnvironmentConfig {
|
||||||
|
static const BUILD_VER = String.fromEnvironment('BUILD_VER', defaultValue: dev_version);
|
||||||
|
static const BUILD_DATE = String.fromEnvironment('BUILD_DATE', defaultValue: "now");
|
||||||
|
}
|
|
@ -9,6 +9,8 @@ import 'package:path/path.dart' as path;
|
||||||
import 'package:ffi/ffi.dart';
|
import 'package:ffi/ffi.dart';
|
||||||
import 'package:cwtch/cwtch/cwtch.dart';
|
import 'package:cwtch/cwtch/cwtch.dart';
|
||||||
|
|
||||||
|
import '../config.dart';
|
||||||
|
|
||||||
/////////////////////
|
/////////////////////
|
||||||
/// Cwtch API ///
|
/// Cwtch API ///
|
||||||
/////////////////////
|
/////////////////////
|
||||||
|
@ -84,7 +86,10 @@ class CwtchFfi implements Cwtch {
|
||||||
home = (envVars['UserProfile'])!;
|
home = (envVars['UserProfile'])!;
|
||||||
bundledTor = "Tor\\Tor\\tor.exe";
|
bundledTor = "Tor\\Tor\\tor.exe";
|
||||||
}
|
}
|
||||||
var cwtchDir = path.join(home, ".cwtch/dev/");
|
var cwtchDir = path.join(home, ".cwtch");
|
||||||
|
if (EnvironmentConfig.BUILD_VER == dev_version) {
|
||||||
|
cwtchDir = path.join(cwtchDir, "dev");
|
||||||
|
}
|
||||||
print("cwtchDir $cwtchDir");
|
print("cwtchDir $cwtchDir");
|
||||||
|
|
||||||
var startCwtchC = library.lookup<NativeFunction<start_cwtch_function>>("c_StartCwtch");
|
var startCwtchC = library.lookup<NativeFunction<start_cwtch_function>>("c_StartCwtch");
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:cwtch/config.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
@ -44,7 +45,10 @@ class CwtchGomobile implements Cwtch {
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
Future<void> Start() async {
|
Future<void> Start() async {
|
||||||
print("gomobile.dart: Start()...");
|
print("gomobile.dart: Start()...");
|
||||||
var cwtchDir = path.join((await androidHomeDirectory).path, ".cwtch/dev/");
|
var cwtchDir = path.join((await androidHomeDirectory).path, ".cwtch");
|
||||||
|
if (EnvironmentConfig.BUILD_VER == dev_version) {
|
||||||
|
cwtchDir = path.join(cwtchDir, "dev");
|
||||||
|
}
|
||||||
String torPath = path.join(await androidLibraryDir, "libtor.so");
|
String torPath = path.join(await androidLibraryDir, "libtor.so");
|
||||||
print("gomobile.dart: Start invokeMethod Start($cwtchDir, $torPath)...");
|
print("gomobile.dart: Start invokeMethod Start($cwtchDir, $torPath)...");
|
||||||
cwtchPlatform.invokeMethod("Start", {"appDir": cwtchDir, "torPath": torPath});
|
cwtchPlatform.invokeMethod("Start", {"appDir": cwtchDir, "torPath": torPath});
|
||||||
|
|
|
@ -7,6 +7,7 @@ import 'package:provider/provider.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||||
|
|
||||||
import '../main.dart';
|
import '../main.dart';
|
||||||
|
import '../config.dart';
|
||||||
|
|
||||||
/// Global Settings View provides access to modify all the Globally Relevant Settings including Locale, Theme and Experiments.
|
/// Global Settings View provides access to modify all the Globally Relevant Settings including Locale, Theme and Experiments.
|
||||||
class GlobalSettingsView extends StatefulWidget {
|
class GlobalSettingsView extends StatefulWidget {
|
||||||
|
@ -156,7 +157,7 @@ class _GlobalSettingsViewState extends State<GlobalSettingsView> {
|
||||||
height: 128,
|
height: 128,
|
||||||
)),
|
)),
|
||||||
applicationName: "Cwtch (Flutter UI)",
|
applicationName: "Cwtch (Flutter UI)",
|
||||||
applicationVersion: AppLocalizations.of(context)!.version.replaceAll("%1", constructVersionString(Provider.of<Settings>(context).packageInfo)),
|
applicationVersion: AppLocalizations.of(context)!.versionBuilddate.replaceAll("%1", EnvironmentConfig.BUILD_VER).replaceAll("%2", EnvironmentConfig.BUILD_DATE),
|
||||||
applicationLegalese: '\u{a9} 2021 Open Privacy Research Society',
|
applicationLegalese: '\u{a9} 2021 Open Privacy Research Society',
|
||||||
),
|
),
|
||||||
]))));
|
]))));
|
||||||
|
|
Loading…
Reference in New Issue