Skip to content

Commit

Permalink
Antlr 4 feature file parser and CMake build system
Browse files Browse the repository at this point in the history
  • Loading branch information
iterumllc committed Jun 7, 2021
1 parent 1523970 commit 1779fa2
Show file tree
Hide file tree
Showing 889 changed files with 25,299 additions and 151,394 deletions.
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ exclude =
**/pdflib/pdfgeom.py,
**/pdflib/pdfutils.py,
**/pdflib/ttfpdf.py,
build,
_skbuild,
./venv*
2 changes: 1 addition & 1 deletion .github/workflows/asan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
run: sudo apt-get install gcc-multilib g++-multilib

- name: Set ASAN-related environment variables
run: echo '::set-env name=XFLAGS::-Og -g -fsanitize=address -fno-omit-frame-pointer'
run: echo "ADD_SANITIZER=address" >> $GITHUB_ENV

- name: Install AFDKO and dependencies
run: |
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install wheel setuptools_scm cibuildwheel
pip install wheel setuptools_scm cibuildwheel scikit-build cmake ninja
- name: Build wheel
run: python -m cibuildwheel --output-dir dist
run: |
git config --global url.https://github.com/.insteadOf git://github.com/
python -m cibuildwheel --output-dir dist
env:
CIBW_BUILD: "cp36-*"
CIBW_MANYLINUX_X86_64_IMAGE: manylinux1
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/run_cvg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ jobs:
XFLAGS: '--coverage'
run: |
python -m pip install --upgrade pip
pip install wheel
pip install wheel setuptools_scm cibuildwheel scikit-build cmake ninja
git config --global url.https://github.com/.insteadOf git://github.com/
python setup.py bdist_wheel
echo 'Installing AFDKO wheel...'
pip install dist/*.whl -q
- name: Generate and upload Python and C coverage
run: |
pip install pytest pytest-cov
python -m pytest --cov --cov-report=xml
python -m pytest tests --cov --cov-report=xml
bash <(curl -s https://codecov.io/bash) -y .codecov.yml
19 changes: 17 additions & 2 deletions .github/workflows/testpythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ jobs:

- name: Use MSBuild (Windows)
uses: microsoft/setup-msbuild@v1.0.2
with:
vs-version: '[16.4,]'
if: matrix.os == 'windows-latest'

- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -65,8 +67,21 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt -r requirements-dev.txt .
pip install -r requirements.txt -r requirements-dev.txt
- name: Set Windows generator to Visual Studio
run: |
echo "CMAKE_GENERATOR=Visual Studio 16 2019" >> $GITHUB_ENV
echo "CMAKE_GENERATOR_PLATFORM=x64" >> $GITHUB_ENV
shell: bash
if: matrix.os == 'windows-latest'

- name: Install AFDKO (Other)
run: |
git config --global url.https://github.com/.insteadOf git://github.com/
pip install .
pip freeze --all
shell: bash

- name: Lint Python code with flake8 using .flake8 config file
run: |
Expand All @@ -79,4 +94,4 @@ jobs:
- name: Test with pytest
run: |
pytest --cov
pytest --no-cov tests
25 changes: 1 addition & 24 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# temporary wheel build directories
afdko.egg-info/
build/*
_skbuild/*
dist/*
.eggs/

Expand All @@ -23,29 +24,5 @@ htmlcov
*.gcda
cov*.xml

# ignore the compiled programs
c/build_all/*
!c/build_all/this_folder_intentionally_left_empty
# ANTLR binaries
**/hotpccts/pccts/bin/**

# ignore the temp build directories and files
*.o
*.a
exe/

# Xcode files
project.xcworkspace/
xcuserdata/
**/xcode/build/
*.xcscheme


# Windows build directories
*vcxproj.user
**/visualstudio/Debug/*
**/visualstudio/Release/*
**/visualstudio/x64/*

# temp output dirs created during tests
**/temp_output
12 changes: 8 additions & 4 deletions .lgtm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ extraction:
after_prepare:
- "pip3 install --upgrade --user cython"
- "pip3 install --upgrade --user wheel"
- "pip3 install --upgrade --user scikit-build"
- "pip3 install --upgrade --user cmake"
- "pip3 install --upgrade --user ninja"
- "git config --global url.https://github.com/.insteadOf git://github.com/"
- "export PATH=\"$HOME/.local/bin:$PATH\""
index:
build_command: "python3 setup.py build"
path_classifiers:
generated:
# Classify files generated from featgram.g as generated code so no alerts:
- c/makeotf/makeotf_lib/source/hotconv/featerr.c
- c/makeotf/makeotf_lib/source/hotconv/featgram.c
- c/makeotf/makeotf_lib/source/hotconv/featscan.c
- c/makeotf/makeotf_lib/source/hotconv/feattoks.h
- c/makeotf/lib/hotconv/FeatParser.cpp
- c/makeotf/lib/hotconv/FeatLexer.cpp
- c/makeotf/lib/hotconv/FeatParserVisitor.cpp
- c/makeotf/lib/hotconv/FeatParserBaseVisitor.cpp
8 changes: 4 additions & 4 deletions .run_cpplint.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
cpplint --recursive --quiet c/detype1
cpplint --recursive --quiet c/makeotf/makeotf_lib/source
cpplint --recursive --quiet c/makeotf/makeotf_lib/api
cpplint --recursive --quiet c/makeotf/makeotf_lib/resource
cpplint --recursive --quiet c/makeotf/include
cpplint --recursive --quiet c/makeotf/resource
cpplint --recursive --quiet c/makeotf/lib
cpplint --recursive --quiet c/makeotf/source
cpplint --recursive --quiet c/mergefonts
cpplint --recursive --quiet c/public
cpplint --recursive --quiet c/shared
cpplint --recursive --quiet c/rotatefont
cpplint --recursive --quiet c/sfntdiff
cpplint --recursive --quiet c/sfntedit
Expand Down
78 changes: 78 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
cmake_minimum_required(VERSION 3.16)

