Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/compile-mql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ jobs:
env:
MT4_METALANG_URL: ${{ secrets.MT4_METALANG_URL }}
MT4_METAEDITOR_URL: ${{ secrets.MT4_METAEDITOR_URL }}
AUTH_USERNAME: ${{ secrets.MT4_URL_AUTH_USERNAME }}
AUTH_PASSWORD: ${{ secrets.MT4_URL_AUTH_PASSWORD }}
MT5_METAEDITOR_URL: ${{ secrets.MT5_METAEDITOR_URL }}
AUTH_USERNAME: ${{ secrets.METATRADER_USERNAME }}
AUTH_PASSWORD: ${{ secrets.METATRADER_PASSWORD }}
run: |
echo "Downloading MT4 compiler from https://.../mt4${MT4_METALANG_URL#*/mt4}"
curl -o metalang.exe --digest -u "$AUTH_USERNAME:$AUTH_PASSWORD" "$MT4_METALANG_URL" --silent --fail --show-error --connect-timeout 10 --max-time 60
Expand All @@ -63,13 +64,18 @@ jobs:
curl -o metaeditor.exe --digest -u "$AUTH_USERNAME:$AUTH_PASSWORD" "$MT4_METAEDITOR_URL" --silent --fail --show-error --connect-timeout 10 --max-time 60
echo "MT4_METAEDITOR=$PWD/metaeditor.exe" >> "$GITHUB_ENV"

echo "Downloading MT5 MetaEditor from https://.../mt5${MT5_METAEDITOR_URL#*/mt5}"
curl -o metaeditor64.exe --digest -u "$AUTH_USERNAME:$AUTH_PASSWORD" "$MT5_METAEDITOR_URL" --silent --fail --show-error --connect-timeout 10 --max-time 60
echo "MT5_METAEDITOR=$PWD/metaeditor64.exe" >> "$GITHUB_ENV"

# ------------------------------------------------------------------------------------------------------------------------------------
- name: Compile MQL files
if: env.SKIP_CI != 'true'
run: |
TRACE=1 \
bin/mqlc -v=mql40 /inc:mql40 mql40/experts mql40/experts/tools mql40/indicators mql40/indicators/.attic mql40/scripts mql40/libraries \
-v=mql45 /inc:mql45 mql45/experts mql45/indicators mql45/scripts mql45/libraries \
/inc:mql50 mql50/experts mql50/indicators mql50/scripts mql50/libraries \
--warn2error

# ------------------------------------------------------------------------------------------------------------------------------------
Expand Down
30 changes: 16 additions & 14 deletions bin/mqlc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
#
# Configuration via environment and/or config file.
#
# @see "<repository>/bin/.mqlc.dist" for an example
# - If environment variable DEBUG is set the script displays debug infos and the final command to be executed.
# - If environment variable ORIG is set the script doesn't modify the compiler output.
# - If environment variable TRACE is set the script shows the location of the last error (if any).
#
# @see "/bin/.mqlc.dist" for a configuration example
# @see https://www.metatrader5.com/en/metaeditor/help/beginning/integration_ide#compiler
#
#
Expand Down Expand Up @@ -79,7 +83,7 @@ Configuration:
Unless option --rc/--norc is used, the script will look for a file named ".mqlc" in the source directory and each
parent directory. If no file is found in any of the parent directories, the script will look in the user's home
directory. Only the first file found will be used. Compiler locations can also be specified using environment vars.
See "<repository>/bin/.mqlc" for an example.
See "/bin/.mqlc.dist" for an example.

