Este documento descreve como configurar o ambiente de desenvolvimento local do GPT usando as mesmas etapas utilizadas no pipeline do GitHub Actions para GNU/Linux e Windows.
Dependências:
- g++
- make
- autoconf
- automake
- libtool
- pkg-config
- libantlr-dev (ANTLR 2.x)
- libpcre2-dev
- nasm
- wget
git clone https://github.com/gportugol/gpt.gitO GPT pode ser compilado nativamente em distribuições GNU/Linux, como o Debian/Ubuntu, usando os pacotes:
sudo apt install -y \
build-essential autoconf automake libtool pkg-config \
libantlr-dev libpcre2-dev nasmautoreconf -i
./configure --prefix=/usr/local
make -j$(nproc)src/gpt -i exemplos/olamundo.gptsrc/gpt -o olamundo exemplos/olamundo.gpt
./olamundoO GPT é compilado no Windows usando MSYS2.
Baixar em https://www.msys2.org e instalar o MSYS2
Abra o terminal MSYS2 MinGW 64-bit.
pacman -Syu --noconfirm
pacman -S --noconfirm \
autoconf automake libtool make \
mingw-w64-x86_64-gcc mingw-w64-x86_64-gcc-libs \
mingw-w64-x86_64-pcre2 pkg-config \
tar unzip wgetwget https://download.java.net/java/GA/jdk25.0.1/2fbf10d8c78e40bd87641c434705079d/8/GPL/openjdk-25.0.1_windows-x64_bin.zip
unzip openjdk-25.0.1_windows-x64_bin.zip
export PATH=$PATH:$(pwd)/jdk-25.0.1/binO ANTLR 2 é muito antigo e não compila corretamente no Mingw64 sem correções.
Precisamos aplicar dois patches usando o sed.
wget http://www.antlr2.org/download/antlr-2.7.7.tar.gz
tar xvfz antlr-2.7.7.tar.gz
cd antlr-2.7.7Insere no topo de CharScanner.hpp:
sed -i \
'1i \
#ifdef _WIN32\n\
#include <string.h>\n\
#define strcasecmp _stricmp\n\
#endif' \
lib/cpp/antlr/CharScanner.hppsed -i \
's/struct CharScannerLiteralsLess : public binary_function<string, string, bool>/\
struct CharScannerLiteralsLess { \
bool operator()(const std::string& x, const std::string& y) const { \
return strcasecmp(x.c_str(), y.c_str()) < 0; \
} \
};/g' \
lib/cpp/antlr/CharScanner.hppEsses patches corrigem:
- Incompatibilidade com
binary_functionremovido no C++17 - Ausência de
strcasecmpno Windows
export CXXFLAGS="-O2 -std=gnu++14 -static -static-libgcc -static-libstdc++"
export LDFLAGS="-static -static-libgcc -static-libstdc++"
autoreconf -fi
./configure --prefix=/usr/local
make -j$(nproc)
make installCriar o alias usado pelo GPT:
ln -s /usr/local/bin/antlr /usr/local/bin/runantlr || truewget https://www.nasm.us/pub/nasm/releasebuilds/0.99.06/nasm-0.99.06-win32.zip
unzip nasm-0.99.06-win32.zip
cp nasm-0.99.06/nasm.exe /mingw64/bin/export CXXFLAGS="-O2 -std=gnu++14 -static -static-libgcc -static-libstdc++"
export LDFLAGS="-static -static-libgcc -static-libstdc++"
autoreconf -i
./configure --prefix=/usr/local
make -j$(nproc)
make installgpt.exe -i exemplos/olamundo.gptgpt.exe -o olamundo.exe exemplos/olamundo.gpt
./olamundo.exeDocumentação na pasta doc e o manual (LaTeX) em doc/manual.
sudo apt install -y latex-make texlive-latex-base texlive-lang-portuguese latex2htmlPara PDF:
cd doc/manual
pdflatex manual.texPara HTML:
cd doc/manual
latex2html manual.tex