Compare commits
27
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e5d6a9d81f | ||
|
|
3e7efdc741 | ||
|
|
7872408f74 | ||
|
|
4fa37b0b10 | ||
|
|
301af992fe | ||
|
|
439ae24705 | ||
|
|
04112340a0 | ||
|
|
c4470046b3 | ||
|
|
11aa1a5f5b | ||
|
|
f84a72aa37 | ||
|
|
9b606a9004 | ||
|
|
92cb70de2b | ||
|
|
0d63c63d4c | ||
|
|
bb0008f941 | ||
|
|
91046817b1 | ||
|
|
c15d8d7336 | ||
|
|
9b3d014c3e | ||
|
|
9e261a8ffc | ||
|
|
3957f970eb | ||
|
|
0ad0cdef14 | ||
|
|
b1844be9cc | ||
|
|
f744ba3265 | ||
|
|
089762d84a | ||
|
|
317c9173ec | ||
|
|
0510de8634 | ||
|
|
9f29353db3 | ||
|
|
469a6e45d4 |
@@ -0,0 +1,65 @@
|
||||
version: '{build}'
|
||||
|
||||
# for Appveyor CI (windows)
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
|
||||
os: Windows Server 2012 R2
|
||||
|
||||
clone_folder: c:\projects\STEPcode
|
||||
|
||||
#grab zip instead of git clone
|
||||
shallow_clone: true
|
||||
platform: x64
|
||||
configuration: Debug
|
||||
|
||||
# errors or couldn't be found by cmake
|
||||
# - GENERATOR: "Visual Studio 9 2008"
|
||||
# ARCH: 32
|
||||
# - GENERATOR: "Visual Studio 10"
|
||||
# ARCH: 32
|
||||
|
||||
#no point in these without artifact support...
|
||||
# - GENERATOR: "Visual Studio 11"
|
||||
#ARCH: 32
|
||||
#- GENERATOR: "Visual Studio 12"
|
||||
#ARCH: 32
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- GENERATOR: "Visual Studio 12 Win64"
|
||||
ARCH: 64
|
||||
|
||||
# build:
|
||||
# parallel: true
|
||||
# project: ALL_BUILD.vcxproj
|
||||
|
||||
#appveyor limits compile/test to 30 minutes
|
||||
# to reduce time, only test schemas with files: ifc2x3, ap214e3, ap209
|
||||
|
||||
build_script:
|
||||
- ps: |
|
||||
cd c:\projects\STEPcode
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -version
|
||||
grep --version
|
||||
cmake .. -DSC_ENABLE_TESTING=ON -G"$env:GENERATOR" -DSC_BUILD_SCHEMAS="ifc2x3;ap214e3;ap209"
|
||||
echo "filtering build output with grep"
|
||||
cmake --build . --config Debug | grep -ve "CMake does not need to re-run because" -e "ZERO_CHECK.ZERO_CHECK" -e "^ Creating directory"
|
||||
|
||||
#msbuld seems to provide no benefits, and I can't filter its output...
|
||||
#msbuild SC.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /p:Configuration=Debug /p:Platform=x64
|
||||
# /toolsversion:14.0 /p:PlatformToolset=v140
|
||||
|
||||
test_script:
|
||||
- cmd: echo Running CTest...
|
||||
- cmd: cd c:\projects\STEPcode\build
|
||||
- cmd: echo excluding test_inverse_attr3, which hangs
|
||||
- cmd: ctest -j1 . -C Debug --output-on-failure
|
||||
|
||||
# - cmd: grep -niB20 "Test Failed" Testing/Temporary/LastTest.log
|
||||
|
||||
# we could upload a compiled zip somewhere (see Appveyor artifact documentation)
|
||||
@@ -1,277 +0,0 @@
|
||||
name: STEPCODE
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
windows:
|
||||
name: Windows Latest MSVC
|
||||
runs-on: windows-latest
|
||||
strategy:
|
||||
fail-fast: true
|
||||
steps:
|
||||
- name: Setup - CMake
|
||||
uses: lukka/get-cmake@latest
|
||||
|
||||
- name: Setup - Ninja
|
||||
uses: seanmiddleditch/gha-setup-ninja@master
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Add github workspace to path
|
||||
# https://github.community/t/deprecated-add-path/136621
|
||||
run: echo "$ENV{GITHUB_WORKSPACE}" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
|
||||
|
||||
- name: Add msbuild to PATH
|
||||
uses: microsoft/setup-msbuild@v1.0.2
|
||||
|
||||
- name: Add cl.exe to PATH
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
cmake -S . -B build -G Ninja -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_CXX_COMPILER="cl.exe" -DSC_ENABLE_TESTING=ON
|
||||
# We do the following in order to help ensure files are "flushed"
|
||||
# to disk before compilation is attempted
|
||||
# https://superuser.com/a/1553374/1286142
|
||||
powershell Write-VolumeCache C
|
||||
powershell Write-VolumeCache D
|
||||
|
||||
- name: Build
|
||||
run: cd build && ninja -j1 -v
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
cd build && ctest -j1 .
|
||||
|
||||
linux:
|
||||
name: Ubuntu Latest GCC
|
||||
runs-on: ubuntu-20.04
|
||||
strategy:
|
||||
fail-fast: true
|
||||
steps:
|
||||
- name: Setup - CMake
|
||||
uses: lukka/get-cmake@latest
|
||||
|
||||
- name: Setup - Ninja
|
||||
uses: seanmiddleditch/gha-setup-ninja@master
|
||||
|
||||
# TODO - we will want this when the new parser work comes in,
|
||||
# as we won't need perplex and the system tools should suffice
|
||||
# to exercise the generator logic:
|
||||
#
|
||||
# - name: Setup - System
|
||||
# env:
|
||||
# DEBIAN_FRONTEND: noninteractive
|
||||
# run: |
|
||||
# sudo apt-get update
|
||||
# # Install dev tools
|
||||
# sudo apt-get install re2c lemon
|
||||
# sudo apt-get clean
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
export PATH=$ENV{GITHUB_WORKSPACE}:$PATH
|
||||
cmake -S . -G Ninja -B build -D ENABLE_ALL=ON -D CMAKE_BUILD_TYPE=Release -DSC_ENABLE_TESTING=ON
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
export PATH=$ENV{GITHUB_WORKSPACE}:$PATH
|
||||
cmake --build build --config Release
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
cd build && ctest -j1 . -C Release
|
||||
|
||||
linux_clang:
|
||||
name: Ubuntu Latest Clang
|
||||
runs-on: ubuntu-20.04
|
||||
strategy:
|
||||
fail-fast: true
|
||||
steps:
|
||||
- name: Setup - CMake
|
||||
uses: lukka/get-cmake@latest
|
||||
|
||||
- name: Setup - Ninja
|
||||
uses: seanmiddleditch/gha-setup-ninja@master
|
||||
|
||||
# TODO - we will want this when the new parser work comes in,
|
||||
# as we won't need perplex and the system tools should suffice
|
||||
# to exercise the generator logic:
|
||||
#
|
||||
# - name: Setup - System
|
||||
# env:
|
||||
# DEBIAN_FRONTEND: noninteractive
|
||||
# run: |
|
||||
# sudo apt-get update
|
||||
# # Install dev tools
|
||||
# sudo apt-get install re2c lemon
|
||||
# sudo apt-get clean
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
export PATH=$ENV{GITHUB_WORKSPACE}:$PATH
|
||||
CC=clang CXX=clang++ cmake -S . -G Ninja -B build -D ENABLE_ALL=ON -D CMAKE_BUILD_TYPE=Release -DSC_ENABLE_TESTING=ON
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
export PATH=$ENV{GITHUB_WORKSPACE}:$PATH
|
||||
CC=clang CXX=clang++ cmake --build build --config Release
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
cd build && ctest -j1 . -C Release
|
||||
|
||||
|
||||
osx:
|
||||
name: macOS Latest Clang
|
||||
runs-on: macos-latest
|
||||
strategy:
|
||||
fail-fast: true
|
||||
steps:
|
||||
- name: Setup - CMake
|
||||
uses: lukka/get-cmake@latest
|
||||
|
||||
- name: Setup - Ninja
|
||||
uses: seanmiddleditch/gha-setup-ninja@master
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
export PATH=$ENV{GITHUB_WORKSPACE}:$PATH
|
||||
export CC=clang
|
||||
export CXX=clang++
|
||||
cmake -S . -G Ninja -B build -D CMAKE_BUILD_TYPE=Release -DSC_ENABLE_TESTING=ON
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
export PATH=$ENV{GITHUB_WORKSPACE}:$PATH
|
||||
cd build && ninja -j1
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
cd build && ctest -j1 . -C Release
|
||||
|
||||
brlcad_linux:
|
||||
name: BRL-CAD Linux step-g Test
|
||||
runs-on: ubuntu-20.04
|
||||
strategy:
|
||||
fail-fast: true
|
||||
steps:
|
||||
- name: Setup - CMake
|
||||
uses: lukka/get-cmake@latest
|
||||
|
||||
- name: Setup - Ninja
|
||||
uses: seanmiddleditch/gha-setup-ninja@master
|
||||
|
||||
- name: Setup - System
|
||||
env:
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
run: |
|
||||
sudo apt-get update
|
||||
# Install dev tools
|
||||
sudo apt-get install re2c lemon
|
||||
sudo apt-get clean
|
||||
|
||||
- name: Checkout
|
||||
run: |
|
||||
git clone --depth 1 https://github.com/BRL-CAD/brlcad.git -b main
|
||||
cd brlcad/src/other/ext && rm -rf stepcode
|
||||
git clone --depth 1 https://github.com/stepcode/stepcode.git -b develop
|
||||
# Ordinarily BRL-CAD keeps track of what files are supposed to be
|
||||
# present in the repository. In this case we're not interested in
|
||||
# updating the list to the working stepcode filelist, so use an empty
|
||||
# list instead
|
||||
echo "set(stepcode_ignore_files)" > stepcode.dist
|
||||
cd ../../../../
|
||||
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
export PATH=$ENV{GITHUB_WORKSPACE}:$PATH
|
||||
cd brlcad
|
||||
cmake -S . -G Ninja -B build -DENABLE_ALL=ON -DCMAKE_BUILD_TYPE=Release -DEXT_BUILD_VERBOSE=ON
|
||||
cd ..
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
export PATH=$ENV{GITHUB_WORKSPACE}:$PATH
|
||||
cd brlcad
|
||||
cmake --build build --config Release --target step-g
|
||||
cd ..
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
export PATH=$ENV{GITHUB_WORKSPACE}:$PATH
|
||||
cd brlcad/build
|
||||
./bin/step-g ../db/nist/NIST_MBE_PMI_3.stp -o nist3.g
|
||||
cd ../..
|
||||
|
||||
|
||||
brlcad_windows:
|
||||
name: BRL-CAD Windows step-g Test
|
||||
runs-on: windows-latest
|
||||
strategy:
|
||||
fail-fast: true
|
||||
steps:
|
||||
- name: Setup - CMake
|
||||
uses: lukka/get-cmake@latest
|
||||
|
||||
- name: Setup - Ninja
|
||||
uses: seanmiddleditch/gha-setup-ninja@master
|
||||
|
||||
- name: Add github workspace to path
|
||||
# https://github.community/t/deprecated-add-path/136621
|
||||
run: echo "$ENV{GITHUB_WORKSPACE}" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
|
||||
|
||||
- name: Add msbuild to PATH
|
||||
uses: microsoft/setup-msbuild@v1.0.2
|
||||
|
||||
- name: Add cl.exe to PATH
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
|
||||
- name: Checkout
|
||||
run: |
|
||||
git clone --depth 1 https://github.com/BRL-CAD/brlcad.git -b main
|
||||
cd brlcad/src/other/ext
|
||||
cmake -E rm -r stepcode
|
||||
git clone --depth 1 https://github.com/stepcode/stepcode.git -b develop
|
||||
# Ordinarily BRL-CAD keeps track of what files are supposed to be
|
||||
# present in the repository. In this case we're not interested in
|
||||
# updating the list to the working stepcode filelist, so use an empty
|
||||
# list instead
|
||||
echo "set(stepcode_ignore_files)" > stepcode.dist
|
||||
cd ../../../../
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
cd brlcad && cmake -S . -B build -G Ninja -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_CXX_COMPILER="cl.exe" -DSC_ENABLE_TESTING=ON
|
||||
cd ..
|
||||
# We do the following in order to help ensure files are "flushed"
|
||||
# to disk before compilation is attempted
|
||||
# https://superuser.com/a/1553374/1286142
|
||||
powershell Write-VolumeCache C
|
||||
powershell Write-VolumeCache D
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cd brlcad/build
|
||||
ninja -j1 -v step-g
|
||||
cd ../..
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
cd brlcad/build
|
||||
./bin/step-g.exe ../db/nist/NIST_MBE_PMI_3.stp -o nist3.g
|
||||
cd ../..
|
||||
|
||||
-18
@@ -1,21 +1,3 @@
|
||||
# Common build directories used in the source tree
|
||||
/build
|
||||
/.build
|
||||
|
||||
# Temporary files
|
||||
*~
|
||||
\#*\#
|
||||
.\#*
|
||||
[._]*.s[a-v][a-z]
|
||||
[._]*.sw[a-p]
|
||||
[._]s[a-v][a-z]
|
||||
[._]sw[a-p]
|
||||
**/__pycache__/
|
||||
|
||||
# OS specific files
|
||||
.DS_Store
|
||||
.DS_Store?
|
||||
|
||||
# Tool specific patterns
|
||||
*.kdev4
|
||||
.kdev_include_paths
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
sudo: false
|
||||
language: cpp
|
||||
compiler:
|
||||
- clang
|
||||
script: mkdir build && cd build && cmake .. -DSC_ENABLE_TESTING=ON && make -j3 && ctest -j2 --output-on-failure
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
notifications:
|
||||
irc: "chat.freenode.net#stepcode"
|
||||
email: scl-dev@groups.google.com
|
||||
on_success: change
|
||||
on_failure: always
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
@@ -19,7 +19,6 @@ Paviot, Thomas (tpaviot)
|
||||
Pictor, Mark (mpictor)
|
||||
Reed, Nick (nickreed)
|
||||
Shah, Kesha (kesha, keshashah)
|
||||
Sparks, Devon (devonsparks)
|
||||
Thomas, Dawn (homovulgaris, madant)
|
||||
Wouters, Dave (davyw)
|
||||
Yapp, Clifford (starseeker)
|
||||
|
||||
+49
-118
@@ -40,131 +40,57 @@
|
||||
|
||||
project(SC)
|
||||
|
||||
# Minimum required version of CMake
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
if (POLICY CMP0077)
|
||||
cmake_policy(SET CMP0077 OLD)
|
||||
endif (POLICY CMP0077)
|
||||
|
||||
# SC version
|
||||
set(SC_VERSION_MAJOR 0)
|
||||
set(SC_VERSION_MINOR 9)
|
||||
set(SC_VERSION_PATCH 1)
|
||||
set(SC_VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR}.${SC_VERSION_PATCH})
|
||||
set(SC_VERSION_MINOR 8-dev)
|
||||
set(SC_VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR})
|
||||
|
||||
# Set language standards
|
||||
set(CMAKE_C_EXTENSIONS OFF)
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
# SC ABI version. SC_ABI_SOVERSION should be incremented
|
||||
# for each release introducing API incompatibilities
|
||||
set(SC_ABI_SOVERSION 2)
|
||||
set(SC_ABI_VERSION ${SC_ABI_SOVERSION}.0.0)
|
||||
|
||||
# Minimum required version of CMake
|
||||
cmake_minimum_required(VERSION 3.6.3)
|
||||
cmake_policy(SET CMP0003 NEW)
|
||||
cmake_policy(SET CMP0026 NEW)
|
||||
cmake_policy(SET CMP0057 NEW)
|
||||
|
||||
# CMake derives much of its functionality from modules, typically
|
||||
# stored in one directory - let CMake know where to find them.
|
||||
set(SC_CMAKE_DIR "${SC_SOURCE_DIR}/cmake")
|
||||
list(APPEND CMAKE_MODULE_PATH "${SC_CMAKE_DIR}")
|
||||
if(NOT SC_IS_SUBBUILD)
|
||||
set(CMAKE_MODULE_PATH "${SC_CMAKE_DIR};${CMAKE_MODULE_PATH}")
|
||||
else(NOT SC_IS_SUBBUILD)
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${SC_CMAKE_DIR}")
|
||||
endif(NOT SC_IS_SUBBUILD)
|
||||
|
||||
# OpenBSD has its own naming conventions. Set a platform variable based on
|
||||
# the OS name so we can test for it succinctly.
|
||||
if ("${CMAKE_SYSTEM}" MATCHES ".*OpenBSD.*")
|
||||
set(OPENBSD ON)
|
||||
endif ("${CMAKE_SYSTEM}" MATCHES ".*OpenBSD.*")
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# Set up various relative path variables and build output directories
|
||||
include(Path_Setup)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# The following logic is what allows binaries to run successfully in
|
||||
# the build directory AND install directory. Thanks to plplot for
|
||||
# identifying the necessity of setting CMAKE_INSTALL_NAME_DIR on OSX.
|
||||
# Documentation of these options is available at
|
||||
# http://www.cmake.org/Wiki/CMake_RPATH_handling
|
||||
|
||||
# use, i.e. don't skip the full RPATH for the build tree
|
||||
if(NOT DEFINED CMAKE_SKIP_BUILD_RPATH)
|
||||
set(CMAKE_SKIP_BUILD_RPATH FALSE)
|
||||
endif()
|
||||
|
||||
# when building, don't use the install RPATH already
|
||||
# (but later on when installing)
|
||||
if(NOT DEFINED CMAKE_BUILD_WITH_INSTALL_RPATH)
|
||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
||||
endif()
|
||||
|
||||
# the RPATH/INSTALL_NAME_DIR to be used when installing
|
||||
if (NOT APPLE)
|
||||
if(NOT DEFINED CMAKE_INSTALL_RPATH)
|
||||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib:\$ORIGIN/../lib")
|
||||
endif()
|
||||
endif(NOT APPLE)
|
||||
# On OSX, we need to set INSTALL_NAME_DIR instead of RPATH
|
||||
# http://www.cmake.org/cmake/help/cmake-2-8-docs.html#variable:CMAKE_INSTALL_NAME_DIR
|
||||
if(NOT DEFINED CMAKE_INSTALL_NAME_DIR)
|
||||
set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
endif()
|
||||
|
||||
# add the automatically determined parts of the RPATH which point to
|
||||
# directories outside the build tree to the install RPATH
|
||||
if(NOT DEFINED CMAKE_INSTALL_RPATH_USE_LINK_PATH)
|
||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
endif()
|
||||
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# Build options
|
||||
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
|
||||
option(BUILD_STATIC_LIBS "Build static libraries" OFF)
|
||||
|
||||
option(SC_PYTHON_GENERATOR "Compile exp2python" ON)
|
||||
option(SC_CPP_GENERATOR "Compile exp2cxx" ON)
|
||||
|
||||
option(SC_TRACE_FPRINTF "Enable extra comments in generated code so the code's source in exp2cxx may be located" OFF)
|
||||
|
||||
option(SC_ENABLE_COVERAGE "Enable code coverage test" OFF)
|
||||
if (SC_ENABLE_COVERAGE AND ${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
|
||||
set(CMAKE_C_FLAGS_DEBUG "-O0 -g -fprofile-arcs -ftest-coverage" CACHE STRING "Extra compile flags required by code coverage" FORCE)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -fprofile-arcs -ftest-coverage" CACHE STRING "Extra compile flags required by code coverage" FORCE)
|
||||
set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "-fprofile-arcs -ftest-coverage" CACHE STRING "Extra linker flags required by code coverage" FORCE)
|
||||
endif (SC_ENABLE_COVERAGE AND ${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
|
||||
|
||||
option(SC_BUILD_EXPRESS_ONLY "Only build express parser." OFF)
|
||||
mark_as_advanced(SC_BUILD_EXPRESS_ONLY)
|
||||
|
||||
option(SC_ENABLE_TESTING "Enable unittesting framework" OFF)
|
||||
if(SC_ENABLE_TESTING)
|
||||
if(NOT "${SC_BUILD_EXPRESS_ONLY}" AND NOT DEFINED SC_BUILD_SCHEMAS)
|
||||
set(SC_BUILD_SCHEMAS "ALL") #test all schemas, unless otherwise specified
|
||||
endif()
|
||||
include(CTest)
|
||||
endif(SC_ENABLE_TESTING)
|
||||
# testing and compilation options, build output dirs, install dirs, uninstall, package creation, etc
|
||||
include(${SC_CMAKE_DIR}/SC_Build_opts.cmake)
|
||||
|
||||
# SC_ADDEXEC and SC_ADDLIB macros, dllimport/export, etc
|
||||
include(SC_Targets)
|
||||
include(${SC_CMAKE_DIR}/SC_Targets.cmake)
|
||||
|
||||
# Macros related to paths
|
||||
include(SC_Paths)
|
||||
include(${SC_CMAKE_DIR}/SC_Paths.cmake)
|
||||
|
||||
# locale stuff
|
||||
include(SC_Locale)
|
||||
include(${SC_CMAKE_DIR}/SC_Locale.cmake)
|
||||
|
||||
# logic related to regenerating the lexer and parser source code
|
||||
include(SC_Regenerate)
|
||||
|
||||
# create config.h header
|
||||
include(SC_Config_Headers)
|
||||
include(${SC_CMAKE_DIR}/SC_Regenerate.cmake)
|
||||
|
||||
if(NOT DEFINED SC_SDAI_ADDITIONAL_EXES_SRCS)
|
||||
set(SC_SDAI_ADDITIONAL_EXES_SRCS "" CACHE STRING "Source files for additional executables to be linked with SDAI libs")
|
||||
endif(NOT DEFINED SC_SDAI_ADDITIONAL_EXES_SRCS)
|
||||
|
||||
if(NOT "${SC_BUILD_EXPRESS_ONLY}" AND NOT DEFINED SC_BUILD_SCHEMAS)
|
||||
if(NOT DEFINED SC_BUILD_SCHEMAS)
|
||||
list(APPEND CONFIG_END_MESSAGES
|
||||
"** Note: CMake variable SC_BUILD_SCHEMAS was not set - defaults to building ALL schemas")
|
||||
# this makes SC_BUILD_SCHEMAS show up in cmake-gui
|
||||
set(SC_BUILD_SCHEMAS "ALL" CACHE STRING "Semicolon-separated list of paths to EXPRESS schemas to be built")
|
||||
endif()
|
||||
"** CMake variable SC_BUILD_SCHEMAS was not set. Defaults to building ALL schemas, which will take a"
|
||||
" while; see http://stepcode.org/mw/index.php?title=STEPcode_CMake_variables#SC_BUILD_SCHEMAS")
|
||||
#this makes SC_BUILD_SCHEMAS show up in cmake-gui
|
||||
set(SC_BUILD_SCHEMAS "ALL" CACHE string "Semicolon-separated list of paths to EXPRESS schemas to be built")
|
||||
endif(NOT DEFINED SC_BUILD_SCHEMAS)
|
||||
|
||||
if(NOT SC_IS_SUBBUILD)
|
||||
list(APPEND CONFIG_END_MESSAGES
|
||||
@@ -173,14 +99,23 @@ if(NOT SC_IS_SUBBUILD)
|
||||
".. Generating step can take a while if you are building several schemas.")
|
||||
endif(NOT SC_IS_SUBBUILD)
|
||||
|
||||
# create config headers sc_cf.h and sc_version_string.h
|
||||
include(${SC_CMAKE_DIR}/SC_Config_Headers.cmake)
|
||||
|
||||
|
||||
################
|
||||
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
if(MSVC)
|
||||
# Disable warning for preferred usage of secure functions (example strcpy should be strcpy_s, ...)
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS)
|
||||
endif()
|
||||
if (${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
|
||||
else()
|
||||
add_definitions(-pedantic -W -Wall -Wundef -Wfloat-equal -Wshadow -Winline -Wno-long-long)
|
||||
if(HAVE_NULLPTR)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
endif(HAVE_NULLPTR)
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
@@ -188,6 +123,8 @@ include_directories(
|
||||
${SC_BINARY_DIR}/include
|
||||
)
|
||||
|
||||
add_subdirectory(src/auxlib)
|
||||
add_subdirectory(src/base)
|
||||
add_subdirectory(src/express)
|
||||
add_subdirectory(src/exppp)
|
||||
add_subdirectory(src/exp2cxx)
|
||||
@@ -204,19 +141,13 @@ if(SC_ENABLE_TESTING)
|
||||
endif(SC_ENABLE_TESTING)
|
||||
add_subdirectory(doc)
|
||||
|
||||
if(NOT SC_IS_SUBBUILD)
|
||||
#-----------------------------------------------------------------------------
|
||||
# SC Packaging
|
||||
# $make package
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "STEPcode")
|
||||
set(CPACK_SET_DESTDIR "ON")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR ${SC_VERSION_MAJOR})
|
||||
set(CPACK_PACKAGE_VERSION_MINOR ${SC_VERSION_MINOR})
|
||||
set(CPACK_PACKAGE_NAME SC)
|
||||
set(CPACK_PACKAGE_CONTACT "SC Developers <scl-dev@googlegroups.com>")
|
||||
include(CPack)
|
||||
endif(NOT SC_IS_SUBBUILD)
|
||||
|
||||
# 'make core' builds everything that isn't generated. for devs.
|
||||
add_custom_target(core)
|
||||
if($CACHE{SC_BUILD_SHARED_LIBS})
|
||||
add_dependencies(core stepdai stepeditor exp2cxx check-express)
|
||||
else()
|
||||
add_dependencies(core stepdai-static stepeditor-static exp2cxx check-express)
|
||||
endif()
|
||||
|
||||
# CONFIG_END_MESSAGES - list of messages to be printed after everything else is done.
|
||||
# THIS MUST BE LAST to ensure that they are visible to the user without scrolling.
|
||||
|
||||
+1
-4
@@ -11,12 +11,9 @@ We love contributions!
|
||||
* Encouraged but not enforced: each commit should stand alone, in the sense that the code should compile and run at that point.
|
||||
* One major topic per pull request. Commits that fix small things (typos, formatting) are perfectly acceptable in a PR fixing a bug or adding a feature.
|
||||
* Tests are good. Tests are required unless you're fixing something simple or that was obviously broken.
|
||||
* Do not change EXPRESS schema definition without reference to an upstream change.
|
||||
* Make your changes and push them to your GitHub repo
|
||||
* Once your branch is pushed, submit a pull request.
|
||||
- enable github option on each PR 'Allow edits from maintainers', refer to github help if necessary
|
||||
* We'll look at the PR and either merge (possibly after rebase) or add feedback.
|
||||
- If there isn't any activity within several days send a message to the mailing list - `scl-dev` AT `groups.google.com`.
|
||||
* We'll look at the PR and either merge or add feedback. If there isn't any activity within several days, send a message to the mailing list - `scl-dev` AT `groups.google.com`.
|
||||
|
||||
## Coding Standards
|
||||
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
STEPcode -- http://github.com/stepcode/stepcode -- http://stepcode.org
|
||||
************************************************************************
|
||||
STEPcode
|
||||
http://github.com/stepcode/stepcode
|
||||
************************************************************************
|
||||
|
||||
Release 0.8 (December, 2014)
|
||||
|
||||
New since v0.7:
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||

|
||||
Travis-CI | AppVeyor CI
|
||||
:-------------:|:---------------:
|
||||
Linux, OSX (LLVM) | Windows (MSVC)
|
||||
[](https://travis-ci.org/stepcode/stepcode) | [](https://ci.appveyor.com/project/mpictor/stepcode)
|
||||
|
||||
***********************************************************************
|
||||
STEPcode v0.8 -- github.com/stepcode/stepcode
|
||||
STEPcode v0.8 -- stepcode.org, github.com/stepcode/stepcode
|
||||
|
||||
* What is STEPcode? SC reads ISO10303-11 EXPRESS schemas and generates
|
||||
C++ source code that can read and write Part 21 files conforming
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
0.8
|
||||
+94
-115
@@ -48,132 +48,111 @@ find_program(LEMON_EXECUTABLE lemon DOC "path to the lemon executable")
|
||||
mark_as_advanced(LEMON_EXECUTABLE)
|
||||
|
||||
if (LEMON_EXECUTABLE)
|
||||
if(NOT LEMON_TEMPLATE)
|
||||
# look for the template, if we've not already been told where it is
|
||||
if (DATA_DIR AND EXISTS "${DATA_DIR}/lemon/lempar.c")
|
||||
find_file(LEMON_TEMPLATE lempar.c
|
||||
PATHS "${DATA_DIR}/lemon/lempar.c"
|
||||
NO_DEFAULT_PATH)
|
||||
endif ()
|
||||
|
||||
# If the above did not succeed, check standard locations
|
||||
get_filename_component(lemon_dir ${LEMON_EXECUTABLE} DIRECTORY)
|
||||
find_file(LEMON_TEMPLATE lempar.c
|
||||
PATHS "${lemon_dir}" "/usr/share/lemon"
|
||||
NO_DEFAULT_PATH)
|
||||
find_file(LEMON_TEMPLATE lempar.c
|
||||
PATHS "${lemon_dir}" "/usr/share/lemon"
|
||||
NO_DEFAULT_PATH)
|
||||
mark_as_advanced(LEMON_TEMPLATE)
|
||||
endif()
|
||||
|
||||
if(NOT LEMON_TEMPLATE)
|
||||
message(SEND_ERROR "failed to find lemon template (lempar.c)")
|
||||
endif()
|
||||
|
||||
# We need a template to be able to use lemon correctly
|
||||
if(NOT LEMON_TEMPLATE)
|
||||
message(FATAL_ERROR "Failed to find lemon template file (lempar.c) - need to set LEMON_TEMPLATE")
|
||||
endif()
|
||||
# Define the macro
|
||||
# LEMON_TARGET(<Name> <LemonInput> <LemonSource> <LemonHeader>
|
||||
# [<ArgString>])
|
||||
# which will create a custom rule to generate a parser. <LemonInput> is
|
||||
# the path to a lemon file. <LemonSource> is the desired name for the
|
||||
# generated source file. <LemonHeader> is the desired name for the
|
||||
# generated header which contains the token list. Anything in the optional
|
||||
# <ArgString> parameter is appended to the lemon command line.
|
||||
#
|
||||
# ====================================================================
|
||||
# Example:
|
||||
#
|
||||
# find_package(LEMON)
|
||||
# LEMON_TARGET(MyParser parser.y parser.c parser.h)
|
||||
# add_executable(Foo main.cpp ${LEMON_MyParser_OUTPUTS})
|
||||
# ====================================================================
|
||||
|
||||
# Define the function
|
||||
# LEMON_TARGET(<Name> <LemonInput> <LemonSource> <LemonHeader>
|
||||
# [<ArgString>])
|
||||
# which will create a custom rule to generate a parser. <LemonInput> is
|
||||
# the path to a lemon file. <LemonSource> is the desired name for the
|
||||
# generated source file. <LemonHeader> is the desired name for the
|
||||
# generated header which contains the token list. Anything in the optional
|
||||
# <ArgString> parameter is appended to the lemon command line.
|
||||
#
|
||||
# ====================================================================
|
||||
# Example:
|
||||
#
|
||||
# find_package(LEMON)
|
||||
# LEMON_TARGET(MyParser parser.y parser.c parser.h)
|
||||
# add_executable(Foo main.cpp ${LEMON_MyParser_OUTPUTS})
|
||||
# ====================================================================
|
||||
include(CMakeParseArguments)
|
||||
|
||||
include(CMakeParseArguments)
|
||||
if(NOT COMMAND LEMON_TARGET)
|
||||
macro(LEMON_TARGET Name LemonInput LemonOutput)
|
||||
set(LT_ARGS DEFINES_FILE COMPILE_FLAGS)
|
||||
CMAKE_PARSE_ARGUMENTS(LEMON_TARGET_ARG "" "${LT_ARGS}" "" ${ARGN})
|
||||
|
||||
if(NOT COMMAND LEMON_TARGET)
|
||||
function(LEMON_TARGET Name LemonInput LemonOutput)
|
||||
set(LT_ARGS DEFINES_FILE COMPILE_FLAGS)
|
||||
cmake_parse_arguments(LEMON_TARGET_ARG "" "${LT_ARGS}" "" ${ARGN})
|
||||
if(NOT "${LEMON_TARGET_ARG_COMPILE_FLAGS}" STREQUAL "")
|
||||
set(LEMON_EXECUTABLE_opts "${LEMON_TARGET_ARG_COMPILE_FLAGS}")
|
||||
separate_arguments(LEMON_EXECUTABLE_opts)
|
||||
else()
|
||||
set(LEMON_EXECUTABLE_opts "")
|
||||
endif()
|
||||
|
||||
if(NOT "${LEMON_TARGET_ARG_COMPILE_FLAGS}" STREQUAL "")
|
||||
set(LEMON_EXECUTABLE_opts "${LEMON_TARGET_ARG_COMPILE_FLAGS}")
|
||||
separate_arguments(LEMON_EXECUTABLE_opts)
|
||||
else()
|
||||
set(LEMON_EXECUTABLE_opts "")
|
||||
endif()
|
||||
# check for LemonOutput
|
||||
get_filename_component(_basename ${LemonOutput} NAME_WE)
|
||||
get_filename_component(_out_src_file ${LemonOutput} NAME)
|
||||
get_filename_component(_out_dir ${LemonOutput} PATH)
|
||||
if(NOT "${_out_dir}" STREQUAL "")
|
||||
message(WARNING "Full path specified for LemonOutput - should be filename only")
|
||||
endif()
|
||||
|
||||
# set report file
|
||||
set(_out_rpt_file "${_basename}.out")
|
||||
|
||||
# check for DEFINES_FILE
|
||||
if ("${LEMON_TARGET_ARG_DEFINES_FILE}" STREQUAL "")
|
||||
set(_out_hdr_file "${_basename}.h")
|
||||
else()
|
||||
get_filename_component(_out_dir ${LEMON_TARGET_ARG_DEFINES_FILE} PATH)
|
||||
get_filename_component(_out_hdr_file ${LEMON_TARGET_ARG_DEFINES_FILE} NAME)
|
||||
if(NOT "${_out_dir}" STREQUAL "")
|
||||
message(WARNING "Full path specified for DEFINES_FILE - should be filename only")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# input file
|
||||
get_filename_component(_in_y_path ${LemonInput} ABSOLUTE)
|
||||
get_filename_component(_in_y_file ${LemonInput} NAME)
|
||||
|
||||
# check for LemonOutput
|
||||
get_filename_component(_basename ${LemonOutput} NAME_WE)
|
||||
get_filename_component(_out_src_file ${LemonOutput} NAME)
|
||||
get_filename_component(_out_dir ${LemonOutput} PATH)
|
||||
if(NOT "${_out_dir}" STREQUAL "")
|
||||
message(WARNING "Full path specified for LemonOutput - should be filename only")
|
||||
endif()
|
||||
# TODO: is this really necessary?
|
||||
add_custom_command(
|
||||
OUTPUT ${_in_y_file}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${_in_y_path} ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
# execute lemon
|
||||
add_custom_command(
|
||||
OUTPUT ${_out_src_file}
|
||||
COMMAND ${LEMON_EXECUTABLE} -T${LEMON_TEMPLATE} ${LEMON_EXECUTABLE_opts} ${_in_y_file}
|
||||
DEPENDS ${_in_y_file}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "[LEMON][${Name}] Building parser with ${LEMON_EXECUTABLE}"
|
||||
)
|
||||
|
||||
# rename the header
|
||||
add_custom_command(
|
||||
OUTPUT ${_out_hdr_file}
|
||||
COMMAND ${CMAKE_COMMAND} ARGS -E rename ${_basename}.h ${_out_hdr_file}
|
||||
DEPENDS ${_out_src_file}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
# set the return values
|
||||
# TODO: for generated sources even headers should be target dependencies
|
||||
set(LEMON_${Name}_DEFINED TRUE)
|
||||
set(LEMON_${Name}_OUTPUT_HEADER "${CMAKE_CURRENT_BINARY_DIR}/${_out_hdr_file}")
|
||||
set(LEMON_${Name}_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
set(LEMON_${Name}_OUTPUTS "${_out_src_file}")
|
||||
|
||||
# set report file
|
||||
set(_out_rpt_file "${_basename}.out")
|
||||
# make sure we clean up generated output and copied input
|
||||
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${LEMON_${Name}_OUTPUTS}")
|
||||
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_CURRENT_BINARY_DIR}/${_in_y_file}")
|
||||
|
||||
# check for DEFINES_FILE
|
||||
if ("${LEMON_TARGET_ARG_DEFINES_FILE}" STREQUAL "")
|
||||
set(_out_hdr_file "${_basename}.h")
|
||||
else()
|
||||
get_filename_component(_out_dir ${LEMON_TARGET_ARG_DEFINES_FILE} PATH)
|
||||
get_filename_component(_out_hdr_file ${LEMON_TARGET_ARG_DEFINES_FILE} NAME)
|
||||
if(NOT "${_out_dir}" STREQUAL "")
|
||||
message(WARNING "Full path specified for DEFINES_FILE - should be filename only")
|
||||
endif()
|
||||
endif()
|
||||
endmacro(LEMON_TARGET)
|
||||
endif(NOT COMMAND LEMON_TARGET)
|
||||
|
||||
# input file
|
||||
get_filename_component(_in_y_path ${LemonInput} ABSOLUTE)
|
||||
get_filename_component(_in_y_file ${LemonInput} NAME)
|
||||
|
||||
# Stage the source file in the binary directory for lemon. We need to make
|
||||
# sure it's fully copied, so use a sentinel guard
|
||||
add_custom_command(
|
||||
OUTPUT ${_in_y_file}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${_in_y_path} ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_in_y_file}.sentinel
|
||||
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/${_in_y_file}.sentinel
|
||||
DEPENDS ${_in_y_file}
|
||||
)
|
||||
add_custom_target(${Name}_input_cpy DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_in_y_file}.sentinel)
|
||||
|
||||
# execute lemon
|
||||
add_custom_command(
|
||||
OUTPUT ${_out_src_file}
|
||||
COMMAND ${LEMON_EXECUTABLE} -T${LEMON_TEMPLATE} ${LEMON_EXECUTABLE_opts} ${_in_y_file}
|
||||
DEPENDS ${Name}_input_cpy
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "[LEMON][${Name}] Building parser with ${LEMON_EXECUTABLE}"
|
||||
)
|
||||
|
||||
# rename the header
|
||||
add_custom_command(
|
||||
OUTPUT ${_out_hdr_file}
|
||||
COMMAND ${CMAKE_COMMAND} ARGS -E rename ${_basename}.h ${_out_hdr_file}
|
||||
DEPENDS ${_out_src_file}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
# set the return values
|
||||
# TODO: for generated sources even headers should be target dependencies
|
||||
set(LEMON_${Name}_DEFINED TRUE PARENT_SCOPE)
|
||||
set(LEMON_${Name}_OUTPUT_HEADER "${CMAKE_CURRENT_BINARY_DIR}/${_out_hdr_file}" PARENT_SCOPE)
|
||||
set(LEMON_${Name}_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}" PARENT_SCOPE)
|
||||
set(LEMON_${Name}_OUTPUTS "${_out_src_file}" PARENT_SCOPE)
|
||||
|
||||
# TODO - remove once perplex goes away...
|
||||
add_custom_target(${Name} DEPENDS ${_out_hdr_file})
|
||||
|
||||
# make sure we clean up generated output and copied input
|
||||
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${_out_src_file}")
|
||||
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_CURRENT_BINARY_DIR}/${_in_y_file}")
|
||||
|
||||
endfunction(LEMON_TARGET)
|
||||
endif(NOT COMMAND LEMON_TARGET)
|
||||
|
||||
endif(LEMON_EXECUTABLE)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(LEMON REQUIRED_VARS LEMON_EXECUTABLE LEMON_TEMPLATE)
|
||||
|
||||
+2
-10
@@ -227,14 +227,6 @@ if(NOT COMMAND PERPLEX_TARGET)
|
||||
set(PERPLEX_${Name}_SRC ${${PVAR_PREFIX}_OUT_SRC_FILE})
|
||||
set(PERPLEX_${Name}_HDR ${${PVAR_PREFIX}_OUT_HDR_FILE})
|
||||
set(PERPLEX_${Name}_INCLUDE_DIR ${${PVAR_PREFIX}_WORKING_DIR})
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${${PVAR_PREFIX}_WORKING_DIR}/${Name}.sentinel
|
||||
COMMAND ${CMAKE_COMMAND} -E touch ${${PVAR_PREFIX}_WORKING_DIR}/${Name}.sentinel
|
||||
DEPENDS ${${PVAR_PREFIX}_OUT_SRC_FILE} ${${PVAR_PREFIX}_OUT_HDR_FILE}
|
||||
)
|
||||
add_custom_target(${Name} DEPENDS ${${PVAR_PREFIX}_WORKING_DIR}/${Name}.sentinel)
|
||||
|
||||
endmacro(PERPLEX_TARGET)
|
||||
endif(NOT COMMAND PERPLEX_TARGET)
|
||||
|
||||
@@ -248,12 +240,12 @@ if(NOT COMMAND ADD_PERPLEX_LEMON_DEPENDENCY)
|
||||
message(SEND_ERROR "PERPLEX target `${PERPLEXTarget}' does not exists.")
|
||||
endif()
|
||||
|
||||
if(NOT TARGET ${LemonTarget})
|
||||
if(NOT LEMON_${LemonTarget}_HDR)
|
||||
message(SEND_ERROR "Lemon target `${LemonTarget}' does not exists.")
|
||||
endif()
|
||||
|
||||
set_source_files_properties(${PERPLEX_${PERPLEXTarget}_SRC}
|
||||
PROPERTIES OBJECT_DEPENDS ${LEMON_${LemonTarget}_OUTPUT_HEADER})
|
||||
PROPERTIES OBJECT_DEPENDS ${LEMON_${LemonTarget}_HDR})
|
||||
endmacro(ADD_PERPLEX_LEMON_DEPENDENCY)
|
||||
endif(NOT COMMAND ADD_PERPLEX_LEMON_DEPENDENCY)
|
||||
|
||||
|
||||
+138
-138
@@ -8,161 +8,161 @@ mark_as_advanced(RE2C_EXECUTABLE)
|
||||
|
||||
if(RE2C_EXECUTABLE)
|
||||
|
||||
execute_process(COMMAND ${RE2C_EXECUTABLE} -v
|
||||
OUTPUT_VARIABLE RE2C_version_output
|
||||
ERROR_VARIABLE RE2C_version_error
|
||||
RESULT_VARIABLE RE2C_version_result
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
if(NOT ${RE2C_version_result} EQUAL 0)
|
||||
execute_process(COMMAND ${RE2C_EXECUTABLE} -v
|
||||
OUTPUT_VARIABLE RE2C_version_output
|
||||
ERROR_VARIABLE RE2C_version_error
|
||||
RESULT_VARIABLE RE2C_version_result
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
if(NOT ${RE2C_version_result} EQUAL 0)
|
||||
message(SEND_ERROR
|
||||
"Command \"${RE2C_EXECUTABLE} -v\" failed with output:\n${RE2C_version_output}\n${RE2C_version_error}")
|
||||
else()
|
||||
"Command \"${RE2C_EXECUTABLE} -v\" failed with output:\n${RE2C_version_output}\n${RE2C_version_error}")
|
||||
else()
|
||||
string(REGEX REPLACE "^re2c ([0-9]+[^ ]*)( .*)?$" "\\1" RE2C_VERSION "${RE2C_version_output}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Provide a macro to generate custom build rules:
|
||||
# Provide a macro to generate custom build rules:
|
||||
|
||||
# RE2C_TARGET(Name RE2CInput RE2COutput [COMPILE_FLAGS <string>])
|
||||
# which creates a custom command to generate the <RE2COutput> file from
|
||||
# the <RE2CInput> file. If COMPILE_FLAGS option is specified, the next
|
||||
# parameter is added to the re2c command line. Name is an alias used to
|
||||
# get details of this custom command.
|
||||
# RE2C_TARGET(Name RE2CInput RE2COutput [COMPILE_FLAGS <string>])
|
||||
# which creates a custom command to generate the <RE2COutput> file from
|
||||
# the <RE2CInput> file. If COMPILE_FLAGS option is specified, the next
|
||||
# parameter is added to the re2c command line. Name is an alias used to
|
||||
# get details of this custom command.
|
||||
|
||||
# This module also defines a macro:
|
||||
# ADD_RE2C_LEMON_DEPENDENCY(RE2CTarget LemonTarget)
|
||||
# which adds the required dependency between a scanner and a parser
|
||||
# where <RE2CTarget> and <LemonTarget> are the first parameters of
|
||||
# respectively RE2C_TARGET and LEMON_TARGET macros.
|
||||
#
|
||||
# ====================================================================
|
||||
# Example:
|
||||
#
|
||||
# find_package(LEMON)
|
||||
# find_package(RE2C)
|
||||
#
|
||||
# LEMON_TARGET(MyParser parser.y "${CMAKE_CURRENT_BINARY_DIR}/parser.cpp")
|
||||
# RE2C_TARGET(MyScanner scanner.re "${CMAKE_CURRENT_BINARY_DIR}/scanner.cpp")
|
||||
# ADD_RE2C_LEMON_DEPENDENCY(MyScanner MyParser)
|
||||
#
|
||||
# include_directories("${CMAKE_CURRENT_BINARY_DIR}")
|
||||
# add_executable(Foo
|
||||
# Foo.cc
|
||||
# ${LEMON_MyParser_OUTPUTS}
|
||||
# ${RE2C_MyScanner_OUTPUTS}
|
||||
# )
|
||||
# ====================================================================
|
||||
#
|
||||
#=============================================================================
|
||||
# Copyright (c) 2010-2016 United States Government as represented by
|
||||
# the U.S. Army Research Laboratory.
|
||||
# Copyright 2009 Kitware, Inc.
|
||||
# Copyright 2006 Tristan Carel
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# * 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.
|
||||
#
|
||||
# * The names of the authors may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "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 COPYRIGHT
|
||||
# HOLDER OR CONTRIBUTORS 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.
|
||||
#=============================================================================
|
||||
# This module also defines a macro:
|
||||
# ADD_RE2C_LEMON_DEPENDENCY(RE2CTarget LemonTarget)
|
||||
# which adds the required dependency between a scanner and a parser
|
||||
# where <RE2CTarget> and <LemonTarget> are the first parameters of
|
||||
# respectively RE2C_TARGET and LEMON_TARGET macros.
|
||||
#
|
||||
# ====================================================================
|
||||
# Example:
|
||||
#
|
||||
# find_package(LEMON)
|
||||
# find_package(RE2C)
|
||||
#
|
||||
# LEMON_TARGET(MyParser parser.y "${CMAKE_CURRENT_BINARY_DIR}/parser.cpp")
|
||||
# RE2C_TARGET(MyScanner scanner.re "${CMAKE_CURRENT_BINARY_DIR}/scanner.cpp")
|
||||
# ADD_RE2C_LEMON_DEPENDENCY(MyScanner MyParser)
|
||||
#
|
||||
# include_directories("${CMAKE_CURRENT_BINARY_DIR}")
|
||||
# add_executable(Foo
|
||||
# Foo.cc
|
||||
# ${LEMON_MyParser_OUTPUTS}
|
||||
# ${RE2C_MyScanner_OUTPUTS}
|
||||
# )
|
||||
# ====================================================================
|
||||
#
|
||||
#=============================================================================
|
||||
# Copyright (c) 2010-2016 United States Government as represented by
|
||||
# the U.S. Army Research Laboratory.
|
||||
# Copyright 2009 Kitware, Inc.
|
||||
# Copyright 2006 Tristan Carel
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# * 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.
|
||||
#
|
||||
# * The names of the authors may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "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 COPYRIGHT
|
||||
# HOLDER OR CONTRIBUTORS 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.
|
||||
#=============================================================================
|
||||
|
||||
#============================================================
|
||||
# RE2C_TARGET (public macro)
|
||||
#============================================================
|
||||
#
|
||||
if(NOT COMMAND RE2C_TARGET)
|
||||
function(RE2C_TARGET Name RE2CInput RE2COutput)
|
||||
set(_re2c_args COMPILE_FLAGS DEFINES_FILE)
|
||||
cmake_parse_arguments(RE2C_TARGET_ARG "" "${_re2c_args}" "" ${ARGN})
|
||||
#============================================================
|
||||
# RE2C_TARGET (public macro)
|
||||
#============================================================
|
||||
#
|
||||
if(NOT COMMAND RE2C_TARGET)
|
||||
macro(RE2C_TARGET Name RE2CInput RE2COutput)
|
||||
set(_re2c_args COMPILE_FLAGS DEFINES_FILE)
|
||||
cmake_parse_arguments(RE2C_TARGET_ARG "" "${_re2c_args}" "" ${ARGN})
|
||||
|
||||
if(NOT "${RE2C_TARGET_ARG_UNPARSED_ARGUMENTS}" STREQUAL "")
|
||||
message(SEND_ERROR "RE2C_TARGET(<Name> <RE2CInput> <RE2COutput>
|
||||
[COMPILE_FLAGS <string>]
|
||||
[DEFINES_FILE <string>])")
|
||||
else()
|
||||
if(NOT "${RE2C_TARGET_ARG_COMPILE_FLAGS}" STREQUAL "")
|
||||
set(RE2C_EXECUTABLE_opts "${RE2C_TARGET_ARG_COMPILE_FLAGS}")
|
||||
separate_arguments(RE2C_EXECUTABLE_opts)
|
||||
else()
|
||||
set(RE2C_EXECUTABLE_opts "")
|
||||
endif()
|
||||
|
||||
if(NOT "${RE2C_TARGET_ARG_UNPARSED_ARGUMENTS}" STREQUAL "")
|
||||
message(SEND_ERROR "RE2C_TARGET(<Name> <RE2CInput> <RE2COutput>
|
||||
[COMPILE_FLAGS <string>]
|
||||
[DEFINES_FILE <string>])")
|
||||
else()
|
||||
if(NOT "${RE2C_TARGET_ARG_COMPILE_FLAGS}" STREQUAL "")
|
||||
set(RE2C_EXECUTABLE_opts "${RE2C_TARGET_ARG_COMPILE_FLAGS}")
|
||||
separate_arguments(RE2C_EXECUTABLE_opts)
|
||||
else()
|
||||
set(RE2C_EXECUTABLE_opts "")
|
||||
endif()
|
||||
if(NOT "${RE2C_TARGET_ARG_DEFINES_FILE}" STREQUAL "")
|
||||
list(APPEND RE2C_EXECUTABLE_opts -t ${RE2C_TARGET_ARG_DEFINES_FILE})
|
||||
endif()
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${RE2COutput}
|
||||
COMMAND ${RE2C_EXECUTABLE}
|
||||
ARGS ${RE2C_EXECUTABLE_opts} -o ${RE2COutput} ${CMAKE_CURRENT_SOURCE_DIR}/${RE2CInput}
|
||||
DEPENDS ${RE2CInput}
|
||||
COMMENT "[RE2C][${Name}] Building scanner with ${RE2C_EXECUTABLE}"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
if(NOT "${RE2C_TARGET_ARG_DEFINES_FILE}" STREQUAL "")
|
||||
list(APPEND RE2C_EXECUTABLE_opts -t ${RE2C_TARGET_ARG_DEFINES_FILE})
|
||||
endif()
|
||||
# TODO: check, for generated sources headers should be included in outputs
|
||||
set(RE2C_${Name}_DEFINED TRUE)
|
||||
set(RE2C_${Name}_OUTPUTS ${RE2COutput})
|
||||
if("${RE2C_TARGET_ARG_DEFINES_FILE}" STREQUAL "")
|
||||
set(RE2C_${Name}_OUTPUT_HEADER "")
|
||||
else()
|
||||
set(RE2C_${Name}_OUTPUT_HEADER "${RE2C_TARGET_ARG_DEFINES_FILE}")
|
||||
endif()
|
||||
set(RE2C_${Name}_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
endif()
|
||||
|
||||
endmacro(RE2C_TARGET)
|
||||
endif(NOT COMMAND RE2C_TARGET)
|
||||
#============================================================
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${RE2COutput}
|
||||
COMMAND ${RE2C_EXECUTABLE}
|
||||
ARGS ${RE2C_EXECUTABLE_opts} -o ${RE2COutput} ${CMAKE_CURRENT_SOURCE_DIR}/${RE2CInput}
|
||||
DEPENDS ${RE2CInput}
|
||||
COMMENT "[RE2C][${Name}] Building scanner with ${RE2C_EXECUTABLE}"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
#============================================================
|
||||
# ADD_RE2C_LEMON_DEPENDENCY (public macro)
|
||||
#============================================================
|
||||
#
|
||||
if(NOT COMMAND ADD_RE2C_LEMON_DEPENDENCY)
|
||||
macro(ADD_RE2C_LEMON_DEPENDENCY RE2CTarget LemonTarget)
|
||||
|
||||
# TODO: check, for generated sources headers should be included in outputs
|
||||
set(RE2C_${Name}_DEFINED TRUE PARENT_SCOPE)
|
||||
set(RE2C_${Name}_OUTPUTS ${RE2COutput} PARENT_SCOPE)
|
||||
if("${RE2C_TARGET_ARG_DEFINES_FILE}" STREQUAL "")
|
||||
set(RE2C_${Name}_OUTPUT_HEADER "" PARENT_SCOPE)
|
||||
else()
|
||||
set(RE2C_${Name}_OUTPUT_HEADER "${RE2C_TARGET_ARG_DEFINES_FILE}" PARENT_SCOPE)
|
||||
endif()
|
||||
set(RE2C_${Name}_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}" PARENT_SCOPE)
|
||||
endif()
|
||||
if(NOT RE2C_${RE2CTarget}_OUTPUTS)
|
||||
message(SEND_ERROR "RE2C target `${RE2CTarget}' does not exists.")
|
||||
endif()
|
||||
|
||||
endfunction(RE2C_TARGET)
|
||||
endif(NOT COMMAND RE2C_TARGET)
|
||||
#============================================================
|
||||
if(NOT LEMON_${LemonTarget}_OUTPUT_HEADER)
|
||||
message(SEND_ERROR "Lemon target `${LemonTarget}' does not exists.")
|
||||
endif()
|
||||
|
||||
#============================================================
|
||||
# ADD_RE2C_LEMON_DEPENDENCY (public macro)
|
||||
#============================================================
|
||||
#
|
||||
if(NOT COMMAND ADD_RE2C_LEMON_DEPENDENCY)
|
||||
function(ADD_RE2C_LEMON_DEPENDENCY RE2CTarget LemonTarget)
|
||||
|
||||
if(NOT RE2C_${RE2CTarget}_OUTPUTS)
|
||||
message(SEND_ERROR "RE2C target `${RE2CTarget}' does not exists.")
|
||||
endif()
|
||||
|
||||
if(NOT LEMON_${LemonTarget}_OUTPUT_HEADER)
|
||||
message(SEND_ERROR "Lemon target `${LemonTarget}' does not exists.")
|
||||
endif()
|
||||
|
||||
set_source_files_properties(${RE2C_${RE2CTarget}_OUTPUTS}
|
||||
PROPERTIES OBJECT_DEPENDS ${LEMON_${LemonTarget}_OUTPUT_HEADER})
|
||||
endfunction(ADD_RE2C_LEMON_DEPENDENCY)
|
||||
endif(NOT COMMAND ADD_RE2C_LEMON_DEPENDENCY)
|
||||
#============================================================
|
||||
set_source_files_properties(${RE2C_${RE2CTarget}_OUTPUTS}
|
||||
PROPERTIES OBJECT_DEPENDS ${LEMON_${LemonTarget}_OUTPUT_HEADER})
|
||||
endmacro(ADD_RE2C_LEMON_DEPENDENCY)
|
||||
endif(NOT COMMAND ADD_RE2C_LEMON_DEPENDENCY)
|
||||
#============================================================
|
||||
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(RE2C REQUIRED_VARS RE2C_EXECUTABLE
|
||||
VERSION_VAR RE2C_VERSION)
|
||||
VERSION_VAR RE2C_VERSION)
|
||||
|
||||
# RE2C_Util.cmake ends here
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
# Utility routines for managing generated files with CMake
|
||||
|
||||
macro(MD5 filename md5sum)
|
||||
file(READ "${filename}" RAW_MD5_FILE)
|
||||
string(REGEX REPLACE "\r" "" STRIPPED_MD5_FILE "${RAW_MD5_FILE}")
|
||||
string(MD5 ${md5sum} "${STRIPPED_MD5_FILE}")
|
||||
endmacro(MD5)
|
||||
|
||||
macro(FILEVAR filename var)
|
||||
string(REGEX REPLACE "[^a-zA-Z0-9]" "_" ${var} ${filename})
|
||||
endmacro(FILEVAR)
|
||||
|
||||
macro(VERIFY_FILES filelist warn resultvar)
|
||||
set(${resultvar} 1)
|
||||
foreach(fileitem ${filelist})
|
||||
# Deal with absolute and relative paths a bit differently
|
||||
get_filename_component(ITEM_ABS_PATH "${fileitem}" ABSOLUTE)
|
||||
if("${fileitem}" STREQUAL "${ITEM_ABS_PATH}")
|
||||
set(filefullname "${fileitem}")
|
||||
else("${fileitem}" STREQUAL "${ITEM_ABS_PATH}")
|
||||
set(filefullname "${CURRENT_SOURCE_DIR}/${fileitem}")
|
||||
endif("${fileitem}" STREQUAL "${ITEM_ABS_PATH}")
|
||||
get_filename_component(filename "${fileitem}" NAME)
|
||||
# Got filename components sorted - proceed
|
||||
if(NOT EXISTS ${filefullname})
|
||||
message(FATAL_ERROR "Attempted to verify non-existant file ${filefullname}")
|
||||
endif(NOT EXISTS ${filefullname})
|
||||
FILEVAR(${filename} filevar)
|
||||
if(NOT baseline_${filevar}_md5)
|
||||
message(FATAL_ERROR "No baseline MD5 available for ${filename} - baseline_${filevar}_md5 is not defined")
|
||||
endif(NOT baseline_${filevar}_md5)
|
||||
MD5(${filefullname} ${filevar}_md5)
|
||||
if(NOT "${${filevar}_md5}" STREQUAL "${baseline_${filevar}_md5}")
|
||||
if("${warn}" STREQUAL "1")
|
||||
message("\n${filename} differs from baseline: baseline md5 hash is ${baseline_${filevar}_md5} and current hash is ${${filevar}_md5}\n")
|
||||
endif("${warn}" STREQUAL "1")
|
||||
set(${resultvar} 0)
|
||||
endif(NOT "${${filevar}_md5}" STREQUAL "${baseline_${filevar}_md5}")
|
||||
endforeach(fileitem ${filelist})
|
||||
endmacro(VERIFY_FILES filelist resultvar)
|
||||
|
||||
macro(WRITE_MD5_SUMS filelist outfile)
|
||||
foreach(fileitem ${filelist})
|
||||
# Deal with absolute and relative paths a bit differently
|
||||
get_filename_component(ITEM_ABS_PATH "${fileitem}" ABSOLUTE)
|
||||
if("${fileitem}" STREQUAL "${ITEM_ABS_PATH}")
|
||||
set(filefullname "${fileitem}")
|
||||
else("${fileitem}" STREQUAL "${ITEM_ABS_PATH}")
|
||||
set(filefullname "${CURRENT_SOURCE_DIR}/${fileitem}")
|
||||
endif("${fileitem}" STREQUAL "${ITEM_ABS_PATH}")
|
||||
get_filename_component(filename "${fileitem}" NAME)
|
||||
# Got filename components sorted - proceed
|
||||
if(NOT EXISTS ${filefullname})
|
||||
message(FATAL_ERROR "Attempted to get MD5 sum of non-existant file ${filefullname}")
|
||||
endif(NOT EXISTS ${filefullname})
|
||||
FILEVAR(${filename} filevar)
|
||||
MD5(${filefullname} ${filevar}_md5)
|
||||
file(APPEND ${outfile} "set(baseline_${filevar}_md5 ${${filevar}_md5})\n")
|
||||
endforeach(fileitem ${filelist})
|
||||
endmacro(WRITE_MD5_SUMS)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
@@ -1,164 +0,0 @@
|
||||
# Copyright (c) 2010-2020 United States Government as represented by
|
||||
# the U.S. Army Research Laboratory.
|
||||
#
|
||||
# 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. The name of the author may not 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.
|
||||
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# Define relative install locations. Don't set these if they have already
|
||||
# been set by some other means (like a higher level CMakeLists.txt file
|
||||
# including this one).
|
||||
|
||||
# The location in which to install BRL-CAD executables.
|
||||
if(NOT BIN_DIR)
|
||||
set(BIN_DIR bin)
|
||||
endif(NOT BIN_DIR)
|
||||
|
||||
# Define a relative path that will "reset" a path back to
|
||||
# the point before BIN_DIR was appended. This is primarily
|
||||
# useful when working with generator expressions
|
||||
unset(RBIN_DIR CACHE)
|
||||
set(LBIN_DIR "${BIN_DIR}")
|
||||
while (NOT "${LBIN_DIR}" STREQUAL "")
|
||||
get_filename_component(LBDIR "${LBIN_DIR}" DIRECTORY)
|
||||
set(LBIN_DIR "${LBDIR}")
|
||||
if ("${RBIN_DIR}" STREQUAL "")
|
||||
set(RBIN_DIR "..")
|
||||
else ("${RBIN_DIR}" STREQUAL "")
|
||||
set(RBIN_DIR "../${RBIN_DIR}")
|
||||
endif ("${RBIN_DIR}" STREQUAL "")
|
||||
endwhile (NOT "${LBIN_DIR}" STREQUAL "")
|
||||
|
||||
# The location in which to install BRL-CAD libraries.
|
||||
if(NOT LIB_DIR)
|
||||
set(LIB_DIR lib)
|
||||
endif(NOT LIB_DIR)
|
||||
if(NOT LIBEXEC_DIR)
|
||||
set(LIBEXEC_DIR libexec)
|
||||
endif(NOT LIBEXEC_DIR)
|
||||
|
||||
# The location in which to install BRL-CAD header files.
|
||||
if(NOT INCLUDE_DIR)
|
||||
set(INCLUDE_DIR include)
|
||||
endif(NOT INCLUDE_DIR)
|
||||
|
||||
# The location in which to install BRL-CAD data files
|
||||
if(NOT DATA_DIR)
|
||||
set(DATA_DIR share)
|
||||
endif(NOT DATA_DIR)
|
||||
|
||||
# The location in which to install BRL-CAD documentation files
|
||||
if(NOT DOC_DIR)
|
||||
set(DOC_DIR ${DATA_DIR}/doc)
|
||||
endif(NOT DOC_DIR)
|
||||
|
||||
# The location in which to install BRL-CAD Manual pages
|
||||
if(NOT MAN_DIR)
|
||||
set(MAN_DIR ${DATA_DIR}/man)
|
||||
endif(NOT MAN_DIR)
|
||||
|
||||
# Make sure no absolute paths have been supplied to these variables
|
||||
set(INSTALL_DIRS BIN INCLUDE LIB LIBEXEC DATA MAN DOC)
|
||||
foreach(instdir ${INSTALL_DIRS})
|
||||
get_filename_component(instdir_full ${${instdir}_DIR} ABSOLUTE)
|
||||
if("${${instdir}_DIR}" STREQUAL "${instdir_full}")
|
||||
message(FATAL_ERROR "Error - absolute path supplied for ${instdir}_DIR. This path must be relative - e.g. \"bin\" instead of \"/usr/bin\"")
|
||||
set(HAVE_INSTALL_DIR_FULL_PATH 1)
|
||||
endif("${${instdir}_DIR}" STREQUAL "${instdir_full}")
|
||||
endforeach(instdir ${INSTALL_DIRS})
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# Output directories - this is where built library and executable
|
||||
# files will be placed after building but prior to install. The
|
||||
# necessary variables change between single and multi configuration
|
||||
# build systems, so it is necessary to handle both cases on a
|
||||
# conditional basis.
|
||||
|
||||
if(NOT CMAKE_CONFIGURATION_TYPES)
|
||||
# If we're not doing multi-configuration, just set the three main
|
||||
# variables to the correct values.
|
||||
if(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${${PROJECT_NAME}_BINARY_DIR}/${LIB_DIR} CACHE INTERNAL "Single output directory for building all libraries.")
|
||||
endif(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
||||
if(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${${PROJECT_NAME}_BINARY_DIR}/${LIB_DIR} CACHE INTERNAL "Single output directory for building all archives.")
|
||||
endif(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
|
||||
if(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${${PROJECT_NAME}_BINARY_DIR}/${BIN_DIR} CACHE INTERNAL "Single output directory for building all executables.")
|
||||
endif(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY)
|
||||
else(NOT CMAKE_CONFIGURATION_TYPES)
|
||||
# Multi-configuration is more difficult. Not only do we need to
|
||||
# properly set the output directories, but we also need to
|
||||
# identify the "toplevel" directory for each configuration so
|
||||
# we can place files, documentation, etc. in the correct
|
||||
# relative positions. Because files may be placed by CMake
|
||||
# without a build target to put them in their proper relative build
|
||||
# directory position using these paths, we must fully qualify them
|
||||
# without using CMAKE_CFG_INTDIR.
|
||||
#
|
||||
# We define directories that may not be quite "standard"
|
||||
# for a particular build tool - for example, native VS2010 projects use
|
||||
# another directory to denote CPU type being compiled for - but CMake only
|
||||
# supports multi-configuration setups having multiple configurations,
|
||||
# not multiple compilers.
|
||||
#
|
||||
# One additional wrinkle we must watch for here is the case where
|
||||
# a multi-configuration setup uses "." for its internal directory -
|
||||
# if that's the case, we need to just set the various config output
|
||||
# directories to the same value.
|
||||
set(CFG_ROOT ${${PROJECT_NAME}_BINARY_DIR})
|
||||
foreach(CFG_TYPE ${CMAKE_CONFIGURATION_TYPES})
|
||||
if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
|
||||
set(CFG_ROOT ${${PROJECT_NAME}_BINARY_DIR}/${CFG_TYPE})
|
||||
endif(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
|
||||
string(TOUPPER "${CFG_TYPE}" CFG_TYPE_UPPER)
|
||||
if(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER})
|
||||
set("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${CFG_ROOT}/${LIB_DIR} CACHE INTERNAL "Single output directory for building ${CFG_TYPE} libraries.")
|
||||
endif(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER})
|
||||
if(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER})
|
||||
set("CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${CFG_ROOT}/${LIB_DIR} CACHE INTERNAL "Single output directory for building ${CFG_TYPE} archives.")
|
||||
endif(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER})
|
||||
if(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER})
|
||||
set("CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${CFG_ROOT}/${BIN_DIR} CACHE INTERNAL "Single output directory for building ${CFG_TYPE} executables.")
|
||||
endif(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER})
|
||||
if(NOT DEFINED CMAKE_BINARY_DIR_${CFG_TYPE_UPPER})
|
||||
set("CMAKE_BINARY_DIR_${CFG_TYPE_UPPER}" ${CFG_ROOT} CACHE INTERNAL "Toplevel binary dir for ${CFG_TYPE} building.")
|
||||
endif(NOT DEFINED CMAKE_BINARY_DIR_${CFG_TYPE_UPPER})
|
||||
if(NOT DEFINED ${PROJECT_NAME}_BINARY_DIR_${CFG_TYPE_UPPER})
|
||||
set("${PROJECT_NAME}_BINARY_DIR_${CFG_TYPE_UPPER}" ${CFG_ROOT} CACHE INTERNAL "Toplevel binary dir for ${CFG_TYPE} building.")
|
||||
endif(NOT DEFINED ${PROJECT_NAME}_BINARY_DIR_${CFG_TYPE_UPPER})
|
||||
endforeach()
|
||||
endif(NOT CMAKE_CONFIGURATION_TYPES)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
@@ -0,0 +1,176 @@
|
||||
# BIN and LIB directories
|
||||
if(NOT DEFINED BIN_DIR)
|
||||
set(BIN_DIR bin)
|
||||
endif(NOT DEFINED BIN_DIR)
|
||||
|
||||
if(NOT DEFINED LIB_DIR)
|
||||
set(LIB_DIR lib)
|
||||
endif(NOT DEFINED LIB_DIR)
|
||||
|
||||
# testing and compilation options, build output dirs, install dirs, etc
|
||||
# included by root CMakeLists
|
||||
|
||||
if(NOT DEFINED INCLUDE_INSTALL_DIR)
|
||||
set(INCLUDE_INSTALL_DIR include)
|
||||
endif(NOT DEFINED INCLUDE_INSTALL_DIR)
|
||||
|
||||
if(NOT DEFINED LIB_INSTALL_DIR)
|
||||
set(LIB_INSTALL_DIR lib)
|
||||
endif(NOT DEFINED LIB_INSTALL_DIR)
|
||||
|
||||
if(NOT DEFINED BIN_INSTALL_DIR)
|
||||
set(BIN_INSTALL_DIR bin)
|
||||
endif(NOT DEFINED BIN_INSTALL_DIR)
|
||||
|
||||
if(NOT DEFINED SC_BUILD_TYPE)
|
||||
set(SC_BUILD_TYPE "Debug" CACHE STRING "Build type") # By default set debug build
|
||||
endif(NOT DEFINED SC_BUILD_TYPE)
|
||||
if(NOT SC_IS_SUBBUILD)
|
||||
set(CMAKE_BUILD_TYPE ${SC_BUILD_TYPE} CACHE INTERNAL "Build type, immutable" FORCE)
|
||||
else(NOT SC_IS_SUBBUILD)
|
||||
set(CMAKE_BUILD_TYPE ${SC_BUILD_TYPE})
|
||||
endif(NOT SC_IS_SUBBUILD)
|
||||
|
||||
# Define helper macro OPTION_WITH_DEFAULT
|
||||
macro(OPTION_WITH_DEFAULT OPTION_NAME OPTION_STRING OPTION_DEFAULT)
|
||||
if(NOT DEFINED ${OPTION_NAME})
|
||||
set(${OPTION_NAME} ${OPTION_DEFAULT})
|
||||
endif(NOT DEFINED ${OPTION_NAME})
|
||||
option(${OPTION_NAME} "${OPTION_STRING}" ${${OPTION_NAME}})
|
||||
endmacro(OPTION_WITH_DEFAULT OPTION_NAME OPTION_STRING OPTION_DEFAULT)
|
||||
|
||||
# build shared libs by default
|
||||
OPTION_WITH_DEFAULT(SC_BUILD_SHARED_LIBS "Build shared libs" ON)
|
||||
|
||||
# don't build static libs by default
|
||||
OPTION_WITH_DEFAULT(SC_BUILD_STATIC_LIBS "Build static libs" OFF)
|
||||
|
||||
OPTION_WITH_DEFAULT(SC_PYTHON_GENERATOR "Compile exp2python" ON)
|
||||
OPTION_WITH_DEFAULT(SC_CPP_GENERATOR "Compile exp2cxx" ON)
|
||||
|
||||
OPTION_WITH_DEFAULT(SC_MEMMGR_ENABLE_CHECKS "Enable sc_memmgr's memory leak detection" OFF)
|
||||
OPTION_WITH_DEFAULT(SC_TRACE_FPRINTF "Enable extra comments in generated code so the code's source in exp2cxx may be located" OFF)
|
||||
|
||||
# Should we use C++11?
|
||||
OPTION_WITH_DEFAULT(SC_ENABLE_CXX11 "Build with C++ 11 features" ON)
|
||||
|
||||
# Get version from git
|
||||
OPTION_WITH_DEFAULT(SC_GIT_VERSION "Build using version from git" ON)
|
||||
|
||||
option(SC_BUILD_EXPRESS_ONLY "Only build express parser." OFF)
|
||||
mark_as_advanced(SC_BUILD_EXPRESS_ONLY)
|
||||
|
||||
option(DEBUGGING_GENERATED_SOURCES "disable md5 verification of generated sources" OFF)
|
||||
mark_as_advanced(DEBUGGING_GENERATED_SOURCES)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# Coverage option
|
||||
OPTION_WITH_DEFAULT(SC_ENABLE_COVERAGE "Enable code coverage test" OFF)
|
||||
if(SC_ENABLE_COVERAGE)
|
||||
set(SC_ENABLE_TESTING ON CACHE BOOL "Testing enabled by coverage option" FORCE)
|
||||
# build static libs, better coverage report
|
||||
set(SC_BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libs" FORCE)
|
||||
set(SC_BUILD_STATIC_LIBS ON CACHE BOOL "Build static libs" FORCE)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -fprofile-arcs -ftest-coverage" CACHE STRING "Extra compile flags required by code coverage" FORCE)
|
||||
set(CMAKE_C_FLAGS_DEBUG "-O0 -g -fprofile-arcs -ftest-coverage" CACHE STRING "Extra compile flags required by code coverage" FORCE)
|
||||
set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "-fprofile-arcs -ftest-coverage" CACHE STRING "Extra linker flags required by code coverage" FORCE)
|
||||
set(SC_BUILD_TYPE "Debug" CACHE STRING "Build type required by testing framework" FORCE)
|
||||
set(SC_PYTHON_GENERATOR OFF) #won't build with static libs
|
||||
endif(SC_ENABLE_COVERAGE)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# Testing option
|
||||
OPTION_WITH_DEFAULT(SC_ENABLE_TESTING "Enable unittesting framework" OFF)
|
||||
if(SC_ENABLE_TESTING)
|
||||
if(NOT ${SC_BUILD_EXPRESS_ONLY} AND NOT DEFINED SC_BUILD_SCHEMAS)
|
||||
set(SC_BUILD_SCHEMAS "ALL") #test all schemas, unless otherwise specified
|
||||
endif()
|
||||
include(CTest)
|
||||
endif(SC_ENABLE_TESTING)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# Executable install option
|
||||
OPTION_WITH_DEFAULT(SC_SKIP_EXEC_INSTALL "Skip installing executables" OFF)
|
||||
if(SC_SKIP_EXEC_INSTALL)
|
||||
set(SC_EXEC_NOINSTALL "NO_INSTALL")
|
||||
endif(SC_SKIP_EXEC_INSTALL)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# The following logic is what allows binaries to run successfully in
|
||||
# the build directory AND install directory. Thanks to plplot for
|
||||
# identifying the necessity of setting CMAKE_INSTALL_NAME_DIR on OSX.
|
||||
# Documentation of these options is available at
|
||||
# http://www.cmake.org/Wiki/CMake_RPATH_handling
|
||||
|
||||
# use, i.e. don't skip the full RPATH for the build tree
|
||||
set(CMAKE_SKIP_BUILD_RPATH FALSE)
|
||||
|
||||
# when building, don't use the install RPATH already
|
||||
# (but later on when installing)
|
||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
||||
|
||||
# the RPATH/INSTALL_NAME_DIR to be used when installing
|
||||
if (NOT APPLE)
|
||||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib:\$ORIGIN/../lib")
|
||||
endif(NOT APPLE)
|
||||
# On OSX, we need to set INSTALL_NAME_DIR instead of RPATH
|
||||
# http://www.cmake.org/cmake/help/cmake-2-8-docs.html#variable:CMAKE_INSTALL_NAME_DIR
|
||||
set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
|
||||
# add the automatically determined parts of the RPATH which point to
|
||||
# directories outside the build tree to the install RPATH
|
||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
|
||||
# When this is a subbuild, assume that the parent project controls all of the following
|
||||
#======================================================================================
|
||||
if(NOT SC_IS_SUBBUILD)
|
||||
|
||||
# Output directories. In a separate file so it can be used by the schema scanner CMake as well.
|
||||
include(${SC_CMAKE_DIR}/SC_Outdirs.cmake)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Configure install locations. Only do this if CMAKE_INSTALL_PREFIX hasn't
|
||||
# been set already, to try and allow parent builds (if any) some control.
|
||||
#
|
||||
# Need a good Debug location for Windows.
|
||||
if(NOT WIN32)
|
||||
if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
|
||||
set(SC_INSTALL_PREFIX "${SC_SOURCE_DIR}/../sc-install")
|
||||
else()
|
||||
set(SC_INSTALL_PREFIX "/usr/local")
|
||||
endif()
|
||||
endif(NOT WIN32)
|
||||
set(SC_INSTALL_PREFIX ${SC_INSTALL_PREFIX} CACHE
|
||||
PATH "Install prefix prepended to target to create install location")
|
||||
set(CMAKE_INSTALL_PREFIX ${SC_INSTALL_PREFIX} CACHE INTERNAL "Prefix prepended to install directories if target destination is not absolute, immutable" FORCE)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# SC Packaging
|
||||
# $make package
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "STEPcode")
|
||||
set(CPACK_SET_DESTDIR "ON")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR ${SC_VERSION_MAJOR})
|
||||
set(CPACK_PACKAGE_VERSION_MINOR ${SC_VERSION_MINOR})
|
||||
set(CPACK_PACKAGE_NAME SC)
|
||||
set(CPACK_PACKAGE_CONTACT "SC Developers <scl-dev@googlegroups.com>")
|
||||
include(CPack)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Uninstall target
|
||||
# From http://www.cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
||||
IMMEDIATE @ONLY)
|
||||
add_custom_target(uninstall
|
||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
||||
|
||||
endif(NOT SC_IS_SUBBUILD)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
@@ -27,16 +27,19 @@ endmacro(P21_TESTS sfile)
|
||||
# create p21read_sdai_*, lazy_sdai_*, any exes listed in SC_SDAI_ADDITIONAL_EXES_SRCS
|
||||
macro(SCHEMA_EXES)
|
||||
RELATIVE_PATH_TO_TOPLEVEL(${CMAKE_CURRENT_SOURCE_DIR} RELATIVE_PATH_COMPONENT)
|
||||
SC_ADDEXEC(p21read_${PROJECT_NAME} SOURCES "${RELATIVE_PATH_COMPONENT}/src/test/p21read/p21read.cc;${RELATIVE_PATH_COMPONENT}/src/test/p21read/sc_benchmark.cc" LINK_LIBRARIES ${PROJECT_NAME} stepdai stepcore stepeditor steputils TESTABLE)
|
||||
SC_ADDEXEC(p21read_${PROJECT_NAME} SOURCES "${RELATIVE_PATH_COMPONENT}/src/test/p21read/p21read.cc" LINK_LIBRARIES ${PROJECT_NAME} stepdai stepcore stepeditor steputils base TESTABLE)
|
||||
#add_dependencies(p21read_${PROJECT_NAME} version_string)
|
||||
if(NOT WIN32)
|
||||
SC_ADDEXEC(lazy_${PROJECT_NAME} SOURCES "${RELATIVE_PATH_COMPONENT}/src/cllazyfile/lazy_test.cc;${RELATIVE_PATH_COMPONENT}/src/cllazyfile/sc_benchmark.cc" LINK_LIBRARIES ${PROJECT_NAME} steplazyfile stepdai stepcore stepeditor steputils TESTABLE)
|
||||
SC_ADDEXEC(lazy_${PROJECT_NAME} SOURCES "${RELATIVE_PATH_COMPONENT}/src/cllazyfile/lazy_test.cc" LINK_LIBRARIES ${PROJECT_NAME} steplazyfile stepdai stepcore stepeditor steputils base TESTABLE)
|
||||
#add_dependencies(lazy_${PROJECT_NAME} version_string)
|
||||
endif(NOT WIN32)
|
||||
|
||||
#add user-defined executables
|
||||
foreach(src ${SC_SDAI_ADDITIONAL_EXES_SRCS})
|
||||
get_filename_component(name ${src} NAME_WE)
|
||||
get_filename_component(path ${src} ABSOLUTE)
|
||||
SC_ADDEXEC(${name}_${PROJECT_NAME} SOURCES ${src} LINK_LIBRARIES ${PROJECT_NAME} stepdai stepcore stepeditor steputils TESTABLE)
|
||||
SC_ADDEXEC(${name}_${PROJECT_NAME} SOURCES ${src} LINK_LIBRARIES ${PROJECT_NAME} stepdai stepcore stepeditor steputils base TESTABLE)
|
||||
add_dependencies(${name}_${PROJECT_NAME} version_string)
|
||||
#set_target_properties(${name}_${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${${PROJECT_NAME}_COMPILE_FLAGS} -I${path}")
|
||||
endforeach(src ${SC_SDAI_ADDITIONAL_EXES_SRCS})
|
||||
ENDMACRO(SCHEMA_EXES)
|
||||
@@ -89,12 +92,12 @@ macro(SCHEMA_TARGETS expFile schemaName sourceFiles)
|
||||
)
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR} ${SC_SOURCE_DIR}/src/cldai ${SC_SOURCE_DIR}/src/cleditor
|
||||
${SC_SOURCE_DIR}/src/clutils ${SC_SOURCE_DIR}/src/clstepcore ${SC_SOURCE_DIR}/src/cllazyfile
|
||||
${SC_SOURCE_DIR}/src/cllazyfile/judy/src
|
||||
${SC_SOURCE_DIR}/src/clutils ${SC_SOURCE_DIR}/src/clstepcore ${SC_SOURCE_DIR}/src/base
|
||||
${SC_SOURCE_DIR}/src/base/judy/src
|
||||
)
|
||||
# if testing is enabled, "TESTABLE" sets property EXCLUDE_FROM_ALL and prevents installation
|
||||
if(BUILD_SHARED_LIBS)
|
||||
SC_ADDLIB(${PROJECT_NAME} SHARED SOURCES ${sourceFiles} LINK_LIBRARIES stepdai stepcore stepeditor steputils TESTABLE)
|
||||
if($CACHE{SC_BUILD_SHARED_LIBS})
|
||||
SC_ADDLIB(${PROJECT_NAME} SHARED SOURCES ${sourceFiles} LINK_LIBRARIES stepdai stepcore stepeditor steputils base TESTABLE)
|
||||
add_dependencies(${PROJECT_NAME} generate_cpp_${PROJECT_NAME})
|
||||
if(WIN32)
|
||||
target_compile_definitions("${PROJECT_NAME}" PRIVATE SC_SCHEMA_DLL_EXPORTS)
|
||||
@@ -102,18 +105,12 @@ macro(SCHEMA_TARGETS expFile schemaName sourceFiles)
|
||||
target_compile_options("${PROJECT_NAME}" PRIVATE "/bigobj")
|
||||
endif()
|
||||
endif()
|
||||
# TODO - ideally we would avoid generating code that triggers this warning, but figuring out
|
||||
# how to do so is a non-trivial exercise. In the meantime, suppress the (very verbose) warnings
|
||||
# we get due to this issue so it doesn't mask other problems.
|
||||
if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
|
||||
target_compile_options("${PROJECT_NAME}" PRIVATE "-Wno-ignored-qualifiers")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if($CACHE{SC_BUILD_STATIC_LIBS})
|
||||
SC_ADDLIB(${PROJECT_NAME}-static STATIC SOURCES ${sourceFiles} LINK_LIBRARIES stepdai-static stepcore-static stepeditor-static steputils-static TESTABLE)
|
||||
SC_ADDLIB(${PROJECT_NAME}-static STATIC SOURCES ${sourceFiles} LINK_LIBRARIES stepdai-static stepcore-static stepeditor-static steputils-static base-static TESTABLE)
|
||||
add_dependencies(${PROJECT_NAME}-static generate_cpp_${PROJECT_NAME})
|
||||
target_compile_definitions("${PROJECT_NAME}-static" PRIVATE SC_STATIC)
|
||||
target_compile_defines("${PROJECT_NAME}-static" PRIVATE SC_STATIC)
|
||||
if(MSVC)
|
||||
target_compile_options("${PROJECT_NAME}-static" PRIVATE "/bigobj")
|
||||
endif()
|
||||
|
||||
@@ -1,4 +1,23 @@
|
||||
# create config.h
|
||||
# create sc_cf.h and sc_version_string.h
|
||||
|
||||
# Take the sc config file template as the starting point for
|
||||
# sc_cf.h.in - scripts may need to append to the template, so
|
||||
# it is read into memory initially.
|
||||
set(CONFIG_H_FILE ${SC_BINARY_DIR}/include/sc_cf.h.in)
|
||||
set_source_files_properties(${CONFIG_H_FILE} PROPERTIES GENERATED TRUE)
|
||||
set(CMAKE_CURRENT_PROJECT SC)
|
||||
define_property(GLOBAL PROPERTY SC_CONFIG_H_CONTENTS BRIEF_DOCS "config.h.in contents" FULL_DOCS "config.h.in contents for SC project")
|
||||
if(NOT COMMAND CONFIG_H_APPEND)
|
||||
macro(CONFIG_H_APPEND PROJECT_NAME NEW_CONTENTS)
|
||||
if(PROJECT_NAME)
|
||||
get_property(${PROJECT_NAME}_CONFIG_H_CONTENTS GLOBAL PROPERTY ${PROJECT_NAME}_CONFIG_H_CONTENTS)
|
||||
set(${PROJECT_NAME}_CONFIG_H_FILE_CONTENTS "${${PROJECT_NAME}_CONFIG_H_CONTENTS}${NEW_CONTENTS}")
|
||||
set_property(GLOBAL PROPERTY ${PROJECT_NAME}_CONFIG_H_CONTENTS "${${PROJECT_NAME}_CONFIG_H_FILE_CONTENTS}")
|
||||
endif(PROJECT_NAME)
|
||||
endmacro(CONFIG_H_APPEND NEW_CONTENTS)
|
||||
endif(NOT COMMAND CONFIG_H_APPEND)
|
||||
file(READ ${SC_SOURCE_DIR}/include/sc_cf_cmake.h.in CONFIG_H_FILE_CONTENTS)
|
||||
CONFIG_H_APPEND(SC "${CONFIG_H_FILE_CONTENTS}")
|
||||
|
||||
include(CheckLibraryExists)
|
||||
include(CheckIncludeFile)
|
||||
@@ -77,9 +96,37 @@ int main() {return !(f() == f());}
|
||||
cmake_pop_check_state()
|
||||
endif(SC_ENABLE_CXX11)
|
||||
|
||||
# Now that all the tests are done, configure the config.h file:
|
||||
configure_file(${CMAKE_SOURCE_DIR}/include/config.h.in ${SC_BINARY_DIR}/${INCLUDE_DIR}/config.h.gen)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SC_BINARY_DIR}/${INCLUDE_DIR}/config.h.gen ${SC_BINARY_DIR}/${INCLUDE_DIR}/config.h)
|
||||
# Now that all the tests are done, configure the sc_cf.h file:
|
||||
get_property(CONFIG_H_FILE_CONTENTS GLOBAL PROPERTY SC_CONFIG_H_CONTENTS)
|
||||
file(WRITE ${CONFIG_H_FILE} "${CONFIG_H_FILE_CONTENTS}")
|
||||
configure_file(${CONFIG_H_FILE} ${SC_BINARY_DIR}/${INCLUDE_INSTALL_DIR}/sc_cf.h)
|
||||
|
||||
# ------------------------
|
||||
|
||||
# create sc_version_string.h, http://stackoverflow.com/questions/3780667
|
||||
# Using 'ver_string' instead of 'sc_version_string.h' is a trick to force the
|
||||
# command to always execute when the custom target is built. It works because
|
||||
# a file by that name never exists.
|
||||
if(SC_GIT_VERSION)
|
||||
configure_file(${SC_CMAKE_DIR}/sc_version_string.cmake ${SC_BINARY_DIR}/sc_version_string.cmake @ONLY)
|
||||
add_custom_target(version_string ALL DEPENDS ver_string)
|
||||
# creates sc_version_string.h using cmake script
|
||||
add_custom_command(OUTPUT ver_string
|
||||
COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${SC_SOURCE_DIR} -DBINARY_DIR=${SC_BINARY_DIR} -P ${SC_BINARY_DIR}/sc_version_string.cmake
|
||||
)
|
||||
# sc_version_string.h is a generated file
|
||||
else(SC_GIT_VERSION)
|
||||
set(VER_HDR "
|
||||
#ifndef SC_VERSION_STRING
|
||||
#define SC_VERSION_STRING
|
||||
static char sc_version[512] = {\"${SC_VERSION}\"};
|
||||
#endif"
|
||||
)
|
||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${INCLUDE_INSTALL_DIR}/sc_version_string.h "${VER_HDR}")
|
||||
endif(SC_GIT_VERSION)
|
||||
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${INCLUDE_INSTALL_DIR}/sc_version_string.h
|
||||
PROPERTIES GENERATED TRUE
|
||||
HEADER_FILE_ONLY TRUE )
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
|
||||
@@ -29,9 +29,8 @@ endif()
|
||||
if(NOT "${SC_GENERATE_LEXER_PARSER}" STREQUAL "OFF")
|
||||
# NOTE: lemon doesn't have a stable versioning system (it's always 1)
|
||||
find_package(LEMON ${_verbosity})
|
||||
find_package(RE2C ${_verbosity})
|
||||
find_package(PERPLEX ${_verbosity})
|
||||
|
||||
find_package(RE2C 1.0.3 ${_verbosity})
|
||||
|
||||
if(LEMON_FOUND AND RE2C_FOUND)
|
||||
set(SC_GENERATE_LP_SOURCES 1)
|
||||
message(".. Found re2c, and lemon - can regenerate lexer/parser if necessary")
|
||||
|
||||
@@ -46,11 +46,7 @@ macro(SC_ADDLIB _addlib_target)
|
||||
|
||||
if(${_arg_prefix}_SHARED)
|
||||
add_library(${_addlib_target} SHARED ${${_arg_prefix}_SOURCES})
|
||||
if(OPENBSD)
|
||||
set_target_properties(${_addlib_target} PROPERTIES VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR})
|
||||
else(OPENBSD)
|
||||
set_target_properties(${_addlib_target} PROPERTIES VERSION ${SC_VERSION} SOVERSION ${SC_VERSION_MAJOR})
|
||||
endif(OPENBSD)
|
||||
set_target_properties(${_addlib_target} PROPERTIES VERSION ${SC_ABI_VERSION} SOVERSION ${SC_ABI_SOVERSION})
|
||||
if(APPLE)
|
||||
set_target_properties(${_addlib_target} PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress")
|
||||
endif(APPLE)
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
# Inherit the parent CMake setting
|
||||
set(CURRENT_SOURCE_DIR @CMAKE_CURRENT_SOURCE_DIR@)
|
||||
set(CURRENT_BINARY_DIR @CMAKE_CURRENT_BINARY_DIR@)
|
||||
|
||||
# Define a variety of convenience routines
|
||||
include(@PROJECT_CMAKE_DIR@/Generated_Source_Utils.cmake)
|
||||
|
||||
# The following steps are executed to sync generated sources:
|
||||
#
|
||||
# 1. Create a new verification_info.cmake file and populate
|
||||
# it with the MD5 sums for current files.
|
||||
#
|
||||
# 2. Overwrite the original cached verification_info.cmake
|
||||
# and generated files with the new ones. If LOCKED_SOURCE_DIR
|
||||
# is ON, this step will not be carried out - instead, an
|
||||
# informational message with manual updating instructions
|
||||
# will be printed.
|
||||
|
||||
set(new_info_file "${CURRENT_BINARY_DIR}/verification_info.cmake")
|
||||
|
||||
|
||||
file(WRITE ${new_info_file} "# Autogenerated verification information\n")
|
||||
|
||||
# Handle input files
|
||||
set(input_files "@MD5_FILELIST@")
|
||||
WRITE_MD5_SUMS("${input_files}" "${new_info_file}")
|
||||
|
||||
message("New verification file created: ${new_info_file}")
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
@@ -0,0 +1,30 @@
|
||||
# Inherit the parent CMake setting
|
||||
set(DEBUGGING_GENERATED_SOURCES @DEBUGGING_GENERATED_SOURCES@)
|
||||
set(CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@")
|
||||
|
||||
# Include the file the provides the baseline against which
|
||||
# current files will be compared
|
||||
|
||||
include("@BASELINE_INFORMATION_FILE@")
|
||||
|
||||
# Define a variety of convenience routines
|
||||
include("@PROJECT_CMAKE_DIR@/Generated_Source_Utils.cmake")
|
||||
|
||||
# Individually verify all of the files in question.
|
||||
set(filelist "@MD5_FILELIST@")
|
||||
VERIFY_FILES("${filelist}" 1 srcs_pass)
|
||||
if(NOT srcs_pass)
|
||||
if(NOT DEBUGGING_GENERATED_SOURCES)
|
||||
message(FATAL_ERROR "Sources have been modified and md5 sums have not been updated. This generally indicates either\n a) an input file has been modified but generated files have not been updated, or\n b) genenerated files have been edited directly.\nTo clear the error:\n a) Copy the new generated sources from the build directory to the generated/ sources directory, use the <target>_md5gen build target to create a new verifictation_info.cmake file, and copy verfication_info.cmake to generated/ as well.\n b) install Perplex/Re2C/LEMON and make the changes to the input file rather than the generated file.\nNote:\n If this is a debugging situation where multiple sequential tests must be conducted, temporarily set the variable DEBUGGING_GENERATED_SOURCES to ON during the CMake configure to disable this check.\nThis measure is necessary to ensure that compilations using either Perplex/Re2C/LEMON generation or the cached outputs of those tools produce consistent results.")
|
||||
else(NOT DEBUGGING_GENERATED_SOURCES)
|
||||
message(WARNING "Note: Sources have been modified and md5 sums have not been updated - build failure condition temporarily overridden by DEBUGGING_GENERATED_SOURCES setting.")
|
||||
endif(NOT DEBUGGING_GENERATED_SOURCES)
|
||||
endif(NOT srcs_pass)
|
||||
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
@@ -0,0 +1,84 @@
|
||||
# creates sc_version_string.h, which defines sc_version()
|
||||
# sc_version() returns a pretty commit description and a build timestamp.
|
||||
|
||||
# only update the file if the git commit has changed, because whenever the file is updated files including the header must rebuild
|
||||
# parallel rebuilds can result in race conditions and failures, particularly when running ctest in parallel
|
||||
|
||||
# http://stackoverflow.com/questions/3780667
|
||||
# http://www.cmake.org/pipermail/cmake/2009-February/027014.html
|
||||
|
||||
set(SC_IS_SUBBUILD "@SC_IS_SUBBUILD@")
|
||||
set(SC_ENABLE_TESTING "@SC_ENABLE_TESTING@")
|
||||
|
||||
set(SC_VERSION_HEADER "${BINARY_DIR}/include/sc_version_string.h")
|
||||
|
||||
#---------- find commit id ------------------
|
||||
#use git for a pretty commit id
|
||||
#uses 'git describe --tags', so tags are required in the repo
|
||||
#create a tag with 'git tag <name>' and 'git push --tags'
|
||||
#if git can't be found, uses contents of SC_VERSION.txt
|
||||
|
||||
set(VERS_FILE ${SOURCE_DIR}/SC_VERSION.txt)
|
||||
if(EXISTS ${SOURCE_DIR}/.git)
|
||||
find_package(Git QUIET)
|
||||
if(GIT_FOUND)
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags WORKING_DIRECTORY ${SOURCE_DIR}
|
||||
RESULT_VARIABLE res_var OUTPUT_VARIABLE GIT_COMMIT_ID)
|
||||
if(NOT ${res_var} EQUAL 0)
|
||||
file(READ ${VERS_FILE} GIT_COMMIT_ID LIMIT 255)
|
||||
if(NOT SC_IS_SUBBUILD)
|
||||
message(WARNING "Git failed (probably no tags in repo). Build will contain revision info from ${VERS_FILE}.")
|
||||
endif(NOT SC_IS_SUBBUILD)
|
||||
endif()
|
||||
else(GIT_FOUND)
|
||||
file(READ ${VERS_FILE} GIT_COMMIT_ID LIMIT 255)
|
||||
if(NOT SC_IS_SUBBUILD)
|
||||
message(WARNING "Git not found. Build will contain revision info from ${VERS_FILE}.")
|
||||
endif(NOT SC_IS_SUBBUILD)
|
||||
endif(GIT_FOUND)
|
||||
else()
|
||||
file(READ ${VERS_FILE} GIT_COMMIT_ID LIMIT 255)
|
||||
if(NOT SC_IS_SUBBUILD)
|
||||
message(WARNING "Git failed ('.git' not found). Build will contain revision info from ${VERS_FILE}.")
|
||||
endif(NOT SC_IS_SUBBUILD)
|
||||
endif()
|
||||
string(REPLACE "\n" "" GIT_COMMIT_ID ${GIT_COMMIT_ID})
|
||||
|
||||
#-------------- date and time ---------------
|
||||
|
||||
if(SC_ENABLE_TESTING)
|
||||
set (date_time_string "NA - disabled for testing")
|
||||
else()
|
||||
string(TIMESTAMP date_time_string UTC)
|
||||
endif()
|
||||
|
||||
set(header_string "/* sc_version_string.h - written by cmake. Changes will be lost! */\n"
|
||||
"#ifndef SC_VERSION_STRING\n"
|
||||
"#define SC_VERSION_STRING\n\n"
|
||||
"/*\n** The git commit id looks like \"test-1-g5e1fb47\", where test is the\n"
|
||||
"** name of the last tagged git revision, 1 is the number of commits since that tag,\n"
|
||||
"** 'g' is unknown, and 5e1fb47 is the first 7 chars of the git sha1 commit id.\n"
|
||||
"** timestamp is created from date/time commands on known platforms, and uses\n"
|
||||
"** preprocessor macros elsewhere.\n*/\n\n"
|
||||
"static char sc_version[512] = {\n"
|
||||
" \"git commit id: ${GIT_COMMIT_ID}, build timestamp ${date_time_string}\"\n"
|
||||
"}\;\n\n"
|
||||
"#endif\n"
|
||||
)
|
||||
|
||||
#don't update the file unless something changed
|
||||
string(RANDOM tmpsuffix)
|
||||
file(WRITE ${SC_VERSION_HEADER}.${tmpsuffix} ${header_string})
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SC_VERSION_HEADER}.${tmpsuffix} ${SC_VERSION_HEADER})
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${SC_VERSION_HEADER}.${tmpsuffix})
|
||||
|
||||
if(NOT SC_IS_SUBBUILD)
|
||||
message("-- sc_version_string.h is up-to-date.")
|
||||
endif(NOT SC_IS_SUBBUILD)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
@@ -1,5 +1,5 @@
|
||||
project(SC_SUBPROJECT_SCHEMA_SCANNER)
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
cmake_minimum_required(VERSION 3.6.3)
|
||||
|
||||
if(NOT ("${CALLED_FROM}" STREQUAL "STEPCODE_CMAKELISTS" AND DEFINED SC_ROOT AND DEFINED SC_BUILDDIR))
|
||||
message(" ${CALLED_FROM} ${SC_ROOT} ${SC_BUILDDIR}")
|
||||
@@ -16,14 +16,15 @@ set(SC_BINARY_DIR ${SC_BUILDDIR})
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/../SC_Outdirs.cmake)
|
||||
|
||||
set(schema_scanner_src
|
||||
${SC_ROOT}/src/base/sc_mkdir.c
|
||||
${SC_ROOT}/src/exp2cxx/genCxxFilenames.c
|
||||
${SC_ROOT}/src/exp2cxx/class_strings.c
|
||||
${SC_ROOT}/src/express/generated/expparse.c
|
||||
${SC_ROOT}/src/express/generated/expscan.c
|
||||
${SC_ROOT}/src/express/lexsupport.c
|
||||
${SC_ROOT}/src/express/alg.c
|
||||
${SC_ROOT}/src/express/alloc.c
|
||||
${SC_ROOT}/src/express/caseitem.c
|
||||
${SC_ROOT}/src/express/dict.c
|
||||
${SC_ROOT}/src/express/entity.c
|
||||
${SC_ROOT}/src/express/error.c
|
||||
${SC_ROOT}/src/express/exp_kw.c
|
||||
@@ -31,7 +32,6 @@ set(schema_scanner_src
|
||||
${SC_ROOT}/src/express/express.c
|
||||
${SC_ROOT}/src/express/factory.c
|
||||
${SC_ROOT}/src/express/hash.c
|
||||
${SC_ROOT}/src/express/lexact.c
|
||||
${SC_ROOT}/src/express/linklist.c
|
||||
${SC_ROOT}/src/express/memory.c
|
||||
${SC_ROOT}/src/express/object.c
|
||||
@@ -44,13 +44,16 @@ set(schema_scanner_src
|
||||
${SC_ROOT}/src/express/symbol.c
|
||||
${SC_ROOT}/src/express/type.c
|
||||
${SC_ROOT}/src/express/variable.c
|
||||
${SC_ROOT}/src/auxlib/bstrlib.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/schemaScanner.cc
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${SC_ROOT}/include/
|
||||
${SC_ROOT}/src/auxlib
|
||||
${SC_ROOT}/src/express/
|
||||
${SC_ROOT}/src/express/generated
|
||||
${SC_ROOT}/src/base
|
||||
${SC_ROOT}/src/exp2cxx
|
||||
${SC_BUILDDIR}/include
|
||||
)
|
||||
|
||||
@@ -14,25 +14,20 @@
|
||||
*/
|
||||
|
||||
extern "C" {
|
||||
#define _XOPEN_SOURCE /* for S_IFDIR */
|
||||
# include "expparse.h"
|
||||
# include "expscan.h"
|
||||
# include "express/scope.h"
|
||||
# include "genCxxFilenames.h"
|
||||
# include "sc_mkdir.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
# include <string.h>
|
||||
|
||||
#include "expparse.h"
|
||||
#include "expscan.h"
|
||||
#include "express/scope.h"
|
||||
#include "genCxxFilenames.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <direct.h>
|
||||
# define getcwd _getcwd
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
# ifdef _WIN32
|
||||
# include <direct.h>
|
||||
# define getcwd _getcwd
|
||||
# else
|
||||
# include <unistd.h>
|
||||
# endif
|
||||
}
|
||||
|
||||
#include <string>
|
||||
@@ -130,30 +125,6 @@ string makeShortName( const char * longName ) {
|
||||
return filename;
|
||||
}
|
||||
|
||||
/* cross-platform mkdir */
|
||||
int sc_mkdir( const char * path ) {
|
||||
#ifdef _WIN32
|
||||
return mkdir( path );
|
||||
#else
|
||||
return mkdir( path, 0777 );
|
||||
#endif /* _WIN32 */
|
||||
}
|
||||
|
||||
/* return -1 if error, 0 if created, 1 if dir existed already */
|
||||
static int mkDirIfNone( const char * path ) {
|
||||
struct stat s;
|
||||
if( stat( path, &s ) != 0 ) {
|
||||
if( errno == ENOENT ) {
|
||||
return sc_mkdir( path );
|
||||
}
|
||||
} else if( s.st_mode & S_IFDIR ) {
|
||||
return 1;
|
||||
}
|
||||
/* either stat returned an error other than ENOENT, or 'path' exists but isn't a dir */
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/** write a CMakeLists.txt file for the schema; print its directory to stdout for CMake's add_subdirectory() command */
|
||||
void writeLists( const char * schemaName, stringstream & eh, stringstream & ei, int ecount,
|
||||
stringstream & th, stringstream & ti, int tcount ) {
|
||||
@@ -249,7 +220,7 @@ void writeLists( const char * schemaName, stringstream & eh, stringstream & ei,
|
||||
|
||||
cmLists.close();
|
||||
|
||||
char pwd[BUFSIZ+1] = {0};
|
||||
char pwd[BUFSIZ] = {0};
|
||||
if( getcwd( pwd, BUFSIZ ) ) {
|
||||
cout << pwd << "/" << shortName << endl;
|
||||
} else {
|
||||
|
||||
@@ -71,9 +71,9 @@ message( STATUS "Schema scanner built. Running it...")
|
||||
|
||||
# not sure if it makes sense to install this or not...
|
||||
if(WIN32)
|
||||
install(PROGRAMS ${SCANNER_OUT_DIR}/schema_scanner.exe DESTINATION ${BIN_DIR})
|
||||
install(PROGRAMS ${SCANNER_OUT_DIR}/schema_scanner.exe DESTINATION ${BIN_INSTALL_DIR})
|
||||
else(WIN32)
|
||||
install(PROGRAMS ${SCANNER_OUT_DIR}/schema_scanner DESTINATION ${BIN_DIR})
|
||||
install(PROGRAMS ${SCANNER_OUT_DIR}/schema_scanner DESTINATION ${BIN_INSTALL_DIR})
|
||||
endif(WIN32)
|
||||
|
||||
# macro SCHEMA_CMLIST
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
# Inherit the parent CMake setting
|
||||
set(CURRENT_SOURCE_DIR @CMAKE_CURRENT_SOURCE_DIR@)
|
||||
set(CURRENT_BINARY_DIR @CMAKE_CURRENT_BINARY_DIR@)
|
||||
set(CACHED_FILES_DIR @CACHED_FILES_DIR@)
|
||||
set(LEMON_EXECUTABLE @LEMON_EXECUTABLE@)
|
||||
set(RE2C_EXECUTABLE @RE2C_EXECUTABLE@)
|
||||
set(PERPLEX_EXECUTABLE @PERPLEX_EXECUTABLE@)
|
||||
set(LOCKED_SOURCE_DIR @LOCKED_SOURCE_DIR@)
|
||||
set(DEBUGGING_GENERATED_SOURCES @DEBUGGING_GENERATED_SOURCES@)
|
||||
|
||||
if(NOT DEBUGGING_GENERATED_SOURCES)
|
||||
# Define a variety of convenience routines
|
||||
include(@PROJECT_CMAKE_DIR@/Generated_Source_Utils.cmake)
|
||||
|
||||
# The following steps are executed to sync generated sources:
|
||||
#
|
||||
# 1. Create a new verification_info.cmake file and populate
|
||||
# it with the current versions of perplex, re2c and lemon.
|
||||
# Also add the MD5 sums for current template files.
|
||||
#
|
||||
# 2. For all files that need to be updated in the cache,
|
||||
# calculate new MD5 sums and add them to the new
|
||||
# verification_info.cmake - this is usually the input
|
||||
# files and the generated outputs.
|
||||
#
|
||||
# 3. Overwrite the original cached verification_info.cmake
|
||||
# and generated files with the new ones. If LOCKED_SOURCE_DIR
|
||||
# is ON, this step will not be carried out - instead, an
|
||||
# informational message with manual updating instructions
|
||||
# will be printed.
|
||||
|
||||
set(new_info_file "${CURRENT_BINARY_DIR}/verification_info.cmake.new")
|
||||
|
||||
|
||||
file(WRITE ${new_info_file} "# Autogenerated verification information\n")
|
||||
|
||||
# Handle generator version numbers
|
||||
GET_GENERATOR_EXEC_VERSIONS()
|
||||
file(APPEND ${new_info_file} "set(baseline_lemon_version \"${lemon_version}\")\n")
|
||||
file(APPEND ${new_info_file} "set(baseline_re2c_version \"${re2c_version}\")\n")
|
||||
file(APPEND ${new_info_file} "set(baseline_perplex_version \"${perplex_version}\")\n")
|
||||
|
||||
# Handle template files
|
||||
set(template_files "@TEMPLATE_FILELIST@")
|
||||
WRITE_MD5_SUMS("${template_files}" "${new_info_file}")
|
||||
|
||||
# Handle input files
|
||||
set(input_files "@INPUT_FILELIST@")
|
||||
WRITE_MD5_SUMS("${input_files}" "${new_info_file}")
|
||||
|
||||
# Handle generated files
|
||||
set(output_files "@BUILD_OUTPUT_FILELIST@")
|
||||
WRITE_MD5_SUMS("${output_files}" "${new_info_file}")
|
||||
|
||||
# Copy files into their final locations
|
||||
if(NOT LOCKED_SOURCE_DIR)
|
||||
configure_file(${new_info_file} "${CACHED_FILES_DIR}/verification_info.cmake" COPYONLY)
|
||||
foreach(outf ${output_files})
|
||||
get_filename_component(filecorename ${outf} NAME)
|
||||
message("copying ${outf} to ${CACHED_FILES_DIR}/${filecorename}")
|
||||
configure_file(${outf} "${CACHED_FILES_DIR}/${filecorename}" COPYONLY)
|
||||
endforeach(outf ${output_files})
|
||||
else(NOT LOCKED_SOURCE_DIR)
|
||||
message("Source directory writing is locked - LOCKED_SOURCE_DIR is set.")
|
||||
message("To update the generated files, manually copy the following to ${CACHED_FILES_DIR}:")
|
||||
message(" ${new_info_file} (rename to verification_info.cmake)")
|
||||
foreach(outf ${output_files})
|
||||
message(" ${outf}")
|
||||
endforeach(outf ${output_files})
|
||||
endif(NOT LOCKED_SOURCE_DIR)
|
||||
|
||||
else(NOT DEBUGGING_GENERATED_SOURCES)
|
||||
|
||||
message("\nNote: DEBUGGING_GENERATED_SOURCES is enabled - generated outputs will contain configuration-specific debugging information, so syncing cached output files is not possible. To restore normal behavior, disable DEBUGGING_GENERATED_SOURCES.\n")
|
||||
|
||||
endif(NOT DEBUGGING_GENERATED_SOURCES)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
# .exp file inside, which it uses. otherwise, ${path} is assumed to
|
||||
# be an express file.
|
||||
|
||||
if(NOT "${SC_BUILD_EXPRESS_ONLY}" AND NOT "${SC_BUILD_SCHEMAS}" STREQUAL "")
|
||||
if(NOT ${SC_BUILD_EXPRESS_ONLY} AND NOT "${SC_BUILD_SCHEMAS}" STREQUAL "")
|
||||
include(${SC_CMAKE_DIR}/schema_scanner/schemaScanner.cmake)
|
||||
foreach(src ${SC_SDAI_ADDITIONAL_EXES_SRCS})
|
||||
get_filename_component(name ${src} NAME_WE)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
# for the use of this file.
|
||||
#
|
||||
project(AP203Minimum)
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
cmake_minimum_required(VERSION 3.6.3)
|
||||
|
||||
# Set STEPCODE_ROOT_DIR to point to the root of the STEPcode source tree.
|
||||
if(NOT DEFINED STEPCODE_ROOT_DIR)
|
||||
@@ -14,14 +14,14 @@ if(NOT DEFINED STEPCODE_ROOT_DIR)
|
||||
endif(NOT DEFINED STEPCODE_ROOT_DIR)
|
||||
|
||||
# STEPCODE_ROOT_DIR is relative or absolute path?
|
||||
if(EXISTS "${CMAKE_BINARY_DIR}/${STEPCODE_ROOT_DIR}/src/express/express.c")
|
||||
if(EXISTS "${CMAKE_BINARY_DIR}/${STEPCODE_ROOT_DIR}/SC_VERSION.txt")
|
||||
set(STEPCODE_ROOT_DIR "${CMAKE_BINARY_DIR}/${STEPCODE_ROOT_DIR}")
|
||||
message("** STEPCODE_ROOT_DIR is a relative path; converted to absolute path: ${STEPCODE_ROOT_DIR}.")
|
||||
else()
|
||||
if(NOT EXISTS "${STEPCODE_ROOT_DIR}/src/express/express.c")
|
||||
if(NOT EXISTS "${STEPCODE_ROOT_DIR}/SC_VERSION.txt")
|
||||
message(FATAL_ERROR "**** Cannot locate STEPCODE_ROOT_DIR - try an absolute path.")
|
||||
endif(NOT EXISTS "${STEPCODE_ROOT_DIR}/src/express/express.c")
|
||||
endif(EXISTS "${CMAKE_BINARY_DIR}/${STEPCODE_ROOT_DIR}/src/express/express.c")
|
||||
endif(NOT EXISTS "${STEPCODE_ROOT_DIR}/SC_VERSION.txt")
|
||||
endif(EXISTS "${CMAKE_BINARY_DIR}/${STEPCODE_ROOT_DIR}/SC_VERSION.txt")
|
||||
|
||||
|
||||
# Use STEPcode as library, but build from this build process.
|
||||
@@ -51,13 +51,14 @@ endif(NOT EXISTS ${SCHEMA_FILE})
|
||||
|
||||
get_filename_component(SCHEMA_SN ${SCHEMA_FILE} NAME)
|
||||
string(REGEX REPLACE "\(.*\).[Ee][Xx][Pp]" "sdai_\\1" SCHEMA_LINK_NAME ${SCHEMA_SN})
|
||||
set(STEPCODE_LIBRARIES stepcore stepeditor stepdai steputils ${SCHEMA_LINK_NAME})
|
||||
set(STEPCODE_LIBRARIES base stepcore stepeditor stepdai steputils ${SCHEMA_LINK_NAME})
|
||||
|
||||
# Add STEPCode project to CMake build.
|
||||
add_subdirectory(${STEPCODE_ROOT_DIR} "${CMAKE_CURRENT_BINARY_DIR}/sc" EXCLUDE_FROM_ALL)
|
||||
|
||||
# Set up STEPcode include directories.
|
||||
set(STEPCODE_INCLUDE_DIR
|
||||
${STEPCODE_ROOT_DIR}/src/base
|
||||
${STEPCODE_ROOT_DIR}/src/clstepcore
|
||||
${STEPCODE_ROOT_DIR}/src/cldai
|
||||
${STEPCODE_ROOT_DIR}/src/clutils
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
# for the use of this file.
|
||||
#
|
||||
project(AP203Minimum)
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
cmake_minimum_required(VERSION 3.6.3)
|
||||
|
||||
INCLUDE( ExternalProject )
|
||||
|
||||
@@ -19,6 +19,7 @@ INCLUDE( External_STEPCode )
|
||||
|
||||
IF(NOT WIN32)
|
||||
set( STEPCODE_LIBRARIES
|
||||
${STEPCODE_INSTALL_DIR}/lib/libbase.a
|
||||
${STEPCODE_INSTALL_DIR}/lib/libstepcore.a
|
||||
${STEPCODE_INSTALL_DIR}/lib/libstepeditor.a
|
||||
${STEPCODE_INSTALL_DIR}/lib/libstepdai.a
|
||||
@@ -27,6 +28,7 @@ IF(NOT WIN32)
|
||||
)
|
||||
ELSE()
|
||||
set( STEPCODE_LIBRARIES
|
||||
${STEPCODE_INSTALL_DIR}/lib/libbase.lib
|
||||
${STEPCODE_INSTALL_DIR}/lib/libstepcore.lib
|
||||
${STEPCODE_INSTALL_DIR}/lib/libstepeditor.lib
|
||||
${STEPCODE_INSTALL_DIR}/lib/libstepdai.lib
|
||||
@@ -42,6 +44,7 @@ MESSAGE( STATUS "STEPCODE_INSTALL_DIR: " ${STEPCODE_INSTALL_DIR} )
|
||||
|
||||
set( STEPCODE_INCLUDE_DIR
|
||||
${STEPCODE_INSTALL_DIR}/include/stepcode
|
||||
${STEPCODE_INSTALL_DIR}/include/stepcode/base
|
||||
${STEPCODE_INSTALL_DIR}/include/stepcode/clstepcore
|
||||
${STEPCODE_INSTALL_DIR}/include/stepcode/cldai
|
||||
${STEPCODE_INSTALL_DIR}/include/stepcode/clutils
|
||||
|
||||
@@ -22,3 +22,8 @@ ENDIF()
|
||||
|
||||
SET( STEPCODE_BINARY_DIR ${BINARY_DIR} )
|
||||
|
||||
# SC CMake does not honor -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
|
||||
# Consequently, force Debug so it installs in ../sc-install directory
|
||||
# instead of /usr/local/lib.
|
||||
#
|
||||
# SC's own programs fail to build with -DSC_BUILD_SHARED_LIBS=OFF
|
||||
@@ -22,20 +22,22 @@ set(express_HDRS
|
||||
express/variable.h
|
||||
)
|
||||
install(FILES ${express_HDRS}
|
||||
DESTINATION ${INCLUDE_DIR}/stepcode/express)
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/express)
|
||||
|
||||
set(exppp_HDRS
|
||||
exppp/exppp.h
|
||||
)
|
||||
install(FILES ${exppp_HDRS}
|
||||
DESTINATION ${INCLUDE_DIR}/stepcode/exppp)
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/exppp)
|
||||
|
||||
install(FILES ordered_attrs.h
|
||||
sc_export.h
|
||||
DESTINATION ${INCLUDE_DIR}/stepcode)
|
||||
sc_stdbool.h
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode)
|
||||
|
||||
install(FILES ${SC_BINARY_DIR}/${INCLUDE_DIR}/config.h
|
||||
DESTINATION ${INCLUDE_DIR}/stepcode)
|
||||
install(FILES ${SC_BINARY_DIR}/${INCLUDE_INSTALL_DIR}/sc_cf.h
|
||||
${SC_BINARY_DIR}/${INCLUDE_INSTALL_DIR}/sc_version_string.h
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
#ifndef SCL_CF_H
|
||||
#define SCL_CF_H
|
||||
|
||||
/**** Define statements for CMake ****/
|
||||
#cmakedefine SC_VERSION "@SC_VERSION@"
|
||||
#cmakedefine HAVE_NDIR_H 1
|
||||
#cmakedefine HAVE_STDINT_H 1
|
||||
#cmakedefine HAVE_SYS_STAT_H 1
|
||||
#cmakedefine HAVE_SYS_PARAM_H 1
|
||||
#cmakedefine HAVE_SYSENT_H 1
|
||||
#cmakedefine HAVE_UNISTD_H 1
|
||||
#cmakedefine HAVE_DIRENT_H 1
|
||||
#cmakedefine HAVE_STDBOOL_H 1
|
||||
#cmakedefine HAVE_PROCESS_H 1
|
||||
#cmakedefine HAVE_IO_H 1
|
||||
|
||||
#cmakedefine SC_TRACE_FPRINTF 1
|
||||
|
||||
#cmakedefine HAVE_ABS 1
|
||||
#cmakedefine HAVE_MEMCPY 1
|
||||
#cmakedefine HAVE_MEMMOVE 1
|
||||
#cmakedefine HAVE_GETOPT 1
|
||||
#cmakedefine HAVE_VSNPRINTF 1
|
||||
|
||||
#cmakedefine HAVE_SSIZE_T 1
|
||||
|
||||
#cmakedefine HAVE_STD_THREAD 1
|
||||
#cmakedefine HAVE_STD_CHRONO 1
|
||||
#cmakedefine HAVE_NULLPTR 1
|
||||
|
||||
#endif /* SCL_CF_H */
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef EXPPP_H
|
||||
#define EXPPP_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <sc_stdbool.h>
|
||||
|
||||
#include <sc_export.h>
|
||||
|
||||
|
||||
@@ -58,23 +58,12 @@ struct freelist_head {
|
||||
#endif
|
||||
};
|
||||
|
||||
char * nnew();
|
||||
|
||||
#include "error.h"
|
||||
|
||||
/***********************************************/
|
||||
/* space allocation macros with error package: */
|
||||
/***********************************************/
|
||||
|
||||
extern SC_EXPRESS_EXPORT int yylineno;
|
||||
|
||||
/** CALLOC grabs and initializes to all 0s space for the indicated
|
||||
* number of instances of the indicated type */
|
||||
#define CALLOC(ptr, num, type) \
|
||||
if (((ptr) = (type*)calloc((num), (unsigned)sizeof(type)))==NULL) { \
|
||||
fprintf(stderr,"fedex: out of space");\
|
||||
} else {}
|
||||
|
||||
SC_EXPRESS_EXPORT void _ALLOCinitialize( void );
|
||||
SC_EXPRESS_EXPORT void ALLOCinitialize( struct freelist_head * flh, unsigned int size, int alloc1, int alloc2 );
|
||||
SC_EXPRESS_EXPORT void ALLOC_destroy( struct freelist_head *, Freelist * );
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <sc_cf.h>
|
||||
#include <sc_export.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
#ifdef HAVE_STDBOOL_H
|
||||
# include <stdbool.h>
|
||||
#else
|
||||
# include <stdbool.h>
|
||||
# include <sc_stdbool.h>
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1900) && !defined(__cplusplus)
|
||||
@@ -96,8 +96,5 @@
|
||||
typedef void ( *voidFuncptr )();
|
||||
typedef int ( *intFuncptr )();
|
||||
|
||||
/* Option index - can we get rid of this? */
|
||||
extern SC_EXPRESS_EXPORT int sc_optind;
|
||||
|
||||
#endif /* BASIC_H */
|
||||
|
||||
|
||||
+6
-17
@@ -56,7 +56,7 @@
|
||||
/************/
|
||||
|
||||
typedef struct Hash_Table_ * Dictionary;
|
||||
typedef HashEntry DictionaryEntry;
|
||||
typedef struct Hash_Iterator_ DictionaryEntry;
|
||||
|
||||
/****************/
|
||||
/* modules used */
|
||||
@@ -71,27 +71,15 @@ typedef HashEntry DictionaryEntry;
|
||||
/********************/
|
||||
/* global variables */
|
||||
/********************/
|
||||
|
||||
/*TODO: surely this is not a good thing?! */
|
||||
extern SC_EXPRESS_EXPORT char DICT_type; /**< set as a side-effect of DICT lookup routines to type of object found */
|
||||
|
||||
/*******************************/
|
||||
/* macro function definitions */
|
||||
/*******************************/
|
||||
|
||||
#define DICTcreate(estimated_max_size) HASHcreate(estimated_max_size)
|
||||
/** should really can DICTdo_init and rename do_type_init to do_init! */
|
||||
#define DICTdo_init(dict,de) HASHlistinit((dict),(de))
|
||||
#define DICTdo_type_init(dict,de,t) HASHlistinit_by_type((dict),(de),(t))
|
||||
#define DICTdo_end(hash_entry) HASHlistend(hash_entry)
|
||||
|
||||
/** modify dictionary entry in-place */
|
||||
#define DICTchange(e,obj,sym,typ) { \
|
||||
(e)->data = (obj); \
|
||||
(e)->symbol = (sym); \
|
||||
(e)->type = (typ); \
|
||||
}
|
||||
#define DICTchange_type(e,typ) (e)->type = (typ)
|
||||
|
||||
#define DICTcreate(x) HASHcreate()
|
||||
#define DICTdo_init(dict,de,t) HASHdo_init((dict),(de),(t))
|
||||
|
||||
/***********************/
|
||||
/* function prototypes */
|
||||
@@ -100,8 +88,9 @@ extern SC_EXPRESS_EXPORT char DICT_type; /**< set as a side-effect of DICT look
|
||||
extern SC_EXPRESS_EXPORT void DICTinitialize( void );
|
||||
extern SC_EXPRESS_EXPORT void DICTcleanup( void );
|
||||
extern SC_EXPRESS_EXPORT int DICTdefine( Dictionary, char *, void *, Symbol *, char );
|
||||
extern SC_EXPRESS_EXPORT int DICT_define( Dictionary, char *, void *, Symbol *, char );
|
||||
extern SC_EXPRESS_EXPORT int DICTdefine_enum( Dictionary, char *, void *, Symbol *, char );
|
||||
extern SC_EXPRESS_EXPORT void DICTundefine( Dictionary, char * );
|
||||
/* TODO: could DICTlookup be implemented more generically using function pointers? */
|
||||
extern SC_EXPRESS_EXPORT void * DICTlookup( Dictionary, char * );
|
||||
extern SC_EXPRESS_EXPORT void * DICTlookup_symbol( Dictionary, char *, Symbol ** );
|
||||
extern SC_EXPRESS_EXPORT void * DICTdo( DictionaryEntry * );
|
||||
|
||||
@@ -144,11 +144,11 @@ extern SC_EXPRESS_EXPORT struct Scope_ * ENTITYcreate( struct Symbol_ * );
|
||||
extern SC_EXPRESS_EXPORT void ENTITYinitialize( void );
|
||||
extern SC_EXPRESS_EXPORT void ENTITYadd_attribute( struct Scope_ *, struct Variable_ * );
|
||||
extern SC_EXPRESS_EXPORT struct Scope_ * ENTITYcopy( struct Scope_ * );
|
||||
extern SC_EXPRESS_EXPORT Entity ENTITYfind_inherited_entity( struct Scope_ *, char *, int );
|
||||
extern SC_EXPRESS_EXPORT Variable ENTITYfind_inherited_attribute( struct Scope_ *, char *, struct Symbol_ ** );
|
||||
extern SC_EXPRESS_EXPORT Entity ENTITYfind_inherited_entity( struct Scope_ *, const char *, int );
|
||||
extern SC_EXPRESS_EXPORT Symbol *ENTITYfind_inherited_attribute( struct Scope_ *, const char *, struct Symbol_ ** );
|
||||
extern SC_EXPRESS_EXPORT Variable ENTITYresolve_attr_ref( Entity, Symbol *, Symbol * );
|
||||
extern SC_EXPRESS_EXPORT bool ENTITYhas_immediate_supertype( Entity, Entity );
|
||||
extern SC_EXPRESS_EXPORT Variable ENTITYget_named_attribute( Entity, char * );
|
||||
extern SC_EXPRESS_EXPORT Variable ENTITYget_named_attribute( Entity, const char * );
|
||||
extern SC_EXPRESS_EXPORT Linked_List ENTITYget_all_attributes( Entity );
|
||||
extern SC_EXPRESS_EXPORT bool ENTITYhas_supertype( Entity, Entity );
|
||||
extern SC_EXPRESS_EXPORT void ENTITYadd_instance( Entity, void *);
|
||||
|
||||
@@ -225,7 +225,7 @@ extern SC_EXPRESS_EXPORT void ERRORset_all_warnings( bool );
|
||||
extern SC_EXPRESS_EXPORT void ERRORsafe( jmp_buf env );
|
||||
extern SC_EXPRESS_EXPORT void ERRORunsafe( void );
|
||||
|
||||
extern SC_EXPRESS_EXPORT char * ERRORget_warnings_help(const char* prefix, const char *eol);
|
||||
extern SC_EXPRESS_EXPORT bool ERRORis_enabled(enum ErrorCode errnum);
|
||||
extern char * ERRORget_warnings_help(const char* prefix, const char *eol);
|
||||
extern bool ERRORis_enabled(enum ErrorCode errnum);
|
||||
|
||||
#endif /* ERROR_H */
|
||||
|
||||
@@ -128,6 +128,7 @@ typedef char * Binary;
|
||||
|
||||
/** these represent a different way of selecting classes of objects
|
||||
* these are particularly useful when looking for multiple types concurrently */
|
||||
|
||||
#define OBJ_TYPE_BITS 0x1
|
||||
#define OBJ_ENTITY_BITS 0x2
|
||||
#define OBJ_FUNCTION_BITS 0x4
|
||||
@@ -138,6 +139,10 @@ typedef char * Binary;
|
||||
#define OBJ_SCHEMA_BITS 0x80
|
||||
#define OBJ_VARIABLE_BITS 0x100
|
||||
#define OBJ_WHERE_BITS 0x200
|
||||
#define OBJ_ALIAS_BITS 0x400
|
||||
#define OBJ_REPEAT_BITS 0x800
|
||||
#define OBJ_QUERY_BITS 0x1000
|
||||
|
||||
|
||||
#define OBJ_ANYTHING_BITS 0x0fffffff
|
||||
#define OBJ_UNFINDABLE_BITS 0x10000000 /**< should never be found */
|
||||
@@ -148,6 +153,7 @@ typedef char * Binary;
|
||||
|
||||
/* OBJ_UNUSED should die, but until it does, allow it to work */
|
||||
#define OBJ_UNUSED_BITS OBJ_UNFINDABLE_BITS
|
||||
#define OBJ_DOCROOT_BITS OBJ_UNFINDABLE_BITS
|
||||
|
||||
#endif /*EXPRESS_BASIC_H*/
|
||||
|
||||
|
||||
@@ -62,7 +62,6 @@
|
||||
#include "alg.h"
|
||||
#include "schema.h"
|
||||
#include "lexact.h"
|
||||
#include "dict.h"
|
||||
|
||||
/************/
|
||||
/* typedefs */
|
||||
@@ -102,7 +101,7 @@ extern char EXPRESSgetopt_options[]; /* initialized elsewhere */
|
||||
extern SC_EXPRESS_EXPORT int ( *EXPRESSgetopt )( int, char * );
|
||||
extern SC_EXPRESS_EXPORT bool EXPRESSignore_duplicate_schemas;
|
||||
|
||||
extern SC_EXPRESS_EXPORT Dictionary EXPRESSbuiltins; /* procedures/functions */
|
||||
extern SC_EXPRESS_EXPORT Hash_Table EXPRESSbuiltins; /* procedures/functions */
|
||||
|
||||
extern SC_EXPRESS_EXPORT struct Scope_ * FUNC_NVL;
|
||||
extern SC_EXPRESS_EXPORT struct Scope_ * FUNC_USEDIN;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#ifndef __FACTORY_H_
|
||||
#define __FACTORY_H_
|
||||
|
||||
#include "sc_export.h"
|
||||
|
||||
SC_EXPRESS_EXPORT void FACTORYinitialize();
|
||||
void FACTORYinitialize();
|
||||
|
||||
#endif /* __FACTORY_H_ */
|
||||
|
||||
+31
-92
@@ -80,28 +80,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "basic.h" /* get basic definitions */
|
||||
#include "sc_export.h"
|
||||
|
||||
/*************/
|
||||
/* constants */
|
||||
/*************/
|
||||
|
||||
#define HASH_NULL (Hash_Table)NULL
|
||||
|
||||
#define SEGMENT_SIZE 256
|
||||
#define SEGMENT_SIZE_SHIFT 8 /**< log2(SEGMENT_SIZE) */
|
||||
#define DIRECTORY_SIZE 256
|
||||
#define DIRECTORY_SIZE_SHIFT 8 /**< log2(DIRECTORY_SIZE) */
|
||||
#define PRIME1 37
|
||||
#define PRIME2 1048583
|
||||
#define MAX_LOAD_FACTOR 5
|
||||
|
||||
/*****************/
|
||||
/* packages used */
|
||||
/*****************/
|
||||
|
||||
#include <sc_export.h>
|
||||
#include "alloc.h"
|
||||
#include "expbasic.h"
|
||||
#include "symbol.h"
|
||||
|
||||
/************/
|
||||
/* typedefs */
|
||||
@@ -109,96 +91,53 @@
|
||||
|
||||
typedef enum { HASH_FIND, HASH_INSERT, HASH_DELETE } Action;
|
||||
|
||||
typedef unsigned long Address;
|
||||
|
||||
/****************/
|
||||
/* abstractions */
|
||||
/****************/
|
||||
|
||||
typedef struct Element_ {
|
||||
char * key;
|
||||
char * data;
|
||||
struct Element_ * next;
|
||||
Symbol * symbol; /**< for debugging hash conflicts */
|
||||
char type; /**< user-supplied type */
|
||||
} * Element;
|
||||
typedef Symbol **Segment;
|
||||
|
||||
typedef Element * Segment;
|
||||
|
||||
typedef struct Hash_Table_ {
|
||||
#if 0
|
||||
int in_use; /**< If someone is traversing the hash table */
|
||||
#endif
|
||||
unsigned int p; /**< Next bucket to be split */
|
||||
unsigned int maxp; /**< upper bound on p during expansion */
|
||||
struct Hash_Table_ {
|
||||
unsigned int p; /**< Next bucket to be split */
|
||||
unsigned int maxp; /**< upper bound on p during expansion */
|
||||
unsigned int KeyCount; /**< current # keys */
|
||||
unsigned int SegmentCount; /**< current # segments */
|
||||
unsigned int MinLoadFactor;
|
||||
unsigned int MaxLoadFactor;
|
||||
Segment Directory[DIRECTORY_SIZE];
|
||||
} * Hash_Table;
|
||||
Segment *Directory;
|
||||
unsigned int DirectorySize;
|
||||
unsigned int SegmentSize;
|
||||
#ifdef HASH_DEBUG
|
||||
unsigned int HashCollisions;
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
unsigned int i; /**< segment index (i think) */
|
||||
unsigned int j; /**< key index in segment (ditto) */
|
||||
Element p; /**< usually the next element to be returned */
|
||||
typedef struct Hash_Table_ *Hash_Table;
|
||||
|
||||
struct Hash_Iterator_ {
|
||||
Hash_Table table;
|
||||
unsigned int hash;
|
||||
Symbol *p;
|
||||
char type;
|
||||
Element e; /**< originally thought of as a place for
|
||||
* the caller of HASHlist to temporarily stash the return value
|
||||
* to allow the caller (i.e., DICTdo) to be macroized, but now
|
||||
* conveniently used by HASHlist, which both stores the ultimate
|
||||
* value here as well as returns it via the return value of HASHlist
|
||||
*/
|
||||
} HashEntry;
|
||||
};
|
||||
|
||||
typedef struct Hash_Iterator_ Hash_Iterator;
|
||||
|
||||
/********************/
|
||||
/* global variables */
|
||||
/********************/
|
||||
|
||||
extern SC_EXPRESS_EXPORT struct freelist_head HASH_Table_fl;
|
||||
extern SC_EXPRESS_EXPORT struct freelist_head HASH_Element_fl;
|
||||
|
||||
/******************************/
|
||||
/* macro function definitions */
|
||||
/******************************/
|
||||
|
||||
/*
|
||||
** Fast arithmetic, relying on powers of 2
|
||||
*/
|
||||
|
||||
/**
|
||||
The centerline compiler was having problems with MUL and DIV. Where DIV
|
||||
was called like this DIV(NewAddress, SEGMENT_SIZE) it is now being called like
|
||||
DIV(NewAddress, SEGMENT_SIZE_SHIFT). The compiler was mentioning some kind of
|
||||
problem with ##. I wonder if maybe the precompiler was expanding SEGMENT_SIZE
|
||||
(which is also defined as a macro) before turning it into SEGMENT_SIZE_SHIFT.
|
||||
SEGMENT_SIZE and DIRECTORY_SIZE were used to call these macros. They are both
|
||||
defined to be 8 though so it seems these are always being used the same way.
|
||||
This change only seems to have affected hash.h and hash.c
|
||||
*/
|
||||
/* #define MUL(x,y) ((x) << (y##_SHIFT)) */
|
||||
#define MUL(x,y) ((x) << (y))
|
||||
/* #define DIV(x,y) ((x) >> (y##_SHIFT)) */
|
||||
#define DIV(x,y) ((x) >> (y))
|
||||
#define MOD(x,y) ((x) & ((y)-1))
|
||||
|
||||
#define HASH_Table_new() (struct Hash_Table_ *)ALLOC_new(&HASH_Table_fl)
|
||||
#define HASH_Table_destroy(x) ALLOC_destroy(&HASH_Table_fl,(Freelist *)x)
|
||||
#define HASH_Element_new() (struct Element_ *)ALLOC_new(&HASH_Element_fl)
|
||||
#define HASH_Element_destroy(x) ALLOC_destroy(&HASH_Element_fl,(Freelist *)(char *)x)
|
||||
|
||||
/***********************/
|
||||
/* function prototypes */
|
||||
/***********************/
|
||||
|
||||
extern SC_EXPRESS_EXPORT void HASHinitialize( void );
|
||||
extern SC_EXPRESS_EXPORT Hash_Table HASHcreate( unsigned );
|
||||
extern SC_EXPRESS_EXPORT Hash_Table HASHcopy( Hash_Table );
|
||||
extern SC_EXPRESS_EXPORT void HASHdestroy( Hash_Table );
|
||||
extern SC_EXPRESS_EXPORT Element HASHsearch( Hash_Table, Element, Action );
|
||||
extern SC_EXPRESS_EXPORT void HASHlistinit( Hash_Table, HashEntry * );
|
||||
extern SC_EXPRESS_EXPORT void HASHlistinit_by_type( Hash_Table, HashEntry *, char );
|
||||
extern SC_EXPRESS_EXPORT Element HASHlist( HashEntry * );
|
||||
extern SC_EXPRESS_EXPORT void HASHinitialize( void );
|
||||
extern SC_EXPRESS_EXPORT Hash_Table HASHcreate( void );
|
||||
extern SC_EXPRESS_EXPORT Hash_Table HASHcopy( Hash_Table );
|
||||
extern SC_EXPRESS_EXPORT void HASHdestroy( Hash_Table );
|
||||
extern SC_EXPRESS_EXPORT Symbol * HASHsearch( Hash_Table, Symbol, Action );
|
||||
extern SC_EXPRESS_EXPORT void HASHdelete( Hash_Table, Symbol * );
|
||||
extern SC_EXPRESS_EXPORT void HASHdo_init( Hash_Table, Hash_Iterator *, char );
|
||||
extern SC_EXPRESS_EXPORT Symbol * HASHdo( Hash_Iterator * );
|
||||
|
||||
#endif /*HASH_H*/
|
||||
#endif /* HASH_H */
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#ifndef __MEMORY_H
|
||||
#define __MEMORY_H
|
||||
|
||||
#include "sc_export.h"
|
||||
|
||||
SC_EXPRESS_EXPORT void MEMORYinitialize();
|
||||
void MEMORYinitialize();
|
||||
|
||||
#endif // __MEMORY_H
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef __SC_FWD_H
|
||||
#define __SC_FWD_H
|
||||
|
||||
struct Symbol_;
|
||||
typedef struct Symbol_ Symbol;
|
||||
|
||||
|
||||
#endif /* __SC_FWD_H */
|
||||
@@ -61,8 +61,8 @@
|
||||
/****************/
|
||||
|
||||
#include "alg.h"
|
||||
#include "dict.h"
|
||||
#include "entity.h"
|
||||
#include "hash.h"
|
||||
#include "linklist.h"
|
||||
|
||||
/***************************/
|
||||
@@ -91,8 +91,8 @@ struct Schema_ {
|
||||
* dictionaries into which are entered renames for each specific
|
||||
* object specified in a rename clause (even if it uses the same
|
||||
* name */
|
||||
Dictionary refdict;
|
||||
Dictionary usedict;
|
||||
Hash_Table refdict;
|
||||
Hash_Table usedict;
|
||||
|
||||
Linked_List use_schemas; /**< lists of schemas that are fully use'd
|
||||
* entries can be 0 if schemas weren't found during RENAMEresolve */
|
||||
@@ -133,7 +133,7 @@ extern SC_EXPRESS_EXPORT int __SCOPE_search_id;
|
||||
/* function prototypes */
|
||||
/***********************/
|
||||
|
||||
extern SC_EXPRESS_EXPORT Variable VARfind( Scope, char *, int );
|
||||
extern SC_EXPRESS_EXPORT Symbol * VARfind( Scope, const char * );
|
||||
extern SC_EXPRESS_EXPORT Schema SCHEMAcreate( void );
|
||||
extern SC_EXPRESS_EXPORT void SCHEMAinitialize( void );
|
||||
extern SC_EXPRESS_EXPORT void SCHEMAadd_use( Schema, Symbol *, Symbol *, Symbol * );
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
/****************/
|
||||
|
||||
#include <sc_export.h>
|
||||
#include "hash.h"
|
||||
#include "type.h"
|
||||
#include "variable.h"
|
||||
#include "entity.h"
|
||||
@@ -62,7 +63,6 @@
|
||||
/*****************/
|
||||
|
||||
#include "expbasic.h" /* get basic definitions */
|
||||
#include "dict.h"
|
||||
#include "symbol.h"
|
||||
|
||||
/***************************/
|
||||
@@ -82,7 +82,7 @@ struct Scope_ {
|
||||
char type; /* see above */
|
||||
ClientData clientData; /**< user may use this for any purpose */
|
||||
int search_id; /**< key to avoid searching this scope twice */
|
||||
Dictionary symbol_table, enum_table;
|
||||
Hash_Table symbol_table, enum_table;
|
||||
struct Scope_ * superscope;
|
||||
union {
|
||||
struct Procedure_ * proc;
|
||||
@@ -115,16 +115,16 @@ struct Scope_ {
|
||||
#define SCOPEput_clientData(s,d) ((s)->clientData = (d))
|
||||
|
||||
|
||||
#define SCOPEdo_types(s,t,de) DICTdo_type_init(s->symbol_table,&de,OBJ_TYPE);{\
|
||||
#define SCOPEdo_types(s,t,de) DICTdo_init(s->symbol_table,&de,OBJ_TYPE);{\
|
||||
Type t; \
|
||||
while (0 != (t = (Type)DICTdo(&de))) {
|
||||
#define SCOPEdo_entities(s,t,de) DICTdo_type_init(s->symbol_table,&de,OBJ_ENTITY); { \
|
||||
#define SCOPEdo_entities(s,t,de) DICTdo_init(s->symbol_table,&de,OBJ_ENTITY); { \
|
||||
Entity t; \
|
||||
while (0 != (t = (Entity)DICTdo(&de))) {
|
||||
#define SCOPEdo_functions(s,t,de) DICTdo_type_init(s->symbol_table,&de,OBJ_FUNCTION); { \
|
||||
#define SCOPEdo_functions(s,t,de) DICTdo_init(s->symbol_table,&de,OBJ_FUNCTION); { \
|
||||
Entity t; \
|
||||
while (0 != (t = (Entity)DICTdo(&de))) {
|
||||
#define SCOPEdo_rules(s,t,de) DICTdo_type_init(s->symbol_table,&de,OBJ_RULE); { \
|
||||
#define SCOPEdo_rules(s,t,de) DICTdo_init(s->symbol_table,&de,OBJ_RULE); { \
|
||||
Entity t; \
|
||||
while (0 != (t = (Entity)DICTdo(&de))) {
|
||||
|
||||
@@ -138,12 +138,12 @@ extern SC_EXPRESS_EXPORT struct Symbol_ * SCOPE_get_symbol( void * );
|
||||
extern SC_EXPRESS_EXPORT void SCOPE_get_entities( Scope, Linked_List );
|
||||
extern SC_EXPRESS_EXPORT Linked_List SCOPEget_entities( Scope );
|
||||
extern SC_EXPRESS_EXPORT Linked_List SCOPEget_entities_superclass_order( Scope );
|
||||
extern SC_EXPRESS_EXPORT void * SCOPEfind( Scope, char *, int );
|
||||
extern SC_EXPRESS_EXPORT Symbol * SCOPEfind( Scope, const char *, int );
|
||||
extern SC_EXPRESS_EXPORT void SCOPE_get_functions( Scope, Linked_List );
|
||||
extern SC_EXPRESS_EXPORT Linked_List SCOPEget_functions( Scope );
|
||||
extern SC_EXPRESS_EXPORT void SCOPE_get_rules( Scope, Linked_List );
|
||||
extern SC_EXPRESS_EXPORT Linked_List SCOPEget_rules( Scope );
|
||||
|
||||
void * SCOPE_find( Scope, char *, int );
|
||||
Symbol * SCOPE_find( Scope, const char *, int );
|
||||
|
||||
#endif /* SCOPE_H */
|
||||
|
||||
+16
-15
@@ -43,27 +43,30 @@
|
||||
/* packages used */
|
||||
/*****************/
|
||||
|
||||
#include <sc_export.h>
|
||||
#include "sc_export.h"
|
||||
|
||||
#include "basic.h" /* get basic definitions */
|
||||
#include "alloc.h"
|
||||
|
||||
/************/
|
||||
/* typedefs */
|
||||
/************/
|
||||
|
||||
typedef struct Symbol_ Symbol;
|
||||
|
||||
/***************************/
|
||||
/* hidden type definitions */
|
||||
/* type definitions */
|
||||
/***************************/
|
||||
|
||||
struct Symbol_ {
|
||||
char * name;
|
||||
const char * filename;
|
||||
const char *name;
|
||||
void *data; /* the AST for this symbol */
|
||||
char type; /* the OBJ_ type, see expbasic.h */
|
||||
int ref_tok; /* the lexer ref_type for this symbol */
|
||||
|
||||
const char *filename;
|
||||
int line;
|
||||
char resolved;
|
||||
char resolved; /* if imported TYPE or ENTITY is unresolved */
|
||||
|
||||
struct Symbol_ *next; /* symbol table clashes */
|
||||
};
|
||||
|
||||
typedef struct Symbol_ Symbol;
|
||||
|
||||
/****************/
|
||||
/* modules used */
|
||||
/****************/
|
||||
@@ -78,9 +81,7 @@ extern SC_EXPRESS_EXPORT struct freelist_head SYMBOL_fl;
|
||||
/* macro function definitions */
|
||||
/******************************/
|
||||
|
||||
#define SYMBOL_new() (struct Symbol_ *)ALLOC_new(&SYMBOL_fl)
|
||||
#define SYMBOL_destroy(x) ALLOC_destroy(&SYMBOL_fl,(Freelist *)x)
|
||||
|
||||
/* TODO: gets called from e.g. type.c, should be set by parser */
|
||||
#define SYMBOLset(obj) obj->symbol.line = yylineno; \
|
||||
obj->symbol.filename = current_filename
|
||||
|
||||
@@ -89,6 +90,6 @@ extern SC_EXPRESS_EXPORT struct freelist_head SYMBOL_fl;
|
||||
/***********************/
|
||||
|
||||
extern SC_EXPRESS_EXPORT void SYMBOLinitialize( void );
|
||||
SC_EXPRESS_EXPORT Symbol * SYMBOLcreate( char * name, int line, const char * filename );
|
||||
SC_EXPRESS_EXPORT Symbol * SYMBOLcreate( char * name, int type, int ref_tok, int line, const char * filename );
|
||||
|
||||
#endif /* SYMBOL_H */
|
||||
|
||||
@@ -129,7 +129,6 @@ typedef enum type_enum Class;
|
||||
/* modules used */
|
||||
/****************/
|
||||
|
||||
#include "dict.h"
|
||||
#include "entity.h"
|
||||
#include "expr.h"
|
||||
#include "scope.h"
|
||||
|
||||
@@ -127,6 +127,6 @@ extern SC_EXPRESS_EXPORT struct freelist_head VAR_fl;
|
||||
|
||||
extern SC_EXPRESS_EXPORT Variable VARcreate( Expression, Type );
|
||||
extern SC_EXPRESS_EXPORT void VARinitialize( void );
|
||||
extern SC_EXPRESS_EXPORT char * VARget_simple_name( Variable );
|
||||
extern SC_EXPRESS_EXPORT const char * VARget_simple_name( Variable );
|
||||
|
||||
#endif /* VARIABLE_H */
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#define SCL_CF_H
|
||||
|
||||
/**** Define statements for CMake ****/
|
||||
#cmakedefine SC_VERSION "@SC_VERSION@"
|
||||
#cmakedefine HAVE_NDIR_H 1
|
||||
#cmakedefine HAVE_STDINT_H 1
|
||||
#cmakedefine HAVE_SYS_STAT_H 1
|
||||
@@ -15,6 +14,7 @@
|
||||
#cmakedefine HAVE_IO_H 1
|
||||
|
||||
#cmakedefine SC_TRACE_FPRINTF 1
|
||||
#cmakedefine SC_MEMMGR_ENABLE_CHECKS 1
|
||||
|
||||
#cmakedefine HAVE_ABS 1
|
||||
#cmakedefine HAVE_MEMCPY 1
|
||||
@@ -0,0 +1,43 @@
|
||||
#ifndef STDBOOL_H_
|
||||
#define STDBOOL_H_
|
||||
|
||||
/**
|
||||
* stdbool.h - ISO C99 Boolean type
|
||||
* Author - Bill Chatfield
|
||||
* E-mail - bill underscore chatfield at yahoo dot com
|
||||
* Copyright - You are free to use for any purpose except illegal acts
|
||||
* Warrenty - None: don't blame me if it breaks something
|
||||
*
|
||||
* In ISO C99, stdbool.h is a standard header and _Bool is a keyword, but
|
||||
* some compilers don't offer these yet. This header file is an
|
||||
* implementation of the standard ISO C99 stdbool.h header file. It checks
|
||||
* for various compiler versions and defines things that are missing in
|
||||
* those versions.
|
||||
*
|
||||
* See http://predef.sourceforge.net/precomp.html for compile macros.
|
||||
*/
|
||||
|
||||
#ifndef __cplusplus
|
||||
|
||||
/**
|
||||
* Microsoft C/C++ version 14.00.50727.762, which comes with Visual C++ 2005,
|
||||
* and version 15.00.30729.01, which comes with Visual C++ 2008, do not
|
||||
* define _Bool.
|
||||
*/
|
||||
#if defined(_MSC_VER) && _MSC_VER<1800
|
||||
typedef int _Bool;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Define the Boolean macros only if they are not already defined.
|
||||
*/
|
||||
#ifndef __bool_true_false_are_defined
|
||||
#define bool _Bool
|
||||
#define false 0
|
||||
#define true 1
|
||||
#define __bool_true_false_are_defined 1
|
||||
#endif
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /*STDBOOL_H_*/
|
||||
@@ -0,0 +1,330 @@
|
||||
//summarize MSVC errors from an appveyor log
|
||||
// compile with 'go build summarize-appveyor-log.go'
|
||||
// takes 0 or 1 args; with 0, gets log from latest
|
||||
// build. with 1, uses that file as raw json-like log
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
headerKey = "Authorization"
|
||||
headerVal = "Bearer %s"
|
||||
projUrl = "https://ci.appveyor.com/api/projects/mpictor/stepcode"
|
||||
//"https://ci.appveyor.com/api/buildjobs/2rjxdv1rnb8jcg8y/log"
|
||||
logUrl = "https://ci.appveyor.com/api/buildjobs/%s/log"
|
||||
consoleUrl = "https://ci.appveyor.com/api/buildjobs/%s/console"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var rawlog io.ReadCloser
|
||||
var build string
|
||||
var err error
|
||||
if len(os.Args) == 2 {
|
||||
rawlog, build, err = processArgv()
|
||||
} else {
|
||||
rawlog, build, err = getLog()
|
||||
}
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "ERROR: %s\n", err)
|
||||
return
|
||||
}
|
||||
defer rawlog.Close()
|
||||
log := decodeConsole(rawlog)
|
||||
warns, errs := countMessages(log)
|
||||
fi, err := os.Create(fmt.Sprintf("appveyor-%s.smy", build))
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "ERROR: %s\n", err)
|
||||
return
|
||||
}
|
||||
printMessages("error", errs, fi)
|
||||
printMessages("warning", warns, fi)
|
||||
|
||||
fmt.Printf("done\n")
|
||||
|
||||
}
|
||||
|
||||
/* categorizes warnings and errors based upon the MSVC message number (i.e. C4244)
|
||||
* the regex will match lines like
|
||||
c:\projects\stepcode\src\base\sc_benchmark.h(45): warning C4251: 'benchmark::descr' : class 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' needs to have dll-interface to be used by clients of class 'benchmark' [C:\projects\STEPcode\build\src\base\base.vcxproj]
|
||||
[00:03:48] C:\projects\STEPcode\src\base\sc_benchmark.cc(61): warning C4244: '=' : conversion from 'SIZE_T' to 'long', possible loss of data [C:\projects\STEPcode\build\src\base\base.vcxproj]*
|
||||
*/
|
||||
func countMessages(log []string) (warns, errs map[string][]string) {
|
||||
warns = make(map[string][]string)
|
||||
errs = make(map[string][]string)
|
||||
fname := " *(.*)" // $1
|
||||
fline := `(?:\((\d+)\)| ): ` // $2 - either line number in parenthesis or a space, followed by a colon
|
||||
msgNr := `([A-Z]+\d+): ` // $3 - C4251, LNK2005, etc
|
||||
msgTxt := `([^\[]*) ` // $4
|
||||
tail := `\[[^\[\]]*\]`
|
||||
warnRe := regexp.MustCompile(fname + fline + `warning ` + msgNr + msgTxt + tail)
|
||||
errRe := regexp.MustCompile(fname + fline + `(?:fatal )?error ` + msgNr + msgTxt + tail)
|
||||
for _, line := range log {
|
||||
if warnRe.MatchString(line) {
|
||||
key := warnRe.ReplaceAllString(line, "$3")
|
||||
path := strings.ToLower(warnRe.ReplaceAllString(line, "$1:$2"))
|
||||
arr := warns[key]
|
||||
if arr == nil {
|
||||
arr = make([]string, 5)
|
||||
//detailed text as first string in array
|
||||
text := warnRe.ReplaceAllString(line, "$4")
|
||||
arr[0] = fmt.Sprintf("%s", text)
|
||||
}
|
||||
//eliminate duplicates
|
||||
match := false
|
||||
for _, l := range arr {
|
||||
if l == path {
|
||||
match = true
|
||||
}
|
||||
}
|
||||
if !match {
|
||||
warns[key] = append(arr, path)
|
||||
}
|
||||
} else if errRe.MatchString(line) {
|
||||
key := errRe.ReplaceAllString(line, "$3")
|
||||
path := strings.ToLower(errRe.ReplaceAllString(line, "$1:$2"))
|
||||
arr := errs[key]
|
||||
if arr == nil {
|
||||
arr = make([]string, 5)
|
||||
//detailed text as first string in array
|
||||
text := errRe.ReplaceAllString(line, "$4")
|
||||
arr[0] = fmt.Sprintf("%s", text)
|
||||
}
|
||||
//eliminate duplicates
|
||||
match := false
|
||||
for _, l := range arr {
|
||||
if l == path {
|
||||
match = true
|
||||
}
|
||||
}
|
||||
if !match {
|
||||
errs[key] = append(arr, path)
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func printMessages(typ string, m map[string][]string, w io.Writer) {
|
||||
//sort keys
|
||||
keys := make([]string, 0, len(m))
|
||||
for key := range m {
|
||||
keys = append(keys, key)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
for _, k := range keys {
|
||||
for i, l := range m[k] {
|
||||
//first string is an example, not a location
|
||||
if i == 0 {
|
||||
fmt.Fprintf(w, "%s %s (i.e. \"%s\")\n", typ, k, l)
|
||||
} else if len(l) > 1 { //not sure where blank lines are coming from...
|
||||
fmt.Fprintf(w, " >> %s\n", l)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//structs from http://json2struct.mervine.net/
|
||||
|
||||
//{"values":[{"i":0,"t":"Specify a project or solution file. The directory does not contain a project or solution file.\r\n","dt":"00:00:04","bg":12,"fg":15}]}
|
||||
type AppVeyorConsoleLines struct {
|
||||
Values []struct {
|
||||
I int `json:"i"`
|
||||
Text string `json:"t"`
|
||||
DateTime string `json:"dt"`
|
||||
BgColor int `json:"bg"`
|
||||
FgColor int `json:"fg"`
|
||||
}
|
||||
}
|
||||
type AppVeyorBuild struct {
|
||||
Build struct {
|
||||
/*BuildNumber int `json:"buildNumber"`*/
|
||||
Version string `json:"version"`
|
||||
Jobs []struct {
|
||||
JobID string `json:"jobId"`
|
||||
} `json:"jobs"`
|
||||
} `json:"build"`
|
||||
}
|
||||
|
||||
func splitAppend(log *[]string, blob string) {
|
||||
//blob = strings.Replace(blob,"\r\n", "\n",-1)
|
||||
blob = strings.Replace(blob, "\\", "/", -1)
|
||||
r := strings.NewReader(blob)
|
||||
unwrapScanner := bufio.NewScanner(r)
|
||||
for unwrapScanner.Scan() {
|
||||
txt := unwrapScanner.Text()
|
||||
//fmt.Printf("%s\n", txt)
|
||||
*log = append(*log, txt)
|
||||
}
|
||||
}
|
||||
|
||||
//calculate length of string without escape chars
|
||||
// func escapeLen(s string)(l int) {
|
||||
// //s = strings.Replace(s,"\\\\", "/",-1)
|
||||
// s = strings.Replace(s,"\\\"", "",-1)
|
||||
// s = strings.Replace(s,"\r\n", "RN",-1)
|
||||
// return len(s)
|
||||
// }
|
||||
|
||||
|
||||
//decode the almost-JSON console data from appveyor
|
||||
func decodeConsole(r io.Reader) (log []string) {
|
||||
wrapper := Wrap(r)
|
||||
dec := json.NewDecoder(wrapper)
|
||||
var consoleLines AppVeyorConsoleLines
|
||||
var err error
|
||||
var txtBlob string
|
||||
err = dec.Decode(&consoleLines)
|
||||
if err == io.EOF {
|
||||
err = nil
|
||||
}
|
||||
if err == nil {
|
||||
for _, l := range consoleLines.Values {
|
||||
txtBlob += l.Text
|
||||
//el := escapeLen(l.Text)
|
||||
//something inserts newlines at 229 chars (+\n\r == 231) (found in CMake output)
|
||||
lenTwoThreeOne := len(l.Text) == 231
|
||||
if lenTwoThreeOne {
|
||||
txtBlob = strings.TrimSuffix(txtBlob, "\r\n")
|
||||
}
|
||||
//something else starts new log lines at 1024 chars without inserting newlines (found in CTest error output)
|
||||
if len(l.Text) != 1024 && !lenTwoThreeOne {
|
||||
//fmt.Printf("sa for l %d, el %d\n", len(l.Text),el)
|
||||
splitAppend(&log, txtBlob)
|
||||
txtBlob = ""
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fmt.Printf("decode err %s\n", err)
|
||||
}
|
||||
if len(txtBlob) > 0 {
|
||||
splitAppend(&log, txtBlob)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func processArgv() (log io.ReadCloser, build string, err error) {
|
||||
fname := os.Args[1]
|
||||
if len(fname) < 14 {
|
||||
err = fmt.Errorf("Name arg '%s' too short. Run as '%s appveyor-NNN.log'", fname, os.Args[0])
|
||||
return
|
||||
}
|
||||
buildRe := regexp.MustCompile(`appveyor-(.+).log`)
|
||||
build = buildRe.ReplaceAllString(fname, "$1")
|
||||
if len(build) == 0 {
|
||||
err = fmt.Errorf("No build id in %s", fname)
|
||||
return
|
||||
}
|
||||
log, err = os.Open(fname)
|
||||
return
|
||||
}
|
||||
|
||||
func getLog() (log io.ReadCloser, build string, err error) {
|
||||
client := &http.Client{}
|
||||
req, err := http.NewRequest("GET", projUrl, nil)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
apikey := os.Getenv("APPVEYOR_API_KEY")
|
||||
//api key isn't necessary for read-only queries on public projects
|
||||
if len(apikey) > 0 {
|
||||
req.Header.Add(headerKey, fmt.Sprintf(headerVal, apikey))
|
||||
} //else {
|
||||
// fmt.Printf("Env var APPVEYOR_API_KEY is not set.")
|
||||
//}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
build, job := decodeProjInfo(resp.Body)
|
||||
fmt.Printf("build #%s, jobId %s\n", build, job)
|
||||
resp, err = http.Get(fmt.Sprintf(consoleUrl, job))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
logName := fmt.Sprintf("appveyor-%s.log", build)
|
||||
fi, err := os.Create(logName)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
_, err = io.Copy(fi, resp.Body)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
log, err = os.Open(logName)
|
||||
if err != nil {
|
||||
log = nil
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func decodeProjInfo(r io.Reader) (vers string, job string) {
|
||||
dec := json.NewDecoder(r)
|
||||
var av AppVeyorBuild
|
||||
err := dec.Decode(&av)
|
||||
if err != io.EOF && err != nil {
|
||||
fmt.Printf("err %s\n", err)
|
||||
return
|
||||
}
|
||||
if len(av.Build.Jobs) != 1 {
|
||||
return
|
||||
}
|
||||
vers = av.Build.Version
|
||||
job = av.Build.Jobs[0].JobID
|
||||
return
|
||||
}
|
||||
|
||||
//wrap a reader, modifying content to make the json decoder happy
|
||||
//only tested with data from appveyor console
|
||||
type jsonWrapper struct {
|
||||
source io.Reader
|
||||
begin bool
|
||||
end bool
|
||||
}
|
||||
|
||||
func Wrap(r io.Reader) *jsonWrapper {
|
||||
return &jsonWrapper{
|
||||
source: r,
|
||||
begin: true,
|
||||
}
|
||||
}
|
||||
|
||||
// func nonNeg(n int) (int) {
|
||||
// if n < 0 {
|
||||
// return 0
|
||||
// }
|
||||
// return n
|
||||
// }
|
||||
|
||||
func (w *jsonWrapper) Read(p []byte) (n int, err error) {
|
||||
if w.end {
|
||||
return 0, io.EOF
|
||||
}
|
||||
if w.begin {
|
||||
w.begin = false
|
||||
n = copy(p, []byte(`{"values":[`))
|
||||
}
|
||||
m, err := w.source.Read(p[n:])
|
||||
n += m
|
||||
if err == io.EOF {
|
||||
w.end = true
|
||||
if n < len(p) {
|
||||
n = copy(p, []byte(`{"dummy":"data"}]}`))
|
||||
} else {
|
||||
err = fmt.Errorf("No room to terminate JSON struct with '}'\n")
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// kate: indent-width 8; space-indent off; replace-tabs off; replace-tabs-save off; replace-trailing-space-save on; remove-trailing-space on; tab-intent on; tab-width 8; show-tabs off;
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
if (${SC_MEMMGR_ENABLE_CHECKS})
|
||||
add_definitions(-DSC_MEMMGR_ENABLE_CHECKS)
|
||||
endif()
|
||||
|
||||
SC_ADDLIB(auxlib STATIC SOURCES bstrlib.c)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,321 @@
|
||||
/*
|
||||
* This source file is part of the bstring string library. This code was
|
||||
* written by Paul Hsieh in 2002-2015, and is covered by the BSD open source
|
||||
* license and the GPL. Refer to the accompanying documentation for details
|
||||
* on usage and license.
|
||||
*/
|
||||
|
||||
/*
|
||||
* bstrlib.h
|
||||
*
|
||||
* This file is the interface for the core bstring functions.
|
||||
*/
|
||||
|
||||
#ifndef BSTRLIB_INCLUDE
|
||||
#define BSTRLIB_INCLUDE
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#if !defined (BSTRLIB_VSNP_OK) && !defined (BSTRLIB_NOVSNP)
|
||||
# if defined (__TURBOC__) && !defined (__BORLANDC__)
|
||||
# define BSTRLIB_NOVSNP
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define BSTR_ERR (-1)
|
||||
#define BSTR_OK (0)
|
||||
#define BSTR_BS_BUFF_LENGTH_GET (0)
|
||||
|
||||
typedef struct tagbstring * bstring;
|
||||
typedef const struct tagbstring * const_bstring;
|
||||
|
||||
/* Version */
|
||||
#define BSTR_VER_MAJOR 1
|
||||
#define BSTR_VER_MINOR 0
|
||||
#define BSTR_VER_UPDATE 0
|
||||
|
||||
/* Copy functions */
|
||||
#define cstr2bstr bfromcstr
|
||||
extern bstring bfromcstr (const char * str);
|
||||
extern bstring bfromcstralloc (int mlen, const char * str);
|
||||
extern bstring bfromcstrrangealloc (int minl, int maxl, const char* str);
|
||||
extern bstring blk2bstr (const void * blk, int len);
|
||||
extern char * bstr2cstr (const_bstring s, char z);
|
||||
extern int bcstrfree (char * s);
|
||||
extern bstring bstrcpy (const_bstring b1);
|
||||
extern int bassign (bstring a, const_bstring b);
|
||||
extern int bassignmidstr (bstring a, const_bstring b, int left, int len);
|
||||
extern int bassigncstr (bstring a, const char * str);
|
||||
extern int bassignblk (bstring a, const void * s, int len);
|
||||
|
||||
/* Destroy function */
|
||||
extern int bdestroy (bstring b);
|
||||
|
||||
/* Space allocation hinting functions */
|
||||
extern int balloc (bstring s, int len);
|
||||
extern int ballocmin (bstring b, int len);
|
||||
|
||||
/* Substring extraction */
|
||||
extern bstring bmidstr (const_bstring b, int left, int len);
|
||||
|
||||
/* Various standard manipulations */
|
||||
extern int bconcat (bstring b0, const_bstring b1);
|
||||
extern int bconchar (bstring b0, char c);
|
||||
extern int bcatcstr (bstring b, const char * s);
|
||||
extern int bcatblk (bstring b, const void * s, int len);
|
||||
extern int binsert (bstring s1, int pos, const_bstring s2, unsigned char fill);
|
||||
extern int binsertblk (bstring s1, int pos, const void * s2, int len, unsigned char fill);
|
||||
extern int binsertch (bstring s1, int pos, int len, unsigned char fill);
|
||||
extern int breplace (bstring b1, int pos, int len, const_bstring b2, unsigned char fill);
|
||||
extern int bdelete (bstring s1, int pos, int len);
|
||||
extern int bsetstr (bstring b0, int pos, const_bstring b1, unsigned char fill);
|
||||
extern int btrunc (bstring b, int n);
|
||||
|
||||
/* Scan/search functions */
|
||||
extern int bstricmp (const_bstring b0, const_bstring b1);
|
||||
extern int bstrnicmp (const_bstring b0, const_bstring b1, int n);
|
||||
extern int biseqcaseless (const_bstring b0, const_bstring b1);
|
||||
extern int biseqcaselessblk (const_bstring b, const void * blk, int len);
|
||||
extern int bisstemeqcaselessblk (const_bstring b0, const void * blk, int len);
|
||||
extern int biseq (const_bstring b0, const_bstring b1);
|
||||
extern int biseqblk (const_bstring b, const void * blk, int len);
|
||||
extern int bisstemeqblk (const_bstring b0, const void * blk, int len);
|
||||
extern int biseqcstr (const_bstring b, const char * s);
|
||||
extern int biseqcstrcaseless (const_bstring b, const char * s);
|
||||
extern int bstrcmp (const_bstring b0, const_bstring b1);
|
||||
extern int bstrncmp (const_bstring b0, const_bstring b1, int n);
|
||||
extern int binstr (const_bstring s1, int pos, const_bstring s2);
|
||||
extern int binstrr (const_bstring s1, int pos, const_bstring s2);
|
||||
extern int binstrcaseless (const_bstring s1, int pos, const_bstring s2);
|
||||
extern int binstrrcaseless (const_bstring s1, int pos, const_bstring s2);
|
||||
extern int bstrchrp (const_bstring b, int c, int pos);
|
||||
extern int bstrrchrp (const_bstring b, int c, int pos);
|
||||
#define bstrchr(b,c) bstrchrp ((b), (c), 0)
|
||||
#define bstrrchr(b,c) bstrrchrp ((b), (c), blength(b)-1)
|
||||
extern int binchr (const_bstring b0, int pos, const_bstring b1);
|
||||
extern int binchrr (const_bstring b0, int pos, const_bstring b1);
|
||||
extern int bninchr (const_bstring b0, int pos, const_bstring b1);
|
||||
extern int bninchrr (const_bstring b0, int pos, const_bstring b1);
|
||||
extern int bfindreplace (bstring b, const_bstring find, const_bstring repl, int pos);
|
||||
extern int bfindreplacecaseless (bstring b, const_bstring find, const_bstring repl, int pos);
|
||||
|
||||
/* List of string container functions */
|
||||
struct bstrList {
|
||||
int qty, mlen;
|
||||
bstring * entry;
|
||||
};
|
||||
extern struct bstrList * bstrListCreate (void);
|
||||
extern int bstrListDestroy (struct bstrList * sl);
|
||||
extern int bstrListAlloc (struct bstrList * sl, int msz);
|
||||
extern int bstrListAllocMin (struct bstrList * sl, int msz);
|
||||
|
||||
/* String split and join functions */
|
||||
extern struct bstrList * bsplit (const_bstring str, unsigned char splitChar);
|
||||
extern struct bstrList * bsplits (const_bstring str, const_bstring splitStr);
|
||||
extern struct bstrList * bsplitstr (const_bstring str, const_bstring splitStr);
|
||||
extern bstring bjoin (const struct bstrList * bl, const_bstring sep);
|
||||
extern bstring bjoinblk (const struct bstrList * bl, const void * s, int len);
|
||||
extern int bsplitcb (const_bstring str, unsigned char splitChar, int pos,
|
||||
int (* cb) (void * parm, int ofs, int len), void * parm);
|
||||
extern int bsplitscb (const_bstring str, const_bstring splitStr, int pos,
|
||||
int (* cb) (void * parm, int ofs, int len), void * parm);
|
||||
extern int bsplitstrcb (const_bstring str, const_bstring splitStr, int pos,
|
||||
int (* cb) (void * parm, int ofs, int len), void * parm);
|
||||
|
||||
/* Miscellaneous functions */
|
||||
extern int bpattern (bstring b, int len);
|
||||
extern int btoupper (bstring b);
|
||||
extern int btolower (bstring b);
|
||||
extern int bltrimws (bstring b);
|
||||
extern int brtrimws (bstring b);
|
||||
extern int btrimws (bstring b);
|
||||
|
||||
#if !defined (BSTRLIB_NOVSNP)
|
||||
extern bstring bformat (const char * fmt, ...);
|
||||
extern int bformata (bstring b, const char * fmt, ...);
|
||||
extern int bassignformat (bstring b, const char * fmt, ...);
|
||||
extern int bvcformata (bstring b, int count, const char * fmt, va_list arglist);
|
||||
|
||||
#define bvformata(ret, b, fmt, lastarg) { \
|
||||
bstring bstrtmp_b = (b); \
|
||||
const char * bstrtmp_fmt = (fmt); \
|
||||
int bstrtmp_r = BSTR_ERR, bstrtmp_sz = 16; \
|
||||
for (;;) { \
|
||||
va_list bstrtmp_arglist; \
|
||||
va_start (bstrtmp_arglist, lastarg); \
|
||||
bstrtmp_r = bvcformata (bstrtmp_b, bstrtmp_sz, bstrtmp_fmt, bstrtmp_arglist); \
|
||||
va_end (bstrtmp_arglist); \
|
||||
if (bstrtmp_r >= 0) { /* Everything went ok */ \
|
||||
bstrtmp_r = BSTR_OK; \
|
||||
break; \
|
||||
} else if (-bstrtmp_r <= bstrtmp_sz) { /* A real error? */ \
|
||||
bstrtmp_r = BSTR_ERR; \
|
||||
break; \
|
||||
} \
|
||||
bstrtmp_sz = -bstrtmp_r; /* Doubled or target size */ \
|
||||
} \
|
||||
ret = bstrtmp_r; \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
typedef int (*bNgetc) (void *parm);
|
||||
typedef size_t (* bNread) (void *buff, size_t elsize, size_t nelem, void *parm);
|
||||
|
||||
/* Input functions */
|
||||
extern bstring bgets (bNgetc getcPtr, void * parm, char terminator);
|
||||
extern bstring bread (bNread readPtr, void * parm);
|
||||
extern int bgetsa (bstring b, bNgetc getcPtr, void * parm, char terminator);
|
||||
extern int bassigngets (bstring b, bNgetc getcPtr, void * parm, char terminator);
|
||||
extern int breada (bstring b, bNread readPtr, void * parm);
|
||||
|
||||
/* Stream functions */
|
||||
extern struct bStream * bsopen (bNread readPtr, void * parm);
|
||||
extern void * bsclose (struct bStream * s);
|
||||
extern int bsbufflength (struct bStream * s, int sz);
|
||||
extern int bsreadln (bstring b, struct bStream * s, char terminator);
|
||||
extern int bsreadlns (bstring r, struct bStream * s, const_bstring term);
|
||||
extern int bsread (bstring b, struct bStream * s, int n);
|
||||
extern int bsreadlna (bstring b, struct bStream * s, char terminator);
|
||||
extern int bsreadlnsa (bstring r, struct bStream * s, const_bstring term);
|
||||
extern int bsreada (bstring b, struct bStream * s, int n);
|
||||
extern int bsunread (struct bStream * s, const_bstring b);
|
||||
extern int bspeek (bstring r, const struct bStream * s);
|
||||
extern int bssplitscb (struct bStream * s, const_bstring splitStr,
|
||||
int (* cb) (void * parm, int ofs, const_bstring entry), void * parm);
|
||||
extern int bssplitstrcb (struct bStream * s, const_bstring splitStr,
|
||||
int (* cb) (void * parm, int ofs, const_bstring entry), void * parm);
|
||||
extern int bseof (const struct bStream * s);
|
||||
|
||||
struct tagbstring {
|
||||
int mlen;
|
||||
int slen;
|
||||
unsigned char * data;
|
||||
};
|
||||
|
||||
/* Accessor macros */
|
||||
#define blengthe(b, e) (((b) == (void *)0 || (b)->slen < 0) ? (int)(e) : ((b)->slen))
|
||||
#define blength(b) (blengthe ((b), 0))
|
||||
#define bdataofse(b, o, e) (((b) == (void *)0 || (b)->data == (void*)0) ? (char *)(e) : ((char *)(b)->data) + (o))
|
||||
#define bdataofs(b, o) (bdataofse ((b), (o), (void *)0))
|
||||
#define bdatae(b, e) (bdataofse (b, 0, e))
|
||||
#define bdata(b) (bdataofs (b, 0))
|
||||
#define bchare(b, p, e) ((((unsigned)(p)) < (unsigned)blength(b)) ? ((b)->data[(p)]) : (e))
|
||||
#define bchar(b, p) bchare ((b), (p), '\0')
|
||||
|
||||
/* Static constant string initialization macro */
|
||||
#define bsStaticMlen(q,m) {(m), (int) sizeof(q)-1, (unsigned char *) ("" q "")}
|
||||
#if defined(_MSC_VER)
|
||||
# define bsStatic(q) bsStaticMlen(q,-32)
|
||||
#endif
|
||||
#ifndef bsStatic
|
||||
# define bsStatic(q) bsStaticMlen(q,-__LINE__)
|
||||
#endif
|
||||
|
||||
/* Static constant block parameter pair */
|
||||
#define bsStaticBlkParms(q) ((void *)("" q "")), ((int) sizeof(q)-1)
|
||||
|
||||
#define bcatStatic(b,s) ((bcatblk)((b), bsStaticBlkParms(s)))
|
||||
#define bfromStatic(s) ((blk2bstr)(bsStaticBlkParms(s)))
|
||||
#define bassignStatic(b,s) ((bassignblk)((b), bsStaticBlkParms(s)))
|
||||
#define binsertStatic(b,p,s,f) ((binsertblk)((b), (p), bsStaticBlkParms(s), (f)))
|
||||
#define bjoinStatic(b,s) ((bjoinblk)((b), bsStaticBlkParms(s)))
|
||||
#define biseqStatic(b,s) ((biseqblk)((b), bsStaticBlkParms(s)))
|
||||
#define bisstemeqStatic(b,s) ((bisstemeqblk)((b), bsStaticBlkParms(s)))
|
||||
#define biseqcaselessStatic(b,s) ((biseqcaselessblk)((b), bsStaticBlkParms(s)))
|
||||
#define bisstemeqcaselessStatic(b,s) ((bisstemeqcaselessblk)((b), bsStaticBlkParms(s)))
|
||||
|
||||
/* Reference building macros */
|
||||
#define cstr2tbstr btfromcstr
|
||||
#define btfromcstr(t,s) { \
|
||||
(t).data = (unsigned char *) (s); \
|
||||
(t).slen = ((t).data) ? ((int) (strlen) ((char *)(t).data)) : 0; \
|
||||
(t).mlen = -1; \
|
||||
}
|
||||
#define blk2tbstr(t,s,l) { \
|
||||
(t).data = (unsigned char *) (s); \
|
||||
(t).slen = l; \
|
||||
(t).mlen = -1; \
|
||||
}
|
||||
#define btfromblk(t,s,l) blk2tbstr(t,s,l)
|
||||
#define bmid2tbstr(t,b,p,l) { \
|
||||
const_bstring bstrtmp_s = (b); \
|
||||
if (bstrtmp_s && bstrtmp_s->data && bstrtmp_s->slen >= 0) { \
|
||||
int bstrtmp_left = (p); \
|
||||
int bstrtmp_len = (l); \
|
||||
if (bstrtmp_left < 0) { \
|
||||
bstrtmp_len += bstrtmp_left; \
|
||||
bstrtmp_left = 0; \
|
||||
} \
|
||||
if (bstrtmp_len > bstrtmp_s->slen - bstrtmp_left) \
|
||||
bstrtmp_len = bstrtmp_s->slen - bstrtmp_left; \
|
||||
if (bstrtmp_len <= 0) { \
|
||||
(t).data = (unsigned char *)""; \
|
||||
(t).slen = 0; \
|
||||
} else { \
|
||||
(t).data = bstrtmp_s->data + bstrtmp_left; \
|
||||
(t).slen = bstrtmp_len; \
|
||||
} \
|
||||
} else { \
|
||||
(t).data = (unsigned char *)""; \
|
||||
(t).slen = 0; \
|
||||
} \
|
||||
(t).mlen = -__LINE__; \
|
||||
}
|
||||
#define btfromblkltrimws(t,s,l) { \
|
||||
int bstrtmp_idx = 0, bstrtmp_len = (l); \
|
||||
unsigned char * bstrtmp_s = (s); \
|
||||
if (bstrtmp_s && bstrtmp_len >= 0) { \
|
||||
for (; bstrtmp_idx < bstrtmp_len; bstrtmp_idx++) { \
|
||||
if (!isspace (bstrtmp_s[bstrtmp_idx])) break; \
|
||||
} \
|
||||
} \
|
||||
(t).data = bstrtmp_s + bstrtmp_idx; \
|
||||
(t).slen = bstrtmp_len - bstrtmp_idx; \
|
||||
(t).mlen = -__LINE__; \
|
||||
}
|
||||
#define btfromblkrtrimws(t,s,l) { \
|
||||
int bstrtmp_len = (l) - 1; \
|
||||
unsigned char * bstrtmp_s = (s); \
|
||||
if (bstrtmp_s && bstrtmp_len >= 0) { \
|
||||
for (; bstrtmp_len >= 0; bstrtmp_len--) { \
|
||||
if (!isspace (bstrtmp_s[bstrtmp_len])) break; \
|
||||
} \
|
||||
} \
|
||||
(t).data = bstrtmp_s; \
|
||||
(t).slen = bstrtmp_len + 1; \
|
||||
(t).mlen = -__LINE__; \
|
||||
}
|
||||
#define btfromblktrimws(t,s,l) { \
|
||||
int bstrtmp_idx = 0, bstrtmp_len = (l) - 1; \
|
||||
unsigned char * bstrtmp_s = (s); \
|
||||
if (bstrtmp_s && bstrtmp_len >= 0) { \
|
||||
for (; bstrtmp_idx <= bstrtmp_len; bstrtmp_idx++) { \
|
||||
if (!isspace (bstrtmp_s[bstrtmp_idx])) break; \
|
||||
} \
|
||||
for (; bstrtmp_len >= bstrtmp_idx; bstrtmp_len--) { \
|
||||
if (!isspace (bstrtmp_s[bstrtmp_len])) break; \
|
||||
} \
|
||||
} \
|
||||
(t).data = bstrtmp_s + bstrtmp_idx; \
|
||||
(t).slen = bstrtmp_len + 1 - bstrtmp_idx; \
|
||||
(t).mlen = -__LINE__; \
|
||||
}
|
||||
|
||||
/* Write protection macros */
|
||||
#define bwriteprotect(t) { if ((t).mlen >= 0) (t).mlen = -1; }
|
||||
#define bwriteallow(t) { if ((t).mlen == -1) (t).mlen = (t).slen + ((t).slen == 0); }
|
||||
#define biswriteprotected(t) ((t).mlen <= 0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,73 @@
|
||||
|
||||
set(SC_BASE_SOURCES
|
||||
sc_memmgr.cc
|
||||
sc_trace_fprintf.c
|
||||
sc_getopt.cc
|
||||
sc_benchmark.cc
|
||||
sc_mkdir.c
|
||||
path2str.c
|
||||
judy/src/judy.c
|
||||
)
|
||||
|
||||
set(SC_BASE_HDRS
|
||||
sc_benchmark.h
|
||||
sc_memmgr.h
|
||||
sc_getopt.h
|
||||
sc_trace_fprintf.h
|
||||
sc_mkdir.h
|
||||
sc_nullptr.h
|
||||
path2str.h
|
||||
judy/src/judy.h
|
||||
judy/src/judyLArray.h
|
||||
judy/src/judyL2Array.h
|
||||
judy/src/judySArray.h
|
||||
judy/src/judyS2Array.h
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/judy/src
|
||||
)
|
||||
|
||||
if($CACHE{SC_MEMMGR_ENABLE_CHECKS})
|
||||
add_definitions(-DSC_MEMMGR_ENABLE_CHECKS)
|
||||
endif()
|
||||
|
||||
if($CACHE{SC_BUILD_SHARED_LIBS})
|
||||
SC_ADDLIB(base SHARED SOURCES ${SC_BASE_SOURCES})
|
||||
if(WIN32)
|
||||
target_link_libraries(base psapi)
|
||||
target_compile_definitions(base PRIVATE SC_BASE_DLL_EXPORTS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if($CACHE{SC_BUILD_STATIC_LIBS})
|
||||
SC_ADDLIB(base-static STATIC SOURCES ${SC_BASE_SOURCES})
|
||||
if(WIN32)
|
||||
target_link_libraries(base-static psapi)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/judy/src")
|
||||
message("Judy array source code not found. Downloading (don't sweat, it's public domain)...")
|
||||
file(DOWNLOAD "http://github.com/mpictor/judy-template/archive/master.tar.gz"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/judy.tar.gz" SHOW_PROGRESS)
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} -E tar xzf "${CMAKE_CURRENT_SOURCE_DIR}/judy.tar.gz"
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/"
|
||||
)
|
||||
file(RENAME judy-template-master judy)
|
||||
file(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/judy.tar.gz")
|
||||
message("Judy array source code extracted.")
|
||||
endif(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/judy/src")
|
||||
|
||||
install(FILES ${SC_BASE_HDRS}
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/base)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
cmake_minimum_required(VERSION 3.6.3)
|
||||
project( JudyTemplates )
|
||||
|
||||
if( NOT DEFINED CMAKE_BUILD_TYPE )
|
||||
@@ -1080,7 +1080,7 @@ JudySlot * judy_prv( Judy * judy ) {
|
||||
// returning previous entry.
|
||||
|
||||
JudySlot * judy_del( Judy * judy ) {
|
||||
int slot, off, size, type;
|
||||
int slot, off, size, type, high;
|
||||
JudySlot * table, *inner;
|
||||
JudySlot next, *node;
|
||||
int keysize, cnt;
|
||||
@@ -1133,6 +1133,7 @@ JudySlot * judy_del( Judy * judy ) {
|
||||
table = ( JudySlot * )( next & JUDY_mask );
|
||||
inner = ( JudySlot * )( table[slot >> 4] & JUDY_mask );
|
||||
inner[slot & 0x0F] = 0;
|
||||
high = slot & 0xF0;
|
||||
|
||||
for( cnt = 16; cnt--; )
|
||||
if( inner[cnt] ) {
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
#include "path2str.h"
|
||||
#include "sc_memmgr.h"
|
||||
#include <string.h>
|
||||
|
||||
/* for windows, rewrite backslashes in paths
|
||||
* that will be written to generated code
|
||||
*/
|
||||
const char * path2str_fn( const char * fileMacro ) {
|
||||
static char * result = 0;
|
||||
static size_t rlen = 0;
|
||||
char * p;
|
||||
if( rlen < strlen( fileMacro ) ) {
|
||||
if( result ) {
|
||||
sc_free( result );
|
||||
}
|
||||
rlen = strlen( fileMacro );
|
||||
result = ( char * )sc_malloc( rlen * sizeof( char ) + 1 );
|
||||
}
|
||||
strcpy( result, fileMacro );
|
||||
p = result;
|
||||
while( *p ) {
|
||||
if( *p == '\\' ) {
|
||||
*p = '/';
|
||||
}
|
||||
p++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef PATH2STR_H
|
||||
#define PATH2STR_H
|
||||
|
||||
#include <sc_export.h>
|
||||
|
||||
/** windows only: rewrite backslashes in paths as forward slashes
|
||||
* call as path2str(__FILE__) to take advantage of macro
|
||||
*
|
||||
* silence "unknown escape sequence" warning when contents of __FILE__
|
||||
* are fprintf'd into string in generated code
|
||||
*/
|
||||
SC_BASE_EXPORT const char * path2str_fn( const char * fileMacro );
|
||||
|
||||
#ifdef _WIN32
|
||||
# define path2str(path) path2str_fn(path)
|
||||
#else
|
||||
# define path2str(path) path
|
||||
#endif
|
||||
|
||||
#endif /* PATH2STR_H */
|
||||
@@ -1,6 +1,7 @@
|
||||
/// \file sc_benchmark.cc memory info, timers, etc for benchmarking
|
||||
|
||||
#include "./sc_benchmark.h"
|
||||
#include "sc_benchmark.h"
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
@@ -2,11 +2,14 @@
|
||||
#define SC_BENCHMARK_H
|
||||
/// \file sc_benchmark.h memory info, timers, etc for benchmarking
|
||||
|
||||
#include "sc_export.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <iostream>
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
|
||||
#include "sc_memmgr.h"
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@@ -20,7 +23,7 @@ extern "C" {
|
||||
*
|
||||
* not yet implemented for OSX or Windows.
|
||||
*/
|
||||
benchVals getMemAndTime( );
|
||||
SC_BASE_EXPORT benchVals getMemAndTime( );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
@@ -36,7 +39,7 @@ extern "C" {
|
||||
* depends on getMemAndTime() above - may not work on all platforms.
|
||||
*/
|
||||
|
||||
class benchmark {
|
||||
class SC_BASE_EXPORT benchmark {
|
||||
protected:
|
||||
benchVals initialVals, laterVals;
|
||||
#ifdef _MSC_VER
|
||||
@@ -0,0 +1,214 @@
|
||||
/****** RENAMED from xgetopt.cc to sc_getopt.cc ***********/
|
||||
|
||||
// XGetopt.cpp Version 1.2
|
||||
//
|
||||
// Author: Hans Dietrich
|
||||
// hdietrich2@hotmail.com
|
||||
//
|
||||
// Description:
|
||||
// XGetopt.cpp implements sc_getopt(), a function to parse command lines.
|
||||
//
|
||||
// History
|
||||
// Version 1.2 - 2003 May 17
|
||||
// - Added Unicode support
|
||||
//
|
||||
// Version 1.1 - 2002 March 10
|
||||
// - Added example to XGetopt.cpp module header
|
||||
//
|
||||
// This software is released into the public domain.
|
||||
// You are free to use it in any way you like.
|
||||
//
|
||||
// This software is provided "as is" with no expressed
|
||||
// or implied warranty. I accept no liability for any
|
||||
// damage or loss of business that this software may cause.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// if you are using precompiled headers then include this line:
|
||||
//#include "stdafx.h"
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// if you are not using precompiled headers then include these lines:
|
||||
//#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "sc_getopt.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// X G e t o p t . c p p
|
||||
//
|
||||
//
|
||||
// NAME
|
||||
// sc_getopt -- parse command line options
|
||||
//
|
||||
// SYNOPSIS
|
||||
// int sc_getopt(int argc, char *argv[], char *optstring)
|
||||
//
|
||||
// extern char *sc_optarg;
|
||||
// extern int sc_optind;
|
||||
//
|
||||
// DESCRIPTION
|
||||
// The sc_getopt() function parses the command line arguments. Its
|
||||
// arguments argc and argv are the argument count and array as
|
||||
// passed into the application on program invocation. In the case
|
||||
// of Visual C++ programs, argc and argv are available via the
|
||||
// variables __argc and __argv (double underscores), respectively.
|
||||
// sc_getopt returns the next option letter in argv that matches a
|
||||
// letter in optstring. (Note: Unicode programs should use
|
||||
// __targv instead of __argv. Also, all character and string
|
||||
// literals should be enclosed in _T( ) ).
|
||||
//
|
||||
// optstring is a string of recognized option letters; if a letter
|
||||
// is followed by a colon, the option is expected to have an argument
|
||||
// that may or may not be separated from it by white space. sc_optarg
|
||||
// is set to point to the start of the option argument on return from
|
||||
// sc_getopt.
|
||||
//
|
||||
// Option letters may be combined, e.g., "-ab" is equivalent to
|
||||
// "-a -b". Option letters are case sensitive.
|
||||
//
|
||||
// sc_getopt places in the external variable sc_optind the argv index
|
||||
// of the next argument to be processed. sc_optind is initialized
|
||||
// to 0 before the first call to sc_getopt.
|
||||
//
|
||||
// When all options have been processed (i.e., up to the first
|
||||
// non-option argument), sc_getopt returns EOF, sc_optarg will point
|
||||
// to the argument, and sc_optind will be set to the argv index of
|
||||
// the argument. If there are no non-option arguments, sc_optarg
|
||||
// will be set to NULL.
|
||||
//
|
||||
// The special option "--" may be used to delimit the end of the
|
||||
// options; EOF will be returned, and "--" (and everything after it)
|
||||
// will be skipped.
|
||||
//
|
||||
// RETURN VALUE
|
||||
// For option letters contained in the string optstring, sc_getopt
|
||||
// will return the option letter. sc_getopt returns a question mark (?)
|
||||
// when it encounters an option letter not included in optstring.
|
||||
// EOF is returned when processing is finished.
|
||||
//
|
||||
// BUGS
|
||||
// 1) Long options are not supported.
|
||||
// 2) The GNU double-colon extension is not supported.
|
||||
// 3) The environment variable POSIXLY_CORRECT is not supported.
|
||||
// 4) The + syntax is not supported.
|
||||
// 5) The automatic permutation of arguments is not supported.
|
||||
// 6) This implementation of sc_getopt() returns EOF if an error is
|
||||
// encountered, instead of -1 as the latest standard requires.
|
||||
//
|
||||
// EXAMPLE
|
||||
// BOOL CMyApp::ProcessCommandLine(int argc, char *argv[])
|
||||
// {
|
||||
// int c;
|
||||
//
|
||||
// while ((c = sc_getopt(argc, argv, _T("aBn:"))) != EOF)
|
||||
// {
|
||||
// switch (c)
|
||||
// {
|
||||
// case _T('a'):
|
||||
// TRACE(_T("option a\n"));
|
||||
// //
|
||||
// // set some flag here
|
||||
// //
|
||||
// break;
|
||||
//
|
||||
// case _T('B'):
|
||||
// TRACE( _T("option B\n"));
|
||||
// //
|
||||
// // set some other flag here
|
||||
// //
|
||||
// break;
|
||||
//
|
||||
// case _T('n'):
|
||||
// TRACE(_T("option n: value=%d\n"), atoi(sc_optarg));
|
||||
// //
|
||||
// // do something with value here
|
||||
// //
|
||||
// break;
|
||||
//
|
||||
// case _T('?'):
|
||||
// TRACE(_T("ERROR: illegal option %s\n"), argv[sc_optind-1]);
|
||||
// return FALSE;
|
||||
// break;
|
||||
//
|
||||
// default:
|
||||
// TRACE(_T("WARNING: no handler for option %c\n"), c);
|
||||
// return FALSE;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// //
|
||||
// // check for non-option args here
|
||||
// //
|
||||
// return TRUE;
|
||||
// }
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
char * sc_optarg; // global argument pointer
|
||||
int sc_optind = 0; // global argv index
|
||||
|
||||
int sc_getopt( int argc, char * argv[], char * optstring ) {
|
||||
static char * next = NULL;
|
||||
if( sc_optind == 0 ) {
|
||||
next = NULL;
|
||||
}
|
||||
|
||||
sc_optarg = NULL;
|
||||
|
||||
if( next == NULL || *next == '\0' ) {
|
||||
if( sc_optind == 0 ) {
|
||||
sc_optind++;
|
||||
}
|
||||
|
||||
if( sc_optind >= argc || argv[sc_optind][0] != '-' || argv[sc_optind][1] == '\0' ) {
|
||||
sc_optarg = NULL;
|
||||
if( sc_optind < argc ) {
|
||||
sc_optarg = argv[sc_optind];
|
||||
}
|
||||
return EOF;
|
||||
}
|
||||
|
||||
if( strcmp( argv[sc_optind], "--" ) == 0 ) {
|
||||
sc_optind++;
|
||||
sc_optarg = NULL;
|
||||
if( sc_optind < argc ) {
|
||||
sc_optarg = argv[sc_optind];
|
||||
}
|
||||
return EOF;
|
||||
}
|
||||
|
||||
next = argv[sc_optind];
|
||||
next++; // skip past -
|
||||
sc_optind++;
|
||||
}
|
||||
|
||||
char c = *next++;
|
||||
char * cp = strchr( optstring, c );
|
||||
|
||||
if( cp == NULL || c == ':' ) {
|
||||
return '?';
|
||||
}
|
||||
|
||||
cp++;
|
||||
if( *cp == ':' ) {
|
||||
if( *next != '\0' ) {
|
||||
sc_optarg = next;
|
||||
next = NULL;
|
||||
} else if( sc_optind < argc ) {
|
||||
sc_optarg = argv[sc_optind];
|
||||
sc_optind++;
|
||||
} else {
|
||||
return '?';
|
||||
}
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/** \file sc_getopt.h
|
||||
* this was xgetopt.h
|
||||
* XGetopt.h Version 1.2
|
||||
*
|
||||
* Author: Hans Dietrich
|
||||
* hdietrich2@hotmail.com
|
||||
*
|
||||
* This software is released into the public domain.
|
||||
* You are free to use it in any way you like.
|
||||
*
|
||||
* This software is provided "as is" with no expressed
|
||||
* or implied warranty. I accept no liability for any
|
||||
* damage or loss of business that this software may cause.
|
||||
*/
|
||||
#ifndef XGETOPT_H
|
||||
#define XGETOPT_H
|
||||
#include "sc_export.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern SC_BASE_EXPORT int sc_optind, sc_opterr;
|
||||
extern SC_BASE_EXPORT char * sc_optarg;
|
||||
|
||||
int SC_BASE_EXPORT sc_getopt( int argc, char * argv[], char * optstring );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* XGETOPT_H */
|
||||
@@ -0,0 +1,405 @@
|
||||
|
||||
#define SC_MEMMGR_CC
|
||||
|
||||
#include <sc_cf.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <string>
|
||||
#include <set>
|
||||
|
||||
#ifdef SC_MEMMGR_ENABLE_CHECKS
|
||||
|
||||
/**
|
||||
sc_memmgr_error definition
|
||||
*/
|
||||
class sc_memmgr_error {
|
||||
private:
|
||||
std::string _srcfile;
|
||||
unsigned int _srcline;
|
||||
unsigned int _occurences;
|
||||
public:
|
||||
sc_memmgr_error( const std::string & file, const unsigned int line );
|
||||
sc_memmgr_error( const sc_memmgr_error & rhs );
|
||||
~sc_memmgr_error( void );
|
||||
|
||||
bool operator<( const sc_memmgr_error & rhs ) const;
|
||||
|
||||
std::string getsrcfile( void ) const;
|
||||
unsigned int getsrcline( void ) const;
|
||||
unsigned int getoccurences( void ) const;
|
||||
};
|
||||
|
||||
typedef std::set<sc_memmgr_error> sc_memmgr_errors;
|
||||
typedef std::set<sc_memmgr_error>::iterator sc_memmgr_error_iterator;
|
||||
|
||||
/**
|
||||
sc_memmgr_record definition
|
||||
*/
|
||||
class sc_memmgr_record {
|
||||
private:
|
||||
void * _addr;
|
||||
size_t _size;
|
||||
std::string _srcfile;
|
||||
unsigned int _srcline;
|
||||
public:
|
||||
sc_memmgr_record( void * addr, size_t size, const char * file, const unsigned int line );
|
||||
sc_memmgr_record( void * addr );
|
||||
sc_memmgr_record( const sc_memmgr_record & rhs );
|
||||
~sc_memmgr_record( void );
|
||||
|
||||
bool operator<( const sc_memmgr_record & rhs ) const;
|
||||
|
||||
void * getaddr( void ) const;
|
||||
size_t getsize( void ) const;
|
||||
std::string getsrcfile( void ) const;
|
||||
unsigned int getsrcline( void ) const;
|
||||
};
|
||||
|
||||
typedef std::set<sc_memmgr_record> sc_memmgr_records;
|
||||
typedef std::set<sc_memmgr_record>::iterator sc_memmgr_record_iterator;
|
||||
|
||||
#endif /* SC_MEMMGR_ENABLE_CHECKS */
|
||||
|
||||
/**
|
||||
sc_memmgr definition
|
||||
*/
|
||||
class sc_memmgr {
|
||||
private:
|
||||
#ifdef SC_MEMMGR_ENABLE_CHECKS
|
||||
bool _record_insert_busy, _record_erase_busy;
|
||||
// memory allocation/reallocation records, inserted at allocation, erased at deallocation.
|
||||
sc_memmgr_records _records;
|
||||
// memory stats
|
||||
unsigned int _allocated; // amount of memory allocated simultaniously
|
||||
unsigned int _maximum_allocated; // maximum amount of memory allocated simultaniously
|
||||
unsigned int _allocated_total; // total amount of memory allocated in bytes
|
||||
unsigned int _reallocated_total; // total amount of memory reallocated in bytes
|
||||
unsigned int _deallocated_total; // total amount of memory deallocated in bytes
|
||||
#endif /* SC_MEMMGR_ENABLE_CHECKS */
|
||||
protected:
|
||||
public:
|
||||
sc_memmgr( void );
|
||||
~sc_memmgr( void );
|
||||
|
||||
void * allocate( size_t size, const char * file, const int line );
|
||||
void * reallocate( void * addr, size_t size, const char * file, const int line );
|
||||
void deallocate( void * addr, const char * file, const int line );
|
||||
};
|
||||
|
||||
/**
|
||||
sc_memmgr instance.
|
||||
There should be one static instance of memmgr.
|
||||
This instance is automatically destroyed when application exits, so this allows us to add
|
||||
memory leak detection in it's destructor.
|
||||
*/
|
||||
sc_memmgr memmgr;
|
||||
|
||||
/**
|
||||
c memory functions implementation
|
||||
*/
|
||||
extern "C" {
|
||||
|
||||
void * sc_malloc_fn( unsigned int size, const char * file, const int line ) {
|
||||
return memmgr.allocate( size, file, line );
|
||||
}
|
||||
|
||||
void * sc_calloc_fn( unsigned int count, unsigned int size, const char * file, const int line ) {
|
||||
return memmgr.allocate( count * size, file, line );
|
||||
}
|
||||
|
||||
void * sc_realloc_fn( void * addr, unsigned int size, const char * file, const int line ) {
|
||||
return memmgr.reallocate( addr, size, file, line );
|
||||
}
|
||||
|
||||
void sc_free_fn( void * addr ) {
|
||||
memmgr.deallocate( addr, "", 0 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
c++ memory operators implementation
|
||||
*/
|
||||
void * sc_operator_new( size_t size, const char * file, const int line ) {
|
||||
return memmgr.allocate( size, file, line );
|
||||
}
|
||||
|
||||
void sc_operator_delete( void * addr, const char * file, const int line ) {
|
||||
memmgr.deallocate( addr, file, line );
|
||||
}
|
||||
|
||||
void sc_operator_delete( void * addr ) {
|
||||
memmgr.deallocate( addr, "", 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
sc_memmgr implementation
|
||||
*/
|
||||
sc_memmgr::sc_memmgr( void ) {
|
||||
#ifdef SC_MEMMGR_ENABLE_CHECKS
|
||||
_record_insert_busy = false;
|
||||
_record_erase_busy = false;
|
||||
|
||||
_allocated = 0;
|
||||
_maximum_allocated = 0;
|
||||
_allocated_total = 0;
|
||||
_reallocated_total = 0;
|
||||
_deallocated_total = 0;
|
||||
#endif /* SC_MEMMGR_ENABLE_CHECKS */
|
||||
}
|
||||
|
||||
/**
|
||||
Destructor:
|
||||
sc_memmgr::~sc_memmgr(void)
|
||||
Description:
|
||||
The sc_memmgr destructor is used to check for memory leaks when enabled.
|
||||
All records still present when sc_memmgr instance is destroyed can be considered as
|
||||
memory leaks.
|
||||
*/
|
||||
sc_memmgr::~sc_memmgr( void ) {
|
||||
#ifdef SC_MEMMGR_ENABLE_CHECKS
|
||||
sc_memmgr_record_iterator irecord;
|
||||
sc_memmgr_errors errors;
|
||||
sc_memmgr_error_iterator ierror;
|
||||
|
||||
// Check if total allocated equals total deallocated
|
||||
if( _allocated_total != _deallocated_total ) {
|
||||
// todo: generate warning for possible memory leaks, enable full memory leak checking
|
||||
fprintf( stderr, "sc_memmgr warning: Possible memory leaks detected (%d of %d bytes)\n", _allocated_total - _deallocated_total, _allocated_total );
|
||||
}
|
||||
|
||||
// Compact leaks into an error list to prevent same leak being reported multiple times.
|
||||
_record_insert_busy = true;
|
||||
_record_erase_busy = true;
|
||||
for( irecord = _records.begin();
|
||||
irecord != _records.end();
|
||||
irecord ++ ) {
|
||||
sc_memmgr_error error( irecord->getsrcfile(), irecord->getsrcline() );
|
||||
ierror = errors.find( error );
|
||||
if( ierror == errors.end() ) {
|
||||
errors.insert( error );
|
||||
}
|
||||
//else
|
||||
// ierror->occurences ++;
|
||||
}
|
||||
_record_insert_busy = false;
|
||||
_record_erase_busy = false;
|
||||
|
||||
// Loop through memory leaks to generate/buffer errors
|
||||
for( ierror = errors.begin();
|
||||
ierror != errors.end();
|
||||
ierror ++ ) {
|
||||
// todo: generate error for memory leak
|
||||
fprintf( stderr, "sc_memmgr warning: Possible memory leak in %s line %d\n", ierror->getsrcfile().c_str(), ierror->getsrcline() );
|
||||
}
|
||||
|
||||
// Clear remaining records
|
||||
_record_erase_busy = true;
|
||||
_records.clear();
|
||||
errors.clear();
|
||||
_record_erase_busy = false;
|
||||
#endif /* SC_MEMMGR_ENABLE_CHECKS */
|
||||
}
|
||||
|
||||
void * sc_memmgr::allocate( size_t size, const char * file, const int line ) {
|
||||
void * addr;
|
||||
|
||||
// Allocate
|
||||
addr = malloc( size );
|
||||
if( addr == NULL ) {
|
||||
// todo: error allocation failed
|
||||
fprintf( stderr, "sc_memmgr error: Memory allocation failed in %s line %d\n", file, line );
|
||||
}
|
||||
|
||||
// Some stl implementations (for example debian gcc) use the new operator to construct
|
||||
// new elements when inserting sc_memmgr_record. When this our new operator gets used
|
||||
// for this operation, this would result in an infinite loop. This is fixed by the
|
||||
// _record_insert_busy flag.
|
||||
#ifdef SC_MEMMGR_ENABLE_CHECKS
|
||||
if( !_record_insert_busy ) {
|
||||
// Store record for this allocation
|
||||
_record_insert_busy = true;
|
||||
_records.insert( sc_memmgr_record( addr, size, file, line ) );
|
||||
_record_insert_busy = false;
|
||||
|
||||
// Update stats
|
||||
_allocated += size;
|
||||
if( _allocated > _maximum_allocated ) {
|
||||
_maximum_allocated = _allocated;
|
||||
}
|
||||
_allocated_total += size;
|
||||
}
|
||||
#endif /* SC_MEMMGR_ENABLE_CHECKS */
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
||||
void * sc_memmgr::reallocate( void * addr, size_t size, const char * file, const int line ) {
|
||||
#ifdef SC_MEMMGR_ENABLE_CHECKS
|
||||
sc_memmgr_record_iterator record;
|
||||
|
||||
if( !_record_insert_busy ) {
|
||||
// Find record of previous allocation/reallocation
|
||||
record = _records.find( sc_memmgr_record( addr ) );
|
||||
if( record == _records.end() ) {
|
||||
// todo: error reallocating memory not allocated?
|
||||
fprintf( stderr, "sc_memmgr warning: Reallocation of not allocated memory at %s line %d\n", file, line );
|
||||
} else {
|
||||
// Update stats
|
||||
_allocated -= record->getsize();
|
||||
_deallocated_total += record->getsize();
|
||||
|
||||
// Erase previous allocation/reallocation
|
||||
_record_erase_busy = true;
|
||||
_records.erase( record );
|
||||
_record_erase_busy = false;
|
||||
}
|
||||
}
|
||||
#endif /* SC_MEMMGR_ENABLE_CHECKS */
|
||||
|
||||
// Reallocate
|
||||
addr = realloc( addr, size );
|
||||
if( addr == NULL ) {
|
||||
// todo: error reallocation failed
|
||||
fprintf( stderr, "sc_memmgr error: Reallocation failed at %s line %d\n", file, line );
|
||||
}
|
||||
|
||||
#ifdef SC_MEMMGR_ENABLE_CHECKS
|
||||
if( !_record_insert_busy ) {
|
||||
// Store record for this reallocation
|
||||
_record_insert_busy = true;
|
||||
_records.insert( sc_memmgr_record( addr, size, file, line ) );
|
||||
_record_insert_busy = false;
|
||||
|
||||
// Update stats
|
||||
_allocated += size;
|
||||
if( _allocated > _maximum_allocated ) {
|
||||
_maximum_allocated = _allocated;
|
||||
}
|
||||
_allocated_total += size;
|
||||
_reallocated_total += size;
|
||||
}
|
||||
#endif /* SC_MEMMGR_ENABLE_CHECKS */
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
||||
void sc_memmgr::deallocate( void * addr, const char * file, const int line ) {
|
||||
#ifdef SC_MEMMGR_ENABLE_CHECKS
|
||||
sc_memmgr_record_iterator record;
|
||||
|
||||
if( !_record_erase_busy ) {
|
||||
// Find record of previous allocation/reallocation
|
||||
record = _records.find( sc_memmgr_record( addr ) );
|
||||
if( record == _records.end() ) {
|
||||
// todo: error free called for not allocated memory?
|
||||
fprintf( stderr, "sc_memmgr warning: Deallocate of not allocated memory at %s line %d\n", file, line );
|
||||
} else {
|
||||
// Update stats
|
||||
_allocated -= record->getsize();
|
||||
_deallocated_total += record->getsize();
|
||||
|
||||
// Erase record
|
||||
_record_erase_busy = true;
|
||||
_records.erase( record );
|
||||
_record_erase_busy = false;
|
||||
}
|
||||
}
|
||||
#else
|
||||
(void) file; // quell unused param warnings
|
||||
(void) line;
|
||||
#endif /* SC_MEMMGR_ENABLE_CHECKS */
|
||||
|
||||
// Deallocate
|
||||
free( addr );
|
||||
}
|
||||
|
||||
#ifdef SC_MEMMGR_ENABLE_CHECKS
|
||||
/**
|
||||
sc_memmgr_error implementation
|
||||
*/
|
||||
sc_memmgr_error::sc_memmgr_error( const std::string & file, const unsigned int line ) {
|
||||
_srcfile = file;
|
||||
_srcline = line;
|
||||
_occurences = 1;
|
||||
}
|
||||
|
||||
sc_memmgr_error::sc_memmgr_error( const sc_memmgr_error & rhs ) {
|
||||
_srcfile = rhs._srcfile;
|
||||
_srcline = rhs._srcline;
|
||||
_occurences = rhs._occurences;
|
||||
}
|
||||
|
||||
sc_memmgr_error::~sc_memmgr_error( void ) {
|
||||
}
|
||||
|
||||
bool sc_memmgr_error::operator<( const sc_memmgr_error & rhs ) const {
|
||||
if( _srcfile == rhs._srcfile ) {
|
||||
return _srcline < rhs._srcline;
|
||||
}
|
||||
return _srcfile < rhs._srcfile;
|
||||
}
|
||||
|
||||
std::string sc_memmgr_error::getsrcfile( void ) const {
|
||||
return _srcfile;
|
||||
}
|
||||
|
||||
unsigned int sc_memmgr_error::getsrcline( void ) const {
|
||||
return _srcline;
|
||||
}
|
||||
|
||||
unsigned int sc_memmgr_error::getoccurences( void ) const {
|
||||
return _occurences;
|
||||
}
|
||||
|
||||
/**
|
||||
sc_memmgr_record implementation
|
||||
*/
|
||||
sc_memmgr_record::sc_memmgr_record( void * addr, size_t size, const char * file, const unsigned int line ) {
|
||||
_addr = addr;
|
||||
_size = size;
|
||||
_srcfile = file;
|
||||
_srcline = line;
|
||||
}
|
||||
|
||||
sc_memmgr_record::sc_memmgr_record( void * addr ) {
|
||||
_addr = addr;
|
||||
_size = 0;
|
||||
_srcfile = "";
|
||||
_srcline = -1;
|
||||
}
|
||||
|
||||
sc_memmgr_record::sc_memmgr_record( const sc_memmgr_record & rhs ) {
|
||||
_addr = rhs._addr;
|
||||
_size = rhs._size;
|
||||
_srcfile = rhs._srcfile;
|
||||
_srcline = rhs._srcline;
|
||||
}
|
||||
|
||||
sc_memmgr_record::~sc_memmgr_record( void ) {
|
||||
}
|
||||
|
||||
bool sc_memmgr_record::operator<( const sc_memmgr_record & rhs ) const {
|
||||
return _addr < rhs._addr;
|
||||
}
|
||||
|
||||
void * sc_memmgr_record::getaddr( void ) const {
|
||||
return _addr;
|
||||
}
|
||||
|
||||
size_t sc_memmgr_record::getsize( void ) const {
|
||||
return _size;
|
||||
}
|
||||
|
||||
std::string sc_memmgr_record::getsrcfile( void ) const {
|
||||
return _srcfile;
|
||||
}
|
||||
|
||||
unsigned int sc_memmgr_record::getsrcline( void ) const {
|
||||
return _srcline;
|
||||
}
|
||||
|
||||
#endif /* SC_MEMMGR_ENABLE_CHECKS */
|
||||
@@ -0,0 +1,79 @@
|
||||
#ifndef SC_MEMMGR_H
|
||||
#define SC_MEMMGR_H
|
||||
|
||||
#include <sc_export.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined(SC_MEMMGR_ENABLE_CHECKS)
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <stddef.h>
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
SC_BASE_EXPORT void * sc_malloc_fn( unsigned int size, const char * file, const int line );
|
||||
SC_BASE_EXPORT void * sc_calloc_fn( unsigned int count, unsigned int size, const char * file, const int line );
|
||||
SC_BASE_EXPORT void * sc_realloc_fn( void * addr, unsigned int size, const char * file, const int line );
|
||||
SC_BASE_EXPORT void sc_free_fn( void * addr );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
SC_BASE_EXPORT void * sc_operator_new( size_t size, const char * file, const int line );
|
||||
SC_BASE_EXPORT void sc_operator_delete( void * addr, const char * file, const int line );
|
||||
SC_BASE_EXPORT void sc_operator_delete( void * addr );
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifndef SC_MEMMGR_CC
|
||||
|
||||
#define sc_malloc(size) sc_malloc_fn(size, __FILE__, __LINE__)
|
||||
#define sc_calloc(count, size) sc_calloc_fn(count, size, __FILE__, __LINE__)
|
||||
#define sc_realloc(addr, size) sc_realloc_fn(addr, size, __FILE__, __LINE__)
|
||||
#define sc_free(addr) sc_free_fn(addr)
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <new>
|
||||
|
||||
inline void * operator new( size_t size, const char * file, const int line ) throw (std::bad_alloc) {
|
||||
return sc_operator_new( size, file, line );
|
||||
}
|
||||
|
||||
inline void * operator new[]( size_t size, const char * file, const int line ) throw (std::bad_alloc) {
|
||||
return sc_operator_new( size, file, line );
|
||||
}
|
||||
|
||||
inline void operator delete( void * addr, const char * file, const int line ) throw (std::bad_alloc) {
|
||||
sc_operator_delete( addr, file, line );
|
||||
}
|
||||
|
||||
inline void operator delete[]( void * addr, const char * file, const int line ) throw (std::bad_alloc) {
|
||||
sc_operator_delete( addr, file, line );
|
||||
}
|
||||
|
||||
inline void operator delete( void * addr ) throw () {
|
||||
sc_operator_delete( addr );
|
||||
}
|
||||
|
||||
inline void operator delete[]( void * addr ) throw () {
|
||||
sc_operator_delete( addr );
|
||||
}
|
||||
|
||||
#define new new(__FILE__, __LINE__)
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* SC_MEMMGR_CC */
|
||||
|
||||
#else
|
||||
#define sc_malloc malloc
|
||||
#define sc_calloc calloc
|
||||
#define sc_realloc realloc
|
||||
#define sc_free free
|
||||
#endif /* SC_MEMMGR_ENABLE_CHECKS */
|
||||
|
||||
#endif /* SC_MEMMGR_H */
|
||||
@@ -0,0 +1,32 @@
|
||||
|
||||
#include "sc_mkdir.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#ifdef _WIN32
|
||||
# include <direct.h>
|
||||
#endif /* _WIN32 */
|
||||
|
||||
/* cross-platform mkdir */
|
||||
int sc_mkdir( const char * path ) {
|
||||
#ifdef _WIN32
|
||||
return mkdir( path );
|
||||
#else
|
||||
return mkdir( path, 0777 );
|
||||
#endif /* _WIN32 */
|
||||
}
|
||||
|
||||
/* return -1 if error, 0 if created, 1 if dir existed already */
|
||||
int mkDirIfNone( const char * path ) {
|
||||
struct stat s;
|
||||
if( stat( path, &s ) != 0 ) {
|
||||
if( errno == ENOENT ) {
|
||||
return sc_mkdir( path );
|
||||
}
|
||||
} else if( s.st_mode & S_IFDIR ) {
|
||||
return 1;
|
||||
}
|
||||
/* either stat returned an error other than ENOENT, or 'path' exists but isn't a dir */
|
||||
return -1;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef SC_MKDIR
|
||||
#define SC_MKDIR
|
||||
|
||||
#include <sc_export.h>
|
||||
|
||||
/** cross-platform mkdir() */
|
||||
SC_BASE_EXPORT int sc_mkdir( const char * path );
|
||||
|
||||
/** create a dir 'path' if 'path' doesn't exist
|
||||
* \return -1 if error, 0 if created, 1 if dir existed already
|
||||
* if it returns -1, check errno
|
||||
*/
|
||||
SC_BASE_EXPORT int mkDirIfNone( const char * path );
|
||||
|
||||
#endif /* SC_MKDIR */
|
||||
@@ -0,0 +1,13 @@
|
||||
#ifndef NULLPTR_H
|
||||
#define NULLPTR_H
|
||||
|
||||
#include <sc_cf.h>
|
||||
|
||||
#ifdef HAVE_NULLPTR
|
||||
#include <cstddef>
|
||||
#else
|
||||
# define nullptr_t void*
|
||||
# define nullptr NULL
|
||||
#endif //HAVE_NULLPTR
|
||||
|
||||
#endif //NULLPTR_H
|
||||
@@ -0,0 +1,39 @@
|
||||
#ifndef __SC_STDIO_H
|
||||
#define __SC_STDIO_H
|
||||
|
||||
/*
|
||||
* https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010
|
||||
* (NOTE: MSVC defines va_list as a char*, so this should be safe)
|
||||
*/
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
static __inline int
|
||||
c99_vsnprintf(char *buffer, size_t sz, const char *format, va_list ap) {
|
||||
int count = -1;
|
||||
|
||||
if (sz != 0)
|
||||
count = _vsnprintf_s(buffer, sz, _TRUNCATE, format, ap);
|
||||
if (count == -1)
|
||||
count = _vscprintf(format, ap);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static __inline int
|
||||
c99_snprintf(char *buffer, size_t sz, const char *format, ...) {
|
||||
int count;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
count = c99_vsnprintf(buffer, sz, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* __SC_STDIO_H */
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#ifndef SC_STRTOULL_H
|
||||
#define SC_STRTOULL_H
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
# define strtoull _strtoui64
|
||||
# define ULLONG_MAX _UI64_MAX
|
||||
#endif
|
||||
|
||||
#endif /* SC_STRTOULL_H */
|
||||
@@ -1,7 +1,8 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "trace_fprintf.h"
|
||||
#include "sc_trace_fprintf.h"
|
||||
|
||||
void trace_fprintf( char const * sourcefile, int line, FILE * file, const char * format, ... ) {
|
||||
va_list args;
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef SC_TRACE_FPRINTF_H
|
||||
#define SC_TRACE_FPRINTF_H
|
||||
|
||||
/** \file trace_fprintf.h
|
||||
/** \file sc_trace_fprintf.h
|
||||
* Used to track the source file and line where generated code is printed from
|
||||
* When enabled, comments are printed into the generated files for every 'fprintf':
|
||||
* / * source: scl/src/exp2cxx/selects.c:1375 * /
|
||||
@@ -20,7 +20,7 @@ extern "C" {
|
||||
/** Used to find where generated c++ originates from in exp2cxx.
|
||||
* To enable, configure with 'cmake .. -DSC_TRACE_FPRINTF=ON'
|
||||
*/
|
||||
void trace_fprintf( char const * sourcefile, int line, FILE * file, const char * format, ... );
|
||||
SC_BASE_EXPORT void trace_fprintf( char const * sourcefile, int line, FILE * file, const char * format, ... );
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -29,25 +29,26 @@ SET(SC_CLDAI_HDRS
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${SC_SOURCE_DIR}/src/base
|
||||
${SC_SOURCE_DIR}/src/clstepcore
|
||||
${SC_SOURCE_DIR}/src/clutils
|
||||
)
|
||||
|
||||
set(_libdeps steputils)
|
||||
set(_libdeps steputils base)
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
if($CACHE{SC_BUILD_SHARED_LIBS})
|
||||
SC_ADDLIB(stepdai SHARED SOURCES ${LIBSTEPDAI_SRCS} LINK_LIBRARIES ${_libdeps})
|
||||
if(WIN32)
|
||||
target_compile_definitions(stepdai PRIVATE SC_DAI_DLL_EXPORTS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(BUILD_STATIC_LIBS)
|
||||
if($CACHE{SC_BUILD_STATIC_LIBS})
|
||||
SC_ADDLIB(stepdai-static STATIC SOURCES ${LIBSTEPDAI_SRCS} LINK_LIBRARIES $<JOIN:${_libdeps},-static >-static)
|
||||
endif()
|
||||
|
||||
install(FILES ${SC_CLDAI_HDRS}
|
||||
DESTINATION ${INCLUDE_DIR}/stepcode/cldai)
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/cldai)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include <memory.h>
|
||||
#include <math.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
#include "sdaiApplication_instance.h"
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <sstream>
|
||||
#include <sdai.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
SDAI_Binary::SDAI_Binary( const char * str, int max ) {
|
||||
content = std::string( str, max );
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <math.h>
|
||||
|
||||
#include <sdai.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
// to help ObjectCenter
|
||||
#ifndef HAVE_MEMMOVE
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//#include <EntityExtent.h>
|
||||
|
||||
#include <sdai.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
SDAI_Entity_extent::SDAI_Entity_extent( )
|
||||
: _definition( 0 ), _definition_name( 0 ), _owned_by( 0 ) {
|
||||
@@ -55,7 +56,7 @@ void SDAI_Entity_extent::owned_by_( SDAI_Model_contents__list_var& mclv ) {
|
||||
}
|
||||
|
||||
SDAI_Model_contents__list_var SDAI_Entity_extent ::owned_by_() const {
|
||||
return ( SDAI_Model_contents__list_var ) &_owned_by;
|
||||
return ( const SDAI_Model_contents__list_var ) &_owned_by;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -56,7 +56,7 @@ class SC_DAI_EXPORT SDAI_Entity_extent : public SDAI_Session_instance {
|
||||
return &_instances;
|
||||
}
|
||||
SDAI_DAObject__set_var instances_() const {
|
||||
return ( SDAI_DAObject__set_var )&_instances;
|
||||
return ( const SDAI_DAObject__set_var )&_instances;
|
||||
}
|
||||
|
||||
// need to implement Model_contents__list
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <math.h>
|
||||
|
||||
#include <sdai.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
/*
|
||||
#include <EntityExtent.h>
|
||||
@@ -50,7 +51,7 @@ SDAI_Entity_extent__set::SDAI_Entity_extent__set( int defaultSize ) {
|
||||
}
|
||||
|
||||
SDAI_Entity_extent__set::~SDAI_Entity_extent__set() {
|
||||
delete[] _buf;
|
||||
delete _buf;
|
||||
}
|
||||
|
||||
void SDAI_Entity_extent__set::Check( int index ) {
|
||||
@@ -61,7 +62,7 @@ void SDAI_Entity_extent__set::Check( int index ) {
|
||||
_bufsize = ( index + 1 ) * 2;
|
||||
newbuf = new SDAI_Entity_extent_ptr[_bufsize];
|
||||
memmove( newbuf, _buf, _count * sizeof( SDAI_Entity_extent_ptr ) );
|
||||
delete[] _buf;
|
||||
delete _buf;
|
||||
_buf = newbuf;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
#include <sdai.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
/*
|
||||
* NIST STEP Core Class Library
|
||||
@@ -312,11 +313,6 @@ SDAI_BOOLEAN & SDAI_BOOLEAN::operator= ( const SDAI_LOGICAL & t ) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
SDAI_BOOLEAN & SDAI_BOOLEAN::operator= ( const SDAI_BOOLEAN & t ) {
|
||||
v = t;
|
||||
return *this;
|
||||
}
|
||||
|
||||
SDAI_BOOLEAN & SDAI_BOOLEAN::operator= ( const Boolean t ) {
|
||||
v = t;
|
||||
return *this;
|
||||
|
||||
@@ -138,7 +138,6 @@ class SC_DAI_EXPORT SDAI_BOOLEAN :
|
||||
|
||||
operator ::Boolean() const;
|
||||
SDAI_BOOLEAN & operator=( const SDAI_LOGICAL & t );
|
||||
SDAI_BOOLEAN & operator=( const SDAI_BOOLEAN & t );
|
||||
|
||||
SDAI_BOOLEAN & operator=( const ::Boolean t );
|
||||
SDAI_LOGICAL operator==( const SDAI_LOGICAL & t ) const;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user