SYNTAX
}
Expand Down Expand Up @@ -112,7 +116,7 @@ declare originalOutput=0 debug=0 trace=0 test=0
function init() {
((BASH_SUBSHELL)) && fail "${FUNCNAME[0]}() can't write to outer scope from subshell"
[[ "${ORIG:-0}" != "0" ]] && originalOutput=1
[[ "${DEBUG:-0}" != "0" ]] && ((!originalOutput)) && debug=1
[[ "${DEBUG:-0}" != "0" ]] && debug=1
[[ "${TRACE:-0}" != "0" ]] && trace=1
[[ "${TEST:-0}" != "0" ]] && test=1
readonly originalOutput debug trace test
Expand Down Expand Up @@ -265,7 +269,7 @@ function compileMql40() {
local srcFile="$1" version="$2" include="$3" s_compiler s_srcFile logFile
local compiler errorStatus=0 startms endms time='' output=() line i errors=0 epl='' warnings=0 wpl='' retVal

((originalOutput)) || echo "Compiling \"$srcFile\" as $(versionName "$version")"
echo "Compiling \"$srcFile\" as $(versionName "$version")"
Comment thread
rosasurfer marked this conversation as resolved.

# compose compiler command
setCompilerPath 'compiler' "$version" "$include"
Expand Down Expand Up @@ -341,11 +345,11 @@ function compileMql40() {
fi

if ((originalOutput)); then
output+=("$errorStatus")
output+=("error status: $errorStatus")
else
output[0]="${output[0]//compiler build/compiler version 4.00 build}" # update compiler info
[[ "${output[1]}" =~ ^Copyright ]] && unset 'output[1]' # remove copyright
((compactOutput)) && [[ "${output[2]}" =~ ^[[:space:]]*$ ]] && unset 'output[2]' # more compact output
((compactOutput)) && [[ "${output[2]}" =~ ^[[:space:]]*$ ]] && unset 'output[2]' # more compact output for compilation of multiple files

local keys=("${!output[@]}")
for i in "${keys[@]:2}"; do # format compiler messages
Expand Down Expand Up @@ -375,9 +379,7 @@ function compileMql5() {
local srcFile="$1" version="$2" include="$3"
local helper compiler compilerCmd includeOption='' logFile errorStatus=0

if ((!originalOutput)); then
echo "Compiling \"$srcFile\" as $(versionName "$version")"
fi
echo "Compiling \"$srcFile\" as $(versionName "$version")"

# compose the compiler command
setCompilerPath 'compiler' "$version"
Expand All @@ -396,9 +398,9 @@ function compileMql5() {
echo "$compilerCmd" >> "$helper"

# run the compiler
printCompilerInfo "$compiler"
if ((!originalOutput)); then
printCompilerInfo "$compiler"
((compactOutput)) || echo ""
((compactOutput)) || echo "" # more compact output for compilation of multiple files
fi
checkCompilerDir "$compiler"
rm -f -- "$logFile"
Expand All @@ -410,7 +412,7 @@ function compileMql5() {
# store logfile in array (convert to UTF-8 + Unix EOL, filter blank lines and infos)
local output=() line='' M='' errors=0 warnings=0
readarray -t output < <(
((originalOutput)) && M="rosasurfer" # marker to toggle result filtering
((originalOutput)) && M="rosasurfer" # custom marker to toggle result filtering
iconv -c -f UTF-16 -t UTF-8 "$logFile" | tr -d '\r' | grep -v -E "^${M}[[:space:]]*$|${M}: information: (compiling|including|generating code|code generated)" || :
)

Expand All @@ -420,7 +422,7 @@ function compileMql5() {
((!errors && !warnings)) && rm -f "$logFile"

if ((originalOutput)); then
output+=("$errorStatus")
output+=("error status: $errorStatus")
else
local keys=("${!output[@]}") size="${#output[@]}"
for i in "${keys[@]:0:$((size-1))}"; do # format compiler messages
Expand Down Expand Up @@ -493,7 +495,7 @@ function formatCompiler5Msg() {
local srcFile="$2" errors="$3" warnings="$4" level levelS file location='' message len

[[ "$logmsg" =~ ^(.*):\ (info|warn|error)[^:]*:\ (.+)$ ]] || fail "unexpected format of compiler message:$NL\"$logmsg\""

file="${BASH_REMATCH[1]}"
file="${file%"${file##*[![:space:]]}"}" # trim trailing white space
if [[ "$file" =~ \([0-9,]+\)$ ]]; then
Expand Down