From 394b710cb04e8ebea26406f74d1ce59f5bb7714c Mon Sep 17 00:00:00 2001 From: Esmaeill Date: Thu, 9 Dec 2021 15:15:42 +0330 Subject: [PATCH] add cmake --- CMakeLists.txt | 7 +++ README.md | 14 +++++ Makefile => example/Makefile | 37 +++++------- {doc => example/doc}/home.html | 0 {doc => example/doc}/htmixer.png | Bin {var => example/var}/home.txt | 0 htmixer.c | 95 ++++++++++++++++++------------- 7 files changed, 90 insertions(+), 63 deletions(-) create mode 100644 CMakeLists.txt rename Makefile => example/Makefile (60%) rename {doc => example/doc}/home.html (100%) rename {doc => example/doc}/htmixer.png (100%) rename {var => example/var}/home.txt (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..39407c0 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.6) + +project(htmixer) + +add_executable(${PROJECT_NAME} htmixer.c) + +install(TARGETS htmixer DESTINATION bin) diff --git a/README.md b/README.md index dd83ada..ddb8a2f 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,17 @@ HTMixer is a Static HTML page generator. this tool can combine different pages a [Read More](https://liyanboy74.github.io/htmixer/) +## Compile & Install +``` +mkdir build +cd build +cmake -G "Unix Makefiles" .. +make +sudo make install +``` + +## Example Generate +``` +cd ../example +make +``` \ No newline at end of file diff --git a/Makefile b/example/Makefile similarity index 60% rename from Makefile rename to example/Makefile index e1287eb..9a3b93e 100644 --- a/Makefile +++ b/example/Makefile @@ -1,30 +1,12 @@ # Makefile Template for HTMixer # by liyanboy74 -# Generate Dir -generate-dir = gh-pages - -default : compile - -# Compice C prog using GCC -compile : - rm -rf build - mkdir build - gcc htmixer.c -o ./build/htmixer - -# Remove Compiled app and Generated files -clean : - rm -rf $(generate-dir) - rm -rf build - -# Deploy on Github Pages, branch [gh-pages] -# more on : https://pypi.org/project/ghp-import/ -# Add CNAME by '-c SITENAME' command -deploy: - ghp-import -p $(generate-dir) +htmixer = "../build/htmixer" +generate-dir = gh-pages +default : generate ##################################### GENARATE ######################################## -# Use 'build/htmixer' for mix 'Doc' and 'Var' files. +# Use 'htmixer' for mix 'Doc' and 'Var' files. # for Example: htmixer OUTPUT_FILR -d DOC1 DOC2 -v VAR1 VAR2 VAR3 # The Var replace by same name in Doc file @@ -37,6 +19,15 @@ generate : cp -r ./doc/htmixer.png ./$(generate-dir)/htmixer.png # Run Mixer - ./build/htmixer ./$(generate-dir)/index.html -d ./doc/home.html -v ./var/home.txt + $(htmixer) ./$(generate-dir)/index.html -d ./doc/home.html -v ./var/home.txt + + +##################################### DEPLOY ########################################## +# Deploy on Github Pages, branch [gh-pages] +# more on : https://pypi.org/project/ghp-import/ +# Add CNAME by '-c SITENAME' command +deploy: + ghp-import -p $(generate-dir) +####################################################################################### diff --git a/doc/home.html b/example/doc/home.html similarity index 100% rename from doc/home.html rename to example/doc/home.html diff --git a/doc/htmixer.png b/example/doc/htmixer.png similarity index 100% rename from doc/htmixer.png rename to example/doc/htmixer.png diff --git a/var/home.txt b/example/var/home.txt similarity index 100% rename from var/home.txt rename to example/var/home.txt diff --git a/htmixer.c b/htmixer.c index 6a8071b..f39ea38 100644 --- a/htmixer.c +++ b/htmixer.c @@ -103,7 +103,7 @@ void catch_var_list(char * fileName) fclose(fp); } -void replace_var_list(char * inputFileName,char* outputFileName) +void replace_var_list(char * FileName) { FILE *fp,*fpt; size_t s,i,k; @@ -111,8 +111,10 @@ void replace_var_list(char * inputFileName,char* outputFileName) char var_name[SIZE_OF_NAME]; int ss=-1; - fp=fopen(inputFileName,"r"); - fpt=fopen(outputFileName,"w"); + char Tempfile[]="rvl.tmp"; + + fp=fopen(FileName,"r"); + fpt=fopen(Tempfile,"w"); s=fread(buff,1,SIZE_OF_BUFFER,fp); for(i=0;i0) + { + fwrite(buff,1,s,fpt); + } + fclose(fp); } - fclose(fp); } int main(int argc,char* argv[]) @@ -322,10 +335,7 @@ int main(int argc,char* argv[]) char var[MAX_INPUT_FILE][SIZE_OF_NAME]; char doc[MAX_INPUT_FILE][SIZE_OF_NAME]; - char genFileName[SIZE_OF_NAME]; - - char tmp1[]="htmixer-tmp1.tmp"; - char tmp2[]="htmixer-tmp2.tmp"; + char genFileName[SIZE_OF_NAME]="\0"; for(j=1;argc>j;j++) { @@ -356,31 +366,36 @@ int main(int argc,char* argv[]) } } - for(j=0;j