project(afdko)

# set(CMAKE_VERBOSE_MAKEFILE ON)

# This matches the MSVC_RUNTIME_LIBRARY property in
# c/makeotf/source/CMakeLists.txt, which can theoretically be used to
# statically link the runtime on Windows. However, the neededruntime DLL
# seems to be present in Windows and setting this caused problems in testing.
# (Setting ANTLR4_WITH_STATIC_CRT below to ON may or may not fix the problem.)
# cmake_policy(SET CMP0091 NEW) # Style of MSVC runtime selection

# RelWithDebInfo builds an optimized binary but includes debugging symbols
# Other common possibilities are "Debug" and "Release"
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Build type configuration" FORCE)
endif()
message(STATUS "Build type is ${CMAKE_BUILD_TYPE}")

set(CMAKE_CXX_STANDARD 11)

# scikit-build
if(SKBUILD)
find_package(PythonExtensions REQUIRED)
endif()

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

# Antlr 4 configuration

# This is an alternate way of supplying the Antlr 4 sources that will override
# the git clone of the tag listed below. This is especially useful if you
# encounter compiler problems and need to make small edits to compensate. Start
# with the Antlr project's sources, e.g.
# https://www.antlr.org/download/antlr4-cpp-runtime-4.9.2-source.zip
# set(ANTLR4_ZIP_REPOSITORY "/path_to_antlr4_archive/a4.zip")

add_definitions(-DANTLR4CPP_STATIC)
set(ANTLR4_WITH_STATIC_CRT OFF)
set(ANTLR4_TAG tags/4.9.2)
include(ExternalAntlr4Cpp)

# sanitizer support
# work around https://github.com/pypa/setuptools/issues/1928 with environment
# variable
if(DEFINED ENV{ADD_SANITIZER})
set(ADD_SANITIZER "$ENV{ADD_SANITIZER}" CACHE STRING "Sanitizer type (\"none\" for no sanitizer")
else()
set(ADD_SANITIZER "none" CACHE STRING "Sanitizer type (\"none\" for no sanitizer")
endif()
include(AddSanitizer)
add_sanitizer("${ADD_SANITIZER}")

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# Ported from old build files, XXX not sure if all of these are needed
if(WIN32)
add_compile_definitions(CTL_CDECL=__cdecl CDECL=__cdecl
OS=os_windowsNT ISP=isp_i80486 _CRT_SECURE_NO_DEPRECATE
$<$<CONFIG:Release>:NDEBUG>)
endif()

include(CheckLibraryExists)
CHECK_LIBRARY_EXISTS(m floor "" HAVE_M_LIB)

include(CTest)
include(AddAFDKOTests)

add_subdirectory(c/shared/source)
add_subdirectory(c/detype1/source)
add_subdirectory(c/mergefonts/source)
add_subdirectory(c/rotatefont/source)
add_subdirectory(c/sfntdiff/source)
add_subdirectory(c/sfntedit/source)
add_subdirectory(c/spot/source)
add_subdirectory(c/tx/source)
add_subdirectory(c/type1/source)
add_subdirectory(c/makeotf)
35 changes: 34 additions & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2014-2018 Adobe. All rights reserved.
Copyright 2014-2021 Adobe. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use these files except in compliance with the License.
Expand All @@ -11,3 +11,36 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

---------------------------------------------------------------------------

The file ExternalAntlr4Cpp.cmake is copied from the Antlr 4 project
(https://github.com/antlr/antlr4/tree/master/runtime/Cpp/cmake) under
the BSD 3-clause license:

[The "BSD 3-clause license"]
Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Empty file.
48 changes: 0 additions & 48 deletions c/buildall.cmd

This file was deleted.

31 changes: 0 additions & 31 deletions c/buildall.sh

This file was deleted.

30 changes: 0 additions & 30 deletions c/buildalllinux.sh

This file was deleted.

Loading

0 comments on commit 1779fa2

Please sign in to comment.