Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
5ddd70e
#fix - solving an error generated in the latest release for the tests…
TheRustifyer Mar 5, 2023
88a55c9
Merge branch 'zerodaycode:main' into main
TheRustifyer Mar 5, 2023
7812281
#fix - disabling the cache for Clang when process BMI's, since Unix s…
TheRustifyer Mar 5, 2023
ffa3a7d
#fix - Cleaned useless logs in the BMIs generation
TheRustifyer Mar 5, 2023
35a5845
Joining the base paths to the module files when the reader assembles …
TheRustifyer Mar 5, 2023
6e2bd84
Enabling a boolean flag to indicate whenever the user wants to genera…
TheRustifyer Mar 5, 2023
dd8506d
Initial implementation of the generation of a database compilation
TheRustifyer Mar 5, 2023
af08d69
Denying all the unknown fields, instead of silently ignore them when …
TheRustifyer Mar 5, 2023
24db40a
Full paths for the compilation database 'directory' property. NEW att…
TheRustifyer Mar 5, 2023
a004540
Caching how the files are flagged to avoid rebuild them. Now they are…
TheRustifyer Mar 5, 2023
ff61f1e
Removing reference types for project_model::CppCompiler, which is che…
TheRustifyer Mar 6, 2023
a8b9898
Solved the need of MSVC for storing the output generated files paths …
TheRustifyer Mar 6, 2023
7029d16
WIP - Working with absolute paths since the creation of the project m…
TheRustifyer Mar 6, 2023
80d2c62
Rework of the translation unit trait
TheRustifyer Mar 6, 2023
453b69c
WIP - Refactoring the whole flux, since the initial parsing to the ge…
TheRustifyer Mar 7, 2023
8ecbb54
Removed `test_mode` function parameter from the run_generated_command…
TheRustifyer Mar 8, 2023
eb4b08b
WIP - Non module source files with their own build and assemble proce…
TheRustifyer Mar 9, 2023
63104f1
Giving to the linker the correct object files, and not the sources
TheRustifyer Mar 9, 2023
cef0a1b
Upgraded the lookup algorithm for retrieve the details of a cached so…
TheRustifyer Mar 9, 2023
ad7fd9a
System modules now deserves their own place, without being merged wit…
TheRustifyer Mar 9, 2023
edb5e13
Cleaned and merged the logic for executing commands for interfaces, i…
TheRustifyer Mar 9, 2023
c5327f8
Cleaned and merged the logic for executing commands for interfaces, i…
TheRustifyer Mar 9, 2023
cf04806
Merge branch 'sources-compiled-without-linking'
TheRustifyer Mar 9, 2023
9f4055c
Removing the generated command lines for the per cycle cache executio…
TheRustifyer Mar 9, 2023
763f645
Distinction for the cached main command line command, depending on if…
TheRustifyer Mar 9, 2023
d5ca4c6
Readjusted the example file
TheRustifyer Mar 9, 2023
ad8c849
More adjusts
TheRustifyer Mar 10, 2023
ae4587f
Reworking the test for the project model because the full paths now s…
Mar 10, 2023
788b152
Refactored and generified the work of convert the generated command l…
TheRustifyer Mar 12, 2023
b8ee0dd
Added the compiler's driver name to the beginning of the generated co…
TheRustifyer Mar 12, 2023
879dbeb
Reenabled the addition of the linker command to the last_generated_co…
TheRustifyer Mar 12, 2023
a4e19e0
Reworking the compilation database, and moving their components into …
TheRustifyer Mar 12, 2023
ea1c57f
Solving the problem of the double incremental time of the cache loadi…
TheRustifyer Mar 12, 2023
1972a06
Code reworked to remove the interior mutability pattern in favor or r…
TheRustifyer Mar 12, 2023
bf27d6a
Merge branch 'zerodaycode:main' into main
TheRustifyer Mar 12, 2023
668d180
Version 0.8.0
TheRustifyer Mar 12, 2023
2e8a464
Merge branch 'zerodaycode:main' into main
TheRustifyer Mar 14, 2023
33d0a7b
removed the restriction of choose the standard library only in OS tha…
TheRustifyer Mar 14, 2023
5d2846f
The output directory now is an absolute path
TheRustifyer Mar 14, 2023
38f8534
Solved issues with absolute paths for unit tests that was using mocke…
TheRustifyer Mar 15, 2023
c5b917e
Updating the CHANGELOG.md to reflect the upcoming ideas that will be …
TheRustifyer Mar 15, 2023
37ca2a6
Version 0.8.1
Mar 15, 2023
8bde361
Cleaning death code
TheRustifyer Mar 16, 2023
a7e3e0b
Version 0.8.2 - Vec<Argument> now it's replaced by Argument, a strong…
TheRustifyer Mar 16, 2023
b0026d8
Version 0.8.3 - The modules key of the configuration file got a new p…
TheRustifyer Mar 16, 2023
4819dfb
Formatting adjustements and deactivating Clang's test because the Cla…
TheRustifyer Mar 17, 2023
17ca263
Merge branch 'main' of https://github.com/zerodaycode/Zork
Apr 2, 2023
701236b
Solved the duplicated error message when some compiler execution retu…
Apr 2, 2023
ec5c836
Shortened the error message when the build fails for a concrete file
Apr 2, 2023
6d1d853
V0.8.4
TheRustifyer Apr 2, 2023
319ae9b
Merge branch 'zerodaycode:main' into main
TheRustifyer Apr 5, 2023
5e06bd0
Merge branch 'zerodaycode:main' into main
TheRustifyer Apr 5, 2023
c3f85a9
Started initial work for implement workspaces like Cargo in Zork++
TheRustifyer Apr 26, 2023
27d0f8b
WIP - Refactoring the main processor loop for the config files parsing
TheRustifyer Apr 28, 2023
c90dee6
Solved the issues with the toml deserialization lifetimes. Now, we ha…
Jul 30, 2023
b16ae51
code: merged changes of the latest release with the workspaces PR
TheRustifyer Nov 28, 2023
9208bc3
Merge branch 'zerodaycode:main' into main
TheRustifyer Jan 17, 2024
e8d50cd
Merge branch 'zerodaycode:main' into main
TheRustifyer Apr 7, 2024
98f57eb
Merge branch 'zerodaycode:main' into main
TheRustifyer Apr 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion zork++/src/lib/config_file/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use serde::*;
///
/// assert_eq!(config.output_dir, Some("out"));
/// ```
#[derive(Deserialize, Debug, PartialEq)]
#[derive(Deserialize, Debug, PartialEq, Clone)]
#[serde(deny_unknown_fields)]
pub struct BuildAttribute<'a> {
#[serde(borrow)]
Expand Down
2 changes: 1 addition & 1 deletion zork++/src/lib/config_file/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ use crate::project_model;
///
/// For a test over a real example, please look at the
/// [`zork::config_file::ZorkConfigFile`] doc-test
#[derive(Deserialize, Debug, PartialEq, Default)]
#[derive(Deserialize, Debug, PartialEq, Default, Clone)]
#[serde(deny_unknown_fields)]
pub struct CompilerAttribute<'a> {
pub cpp_compiler: CppCompiler,
Expand Down
6 changes: 5 additions & 1 deletion zork++/src/lib/config_file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ pub mod executable;
pub mod modules;
pub mod project;
pub mod tests;
pub mod workspace;

