Skip to content
Snippets Groups Projects
Commit 1b46d8f1 authored by Ivar Härnqvist's avatar Ivar Härnqvist
Browse files

add readme, logo, CMakeLists, setup boilerplate and example code

parent 7b263393
No related branches found
No related tags found
4 merge requests!67WIP: B-ASIC version 1.0.0 hotfix,!65B-ASIC version 1.0.0,!15Add changes from sprint 1 and 2 to master,!1WIP: System shell to develop branch
......@@ -3,6 +3,7 @@
build*/
bin*/
logs/
dist/
CMakeLists.txt.user*
*.autosave
*.creator
......@@ -25,4 +26,5 @@ ehthumbs.db
ehthumbs_vista.db
$RECYCLE.BIN/
*.stackdump
[Dd]esktop.ini
\ No newline at end of file
[Dd]esktop.ini
*.egg-info
\ No newline at end of file
stages:
- build
PythonBuild:
stage: build
artifacts:
untracked: true
script:
- apt-get update && apt-get install python3 -y
- bash build.sh
\ No newline at end of file
cmake_minimum_required(VERSION 3.8)
project(
"B-ASIC"
VERSION 0.0.1
DESCRIPTION "Better ASIC Toolbox for python3"
LANGUAGES C CXX
)
find_package(fmt 6.1.2 REQUIRED)
find_package(pybind11 CONFIG REQUIRED)
set(LIBRARY_NAME "b_asic")
set(TARGET_NAME "_${LIBRARY_NAME}")
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
include(GNUInstallDirs)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_INSTALL_LIBDIR}")
endif()
add_library(
"${TARGET_NAME}" MODULE
"${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp"
)
add_library(
"${TARGET_NAME}:${TARGET_NAME}"
ALIAS "${TARGET_NAME}"
)
set_target_properties(
"${TARGET_NAME}"
PROPERTIES
PREFIX ""
)
target_include_directories(
"${TARGET_NAME}"
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/src"
)
target_compile_features(
"${TARGET_NAME}"
PRIVATE
cxx_std_17
)
target_compile_options(
"${TARGET_NAME}"
PRIVATE
$<$<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>>:
-W -Wall -Wextra -Werror -Wno-psabi -fvisibility=hidden
$<$<CONFIG:Debug>:-g>
$<$<NOT:$<CONFIG:Debug>>:-O3>
>
$<$<CXX_COMPILER_ID:MSVC>:
/W3 /WX /permissive- /utf-8
$<$<CONFIG:Debug>:/Od>
$<$<NOT:$<CONFIG:Debug>>:/Ot>
>
)
target_link_libraries(
"${TARGET_NAME}"
PRIVATE
fmt::fmt-header-only
pybind11::module
)
add_custom_target(
copy_python_files ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_LIST_DIR}/${LIBRARY_NAME}" "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
COMMENT "Copying python files to ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
)
add_custom_target(
copy_misc_files ALL
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_LIST_DIR}/README.md" "${CMAKE_CURRENT_LIST_DIR}/LICENSE" "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
COMMENT "Copying misc. files to ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
)
\ No newline at end of file
LICENSE 100644 → 100755
File mode changed from 100644 to 100755
include README.md
include LICENSE
recursive-include src *.cpp *.h
README.md 100644 → 100755
<img src="https://files.slack.com/files-pri/TSHPRJY83-FTTRW9MQ8/b-asic-logo-opaque.png" width="318" height="100">
<br>
<h3>The leading company in circuit design<h3>
\ No newline at end of file
<img src="logo.png" width="278" height="100">
# B-ASIC - Better ASIC Toolbox
B-ASIC is an ASIC toolbox for Python 3 that simplifies circuit design and optimization.
## Prerequisites
The following packages are required in order to build the library:
* cmake 3.8+
* gcc 7+/clang 7+/msvc 16+
* fmtlib 6.1.2+
* pybind11 2.3.0+
* python 3.6+
* setuptools
* wheel
* pybind11
## Development
How to build and debug the library during development.
### Using CMake directly
How to build using CMake.
#### Configuring
In `B-ASIC`:
```
mkdir build
cd build
cmake ..
```
#### Building (Debug)
In `B-ASIC/build`:
```
cmake --build .
```
The output gets written to `B-ASIC/build/lib`.
#### Building (Release)
In `B-ASIC/build`:
```
cmake --build . --config Release
```
The output gets written to `B-ASIC/build/lib`.
### Using setuptools to create a package
How to create a package using setuptools.
#### Setup (Binary distribution)
In `B-ASIC`:
```
python3 setup.py bdist_wheel
```
The output gets written to `B-ASIC/dist`.
#### Setup (Source distribution)
In `B-ASIC`:
```
python3 setup.py sdist
```
The output gets written to `B-ASIC/dist`.
## Usage
How to build and use the library as a user.
### Installation
```
python3 -m pip install b_asic
```
### Importing
```
python3
>>> import b_asic as asic
>>> help(asic)
```
## License
B-ASIC is distributed under the MIT license.
See the included LICENSE file for more information.
\ No newline at end of file
"""Better ASIC Toolbox"""
from _b_asic import *
def mul(a, b):
"""A function that multiplies two numbers"""
return a * b
#! bin/sh
for n in `find . -name "*.py"`
do
python3 $n
done
\ No newline at end of file
print("Hello world")
\ No newline at end of file
logo.png 0 → 100755
logo.png

