forked from firka/firka
chore: update codegen, build configs
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -100,9 +100,12 @@ firka/debug-info/
|
||||
**/.env*
|
||||
**/*.dart.js
|
||||
**/*.info.json
|
||||
**/*.g.dart
|
||||
**/.codegen-cache.yaml
|
||||
|
||||
# tools.py logs
|
||||
tool_logs/build/*.log
|
||||
tool_logs/d8dx_fix/*.log
|
||||
tool_logs/pub_fix/*.log
|
||||
secrets/upload_certificate.pem
|
||||
secrets (2)/upload_certificate.pem
|
||||
|
||||
@@ -18,6 +18,14 @@ subprojects {
|
||||
if (project.name != "app") {
|
||||
project.evaluationDependsOn(":app")
|
||||
|
||||
// android_alarm_manager_plus 5.1.1's own build.gradle.kts only applies
|
||||
// org.jetbrains.kotlin.android when AGP < 9, then unconditionally
|
||||
// configures KotlinAndroidProjectExtension - which doesn't exist here
|
||||
// on AGP 9+ unless we apply the plugin ourselves first.
|
||||
if (project.name == "android_alarm_manager_plus") {
|
||||
pluginManager.apply("org.jetbrains.kotlin.android")
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
if (plugins.hasPlugin("com.android.library")) {
|
||||
extensions.configure<LibraryExtension> {
|
||||
|
||||
@@ -1,22 +1,10 @@
|
||||
icons:
|
||||
"flutter_launcher_icons.yaml": "c600507ca0df7cebd0f708124842512a14ed3d597b779176200d6ba25b1335b1"
|
||||
"pubspec.yaml": "5d40f014d654e257bc58e8ebfb2468a5ed7f75d913a67fb89314b9fda1c257a6"
|
||||
"flutter_launcher_icons.yaml": "993c1cd3a99db70747299601e556d19ec959b0a16fd9ff2dbf2386cb6f2a640d"
|
||||
"pubspec.yaml": "198608775541fab3b6ff8cc21545e12a3413455f6ed87355cfdb576a97efab2d"
|
||||
"assets/images/logos/colored_logo.webp": "4b4fa99d144fe6694aa4487ba1b26aeecafae41e3c877836cd7da28d61a77983"
|
||||
"assets/images/logos/monochrome_logo.png": "188d2b0a64c70323b09bcee721663d6698fb557066f20ddaec97bba6869c1c6c"
|
||||
"assets/images/logos/monochrome_logo.png": "c269a5e689622484d800a4fda5927591a0bf99d34790a4f146b93cf6edabd455"
|
||||
"assets/images/logos/colored_logo_without_mustache.png": "d11cff9f38985885873bfdd2d84e61f8fab03803eada94d4caac1545ef3685f3"
|
||||
"assets/images/logos/colored_logo_only_mustache.png": "bad6220c11bdfb1dfe04e5173bd2ebedd3999689d4b3a68fc63dc520c96dd33b"
|
||||
l10n:
|
||||
"l10n.yml": "a57bc304cac4a2b0235593586f17f400a5165d67fc9aadeaa11893cfa36ee082"
|
||||
"lib/l10n/app_pl.arb": "a8426455757e587c7635c3a62c650a4aae2a0cac1de1175e8ab7fb0d3b387537"
|
||||
"lib/l10n/app_de.arb": "c498950bbc917e35b1910451ad9fbd4e625db89151f07558e846a7c119a583af"
|
||||
"lib/l10n/app_en.arb": "159405752b5e73eedbe546a59567550091926a37cf9cf6ce78dd58f1a0dd1d4b"
|
||||
"lib/l10n/app_hu.arb": "c7fba2a8f91217433698d766e9451d8fad86ae71021adf714639fc3907a34891"
|
||||
isar:
|
||||
"lib/data/models/app_settings_model.dart": "5eb5af345f1347f104257f0999763650fe2673f9da1754bd12d3f756fe5c9723"
|
||||
"lib/data/models/token_model.dart": "8c957cd07e473827d78fd8fd4fb6c1336b636a69c25c93618e1e7f94b7cf0683"
|
||||
"lib/data/models/homework_cache_model.dart": "45789970b27d5790cdc54c292ef2f5feaa5f4e293b8a8862fd676d5eb3e25d29"
|
||||
"lib/data/models/generic_cache_model.dart": "62003ec1fd73a0fa6786d337acdef42b9a6eb9efaa78d17eaf4fe091504b8490"
|
||||
"lib/data/models/timetable_cache_model.dart": "b972bf51e399f8d20d4f9ad660082d4cc4a9798df9ac9d6ec9ef6ac640205572"
|
||||
splash:
|
||||
"flutter_native_splash.yaml": "0fd4a85d6f950d97298e99916927649940ffcfdadfc136ceee126fed0dbaa9f2"
|
||||
"flutter_native_splash.yaml": "f1bddb74798b1539c4e9213ca9ae305d625ebb0ac5bcbe079b523437e0abc2c4"
|
||||
"assets/images/logos/splash.png": "88fbebc3d686cb9095bcce362029b69978b1b14270e465e91d962b1425db1152"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
flutter_launcher_icons:
|
||||
generate: true
|
||||
android: "launcher_icon"
|
||||
ios: false
|
||||
image_path: "assets/images/logos/colored_logo.webp"
|
||||
adaptive_icon_monochrome: "assets/images/logos/monochrome_logo.png"
|
||||
adaptive_icon_background: "assets/images/logos/colored_logo_without_mustache.png"
|
||||
|
||||
@@ -17,4 +17,6 @@ flutter_native_splash:
|
||||
icon_background_color: "#7ca120"
|
||||
icon_background_color_dark: "#7ca120"
|
||||
|
||||
android: true
|
||||
ios: false
|
||||
web: false
|
||||
|
||||
@@ -6,10 +6,12 @@ import 'package:path/path.dart' as p;
|
||||
import 'package:yaml/yaml.dart' as yaml;
|
||||
|
||||
const _lockFileName = 'codegen-lock.yaml';
|
||||
const _cacheFileName = '.codegen-cache.yaml';
|
||||
|
||||
void main() async {
|
||||
final root = _projectRoot();
|
||||
stdout.writeln(root);
|
||||
_cleanIos(root);
|
||||
var ran = false;
|
||||
|
||||
if (_iconsOutOfDate(root)) {
|
||||
@@ -31,6 +33,7 @@ void main() async {
|
||||
runInShell: true,
|
||||
);
|
||||
if (iconResult.exitCode == 0) {
|
||||
_cleanIos(root);
|
||||
_updateLockWithHashes(root, 'icons', _computeHashes(root, inputs));
|
||||
ran = true;
|
||||
}
|
||||
@@ -53,19 +56,23 @@ void main() async {
|
||||
'--template-arb-file',
|
||||
'app_hu.arb',
|
||||
], root);
|
||||
_updateLockWithHashes(root, 'l10n', _computeHashes(root, inputs));
|
||||
_updateCacheWithHashes(root, 'l10n', _computeHashes(root, inputs));
|
||||
ran = true;
|
||||
}
|
||||
|
||||
var common = p.join(p.dirname(root), "firka_common");
|
||||
if (_isarOutOfDate(common) || _isarGeneratedFilesMissing(common)) {
|
||||
final common = p.join(p.dirname(root), 'firka_common');
|
||||
if (_isarOutOfDate(common)) {
|
||||
final inputs = _isarInputs(common);
|
||||
final hashes = _computeHashes(common, inputs);
|
||||
stdout.writeln(
|
||||
'Isar generated dart files out of date or missing, running build_runner...',
|
||||
);
|
||||
await _run('dart', ['run', 'build_runner', 'build'], common);
|
||||
_updateLockWithHashes(common, 'isar', hashes);
|
||||
await _run(
|
||||
'dart',
|
||||
['run', 'build_runner', 'build', '--delete-conflicting-outputs'],
|
||||
common,
|
||||
);
|
||||
_updateCacheWithHashes(common, 'isar', hashes);
|
||||
ran = true;
|
||||
}
|
||||
|
||||
@@ -76,10 +83,13 @@ void main() async {
|
||||
'Splash out of date, running flutter_native_splash:create...',
|
||||
);
|
||||
await _run('dart', ['run', 'flutter_native_splash:create'], root);
|
||||
_cleanIos(root);
|
||||
_updateLockWithHashes(root, 'splash', _computeHashes(root, inputs));
|
||||
ran = true;
|
||||
}
|
||||
|
||||
_cleanIos(root);
|
||||
|
||||
if (!ran) {
|
||||
stdout.writeln('All generated files are up to date.');
|
||||
}
|
||||
@@ -91,9 +101,10 @@ String _projectRoot() {
|
||||
}
|
||||
|
||||
String _lockPath(String root) => p.join(root, _lockFileName);
|
||||
String _cachePath(String root) => p.join(root, _cacheFileName);
|
||||
|
||||
Map<String, Map<String, String>>? _readLock(String root) {
|
||||
final file = File(_lockPath(root));
|
||||
Map<String, Map<String, String>>? _readYamlFile(String filePath) {
|
||||
final file = File(filePath);
|
||||
if (!file.existsSync()) return null;
|
||||
try {
|
||||
final content = file.readAsStringSync();
|
||||
@@ -116,9 +127,9 @@ Map<String, Map<String, String>>? _readLock(String root) {
|
||||
}
|
||||
}
|
||||
|
||||
void _writeLock(String root, Map<String, Map<String, String>> lock) {
|
||||
void _writeYamlFile(String filePath, Map<String, Map<String, String>> data) {
|
||||
final buf = StringBuffer();
|
||||
for (final stepEntry in lock.entries) {
|
||||
for (final stepEntry in data.entries) {
|
||||
buf.writeln('${stepEntry.key}:');
|
||||
for (final fileEntry in stepEntry.value.entries) {
|
||||
buf.writeln(
|
||||
@@ -126,9 +137,15 @@ void _writeLock(String root, Map<String, Map<String, String>> lock) {
|
||||
);
|
||||
}
|
||||
}
|
||||
File(_lockPath(root)).writeAsStringSync(buf.toString());
|
||||
File(filePath).writeAsStringSync(buf.toString());
|
||||
}
|
||||
|
||||
Map<String, Map<String, String>>? _readLock(String root) =>
|
||||
_readYamlFile(_lockPath(root));
|
||||
|
||||
Map<String, Map<String, String>>? _readCache(String root) =>
|
||||
_readYamlFile(_cachePath(root));
|
||||
|
||||
String _escapeYaml(String s) =>
|
||||
s.replaceAll('\\', '\\\\').replaceAll('"', '\\"');
|
||||
|
||||
@@ -148,10 +165,10 @@ bool _hashesMatch(
|
||||
String root,
|
||||
String stepName,
|
||||
List<File> inputs,
|
||||
Map<String, Map<String, String>>? lock,
|
||||
Map<String, Map<String, String>>? lockOrCache,
|
||||
) {
|
||||
if (lock == null || !lock.containsKey(stepName)) return false;
|
||||
final stepHashes = lock[stepName]!;
|
||||
if (lockOrCache == null || !lockOrCache.containsKey(stepName)) return false;
|
||||
final stepHashes = lockOrCache[stepName]!;
|
||||
for (final f in inputs) {
|
||||
final rel = _relativePath(root, f);
|
||||
final stored = stepHashes[rel];
|
||||
@@ -172,22 +189,24 @@ void _updateLockWithHashes(
|
||||
) {
|
||||
final lock = _readLock(root) ?? <String, Map<String, String>>{};
|
||||
lock[stepName] = Map.from(hashes);
|
||||
_writeLock(root, lock);
|
||||
_writeYamlFile(_lockPath(root), lock);
|
||||
}
|
||||
|
||||
DateTime? _modified(File file) {
|
||||
if (!file.existsSync()) return null;
|
||||
return file.lastModifiedSync();
|
||||
void _updateCacheWithHashes(
|
||||
String root,
|
||||
String stepName,
|
||||
Map<String, String> hashes,
|
||||
) {
|
||||
final cache = _readCache(root) ?? <String, Map<String, String>>{};
|
||||
cache[stepName] = Map.from(hashes);
|
||||
_writeYamlFile(_cachePath(root), cache);
|
||||
}
|
||||
|
||||
bool _anyNewerThan(Iterable<File> inputs, File output) {
|
||||
final outTime = _modified(output);
|
||||
if (outTime == null) return true;
|
||||
for (final f in inputs) {
|
||||
final t = _modified(f);
|
||||
if (t != null && t.isAfter(outTime)) return true;
|
||||
void _cleanIos(String root) {
|
||||
final iosDir = Directory(p.join(root, 'ios'));
|
||||
if (iosDir.existsSync()) {
|
||||
iosDir.deleteSync(recursive: true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
List<File> _iconsInputs(String root) {
|
||||
@@ -217,7 +236,7 @@ bool _iconsOutOfDate(String root) {
|
||||
'android/app/src/main/res/mipmap-anydpi-v26/launcher_icon.xml',
|
||||
),
|
||||
);
|
||||
if (!_anyNewerThan(inputs, output)) return false;
|
||||
if (!output.existsSync()) return true;
|
||||
return !_hashesMatch(root, 'icons', inputs, _readLock(root));
|
||||
}
|
||||
|
||||
@@ -233,11 +252,28 @@ List<File> _l10nInputs(String root) {
|
||||
return [l10nYml, ...arbs].where((f) => f.existsSync()).cast<File>().toList();
|
||||
}
|
||||
|
||||
bool _l10nGeneratedFilesMissing(String root) {
|
||||
final l10nDir = p.join(root, 'lib/l10n');
|
||||
final mainOutput = File(p.join(l10nDir, 'app_localizations.dart'));
|
||||
if (!mainOutput.existsSync()) return true;
|
||||
final dir = Directory(l10nDir);
|
||||
if (!dir.existsSync()) return true;
|
||||
for (final file in dir.listSync().whereType<File>()) {
|
||||
if (file.path.endsWith('.arb')) {
|
||||
final base = p.basenameWithoutExtension(file.path);
|
||||
final genFile = File(
|
||||
p.join(l10nDir, '${base.replaceFirst("app_", "app_localizations_")}.dart'),
|
||||
);
|
||||
if (!genFile.existsSync()) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool _l10nOutOfDate(String root) {
|
||||
final inputs = _l10nInputs(root);
|
||||
final output = File(p.join(root, 'lib/l10n/app_localizations.dart'));
|
||||
if (!_anyNewerThan(inputs, output)) return false;
|
||||
return !_hashesMatch(root, 'l10n', inputs, _readLock(root));
|
||||
if (_l10nGeneratedFilesMissing(root)) return true;
|
||||
return !_hashesMatch(root, 'l10n', inputs, _readCache(root));
|
||||
}
|
||||
|
||||
List<File> _isarInputs(String root) {
|
||||
@@ -253,20 +289,6 @@ List<File> _isarInputs(String root) {
|
||||
return list;
|
||||
}
|
||||
|
||||
bool _isarOutOfDate(String root) {
|
||||
final inputs = _isarInputs(root);
|
||||
if (inputs.isEmpty) return false;
|
||||
final modelsDir = p.join(root, 'lib/data/models');
|
||||
for (final dartFile in inputs) {
|
||||
final baseName = p.basenameWithoutExtension(dartFile.path);
|
||||
final gFile = File(p.join(modelsDir, '$baseName.g.dart'));
|
||||
if (_anyNewerThan([dartFile], gFile)) {
|
||||
return !_hashesMatch(root, 'isar', inputs, _readLock(root));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool _isarGeneratedFilesMissing(String root) {
|
||||
final inputs = _isarInputs(root);
|
||||
if (inputs.isEmpty) return false;
|
||||
@@ -279,6 +301,13 @@ bool _isarGeneratedFilesMissing(String root) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool _isarOutOfDate(String root) {
|
||||
final inputs = _isarInputs(root);
|
||||
if (inputs.isEmpty) return false;
|
||||
if (_isarGeneratedFilesMissing(root)) return true;
|
||||
return !_hashesMatch(root, 'isar', inputs, _readCache(root));
|
||||
}
|
||||
|
||||
List<File> _splashInputs(String root) {
|
||||
final config = File(p.join(root, 'flutter_native_splash.yaml'));
|
||||
final splashImage = File(p.join(root, 'assets/images/logos/splash.png'));
|
||||
@@ -294,7 +323,11 @@ bool _splashOutOfDate(String root) {
|
||||
final output = File(
|
||||
p.join(root, 'android/app/src/main/res/drawable/launch_background.xml'),
|
||||
);
|
||||
if (!_anyNewerThan(inputs, output)) return false;
|
||||
if (!output.existsSync()) return true;
|
||||
final splash12 = File(
|
||||
p.join(root, 'assets/images/logos/splash_android12.png'),
|
||||
);
|
||||
if (!splash12.existsSync()) return true;
|
||||
return !_hashesMatch(root, 'splash', inputs, _readLock(root));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user