Skip to content

Commit a422782

Browse files
committed
updated precompile
1 parent b9bc28a commit a422782

File tree

58 files changed

+1564
-638
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1564
-638
lines changed

.cargo/config.toml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
TEST_MODULE_MACRO_CODEGEN_WORKDIR = "/Users/hayde/IdeaProjects/rust-spring-knockoff/module_macro_codegen/test_work"
33
AUG_FILE = "/Users/hayde/IdeaProjects/rust-spring-knockoff/codegen_resources/knockoff_test_aug.rs"
44
KNOCKOFF_FACTORIES = "/Users/hayde/IdeaProjects/rust-spring-knockoff/codegen_resources/knockoff_factories.toml"
5+
KNOCKOFF_PRECOMPILE = "/Users/hayde/IdeaProjects/rust-spring-knockoff/codegen_resources/knockoff_precompile.toml"
56
TEST_MODULE_MACRO_CODEGEN_KNOCKOFF_FACTORIES = "/Users/hayde/IdeaProjects/rust-spring-knockoff/module_macro_codegen/test_resources/test_knockoff_factories.toml"
67
LOGGING_DIR = "/Users/hayde/IdeaProjects/rust-spring-knockoff/log_out/log.log"
78
KNOCKOFF_LOGGING_TEST_FILE = "/Users/hayde/IdeaProjects/rust-spring-knockoff/log_out/knockoff_logging_test.log"

.idea/workspace.xml

+18-22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+6-2
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,14 @@ members = [
3131
"rust_spring_knockoff",
3232
"string_utils",
3333
"set_enum_fields",
34-
"authentication_codegen"
34+
"authentication_codegen",
35+
"module_precompile_codegen",
36+
"module_precompile"
3537
# "boot_application_builder"
3638
]
3739
exclude = [
3840
"target/knockoff_providers_gen",
39-
"target/knockoff_providers_genone"
41+
"target/knockoff_providers_genone",
42+
"target/knockoff_precompile_gen",
43+
"authentication_gen"
4044
]

authentication_gen/.cargo/config.toml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[env]
2+
KNOCKOFF_FACTORIES = "/Users/hayde/IdeaProjects/rust-spring-knockoff/authentication_gen/codegen_resources/knockoff_factories.toml"
3+
LOGGING_DIR = "/Users/hayde/IdeaProjects/rust-spring-knockoff/log_out/log.log"
4+
KNOCKOFF_LOGGING_TEST_FILE = "/Users/hayde/IdeaProjects/rust-spring-knockoff/log_out/knockoff_logging_test.log"
5+
PROJECT_BASE_DIRECTORY = "/Users/hayde/IdeaProjects/rust-spring-knockoff/authentication_gen"
6+
MODULE_MACRO_REGISTRY_INDEX_URI = "http://localhost:1234/git/index"
7+
KNOCKOFF_DEV = "true"
8+
OUT_CODEGEN_DIR = "/codegen.rs"
9+
[registries]
10+
estuary = { index = "http://localhost:1234/git/index" }

authentication_gen/Cargo.toml

+15-10
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ executors = "0.9.0"
1717
paste = "1.0.12"
1818
rand = "0.8.5"
1919

20-
[build-dependencies.build_lib]
21-
path ="../build_lib"
22-
version = "0.1.5"
23-
registry = "estuary"
2420
[dependencies.module_macro_shared]
2521
path ="../module_macro_shared"
2622
version = "0.1.5"
@@ -50,6 +46,17 @@ path ="../codegen_utils"
5046
version = "0.1.5"
5147
registry = "estuary"
5248