69 KiB

setup.py 0 → 100755
import os
import sys
import shutil
import subprocess
import setuptools
from setuptools import Extension
from setuptools.command.build_ext import build_ext
CMAKE_EXE = os.environ.get('CMAKE_EXE', shutil.which('cmake'))
class CMakeExtension(Extension):
def __init__(self, name, sourcedir = ""):
super().__init__(name, sources=[])
self.sourcedir = os.path.abspath(sourcedir)
class CMakeBuild(build_ext):
def build_extension(self, ext):
if not isinstance(ext, CMakeExtension):
return super().build_extension(ext)
if not CMAKE_EXE:
raise RuntimeError(f"Cannot build extension {ext.name}: CMake executable not found! Set the CMAKE_EXE environment variable or update your path.")
cmake_build_type = "Debug" if self.debug else "Release"
cmake_output_dir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
cmake_configure_argv = [
CMAKE_EXE, ext.sourcedir,
"-DCMAKE_BUILD_TYPE=" + cmake_build_type,
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=" + cmake_output_dir,
"-DPYTHON_EXECUTABLE=" + sys.executable,
]
cmake_build_argv = [
CMAKE_EXE, "--build", ".",
"--config", cmake_build_type
]
if not os.path.exists(self.build_temp):
os.makedirs(self.build_temp)
env = os.environ.copy()
print(f"=== Configuring {ext.name} ===")
print(f"Temp dir: {self.build_temp}")
print(f"Output dir: {cmake_output_dir}")
subprocess.check_call(cmake_configure_argv, cwd=self.build_temp, env=env)
print(f"=== Building {ext.name} ===")
print(f"Temp dir: {self.build_temp}")
print(f"Output dir: {cmake_output_dir}")
print(f"Build type: {cmake_build_type}")
subprocess.check_call(cmake_build_argv, cwd=self.build_temp, env=env)
print()
setuptools.setup(
name = "b-asic",
version = "0.0.1",
author = "Adam Jakobsson, Angus Lothian, Arvid Westerlund, Felix Goding, Ivar Härnqvist, Jacob Wahlman, Kevin Scott, Rasmus Karlsson",
author_email = "adaja901@student.liu.se, anglo547@student.liu.se, arvwe160@student.liu.se, felgo673@student.liu.se, ivaha717@student.liu.se, jacwa448@student.liu.se, kevsc634@student.liu.se, raska119@student.liu.se",
description = "Better ASIC Toolbox",
long_description = open("README.md", "r").read(),
long_description_content_type = "text/markdown",
url = "https://gitlab.liu.se/PUM_TDDD96/B-ASIC",
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires = ">=3.6",
install_requires = ["pybind11>=2.3.0"],
packages = ["b_asic"],
ext_modules = [CMakeExtension("b_asic")],
cmdclass = {"build_ext": CMakeBuild},
zip_safe = False
)
\ No newline at end of file
#include <pybind11/pybind11.h>
namespace py = pybind11;
namespace asic {
int add(int a, int b) {
return a + b;
}
int sub(int a, int b) {
return a - b;
}
} // namespace asic
PYBIND11_MODULE(_b_asic, m) {
m.doc() = "Better ASIC Toolbox Extension Module";
m.def("add", &asic::add, "A function which adds two numbers", py::arg("a"), py::arg("b"));
m.def("sub", &asic::sub, "A function which subtracts two numbers", py::arg("a"), py::arg("b"));
}
\ No newline at end of file
print("Worked to build this file")
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment