From d497587bcf40d10f2d82befe80fd833e8b5570c0 Mon Sep 17 00:00:00 2001 From: anhe-odoo Date: Mon, 7 Feb 2022 11:52:39 +0100 Subject: [PATCH] [MAKE] Update of CMake structure + Add of Menu Option --- 0~MENU__.cbs | 391 -------------------------------------------- CMakeLists.txt | 26 ++- _WAITKEY.cbs | 2 - error_codes.def | 62 ------- macroDef.mac | 119 -------------- srcs/0~MENU__.cbs | 2 +- srcs/CMakeLists.txt | 12 ++ 7 files changed, 35 insertions(+), 579 deletions(-) delete mode 100644 0~MENU__.cbs delete mode 100644 _WAITKEY.cbs delete mode 100644 error_codes.def delete mode 100644 macroDef.mac create mode 100644 srcs/CMakeLists.txt diff --git a/0~MENU__.cbs b/0~MENU__.cbs deleted file mode 100644 index 51dc36e..0000000 --- a/0~MENU__.cbs +++ /dev/null @@ -1,391 +0,0 @@ -#define PERIODIC 0 -#define CONSTANT 1 -#define CONVERT 0 -#define CHEMISTRY 0 -#define CIRCUIT 0 - -#include "error_codes.def" - -Local i,g -AxesOff -GridOff -LabelOff -ViewWindow 1,127,0,1,63,0 -Lbl 1 -Cls -PlotOn 1,64: -F-Line 1,61,3,63: -For 1→i To 28 Step 3 - F-Line i,58,5+i,63: - F-Line i+94,58,99+i,63: -Next -F-Line 31,58,34,61: -PlotOn 34,58: -F-Line 95,61,97,63: -F-Line 122,58,127,63: -F-Line 125,58,127,60: -For 2→i To 92 Step 30 - F-Line i,39,i+28,39: - F-Line i+28,40,i+28,56: - If i<3 - Then F-Line i,20,i+28,20: - F-Line i+28,21,i+28,37: - IfEnd -// If i<33 -// Then F-Line i,1,i+28,1: -// F-Line i+28,2,i+28,1'8: -// IfEnd -Next - -#if defined(PERIODIC) && (PERIODIC == 1) - F-Line 2,40,2,49: - F-Line 4,40,4,49: - F-Line 6,40,6,49: - For 8→i To 14 Step 2 - F-Line i,40,i,43: - PlotOn i-1,41: - PlotOn i-1,43: - Next - PlotOn 15,41: - PlotOn 15,43: - F-Line 16,40,16,47: - F-Line 18,40,18,47: - F-Line 20,40,20,49: - F-Line 22,40,22,49: - For 41→i To 49 Step 2 - PlotOn 3,i: - PlotOn 5,i: - PlotOn 21,i: - Next - For 41→i To 47 Step 2 - PlotOn 5,i: - PlotOn 17,i: - PlotOn 19,i: - Next - F-Line 8,49,8,45: - F-Line 11,49,11,45: - F-Line 9,47,10,47: - F-Line 14,49,14,47: - F-Line 4,52,4,55: - F-Line 2,56,6,56: - PlotOn 7,54: - F-Line 9,52,9,56: - F-Line 10,56,11,56: - F-Line 10,54,11,54: - PlotOn 12,55: - F-Line 14,52,14,56: - F-Line 15,56,16,56: - F-Line 15,54,16,54: - F-Line 17,52,17,53: - PlotOn 17,55: - F-Line 19,52,19,56: - F-Line 20,52,21,52: - F-Line 20,56,21,56: - F-Line 22,53,22,55: - F-Line 24,53,24,55: - F-Line 25,56,26,56: - F-Line 25,52,27,54: - PlotOn 27,55: - PlotOn 27,52: - F-Line 24,40,24,45: - F-Line 25,40,25,45: - F-Line 26,40,26,45: - PlotOff 26,43: - PlotOn 27,45: - F-Line 28,40,28,45: - F-Line 29,40,29,45: -#else - FillRect 2,8,30,25 -#endif - -#if defined(CONSTANT) && (CONSTANT == 1) - F-Line 33,50,35,50: - F-Line 36,49,38,49: - F-Line 39,48,41,46: - F-Line 43,43,42,45: - F-Line 32,45,32,48: - F-Line 33,46,33,47: - F-Line 35,46,36,46: - F-Line 37,45,38,43: - F-Line 39,41,39,40: - F-Line 42,41,43,41: - F-Line 41,40,44,40: - F-Line 32,40,32,43: - F-Line 33,40,33,43: - F-Line 34,40,34,42: - F-Line 35,40,35,41: - F-Line 44,46,46,46: - F-Line 44,48,45,48: - F-Line 44,50,46,50: - PlotOn 43,49: - PlotOn 43,47: - PlotOn 47,47: - PlotOn 48,48: - PlotOn 49,47: - PlotOn 48,46: - F-Line 48,44,49,44: - F-Line 47,41,47,43: - F-Line 50,43,48,42: - F-Line 48,40,49,40: - F-Line 51,45,52,45: - F-Line 54,47,54,49: - F-Line 56,47,56,49: - F-Line 53,50,57,50: - F-Line 32,53,32,55: - F-Line 33,52,35,52: - F-Line 33,56,35,56: - F-Line 37,53,37,55: - F-Line 38,52,39,52: - F-Line 38,56,39,56: - F-Line 40,53,40,55: - F-Line 42,52,42,56: - PlotOn 43,55: - PlotOn 44,54: - F-Line 45,52,45,56: - F-Line 47,52,49,52: - F-Line 48,54,49,54: - F-Line 48,56,50,56: - PlotOn 50,53: - PlotOn 47,55: - F-Line 52,56,56,56: - F-Line 54,52,54,55: - F-Line 54,39,54,45: - F-Line 55,45,59,45: - F-Line 55,43,58,43: - F-Line 56,41,59,41: - PlotOn 55,42: - PlotOn 59,44: -#else - FillRect 32,8,60,25 -#endif - -#if defined(CONVERT) && (CONVERT == 1) - F-Line 62,53,62,55: - F-Line 63,52,64,52: - F-Line 63,56,64,56: - F-Line 67,52,68,52: - F-Line 66,53,66,55: - F-Line 67,56,68,56: - F-Line 69,53,69,55: - F-Line 71,52,71,56: - F-Line 72,55,73,54: - F-Line 74,52,74,56: - F-Line 76,53,76,56: - PlotOn 77,52: - F-Line 78,53,78,56: - F-Line 80,52,80,56: - F-Line 81,52,82,52: - F-Line 81,56,82,56: - PlotOn 81,54: - F-Line 84,52,84,56: - F-Line 87,55,85,56: - F-Line 85,54,86,54: - F-Line 87,52,87,53: - F-Line 84,40,84,45: - F-Line 85,45,89,45: - F-Line 85,43,88,43: - F-Line 85,41,88,41: - PlotOn 85,42: - PlotOn 89,40: - PlotOn 89,42: - PlotOn 89,44: - F-Line 62,47,62,48: - F-Line 64,47,64,48: - F-Line 66,47,66,48: - PlotOn 63,49: - PlotOn 65,49: - F-Line 68,48,69,48: - PlotOn 70,47: - PlotOn 70,49: - PlotOn 71,48: - F-Line 73,47,73,48: - PlotOn 73,50: - F-Line 75,47,75,49: - F-Line 76,49,77,47: - F-Line 79,42,79,48: - PlotOn 80,48: - PlotOn 81,47: - PlotOn 81,49: - PlotOn 82,48: - F-Line 84,47,86,47: - F-Line 84,48,85,49: - F-Line 86,48,86,49: - F-Line 88,47,88,50: - PlotOn 64,45: - PlotOn 63,44: - PlotOn 65,44: - PlotOn 64,43: - F-Line 64,42,66,42: - F-Line 68,42,68,43: - F-Line 68,40,70,42: - PlotOn 70,43: - F-Line 72,42,73,43: - F-Line 74,41,74,44: - PlotOn 73,41: - PlotOn 76,42: - PlotOn 77,41: - PlotOn 77,43: - PlotOn 78,42: -#else - FillRect 62,8,90,25 -#endif - -#if defined(CHEMISTRY) && (CHEMISTRY == 1) - F-Line 92,52,92,56: - F-Line 93,52,94,52: - F-Line 93,54,94,54: - F-Line 93,56,94,56: - PlotOn 95,53: - PlotOn 95,55: - F-Line 97,52,97,55: - F-Line 98,56,99,56: - F-Line 98,54,99,54: - F-Line 100,52,100,55: - F-Line 102,52,102,56: - F-Line 103,52,104,52: - F-Line 106,52,106,55: - F-Line 107,56,108,56: - F-Line 107,54,108,54: - F-Line 109,52,109,55: - F-Line 111,52,111,56: - F-Line 112,55,113,54: - F-Line 114,52,114,56: - F-Line 116,53,116,55: - F-Line 117,52,118,52: - F-Line 117,56,118,56: - F-Line 92,48,92,49: - F-Line 93,50,94,50: - F-Line 93,47,94,47: - F-Line 95,48,95,49: - F-Line 97,48,97,49: - F-Line 98,47,99,47: - F-Line 98,50,99,50: - F-Line 100,48,100,49: - F-Line 95,45,97,45: - F-Line 94,44,98,44: - F-Line 94,43,98,43: - F-Line 94,42,98,42: - F-Line 95,41,97,41: - F-Line 102,47,106,47: - PlotOn 105,48: - F-Line 102,45,106,45: - PlotOn 103,44: - F-Line 105,41,105,42: - F-Line 106,43,107,43: - F-Line 106,40,107,40: - F-Line 108,41,108,42: - F-Line 109,43,111,43: - F-Line 108,44,112,44: - F-Line 108,45,112,45: - F-Line 108,46,112,46: - F-Line 109,47,111,47: - F-Line 112,48,112,49: - F-Line 113,47,114,47: - F-Line 113,50,114,50: - F-Line 115,48,115,49: - F-Line 114,40,114,45: - F-Line 115,40,117,40: - F-Line 115,41,117,41: - F-Line 115,45,119,45: - F-Line 116,44,117,44: - F-Line 116,43,117,43: - F-Line 119,43,119,44: - F-Line 119,40,119,41: -#else - FillRect 92,8,120,25 -#endif - -#if defined(CIRCUIT) && (CIRCUIT == 1) - Text 27,2,"CIRCUIT": - F-Line 3,30,15,30: - F-Line 15,31,18,31: - F-Line 15,29,18,29: - F-Line 18,30,21,30: - F-Line 21,29,21,28: - F-Line 20,28,20,25: - F-Line 22,28,22,25: - F-Line 21,25,21,23: - F-Line 20,23,9,23: - F-Line 9,24,6,24: - F-Line 9,22,6,22: - F-Line 6,23,3,23: - F-Line 3,24,3,25: - F-Line 2,26,2,27: - F-Line 4,26,4,27: - F-Line 3,28,3,29: - PlotOn 6,29: - PlotOn 7,31: - PlotOn 8,29: - PlotOn 9,31: - PlotOn 10,29: - F-Line 13,29,13,28: - F-Line 12,27,14,27: - F-Line 12,25,14,25: - PlotOn 13,24: - F-Line 24,26,24,21: - F-Line 25,22,28,22: - F-Line 25,26,29,26: - F-Line 26,24,29,24: - PlotOn 29,23: - PlotOn 29,21: -#else - FillRect 2,27,30,44 -#endif - -LocateYX 0,38,"MAIN MENU" - -Lbl 2 -Prog "_WAITKEY"→g -Switch g: -# if defined(PERIODIC) && (PERIODIC == 1) - Case 72: - Try : - Prog "PER~MAIN" - Except _GO_ERROR_: - PopUpWin(11,"ERREUR!","Programme introuvable") - TryEnd - Goto 1 -# endif -# if defined(CONSTANT) && (CONSTANT == 1) - Case 62: - Try : - Prog "CST~MAIN" - Except _GO_ERROR_: - PopUpWin(11,"ERREUR!","Programme introuvable") - TryEnd - Goto 1 -# endif -# if defined(CONVERT) && (CONVERT == 1) - Case 52: - Try : - Prog "CNV~MAIN" - Except _GO_ERROR_: - PopUpWin(11,"ERREUR!","Programme introuvable") - TryEnd - Goto 1 -# endif -# if defined(CHEMISTRY) && (CHEMISTRY == 1) - Case 73: - Try : - Prog "CHM~MAIN" - Except _GO_ERROR_: - PopUpWin(11,"ERREUR!","Programme introuvable") - TryEnd - Goto 1 -# endif -# if defined(CIRCUIT) && (CIRCUIT == 1) - Case 63: - Try : - Prog "ELC~MAIN" - Except _GO_ERROR_: - PopUpWin(11,"ERREUR!","Programme introuvable") - TryEnd - Goto 1 -# endif - Case 48: - Return - Case 47: - ClrText - Stop -SwitchEnd - Goto 2 diff --git a/CMakeLists.txt b/CMakeLists.txt index ff89c78..eacaffe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,8 +2,26 @@ cmake_minimum_required(VERSION 3.5) project(elysius NONE) +option(BUILD_MENU "Add the Main Menu" ON) + +add_subdirectory(srcs) + add_custom_target(menu ALL) -add_custom_command( - TARGET menu - COMMAND ./pithon.sh ./srcs/0~MENU__.cbs - ) \ No newline at end of file +find_program(FOO_EXECUTABLE foo) +function(preprocess_foo out_var) + set(result) + foreach(in_f ${ARGN}) + add_custom_command( + PRE_BUILD + TARGET menu + COMMAND cd ${PROJECT_SOURCE_DIR} && ./pithon.sh srcs/${in_f} + DEPENDS srcs/${in_f} + COMMENT "Creating preprocessed foo file ${in_f}" + VERBATIM + ) + list(APPEND result ${out_f}) + endforeach() + set(${out_var} "${result}" PARENT_SCOPE) +endfunction() + +preprocess_foo(prep_files ${SOURCEFILES}) diff --git a/_WAITKEY.cbs b/_WAITKEY.cbs deleted file mode 100644 index 00c3594..0000000 --- a/_WAITKEY.cbs +++ /dev/null @@ -1,2 +0,0 @@ -Getkey1 -Do:LpWhile Getkey diff --git a/error_codes.def b/error_codes.def deleted file mode 100644 index 7818b48..0000000 --- a/error_codes.def +++ /dev/null @@ -1,62 +0,0 @@ -// DEFINITION OF ERROR CODES AS MACRO -// General Errors ================================================================= -#define _SYNTAX_ERROR_ 1 -#define _MA_ERROR_ 2 -#define _GO_ERROR_ 3 -#define _NESTING_ERROR_ 4 -#define _STACK_ERROR_ 5 -#define _MEMORY_ERROR_ 6 -#define _ARG_ERROR_ 7 -#define _DIM_ERROR_ 8 -#define _RANGE_ERROR_ 9 - -// Miscellaneous Errors =========================================================== -#define _NONREAL_ERROR_ 11 - -// Communication Errors =========================================================== -#define _COM_ERROR_ 20 -#define _TRANSMIST_ERROR_ 21 -#define _RECEIVE_ERROR_ 22 - -// Other Errors ================================================================== -/* -28: Too Much Data - -33: For without Next -34: Next without For -35: While w/o W.End -36: W.End w/o While -37: Do w/o LpWhile -38: LpWhile w/o Do -39: Not Loop ERROR -40: Division By Zero -41: Undefined Label -42: Not enough Memory -43: String Too Long -44: No Matrix array -45: Illegal Ary size -46: No Prog found -47: Too many SubProg -48: If without IfEnd -49: Then without If -50: Case w/o Switch -51: Default w/o Swtch -52: Switch w/o S.End -53: S.End w/o Switch -54: Can't find file -55: Illegal Element -56: Already Opened -57: Com Not Opened -58: Type Mismatched -59: Out of Domain -60: Undefined Var. -61: Undefined Func. -62: Not Supported -63: Exceed Var. limit -64: Duplicated Def. -65: Address Align ERR -66: Not met Accuracy -70: Try w/o Except -71: Except w/o Try -72: TryEnd w/o Try -*/ diff --git a/macroDef.mac b/macroDef.mac deleted file mode 100644 index 916ebd1..0000000 --- a/macroDef.mac +++ /dev/null @@ -1,119 +0,0 @@ -/** \file macroDef.mac - * \brief Implementation des macros utilisees dans les autres fichiers */ - -//#include "numbered.mac" - -// MACRO-DEFINITION PERMETTANT DE CONCATENER DEUX COMMANDES ======================================== -#if !defined( conct ) -# define conct(STR1, STR2) STR1 ## STR2 -#endif - - -// MACRO-DEFINITIONS NECESSAIRES A LA CONVERSION EN BOOLEEN ======================================== -#if !defined( _bool ) -# define _bool(COND) isProbe(_bool ## _ ## COND) -# define _bool_0 a , 0 -# define _bool_ a , 0 -# define isProbe(...) _second(__VA_ARGS__ , 1) -# define _second(a, b, ...) b - -# define _not(a) inline_if(a)( 0 )( 1 ) -# define _and(a,b) inline_if(a)(_bool(b))( 0 ) -# define _or(a,b) inline_if(a)( 1 )(_bool(b)) -# define _xor(a,b) inline_if(a)( _not(b))( b ) -#endif - - -// MACRO-DEFINITIONS PERMETTANT LA DEFINITION DU IF-ELSE =========================================== -#if !defined( inline_if ) -# define inline_if(...) iif(_bool(__VA_ARGS__)) -# define iif(COND) conct(__iif_, COND) -# define __iif_1(...) __VA_ARGS__ _elif_1 -# define __iif_0(...) _elif_0 -# define _elif_1(...) -# define _elif_0(...) __VA_ARGS__ -#endif - -// MACRO-DEFINITIONS PERMETTANT LE FOREACH ========================================================= -#if !defined( foreach ) -# define foreach(var,list,cond) \ - for var in [var for var in list if cond] -#endif - - - -// MACRO-DEFINITIONS PERMETTANT LA DEFINITION D'UNE BOUCLE FOREACH ================================= -#if !defined(for_each) -# define for_each(...) _getOverride(__VA_ARGS__, _for3, _for2)(__VA_ARGS__) -# define _getOverride(_1, _2, _3, NAME, ...) NAME -# define __for() fora -# define _for2(data, expr) data(expr) -# define _for3(imin, imax, expr) EVAL(fora(imin, sub(imax,imin), expr)) -# define fora(indx, nmbr, expr) /*(*/ \ - expr(indx) \ - inline_if ( nmbr ) ( \ - defer2 (__for) () (inc(indx), dec(nmbr), expr) \ - )() \ - /*)*/ -#endif - - -// MACRO PERMETTANT DE VERIFIER Q'UNE FONCTION A DES ARGUMENTS ===================================== -#if !defined(has_args) -# define has_args(...) _tmp(_first(_eof __VA_ARGS__)(0)) -# define _first(a, ...) a -# define _eof(...) _tmp(_first(__VA_ARGS__)) -# define _tmp(...) _bool(__VA_ARGS__) -#endif - - -// MACRO PERMETTANT D'ALLER CHERCHER UN ELEMENT DANS UNE LISTE ===================================== -#if !defined(get_data) -# define get_data(data, indx) tt(indx, data(lst)) -# define tt(...) EVAL(got(__VA_ARGS__)) -# define lst(a) a, -# define _got() got -# define got(indx, valr, ...) ( \ - inline_if ( indx ) ( \ - defer2 (_got) () (dec(indx), __VA_ARGS__ ) \ - ) /*else*/ ( \ - valr \ - ) \ - ) -#endif - - -// MACRO-DEFINITIONS DE DEREFERENCE ET D'EVALUATION ================================================ -#if !defined(defer) -# define _null() -# define defer(...) __VA_ARGS__ _null() -# define defer2(...) __VA_ARGS__ defer(_null) () -#endif - - -// MACRO-DEFINITIONS PERMETTANT DE CALCULER UNE SOUSTRACTION ======================================= -#if !defined(sub) -# define sub(a, b) EVAL(dif(a, b)) -# define _dif() dif -# define dif(NUM1, NUM2) /*(*/ \ - inline_if ( NUM2 ) ( \ - defer2 (_dif) () (dec(NUM1), dec(NUM2)) \ - ) /*else*/ ( \ - NUM1 \ - ) \ - /*)*/ -#endif - - -// MACRO-DEFINITIONS PERMETTANT DE CALCULER UNE ADDITION =========================================== -#if !defined(add) -# define add(a, b) EVAL(_sum(a, b)) -# define _add() _sum -# define _sum(NUM1, NUM2) /*(*/ \ - inline_if( NUM2 ) ( \ - defer2 (_add) () (inc(NUM1), dec(NUM2)) \ - ) /*else*/ ( \ - NUM1 \ - ) \ - /*)*/ -#endif \ No newline at end of file diff --git a/srcs/0~MENU__.cbs b/srcs/0~MENU__.cbs index 449fabe..acda54c 100644 --- a/srcs/0~MENU__.cbs +++ b/srcs/0~MENU__.cbs @@ -4,7 +4,7 @@ #define CHEMISTRY 0 #define CIRCUIT 0 -#include "error_codes.def" +#include "../preproc/error_codes.def" Local i AxesOff diff --git a/srcs/CMakeLists.txt b/srcs/CMakeLists.txt new file mode 100644 index 0000000..38d0c58 --- /dev/null +++ b/srcs/CMakeLists.txt @@ -0,0 +1,12 @@ +set(source_list + "_WAITKEY.cbs" +) + +if(BUILD_MENU) + set(source_list + ${source_list} + "0~MENU__.cbs" + ) +endif() + +set(SOURCEFILES ${source_list} PARENT_SCOPE)