Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
create-prog-app
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iliya.saroukha
create-prog-app
Commits
74e80ad6
Commit
74e80ad6
authored
2 years ago
by
iliya.saroukha
Browse files
Options
Downloads
Patches
Plain Diff
created new template for algo Makefile
parent
0755efc5
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/code_templates/mod.rs
+67
-27
67 additions, 27 deletions
src/code_templates/mod.rs
src/main.rs
+5
-1
5 additions, 1 deletion
src/main.rs
with
72 additions
and
28 deletions
src/code_templates/mod.rs
+
67
−
27
View file @
74e80ad6
...
@@ -66,46 +66,86 @@ pub fn template_for_examfile() -> CodeBuffer {
...
@@ -66,46 +66,86 @@ pub fn template_for_examfile() -> CodeBuffer {
return
buffer
;
return
buffer
;
}
}
pub
fn
template_for_makefile_algo
(
mut
hfile_name
:
String
,
mut
main_name
:
String
)
->
CodeBuffer
{
//
pub fn template_for_makefile_algo(mut hfile_name: String, mut main_name: String) -> CodeBuffer {
let
mut
buffer
=
CodeBuffer
::
new
(
4
);
//
let mut buffer = CodeBuffer::new(4);
// Removing extensions
// // Removing extensions
for
_
in
0
..
2
{
// for _ in 0..2 {
hfile_name
.pop
();
// hfile_name.pop();
main_name
.pop
();
// main_name.pop();
}
// }
// buffer.println("# This file was automatically generated by `create-prog-app`");
// buffer.println("CC:=gcc");
// buffer.println("CFLAGS:=-Wall -Wextra -g -pedantic -fsanitize=address -fsanitize=leak");
// buffer.println("LIBS:=-lm");
// buffer.println("VPATH:=struct");
// buffer.println("# Due to the oddity of MAKE and the fact you cannot generate \"true\" tabs,");
// buffer.println("# the \"tab\" character is replaced by spaces.");
// buffer.println("# `create-prog-app` STRONGLY advises you not to change/modify the line below");
// buffer.println(".RECIPEPREFIX:=$(.RECIPEPREFIX) ");
// buffer.println("");
// buffer.println(
// format!(
// "{}: {}.o {}.o",
// main_name.to_lowercase(),
// main_name.to_lowercase(),
// hfile_name.to_lowercase()
// )
// .as_str(),
// );
// buffer.println_right("$(CC) $(CFLAGS) $(LIBS) $^ -o $@");
// buffer.println_left("");
// buffer.println(format!("{0}.o: {0}.c", main_name.to_lowercase()).as_str());
// buffer.println_right("$(CC) $(CFLAGS) $(LIBS) -c $<");
// buffer.println_left("");
// buffer.println(format!("{0}.o: {0}.c {0}.h", hfile_name.to_lowercase()).as_str());
// buffer.println_right("$(CC) $(CFLAGS) $(LIBS) -c $<");
// buffer.println_left("");
// buffer.println("clean:");
// buffer.println_right(format!("rm -f *.o {}", main_name.to_lowercase()).as_str());
// buffer.println_left("");
// buffer.println(format!("rebuild: clean {}", main_name.to_lowercase()).as_str());
// return buffer;
// }
pub
fn
template_for_makefile_algo_v2
(
impl_name
:
String
,
mut
main_name
:
String
)
->
CodeBuffer
{
let
mut
buffer
=
CodeBuffer
::
new
(
4
);
buffer
.println
(
"# This file was automatically generated by `create-prog-app`"
);
buffer
.println
(
"# This file was automatically generated by `create-prog-app`"
);
buffer
.println
(
"CC := gcc"
);
buffer
.println
(
"CC := gcc"
);
buffer
.println
(
"CFLAGS := -Wall -Wextra -g -pedantic -fsanitize=address -fsanitize=leak"
);
buffer
.println
(
"CFLAGS := -Wall -Wextra -g -pedantic -fsanitize=address -fsanitize=leak"
);
buffer
.println
(
"L
IBS
:=-lm"
);
buffer
.println
(
"L
DFLAGS
:=
-lm"
);
buffer
.println
(
"VPATH := struct"
);
buffer
.println
(
"VPATH := struct"
);
buffer
.println
(
"# Due to the oddity of MAKE and the fact you cannot generate
\"
true
\"
tabs,"
);
buffer
.println
(
"# the
\"
tab
\"
character is replaced by spaces."
);
buffer
.println
(
"# `create-prog-app` STRONGLY advises you not to change/modify the line below"
);
buffer
.println
(
".RECIPEPREFIX:=$(.RECIPEPREFIX) "
);
buffer
.println
(
""
);
buffer
.println
(
""
);
buffer
.println
(
buffer
.println
(
format!
(
format!
(
"{}: {}.o {}.o"
,
"SOURCES := {} {}"
,
main_name
.to_lowercase
(),
main_name
.to_lowercase
(),
main_name
.to_lowercase
(),
hfile
_name
.to_lowercase
()
impl
_name
.to_lowercase
()
)
)
.as_str
(),
.as_str
(),
);
);
buffer
.println_right
(
"$(CC) $(CFLAGS) $(LIBS) $^ -o $@"
);
buffer
.println_left
(
""
);
for
_
in
0
..
2
{
buffer
.println
(
format!
(
"{0}.o: {0}.c"
,
main_name
.to_lowercase
())
.as_str
());
main_name
.pop
();
buffer
.println_right
(
"$(CC) $(CFLAGS) $(LIBS) -c $<"
);
}
buffer
.println_left
(
""
);
buffer
.println
(
format!
(
"{0}.o: {0}.c {0}.h"
,
hfile_name
.to_lowercase
())
.as_str
());
buffer
.println
(
"OBJECTS := $(patsubst %.c, %.o, $(SOURCES))"
);
buffer
.println_right
(
"$(CC) $(CFLAGS) $(LIBS) -c $<"
);
buffer
.println
(
format!
(
"TARGET := {}"
,
main_name
)
.as_str
());
buffer
.println
(
"# Due to the oddity of MAKE and the fact you cannot generate
\"
true
\"
tabs,"
);
buffer
.println
(
"# the
\"
tab
\"
character is replaced by spaces."
);
buffer
.println
(
"# `create-prog-app` STRONGLY advises you not to change/modify the line below"
);
buffer
.println
(
".RECIPEPREFIX:=$(.RECIPEPREFIX) "
);
buffer
.println
(
""
);
buffer
.println
(
"$(TARGET): $(OBJECTS)"
);
buffer
.println_right
(
"$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)"
);
buffer
.println_left
(
""
);
buffer
.println_left
(
""
);
buffer
.println
(
".PHONY: clean"
);
buffer
.println
(
""
);
buffer
.println
(
"clean:"
);
buffer
.println
(
"clean:"
);
buffer
.println_right
(
format!
(
"rm -f *.o {}"
,
main_name
.to_lowercase
())
.as_str
());
buffer
.println_right
(
"rm -f $(OBJECTS) $(TARGET)"
);
buffer
.println_left
(
""
);
buffer
.println
(
format!
(
"rebuild: clean {}"
,
main_name
.to_lowercase
())
.as_str
());
return
buffer
;
return
buffer
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/main.rs
+
5
−
1
View file @
74e80ad6
...
@@ -49,8 +49,12 @@ fn algo_template() {
...
@@ -49,8 +49,12 @@ fn algo_template() {
File
::
create
(
&
(
root
.to_owned
()
.into_os_string
()
.into_string
()
.unwrap
()
+
"Makefile"
))
File
::
create
(
&
(
root
.to_owned
()
.into_os_string
()
.into_string
()
.unwrap
()
+
"Makefile"
))
.expect
(
"Cannot create Makefile!"
);
.expect
(
"Cannot create Makefile!"
);
// let makefile_template =
// code_templates::template_for_makefile_algo(header_filename.clone(), main_filename.clone())
// .to_string();
let
makefile_template
=
let
makefile_template
=
code_templates
::
template_for_makefile_algo
(
header
_filename
.clone
(),
main_filename
.clone
())
code_templates
::
template_for_makefile_algo
_v2
(
impl
_filename
.clone
(),
main_filename
.clone
())
.to_string
();
.to_string
();
makefile
makefile
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment