fn main() {
    // save the file to output directory
    let out_dir = env::var("OUT_DIR").unwrap();
    let swizzle_file_path = Path::new(&out_dir).join("swizzle_operator_macro.rs");

    // This is the string representing the generated macro
    let data = format!(
"/// Generate glm/glsl style swizzle operators
macro_rules! impl_swizzle_functions {{
    ($vector_type1:ident, $vector_type2:ident, $vector_type3:ident, $S:ident, x) => {{
{x3}
    }};
    ($vector_type1:ident, $vector_type2:ident, $vector_type3:ident, $S:ident, xy) => {{
{xy3}
    }};
    ($vector_type1:ident, $vector_type2:ident, $vector_type3:ident, $S:ident, xyz) => {{
{xyz3}
    }};
    ($vector_type1:ident, $vector_type2:ident, $vector_type3:ident, $vector_type4:ident, $S:ident, x) => {{
{x4}
    }};
    ($vector_type1:ident, $vector_type2:ident, $vector_type3:ident, $vector_type4:ident, $S:ident, xy) => {{
{xy4}
    }};
    ($vector_type1:ident, $vector_type2:ident, $vector_type3:ident, $vector_type4:ident, $S:ident, xyz) => {{
{xyz4}
    }};
    ($vector_type1:ident, $vector_type2:ident, $vector_type3:ident, $vector_type4:ident, $S:ident, xyzw) => {{
{xyzw4}
    }};
}}", x3 = gen_swizzle_functions("x", 3),
     xy3 = gen_swizzle_functions("xy", 3),
     xyz3 = gen_swizzle_functions("xyz", 3),
     x4 = gen_swizzle_functions("x", 4),
     xy4 = gen_swizzle_functions("xy", 4),
     xyz4 = gen_swizzle_functions("xyz", 4),
     xyzw4 = gen_swizzle_functions("xyzw", 4));
    let mut f = File::create(swizzle_file_path)
        .expect("Unable to create file that defines the swizzle operator macro.");
    f.write_all(data.as_bytes())
        .expect("Unable to write swizzle operator macro.");
}
This script generates the macro for building swizzle operators for multidimensional
vectors and points. This macro is included in macros.rs
build.rs