This is an experimental translator of C (ISO/IEC 9899:2018) programs to EO programs.
Assuming, you are on Ubuntu 22.04+:
apt update
apt install -y software-properties-common
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F7C91591CC543ECA
add-apt-repository \
'deb http://c2eo.polystat.org/debian/ c2eo-rep non-free main contrib'
apt-get install -y clang
apt-get install -y c2eoThen, just run:
c2eo <path-to-c-file-name> <eo-file-name>.eoYou can also use yegor256/c2eo image via Docker:
docker run -v $(pwd):/eo yegor256/c2eo:<tag> hello.c hello.eoAssuming you have hello.c in the current directory, the hello.eo will be
created next to it.
We do not support the utility for other distributions and operating systems yet. However, you can try to build the project from source at your own risk.
Again, we recommend Ubuntu 22.04+ and you will need wget 1.21+, tar 1.30+, git 2.32.+, cmake 3.18+, gcc 11.2.+, g++ 11.2.+, ninja-build 1.10.1+, clang 14.0.0+ and python3 3.10.0+. You will also need requirements for the EO project (Maven 3.3+ and Java 8+)
Then, you need to install GTest 1.12.1+
apt install libgtest-dev googletest
cd /usr/src/googletest
cmake .
make
lib
cp *.a /usr/local/libAfter that, you need to install LLVM/Clang 12.0.1 or you may use an alternative way below this code:
wget https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-12.0.1.tar.gz
tar -xvf llvmorg-12.0.1.tar.gz
mv ./llvm-project-llvmorg-12.0.1 ./llvm-clang
cd llvm-clang
mkdir build && cd $_
cmake --no-warn-unused-cli \
-DBUILD_SHARED_LIBS:STRING=ON \
-DLLVM_TARGETS_TO_BUILD:STRING=X86 \
-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE \
"-DLLVM_ENABLE_PROJECTS:STRING=clang;compiler-rt" \
-DCMAKE_BUILD_TYPE:STRING=Debug \
-DLLVM_OPTIMIZED_TABLEGEN:STRING=ON \
-DLLVM_USE_SPLIT_DWARF:STRING=ON \
-DLLVM_USE_LINKER:STRING=gold \
../llvm -G Ninja
cmake --build . --config Debug --target all -j 10 -- -j1 -l 2
cd ../..You may also try our own pre-packaged archive:
apt install megatools
megadl 'https://mega.nz/#!cZ9WQCqB!z713CuC-GNFQAXIxZwZxI05zOH4FAOpwYHEElgOZflA'
tar -xvf llvm-clang.tar.gzIt is assumed that the llvm-clang dir is located in the c2eo dir.
If your llvm-clang is in different place, set the path in that
line.
Formally speaking, this is where the preparation can be completed. However, in order to fully work with the project, testing and executing the translated code, you need to study the EO compiler project and fulfill its necessary requirements. After that, it will be possible to proceed with further steps.
All sources files of transpiler are located in src/transpiler.
The transpiler's work begins with the code from the source file
src/transpiler/main.cpp.
After making changes in these files, we will need to rebuild the executable
file c2eo.
To do this, you need to go to the repository root.
For the first time, create the build folder:
mkdir buildthen go to the build folder and run the following commands:
cmake ..
makeAs you have already noticed, the project is being built in the build folder.
The result of this build is the c2eo file in bin.
Now you have a transpiler and you can convert programs from C to EO.
Just run:
./c2eo <path-to-c-file-name> <eo-file-name>.eo
# ./c2eo ../some_dir/example.c example.eoYour PR will pass the following checks, so before creating PR run these locally to make sure everything is ok:
-
clang-format src/transpiler/*.(cpp|h) -i
-
cpplint --filter=-runtime/references,-runtime/string,-build/c++11 \ src/transpiler/** -
cd scripts python3 clang_tidy.py -
cd scripts python3 transpile.py <your_path_to_the_folder>/gcc.c-torture -s gcc -n
-
cd scripts python3 test.py -p <your_path_to_the_folder>/c-testcuite -s testcuite -n
-
test
cd scripts python3 test.py -s test
-
unit-tests
cd scripts python3 build_c2eo.py cd ../bin/ ./unit_tests --gtest_filter=*
From scripts/ directory:
$ python3 update-release.py -h
usage: update-release.py [-h] [--branch BRANCH] [--version VERSION]
Release maker
optional arguments:
-h, --help show this help message and exit
--version VERSION specify the new versionExample
python3 update-release.py --version=0.1.1To use this script, make sure you have the following packages installed:
pip3 install git_config pgpy s3cmd
apt install md5deep reprepro gcc cmake dpkg wget tar s3cmd -y
# for the latest version of the cmake package, try:
pip3 install cmakeNotes:
- Use
.as a version delimiter. - This script uses the current date, time, and time zone. Make sure they are configured correctly.
- This script extracts your name and email from
git config. Make sure you have them.
This script will write automatically generated merges to the changelog file. You can view an approximate list of changes by running the following command in the terminal:
git log $(git describe --tags --abbrev=0)..HEAD \
--merges --oneline --format=" * %h %s by %an <%aE>"- Build the executable file.
- Create a deb file (basic: HABR)
- Create a repository (basic: UNIXFORUM)
- Upload a repository tree into the bucket's virtual 'directory'.
The following files will be generated:
$ tree
.
├── c2eo-X.X.X
│ ├── DEBIAN
│ │ ├── changelog
│ │ ├── control
│ │ ├── copyright
│ │ └── md5sums
│ └── usr
│ ├── bin
│ │ └── c2eo
│ └── lib
│ ├── libclangAnalysis.so
│ ├── libclangAnalysis.so.12
│ ├── ...
│ └── libLLVMTransformUtils.so.12
├── c2eo-X.X.X.deb
├── readme.md
├── repository
│ ├── conf
│ │ └── distributions
│ ├── db
│ │ ├── checksums.db
│ │ ├── contents.cache.db
│ │ ├── packages.db
│ │ ├── references.db
│ │ ├── release.caches.db
│ │ └── version
│ ├── dists
│ │ └── c2eo-rep
│ │ ├── contrib
│ │ │ ├── binary-amd64
│ │ │ │ ├── Packages
│ │ │ │ ├── Packages.gz
│ │ │ │ └── Release
│ │ │ ├── binary-i386
│ │ │ │ ├── Packages
│ │ │ │ ├── Packages.gz
│ │ │ │ └── Release
│ │ │ ├── debian-installer
│ │ │ │ ├── binary-amd64
│ │ │ │ │ ├── Packages
│ │ │ │ │ └── Packages.gz
│ │ │ │ └── binary-i386
│ │ │ │ ├── Packages
│ │ │ │ └── Packages.gz
│ │ │ └── source
│ │ │ ├── Release
│ │ │ └── Sources.gz
│ │ ├── InRelease
│ │ ├── main
│ │ │ ├── binary-amd64
│ │ │ │ ├── Packages
│ │ │ │ ├── Packages.gz
│ │ │ │ └── Release
│ │ │ ├── binary-i386
│ │ │ │ ├── Packages
│ │ │ │ ├── Packages.gz
│ │ │ │ └── Release
│ │ │ ├── debian-installer
│ │ │ │ ├── binary-amd64
│ │ │ │ │ ├── Packages
│ │ │ │ │ └── Packages.gz
│ │ │ │ └── binary-i386
│ │ │ │ ├── Packages
│ │ │ │ └── Packages.gz
│ │ │ └── source
│ │ │ ├── Release
│ │ │ └── Sources.gz
│ │ ├── non-free
│ │ │ ├── binary-amd64
│ │ │ │ ├── Packages
│ │ │ │ ├── Packages.gz
│ │ │ │ └── Release
│ │ │ ├── binary-i386
│ │ │ │ ├── Packages
│ │ │ │ ├── Packages.gz
│ │ │ │ └── Release
│ │ │ ├── debian-installer
│ │ │ │ ├── binary-amd64
│ │ │ │ │ ├── Packages
│ │ │ │ │ └── Packages.gz
│ │ │ │ └── binary-i386
│ │ │ │ ├── Packages
│ │ │ │ └── Packages.gz
│ │ │ └── source
│ │ │ ├── Release
│ │ │ └── Sources.gz
│ │ ├── Release
│ │ └── Release.gpg
│ └── pool
│ └── main
│ └── c
│ └── c2eo
│ └── c2eo_X.X.X_all.deb
├── todo.sh
└── update-release.py
35 directories, 120 filesThen you have to upload ./repository/dists and ./repository/pool to
c2eo.polystat.org/debian/.