49+
[build-dependencies]
50+
rand = "0.8.5"
51+
syn = {version = "1.0", features = ["full"]}
52+
executors = "0.9.0"
53+
lazy_static = "1.4.0"
54+
paste = "1.0.12"
55+
proc-macro2 = "1.0.51"
56+
[build-dependencies.module_precompile]
57+
path = "../module_precompile"
58+
version = "0.1.5"
59+
registry = "estuary"
5360
[build-dependencies.codegen_utils]
5461
path = "../codegen_utils"
5562
version = "0.1.5"
@@ -78,10 +85,8 @@ registry = "estuary"
7885
path = "../web_framework_shared"
7986
version = "0.1.5"
8087
registry = "estuary"
88+
[build-dependencies.build_lib]
89+
path ="../build_lib"
90+
version = "0.1.5"
91+
registry = "estuary"
8192

82-
[build-dependencies]
83-
rand = "0.8.5"
84-
syn = {version = "1.0", features = ["full"]}
85-
executors = "0.9.0"
86-
lazy_static = "1.4.0"
87-
paste = "1.0.12"

authentication_gen/build.rs

+30-24
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
11
use std::{env, fs};
2-
use std::ffi::{OsStr, OsString};
32
use std::fs::File;
43
use std::io::{Read, Write};
5-
use std::ops::Deref;
64
use std::path::Path;
7-
use std::ptr::write;
8-
use syn::__private::{Span, ToTokens};
9-
use syn::{braced, Fields, Ident, Item, ItemMod, ItemStruct, Token, token, Visibility, VisPublic};
10-
use syn::__private::quote::__private::push_div_eq_spanned;
11-
use syn::parse::{ParseBuffer, ParseStream};
12-
use syn::token::Brace;
13-
use build_lib::replace_modules;
14-
use codegen_utils::env::{get_project_base_build_dir, get_build_project_dir};
15-
use module_macro_codegen::parser::LibParser;
5+
use proc_macro2::TokenStream;
166

177
use knockoff_logging::*;
188

@@ -22,20 +12,36 @@ use std::sync::Mutex;
2212
use codegen_utils::project_directory;
2313
import_logger_root!("build.rs", concat!(project_directory!(), "/log_out/authentication_gen_build.log"));
2414

15+
/// TODO: load the knockoff_factories from here, parse the pre_compiled example.
2516
fn main() {
26-
log_message!("Initializing module macro lib.");
27-
let aug_file = get_aug_file();
28-
if aug_file.is_some() {
29-
LibParser::do_codegen(aug_file.unwrap().as_str(), "codegen.rs");
30-
let mut cargo_change = "cargo:rerun-if-changed=".to_string();
31-
cargo_change += get_project_base_build_dir().as_str();
32-
println!("{}", cargo_change);
17+
info!("Initializing authentication gen build.");
18+
let generated: TokenStream = module_precompile::get_tokens(&"authentication_gen");
19+
let out_file = open_out_file();
20+
if let Some(_) = out_file
21+
.map(|mut out_file| {
22+
out_file.write_all(generated.to_string().as_bytes())
23+
.map_err(|e| {
24+
error!("Error writing authentication gen codegen: {:?}", e);
25+
})
26+
.ok()
27+
})
28+
.map_err(|e| {
29+
if generated.to_string().as_str().len() != 0 {
30+
panic!("Could not create codegen.")
31+
}
32+
Err(e)
33+
})
34+
.ok()
35+
.flatten() {
36+
info!("Wrote codegen for authentication gen.");
37+
} else {
38+
error!("Failed to write codegen with authentication gen.");
3339
}
3440
}
3541

36-
fn get_aug_file() -> Option<String> {
37-
let aug_file = env::var("AUG_FILE").ok()
38-
.or(Some(String::from(get_build_project_dir("codegen_resources/knockoff_test_aug.rs"))))
39-
.unwrap();
40-
Some(aug_file)
41-
}
42+
fn open_out_file() -> Result<File, std::io::Error> {
43+
let out_file = concat!(env!("OUT_DIR"), "/codegen.rs");
44+
let mut out_path = Path::new(out_file);
45+
let mut out_file = File::create(out_path);
46+
out_file
47+
}

0 commit comments

Comments
 (0)