diff --git a/CMakeLists.txt b/CMakeLists.txt index eacaffe..30250a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,10 +2,35 @@ cmake_minimum_required(VERSION 3.5) project(elysius NONE) -option(BUILD_MENU "Add the Main Menu" ON) +option(BUILD_MENU "Add the Main Menu" ON) +option(BUILD_CSTN "Include constants collection" ON) +option(BUILD_CHIM "Include chemical equations analyser" ON) +option(BUILD_PRDQ "Include periodic elements table" ON) +option(BUILD_CONV "Include units conversion program" ON) +option(BUILD_ELEC "Include electronic circuits solver" ON) add_subdirectory(srcs) +if(BUILD_CSTN) + set(DEFINITION "${DEFINITION} -DCONSTANT") +endif() + +if(BUILD_CHIM) + set(DEFINITION "${DEFINITION} -DCHEMISTRY") +endif() + +if(BUILD_PRDQ) + set(DEFINITION "${DEFINITION} -DPERIODIC") +endif() + +if(BUILD_CONV) + set(DEFINITION "${DEFINITION} -DCONVERT") +endif() + +if(BUILD_ELEC) + set(DEFINITION "${DEFINITION} -DCIRCUIT") +endif() + add_custom_target(menu ALL) find_program(FOO_EXECUTABLE foo) function(preprocess_foo out_var) @@ -14,7 +39,7 @@ function(preprocess_foo out_var) add_custom_command( PRE_BUILD TARGET menu - COMMAND cd ${PROJECT_SOURCE_DIR} && ./pithon.sh srcs/${in_f} + COMMAND cd ${PROJECT_SOURCE_DIR} && ./pithon.sh srcs/${in_f} ${DEFINITION} DEPENDS srcs/${in_f} COMMENT "Creating preprocessed foo file ${in_f}" VERBATIM diff --git a/pithon.sh b/pithon.sh index db6dc7d..a396e77 100755 --- a/pithon.sh +++ b/pithon.sh @@ -11,6 +11,8 @@ out="${1/.cbs/.txt}"; # TODO : +echo $2 + word='a-zA-Z0-9_'; cat "$1" | sed 's/^[ \t]*//;s/[ \t]*$//' > "$out.tmp"; @@ -51,7 +53,7 @@ sed -e 's/\xe2\x88\x9a/sqrt/g' -e 's/\xe2\x88\x87/nabla/g;s/\xe2\x88\x80/for/g' #sed -i -e "s/\[ *\([$word]*\) *; *\([$word]*\) *\]/range(\1,\2+1)/g" "$out"; #sed -i -e "s/\] *\([$word]*\) *; *\([$word]*\) *\]/range(\1+1,\2+1)/g" "$out"; -cpp "$out" > "$out.tmp"; +cpp "$out" $2 > "$out.tmp"; sed '/^#/ d' "$out.tmp" > "$out" && rm "$out.tmp"; sed -i 's/#.*$//;/^$/d' "$out"; @@ -62,4 +64,4 @@ sed -i 's/\xe2\x9f\xa9/]/g;s/\xe2\x9f\xa8/[/g' "$out"; python3 g1mtool.py pack "$out" -rm "$out"; \ No newline at end of file +#rm "$out"; \ No newline at end of file diff --git a/srcs/0~MENU__.cbs b/srcs/0~MENU__.cbs index acda54c..3b3b546 100644 --- a/srcs/0~MENU__.cbs +++ b/srcs/0~MENU__.cbs @@ -1,15 +1,7 @@ -#define PERIODIC 0 -#define CONSTANT 1 -#define CONVERT 0 -#define CHEMISTRY 0 -#define CIRCUIT 0 - #include "../preproc/error_codes.def" Local i -AxesOff -GridOff -LabelOff +AxesOff:GridOff:LabelOff ViewWindow 1,127,0,1,63,0 Lbl 1 Cls @@ -37,7 +29,7 @@ For 2→i To 92 Step 30 // IfEnd Next -#if defined(PERIODIC) && (PERIODIC == 1) +#if defined(PERIODIC) F-Line 2,40,2,49: F-Line 4,40,4,49: F-Line 6,40,6,49: @@ -98,7 +90,7 @@ Next FillRect 2,8,30,25 #endif -#if defined(CONSTANT) && (CONSTANT == 1) +#if defined(CONSTANT) F-Line 33,50,35,50: F-Line 36,49,38,49: F-Line 39,48,41,46: @@ -159,7 +151,7 @@ Next FillRect 32,8,60,25 #endif -#if defined(CONVERT) && (CONVERT == 1) +#if defined(CONVERT) F-Line 62,53,62,55: F-Line 63,52,64,52: F-Line 63,56,64,56: @@ -230,7 +222,7 @@ Next FillRect 62,8,90,25 #endif -#if defined(CHEMISTRY) && (CHEMISTRY == 1) +#if defined(CHEMISTRY) F-Line 92,52,92,56: F-Line 93,52,94,52: F-Line 93,54,94,54: @@ -295,7 +287,7 @@ Next FillRect 92,8,120,25 #endif -#if defined(CIRCUIT) && (CIRCUIT == 1) +#if defined(CIRCUIT) Text 27,2,"CIRCUIT": F-Line 3,30,15,30: F-Line 15,31,18,31: @@ -337,7 +329,7 @@ LocateYX 0,38,"MAIN MENU" Lbl 2 Prog "_WAITKEY"→i Switch i: -# if defined(PERIODIC) && (PERIODIC == 1) +# if defined(PERIODIC) Case 72: Try : Prog "PER~MAIN" @@ -346,7 +338,7 @@ Switch i: TryEnd Goto 1 # endif -# if defined(CONSTANT) && (CONSTANT == 1) +# if defined(CONSTANT) Case 62: Try : Prog "CST~MAIN" @@ -355,7 +347,7 @@ Switch i: TryEnd Goto 1 # endif -# if defined(CONVERT) && (CONVERT == 1) +# if defined(CONVERT) Case 52: Try : Prog "CNV~MAIN" @@ -364,7 +356,7 @@ Switch i: TryEnd Goto 1 # endif -# if defined(CHEMISTRY) && (CHEMISTRY == 1) +# if defined(CHEMISTRY) Case 73: Try : Prog "CHM~MAIN" @@ -373,7 +365,7 @@ Switch i: TryEnd Goto 1 # endif -# if defined(CIRCUIT) && (CIRCUIT == 1) +# if defined(CIRCUIT) Case 63: Try : Prog "ELC~MAIN" @@ -388,4 +380,4 @@ Switch i: ClrText Stop SwitchEnd - Goto 2 +Goto 2