tenseleyflow/bencch / 56efe6d

Browse files

Expand fgof campaign coverage

Authored by espadonne
SHA
56efe6d8fcc64bdc186d9c1a0308db6cc8e03125
Parents
ac55ee6
Tree
6042f69

2 changed files

StatusFile+-
M bench/src/project_campaign.rs 97 0
M projects/fortrangoingonforty.afproj 39 0
bench/src/project_campaign.rsmodified
@@ -737,6 +737,9 @@ fn prepare_project_workdir(
737737
             e
738738
         )
739739
     })?;
740
+    if let Some(workspace_root) = project.source.parent() {
741
+        localize_fgof_git_dependencies(&source_root, workspace_root, &root)?;
742
+    }
740743
     Ok(source_root)
741744
 }
742745
 
@@ -773,6 +776,100 @@ fn copy_project_tree(source: &Path, dest: &Path) -> io::Result<()> {
773776
     Ok(())
774777
 }
775778
 
779
+fn localize_fgof_git_dependencies(
780
+    project_root: &Path,
781
+    workspace_root: &Path,
782
+    sandbox_root: &Path,
783
+) -> Result<(), String> {
784
+    let manifest = project_root.join("fpm.toml");
785
+    if !manifest.exists() {
786
+        return Ok(());
787
+    }
788
+
789
+    let original = fs::read_to_string(&manifest)
790
+        .map_err(|e| format!("cannot read '{}': {}", manifest.display(), e))?;
791
+    let mut rewritten = Vec::new();
792
+    let mut changed = false;
793
+    let deps_root = sandbox_root.join("deps");
794
+
795
+    for line in original.lines() {
796
+        if let Some((dep_name, repo_name)) = parse_fgof_git_dependency(line) {
797
+            let local_dep = workspace_root.join(&repo_name);
798
+            if local_dep.exists() {
799
+                let vendored_dep = deps_root.join(&repo_name);
800
+                if !vendored_dep.exists() {
801
+                    copy_project_tree(&local_dep, &vendored_dep).map_err(|e| {
802
+                        format!(
803
+                            "cannot vendor dependency '{}' into '{}': {}",
804
+                            local_dep.display(),
805
+                            vendored_dep.display(),
806
+                            e
807
+                        )
808
+                    })?;
809
+                    localize_fgof_git_dependencies(&vendored_dep, workspace_root, sandbox_root)?;
810
+                }
811
+                let relative = relative_path(project_root, &vendored_dep);
812
+                rewritten.push(format!(
813
+                    "{} = {{ path = \"{}\" }}",
814
+                    dep_name,
815
+                    relative.display()
816
+                ));
817
+                changed = true;
818
+                continue;
819
+            }
820
+        }
821
+        rewritten.push(line.to_string());
822
+    }
823
+
824
+    if changed {
825
+        let mut content = rewritten.join("\n");
826
+        if original.ends_with('\n') {
827
+            content.push('\n');
828
+        }
829
+        fs::write(&manifest, content)
830
+            .map_err(|e| format!("cannot write '{}': {}", manifest.display(), e))?;
831
+    }
832
+
833
+    Ok(())
834
+}
835
+
836
+fn parse_fgof_git_dependency(line: &str) -> Option<(String, String)> {
837
+    let trimmed = line.trim();
838
+    if trimmed.is_empty() || trimmed.starts_with('#') {
839
+        return None;
840
+    }
841
+    let git_prefix = "git = \"https://github.com/FortranGoingOnForty/";
842
+    let git_pos = trimmed.find(git_prefix)?;
843
+    let dep_name = trimmed.split('=').next()?.trim();
844
+    let rest = &trimmed[git_pos + git_prefix.len()..];
845
+    let repo_name = rest.split(".git").next()?.trim();
846
+    if dep_name.is_empty() || repo_name.is_empty() {
847
+        return None;
848
+    }
849
+    Some((dep_name.to_string(), repo_name.to_string()))
850
+}
851
+
852
+fn relative_path(from_dir: &Path, to_path: &Path) -> PathBuf {
853
+    let from_components: Vec<_> = from_dir.components().collect();
854
+    let to_components: Vec<_> = to_path.components().collect();
855
+    let mut common = 0usize;
856
+    while common < from_components.len()
857
+        && common < to_components.len()
858
+        && from_components[common] == to_components[common]
859
+    {
860
+        common += 1;
861
+    }
862
+
863
+    let mut relative = PathBuf::new();
864
+    for _ in common..from_components.len() {
865
+        relative.push("..");
866
+    }
867
+    for component in &to_components[common..] {
868
+        relative.push(component.as_os_str());
869
+    }
870
+    relative
871
+}
872
+
776873
 fn should_skip_copy(name: &std::ffi::OsStr) -> bool {
777874
     matches!(
778875
         name.to_str(),
projects/fortrangoingonforty.afprojmodified
@@ -177,3 +177,42 @@ test => fpm test --compiler "{fc}" --c-compiler "{cc}"
177177
 note "Portable file-watching library with polling backend and watch-session semantics."
178178
 note "Good low-dependency target for filesystem change detection and library packaging behavior."
179179
 end
180
+
181
+project "fgof-temp"
182
+source "../../../fgof-temp"
183
+native "fpm"
184
+priority 15
185
+status active
186
+coverage => pure_semantics, system_interop, performance
187
+library_seed => fortpath
188
+build => fpm build --compiler "{fc}" --c-compiler "{cc}"
189
+test => fpm test --compiler "{fc}" --c-compiler "{cc}"
190
+note "Temp-file, temp-directory, and atomic-write library with real filesystem lifecycle coverage."
191
+note "Good low-noise target for ownership, cleanup, and exact-text I/O truthfulness."
192
+end
193
+
194
+project "fgof-cache"
195
+source "../../../fgof-cache"
196
+native "fpm"
197
+priority 16
198
+status active
199
+coverage => pure_semantics, cross_tu, system_interop, performance
200
+library_seed => fortpath, fortconfig
201
+build => fpm build --compiler "{fc}" --c-compiler "{cc}"
202
+test => fpm test --compiler "{fc}" --c-compiler "{cc}"
203
+note "Disk-cache library with sharding, stale pruning, and atomic text persistence."
204
+note "Good package-style target for layered library dependencies once fgof-temp stays green."
205
+end
206
+
207
+project "fgof-state"
208
+source "../../../fgof-state"
209
+native "fpm"
210
+priority 17
211
+status active
212
+coverage => pure_semantics, cross_tu, system_interop, performance
213
+library_seed => fortconfig, fortpath
214
+build => fpm build --compiler "{fc}" --c-compiler "{cc}"
215
+test => fpm test --compiler "{fc}" --c-compiler "{cc}"
216
+note "Persistent state library with versioned document load/save and atomic replacement."
217
+note "Good package-style target for durable app/workspace state semantics after fgof-temp."
218
+end