Skip to content

Commit

Permalink
replace cmake with meson #162
Browse files Browse the repository at this point in the history
  • Loading branch information
Nic30 committed May 30, 2023
1 parent 56b2da6 commit 78a0d61
Show file tree
Hide file tree
Showing 25 changed files with 479 additions and 567 deletions.
54 changes: 17 additions & 37 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ orbs:

jobs:
install-test-coverage:
# executor: python/default
resource_class: medium
docker:
- image: ubuntu:rolling
Expand All @@ -19,42 +18,30 @@ jobs:
export DEBIAN_FRONTEND=noninteractive
export TZ=America/USA
apt update
apt install -y build-essential libantlr4-runtime-dev antlr4 cmake ninja-build python3-pip python3-dev python3 python3-pip python3-venv git lcov rubygems
apt install -y build-essential libantlr4-runtime-dev antlr4 cmake ninja-build python3-pip python3-dev python3 python3-pip python3-venv python3-build git lcov rubygems
python3 -m venv venv
echo "source $PWD/venv/bin/activate" >> $BASH_ENV
echo 'export SKBUILD_CONFIGURE_OPTIONS="-DCMAKE_BUILD_TYPE:STRING=Debug -DCODE_COVERAGE=ON"' >> $BASH_ENV
# because we do not have enough RAM
echo 'export SKBUILD_BUILD_OPTIONS="-j1"' >> $BASH_ENV
source $BASH_ENV
- run:
command: |
update-alternatives --install /usr/bin/python python /usr/bin/python3 10;
update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 10;
- run: git submodule sync
- run: git submodule update --init
# - python/load-cache

- run:
command: |
gcc -v;
python --version;
cmake --version;
meson --version;
free;
- run: pip install jupyter
- run: gem install coveralls-lcov
#- run:
# command: |
# echo export CXXFLAGS=\"$CXXFLAGS --param ggc-min-expand=1 --param ggc-min-heapsize=32768\" >> "$BASH_ENV"
- py/install-setup-py:
rm-package-dir: true
build-args: "--verbose"
# - python/save-cache
- run:
name: build
command: |
python3 -m build -Csetup-args="-Db_coverage=true" -Ccompile-args="-j 1 --verbose" . # -j1 because we do not have enough RAM
mv $MODULE_NAME "removed_because_of_coverage_$MODULE_NAME"
- py/test-and-coverage:
coverage: false
coverage: false # dissable python coverage, we are collecting only C++ one
- run:
name: Filter lcov outputs for scikit-build and upload it to coveralls.io
command: |
Expand All @@ -63,7 +50,7 @@ jobs:
fi
if [ -z "$CIRCLE_PULL_REQUEST" ]; then
lcov --compat-libtool --directory . --capture --output-file coverage.info.raw;
lcov --remove coverage.info.raw -o coverage.info '/usr/*' '*_skbuild/*';
lcov --remove coverage.info.raw -o coverage.info '/usr/*';
sed -i 's/\/root\/project\///g' coverage.info;
sed -i 's/\/root\///g' coverage.info;
coveralls-lcov coverage.info --repo-token ${COVERALLS_REPO_TOKEN};
Expand All @@ -72,7 +59,6 @@ jobs:
fi
install-test-deploy:
# executor: python/default
resource_class: medium
docker:
- image: ubuntu:rolling
Expand All @@ -85,16 +71,11 @@ jobs:
export DEBIAN_FRONTEND=noninteractive
export TZ=America/USA
apt update
apt install -y build-essential libantlr4-runtime-dev antlr4 cmake ninja-build python3-pip python3-dev python3 python3-pip python3-venv git lcov rubygems
# libantlr4-runtime-dev antlr4 are ommited in order that meson downloads them using wrap
apt install -y build-essential cmake ninja-build python3-pip python3-dev python3 python3-pip python3-venv python3-build git lcov rubygems
python3 -m venv venv
echo "source $PWD/venv/bin/activate" >> $BASH_ENV
# because we do not have enough RAM
echo 'export SKBUILD_BUILD_OPTIONS="-j1"' >> $BASH_ENV
source $BASH_ENV
- run:
command: |
update-alternatives --install /usr/bin/python python /usr/bin/python3 10;
update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 10;
- run: git submodule sync
- run: git submodule update --init
Expand All @@ -109,13 +90,12 @@ jobs:
- run: pip install jupyter
- run: gem install coveralls-lcov
#- run:
# command: |
# echo export CXXFLAGS=\"$CXXFLAGS --param ggc-min-expand=1 --param ggc-min-heapsize=32768\" >> "$BASH_ENV"
- py/install-setup-py:
rm-package-dir: true
build-args: "--verbose"
# - python/save-cache
- run:
name: build
command: |
python3 -m build -Ccompile-args="-j 1 --verbose" . # -j1 because we do not have enough RAM
rm -rf $MODULE_NAME
- py/test-and-coverage:
coverage: false
- py/deploy-pypi-on-tag:
Expand Down
13 changes: 3 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,8 @@ dist/
_skbuild/
.eggs/
hdlConvertor.egg-info

# parser generated source dirs/files
src/svConvertor/sv2017Parser/
src/verilogPreproc/verilogPreprocParser/
src/vhdlConvertor/vhdlParser/

include/hdlConvertor/svConvertor/sv2017Parser/*.h
include/hdlConvertor/verilogPreproc/verilogPreprocParser/*.h
include/hdlConvertor/vhdlConvertor/vhdlParser/*.h
venv/
subprojects/antlr4-runtime


# devel archives
Expand All @@ -66,4 +59,4 @@ coverage.info
coverage.info.raw

# Ignore .vscode files
.vscode/
.vscode/
53 changes: 0 additions & 53 deletions CMakeLists.txt

This file was deleted.

35 changes: 12 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,48 +29,37 @@ It contains:
Linux:
Installing dependencies (Ubuntu 20.10)
```
# we recommend to use gcc>=9, Visual Studio 2017 or equivalent
# gcc>=9, Visual Studio 2017 or equivalent recommended
sudo apt install build-essential uuid-dev cmake default-jre python3 python3-dev python3-pip libantlr4-runtime-dev antlr4 ninja-build
```

Installing this library
```
# python recommends to use venv (virtualenv) https://docs.python.org/3/library/venv.html
# sudo pip3 install venv
# python3 -m venv myvenv
# source myvenv/bin/activate
# note this may be older version than you see in repo
sudo pip3 install hdlConvertor
pip3 install hdlConvertor
# or download repository and run
sudo pip3 install --upgrade --force-reinstall --no-cache-dir git+https://github.com/Nic30/hdlConvertorAst.git
sudo pip3 install -r requirements.txt
sudo python3 setup.py install
# if you are using version from git rather uninstall
# old library first if required
# sudo pip3 uninstall hdlConvertor
```

Installer also supports other options which may be usefull
```
python setup.py install --prefix /tmp/python_install/ --build-type Debug -- -DANTLR_JAR_LOCATION=/antlr-4.7.1-complete.jar -- VERBOSE=1
pip3 install --upgrade --force-reinstall --no-cache-dir git+https://github.com/Nic30/hdlConvertorAst.git # optionally
pip3 install .
```

You can also install only C++ library/generate .deb package (nothing specific, just normal cmake-based library)
```
mkdir build && cd build
cmake .. && cmake . --build
cpack # to generate .deb package
meson setup build -Dpython_package=false
ninja -C build
```

Windows:

Take a look at appveyor.yml and [doc/windows_installation_and_build.rst](doc/windows_installation_and_build.rst). It is required to download antlr4 first and have visual studio or other c++ compiler installed.

For dev purposes also this link could be usefull https://meson-python.readthedocs.io/en/latest/how-to-guides/meson-args.html#how-to-guides-meson-args

## Usage

The HDL AST (the parsed code) is represented by objects from `hdlConvertor.hdlAst`. Parsing and code modification is straightforward, as you can see in following example [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/Nic30/hdlConvertor/master?filepath=notebooks%2F01_parse_and_dump.ipynb)



### Similar projects:
(Tell us If you know about some other project!)

Expand Down
46 changes: 0 additions & 46 deletions hdlConvertor/CMakeLists.txt

This file was deleted.

41 changes: 41 additions & 0 deletions hdlConvertor/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

# install all python sources
py_sources = run_command(py3, '../utils/rec_glob.py', '.', '*.py', check:true)\
.stdout().strip().split('\n')

# mark sources of a single module for an installation
py3.install_sources(
py_sources,
pure: false, # Will be installed next to binaries
subdir: 'hdlConvertor', # Folder relative to site-packages to install to
)

_hdlConvertor_cpp_sources = [
'toPy_expr.cpp',
'toPy_statements.cpp',
'toPy_type.cpp',
'toPy.cpp',
'toPy.h',
]

py3.extension_module(
'_hdlConvertor',
_hdlConvertor_cpp_sources + ['_hdlConvertor.pyx', 'python_ver_independent_str.pyx', 'verilogPreproc.pyx'],
include_directories: [mainIncludeDir_inc],
dependencies : [py3_dep, antlr4_cpp_dep, hdlConvertor_cpp_dep],
install: true,
cpp_args: EXTRA_CXX_FLAGS,
override_options : ['cython_language=cpp'],
subdir: 'hdlConvertor/',
)

#file(GLOB hdlConvertor_py_SRC
# "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
#)
#include_directories(
# "${CMAKE_CURRENT_SOURCE_DIR}"
# "${CMAKE_CURRENT_SOURCE_DIR}/../include/"
#)



4 changes: 4 additions & 0 deletions include/hdlConvertor/svConvertor/sv2017Parser/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
antrl_parser_headers = custom_target('antrl_parser_sv2017_headers',
input : antlr_parser_parser_src_gen,
output : generated_headers,
command : [cp, ] + generated_headers_abs + [meson.current_build_dir()])
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
antrl_parser_headers = custom_target('antrl_parser_verilogPreproc_headers',
input : antlr_parser_parser_src_gen,
output : generated_headers,
command : [cp, ] + generated_headers_abs + [meson.current_build_dir()])
4 changes: 4 additions & 0 deletions include/hdlConvertor/vhdlConvertor/vhdlParser/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
antrl_parser_headers = custom_target('antrl_parser_vhdl_headers',
input : antlr_parser_parser_src_gen,
output : generated_headers,
command : [cp, ] + generated_headers_abs + [meson.current_build_dir()])
Loading

0 comments on commit 78a0d61

Please sign in to comment.