use std::fmt::Debug;

use serde::Deserialize;
use crate::config_file::workspace::WorkspaceAttribute;

use self::{
build::BuildAttribute, compiler::CompilerAttribute, executable::ExecutableAttribute,
Expand Down Expand Up @@ -42,8 +44,10 @@ use self::{
/// The [`ZorkConfigFile`] is the type that holds
/// the whole hierarchy of Zork++ config file attributes
/// and properties
#[derive(Deserialize, Debug, Default)]
#[derive(Deserialize, Debug, Default, Clone)]
pub struct ZorkConfigFile<'a> {
#[serde(borrow)]
pub workspace: Option<WorkspaceAttribute<'a>>,
#[serde(borrow)]
pub project: ProjectAttribute<'a>,
#[serde(borrow)]
Expand Down
8 changes: 4 additions & 4 deletions zork++/src/lib/config_file/modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ use serde::Deserialize;
/// assert_eq!(&gcc_sys_headers[3], &"type_traits");
/// assert_eq!(&gcc_sys_headers[4], &"functional");
/// ```
#[derive(Deserialize, Debug, PartialEq)]
#[derive(Deserialize, Debug, PartialEq, Clone)]
pub struct ModulesAttribute<'a> {
#[serde(borrow)]
pub base_ifcs_dir: Option<&'a str>,
Expand Down Expand Up @@ -132,7 +132,7 @@ pub struct ModulesAttribute<'a> {
/// assert_eq!(ifc_3.file, "some_module_part.cppm");
/// assert_eq!(ifc_3.module_name, Some("math_part"));
/// ```
#[derive(Deserialize, Debug, PartialEq)]
#[derive(Deserialize, Debug, PartialEq, Clone)]
#[serde(deny_unknown_fields)]
pub struct ModuleInterface<'a> {
#[serde(borrow)]
Expand All @@ -158,7 +158,7 @@ pub struct ModuleInterface<'a> {
/// * `is_internal_partition` - Optional field for declare that the module is actually
/// a module for hold implementation details, known as module implementation partitions.
/// This option only takes effect with MSVC
#[derive(Deserialize, Debug, PartialEq)]
#[derive(Deserialize, Debug, PartialEq, Clone)]
pub struct ModulePartition<'a> {
#[serde(borrow)]
pub module: &'a str,
Expand Down Expand Up @@ -200,7 +200,7 @@ pub struct ModulePartition<'a> {
/// assert_eq!(deps[1], "type_traits");
/// assert_eq!(deps[2], "iostream");
/// ```
#[derive(Deserialize, Debug, PartialEq)]
#[derive(Deserialize, Debug, PartialEq, Clone)]
pub struct ModuleImplementation<'a> {
#[serde(borrow)]
pub file: &'a str,
Expand Down
2 changes: 1 addition & 1 deletion zork++/src/lib/config_file/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use serde::*;
///
/// For a test over a real example, please look at the
/// [`zork::config_file::ZorkConfigFile`] doc-test
#[derive(Deserialize, Debug, PartialEq, Default)]
#[derive(Deserialize, Debug, PartialEq, Default, Clone)]
#[serde(deny_unknown_fields)]
pub struct ProjectAttribute<'a> {
pub name: &'a str,
Expand Down
2 changes: 1 addition & 1 deletion zork++/src/lib/config_file/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use serde::*;
///
/// For a test over a real example, please look at the
/// [`zork::config_file::ZorkConfigFile`] doc-test
#[derive(Deserialize, Debug, PartialEq)]
#[derive(Deserialize, Debug, PartialEq, Clone)]
pub struct TestsAttribute<'a> {
#[serde(borrow)]
pub test_executable_name: Option<&'a str>,
Expand Down
39 changes: 39 additions & 0 deletions zork++/src/lib/config_file/workspace.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
use serde::Deserialize;

/// [`WorkspaceAttribute`] - Defines the characteristics of a `Zork++` workspace.
///
/// A `Zork++` workspace is a similar concept to Cargo workspaces, where the managed by
/// the workspace collection of projects shares dependencies, a common output directory,
/// metadata attributes... Commands applied to a workspace are propagated down to the
/// workspace members.
///
/// This allows the user to divide a project into smaller pieces, or create new organization
/// structures for more complex configurations.
///
/// * `members` - A collection of the names by which the dependent projects (every member of the ws)
/// has been defined in their own `zork**.toml` config file in the **project_name** key
///
/// ### Tests
///
/// ```rust
/// use zork::config_file::workspace::{
/// WorkspaceAttribute
/// };
///

/// ```
///
/// > Note: TOML table are toml commented (#) to allow us to parse
/// the inner attributes as the direct type that they belongs to.
/// That commented tables aren't the real TOML, they are just there
/// for testing and exemplification purposes of the inner attributes
/// of the configuration file.
///
/// For a test over a real example, please look at the
/// [`zork::config_file::ZorkConfigFile`] doc-test
#[derive(Deserialize, Debug, PartialEq, Default, Clone)]
#[serde(deny_unknown_fields)]
pub struct WorkspaceAttribute<'a> {
#[serde(borrow)]
pub members: Vec<&'a str>
}
56 changes: 34 additions & 22 deletions zork++/src/lib/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub mod worker {
project_model::{compiler::CppCompiler, ZorkModel},
utils::{
self,
reader::{build_model, find_config_files, ConfigFile},
reader::{build_model, find_config_files},
template::create_templated_project,
},
};
Expand All @@ -49,36 +49,48 @@ pub mod worker {
return create_templated_project(path, name, git, compiler.into(), template);
};

let config_files: Vec<ConfigFile> = find_config_files(path, &cli_args.match_files)
.with_context(|| "We didn't found a valid Zork++ configuration file")?;
log::trace!("Config files found: {config_files:?}");
// Find and store the config file paths directly.
let config_files_raw = find_config_files(path, &cli_args.match_files)
.with_context(|| "We didn't found a valid Zork++ configuration file")
.unwrap();
let config_file_paths: Vec<_> = config_files_raw.iter().map(|cfg| cfg.path.clone()).collect();
log::trace!("Config files found: {config_file_paths:?}");

// Read the file contents and store them in a Vec of strings.
let mut config_file_contents: Vec<String> = Vec::new();
for config_file_path in &config_file_paths {
let contents = fs::read_to_string(config_file_path)
.with_context(|| {
format!(
"An error happened parsing the configuration file: {:?}",
config_file_path.file_name()
)
})
.expect("UPS");
config_file_contents.push(contents);
}

for config_file in config_files {
log::debug!(
"Launching a Zork++ work event for the configuration file: {:?}, located at: {:?}\n",
config_file.dir_entry.file_name(),
config_file.path
// Deserialize the config files one by one, passing references to the strings in the Vec.
let mut zork_config_files = vec![];
for config_file_content in &config_file_contents {
zork_config_files.push(
toml::from_str::<ZorkConfigFile>(config_file_content)
.with_context(|| "Could not parse configuration file")
.expect("UPS 2")
);
let raw_file = fs::read_to_string(config_file.path).with_context(|| {
format!(
"An error happened parsing the configuration file: {:?}",
config_file.dir_entry.file_name()
)
})?;
// TODO from here, we should check if there's workspaces, and adapt the processing
// workflow from here
}

let config: ZorkConfigFile = toml::from_str(raw_file.as_str())
.with_context(|| "Could not parse configuration file")?;
let program_data = build_model(&config, cli_args)?;
for zork_config_file in zork_config_files {
let program_data = build_model(&zork_config_file, cli_args)?;
create_output_directory(&program_data)?;

let cache = cache::load(&program_data, cli_args)
.with_context(|| "Unable to load the Zork++ cache")?;

do_main_work_based_on_cli_input(cli_args, &program_data, cache).with_context(|| {
format!(
"Failed to build the project for the config file: {:?}",
config_file.dir_entry.file_name()
)
format!("Failed to build the project: {:?}", zork_config_file.project.name)
})?;
}

Expand Down
3 changes: 3 additions & 0 deletions zork++/src/lib/project_model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ pub mod modules;
pub mod project;
pub mod sourceset;
pub mod tests;
pub mod workspace;

use std::fmt::Debug;
use crate::project_model::workspace::WorkspaceModel;

use self::{
build::BuildModel, compiler::CompilerModel, executable::ExecutableModel, modules::ModulesModel,
Expand All @@ -15,6 +17,7 @@ use self::{

#[derive(Debug, PartialEq, Eq)]
pub struct ZorkModel<'a> {
pub workspace: WorkspaceModel<'a>,
pub project: ProjectModel<'a>,
pub compiler: CompilerModel<'a>,
pub build: BuildModel,
Expand Down
4 changes: 4 additions & 0 deletions zork++/src/lib/project_model/workspace.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#[derive(Debug, PartialEq, Eq)]
pub struct WorkspaceModel<'a> {
pub members: Vec<&'a str>
}
35 changes: 35 additions & 0 deletions zork++/src/lib/utils/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ use crate::{
use color_eyre::{eyre::eyre, Result};
use std::path::{Path, PathBuf};
use walkdir::{DirEntry, WalkDir};
use crate::config_file::workspace::WorkspaceAttribute;
use crate::project_model::workspace::WorkspaceModel;

use super::constants::DEFAULT_OUTPUT_DIR;

Expand Down Expand Up @@ -59,6 +61,21 @@ pub fn find_config_files(
log::debug!("Searching for Zork++ configuration files...");
let mut files = vec![];

/*
Opción A: Matcheamos con depth = 1, con lo cual solo puedes correr zork++ desde mínimo, dentro
de la raíz del projecto, PEEEERO... habría que buscar de nuevo las config files registradas
en el workspace

Opción B: Cargarlas todas. Parsear fuera del bucle principal. Organizar. En caso de haber
workspace, lógica 1. Else => otra lógica

Opción C: Buscar siempre con depth = 1. Si cuando salen los resultados, la config file es
un workspace, volver a buscar. Si no, ya estaríamos compilando el crate al que apunta "el tema"

Opción D: Al pasar la flag de workspace, sabemos que es de antemano un workspace. Eso implica menos
lógica de proceso, pero podría haber distintos zork por ahí aunque sea de puto milagro

*/
for e in WalkDir::new(base_path)
.max_depth(2)
.into_iter()
Expand Down Expand Up @@ -89,6 +106,11 @@ pub fn find_config_files(
}

pub fn build_model<'a>(config: &'a ZorkConfigFile, cli_args: &'a CliArgs) -> Result<ZorkModel<'a>> {
pub fn build_model<'a>(
config: &'a ZorkConfigFile,
project_root_from_cli: &Path,
) -> Result<ZorkModel<'a>> {
let workspace = assemble_workspace_model(&config.workspace);
let project = assemble_project_model(&config.project);

let absolute_project_root = if cli_args.root.is_none() {
Expand All @@ -110,6 +132,7 @@ pub fn build_model<'a>(config: &'a ZorkConfigFile, cli_args: &'a CliArgs) -> Res
let tests = assemble_tests_model(project.name, &config.tests, &absolute_project_root);

Ok(ZorkModel {
workspace,
project,
compiler,
build,
Expand All @@ -119,6 +142,12 @@ pub fn build_model<'a>(config: &'a ZorkConfigFile, cli_args: &'a CliArgs) -> Res
})
}

fn assemble_workspace_model<'a>(config: &'a Option<WorkspaceAttribute>) -> WorkspaceModel<'a> {
WorkspaceModel {
members: config.as_ref().unwrap_or(&WorkspaceAttribute::default()).members.clone()
}
}

fn assemble_project_model<'a>(config: &'a ProjectAttribute) -> ProjectModel<'a> {
ProjectModel {
name: config.name,
Expand Down Expand Up @@ -407,6 +436,9 @@ mod test {
let abs_path_for_mock = fs::get_project_root_absolute_path(Path::new("."))?;

let expected = ZorkModel {
workspace: WorkspaceModel {
members: vec![],
},
project: ProjectModel {
name: "Zork++",
authors: &["zerodaycode.gz@gmail.com"],
Expand Down Expand Up @@ -457,6 +489,9 @@ mod test {
let abs_path_for_mock = fs::get_project_root_absolute_path(Path::new("."))?;

let expected = ZorkModel {
workspace: WorkspaceModel {
members: vec![],
},
project: ProjectModel {
name: "Zork++",
authors: &["zerodaycode.gz@gmail.com"],
Expand Down