build-windows/generate_code.cmd
author Krista 'DarthMama' Bennett <krista@pep.foundation>
Wed, 27 Jan 2021 17:13:24 +0100
branchmime-integrate
changeset 5281 2eeac2d5d012
parent 5188 47f76f5c2ca3
permissions -rw-r--r--
push before migration
     1 @ECHO OFF
     2 
     3 :: The script is located in ...\pEpForWindowsAdapterSolution\pEpEngine\build-windows\
     4 SET current_directory=%~dp0
     5 
     6 :: Engine directory is ...\pEpForWindowsAdapterSolution\pEpEngine\
     7 SET engine_directory=%current_directory:~0,-14%
     8 
     9 :: YML2 directory is ...\pEpForWindowsAdapterSolution\yml2\
    10 SET yml2_directory=%engine_directory:~0,-11%\yml2
    11 
    12 :: Create the system.db
    13 PUSHD %engine_directory%\db
    14 CALL make_systemdb
    15 IF NOT EXIST "%ProgramData%\pEp" "MKDIR %ProgramData%\pEp"
    16 DEL "%ProgramData%\pEp\system.db"
    17 MOVE system.db "%ProgramData%\pEp\system.db"
    18 
    19 :: Generate code in ...\pEpEngine\sync
    20 CD ..\sync
    21 
    22 :: Make sure YML2 is installed
    23 PY -m pip install wheel
    24 PY -m pip install yml2
    25 
    26 :: Generate the Sync code
    27 IF NOT EXIST generated MKDIR generated
    28 
    29 ECHO PY -m yml2.yml2proc -E utf-8 -y gen_actions.ysl2 sync.fsm
    30 PY -m yml2.yml2proc -E utf-8 -y gen_actions.ysl2 sync.fsm
    31 IF %ERRORLEVEL% NEQ 0 GOTO end
    32 
    33 ECHO PY -m yml2.yml2proc -E utf-8 -y gen_codec.ysl2 distribution.fsm
    34 PY -m yml2.yml2proc -E utf-8 -y gen_codec.ysl2 distribution.fsm
    35 IF %ERRORLEVEL% NEQ 0 GOTO end
    36 
    37 ECHO PY -m yml2.yml2proc -E utf-8 -y gen_codec.ysl2 sync.fsm
    38 PY -m yml2.yml2proc -E utf-8 -y gen_codec.ysl2 sync.fsm
    39 IF %ERRORLEVEL% NEQ 0 GOTO end
    40 
    41 ECHO PY -m yml2.yml2proc -E utf-8 -y gen_messages.ysl2 sync.fsm
    42 PY -m yml2.yml2proc -E utf-8 -y gen_messages.ysl2 sync.fsm
    43 IF %ERRORLEVEL% NEQ 0 GOTO end
    44 
    45 ECHO PY -m yml2.yml2proc -E utf-8 -y gen_messages.ysl2 distribution.fsm
    46 PY -m yml2.yml2proc -E utf-8 -y gen_messages.ysl2 distribution.fsm
    47 IF %ERRORLEVEL% NEQ 0 GOTO end
    48 
    49 ECHO PY -m yml2.yml2proc -E utf-8 -y gen_message_func.ysl2 sync.fsm
    50 PY -m yml2.yml2proc -E utf-8 -y gen_message_func.ysl2 sync.fsm
    51 IF %ERRORLEVEL% NEQ 0 GOTO end
    52 
    53 ECHO PY -m yml2.yml2proc -E utf-8 -y gen_statemachine.ysl2 sync.fsm
    54 PY -m yml2.yml2proc -E utf-8 -y gen_statemachine.ysl2 sync.fsm
    55 IF %ERRORLEVEL% NEQ 0 GOTO end
    56 
    57 XCOPY /y generated\*.asn1 ..\asn.1\
    58 XCOPY /y generated\*.c ..\src\
    59 XCOPY /y generated\*.h ..\src\
    60 
    61 CD %engine_directory%\asn.1
    62 
    63 DEL *.h
    64 DEL *.c
    65 
    66 ..\..\Tools\asn1c\bin\asn1c -S ../../Tools/asn1c/share/asn1c -gen-PER -fincludes-quoted -fcompound-names -pdu=auto pEp.asn1 keysync.asn1 sync.asn1
    67 IF %ERRORLEVEL% NEQ 0 GOTO end
    68 
    69 ..\..\Tools\asn1c\bin\asn1c -S ../../Tools/asn1c/share/asn1c -gen-PER -fincludes-quoted -fcompound-names -pdu=auto pEp.asn1 keyreset.asn1 distribution.asn1
    70 IF %ERRORLEVEL% NEQ 0 GOTO end
    71 
    72 DEL *-sample.c
    73 
    74 CD %engine_directory%\..
    75 RD /S/Q pEp
    76 MKDIR pEp
    77 XCOPY pEpEngine\src\*.h pEp\ /Y/F/I
    78 
    79 
    80 :end
    81 
    82 POPD
    83 EXIT /B %ERRORLEVEL%