@@ -1070,8 +1070,76 @@ private void compileLibrary(UserLibrary lib, List<File> includeFolders)
1070
1070
if (lib .useRecursion ()) {
1071
1071
// libBuildFolder == {build.path}/LibName
1072
1072
// libFolder == {lib.path}/src
1073
- recursiveCompileFilesInFolder (libBuildFolder , libFolder , includeFolders );
1074
-
1073
+
1074
+ // Compile the library with .a linkage if a flag was set in library.properties
1075
+ if (lib .alinkage ()){
1076
+
1077
+ File afile = new File (libBuildFolder , lib .getName () + ".a" );
1078
+
1079
+ createFolder (libBuildFolder );
1080
+ List <File > libraryObjectFiles = compileFiles (libBuildFolder , libFolder , true , includeFolders );
1081
+
1082
+ // See if the .a file is already uptodate
1083
+ if (afile .exists ()) {
1084
+ boolean changed = false ;
1085
+ for (File file : libraryObjectFiles ) {
1086
+ if (file .lastModified () > afile .lastModified ()) {
1087
+ changed = true ;
1088
+ break ;
1089
+ }
1090
+ }
1091
+
1092
+ // If none of the object files is newer than the .a file, don't
1093
+ // bother rebuilding the .a file. There is a small corner case
1094
+ // here: If a source file was removed, but no other source file
1095
+ // was modified, this will not rebuild core.a even when it
1096
+ // should. It's hard to fix and not a realistic case, so it
1097
+ // shouldn't be a problem.
1098
+ if (!changed ) {
1099
+ if (verbose )
1100
+ System .out .println (I18n .format (tr ("Using previously compiled file: {0}" ), afile .getPath ()));
1101
+
1102
+ // this is no longer an object file, but will be added anyways.
1103
+ objectFiles .add (afile );
1104
+ return ;
1105
+ }
1106
+ }
1107
+
1108
+ // Delete the .a file, to prevent any previous code from lingering
1109
+ afile .delete ();
1110
+
1111
+ try {
1112
+ for (File file : libraryObjectFiles ) {
1113
+ PreferencesMap dict = new PreferencesMap (prefs );
1114
+ dict .put ("ide_version" , "" + BaseNoGui .REVISION );
1115
+ dict .put ("archive_file" , afile .getName ());
1116
+ dict .put ("object_file" , file .getAbsolutePath ());
1117
+ dict .put ("build.path" , libBuildFolder .getAbsolutePath ());
1118
+
1119
+ String [] cmdArray ;
1120
+ String cmd = prefs .getOrExcept ("recipe.ar.pattern" );
1121
+ try {
1122
+ cmdArray = StringReplacer .formatAndSplit (cmd , dict , true );
1123
+ } catch (Exception e ) {
1124
+ throw new RunnerException (e );
1125
+ }
1126
+ execAsynchronously (cmdArray );
1127
+ }
1128
+
1129
+ } catch (RunnerException e ) {
1130
+ afile .delete ();
1131
+ throw e ;
1132
+ }
1133
+
1134
+ // this is no longer an object file, but will be added anyways.
1135
+ objectFiles .add (afile );
1136
+ }
1137
+
1138
+ // no alinkage, old, default .o file linkage
1139
+ else {
1140
+ recursiveCompileFilesInFolder (libBuildFolder , libFolder , includeFolders );
1141
+ }
1142
+
1075
1143
} else {
1076
1144
// libFolder == {lib.path}/
1077
1145
// utilityFolder == {lib.path}/utility
0 commit comments