Compare commits
247
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed686ee1d9 | ||
|
|
79926118c5 | ||
|
|
0f8c5eed76 | ||
|
|
9d47461e32 | ||
|
|
e480b0bbd1 | ||
|
|
40bef08602 | ||
|
|
ee5c3dbfd2 | ||
|
|
2e0b644c99 | ||
|
|
18f7b43c99 | ||
|
|
b5e0082f56 | ||
|
|
c4d4373280 | ||
|
|
54c89ed13e | ||
|
|
9baa5dadaa | ||
|
|
e7c70802d4 | ||
|
|
8a228eb2c8 | ||
|
|
18e16bc6ed | ||
|
|
c5d6b10a9a | ||
|
|
9726d00caa | ||
|
|
d962ea0381 | ||
|
|
5a37441843 | ||
|
|
deefe3442d | ||
|
|
2d8ad4ba0c | ||
|
|
b5aea76eed | ||
|
|
e0e60f1277 | ||
|
|
14a16f18b0 | ||
|
|
aba9111ff6 | ||
|
|
5b0085612f | ||
|
|
0c81351efd | ||
|
|
87bfb7929d | ||
|
|
43a95a6cf4 | ||
|
|
99855789c2 | ||
|
|
05c6adb716 | ||
|
|
6705c0f62b | ||
|
|
6e18e57380 | ||
|
|
3d74790546 | ||
|
|
84fa417d0d | ||
|
|
e7b231ca07 | ||
|
|
ced6a1d84b | ||
|
|
1d35f711ce | ||
|
|
92549337e2 | ||
|
|
ec07e4e6bd | ||
|
|
0e091f0de7 | ||
|
|
6040858231 | ||
|
|
a267616a30 | ||
|
|
3113afd2a4 | ||
|
|
9005894a16 | ||
|
|
d69363b85e | ||
|
|
6d7e383ed2 | ||
|
|
66e696471c | ||
|
|
844a380d4c | ||
|
|
9b233ac6ca | ||
|
|
780ed87cbb | ||
|
|
7a19e69532 | ||
|
|
0b950dd18e | ||
|
|
7836a9ec77 | ||
|
|
3bfac87072 | ||
|
|
bf80813ee5 | ||
|
|
801bed19e1 | ||
|
|
4ee1286a18 | ||
|
|
d1d13d5bce | ||
|
|
8b777842d3 | ||
|
|
29a0de453d | ||
|
|
0e548f7f1b | ||
|
|
ebf495a74a | ||
|
|
e81cd61d65 | ||
|
|
19b8148e73 | ||
|
|
57a929cd71 | ||
|
|
e1de4558e6 | ||
|
|
966fb9d323 | ||
|
|
7a038d11ed | ||
|
|
4d03347df6 | ||
|
|
befb85f2f9 | ||
|
|
aa79dbfeec | ||
|
|
a01c338005 | ||
|
|
975a74d36b | ||
|
|
93369ce4aa | ||
|
|
8cc8fc7590 | ||
|
|
74b6fe4575 | ||
|
|
aa595c9c91 | ||
|
|
e79c15dae8 | ||
|
|
66aec9749e | ||
|
|
11694e8bf9 | ||
|
|
fb00dd424f | ||
|
|
c9c1bb99da | ||
|
|
b3fc4258c8 | ||
|
|
58732df22c | ||
|
|
a74c755f1e | ||
|
|
5e2ac7ea72 | ||
|
|
391f630af6 | ||
|
|
4025beba46 | ||
|
|
c2dc4f13fa | ||
|
|
9880ca87bc | ||
|
|
6ff7580814 | ||
|
|
845c3fdc34 | ||
|
|
6cbc18b87a | ||
|
|
aa3b89affb | ||
|
|
6bbd46007c | ||
|
|
c0d3fac5f7 | ||
|
|
56da4ab614 | ||
|
|
111d7e94b0 | ||
|
|
db2c3d8e5b | ||
|
|
592823b64b | ||
|
|
ed8390a0b4 | ||
|
|
6fd22a1e0a | ||
|
|
f35d25d93d | ||
|
|
d824fc0c4e | ||
|
|
1bd7ad942b | ||
|
|
bc96f29d6b | ||
|
|
820ca86159 | ||
|
|
f9f5c71204 | ||
|
|
84d939baa7 | ||
|
|
04a5404e60 | ||
|
|
c85720fbb4 | ||
|
|
ac19698fde | ||
|
|
b36b78ffce | ||
|
|
77a43bc3f2 | ||
|
|
fc4edb9b06 | ||
|
|
6e53c8f833 | ||
|
|
9d1583be63 | ||
|
|
94c978359d | ||
|
|
8a7e0af3b5 | ||
|
|
840d57c2f1 | ||
|
|
33102ee9e3 | ||
|
|
627c0935a8 | ||
|
|
c2842f884a | ||
|
|
80b4588f6a | ||
|
|
e05bfc7bd4 | ||
|
|
f83e0abc74 | ||
|
|
0978cfcd00 | ||
|
|
28783de62b | ||
|
|
7dbda20be0 | ||
|
|
fdf271c888 | ||
|
|
8e9a68968c | ||
|
|
520e7a3789 | ||
|
|
4bab26918d | ||
|
|
efd353858e | ||
|
|
9b15e1c697 | ||
|
|
64873b4dd7 | ||
|
|
28c5d26429 | ||
|
|
43231cdbc9 | ||
|
|
7209a3e75d | ||
|
|
88e512c92c | ||
|
|
09deafbe23 | ||
|
|
830e29fb80 | ||
|
|
3c17e71b63 | ||
|
|
1d46986e80 | ||
|
|
ca1d62719a | ||
|
|
a6bea3572e | ||
|
|
ae933edba5 | ||
|
|
93c79df2df | ||
|
|
3e9fe17fcd | ||
|
|
874dca8499 | ||
|
|
c7bd9fa995 | ||
|
|
4446d02063 | ||
|
|
97c3d193a1 | ||
|
|
65e0f704fd | ||
|
|
d36c0dde5b | ||
|
|
8ed3d2fe33 | ||
|
|
61d34a352c | ||
|
|
6c9a2582c6 | ||
|
|
0fd354cb39 | ||
|
|
fd8b7e3a6b | ||
|
|
0be8f439ef | ||
|
|
8a8ea3e23a | ||
|
|
70b5d0d0af | ||
|
|
06ee050fb2 | ||
|
|
472bd4cb12 | ||
|
|
fed696dc63 | ||
|
|
35da61660b | ||
|
|
0ef7755151 | ||
|
|
7aa4309848 | ||
|
|
3c21bf00ac | ||
|
|
0f303d5c06 | ||
|
|
cfbd07306d | ||
|
|
cd8efa604f | ||
|
|
af637a28d8 | ||
|
|
0cefcae153 | ||
|
|
b42a909e65 | ||
|
|
dace0f70ef | ||
|
|
43329f557f | ||
|
|
3e8b836b3e | ||
|
|
ead7c6c8c3 | ||
|
|
fc3bcf0578 | ||
|
|
68cca0e222 | ||
|
|
bfe5219dc2 | ||
|
|
ae6f9d9310 | ||
|
|
f8b786ac40 | ||
|
|
53a2bcdd8b | ||
|
|
f11d325641 | ||
|
|
aa6cbe2d72 | ||
|
|
50e2cdb527 | ||
|
|
1f184eae8c | ||
|
|
90f3c5ce26 | ||
|
|
aa85c396bf | ||
|
|
f19cfecebe | ||
|
|
7456652b67 | ||
|
|
2a50010e6f | ||
|
|
bf14461dae | ||
|
|
ec12b1ce7c | ||
|
|
de375f8cea | ||
|
|
30534dbf0e | ||
|
|
5fddadb1e4 | ||
|
|
20c6d4c800 | ||
|
|
125820c84c | ||
|
|
6984cf6a46 | ||
|
|
322018c6db | ||
|
|
d5f60d72e0 | ||
|
|
aa5b0e3fa2 | ||
|
|
c81d05cff6 | ||
|
|
799a51f340 | ||
|
|
89b00f1596 | ||
|
|
ccb6728efa | ||
|
|
75af3df51c | ||
|
|
0f1196ef94 | ||
|
|
e4277656ef | ||
|
|
8dc5dceb59 | ||
|
|
093e59e5a7 | ||
|
|
177eef8acf | ||
|
|
211bc660da | ||
|
|
0b6853f5a7 | ||
|
|
b158a79f6c | ||
|
|
1f1965beae | ||
|
|
9f35265f75 | ||
|
|
345bcd8174 | ||
|
|
f05ce582ac | ||
|
|
5e1ad8f1c8 | ||
|
|
dcb156f1eb | ||
|
|
1bf945d60b | ||
|
|
380618fa7e | ||
|
|
55d36377c3 | ||
|
|
62be4c90c6 | ||
|
|
c2fddd8a7a | ||
|
|
8adb5e638d | ||
|
|
fceb57390c | ||
|
|
ae18190f69 | ||
|
|
8c9b3471fb | ||
|
|
22c437d45e | ||
|
|
5ea56aac02 | ||
|
|
14c5476537 | ||
|
|
f7e929fe6a | ||
|
|
736d637d63 | ||
|
|
6cf5d1e860 | ||
|
|
faadf26cdf | ||
|
|
e617808be1 | ||
|
|
97de8f9069 | ||
|
|
29f87a6d58 | ||
|
|
880a42bb90 |
@@ -1,65 +0,0 @@
|
||||
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)
|
||||
@@ -0,0 +1,286 @@
|
||||
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 --verbose -j1 .
|
||||
|
||||
linux:
|
||||
name: Ubuntu Latest GCC
|
||||
runs-on: ubuntu-latest
|
||||
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 --verbose -j1 . -C Release
|
||||
|
||||
linux_clang:
|
||||
name: Ubuntu Latest Clang
|
||||
runs-on: ubuntu-latest
|
||||
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 --verbose -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 --verbose -j1 . -C Release
|
||||
|
||||
brlcad_linux:
|
||||
name: BRL-CAD Linux step-g Test
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: true
|
||||
steps:
|
||||
- name: Setup - CMake
|
||||
uses: lukka/get-cmake@latest
|
||||
|
||||
- name: Setup - System
|
||||
env:
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install re2c astyle xsltproc libxml2-utils
|
||||
sudo apt-get install xserver-xorg-dev libx11-dev libxi-dev libxext-dev libglu1-mesa-dev libfontconfig-dev
|
||||
sudo apt-get install zlib1g-dev libpng-dev libjpeg-dev libtiff-dev libeigen3-dev libgdal-dev libassimp-dev libopencv-dev
|
||||
sudo apt-get clean
|
||||
|
||||
- name: Clone bext
|
||||
run: |
|
||||
git clone https://github.com/BRL-CAD/bext.git
|
||||
cd bext/stepcode
|
||||
cmake -E rm -r stepcode
|
||||
git clone --depth 1 https://github.com/stepcode/stepcode.git -b develop
|
||||
cd ../..
|
||||
|
||||
- name: Build bext
|
||||
run: |
|
||||
cmake -E make_directory bext_build
|
||||
cmake -S bext -B bext_build -DCMAKE_BUILD_TYPE=Release -DUSE_GDAL=OFF -DUSE_TCL=OFF -DUSE_QT=OFF -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}\bext_output
|
||||
cmake --build bext_build --config Release -j2
|
||||
# We only need the build ouputs (bext_output) after this point, so
|
||||
# clean up to save space for the main BRL-CAD build.
|
||||
cmake -E rm -rf bext
|
||||
cmake -E rm -rf bext_build
|
||||
|
||||
|
||||
- name: Checkout
|
||||
run: |
|
||||
git clone --depth 1 https://github.com/BRL-CAD/brlcad.git -b main
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
cmake -E make_directory brlcad_build
|
||||
cd brlcad_build
|
||||
cmake -S ../brlcad -DBRLCAD_EXT_DIR=${{ github.workspace }}\bext_output -DBRLCAD_ENABLE_GDAL=OFF -DBRLCAD_ENABLE_TCL=OFF -DBRLCAD_ENABLE_QT=OFF -G Ninja
|
||||
cd ..
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cd brlcad_build
|
||||
cmake --build . --target step-g
|
||||
cd ..
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
cd brlcad_build
|
||||
./bin/step-g ../brlcad/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: 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: Clone bext
|
||||
run: |
|
||||
git clone https://github.com/BRL-CAD/bext.git
|
||||
cd bext/stepcode
|
||||
cmake -E rm -r stepcode
|
||||
git clone --depth 1 https://github.com/stepcode/stepcode.git -b develop
|
||||
cd ../..
|
||||
|
||||
- name: Build bext
|
||||
shell: powershell
|
||||
run: |
|
||||
cmake -E make_directory bext_build
|
||||
cmake -S bext -B bext_build -DCMAKE_BUILD_TYPE=Release -DUSE_GDAL=OFF -DUSE_TCL=OFF -DUSE_QT=OFF -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}\bext_output
|
||||
cmake --build bext_build --config Release -j2
|
||||
# We only need the build ouputs (bext_output) after this point, so
|
||||
# clean up to save space for the main BRL-CAD build.
|
||||
cmake -E rm -rf bext
|
||||
cmake -E rm -rf bext_build
|
||||
|
||||
|
||||
- name: Checkout
|
||||
run: |
|
||||
git clone --depth 1 https://github.com/BRL-CAD/brlcad.git -b main
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
cmake -E make_directory brlcad_build
|
||||
cmake -S brlcad -B brlcad_build -DCMAKE_BUILD_TYPE=Release -DBRLCAD_EXT_DIR=${{ github.workspace }}\bext_output -DBRLCAD_ENABLE_GDAL=OFF -DBRLCAD_ENABLE_TCL=OFF -DBRLCAD_ENABLE_QT=OFF -G Ninja -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_CXX_COMPILER="cl.exe"
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cd brlcad_build
|
||||
cmake --build . --config Release --target step-g
|
||||
cd ..
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
cd brlcad_build
|
||||
./bin/step-g.exe ../brlcad/db/nist/NIST_MBE_PMI_3.stp -o nist3.g
|
||||
cd ..
|
||||
|
||||
+22
@@ -1,3 +1,25 @@
|
||||
# Common build directories used in the source tree
|
||||
/build
|
||||
/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
|
||||
|
||||
# Parser generator intermediate files
|
||||
*.out
|
||||
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
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,6 +19,7 @@ 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)
|
||||
|
||||
+235
-50
@@ -40,57 +40,248 @@
|
||||
|
||||
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 8-dev)
|
||||
set(SC_VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR})
|
||||
set(SC_VERSION_MINOR 9)
|
||||
set(SC_VERSION_PATCH 1)
|
||||
set(SC_VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR}.${SC_VERSION_PATCH})
|
||||
|
||||
# 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)
|
||||
# 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)
|
||||
|
||||
# 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")
|
||||
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)
|
||||
list(APPEND CMAKE_MODULE_PATH "${SC_CMAKE_DIR}")
|
||||
|
||||
# testing and compilation options, build output dirs, install dirs, uninstall, package creation, etc
|
||||
include(${SC_CMAKE_DIR}/SC_Build_opts.cmake)
|
||||
# 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_ENABLE_ADDRESS_SANITIZER "Enable AddressSanitizer instrumentation" OFF)
|
||||
option(SC_ENABLE_UNDEFINED_SANITIZER "Enable UndefinedBehaviorSanitizer instrumentation" OFF)
|
||||
option(SC_ENABLE_THREAD_SANITIZER "Enable ThreadSanitizer instrumentation" OFF)
|
||||
|
||||
if(SC_ENABLE_THREAD_SANITIZER AND
|
||||
(SC_ENABLE_ADDRESS_SANITIZER OR SC_ENABLE_UNDEFINED_SANITIZER))
|
||||
message(FATAL_ERROR
|
||||
"SC_ENABLE_THREAD_SANITIZER must use a separate build from "
|
||||
"AddressSanitizer and UndefinedBehaviorSanitizer"
|
||||
)
|
||||
endif()
|
||||
|
||||
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)
|
||||
|
||||
# SC_ADDEXEC and SC_ADDLIB macros, dllimport/export, etc
|
||||
include(${SC_CMAKE_DIR}/SC_Targets.cmake)
|
||||
include(SC_Targets)
|
||||
|
||||
# Macros related to paths
|
||||
include(${SC_CMAKE_DIR}/SC_Paths.cmake)
|
||||
include(SC_Paths)
|
||||
|
||||
# locale stuff
|
||||
include(${SC_CMAKE_DIR}/SC_Locale.cmake)
|
||||
include(SC_Locale)
|
||||
|
||||
# logic related to regenerating the lexer and parser source code
|
||||
include(${SC_CMAKE_DIR}/SC_Regenerate.cmake)
|
||||
include(SC_Regenerate)
|
||||
|
||||
# create config.h header
|
||||
include(SC_Config_Headers)
|
||||
|
||||
# Apply sanitizer instrumentation after configure-time feature tests so their
|
||||
# try-compile executables do not depend on sanitizer runtime behavior. Keep
|
||||
# link flags explicit for CMake 3.12 compatibility (add_link_options was added
|
||||
# in CMake 3.13).
|
||||
if(SC_ENABLE_ADDRESS_SANITIZER OR
|
||||
SC_ENABLE_UNDEFINED_SANITIZER OR
|
||||
SC_ENABLE_THREAD_SANITIZER)
|
||||
if(MSVC)
|
||||
message(FATAL_ERROR "STEPcode sanitizer builds are not yet supported with MSVC")
|
||||
endif()
|
||||
|
||||
include(CMakePushCheckState)
|
||||
include(CheckCSourceCompiles)
|
||||
include(CheckCXXSourceCompiles)
|
||||
include(CheckCCompilerFlag)
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
set(_sc_sanitizer_compile_options)
|
||||
set(_sc_sanitizer_link_options)
|
||||
|
||||
function(sc_require_sanitizer FLAG RESULT_PREFIX)
|
||||
cmake_push_check_state()
|
||||
set(CMAKE_REQUIRED_FLAGS "${FLAG}")
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES "${FLAG}")
|
||||
check_c_source_compiles("int main(void) { return 0; }" ${RESULT_PREFIX}_C_SUPPORTED)
|
||||
check_cxx_source_compiles("int main() { return 0; }" ${RESULT_PREFIX}_CXX_SUPPORTED)
|
||||
cmake_pop_check_state()
|
||||
if(NOT ${RESULT_PREFIX}_C_SUPPORTED OR NOT ${RESULT_PREFIX}_CXX_SUPPORTED)
|
||||
message(FATAL_ERROR
|
||||
"STEPcode sanitizer mode was requested, but the C/C++ compiler and "
|
||||
"linker do not support ${FLAG}"
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
if(SC_ENABLE_ADDRESS_SANITIZER)
|
||||
sc_require_sanitizer("-fsanitize=address" SC_ASAN)
|
||||
list(APPEND _sc_sanitizer_compile_options -fsanitize=address)
|
||||
list(APPEND _sc_sanitizer_link_options -fsanitize=address)
|
||||
# exp2cxx is executed during the build to generate schema bindings. It
|
||||
# remains address-instrumented, but leak checking a short-lived build
|
||||
# tool is both outside the test scope and unsupported under common build
|
||||
# tracers/sandboxes. Limit this environment to schema generation; CTest
|
||||
# and installed tools retain the user's normal ASan settings.
|
||||
set(SC_SCHEMA_GENERATOR_ENVIRONMENT "ASAN_OPTIONS=detect_leaks=0")
|
||||
endif()
|
||||
|
||||
if(SC_ENABLE_UNDEFINED_SANITIZER)
|
||||
sc_require_sanitizer("-fsanitize=undefined" SC_UBSAN)
|
||||
cmake_push_check_state()
|
||||
set(CMAKE_REQUIRED_FLAGS "-fsanitize=undefined")
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES "-fsanitize=undefined")
|
||||
check_c_compiler_flag(
|
||||
"-fno-sanitize-recover=undefined"
|
||||
SC_UBSAN_C_NO_RECOVER_SUPPORTED
|
||||
)
|
||||
check_cxx_compiler_flag(
|
||||
"-fno-sanitize-recover=undefined"
|
||||
SC_UBSAN_CXX_NO_RECOVER_SUPPORTED
|
||||
)
|
||||
cmake_pop_check_state()
|
||||
if(NOT SC_UBSAN_C_NO_RECOVER_SUPPORTED OR
|
||||
NOT SC_UBSAN_CXX_NO_RECOVER_SUPPORTED)
|
||||
message(FATAL_ERROR
|
||||
"STEPcode's fail-fast UndefinedBehaviorSanitizer mode was requested, "
|
||||
"but the C/C++ compiler does not support "
|
||||
"-fno-sanitize-recover=undefined"
|
||||
)
|
||||
endif()
|
||||
list(APPEND _sc_sanitizer_compile_options
|
||||
-fsanitize=undefined
|
||||
-fno-sanitize-recover=undefined
|
||||
)
|
||||
list(APPEND _sc_sanitizer_link_options -fsanitize=undefined)
|
||||
endif()
|
||||
|
||||
if(SC_ENABLE_THREAD_SANITIZER)
|
||||
sc_require_sanitizer("-fsanitize=thread" SC_TSAN)
|
||||
list(APPEND _sc_sanitizer_compile_options -fsanitize=thread)
|
||||
list(APPEND _sc_sanitizer_link_options -fsanitize=thread)
|
||||
endif()
|
||||
|
||||
check_c_compiler_flag("-fno-omit-frame-pointer" SC_SANITIZER_C_FRAME_POINTER_SUPPORTED)
|
||||
check_cxx_compiler_flag("-fno-omit-frame-pointer" SC_SANITIZER_CXX_FRAME_POINTER_SUPPORTED)
|
||||
if(SC_SANITIZER_C_FRAME_POINTER_SUPPORTED)
|
||||
list(APPEND _sc_sanitizer_compile_options
|
||||
$<$<COMPILE_LANGUAGE:C>:-fno-omit-frame-pointer>
|
||||
)
|
||||
endif()
|
||||
if(SC_SANITIZER_CXX_FRAME_POINTER_SUPPORTED)
|
||||
list(APPEND _sc_sanitizer_compile_options
|
||||
$<$<COMPILE_LANGUAGE:CXX>:-fno-omit-frame-pointer>
|
||||
)
|
||||
endif()
|
||||
|
||||
add_compile_options(${_sc_sanitizer_compile_options})
|
||||
string(JOIN " " _sc_sanitizer_link_flags ${_sc_sanitizer_link_options})
|
||||
foreach(_sc_link_type EXE SHARED MODULE)
|
||||
set(
|
||||
CMAKE_${_sc_link_type}_LINKER_FLAGS
|
||||
"${CMAKE_${_sc_link_type}_LINKER_FLAGS} ${_sc_sanitizer_link_flags}"
|
||||
)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
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 DEFINED SC_BUILD_SCHEMAS)
|
||||
if(NOT "${SC_BUILD_EXPRESS_ONLY}" AND NOT DEFINED SC_BUILD_SCHEMAS)
|
||||
list(APPEND CONFIG_END_MESSAGES
|
||||
"** 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)
|
||||
"** 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()
|
||||
|
||||
if(NOT SC_IS_SUBBUILD)
|
||||
list(APPEND CONFIG_END_MESSAGES
|
||||
@@ -99,23 +290,14 @@ 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)
|
||||
else()
|
||||
endif()
|
||||
if (${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
|
||||
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(
|
||||
@@ -123,8 +305,6 @@ 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)
|
||||
@@ -141,13 +321,19 @@ if(SC_ENABLE_TESTING)
|
||||
endif(SC_ENABLE_TESTING)
|
||||
add_subdirectory(doc)
|
||||
|
||||
# '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()
|
||||
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)
|
||||
|
||||
|
||||
# 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.
|
||||
@@ -161,4 +347,3 @@ endforeach(_msg ${CONFIG_END_MESSAGES})
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
|
||||
+4
-1
@@ -11,9 +11,12 @@ 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.
|
||||
* 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`.
|
||||
- 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`.
|
||||
|
||||
## Coding Standards
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ This repo was moved and renamed in May 2012. Previously, it was at
|
||||
http://github.com/mpictor/StepClassLibrary
|
||||
|
||||
Some are duplicates of changes recorded in the BRL-CAD repo:
|
||||
http://brlcad.svn.sourceforge.net/viewvc/brlcad/brlcad/trunk/src/other/step/?view=log
|
||||
https://github.com/BRL-CAD/brlcad/tree/158beae4556d94821938368951546384cba53107/src/other/ext/stepcode
|
||||
|
||||
Pre-BRL-CAD changes:
|
||||
************************************************************************
|
||||
|
||||
@@ -51,7 +51,13 @@ Installation
|
||||
-DSC_BUILD_SCHEMAS=ALL
|
||||
- Added to make use of ctest easier. If SC_BUILD_SCHEMAS == ALL,
|
||||
then CMake adds each *.exp file found in data/.
|
||||
-DSC_BUILD_TYPE=Release
|
||||
-DSC_EXP2CXX_API_VERSION=2
|
||||
- opts in to compact descriptor-driven SELECTs and dependency-bounded
|
||||
entity headers in the generated C++ API.
|
||||
- clients include the entity headers they use (for example,
|
||||
entity/SdaiProduct.h); schema.h no longer expands every entity class.
|
||||
- version 1 remains the default for source compatibility.
|
||||
-DCMAKE_BUILD_TYPE=Release
|
||||
- this causes binaries to be built without debugging information
|
||||
- without this, cmake defaults to a Debug build
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
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,10 +1,7 @@
|
||||
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 -- stepcode.org, github.com/stepcode/stepcode
|
||||
STEPcode v0.8 -- 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
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
0.8
|
||||
+115
-94
@@ -48,111 +48,132 @@ 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)
|
||||
|
||||
if(NOT LEMON_TEMPLATE)
|
||||
message(SEND_ERROR "failed to find lemon template (lempar.c)")
|
||||
endif()
|
||||
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})
|
||||
# ====================================================================
|
||||
# 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()
|
||||
|
||||
include(CMakeParseArguments)
|
||||
# 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})
|
||||
# ====================================================================
|
||||
|
||||
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})
|
||||
include(CMakeParseArguments)
|
||||
|
||||
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 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})
|
||||
|
||||
# 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)
|
||||
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()
|
||||
|
||||
# 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}")
|
||||
# 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()
|
||||
|
||||
# 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}")
|
||||
# set report file
|
||||
set(_out_rpt_file "${_basename}.out")
|
||||
|
||||
endmacro(LEMON_TARGET)
|
||||
endif(NOT COMMAND LEMON_TARGET)
|
||||
# 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()
|
||||
|
||||
endif()
|
||||
# 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} ${_basename}.h
|
||||
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} ${_basename}.h
|
||||
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)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(LEMON REQUIRED_VARS LEMON_EXECUTABLE LEMON_TEMPLATE)
|
||||
|
||||
+10
-2
@@ -227,6 +227,14 @@ 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)
|
||||
|
||||
@@ -240,12 +248,12 @@ if(NOT COMMAND ADD_PERPLEX_LEMON_DEPENDENCY)
|
||||
message(SEND_ERROR "PERPLEX target `${PERPLEXTarget}' does not exists.")
|
||||
endif()
|
||||
|
||||
if(NOT LEMON_${LemonTarget}_HDR)
|
||||
if(NOT TARGET ${LemonTarget})
|
||||
message(SEND_ERROR "Lemon target `${LemonTarget}' does not exists.")
|
||||
endif()
|
||||
|
||||
set_source_files_properties(${PERPLEX_${PERPLEXTarget}_SRC}
|
||||
PROPERTIES OBJECT_DEPENDS ${LEMON_${LemonTarget}_HDR})
|
||||
PROPERTIES OBJECT_DEPENDS ${LEMON_${LemonTarget}_OUTPUT_HEADER})
|
||||
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)
|
||||
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()
|
||||
#============================================================
|
||||
# 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})
|
||||
|
||||
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_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()
|
||||
|
||||
# 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)
|
||||
#============================================================
|
||||
if(NOT "${RE2C_TARGET_ARG_DEFINES_FILE}" STREQUAL "")
|
||||
list(APPEND RE2C_EXECUTABLE_opts -t ${RE2C_TARGET_ARG_DEFINES_FILE})
|
||||
endif()
|
||||
|
||||
#============================================================
|
||||
# ADD_RE2C_LEMON_DEPENDENCY (public macro)
|
||||
#============================================================
|
||||
#
|
||||
if(NOT COMMAND ADD_RE2C_LEMON_DEPENDENCY)
|
||||
macro(ADD_RE2C_LEMON_DEPENDENCY RE2CTarget LemonTarget)
|
||||
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_${RE2CTarget}_OUTPUTS)
|
||||
message(SEND_ERROR "RE2C target `${RE2CTarget}' does not exists.")
|
||||
endif()
|
||||
# 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 LEMON_${LemonTarget}_OUTPUT_HEADER)
|
||||
message(SEND_ERROR "Lemon target `${LemonTarget}' does not exists.")
|
||||
endif()
|
||||
endfunction(RE2C_TARGET)
|
||||
endif(NOT COMMAND RE2C_TARGET)
|
||||
#============================================================
|
||||
|
||||
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)
|
||||
#============================================================
|
||||
#============================================================
|
||||
# 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)
|
||||
#============================================================
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
# 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
|
||||
@@ -0,0 +1,164 @@
|
||||
# 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
|
||||
@@ -1,176 +0,0 @@
|
||||
# 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,20 +27,29 @@ 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" LINK_LIBRARIES ${PROJECT_NAME} stepdai stepcore stepeditor steputils base TESTABLE)
|
||||
#add_dependencies(p21read_${PROJECT_NAME} version_string)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
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)
|
||||
elseif(BUILD_STATIC_LIBS)
|
||||
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}-static stepeditor-static stepcore-static stepdai-static steputils-static TESTABLE)
|
||||
endif()
|
||||
if(NOT WIN32)
|
||||
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)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
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)
|
||||
elseif(BUILD_STATIC_LIBS)
|
||||
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}-static steplazyfile-static stepeditor-static stepcore-static stepdai-static steputils-static TESTABLE)
|
||||
endif()
|
||||
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 base TESTABLE)
|
||||
add_dependencies(${name}_${PROJECT_NAME} version_string)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
SC_ADDEXEC(${name}_${PROJECT_NAME} SOURCES ${src} LINK_LIBRARIES ${PROJECT_NAME} stepdai stepcore stepeditor steputils TESTABLE)
|
||||
elseif(BUILD_STATIC_LIBS)
|
||||
SC_ADDEXEC(${name}_${PROJECT_NAME} SOURCES ${src} LINK_LIBRARIES ${PROJECT_NAME}-static stepcore-static stepdai-static stepeditor-static steputils-static TESTABLE)
|
||||
#set_target_properties(${name}_${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${${PROJECT_NAME}_COMPILE_FLAGS} -I${path}")
|
||||
endif()
|
||||
endforeach(src ${SC_SDAI_ADDITIONAL_EXES_SRCS})
|
||||
ENDMACRO(SCHEMA_EXES)
|
||||
|
||||
@@ -80,37 +89,62 @@ macro(SCHEMA_TARGETS expFile schemaName sourceFiles)
|
||||
# schema scanner comes up with a short schema name for PROJECT() (which sets ${PROJECT_NAME})
|
||||
message(STATUS "Will generate ${${PROJECT_NAME}_file_count} C++ files for ${PROJECT_NAME}.")
|
||||
|
||||
add_custom_target(generate_cpp_${PROJECT_NAME} DEPENDS exp2cxx ${expFile} ${sourceFiles} SOURCES ${sourceFiles})
|
||||
set(_schema_generated_files)
|
||||
foreach(_schema_source ${sourceFiles})
|
||||
list(APPEND _schema_generated_files "${CMAKE_CURRENT_SOURCE_DIR}/${_schema_source}")
|
||||
endforeach()
|
||||
add_custom_target(generate_cpp_${PROJECT_NAME} DEPENDS exp2cxx ${expFile} ${_schema_generated_files} SOURCES ${_schema_generated_files})
|
||||
# this calls a cmake script because it doesn't seem to be possible
|
||||
# to divert stdout, stderr in cmake except via execute_process
|
||||
add_custom_command(OUTPUT ${sourceFiles}
|
||||
add_custom_command(OUTPUT ${_schema_generated_files}
|
||||
COMMAND ${CMAKE_COMMAND} -DEXE=\"$<TARGET_FILE:exp2cxx>\" -DEXP=\"${expFile}\"
|
||||
-DONESHOT=\"${SC_GENERATE_CXX_ONESHOT}\" -DSDIR=\"${CMAKE_CURRENT_LIST_DIR}\"
|
||||
-DCHUNK_SIZE=\"${SC_EXP2CXX_CHUNK_SIZE}\"
|
||||
-DAPI_VERSION=\"${SC_EXP2CXX_API_VERSION}\"
|
||||
-DLATE_BOUND=\"${SC_EXP2CXX_LATE_BOUND}\"
|
||||
-DCOMPAT_NAMES=\"${SC_EXP2CXX_COMPAT_NAMES}\"
|
||||
-DMETADATA_PROFILE=\"${SC_EXP2CXX_METADATA}\"
|
||||
-DGENERATOR_ENVIRONMENT=\"${SC_SCHEMA_GENERATOR_ENVIRONMENT}\"
|
||||
-P ${SC_CMAKE_DIR}/SC_Run_exp2cxx.cmake
|
||||
DEPENDS exp2cxx ${expFile}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
||||
COMMENT "[exp2cxx] Generating ${${PROJECT_NAME}_file_count} C++ files for ${PROJECT_NAME}."
|
||||
)
|
||||
include_directories(
|
||||
set(_schema_include_dirs
|
||||
${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/base
|
||||
${SC_SOURCE_DIR}/src/base/judy/src
|
||||
${SC_SOURCE_DIR}/src/clutils ${SC_SOURCE_DIR}/src/clstepcore ${SC_SOURCE_DIR}/src/cllazyfile
|
||||
${SC_SOURCE_DIR}/src/cllazyfile/judy/src
|
||||
)
|
||||
# if testing is enabled, "TESTABLE" sets property EXCLUDE_FROM_ALL and prevents installation
|
||||
if($CACHE{SC_BUILD_SHARED_LIBS})
|
||||
SC_ADDLIB(${PROJECT_NAME} SHARED SOURCES ${sourceFiles} LINK_LIBRARIES stepdai stepcore stepeditor steputils base TESTABLE)
|
||||
# Schema libraries should be installed by default
|
||||
if(BUILD_SHARED_LIBS)
|
||||
SC_ADDLIB(${PROJECT_NAME} SHARED SOURCES ${_schema_generated_files} LINK_LIBRARIES stepdai stepcore stepeditor steputils)
|
||||
add_dependencies(${PROJECT_NAME} generate_cpp_${PROJECT_NAME})
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${_schema_include_dirs})
|
||||
if(${PROJECT_NAME}_unity_build)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE SC_SDAI_UNITY_BUILD)
|
||||
endif()
|
||||
if(WIN32)
|
||||
target_compile_definitions("${PROJECT_NAME}" PRIVATE SC_SCHEMA_DLL_EXPORTS)
|
||||
if(MSVC)
|
||||
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 base-static TESTABLE)
|
||||
if(BUILD_STATIC_LIBS)
|
||||
SC_ADDLIB(${PROJECT_NAME}-static STATIC SOURCES ${_schema_generated_files} LINK_LIBRARIES stepcore-static stepdai-static stepeditor-static steputils-static)
|
||||
add_dependencies(${PROJECT_NAME}-static generate_cpp_${PROJECT_NAME})
|
||||
target_compile_defines("${PROJECT_NAME}-static" PRIVATE SC_STATIC)
|
||||
target_include_directories(${PROJECT_NAME}-static PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${_schema_include_dirs})
|
||||
target_compile_definitions("${PROJECT_NAME}-static" PRIVATE SC_STATIC)
|
||||
if(${PROJECT_NAME}_unity_build)
|
||||
target_compile_definitions(${PROJECT_NAME}-static PRIVATE SC_SDAI_UNITY_BUILD)
|
||||
endif()
|
||||
if(MSVC)
|
||||
target_compile_options("${PROJECT_NAME}-static" PRIVATE "/bigobj")
|
||||
endif()
|
||||
@@ -130,4 +164,3 @@ endmacro(SCHEMA_TARGETS expFile schemaName sourceFiles)
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
|
||||
@@ -1,23 +1,4 @@
|
||||
# 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}")
|
||||
# create config.h
|
||||
|
||||
include(CheckLibraryExists)
|
||||
include(CheckIncludeFile)
|
||||
@@ -96,37 +77,9 @@ int main() {return !(f() == f());}
|
||||
cmake_pop_check_state()
|
||||
endif(SC_ENABLE_CXX11)
|
||||
|
||||
# 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 )
|
||||
# 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)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
|
||||
@@ -29,8 +29,9 @@ 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 1.0.3 ${_verbosity})
|
||||
|
||||
find_package(RE2C ${_verbosity})
|
||||
find_package(PERPLEX ${_verbosity})
|
||||
|
||||
if(LEMON_FOUND AND RE2C_FOUND)
|
||||
set(SC_GENERATE_LP_SOURCES 1)
|
||||
message(".. Found re2c, and lemon - can regenerate lexer/parser if necessary")
|
||||
|
||||
@@ -1,10 +1,26 @@
|
||||
|
||||
# if oneshot is true, don't run exp2cxx if source files exist. if schema.cc exists, assume others do
|
||||
if(NOT DEFINED API_VERSION OR "${API_VERSION}" STREQUAL "")
|
||||
set(API_VERSION 1)
|
||||
endif()
|
||||
if(NOT DEFINED METADATA_PROFILE OR "${METADATA_PROFILE}" STREQUAL "")
|
||||
set(METADATA_PROFILE full)
|
||||
endif()
|
||||
|
||||
if(ONESHOT AND EXISTS "${SDIR}/schema.cc")
|
||||
message("WARNING: SC_GENERATE_CXX_ONESHOT is enabled. If generated code has been modified, it will NOT be rewritten!")
|
||||
message("This is ONLY for debugging STEPcode internals!")
|
||||
else()
|
||||
execute_process(COMMAND ${EXE} ${EXP}
|
||||
set(_exp2cxx_mode_args)
|
||||
if(LATE_BOUND)
|
||||
list(APPEND _exp2cxx_mode_args --late-bound)
|
||||
endif()
|
||||
if(COMPAT_NAMES)
|
||||
list(APPEND _exp2cxx_mode_args --compat-names)
|
||||
endif()
|
||||
list(APPEND _exp2cxx_mode_args --metadata ${METADATA_PROFILE})
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E env ${GENERATOR_ENVIRONMENT}
|
||||
${EXE} -k ${CHUNK_SIZE} -V ${API_VERSION} ${_exp2cxx_mode_args} ${EXP}
|
||||
WORKING_DIRECTORY ${SDIR}
|
||||
RESULT_VARIABLE _res
|
||||
OUTPUT_FILE exp2cxx_stdout.txt
|
||||
@@ -22,4 +38,3 @@ endif()
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
|
||||
+26
-10
@@ -10,15 +10,23 @@ macro(SC_ADDEXEC execname)
|
||||
|
||||
add_executable(${execname} ${${_arg_prefix}_SOURCES})
|
||||
|
||||
if(BUILD_STATIC_LIBS)
|
||||
target_compile_definitions(${execname} PRIVATE SC_STATIC)
|
||||
endif()
|
||||
|
||||
if(DEFINED "${_arg_prefix}_LINK_LIBRARIES")
|
||||
foreach(_lib ${${_arg_prefix}_LINK_LIBRARIES})
|
||||
if($CACHE{SC_STATIC_UTILS})
|
||||
if(NOT $<TARGET_PROPERTY:${_lib},TYPE> STREQUAL "STATIC_LIBRARY")
|
||||
get_property(_lib_type TARGET ${_lib} PROPERTY TYPE)
|
||||
if(NOT _lib_type STREQUAL "STATIC_LIBRARY")
|
||||
message(SEND_ERROR "SC_ADDEXEC usage error - expected STATIC LINK_LIBRARIES targets (${_lib})")
|
||||
endif()
|
||||
endif()
|
||||
target_link_libraries(${execname} ${_lib})
|
||||
# Executables consume their dependencies but do not publish an
|
||||
# interface to downstream targets.
|
||||
target_link_libraries(${execname} PRIVATE ${_lib})
|
||||
endforeach()
|
||||
target_link_libraries(${execname} PRIVATE ${${_arg_prefix}_LINK_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(NOT ${_arg_prefix}_NO_INSTALL AND NOT ${_arg_prefix}_TESTABLE)
|
||||
@@ -37,7 +45,7 @@ endmacro()
|
||||
macro(SC_ADDLIB _addlib_target)
|
||||
set(_addlib_opts SHARED STATIC NO_INSTALL TESTABLE)
|
||||
set(_addlib_multikw SOURCES LINK_LIBRARIES)
|
||||
string(TOUPPER "SC_ADDLIB_${libname}_ARG" _arg_prefix)
|
||||
string(TOUPPER "SC_ADDLIB_${_addlib_target}_ARG" _arg_prefix)
|
||||
cmake_parse_arguments(${_arg_prefix} "${_addlib_opts}" "" "${_addlib_multikw}" ${ARGN})
|
||||
|
||||
if(NOT DEFINED ${_arg_prefix}_SOURCES)
|
||||
@@ -46,7 +54,11 @@ macro(SC_ADDLIB _addlib_target)
|
||||
|
||||
if(${_arg_prefix}_SHARED)
|
||||
add_library(${_addlib_target} SHARED ${${_arg_prefix}_SOURCES})
|
||||
set_target_properties(${_addlib_target} PROPERTIES VERSION ${SC_ABI_VERSION} SOVERSION ${SC_ABI_SOVERSION})
|
||||
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)
|
||||
if(APPLE)
|
||||
set_target_properties(${_addlib_target} PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress")
|
||||
endif(APPLE)
|
||||
@@ -60,20 +72,25 @@ macro(SC_ADDLIB _addlib_target)
|
||||
if(DEFINED ${_arg_prefix}_LINK_LIBRARIES)
|
||||
foreach(_lib ${${_arg_prefix}_LINK_LIBRARIES})
|
||||
if(${_arg_prefix}_STATIC AND TARGET ${_lib})
|
||||
get_property(_libtype TARGET ${_lib} PROPERTY TYPE)
|
||||
if(NOT ${_libtype} STREQUAL "STATIC_LIBRARY")
|
||||
message(SEND_ERROR "SC_ADDLIB usage error - expected (static) LINK_LIBRARIES targets (${_lib})")
|
||||
get_property(_libtype TARGET ${_lib} PROPERTY TYPE)
|
||||
if(NOT ${_libtype} STREQUAL "STATIC_LIBRARY")
|
||||
message(SEND_ERROR "SC_ADDLIB usage error - expected (static) LINK_LIBRARIES targets (${_lib})")
|
||||
endif()
|
||||
endif()
|
||||
target_link_libraries(${_addlib_target} ${_lib})
|
||||
# Schema libraries are consumed directly by generated test programs.
|
||||
# Publish their link requirements explicitly; the legacy unscoped
|
||||
# signature does not reliably provide a transitive interface with
|
||||
# current CMake versions.
|
||||
target_link_libraries(${_addlib_target} PUBLIC ${_lib})
|
||||
endforeach()
|
||||
target_link_libraries(${_addlib_target} ${_lib})
|
||||
endif()
|
||||
|
||||
if(NOT ${_arg_prefix}_NO_INSTALL AND NOT ${_arg_prefix}_TESTABLE)
|
||||
install(TARGETS ${_addlib_target}
|
||||
RUNTIME DESTINATION ${BIN_DIR}
|
||||
LIBRARY DESTINATION ${LIB_DIR}
|
||||
ARCHIVE DESTINATION ${LIB_DIR}
|
||||
ARCHIVE DESTINATION ${LIB_DIR}
|
||||
)
|
||||
endif()
|
||||
endmacro()
|
||||
@@ -84,4 +101,3 @@ endmacro()
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
# 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
|
||||
@@ -1,30 +0,0 @@
|
||||
# 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
|
||||
@@ -1,84 +0,0 @@
|
||||
# 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.6.3)
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
|
||||
if(NOT ("${CALLED_FROM}" STREQUAL "STEPCODE_CMAKELISTS" AND DEFINED SC_ROOT AND DEFINED SC_BUILDDIR))
|
||||
message(" ${CALLED_FROM} ${SC_ROOT} ${SC_BUILDDIR}")
|
||||
@@ -16,15 +16,14 @@ 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
|
||||
@@ -32,6 +31,7 @@ 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,16 +44,13 @@ 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,22 +14,28 @@
|
||||
*/
|
||||
|
||||
extern "C" {
|
||||
# include "expparse.h"
|
||||
# include "expscan.h"
|
||||
# include "express/scope.h"
|
||||
# include "genCxxFilenames.h"
|
||||
# include "sc_mkdir.h"
|
||||
#define _XOPEN_SOURCE /* for S_IFDIR */
|
||||
|
||||
# include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
|
||||
# ifdef _WIN32
|
||||
# include <direct.h>
|
||||
# define getcwd _getcwd
|
||||
# else
|
||||
# include <unistd.h>
|
||||
# endif
|
||||
#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
|
||||
}
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
@@ -45,6 +51,35 @@ using std::ofstream;
|
||||
using std::cerr;
|
||||
using std::cout;
|
||||
|
||||
static unsigned long entityChunkSize = 256;
|
||||
static unsigned long typeChunkSize = 256;
|
||||
|
||||
static bool
|
||||
parseChunkSizes( const char * value )
|
||||
{
|
||||
if( !value || !value[0] ) {
|
||||
return false;
|
||||
}
|
||||
char * end = 0;
|
||||
const unsigned long entities = strtoul( value, &end, 10 );
|
||||
if( !end || entities == 0 ) {
|
||||
return false;
|
||||
}
|
||||
unsigned long types = entities;
|
||||
if( *end == ':' ) {
|
||||
char * typeEnd = 0;
|
||||
types = strtoul( end + 1, &typeEnd, 10 );
|
||||
if( !end[1] || !typeEnd || *typeEnd || types == 0 ) {
|
||||
return false;
|
||||
}
|
||||
} else if( *end ) {
|
||||
return false;
|
||||
}
|
||||
entityChunkSize = entities;
|
||||
typeChunkSize = types;
|
||||
return true;
|
||||
}
|
||||
|
||||
/** \return true for types that exp2cxx won't generate code for */
|
||||
bool notGenerated( const Type t ) {
|
||||
switch( TYPEget_body( t )->type ) {
|
||||
@@ -125,6 +160,30 @@ 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 ) {
|
||||
@@ -157,20 +216,34 @@ void writeLists( const char * schemaName, stringstream & eh, stringstream & ei,
|
||||
cmLists << "# targets, logic, etc are within a set of macros shared by all schemas" << endl;
|
||||
cmLists << "include(${SC_CMAKE_DIR}/SC_CXX_schema_macros.cmake)" << endl;
|
||||
|
||||
// * 2 for headers, + 10 other files
|
||||
cmLists << "set(" << shortName << "_file_count " << ( ( ecount + tcount ) * 2 ) + 10 << ")" << endl << endl;
|
||||
const int entityChunks = std::max( 1, ( ecount + static_cast<int>( entityChunkSize ) - 1 ) / static_cast<int>( entityChunkSize ) );
|
||||
const int typeChunks = std::max( 1, ( tcount + static_cast<int>( typeChunkSize ) - 1 ) / static_cast<int>( typeChunkSize ) );
|
||||
cmLists << "if(SC_EXP2CXX_LATE_BOUND)" << endl;
|
||||
cmLists << " set(" << shortName << "_file_count 10)" << endl;
|
||||
cmLists << "else()" << endl;
|
||||
cmLists << " set(" << shortName << "_file_count " <<
|
||||
( ecount + tcount ) * 2 + entityChunks + typeChunks + 14 << ")" << endl;
|
||||
cmLists << "endif()" << endl << endl;
|
||||
|
||||
|
||||
cmLists << "PROJECT(" << shortName << ")" << endl;
|
||||
cmLists << "# list headers so they can be installed - entity, type, misc" << endl;
|
||||
|
||||
cmLists << "set(" << shortName << "_entity_hdrs" << endl;
|
||||
cmLists << "if(SC_EXP2CXX_LATE_BOUND)" << endl;
|
||||
cmLists << " set(" << shortName << "_entity_hdrs)" << endl;
|
||||
cmLists << "else()" << endl;
|
||||
cmLists << " set(" << shortName << "_entity_hdrs" << endl;
|
||||
cmLists << eh.str();
|
||||
cmLists << " )" << endl << endl;
|
||||
cmLists << " )" << endl;
|
||||
cmLists << "endif()" << endl << endl;
|
||||
|
||||
cmLists << "set(" << shortName << "_type_hdrs" << endl;
|
||||
cmLists << "if(SC_EXP2CXX_LATE_BOUND)" << endl;
|
||||
cmLists << " set(" << shortName << "_type_hdrs)" << endl;
|
||||
cmLists << "else()" << endl;
|
||||
cmLists << " set(" << shortName << "_type_hdrs" << endl;
|
||||
cmLists << th.str();
|
||||
cmLists << " )" << endl << endl;
|
||||
cmLists << " )" << endl;
|
||||
cmLists << "endif()" << endl << endl;
|
||||
|
||||
cmLists << "set(" << shortName << "_misc_hdrs" << endl;
|
||||
cmLists << " Sdaiclasses.h schema.h" << endl;
|
||||
@@ -195,11 +268,26 @@ void writeLists( const char * schemaName, stringstream & eh, stringstream & ei,
|
||||
|
||||
cmLists << "# unity build: #include small .cc files to reduce the number" << endl;
|
||||
cmLists << "# of translation units that must be compiled" << endl;
|
||||
cmLists << "if(SC_UNITY_BUILD)" << endl << " # turns off include statements within type and entity .cc's - the unity T.U.'s include a unity header" << endl;
|
||||
cmLists << " add_definitions( -DSC_SDAI_UNITY_BUILD)" << endl;
|
||||
cmLists << " set(" << shortName << "_entity_impls Sdai" << schema_upper << "_unity_entities.cc)" << endl;
|
||||
cmLists << " set(" << shortName << "_type_impls Sdai" << schema_upper << "_unity_types.cc)" << endl;
|
||||
cmLists << "else(SC_UNITY_BUILD)" << endl;
|
||||
cmLists << "if(SC_EXP2CXX_LATE_BOUND)" << endl;
|
||||
cmLists << " set(" << shortName << "_unity_build FALSE)" << endl;
|
||||
cmLists << " set(" << shortName << "_entity_impls)" << endl;
|
||||
cmLists << " set(" << shortName << "_type_impls)" << endl;
|
||||
cmLists << "elseif(SC_UNITY_BUILD)" << endl;
|
||||
cmLists << " # bounded compact chunks; definitions are target-local" << endl;
|
||||
cmLists << " set(" << shortName << "_unity_build TRUE)" << endl;
|
||||
cmLists << " set(" << shortName << "_entity_impls" << endl;
|
||||
for( int chunk = 1; chunk <= entityChunks; ++chunk ) {
|
||||
cmLists << " Sdai" << schema_upper << "_unity_entities_" <<
|
||||
std::setfill( '0' ) << std::setw( 4 ) << chunk << ".cc" << endl;
|
||||
}
|
||||
cmLists << " )" << endl;
|
||||
cmLists << " set(" << shortName << "_type_impls" << endl;
|
||||
for( int chunk = 1; chunk <= typeChunks; ++chunk ) {
|
||||
cmLists << " Sdai" << schema_upper << "_unity_types_" <<
|
||||
std::setfill( '0' ) << std::setw( 4 ) << chunk << ".cc" << endl;
|
||||
}
|
||||
cmLists << " )" << endl;
|
||||
cmLists << "else()" << endl;
|
||||
cmLists << " set(" << shortName << "_entity_impls" << endl;
|
||||
cmLists << ei.str();
|
||||
cmLists << " )" << endl << endl;
|
||||
@@ -207,12 +295,13 @@ void writeLists( const char * schemaName, stringstream & eh, stringstream & ei,
|
||||
cmLists << " set(" << shortName << "_type_impls" << endl;
|
||||
cmLists << ti.str();
|
||||
cmLists << " )" << endl;
|
||||
cmLists << "endif(SC_UNITY_BUILD)" << endl << endl;
|
||||
cmLists << "endif()" << endl << endl;
|
||||
|
||||
cmLists << "set( " << shortName << "_misc_impls" << endl;
|
||||
cmLists << " SdaiAll.cc compstructs.cc schema.cc" << endl;
|
||||
cmLists << " Sdai" << schema_upper << ".cc" << endl;
|
||||
cmLists << " Sdai" << schema_upper << ".init.cc )" << endl << endl;
|
||||
cmLists << " Sdai" << schema_upper << ".init.cc" << endl;
|
||||
cmLists << " Sdai" << schema_upper << ".sources.cmake )" << endl << endl;
|
||||
|
||||
cmLists << "set(schema_target_files ${" << shortName << "_entity_impls} " << "${" << shortName << "_type_impls} " << "${" << shortName << "_misc_impls})" << endl;
|
||||
cmLists << "SCHEMA_TARGETS(\"" << input_filename << "\" \"" << schemaName << "\"" << endl;
|
||||
@@ -220,7 +309,7 @@ void writeLists( const char * schemaName, stringstream & eh, stringstream & ei,
|
||||
|
||||
cmLists.close();
|
||||
|
||||
char pwd[BUFSIZ] = {0};
|
||||
char pwd[BUFSIZ+1] = {0};
|
||||
if( getcwd( pwd, BUFSIZ ) ) {
|
||||
cout << pwd << "/" << shortName << endl;
|
||||
} else {
|
||||
@@ -301,14 +390,18 @@ int main( int argc, char ** argv ) {
|
||||
DictionaryEntry de;
|
||||
/* copied from fedex.c */
|
||||
Express model;
|
||||
if( ( argc != 2 ) || ( strlen( argv[1] ) < 1 ) ) {
|
||||
fprintf( stderr, "\nUsage: %s file.exp\nOutput: a CMakeLists.txt to build the schema,", argv[0] );
|
||||
if( ( argc != 2 && argc != 3 ) || ( strlen( argv[1] ) < 1 ) ) {
|
||||
fprintf( stderr, "\nUsage: %s file.exp [entity-chunk-size[:type-chunk-size]]\nOutput: a CMakeLists.txt to build the schema,", argv[0] );
|
||||
fprintf( stderr, " containing file names for entities, types, etc\n" );
|
||||
fprintf( stderr, "also prints (to stdout) the absolute path to the directory CMakeLists.txt was created in\n" );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
EXPRESSprogram_name = argv[0];
|
||||
input_filename = argv[1];
|
||||
if( argc == 3 && !parseChunkSizes( argv[2] ) ) {
|
||||
fprintf( stderr, "chunk sizes must be positive integers in N or N:N form\n" );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
EXPRESSinitialize();
|
||||
|
||||
|
||||
@@ -18,6 +18,44 @@ else(NOT DEFINED SC_UNITY_BUILD)
|
||||
message( STATUS "Respecting user-defined SC_UNITY_BUILD value of ${SC_UNITY_BUILD}.")
|
||||
endif(NOT DEFINED SC_UNITY_BUILD)
|
||||
|
||||
if(NOT DEFINED SC_EXP2CXX_CHUNK_SIZE)
|
||||
set(SC_EXP2CXX_CHUNK_SIZE "64:8" CACHE STRING "Maximum entity:type objects in generated unity translation units")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED SC_EXP2CXX_API_VERSION)
|
||||
set(SC_EXP2CXX_API_VERSION "1")
|
||||
endif()
|
||||
set(SC_EXP2CXX_API_VERSION "${SC_EXP2CXX_API_VERSION}" CACHE STRING "Generated C++ API version (1 or 2)")
|
||||
set_property(CACHE SC_EXP2CXX_API_VERSION PROPERTY STRINGS 1 2)
|
||||
if(NOT SC_EXP2CXX_API_VERSION MATCHES "^[12]$")
|
||||
message(FATAL_ERROR "SC_EXP2CXX_API_VERSION must be 1 or 2")
|
||||
endif()
|
||||
|
||||
option(SC_EXP2CXX_LATE_BOUND "Generate descriptor-backed entities without early-bound C++ entity classes" OFF)
|
||||
if(SC_EXP2CXX_LATE_BOUND AND NOT SC_EXP2CXX_API_VERSION STREQUAL "2")
|
||||
message(FATAL_ERROR "SC_EXP2CXX_LATE_BOUND requires SC_EXP2CXX_API_VERSION=2")
|
||||
endif()
|
||||
|
||||
option(SC_EXP2CXX_COMPAT_NAMES "Retain generated entity aliases in late-bound output" OFF)
|
||||
if(SC_EXP2CXX_COMPAT_NAMES AND NOT SC_EXP2CXX_LATE_BOUND)
|
||||
message(FATAL_ERROR "SC_EXP2CXX_COMPAT_NAMES requires SC_EXP2CXX_LATE_BOUND=ON")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED SC_EXP2CXX_METADATA)
|
||||
set(SC_EXP2CXX_METADATA "full")
|
||||
endif()
|
||||
set(SC_EXP2CXX_METADATA "${SC_EXP2CXX_METADATA}" CACHE STRING
|
||||
"Generated schema metadata profile (full or structural)")
|
||||
set_property(CACHE SC_EXP2CXX_METADATA PROPERTY STRINGS full structural)
|
||||
if(NOT SC_EXP2CXX_METADATA MATCHES "^(full|structural)$")
|
||||
message(FATAL_ERROR "SC_EXP2CXX_METADATA must be full or structural")
|
||||
endif()
|
||||
if(SC_EXP2CXX_METADATA STREQUAL "structural" AND
|
||||
NOT SC_EXP2CXX_LATE_BOUND)
|
||||
message(FATAL_ERROR
|
||||
"SC_EXP2CXX_METADATA=structural requires SC_EXP2CXX_LATE_BOUND=ON")
|
||||
endif()
|
||||
|
||||
|
||||
# --- variables ---
|
||||
# SC_ROOT: SC root dir
|
||||
@@ -71,9 +109,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_INSTALL_DIR})
|
||||
install(PROGRAMS ${SCANNER_OUT_DIR}/schema_scanner.exe DESTINATION ${BIN_DIR})
|
||||
else(WIN32)
|
||||
install(PROGRAMS ${SCANNER_OUT_DIR}/schema_scanner DESTINATION ${BIN_INSTALL_DIR})
|
||||
install(PROGRAMS ${SCANNER_OUT_DIR}/schema_scanner DESTINATION ${BIN_DIR})
|
||||
endif(WIN32)
|
||||
|
||||
# macro SCHEMA_CMLIST
|
||||
@@ -82,7 +120,7 @@ endif(WIN32)
|
||||
# SCHEMA_FILE - path to the schema
|
||||
# TODO should we have a result variable to return schema name(s) found?
|
||||
macro(SCHEMA_CMLIST SCHEMA_FILE)
|
||||
execute_process(COMMAND ${SCANNER_OUT_DIR}/schema_scanner ${SCHEMA_FILE}
|
||||
execute_process(COMMAND ${SCANNER_OUT_DIR}/schema_scanner ${SCHEMA_FILE} ${SC_EXP2CXX_CHUNK_SIZE}
|
||||
WORKING_DIRECTORY ${SC_BINARY_DIR}/schemas
|
||||
RESULT_VARIABLE _ss_stat
|
||||
OUTPUT_VARIABLE _ss_out
|
||||
@@ -97,7 +135,16 @@ macro(SCHEMA_CMLIST SCHEMA_FILE)
|
||||
string(STRIP "${_ss_out}" _ss_stripped)
|
||||
string(REGEX REPLACE "\\\n" ";" _list ${_ss_stripped})
|
||||
foreach(_dir ${_list})
|
||||
add_subdirectory(${_dir} ${_dir}) #specify source and binary dirs as the same
|
||||
get_property(_already_added GLOBAL PROPERTY _SC_SCHEMA_DIRS)
|
||||
list(FIND _already_added "${_dir}" _idx)
|
||||
if(${_idx} EQUAL -1)
|
||||
set_property(GLOBAL APPEND PROPERTY _SC_SCHEMA_DIRS "${_dir}")
|
||||
# Keep generated targets under the top-level binary tree. Passing the
|
||||
# absolute generated-source path as both arguments creates absolute
|
||||
# make target names with newer CMake.
|
||||
get_filename_component(_schema_dir_name "${_dir}" NAME)
|
||||
add_subdirectory("${_dir}" "${SC_BINARY_DIR}/schema-targets/${_schema_dir_name}")
|
||||
endif()
|
||||
endforeach(_dir ${_ss_out})
|
||||
# configure_file forces cmake to run again if the schema has been modified
|
||||
#if multiple schemas in one file, _schema is the last one printed.
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
# 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
@@ -9,7 +9,7 @@ set(CTEST_INITIAL_CACHE "
|
||||
SITE:STRING=${CTEST_SITE}
|
||||
BUILDNAME:STRING=${CTEST_BUILD_NAME}
|
||||
SC_ENABLE_TESTING:BOOL=ON
|
||||
SC_BUILD_TYPE:STRING=Debug
|
||||
CMAKE_BUILD_TYPE:STRING=Debug
|
||||
")
|
||||
|
||||
|
||||
|
||||
+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)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,62 @@
|
||||
# AP242 TREAT Schema File
|
||||
|
||||
This directory contains an altered version of the AP242 (ISO 10303-242) schema.
|
||||
|
||||
It is corrected to avoid the non-standard parsing requirement of the original
|
||||
by using explicit TREAT expression for type narrowing
|
||||
|
||||
## The Difference
|
||||
|
||||
Both files are identical except for a single line at line 34149 in the `styled_item` entity WHERE rule WR3:
|
||||
|
||||
**Original (242_mim_lf.exp)**:
|
||||
```express
|
||||
QUERY(it <* item | ...)
|
||||
```
|
||||
|
||||
**TREAT version (242_mim_lf_treat.exp)**:
|
||||
```express
|
||||
QUERY(it <* TREAT(item AS set_representation_item) | ...)
|
||||
```
|
||||
|
||||
### Historical Context
|
||||
The original AP242 schema contains a WHERE rule that:
|
||||
1. Checks if `item` (a SELECT type) is a `SET_REPRESENTATION_ITEM`
|
||||
2. Then tries to iterate over `item` in a QUERY expression
|
||||
|
||||
This pattern requires implicit type narrowing, which is not part of the ISO 10303-11 standard.
|
||||
|
||||
### STEPcode's Solution
|
||||
STEPcode implements **flow-sensitive type narrowing** as an extension:
|
||||
- Recognizes TYPEOF guard patterns like `'Type' IN TYPEOF(var)` in AND expressions
|
||||
- Automatically narrows the type for subsequent uses
|
||||
- Makes the original schema parse successfully
|
||||
|
||||
### Standards-Compliant Alternative
|
||||
The TREAT version uses the ISO 10303-11 TREAT expression:
|
||||
- `TREAT(item AS set_representation_item)` explicitly narrows the type
|
||||
- No implicit narrowing needed
|
||||
- Works in any compliant EXPRESS parser
|
||||
|
||||
## Testing
|
||||
|
||||
Both versions parse successfully and produce identical output:
|
||||
|
||||
```bash
|
||||
# Run comparison test
|
||||
./test/compare_ap242_versions.sh
|
||||
```
|
||||
|
||||
Expected output:
|
||||
```
|
||||
✓ Both versions parse successfully
|
||||
✓ Both versions generate the same number of files
|
||||
```
|
||||
|
||||
For detailed comparison, see `doc/ap242-comparison.md`.
|
||||
|
||||
## Related Documentation
|
||||
|
||||
- `doc/ap242-comparison.md` - Detailed comparison and analysis
|
||||
- `doc/express-type-unwrapping.md` - TREAT and narrowing documentation
|
||||
- `src/express/test/README_AP242_BASELINE.md` - Historical PE056 error info
|
||||
@@ -0,0 +1,165 @@
|
||||
# AP242 Schema Comparison: Flow-Sensitive Narrowing vs TREAT Expression
|
||||
|
||||
## Overview
|
||||
|
||||
This document compares two versions of the AP242 schema to demonstrate the difference between STEPcode's non-standard flow-sensitive narrowing extension and the ISO 10303-11 compliant TREAT expression.
|
||||
|
||||
## Schema Versions
|
||||
|
||||
### 1. Original Version (`242_mim_lf.exp`)
|
||||
- **Status**: Uses implicit flow-sensitive narrowing (non-standard extension)
|
||||
- **Location**: `data/ap242/242_mim_lf.exp`
|
||||
- **Size**: 54,756 lines
|
||||
- **Problematic code**: Line 34149 in `styled_item` entity, WR3 WHERE rule
|
||||
|
||||
### 2. TREAT Version (`242_mim_lf_treat.exp`)
|
||||
- **Status**: Standards-compliant using TREAT expression
|
||||
- **Location**: `data/ap242/242_mim_lf_treat.exp`
|
||||
- **Size**: 54,756 lines
|
||||
- **Fix applied**: Line 34149 - explicit TREAT expression
|
||||
|
||||
## The Problem
|
||||
|
||||
In the `styled_item` entity at line ~34148, the WHERE rule WR3 contains:
|
||||
|
||||
```express
|
||||
WR3: ('AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF.MAPPED_ITEM' IN TYPEOF(item)) OR
|
||||
('AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF.GEOMETRIC_REPRESENTATION_ITEM' IN TYPEOF(item)) OR
|
||||
(('AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF.SET_REPRESENTATION_ITEM' IN TYPEOF(item)) AND
|
||||
(SIZEOF(QUERY(it <* item | ...)) = 0));
|
||||
```
|
||||
|
||||
### Issue
|
||||
- `item` is of type `styled_item_target`, which is a SELECT type
|
||||
- The SELECT contains `set_representation_item` (which is an aggregate type)
|
||||
- The code checks `'SET_REPRESENTATION_ITEM' IN TYPEOF(item)` (a TYPEOF guard)
|
||||
- Then tries to iterate over `item` in a QUERY: `QUERY(it <* item | ...)`
|
||||
|
||||
### Why This Was Problematic
|
||||
According to strict ISO 10303-11 standards, you cannot iterate over a SELECT type directly in a QUERY expression, even if there's a preceding TYPEOF guard. The guard and the QUERY are separate expressions in an AND clause.
|
||||
|
||||
## The Solutions
|
||||
|
||||
### Solution 1: Flow-Sensitive Narrowing (Non-Standard Extension)
|
||||
|
||||
STEPcode implements a **flow-sensitive type narrowing** extension that:
|
||||
1. Recognizes the pattern `'TypeName' IN TYPEOF(var)` in AND expressions
|
||||
2. Automatically narrows the type of `var` to `TypeName` for subsequent expressions in the AND
|
||||
3. Allows `QUERY(it <* item | ...)` to work because `item` is implicitly narrowed to `set_representation_item`
|
||||
|
||||
**Code (original, line 34149)**:
|
||||
```express
|
||||
QUERY(it <* item | ...)
|
||||
```
|
||||
|
||||
**How it works**:
|
||||
- The AND expression LHS has the guard: `'SET_REPRESENTATION_ITEM' IN TYPEOF(item)`
|
||||
- The RHS has the QUERY: `SIZEOF(QUERY(it <* item | ...)) = 0`
|
||||
- STEPcode's narrowing recognizes the pattern and narrows `item` to `set_representation_item`
|
||||
- The QUERY can now iterate over the narrowed type
|
||||
|
||||
### Solution 2: TREAT Expression (Standards-Compliant)
|
||||
|
||||
The ISO 10303-11 standard provides the TREAT expression for explicit type narrowing:
|
||||
|
||||
**Code (TREAT version, line 34149)**:
|
||||
```express
|
||||
QUERY(it <* TREAT(item AS set_representation_item) | ...)
|
||||
```
|
||||
|
||||
**How it works**:
|
||||
- `TREAT(item AS set_representation_item)` explicitly narrows the SELECT type to the member type
|
||||
- The QUERY can iterate over the result of TREAT, which is guaranteed to be `set_representation_item`
|
||||
- No implicit narrowing needed - the intent is explicit in the code
|
||||
|
||||
## The Exact Difference
|
||||
|
||||
```diff
|
||||
--- data/ap242/242_mim_lf.exp
|
||||
+++ data/ap242/242_mim_lf_treat.exp
|
||||
@@ -34146,7 +34146,7 @@
|
||||
('AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF.GEOMETRIC_REPRESENTATION_ITEM' IN TYPEOF(item)) OR
|
||||
(('AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF.SET_REPRESENTATION_ITEM' IN TYPEOF(item)) AND
|
||||
(SIZEOF(QUERY(it
|
||||
- <* item
|
||||
+ <* TREAT(item AS set_representation_item)
|
||||
| NOT (('AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF.MAPPED_ITEM' IN TYPEOF(it)) OR
|
||||
('AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF.GEOMETRIC_REPRESENTATION_ITEM' IN
|
||||
TYPEOF(it))))) =
|
||||
```
|
||||
|
||||
**Change**: Single line change from `<* item` to `<* TREAT(item AS set_representation_item)`
|
||||
|
||||
## Testing Results
|
||||
|
||||
### Original Version (with Flow-Sensitive Narrowing)
|
||||
```bash
|
||||
./build/bin/exp2cxx data/ap242/242_mim_lf.exp /tmp/ap242_original_test
|
||||
```
|
||||
**Result**: ✅ Parses successfully, generates 5,626 C++ files
|
||||
|
||||
### TREAT Version (Standards-Compliant)
|
||||
```bash
|
||||
./build/bin/exp2cxx data/ap242/242_mim_lf_treat.exp /tmp/ap242_treat_test
|
||||
```
|
||||
**Result**: ✅ Parses successfully, generates 5,626 C++ files
|
||||
|
||||
### Output Comparison
|
||||
Both versions generate identical output:
|
||||
- Same number of entities
|
||||
- Same entity relationships
|
||||
- Same multiple inheritance warnings
|
||||
- Identical "Finished writing files" status
|
||||
|
||||
## Verification
|
||||
|
||||
To verify both versions produce consistent output:
|
||||
|
||||
```bash
|
||||
# Parse original version
|
||||
mkdir -p /tmp/ap242_original
|
||||
./build/bin/exp2cxx data/ap242/242_mim_lf.exp /tmp/ap242_original
|
||||
|
||||
# Parse TREAT version
|
||||
mkdir -p /tmp/ap242_treat
|
||||
./build/bin/exp2cxx data/ap242/242_mim_lf_treat.exp /tmp/ap242_treat
|
||||
|
||||
# Compare generated headers (should be identical except for file references)
|
||||
diff /tmp/ap242_original/SdaiAP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF.h \
|
||||
/tmp/ap242_treat/SdaiAP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF.h
|
||||
```
|
||||
|
||||
## Implications
|
||||
|
||||
### For STEPcode Users
|
||||
- **Current**: Both versions work due to flow-sensitive narrowing extension
|
||||
- **Future**: TREAT version is more portable if other EXPRESS parsers are used
|
||||
- **Recommended**: Use TREAT for new schemas to ensure standards compliance
|
||||
|
||||
### For STEPcode Development
|
||||
- Flow-sensitive narrowing is a valuable usability extension
|
||||
- TREAT expression provides standards-compliant alternative
|
||||
- Both should continue to be supported for compatibility
|
||||
|
||||
### For Standards Compliance
|
||||
- Original AP242 schema uses pattern that requires extension
|
||||
- TREAT version is fully ISO 10303-11 compliant
|
||||
- TREAT makes intent explicit and improves code clarity
|
||||
|
||||
## Related Documentation
|
||||
|
||||
- `doc/express-type-unwrapping.md` - Full documentation of TREAT and narrowing features
|
||||
- `src/express/test/README_AP242_BASELINE.md` - Historical PE056 error documentation
|
||||
- Test schemas:
|
||||
- `test/unitary_schemas/flow_narrowing_test.exp` - Flow-sensitive narrowing examples
|
||||
- `test/unitary_schemas/minimal_treat_test.exp` - TREAT expression examples
|
||||
|
||||
## Conclusion
|
||||
|
||||
This comparison demonstrates:
|
||||
1. ✅ STEPcode's flow-sensitive narrowing successfully handles the original AP242 schema
|
||||
2. ✅ TREAT expression provides the standards-compliant alternative
|
||||
3. ✅ Both approaches produce identical, correct output
|
||||
4. ✅ The single-line change makes the code more explicit and portable
|
||||
|
||||
The availability of both approaches gives users flexibility while maintaining standards compliance when needed.
|
||||
@@ -0,0 +1,251 @@
|
||||
# AP242 API v2 Output Benchmarks
|
||||
|
||||
This file records comparable measurements for the staged API v2 output
|
||||
work. It is intended to make changes in generated output cost visible in
|
||||
the commits which introduce them.
|
||||
|
||||
## Method
|
||||
|
||||
The measurements were made on 2026-08-02 with GCC 13.3.0 and C++11.
|
||||
|
||||
The schema under test was BRL-CAD's `ap242e4.exp` conversion schema.
|
||||
The real exchange-file workload was the NIST STC 09 ASME AP242 edition
|
||||
4 sample, `nist_stc_09_asme1_ap242-e4.stp`.
|
||||
|
||||
The generator used `--late-bound`, the default 64-entity and 8-type chunk
|
||||
limits, and a release STEPcode build. Compilation used `-O2 -fPIC` and two
|
||||
concurrent compiler processes. Generated-output counts include `.cc`, `.h`,
|
||||
and `.cmake` files through directory depth two. The baseline is commit
|
||||
`fa2758c5` before recommendations 1--4.
|
||||
|
||||
## Results
|
||||
|
||||
| Measurement | Baseline | Recommendations 1--4 | Change |
|
||||
|---|---:|---:|---:|
|
||||
| Generated files | 5,719 | 905 | -84.2% |
|
||||
| Generated lines | 254,220 | 123,552 | -51.4% |
|
||||
| Generated bytes | 13,942,523 | 9,804,680 | -29.7% |
|
||||
| Entity leaf files | 4,814 | 0 | -100.0% |
|
||||
| Generation wall time | 2.74 s | 0.56 s | -79.6% |
|
||||
| Generation peak RSS | 109,024 KiB | 109,280 KiB | +0.2% |
|
||||
| Compile/link wall time | 157.68 s | 37.02 s | -76.5% |
|
||||
| Compile/link user time | 277.75 s | 66.32 s | -76.1% |
|
||||
| Compile/link peak RSS | 593,320 KiB | 199,156 KiB | -66.4% |
|
||||
| Schema shared library | 9,956,640 B | 7,716,096 B | -22.5% |
|
||||
| ELF relocations | 28,843 | 39,719 | +37.7% |
|
||||
| Function symbols | 15,641 | 13,542 | -13.4% |
|
||||
| Read/write wall time | 0.26 s | 0.25 s | -3.8% |
|
||||
| Read/write peak RSS | 88,732 KiB | 85,040 KiB | -4.2% |
|
||||
|
||||
The relocation increase is caused by the stable module-ID tables referring
|
||||
to descriptor slots. It is recorded here because the packed schema image
|
||||
stage is expected to remove most of that cost.
|
||||
|
||||
## Recommendations 1--4
|
||||
|
||||
This stage adds stable entity, type, and attribute IDs through `SchemaModule`,
|
||||
makes compatibility entity names opt-in for late-bound output, moves schema
|
||||
rules and complex-entity support to runtime-consumed tables, and writes late
|
||||
entity metadata directly to bounded chunks instead of creating 4,814 leaf
|
||||
files.
|
||||
|
||||
The real AP242 exchange-file check created and validated 10,609 instances
|
||||
with zero errors and zero warnings. Its 949,685-byte rewritten Part 21 file
|
||||
matched the baseline apart from the expected `FILE_NAME` timestamp.
|
||||
|
||||
## Recommendation 5
|
||||
|
||||
This stage resolves each late-bound entity's flattened attribute layout once
|
||||
after schema initialization. Instance construction then follows descriptor
|
||||
and index records directly instead of recursively walking supertypes and
|
||||
repeating attribute-name searches. The cache is external to
|
||||
`EntityDescriptor`, so its object layout and the API v1 ABI are unchanged.
|
||||
|
||||
The construction benchmark uses the 1,531 `DIRECTION` instances in the real
|
||||
exchange file and repeats that population 1,000 times. This isolates the
|
||||
work changed by this stage while retaining a type and frequency from the
|
||||
AP242 workload. Results are the median of three runs.
|
||||
|
||||
| Measurement | Recommendations 1--4 | Recommendation 5 | Change |
|
||||
|---|---:|---:|---:|
|
||||
| 1,531,000 entity constructions | 0.84 s | 0.63 s | -25.0% |
|
||||
| Construction user time | 0.82 s | 0.61 s | -25.6% |
|
||||
| Construction peak RSS | 68,956 KiB | 69,600 KiB | +0.9% |
|
||||
| 20 full read/write runs | 4.90 s | 4.91 s | no measurable change |
|
||||
| Full read/write peak RSS | 85,164 KiB | 85,732 KiB | +0.7% |
|
||||
| `libstepcore` size | 640,936 B | 651,312 B | +1.6% |
|
||||
|
||||
The complete exchange-file check still created and validated 10,609
|
||||
instances with zero errors and zero warnings. Its rewritten file remained
|
||||
949,685 bytes and differed from the previous stage only in the expected
|
||||
`FILE_NAME` timestamp. Generated schema file counts, source size, and the
|
||||
schema shared library are unchanged because this is a shared-runtime change.
|
||||
|
||||
## Recommendation 6
|
||||
|
||||
This stage replaces the generated `SchemaModuleSlot` pointer arrays with a
|
||||
16-byte, relocation-free `SchemaModuleImage`. Shared initialization helpers
|
||||
capture descriptor pointers in stable generated-ID order and transfer those
|
||||
vectors to `SchemaModule` after initialization. The older slot-based entry
|
||||
point remains available for existing generated API v2 code.
|
||||
|
||||
Source and binary measurements compare recommendation 5 with the packed
|
||||
image. Compile times use matching clean CMake builds with two compiler
|
||||
processes. Read/write times are medians from paired 20-run batches.
|
||||
|
||||
| Measurement | Recommendation 5 | Recommendation 6 | Change |
|
||||
|---|---:|---:|---:|
|
||||
| Generated files | 905 | 905 | unchanged |
|
||||
| Generated lines | 123,552 | 117,046 | -5.3% |
|
||||
| Generated bytes | 9,804,680 | 9,060,249 | -7.6% |
|
||||
| Schema module source | 808,907 B | 64,367 B | -92.0% |
|
||||
| Schema module source lines | 7,280 | 773 | -89.4% |
|
||||
| Compile/link wall time | 41.38 s | 41.49 s | no measurable change |
|
||||
| Compile/link peak RSS | 208,312 KiB | 208,188 KiB | -0.1% |
|
||||
| Schema shared library | 7,728,384 B | 7,470,304 B | -3.3% |
|
||||
| ELF relocations | 39,719 | 33,221 | -16.4% |
|
||||
| 20 full read/write runs | 5.10 s | 5.07 s | -0.6% |
|
||||
| Full read/write peak RSS | 85,736 KiB | 85,572 KiB | -0.2% |
|
||||
| `libstepcore` size | 651,312 B | 661,088 B | +1.5% |
|
||||
|
||||
The image removes 6,498 per-descriptor pointer relocations. The shared
|
||||
runtime grows by 9,776 bytes once, while each AP242 schema library is 258,080
|
||||
bytes smaller. Generated API v1 output and the conventional public entity
|
||||
classes remain unchanged.
|
||||
|
||||
The complete exchange-file check again created and validated 10,609
|
||||
instances with zero errors and zero warnings. Its 949,685-byte rewrite
|
||||
differed from recommendation 5 only in the expected `FILE_NAME` timestamp.
|
||||
|
||||
## Recommendation 7
|
||||
|
||||
This stage replaces the remaining generated descriptor procedures with one
|
||||
bounded, offset-based schema image. The shared loader validates every array,
|
||||
string, range, descriptor reference, schema binding, and complex-entity tree
|
||||
before it changes the registry. It then constructs the descriptor graph with
|
||||
an explicit per-load context; the process-global capture path remains only for
|
||||
older generated API v2 code. Complex-entity metadata uses the same packed
|
||||
representation and validation model.
|
||||
|
||||
Source and binary measurements compare recommendation 6 with the complete
|
||||
descriptor image. Compile times use clean CMake builds with two compiler
|
||||
processes. Read/write times use matching 20-run batches.
|
||||
|
||||
| Measurement | Recommendation 6 | Recommendation 7 | Change |
|
||||
|---|---:|---:|---:|
|
||||
| Generated files | 905 | 865 | -4.4% |
|
||||
| Generated lines | 117,046 | 86,400 | -26.2% |
|
||||
| Generated bytes | 9,060,249 | 4,865,657 | -46.3% |
|
||||
| Entity initialization chunks | 38 | 0 | -100.0% |
|
||||
| Compile/link wall time | 41.49 s | 18.71 s | -54.9% |
|
||||
| Compile/link peak RSS | 208,188 KiB | 208,528 KiB | +0.2% |
|
||||
| Schema shared library | 7,470,304 B | 3,503,352 B | -53.1% |
|
||||
| ELF relocations | 33,221 | 9,620 | -71.0% |
|
||||
| 20 full read/write runs | 5.07 s | 4.97 s | -2.0% |
|
||||
| Full read/write peak RSS | 85,572 KiB | 82,916 KiB | -3.1% |
|
||||
|
||||
The image removes the 2,407 generated entity initialization functions and
|
||||
23,601 additional relocations. The generated schema library is 3,966,952
|
||||
bytes smaller, while its existing typed SELECT and enumeration factories
|
||||
remain available for this transitional stage.
|
||||
|
||||
The complete exchange-file check created and validated 10,609 instances with
|
||||
zero errors and zero warnings. Its 949,685-byte rewrite retained the same
|
||||
semantic result as recommendation 6.
|
||||
|
||||
## Recommendations 8 and 9
|
||||
|
||||
This stage makes the compact late-bound output independent of generated type
|
||||
classes. Shared descriptor-driven implementations now construct SELECT,
|
||||
enumeration, and aggregate values, including nested values and BOOLEAN or
|
||||
LOGICAL aliases. Enumeration elements and renamed USE or REFERENCE items are
|
||||
retained in the packed image. The conventional early-bound API v1 and API v2
|
||||
paths still emit their schema-specific type classes.
|
||||
|
||||
The generated schema header is now a dependency-bounded consumer interface.
|
||||
It contains stable entity, type, and attribute IDs plus `SchemaModule` lookup
|
||||
functions, and includes only `schemaModule.h`. Runtime and model-construction
|
||||
declarations remain in the internal `schema.h` umbrella.
|
||||
|
||||
| Measurement | Recommendation 7 | Recommendations 8--9 | Change |
|
||||
|---|---:|---:|---:|
|
||||
| Generated files | 865 | 10 | -98.8% |
|
||||
| Generated lines | 86,400 | 54,839 | -36.5% |
|
||||
| Generated bytes | 4,865,657 | 3,303,993 | -32.1% |
|
||||
| Type leaf files | 802 | 0 | -100.0% |
|
||||
| Type initialization chunks | 51 | 0 | -100.0% |
|
||||
| Compile/link wall time | 18.71 s | 1.21 s | -93.5% |
|
||||
| Compile/link peak RSS | 208,528 KiB | 126,580 KiB | -39.3% |
|
||||
| Schema shared library | 3,503,352 B | 2,178,296 B | -37.8% |
|
||||
| ELF relocations | 9,620 | 49 | -99.5% |
|
||||
| Exported function symbols | 4,647 | 8 | -99.8% |
|
||||
| Public header preprocessed bytes | 2,384,191 | 635,945 | -73.3% |
|
||||
| 20 full read/write runs | 4.97 s | 4.91 s | -1.2% |
|
||||
| Full read/write peak RSS | 82,916 KiB | 82,304 KiB | -0.7% |
|
||||
|
||||
The complete exchange-file check again created and validated 10,609
|
||||
instances with zero errors and zero warnings, and wrote the same 949,685-byte
|
||||
semantic result. Runtime unit coverage separately exercises generic SELECT,
|
||||
enumeration, aggregate, malformed-image, and packed rename behavior.
|
||||
|
||||
## Recommendation 10
|
||||
|
||||
This stage adds an opt-in `structural` metadata profile for late-bound API
|
||||
version 2. The default `full` profile is unchanged. Structural images keep
|
||||
the descriptor graph needed to construct, read, write, and inspect entity,
|
||||
attribute, type, aggregate, enumeration, SELECT, inverse, and renamed values.
|
||||
They omit EXPRESS descriptions, WHERE and UNIQUE rules, schema rule and
|
||||
algorithm text, supertype statements, derived expressions, and symbolic
|
||||
aggregate-bound text.
|
||||
|
||||
The source and library measurements below compare matching fresh output from
|
||||
the two profiles. Compile times use clean CMake builds with one compiler
|
||||
process; read/write times use matching 20-run batches.
|
||||
|
||||
| Measurement | Full metadata | Structural metadata | Change |
|
||||
|---|---:|---:|---:|
|
||||
| Generated files | 10 | 10 | unchanged |
|
||||
| Generated lines | 54,839 | 29,993 | -45.3% |
|
||||
| Generated bytes | 3,304,007 | 1,525,897 | -53.8% |
|
||||
| Packed schema source | 2,612,413 B | 834,303 B | -68.1% |
|
||||
| Generation wall time | 0.48 s | 0.41 s | -14.6% |
|
||||
| Compile/link wall time | 2.08 s | 2.03 s | -2.4% |
|
||||
| Compile/link peak RSS | 126,784 KiB | 118,220 KiB | -6.8% |
|
||||
| Schema shared library | 2,178,296 B | 720,120 B | -66.9% |
|
||||
| ELF relocations | 49 | 49 | unchanged |
|
||||
| 20 full read/write runs | 4.76 s | 4.71 s | -1.1% |
|
||||
| Full read/write peak RSS | 82,276 KiB | 78,900 KiB | -4.1% |
|
||||
|
||||
The structural profile created and validated all 10,609 instances in the
|
||||
real exchange file with zero errors and zero warnings. It wrote the same
|
||||
949,685-byte semantic result as the full profile.
|
||||
|
||||
## Recommendation 11
|
||||
|
||||
This stage writes each generated file to a sibling temporary file and replaces
|
||||
the destination only when its content changes. A compact generated-file
|
||||
manifest supports safe cleanup when an option change makes old entity, type,
|
||||
or unity files obsolete; files not named by the previous manifest are left
|
||||
alone. The manifest itself is also content-stable.
|
||||
|
||||
The deterministic-output audit also found that nonliteral aggregate bounds
|
||||
were being read through the integer member of the expression union. Packed
|
||||
images now emit those bounds as expression records, eliminating process-address
|
||||
values from generated AP242 source as well as correcting the metadata kind.
|
||||
|
||||
| Measurement after identical AP242 generation | Rewrite all | Stable output | Change |
|
||||
|---|---:|---:|---:|
|
||||
| Changed schema source/header timestamps | 10 of 10 | 0 of 10 | -100.0% |
|
||||
| Changed manifest timestamps | n/a | 0 of 1 | stable |
|
||||
| Generation wall time | 0.41 s | 0.40 s | no overhead |
|
||||
| Following CMake build wall time | 2.01 s | 0.06 s | -97.0% |
|
||||
| Following build peak RSS | 118,108 KiB | 18,432 KiB | -84.4% |
|
||||
|
||||
The AP242 manifest is 390 bytes. Switching the focused regression schema
|
||||
from early-bound API version 2 to compact late-bound output removes all stale
|
||||
entity, type, and unity files and their empty directories while preserving an
|
||||
unrelated file in the output directory.
|
||||
|
||||
The real exchange-file check still created and validated all 10,609 instances
|
||||
with zero errors and zero warnings. Its rewritten result remained 949,685
|
||||
bytes.
|
||||
@@ -0,0 +1,367 @@
|
||||
# EXPRESS Type Unwrapping and Narrowing
|
||||
|
||||
## Overview
|
||||
|
||||
This document describes the type unwrapping and narrowing features implemented in STEPcode's EXPRESS compiler. These features enable proper type checking and semantic analysis for aggregate types and SELECT type narrowing.
|
||||
|
||||
**Note:** Some features described here are extensions beyond the ISO 10303-11 standard and are explicitly marked as such.
|
||||
|
||||
## Deep Aggregate Unwrapping
|
||||
|
||||
### Background
|
||||
|
||||
In EXPRESS, aggregate types (ARRAY, LIST, SET, BAG) can be nested and wrapped in type definitions. For semantic analysis and type checking, the compiler often needs to "unwrap" these layers to access the underlying element type.
|
||||
|
||||
### Shallow vs Deep Type Checking
|
||||
|
||||
#### Shallow Aggregate Check: `TYPEis_aggregate`
|
||||
|
||||
The macro `TYPEis_aggregate(t)` performs a **shallow** check by testing if `t->u.type->body->base` is non-NULL. This indicates the type has a base type, which is characteristic of aggregate types.
|
||||
|
||||
```c
|
||||
#define TYPEis_aggregate(t) ((t)->u.type->body->base)
|
||||
```
|
||||
|
||||
**Important:** This is a shallow check and does not follow type definition chains. It returns true if the immediate type structure has a base type.
|
||||
|
||||
**Use when:**
|
||||
- You need a quick check if a type is directly an aggregate
|
||||
- You're working with the immediate type structure
|
||||
- Performance is critical and deep unwrapping isn't needed
|
||||
|
||||
#### Deep Aggregate Unwrapping: `TYPEget_nonaggregate_base_type`
|
||||
|
||||
The function `TYPEget_nonaggregate_base_type(Type t)` performs **deep unwrapping** by iteratively following the chain of aggregate base types until reaching a non-aggregate type.
|
||||
|
||||
```express
|
||||
TYPE int_list = LIST OF INTEGER;
|
||||
TYPE named_int_list = int_list; -- typedef chain
|
||||
TYPE set_of_lists = SET OF named_int_list;
|
||||
```
|
||||
|
||||
For `set_of_lists`:
|
||||
- `TYPEis_aggregate()` → true (immediate check)
|
||||
- `TYPEget_nonaggregate_base_type()` → INTEGER (unwraps through SET → LIST → INTEGER)
|
||||
|
||||
**Use when:**
|
||||
- Comparing element types across different aggregate wrappers
|
||||
- Type resolution requires the ultimate element type
|
||||
- Semantic checking needs to validate deep type compatibility
|
||||
|
||||
### Deep Unwrapping Implementation
|
||||
|
||||
```c
|
||||
Type TYPEget_nonaggregate_base_type( Type t ) {
|
||||
while( TYPEis_aggregate( t ) ) {
|
||||
t = t->u.type->body->base;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
```
|
||||
|
||||
This function safely handles:
|
||||
- Nested aggregates (SET OF LIST OF ...)
|
||||
- Type definition chains
|
||||
- Mixed aggregate types
|
||||
|
||||
### Aggregate Type Comparison: `TYPE_retrieve_aggregate`
|
||||
|
||||
For SELECT types containing multiple aggregate members, `TYPE_retrieve_aggregate()` validates that all aggregate members share the same element type.
|
||||
|
||||
```express
|
||||
TYPE item_a = SET OF INTEGER;
|
||||
TYPE item_b = LIST OF INTEGER;
|
||||
TYPE my_select = SELECT(item_a, item_b); -- Valid: both have INTEGER elements
|
||||
```
|
||||
|
||||
The function:
|
||||
1. Iterates through SELECT members
|
||||
2. Identifies which are aggregates
|
||||
3. Unwraps typedef chains to find element types
|
||||
4. Returns common element type or NULL if incompatible
|
||||
|
||||
## TREAT Expression Semantics
|
||||
|
||||
### ISO 10303-11 Standard Syntax
|
||||
|
||||
The TREAT expression is defined in ISO 10303-11 as:
|
||||
|
||||
```express
|
||||
TREAT(expression AS type_identifier)
|
||||
```
|
||||
|
||||
**Purpose:** Explicitly narrow a SELECT type to one of its member types.
|
||||
|
||||
### STEPcode Implementation
|
||||
|
||||
STEPcode implements TREAT as specified in ISO 10303-11 with the following semantics:
|
||||
|
||||
#### Type Resolution
|
||||
|
||||
1. **Operand Resolution:** The expression being narrowed is resolved first
|
||||
```c
|
||||
EXPresolve( e->e.op1, s, Type_Dont_Care );
|
||||
operand_type = e->e.op1->return_type;
|
||||
```
|
||||
|
||||
2. **Target Type Lookup:** The target type identifier is resolved via scope lookup
|
||||
```c
|
||||
target_type = (Type)SCOPEfind( s, e->symbol.name, SCOPE_FIND_TYPE );
|
||||
```
|
||||
|
||||
3. **Type Compatibility:** The implementation validates that narrowing is semantically valid
|
||||
- For SELECT operands: Verifies target is a member type
|
||||
- For other types: Allows permissively (may emit warnings)
|
||||
|
||||
4. **Return Type:** The expression's return type becomes the target type
|
||||
```c
|
||||
return target_type; /* Not Type_Generic */
|
||||
```
|
||||
|
||||
#### Error Handling
|
||||
|
||||
**Clear errors with location information:**
|
||||
|
||||
- **Missing operand:** `SYNTAX` error - "TREAT expression missing operand"
|
||||
- **Missing target type:** `SYNTAX` error - "TREAT expression missing target type"
|
||||
- **Undefined type:** `UNDEFINED_TYPE` error with the type name
|
||||
- **Type mismatch:** Currently permissive (no error, future: may warn)
|
||||
|
||||
All errors use `ERRORreport_with_symbol()` which provides:
|
||||
- File name and line number
|
||||
- Symbol context
|
||||
- Descriptive error message
|
||||
|
||||
#### Example Usage
|
||||
|
||||
```express
|
||||
TYPE attachment = SELECT(nail, screw);
|
||||
END_TYPE;
|
||||
|
||||
FUNCTION get_length(item : attachment) : REAL;
|
||||
LOCAL
|
||||
n : nail;
|
||||
END_LOCAL;
|
||||
|
||||
IF ('EXAMPLE.NAIL' IN TYPEOF(item)) THEN
|
||||
n := TREAT(item AS nail); -- Narrows SELECT to nail
|
||||
RETURN n.length;
|
||||
END_IF;
|
||||
|
||||
RETURN 0.0;
|
||||
END_FUNCTION;
|
||||
```
|
||||
|
||||
### Grammar Integration
|
||||
|
||||
The TREAT syntax is integrated into the EXPRESS parser grammar as a unary expression:
|
||||
|
||||
```yacc
|
||||
unary_expression ::= TOK_TREAT TOK_LEFT_PAREN expression TOK_AS
|
||||
TOK_IDENTIFIER TOK_RIGHT_PAREN
|
||||
```
|
||||
|
||||
Key points:
|
||||
- `TOK_TREAT`: Recognized as a keyword
|
||||
- Creates unary expression with `OP_TREAT` operator
|
||||
- Operand stored in `op1`
|
||||
- Target type name stored in `symbol` field
|
||||
|
||||
## Flow-Sensitive SELECT Narrowing
|
||||
|
||||
**Extension Status:** This is a **non-standard extension** that enhances type safety for SELECT types.
|
||||
|
||||
### Background
|
||||
|
||||
EXPRESS WHERE clauses often use TYPEOF guards to check SELECT types before accessing member-specific attributes. Flow-sensitive narrowing automatically narrows SELECT types within the scope of such guards.
|
||||
|
||||
### Pattern Recognition
|
||||
|
||||
The narrowing system recognizes this pattern:
|
||||
|
||||
```express
|
||||
'TypeName' IN TYPEOF(variable)
|
||||
```
|
||||
|
||||
When this pattern appears in an AND conjunction, the variable is narrowed to `TypeName` for subsequent expressions in the conjunction.
|
||||
|
||||
### Implementation Architecture
|
||||
|
||||
#### Refinement Context
|
||||
|
||||
A **refinement context** tracks active type narrowings during expression resolution:
|
||||
|
||||
```c
|
||||
typedef struct RefinementContext_ {
|
||||
Refinement refinements; /* Linked list of variable → type mappings */
|
||||
struct RefinementContext_ *previous; /* Stack of contexts */
|
||||
} *RefinementContext;
|
||||
|
||||
RefinementContext active_refinements = NULL; /* Thread-local global */
|
||||
```
|
||||
|
||||
#### Pattern Matching
|
||||
|
||||
The function `match_typeof_guard()` identifies guard patterns:
|
||||
|
||||
1. Expression is `IN` operator
|
||||
2. Left operand is string literal (type name)
|
||||
3. Right operand is `TYPEOF(identifier)`
|
||||
4. Identifier resolves to a variable
|
||||
|
||||
#### Refinement Collection
|
||||
|
||||
The function `collect_refinements_from_conjunction()` recursively walks AND expressions:
|
||||
|
||||
1. Recursively descends into AND nodes
|
||||
2. Matches TYPEOF guard patterns at leaves
|
||||
3. Validates narrowing is semantically correct:
|
||||
- Variable must have SELECT type
|
||||
- Target type must be SELECT member (validated via `is_select_member()`)
|
||||
4. Returns linked list of valid refinements
|
||||
|
||||
#### Application
|
||||
|
||||
In `EXPresolve_op_and()`:
|
||||
|
||||
```c
|
||||
Type EXPresolve_op_and(Expression e, Scope s) {
|
||||
EXPresolve(e->e.op1, s, Type_Dont_Care); /* Resolve LHS normally */
|
||||
|
||||
Refinement refs = collect_refinements_from_conjunction(e->e.op1, s);
|
||||
|
||||
if (refs) {
|
||||
/* Create temporary context */
|
||||
struct RefinementContext_ ctx;
|
||||
ctx.refinements = refs;
|
||||
ctx.previous = active_refinements;
|
||||
active_refinements = &ctx;
|
||||
|
||||
EXPresolve(e->e.op2, s, Type_Dont_Care); /* Resolve RHS with narrowing */
|
||||
|
||||
/* Restore previous context */
|
||||
active_refinements = ctx.previous;
|
||||
free_refinements(refs);
|
||||
} else {
|
||||
EXPresolve(e->e.op2, s, Type_Dont_Care);
|
||||
}
|
||||
|
||||
return Type_Logical;
|
||||
}
|
||||
```
|
||||
|
||||
### Behavior Scope
|
||||
|
||||
**What is narrowed:**
|
||||
- Variables with SELECT type
|
||||
- Within RHS of AND expressions
|
||||
- Where LHS contains TYPEOF guard
|
||||
|
||||
**What is NOT narrowed:**
|
||||
- OR expressions (conservative - doesn't extract from disjunction)
|
||||
- NOT expressions (conservative - doesn't extract from negation)
|
||||
- Other boolean operators
|
||||
- Variables not guarded by TYPEOF
|
||||
|
||||
**Rationale:** Conservative approach prevents false narrowing in cases where the guard may not hold.
|
||||
|
||||
### Limitations
|
||||
|
||||
1. **Single-level context:** Only immediate AND RHS is narrowed, not deeply nested scopes
|
||||
2. **No cross-statement narrowing:** Limited to expression-level scope
|
||||
3. **AND-only:** Does not propagate through OR/NOT (conservative)
|
||||
4. **Pattern-based:** Only recognizes exact `'Type' IN TYPEOF(var)` pattern
|
||||
|
||||
### Example
|
||||
|
||||
```express
|
||||
ENTITY test_entity;
|
||||
item : target; -- target is SELECT(set_representation_item, simple_int)
|
||||
WHERE
|
||||
wr1: ('SCHEMA.SET_REPRESENTATION_ITEM' IN TYPEOF(item)) AND
|
||||
(SIZEOF(item) > 0); -- item narrowed to set_representation_item
|
||||
END_ENTITY;
|
||||
```
|
||||
|
||||
Without narrowing, `SIZEOF(item)` would fail (can't take SIZEOF of SELECT). With narrowing, `item` is known to be an aggregate, so `SIZEOF` is valid.
|
||||
|
||||
## Memory Management
|
||||
|
||||
### Refinement Lifecycle
|
||||
|
||||
1. **Collection:** `collect_refinements_from_conjunction()` allocates refinement nodes
|
||||
2. **Usage:** Active during RHS expression resolution only
|
||||
3. **Cleanup:** `free_refinements()` called after RHS resolution completes
|
||||
|
||||
### Context Stack Model
|
||||
|
||||
The implementation uses a **stack-based context model** rather than deep copying:
|
||||
|
||||
- `RefinementContext` has `previous` pointer forming a stack
|
||||
- New contexts pushed onto stack with `active_refinements = &ctx`
|
||||
- Restored with `active_refinements = ctx.previous`
|
||||
- No deep copying of refinement data
|
||||
|
||||
**Memory safety:**
|
||||
- Refinement nodes allocated individually
|
||||
- Freed immediately after use
|
||||
- No dangling pointers (stack-local contexts)
|
||||
- No memory leaks (verified by code inspection)
|
||||
|
||||
## Testing
|
||||
|
||||
### Test Coverage
|
||||
|
||||
**TREAT expression tests:**
|
||||
- `test/unitary_schemas/minimal_treat_test.exp` - Basic TREAT usage
|
||||
- `test/unitary_schemas/test_treat_real.exp` - Nested SELECT types
|
||||
- `test/unitary_schemas/treat_expression.exp` - TREAT in WHERE clauses
|
||||
|
||||
**Flow-sensitive narrowing tests:**
|
||||
- `test/unitary_schemas/flow_narrowing_test.exp` - AND-based narrowing
|
||||
- `test/unitary_schemas/select_aggregate_test.exp` - SELECT of aggregates
|
||||
|
||||
**Production schema comparison:**
|
||||
- `data/ap242/242_mim_lf.exp` - Original AP242 with flow-sensitive narrowing
|
||||
- `data/ap242/242_mim_lf_treat.exp` - TREAT-based standards-compliant version
|
||||
- `test/compare_ap242_versions.sh` - Automated comparison script
|
||||
|
||||
See `doc/ap242-comparison.md` for detailed analysis of the AP242 schema comparison.
|
||||
|
||||
### AP242 Compatibility
|
||||
|
||||
The implementation is validated against the AP242 schema, ensuring:
|
||||
- Large-scale schema parsing succeeds
|
||||
- Complex type hierarchies handled correctly
|
||||
- Production schema compatibility
|
||||
|
||||
**AP242 Schema Versions:**
|
||||
- `data/ap242/242_mim_lf.exp` - Original schema using flow-sensitive narrowing extension
|
||||
- `data/ap242/242_mim_lf_treat.exp` - Standards-compliant version using TREAT expression
|
||||
|
||||
Both versions parse successfully and produce identical output. See `doc/ap242-comparison.md` for detailed analysis.
|
||||
|
||||
## Standards Compliance Notes
|
||||
|
||||
### ISO 10303-11 Compliance
|
||||
|
||||
**Fully compliant:**
|
||||
- TREAT expression syntax and semantics
|
||||
- Aggregate type definitions
|
||||
- SELECT type definitions
|
||||
- Standard type resolution rules
|
||||
|
||||
**Extensions (non-standard):**
|
||||
- Flow-sensitive type narrowing in AND expressions
|
||||
- Permissive TREAT type checking (warns vs errors)
|
||||
|
||||
### Extension Philosophy
|
||||
|
||||
STEPcode's extensions follow these principles:
|
||||
|
||||
1. **Conservative:** Only apply when semantically safe
|
||||
2. **Permissive:** Prefer warnings over errors where reasonable
|
||||
3. **Explicit:** Document extensions clearly
|
||||
4. **Compatible:** Don't break standard-compliant schemas
|
||||
|
||||
Extensions are designed to enhance usability while maintaining backward compatibility with ISO 10303-11 compliant EXPRESS schemas.
|
||||
+33
-1
@@ -45,6 +45,11 @@ EXPRESS code into C++ source code. The C++ source code is generated
|
||||
in files in the directory in which exp2cxx was run. The files are
|
||||
named according to the schema names in the input EXPRESS file.
|
||||
|
||||
Generated files are replaced only when their content changes. exp2cxx records
|
||||
the files it owns in `.exp2cxx-manifest`; a later run removes obsolete files
|
||||
from that manifest while leaving unrelated files in the output directory
|
||||
untouched.
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B -s|S
|
||||
@@ -57,6 +62,34 @@ Generates C++ classes for use with CORBA (Orbix).
|
||||
.B -l|L
|
||||
Prints logging code in the generated C++ classes.
|
||||
.TP
|
||||
.B -k entity-chunk-size[:type-chunk-size]
|
||||
Limits the number of generated schema objects in each deterministic unity
|
||||
translation unit. A single value applies to both entity and type chunks.
|
||||
.TP
|
||||
.B -V 1|2, --api-version 1|2
|
||||
Selects the generated C++ API. Version 1 is the source-compatible default.
|
||||
Version 2 emits compact SELECT classes, table-driven schema initialization, and
|
||||
dependency-bounded entity headers backed by shared runtime code. Version 2
|
||||
clients include the individual entity headers they use; schema.h does not
|
||||
include every entity class definition.
|
||||
.TP
|
||||
.B -T, --late-bound
|
||||
Selects API version 2 and omits generated early-bound C++ entity classes.
|
||||
Entity instances are constructed at runtime from schema descriptors. This mode
|
||||
is intended for conversion and inspection applications which do not require the
|
||||
conventional generated entity API.
|
||||
.TP
|
||||
.B --compat-names
|
||||
Retains the generated entity-name aliases in late-bound output. Normal
|
||||
late-bound API v2 output uses schema module IDs instead and omits these aliases.
|
||||
.TP
|
||||
.B --metadata full|structural
|
||||
Selects the generated schema metadata profile. Full is the default and
|
||||
retains EXPRESS descriptions, constraints, and executable schema text.
|
||||
Structural is available with late-bound API version 2; it retains the entity,
|
||||
attribute, type, aggregate, enumeration, SELECT, inverse, and rename graph
|
||||
needed by conversion tools while omitting descriptive and constraint text.
|
||||
.TP
|
||||
.B -v
|
||||
Produces a version description.
|
||||
.TP
|
||||
@@ -161,4 +194,3 @@ appropriate file to download).
|
||||
|
||||
.SH BUGS
|
||||
See fedex(1).
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
# for the use of this file.
|
||||
#
|
||||
project(AP203Minimum)
|
||||
cmake_minimum_required(VERSION 3.6.3)
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
|
||||
# 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}/SC_VERSION.txt")
|
||||
if(EXISTS "${CMAKE_BINARY_DIR}/${STEPCODE_ROOT_DIR}/src/express/express.c")
|
||||
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}/SC_VERSION.txt")
|
||||
if(NOT EXISTS "${STEPCODE_ROOT_DIR}/src/express/express.c")
|
||||
message(FATAL_ERROR "**** Cannot locate STEPCODE_ROOT_DIR - try an absolute path.")
|
||||
endif(NOT EXISTS "${STEPCODE_ROOT_DIR}/SC_VERSION.txt")
|
||||
endif(EXISTS "${CMAKE_BINARY_DIR}/${STEPCODE_ROOT_DIR}/SC_VERSION.txt")
|
||||
endif(NOT EXISTS "${STEPCODE_ROOT_DIR}/src/express/express.c")
|
||||
endif(EXISTS "${CMAKE_BINARY_DIR}/${STEPCODE_ROOT_DIR}/src/express/express.c")
|
||||
|
||||
|
||||
# Use STEPcode as library, but build from this build process.
|
||||
@@ -31,7 +31,6 @@ set(SC_IS_SUBBUILD TRUE)
|
||||
if(NOT DEFINED CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Debug)
|
||||
endif(NOT DEFINED CMAKE_BUILD_TYPE)
|
||||
set(SC_BUILD_TYPE ${CMAKE_BUILD_TYPE})
|
||||
|
||||
# Path to STEPcode
|
||||
set(STEPCODE_BUILD_DIR ${CMAKE_BINARY_DIR}/sc CACHE PATH "STEPcode build subdir")
|
||||
@@ -51,18 +50,13 @@ 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 base stepcore stepeditor stepdai steputils ${SCHEMA_LINK_NAME})
|
||||
set(STEPCODE_LIBRARIES 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
|
||||
${STEPCODE_ROOT_DIR}/src/cleditor
|
||||
${STEPCODE_BUILD_DIR}/include
|
||||
${STEPCODE_ROOT_DIR}/include
|
||||
${CMAKE_BINARY_DIR}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
# for the use of this file.
|
||||
#
|
||||
project(AP203Minimum)
|
||||
cmake_minimum_required(VERSION 3.6.3)
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
|
||||
INCLUDE( ExternalProject )
|
||||
|
||||
@@ -19,7 +19,6 @@ 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
|
||||
@@ -28,7 +27,6 @@ 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
|
||||
@@ -44,7 +42,6 @@ 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
|
||||
|
||||
@@ -4,9 +4,9 @@ ExternalProject_Add( STEPCODE
|
||||
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
||||
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
|
||||
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
|
||||
-DSC_BUILD_TYPE=Debug
|
||||
-DCMAKE_BUILD_TYPE=Debug
|
||||
-DSC_BUILD_SCHEMAS=ap203/ap203.exp
|
||||
-DSC_BUILD_STATIC_LIBS=ON
|
||||
-DBUILD_STATIC_LIBS=ON
|
||||
-DSC_PYTHON_GENERATOR=OFF
|
||||
-DSC_INSTALL_PREFIX:PATH=<INSTALL_DIR>
|
||||
)
|
||||
@@ -22,8 +22,3 @@ 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
|
||||
@@ -49,15 +49,15 @@
|
||||
// $./AP203Minimum
|
||||
// AP203Minimum outfile.stp
|
||||
|
||||
#include <STEPfile.h>
|
||||
#include <sdai.h>
|
||||
#include <STEPattribute.h>
|
||||
#include <ExpDict.h>
|
||||
#include <Registry.h>
|
||||
#include <errordesc.h>
|
||||
#include <cleditor/STEPfile.h>
|
||||
#include <clstepcore/sdai.h>
|
||||
#include <clstepcore/STEPattribute.h>
|
||||
#include <clstepcore/ExpDict.h>
|
||||
#include <clstepcore/Registry.h>
|
||||
#include <clutils/errordesc.h>
|
||||
|
||||
#include <STEPcomplex.h>
|
||||
#include <SdaiHeaderSchema.h>
|
||||
#include <clstepcore/STEPcomplex.h>
|
||||
#include <cleditor/SdaiHeaderSchema.h>
|
||||
|
||||
#include "schema.h"
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#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
|
||||
@@ -14,7 +15,6 @@
|
||||
#cmakedefine HAVE_IO_H 1
|
||||
|
||||
#cmakedefine SC_TRACE_FPRINTF 1
|
||||
#cmakedefine SC_MEMMGR_ENABLE_CHECKS 1
|
||||
|
||||
#cmakedefine HAVE_ABS 1
|
||||
#cmakedefine HAVE_MEMCPY 1
|
||||
+11
-7
@@ -22,22 +22,26 @@ set(express_HDRS
|
||||
express/variable.h
|
||||
)
|
||||
install(FILES ${express_HDRS}
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/express)
|
||||
DESTINATION ${INCLUDE_DIR}/stepcode/express)
|
||||
|
||||
set(exppp_HDRS
|
||||
exppp/exppp.h
|
||||
)
|
||||
install(FILES ${exppp_HDRS}
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/exppp)
|
||||
DESTINATION ${INCLUDE_DIR}/stepcode/exppp)
|
||||
|
||||
install(FILES ordered_attrs.h
|
||||
sc_export.h
|
||||
sc_stdbool.h
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode)
|
||||
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)
|
||||
install(FILES ${SC_BINARY_DIR}/${INCLUDE_DIR}/config.h
|
||||
DESTINATION ${INCLUDE_DIR}/stepcode)
|
||||
|
||||
add_subdirectory(cldai)
|
||||
add_subdirectory(cleditor)
|
||||
add_subdirectory(cllazyfile)
|
||||
add_subdirectory(clstepcore)
|
||||
add_subdirectory(clutils)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
set(DAI_HDRS
|
||||
sdaiApplication_instance_set.h
|
||||
sdaiBinary.h
|
||||
sdaiDaObject.h
|
||||
sdaiEntity_extent.h
|
||||
sdaiEntity_extent_set.h
|
||||
sdaiEnum.h
|
||||
sdaiModel_contents.h
|
||||
sdaiModel_contents_list.h
|
||||
sdaiObject.h
|
||||
sdaiSession_instance.h
|
||||
sdaiString.h
|
||||
)
|
||||
|
||||
install(FILES ${DAI_HDRS}
|
||||
DESTINATION ${INCLUDE_DIR}/stepcode/cldai)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef SDAIDAOBJECT_H
|
||||
#define SDAIDAOBJECT_H 1
|
||||
|
||||
#include <sdaiObject.h>
|
||||
#include <sdaiString.h>
|
||||
#include <sdaiEnum.h>
|
||||
#include "cldai/sdaiObject.h"
|
||||
#include "cldai/sdaiString.h"
|
||||
#include "cldai/sdaiEnum.h"
|
||||
|
||||
#include <sc_export.h>
|
||||
|
||||
@@ -56,7 +56,7 @@ class SC_DAI_EXPORT SDAI_Entity_extent : public SDAI_Session_instance {
|
||||
return &_instances;
|
||||
}
|
||||
SDAI_DAObject__set_var instances_() const {
|
||||
return ( const SDAI_DAObject__set_var )&_instances;
|
||||
return ( SDAI_DAObject__set_var )&_instances;
|
||||
}
|
||||
|
||||
// need to implement Model_contents__list
|
||||
@@ -138,6 +138,7 @@ 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;
|
||||
@@ -40,7 +40,7 @@ class SC_DAI_EXPORT SDAI_Model_contents_instances : public SDAI_DAObject {
|
||||
return &_instances;
|
||||
}
|
||||
SDAI_DAObject__set_var contents_() const {
|
||||
return ( const SDAI_DAObject__set_var ) &_instances;
|
||||
return ( SDAI_DAObject__set_var ) &_instances;
|
||||
}
|
||||
|
||||
};
|
||||
@@ -3,7 +3,7 @@
|
||||
#define SESSION_INSTANCE_H 1
|
||||
|
||||
#include <sc_export.h>
|
||||
//#include <sdai.h>
|
||||
//#include "clstepcore/sdai.h"
|
||||
|
||||
class SC_DAI_EXPORT SDAI_Session_instance : public SDAI_sdaiObject {
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
*/
|
||||
|
||||
#include <sc_export.h>
|
||||
#include <string>
|
||||
#include <limits>
|
||||
|
||||
|
||||
@@ -36,6 +37,7 @@ class SC_DAI_EXPORT SDAI_String {
|
||||
|
||||
// operators
|
||||
SDAI_String & operator= ( const char * s );
|
||||
SDAI_String & operator= ( const SDAI_String & s );
|
||||
bool operator== ( const char * s ) const;
|
||||
|
||||
void clear( void );
|
||||
@@ -0,0 +1,20 @@
|
||||
set(EDITOR_HDRS
|
||||
STEPfile.h
|
||||
cmdmgr.h
|
||||
editordefines.h
|
||||
SdaiHeaderSchema.h
|
||||
SdaiHeaderSchemaClasses.h
|
||||
SdaiSchemaInit.h
|
||||
seeinfodefault.h
|
||||
)
|
||||
|
||||
install(FILES ${EDITOR_HDRS}
|
||||
DESTINATION ${INCLUDE_DIR}/stepcode/cleditor)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
@@ -15,14 +15,14 @@
|
||||
|
||||
#include <sc_export.h>
|
||||
#include <string>
|
||||
#include <instmgr.h>
|
||||
#include <Registry.h>
|
||||
#include "clstepcore/instmgr.h"
|
||||
#include "clstepcore/Registry.h"
|
||||
#include <fstream>
|
||||
#include <dirobj.h>
|
||||
#include <errordesc.h>
|
||||
#include "clutils/dirobj.h"
|
||||
#include "clutils/errordesc.h"
|
||||
#include <time.h>
|
||||
|
||||
#include <read_func.h>
|
||||
#include "clstepcore/read_func.h"
|
||||
|
||||
//error reporting level
|
||||
#define READ_COMPLETE 10
|
||||
@@ -5,11 +5,11 @@
|
||||
// regenerate it.
|
||||
|
||||
#include <sc_export.h>
|
||||
#include <sdai.h>
|
||||
#include <Registry.h>
|
||||
#include <STEPaggregate.h>
|
||||
#include <SdaiHeaderSchemaClasses.h>
|
||||
#include <SdaiSchemaInit.h>
|
||||
#include "clstepcore/sdai.h"
|
||||
#include "clstepcore/Registry.h"
|
||||
#include "clstepcore/STEPaggregate.h"
|
||||
#include "cleditor/SdaiHeaderSchemaClasses.h"
|
||||
#include "cleditor/SdaiSchemaInit.h"
|
||||
|
||||
///////// ENTITY section_language
|
||||
|
||||
@@ -9,16 +9,16 @@
|
||||
#endif
|
||||
|
||||
#include <sc_export.h>
|
||||
#include <sdai.h>
|
||||
#include <Registry.h>
|
||||
#include <STEPaggregate.h>
|
||||
#include <STEPundefined.h>
|
||||
#include <ExpDict.h>
|
||||
#include <STEPattribute.h>
|
||||
#include <complexSupport.h>
|
||||
#include "clstepcore/sdai.h"
|
||||
#include "clstepcore/Registry.h"
|
||||
#include "clstepcore/STEPaggregate.h"
|
||||
#include "clstepcore/STEPundefined.h"
|
||||
#include "clstepcore/ExpDict.h"
|
||||
#include "clstepcore/STEPattribute.h"
|
||||
#include "clstepcore/complexSupport.h"
|
||||
|
||||
#include <SdaiHeaderSchemaClasses.h>
|
||||
#include <SdaiHeaderSchema.h>
|
||||
#include "cleditor/SdaiHeaderSchemaClasses.h"
|
||||
#include "cleditor/SdaiHeaderSchema.h"
|
||||
|
||||
SC_EDITOR_EXPORT void HeaderSchemaInit( Registry & );
|
||||
SC_EDITOR_EXPORT void HeaderInitSchemasAndEnts( Registry & );
|
||||
@@ -13,16 +13,16 @@
|
||||
*/
|
||||
|
||||
#include <sc_export.h>
|
||||
#include <gennode.h>
|
||||
#include <gennodelist.h>
|
||||
#include <gennodearray.h>
|
||||
#include "clutils/gennode.h"
|
||||
#include "clutils/gennodelist.h"
|
||||
#include "clutils/gennodearray.h"
|
||||
|
||||
#include <editordefines.h>
|
||||
#include <mgrnode.h>
|
||||
#include <mgrnodelist.h>
|
||||
#include <dispnode.h>
|
||||
#include <dispnodelist.h>
|
||||
#include <SingleLinkList.h>
|
||||
#include "cleditor/editordefines.h"
|
||||
#include "clstepcore/mgrnode.h"
|
||||
#include "clstepcore/mgrnodelist.h"
|
||||
#include "clstepcore/dispnode.h"
|
||||
#include "clstepcore/dispnodelist.h"
|
||||
#include "clstepcore/SingleLinkList.h"
|
||||
|
||||
//#define NUM_CMDMGR_CMDS 9
|
||||
// this is the number of columns that contain cmds (as opposed
|
||||
@@ -145,6 +145,7 @@ class SC_EDITOR_EXPORT CmdMgr {
|
||||
public:
|
||||
|
||||
CmdMgr();
|
||||
~CmdMgr();
|
||||
|
||||
// STATE LIST OPERATIONS
|
||||
MgrNode * GetHead( stateEnum listType );
|
||||
@@ -20,10 +20,10 @@
|
||||
class MgrNode;
|
||||
class DisplayNode;
|
||||
class DisplayNodelist;
|
||||
#include <sdai.h>
|
||||
#include "clstepcore/sdai.h"
|
||||
//class SDAI_Application_instance;
|
||||
|
||||
#include <editordefines.h>
|
||||
#include "cleditor/editordefines.h"
|
||||
|
||||
class SC_EDITOR_EXPORT seeInfo : public DisplayNode {
|
||||
public:
|
||||
@@ -0,0 +1,27 @@
|
||||
set(LAZY_HDRS
|
||||
headerSectionReader.h
|
||||
lazyFileReader.h
|
||||
lazyP21DataSectionReader.h
|
||||
p21HeaderSectionReader.h
|
||||
lazyDataSectionReader.h
|
||||
lazyInstMgr.h
|
||||
lazySupport.h
|
||||
lazyTypes.h
|
||||
sectionReader.h
|
||||
instMgrHelper.h
|
||||
judy.h
|
||||
judyL2Array.h
|
||||
judyLArray.h
|
||||
judyS2Array.h
|
||||
judySArray.h
|
||||
)
|
||||
|
||||
install(FILES ${LAZY_HDRS}
|
||||
DESTINATION ${INCLUDE_DIR}/stepcode/cllazyfile)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
@@ -5,10 +5,9 @@
|
||||
#include <fstream>
|
||||
|
||||
#include "judyL2Array.h"
|
||||
#include "lazyFileReader.h"
|
||||
#include "sectionReader.h"
|
||||
#include "lazyTypes.h"
|
||||
#include "sc_memmgr.h"
|
||||
#include "cllazyfile/lazyFileReader.h"
|
||||
#include "cllazyfile/sectionReader.h"
|
||||
#include "cllazyfile/lazyTypes.h"
|
||||
|
||||
#include "sc_export.h"
|
||||
|
||||
@@ -28,11 +27,9 @@ class SC_LAZYFILE_EXPORT headerSectionReader: public sectionReader {
|
||||
}
|
||||
|
||||
virtual ~headerSectionReader() {
|
||||
//FIXME delete each instance?! maybe add to clear, since it iterates over everything already
|
||||
//enum clearHow { rawData, deletePointers }
|
||||
_headerInstances->clear();
|
||||
_headerInstances->clear( true );
|
||||
delete _headerInstances;
|
||||
}
|
||||
};
|
||||
|
||||
#endif //HEADERSECTIONREADER_H
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
#include <sc_export.h>
|
||||
|
||||
#include <mgrnode.h>
|
||||
#include <lazyInstMgr.h>
|
||||
#include <instmgr.h>
|
||||
#include "clstepcore/mgrnode.h"
|
||||
#include "cllazyfile/lazyInstMgr.h"
|
||||
#include "clstepcore/instmgr.h"
|
||||
|
||||
/**
|
||||
* \file instMgrHelper.h helper classes for the lazyInstMgr. Allows use of SDAI_Application_instance class
|
||||
@@ -31,7 +31,9 @@ class SC_LAZYFILE_EXPORT mgrNodeHelper: public MgrNodeBase {
|
||||
_id = id;
|
||||
}
|
||||
inline SDAI_Application_instance * GetSTEPentity() {
|
||||
return _lim->loadInstance( _id, true );
|
||||
/* Attribute resolution must not convert a batch-owned cache hit
|
||||
* into a process-lifetime retained instance. */
|
||||
return _lim->loadInstance( _id, true, false );
|
||||
}
|
||||
};
|
||||
|
||||
@@ -58,4 +60,3 @@ class SC_LAZYFILE_EXPORT instMgrAdapter: public InstMgrBase {
|
||||
|
||||
|
||||
#endif //INSTMGRHELPER_H
|
||||
|
||||
@@ -25,8 +25,8 @@ struct judyl2KVpair {
|
||||
/** A judyL2 array maps JudyKey's to multiple JudyValue's, similar to std::multimap.
|
||||
* Internally, this is a judyL array of std::vector< JudyValue >.
|
||||
* The first template parameter must be the same size as a void*
|
||||
* \param JudyKey the type of the key, i.e. uint64_t, etc
|
||||
* \param JudyValue the type of the value, i.e. int, pointer-to-object, etc. With judyL2Array, the size of this value can vary.
|
||||
* \tparam JudyKey the type of the key, i.e. uint64_t, etc
|
||||
* \tparam JudyValue the type of the value, i.e. int, pointer-to-object, etc. With judyL2Array, the size of this value can vary.
|
||||
*/
|
||||
template< typename JudyKey, typename JudyValue >
|
||||
class judyL2Array {
|
||||
@@ -24,8 +24,8 @@ struct judylKVpair {
|
||||
* a JudyValue. Each cell must be set to a non-zero value by the caller.
|
||||
*
|
||||
* Both template parameters must be the same size as a void*
|
||||
* \param JudyKey the type of the key, i.e. uint64_t, pointer-to-object, etc
|
||||
* \param JudyValue the type of the value
|
||||
* \tparam JudyKey the type of the key, i.e. uint64_t, pointer-to-object, etc
|
||||
* \tparam JudyValue the type of the value
|
||||
*/
|
||||
template< typename JudyKey, typename JudyValue >
|
||||
class judyLArray {
|
||||
@@ -159,8 +159,8 @@ class judyLArray {
|
||||
* getLastValue() will return the entry before the one that was deleted
|
||||
* \sa isEmpty()
|
||||
*/
|
||||
bool removeEntry( JudyKey * key ) {
|
||||
if( judy_slot( _judyarray, key, _depth * JUDY_key_size ) ) {
|
||||
bool removeEntry( JudyKey key ) {
|
||||
if( judy_slot( _judyarray, reinterpret_cast<const unsigned char *>( &key ), _depth * JUDY_key_size ) ) {
|
||||
_lastSlot = ( JudyValue * ) judy_del( _judyarray );
|
||||
return true;
|
||||
} else {
|
||||
@@ -25,7 +25,7 @@ struct judys2KVpair {
|
||||
|
||||
/** A judyS2 array maps a set of strings to multiple JudyValue's, similar to std::multimap.
|
||||
* Internally, this is a judyS array of std::vector< JudyValue >.
|
||||
* \param JudyValue the type of the value, i.e. int, pointer-to-object, etc.
|
||||
* \tparam JudyValue the type of the value, i.e. int, pointer-to-object, etc.
|
||||
*/
|
||||
template< typename JudyValue >
|
||||
class judyS2Array {
|
||||
@@ -51,8 +51,8 @@ class judyS2Array {
|
||||
explicit judyS2Array( const judyS2Array< JudyValue > & other ): _maxKeyLen( other._maxKeyLen ), _success( other._success ) {
|
||||
_judyarray = judy_clone( other._judyarray );
|
||||
_buff = new unsigned char[_maxKeyLen];
|
||||
strncpy( _buff, other._buff, _maxKeyLen );
|
||||
_buff[ _maxKeyLen ] = '\0'; //ensure that _buff is null-terminated, since strncpy won't necessarily do so
|
||||
strncpy( reinterpret_cast< char * >( _buff ), reinterpret_cast< const char * >( other._buff ), _maxKeyLen - 1 );
|
||||
_buff[ _maxKeyLen - 1 ] = '\0'; //ensure that _buff is null-terminated
|
||||
find( _buff ); //set _lastSlot
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@ class judySArray {
|
||||
explicit judySArray( const judySArray< JudyValue > & other ): _maxKeyLen( other._maxKeyLen ), _success( other._success ) {
|
||||
_judyarray = judy_clone( other._judyarray );
|
||||
_buff = new unsigned char[_maxKeyLen];
|
||||
strncpy( _buff, other._buff, _maxKeyLen );
|
||||
_buff[ _maxKeyLen ] = '\0'; //ensure that _buff is null-terminated, since strncpy won't necessarily do so
|
||||
strncpy( reinterpret_cast< char * >( _buff ), reinterpret_cast< const char * >( other._buff ), _maxKeyLen - 1 );
|
||||
_buff[ _maxKeyLen - 1 ] = '\0'; //ensure that _buff is null-terminated
|
||||
find( _buff ); //set _lastSlot
|
||||
}
|
||||
|
||||
@@ -3,9 +3,8 @@
|
||||
|
||||
#include <map>
|
||||
#include <iostream>
|
||||
#include "sectionReader.h"
|
||||
#include "lazyTypes.h"
|
||||
#include "sc_memmgr.h"
|
||||
#include "cllazyfile/sectionReader.h"
|
||||
#include "cllazyfile/lazyTypes.h"
|
||||
|
||||
#include "sc_export.h"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef LAZYFILEREADER_H
|
||||
#define LAZYFILEREADER_H
|
||||
|
||||
#include <atomic>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <cstdlib>
|
||||
@@ -8,16 +9,14 @@
|
||||
#include "sc_export.h"
|
||||
|
||||
// PART 21
|
||||
#include "lazyP21DataSectionReader.h"
|
||||
#include "p21HeaderSectionReader.h"
|
||||
#include "headerSectionReader.h"
|
||||
#include "cllazyfile/lazyP21DataSectionReader.h"
|
||||
#include "cllazyfile/p21HeaderSectionReader.h"
|
||||
#include "cllazyfile/headerSectionReader.h"
|
||||
|
||||
/* // PART 28
|
||||
* #include "lazyP28DataSectionReader.h"
|
||||
* #include "p28HeaderSectionReader.h"
|
||||
*/
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
class lazyInstMgr;
|
||||
class Registry;
|
||||
class headerSectionReader;
|
||||
@@ -34,11 +33,14 @@ class SC_LAZYFILE_EXPORT lazyFileReader {
|
||||
lazyInstMgr * _parent;
|
||||
headerSectionReader * _header;
|
||||
std::ifstream _file;
|
||||
std::atomic<bool> _schemaWarningClaimed;
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
fileTypeEnum _fileType;
|
||||
fileID _fileID;
|
||||
lazyFileOffset _fileSize;
|
||||
bool _valid;
|
||||
|
||||
void initP21();
|
||||
|
||||
@@ -50,6 +52,12 @@ class SC_LAZYFILE_EXPORT lazyFileReader {
|
||||
fileID ID() const {
|
||||
return _fileID;
|
||||
}
|
||||
lazyFileOffset fileSize() const {
|
||||
return _fileSize;
|
||||
}
|
||||
bool valid() const {
|
||||
return _valid;
|
||||
}
|
||||
instancesLoaded_t * getHeaderInstances();
|
||||
|
||||
lazyFileReader( std::string fname, lazyInstMgr * i, fileID fid );
|
||||
@@ -62,8 +70,15 @@ class SC_LAZYFILE_EXPORT lazyFileReader {
|
||||
return _parent;
|
||||
}
|
||||
|
||||
/** Return true only to the first caller reporting a FILE_SCHEMA
|
||||
* selection warning for this file. Instance materialization may
|
||||
* occur concurrently and span multiple DATA sections. */
|
||||
bool claimSchemaWarning() {
|
||||
return !_schemaWarningClaimed.exchange( true,
|
||||
std::memory_order_relaxed );
|
||||
}
|
||||
|
||||
bool needKW( const char * kw );
|
||||
};
|
||||
|
||||
#endif //LAZYFILEREADER_H
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
#ifndef LAZYINSTMGR_H
|
||||
#define LAZYINSTMGR_H
|
||||
|
||||
#include <cctype>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <assert.h>
|
||||
|
||||
#include "lazyDataSectionReader.h"
|
||||
#include "lazyFileReader.h"
|
||||
#include "lazyTypes.h"
|
||||
#include "cllazyfile/lazyDataSectionReader.h"
|
||||
#include "cllazyfile/lazyFileReader.h"
|
||||
#include "cllazyfile/lazyTypes.h"
|
||||
#include "cllazyfile/lazySupport.h"
|
||||
|
||||
#include "Registry.h"
|
||||
#include "sc_memmgr.h"
|
||||
#include "clstepcore/Registry.h"
|
||||
#include "sc_export.h"
|
||||
|
||||
#include "judyLArray.h"
|
||||
@@ -20,6 +23,7 @@
|
||||
|
||||
class Registry;
|
||||
class instMgrAdapter;
|
||||
class lazyRefs;
|
||||
|
||||
class SC_LAZYFILE_EXPORT lazyInstMgr {
|
||||
protected:
|
||||
@@ -62,15 +66,51 @@ class SC_LAZYFILE_EXPORT lazyInstMgr {
|
||||
|
||||
lazyFileReaderVec_t _files;
|
||||
|
||||
/** All indexed DATA instance IDs in deterministic file order. */
|
||||
instanceRefs _allInstances;
|
||||
|
||||
Registry * _headerRegistry, * _mainRegistry;
|
||||
bool _ownsMainRegistry;
|
||||
ErrorDescriptor * _errors;
|
||||
|
||||
unsigned long _lazyInstanceCount, _loadedInstanceCount;
|
||||
uint64_t _cacheHighWater, _cacheHits, _cacheMisses, _materializations, _evictions;
|
||||
uint64_t _activeBatches;
|
||||
uint64_t _residentSourceBytes, _sourceBytesHighWater;
|
||||
int _longestTypeNameLen;
|
||||
std::string _longestTypeName;
|
||||
|
||||
std::map<instanceID, size_t> _pinCounts;
|
||||
std::map<instanceID, uint64_t> _instanceSourceBytes;
|
||||
std::map<instanceID, std::vector<std::string> > _instanceComponentTypes;
|
||||
std::map<std::string, std::string> _materializationTypeAliases;
|
||||
std::set<instanceID> _batchOwnedInstances;
|
||||
std::set<instanceID> _permanentlyLoadedInstances;
|
||||
std::set<instanceID> _instancesLoading;
|
||||
std::set<instanceID> _deferredInverseInstances;
|
||||
size_t _batchLoadDepth;
|
||||
|
||||
LazyProgressCallback _progressCallback;
|
||||
LazyCancellationCallback _cancellationCallback;
|
||||
LazyDiagnosticCallback _diagnosticCallback;
|
||||
std::map<std::string, uint64_t> _diagnosticCounts;
|
||||
bool _cancelled;
|
||||
|
||||
instMgrAdapter * _ima;
|
||||
|
||||
friend class LazyInstanceBatch;
|
||||
friend class lazyRefs;
|
||||
void releaseBatch( const std::vector<instanceID> & instances );
|
||||
void resolveDeferredInverses();
|
||||
bool isMaterializing( instanceID id ) const {
|
||||
return _instancesLoading.count( id ) != 0;
|
||||
}
|
||||
void deferInverseResolution( instanceID id ) {
|
||||
_deferredInverseInstances.insert( id );
|
||||
}
|
||||
SDAI_Application_instance * cachedInstance( instanceID id );
|
||||
std::vector<instanceID> dependencyClosure( const std::vector<instanceID> & roots );
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
@@ -78,13 +118,34 @@ class SC_LAZYFILE_EXPORT lazyInstMgr {
|
||||
public:
|
||||
lazyInstMgr();
|
||||
~lazyInstMgr();
|
||||
void openFile( std::string fname );
|
||||
bool openFile( std::string fname );
|
||||
|
||||
void addLazyInstance( namedLazyInstance inst );
|
||||
InstMgrBase * getAdapter() {
|
||||
return ( InstMgrBase * ) _ima;
|
||||
}
|
||||
|
||||
/** Register an explicit source-keyword substitution used only when
|
||||
* materializing an SDAI object. The lazy type index retains the
|
||||
* original Part 21 keyword. This is intended for known,
|
||||
* attribute-compatible exporter aliases, not arbitrary recovery. */
|
||||
void setMaterializationTypeAlias( std::string source, const std::string & target ) {
|
||||
for( std::string::iterator c = source.begin(); c != source.end(); ++c ) {
|
||||
*c = static_cast<char>( toupper( static_cast<unsigned char>( *c ) ) );
|
||||
}
|
||||
_materializationTypeAliases[source] = target;
|
||||
}
|
||||
|
||||
std::string materializationType( std::string source ) const {
|
||||
std::string key = source;
|
||||
for( std::string::iterator c = key.begin(); c != key.end(); ++c ) {
|
||||
*c = static_cast<char>( toupper( static_cast<unsigned char>( *c ) ) );
|
||||
}
|
||||
std::map<std::string, std::string>::const_iterator alias =
|
||||
_materializationTypeAliases.find( key );
|
||||
return alias == _materializationTypeAliases.end() ? source : alias->second;
|
||||
}
|
||||
|
||||
instanceRefs_t * getFwdRefs() {
|
||||
return & _fwdInstanceRefs;
|
||||
}
|
||||
@@ -92,19 +153,33 @@ class SC_LAZYFILE_EXPORT lazyInstMgr {
|
||||
instanceRefs_t * getRevRefs() {
|
||||
return & _revInstanceRefs;
|
||||
}
|
||||
LazyInstanceIdView instancesByType( std::string type, bool caseSensitive = false );
|
||||
LazyInstanceIdView allInstances() const {
|
||||
return LazyInstanceIdView( &_allInstances );
|
||||
}
|
||||
LazyInstanceIdView forwardReferences( instanceID id );
|
||||
LazyInstanceIdView reverseReferences( instanceID id );
|
||||
/** Copy the exact indexed source record for an instance. Returns an
|
||||
* empty string when the ID is missing or ambiguous. */
|
||||
std::string sourceRecord( instanceID id );
|
||||
/** Return the Part 21 component keywords of a complex instance in
|
||||
* source order. Ordinary and unknown instances return an empty
|
||||
* vector. */
|
||||
const std::vector<std::string> & componentTypes( instanceID id ) const;
|
||||
|
||||
/// returns a vector containing the instances that match `type`
|
||||
instanceTypes_t::cvector * getInstances( std::string type, bool caseSensitive = false ) { /*const*/
|
||||
if( !caseSensitive ) {
|
||||
std::string::iterator it = type.begin();
|
||||
for( ; it != type.end(); ++it ) {
|
||||
*it = toupper( *it );
|
||||
*it = static_cast<char>( toupper( static_cast<unsigned char>( *it ) ) );
|
||||
}
|
||||
}
|
||||
return _instanceTypes->find( type.c_str() );
|
||||
}
|
||||
/// get the number of instances of a certain type
|
||||
unsigned int countInstances( std::string type ) {
|
||||
instanceTypes_t::cvector * v = _instanceTypes->find( type.c_str() );
|
||||
unsigned int countInstances( std::string type, bool caseSensitive = false ) {
|
||||
instanceTypes_t::cvector * v = getInstances( type, caseSensitive );
|
||||
if( !v ) {
|
||||
return 0;
|
||||
}
|
||||
@@ -124,6 +199,28 @@ class SC_LAZYFILE_EXPORT lazyInstMgr {
|
||||
return _loadedInstanceCount;
|
||||
}
|
||||
|
||||
LazyCacheStatistics cacheStatistics() const;
|
||||
|
||||
void setProgressCallback( const LazyProgressCallback & callback ) {
|
||||
_progressCallback = callback;
|
||||
}
|
||||
void setCancellationCallback( const LazyCancellationCallback & callback ) {
|
||||
_cancellationCallback = callback;
|
||||
}
|
||||
void setDiagnosticCallback( const LazyDiagnosticCallback & callback ) {
|
||||
_diagnosticCallback = callback;
|
||||
}
|
||||
bool cancelled() const {
|
||||
return _cancelled;
|
||||
}
|
||||
void observeScan( fileID file, lazyFileOffset offset, lazyFileOffset fileSize );
|
||||
void emitDiagnostic( LazyDiagnostic diagnostic );
|
||||
uint64_t diagnosticCount( const std::string & key ) const;
|
||||
const std::map<std::string, uint64_t> & diagnosticCounts() const {
|
||||
return _diagnosticCounts;
|
||||
}
|
||||
void validateReferences();
|
||||
|
||||
/// get the number of data sections that have been identified
|
||||
unsigned int countDataSections() {
|
||||
return _dataSections.size();
|
||||
@@ -131,7 +228,9 @@ class SC_LAZYFILE_EXPORT lazyInstMgr {
|
||||
|
||||
///builds the registry using the given initFunct
|
||||
const Registry * initRegistry( CF_init initFunct ) {
|
||||
setRegistry( new Registry( initFunct ) );
|
||||
assert( _mainRegistry == 0 );
|
||||
_mainRegistry = new Registry( initFunct );
|
||||
_ownsMainRegistry = true;
|
||||
return _mainRegistry;
|
||||
}
|
||||
|
||||
@@ -139,6 +238,7 @@ class SC_LAZYFILE_EXPORT lazyInstMgr {
|
||||
void setRegistry( Registry * reg ) {
|
||||
assert( _mainRegistry == 0 );
|
||||
_mainRegistry = reg;
|
||||
_ownsMainRegistry = false;
|
||||
}
|
||||
|
||||
const Registry * getHeaderRegistry() const {
|
||||
@@ -166,8 +266,12 @@ class SC_LAZYFILE_EXPORT lazyInstMgr {
|
||||
/** returns a pointer to an instance, loading it if necessary.
|
||||
* \param id the instance number to look for
|
||||
* \param reSeek if true, reset file position to current position when done. only necessary when loading an instance with dependencies; excessive use will cause a performance hit
|
||||
* \param promoteCached if true, a cached instance requested outside a batch is retained for legacy callers
|
||||
*/
|
||||
SDAI_Application_instance * loadInstance( instanceID id, bool reSeek = false );
|
||||
SDAI_Application_instance * loadInstance( instanceID id, bool reSeek = false, bool promoteCached = true );
|
||||
|
||||
LazyInstanceBatch loadBatch( instanceID root );
|
||||
LazyInstanceBatch loadBatch( const std::vector<instanceID> & roots );
|
||||
|
||||
//list all instances that one instance depends on (recursive)
|
||||
instanceSet * instanceDependencies( instanceID id );
|
||||
@@ -184,11 +288,16 @@ class SC_LAZYFILE_EXPORT lazyInstMgr {
|
||||
std::cerr << "Error at " << __FILE__ << ":" << __LINE__ << " - multiple instances (" << cv->size() << ") with one instanceID (" << id << ") not supported yet." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
positionAndSection ps = cv->at( 0 );
|
||||
//extract p, s, call
|
||||
long int off = ps & 0xFFFFFFFFFFFFULL;
|
||||
sectionID sid = ps >> 48;
|
||||
return _dataSections[sid]->getType( off );
|
||||
instancePosition pos = cv->at( 0 );
|
||||
//a data section indexes its instances from its own constructor and is
|
||||
//registered only afterwards, and only if it succeeded - so an instance
|
||||
//can name a section that was never registered. Same test sourceRecord()
|
||||
//already makes.
|
||||
if( pos.section >= _dataSections.size() || !_dataSections[pos.section] ) {
|
||||
std::cerr << "Error at " << __FILE__ << ":" << __LINE__ << " - instanceID " << id << " names data section " << pos.section << ", which failed to index." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
return _dataSections[pos.section]->getType( pos.begin );
|
||||
}
|
||||
std::cerr << "Error at " << __FILE__ << ":" << __LINE__ << " - instanceID " << id << " not found." << std::endl;
|
||||
return 0;
|
||||
@@ -219,4 +328,3 @@ class SC_LAZYFILE_EXPORT lazyInstMgr {
|
||||
};
|
||||
|
||||
#endif //LAZYINSTMGR_H
|
||||
|
||||
+6
-7
@@ -1,19 +1,19 @@
|
||||
#ifndef LAZYP21DATASECTIONREADER_H
|
||||
#define LAZYP21DATASECTIONREADER_H
|
||||
|
||||
#include "lazyDataSectionReader.h"
|
||||
#include "lazyFileReader.h"
|
||||
#include "sc_memmgr.h"
|
||||
#include "cllazyfile/lazyDataSectionReader.h"
|
||||
#include "cllazyfile/lazyFileReader.h"
|
||||
#include "sc_export.h"
|
||||
|
||||
class SC_LAZYFILE_EXPORT lazyP21DataSectionReader: public lazyDataSectionReader {
|
||||
protected:
|
||||
/** Index the instances in an Edition 1 SCOPE and leave the stream at
|
||||
* the owning entity's record. */
|
||||
bool indexScope();
|
||||
public:
|
||||
lazyP21DataSectionReader( lazyFileReader * parent, std::ifstream & file, std::streampos start, sectionID sid );
|
||||
|
||||
void findSectionStart() {
|
||||
_sectionStart = findNormalString( "DATA", true );
|
||||
}
|
||||
void findSectionStart();
|
||||
/** gets information (start, end, name, etc) about the next
|
||||
* instance in the file and returns it in a namedLazyInstance
|
||||
* \sa p21HeaderSectionReader::nextInstance()
|
||||
@@ -23,4 +23,3 @@ class SC_LAZYFILE_EXPORT lazyP21DataSectionReader: public lazyDataSectionReader
|
||||
};
|
||||
|
||||
#endif //LAZYP21DATASECTIONREADER_H
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
#ifndef LAZYSUPPORT_H
|
||||
#define LAZYSUPPORT_H
|
||||
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "cllazyfile/lazyTypes.h"
|
||||
#include "sc_export.h"
|
||||
|
||||
class lazyInstMgr;
|
||||
class SDAI_Application_instance;
|
||||
|
||||
enum LazyDiagnosticSeverity {
|
||||
LAZY_DIAGNOSTIC_INFO,
|
||||
LAZY_DIAGNOSTIC_WARNING,
|
||||
LAZY_DIAGNOSTIC_ERROR,
|
||||
LAZY_DIAGNOSTIC_FATAL
|
||||
};
|
||||
|
||||
struct SC_LAZYFILE_EXPORT LazyDiagnostic {
|
||||
LazyDiagnosticSeverity severity;
|
||||
instanceID entity;
|
||||
std::string type;
|
||||
lazyFileOffset offset;
|
||||
uint64_t line;
|
||||
std::string attribute;
|
||||
std::string message;
|
||||
uint64_t occurrences;
|
||||
|
||||
LazyDiagnostic(): severity( LAZY_DIAGNOSTIC_INFO ), entity( 0 ), offset( 0 ),
|
||||
line( 0 ), occurrences( 1 ) {}
|
||||
};
|
||||
|
||||
struct SC_LAZYFILE_EXPORT LazyScanProgress {
|
||||
fileID file;
|
||||
lazyFileOffset offset;
|
||||
lazyFileOffset fileSize;
|
||||
uint64_t instancesScanned;
|
||||
|
||||
LazyScanProgress(): file( 0 ), offset( 0 ), fileSize( 0 ), instancesScanned( 0 ) {}
|
||||
};
|
||||
|
||||
struct SC_LAZYFILE_EXPORT LazyCacheStatistics {
|
||||
uint64_t instancesScanned;
|
||||
uint64_t instancesLoaded;
|
||||
uint64_t instancesPinned;
|
||||
uint64_t cacheHighWater;
|
||||
uint64_t cacheHits;
|
||||
uint64_t cacheMisses;
|
||||
uint64_t materializations;
|
||||
uint64_t evictions;
|
||||
uint64_t activeBatches;
|
||||
uint64_t dataSections;
|
||||
uint64_t residentSourceBytes;
|
||||
uint64_t sourceBytesHighWater;
|
||||
bool cancelled;
|
||||
|
||||
LazyCacheStatistics(): instancesScanned( 0 ), instancesLoaded( 0 ), instancesPinned( 0 ),
|
||||
cacheHighWater( 0 ), cacheHits( 0 ), cacheMisses( 0 ), materializations( 0 ),
|
||||
evictions( 0 ), activeBatches( 0 ), dataSections( 0 ), residentSourceBytes( 0 ),
|
||||
sourceBytesHighWater( 0 ), cancelled( false ) {}
|
||||
};
|
||||
|
||||
typedef std::function<void ( const LazyScanProgress & )> LazyProgressCallback;
|
||||
typedef std::function<bool ()> LazyCancellationCallback;
|
||||
typedef std::function<void ( const LazyDiagnostic & )> LazyDiagnosticCallback;
|
||||
|
||||
/** A non-owning, zero-copy view of an indexed instance-ID vector.
|
||||
* The view remains valid until another file is scanned by the manager.
|
||||
*/
|
||||
class SC_LAZYFILE_EXPORT LazyInstanceIdView {
|
||||
public:
|
||||
typedef instanceRefs::const_iterator const_iterator;
|
||||
|
||||
LazyInstanceIdView(): _ids( 0 ) {}
|
||||
explicit LazyInstanceIdView( const instanceRefs * ids ): _ids( ids ) {}
|
||||
|
||||
const_iterator begin() const;
|
||||
const_iterator end() const;
|
||||
size_t size() const;
|
||||
bool empty() const;
|
||||
instanceID operator[]( size_t index ) const;
|
||||
|
||||
private:
|
||||
const instanceRefs * _ids;
|
||||
};
|
||||
|
||||
/** A dependency closure materialized and pinned for a bounded operation.
|
||||
* STEPcode parsing remains single-threaded. Detach immutable conversion data
|
||||
* before releasing the batch or passing work to another thread.
|
||||
*/
|
||||
class SC_LAZYFILE_EXPORT LazyInstanceBatch {
|
||||
public:
|
||||
LazyInstanceBatch();
|
||||
~LazyInstanceBatch();
|
||||
LazyInstanceBatch( LazyInstanceBatch && other );
|
||||
LazyInstanceBatch & operator=( LazyInstanceBatch && other );
|
||||
|
||||
LazyInstanceBatch( const LazyInstanceBatch & ) = delete;
|
||||
LazyInstanceBatch & operator=( const LazyInstanceBatch & ) = delete;
|
||||
|
||||
bool valid() const;
|
||||
void release();
|
||||
const std::vector<instanceID> & roots() const;
|
||||
const std::vector<instanceID> & instances() const;
|
||||
SDAI_Application_instance * get( instanceID id ) const;
|
||||
|
||||
private:
|
||||
friend class lazyInstMgr;
|
||||
LazyInstanceBatch( lazyInstMgr * manager, const std::vector<instanceID> & roots,
|
||||
const std::vector<instanceID> & instances );
|
||||
|
||||
lazyInstMgr * _manager;
|
||||
std::vector<instanceID> _roots;
|
||||
std::vector<instanceID> _instances;
|
||||
};
|
||||
|
||||
/** Adapter preserving a stream-oriented diagnostic presentation. */
|
||||
class SC_LAZYFILE_EXPORT LazyTextDiagnosticAdapter {
|
||||
public:
|
||||
explicit LazyTextDiagnosticAdapter( std::ostream & stream );
|
||||
void operator()( const LazyDiagnostic & diagnostic ) const;
|
||||
|
||||
private:
|
||||
std::ostream * _stream;
|
||||
};
|
||||
|
||||
#endif // LAZYSUPPORT_H
|
||||
@@ -1,11 +1,12 @@
|
||||
#ifndef LAZYTYPES_H
|
||||
#define LAZYTYPES_H
|
||||
|
||||
#include "sc_cf.h"
|
||||
#include "config.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
@@ -29,6 +30,7 @@ enum fileTypeEnum { Part21, Part28 };
|
||||
// enum loadingEnum { immediate, lazy };
|
||||
|
||||
typedef uint64_t instanceID; ///< the number assigned to an instance in the file
|
||||
typedef uint64_t lazyFileOffset; ///< byte offset in an exchange file
|
||||
typedef uint16_t sectionID; ///< globally unique index of a sectionReader in a sectionReaderVec_t
|
||||
typedef uint16_t fileID; ///< the index of a lazyFileReader in a lazyFileReaderVec_t. Can be inferred from a sectionID
|
||||
|
||||
@@ -42,7 +44,10 @@ typedef uint16_t fileID; ///< the index of a lazyFileReader in a lazyFileRe
|
||||
* section = ( ps >> 48 );
|
||||
* TODO: Also 8 bits of flags? Would allow files of 2^40 bytes, or ~1TB.
|
||||
*/
|
||||
typedef uint64_t positionAndSection;
|
||||
typedef struct {
|
||||
lazyFileOffset begin;
|
||||
sectionID section;
|
||||
} instancePosition;
|
||||
|
||||
typedef std::vector< instanceID > instanceRefs;
|
||||
|
||||
@@ -55,7 +60,8 @@ typedef std::set< instanceID > instanceSet;
|
||||
* situations, so the information should be kept up-to-date.
|
||||
*/
|
||||
typedef struct {
|
||||
long begin; ///< this is the result of tellg() before reading the instanceID; there may be whitespace or comments, but nothing else.
|
||||
lazyFileOffset begin; ///< byte offset before the instance ID; whitespace or comments may precede it.
|
||||
lazyFileOffset end; ///< byte offset immediately after the terminating semicolon.
|
||||
instanceID instance;
|
||||
sectionID section;
|
||||
/* bool modified; */ /* this will be useful when writing instances - if an instance is
|
||||
@@ -67,6 +73,7 @@ typedef struct {
|
||||
lazyInstanceLoc loc;
|
||||
const char * name;
|
||||
instanceRefs * refs;
|
||||
std::vector<std::string> * componentTypes; ///< compositional types for a complex instance
|
||||
} namedLazyInstance;
|
||||
|
||||
// instanceRefs - map between an instanceID and instances that refer to it
|
||||
@@ -80,7 +87,7 @@ typedef judyLArray< instanceID, SDAI_Application_instance * > instancesLoaded_t;
|
||||
|
||||
// instanceStreamPos - map instance id to a streampos and data section
|
||||
// there could be multiple instances with the same ID, but in different files (or different sections of the same file?)
|
||||
typedef judyL2Array< instanceID, positionAndSection > instanceStreamPos_t;
|
||||
typedef judyL2Array< instanceID, instancePosition > instanceStreamPos_t;
|
||||
|
||||
|
||||
// data sections
|
||||
@@ -93,4 +100,3 @@ typedef std::vector< lazyFileReader * > lazyFileReaderVec_t;
|
||||
// NOTE not useful? typedef std::vector< lazyInstance > lazyInstanceVec_t;
|
||||
|
||||
#endif //LAZYTYPES_H
|
||||
|
||||
+1
-2
@@ -1,8 +1,7 @@
|
||||
#ifndef P21HEADERSECTIONREADER_H
|
||||
#define P21HEADERSECTIONREADER_H
|
||||
|
||||
#include "headerSectionReader.h"
|
||||
#include "sc_memmgr.h"
|
||||
#include "cllazyfile/headerSectionReader.h"
|
||||
#include "sc_export.h"
|
||||
|
||||
class SC_LAZYFILE_EXPORT p21HeaderSectionReader: public headerSectionReader {
|
||||
@@ -3,11 +3,10 @@
|
||||
|
||||
#include <fstream>
|
||||
#include <set>
|
||||
#include "lazyTypes.h"
|
||||
#include "sc_memmgr.h"
|
||||
#include "cllazyfile/lazyTypes.h"
|
||||
#include "sc_export.h"
|
||||
#include "errordesc.h"
|
||||
#include "STEPcomplex.h"
|
||||
#include "clutils/errordesc.h"
|
||||
#include "clstepcore/STEPcomplex.h"
|
||||
|
||||
class SDAI_Application_instance;
|
||||
class lazyFileReader;
|
||||
@@ -38,6 +37,7 @@ class SC_LAZYFILE_EXPORT sectionReader {
|
||||
// protected member functions
|
||||
|
||||
sectionReader( lazyFileReader * parent, std::ifstream & file, std::streampos start, sectionID sid );
|
||||
~sectionReader();
|
||||
|
||||
/** Find a string, ignoring occurrences in comments or Part 21 strings (i.e. 'string with \S\' control directive' )
|
||||
* \param str string to find
|
||||
@@ -46,12 +46,31 @@ class SC_LAZYFILE_EXPORT sectionReader {
|
||||
*/
|
||||
std::streampos findNormalString( const std::string & str, bool semicolon = false );
|
||||
|
||||
/** Skip from immediately after a comment's opening slash and star
|
||||
* through its closing star and slash. Part 21 comments are opaque:
|
||||
* apostrophes and string-control text inside them have no syntax.
|
||||
*/
|
||||
bool skipComment();
|
||||
|
||||
/** Skip whitespace and Part 21 comments, leaving the next syntactic
|
||||
* token unread. */
|
||||
bool skipTokenSeparators();
|
||||
|
||||
/** Skip an Edition 1 SCOPE construct, including nested scopes and its
|
||||
* optional export list. The stream must initially point at '&' and
|
||||
* is left at the owning entity's record. */
|
||||
bool skipScope();
|
||||
|
||||
/** Skip an optional scope export list at the current stream
|
||||
* position. */
|
||||
bool skipScopeExportList();
|
||||
|
||||
/** Get a keyword ending with one of delimiters.
|
||||
*/
|
||||
const char * getDelimitedKeyword( const char * delimiters );
|
||||
|
||||
/** Seek to the end of the current instance */
|
||||
std::streampos seekInstanceEnd( instanceRefs ** refs );
|
||||
std::streampos seekInstanceEnd( instanceRefs ** refs, std::vector<std::string> * componentTypes = 0 );
|
||||
|
||||
/// operator>> is very slow?!
|
||||
inline void skipWS() {
|
||||
@@ -63,9 +82,15 @@ class SC_LAZYFILE_EXPORT sectionReader {
|
||||
STEPcomplex * CreateSubSuperInstance( const Registry * reg, instanceID fileid, Severity & sev );
|
||||
|
||||
public:
|
||||
SDAI_Application_instance * getRealInstance( const Registry * reg, long int begin, instanceID instance,
|
||||
SDAI_Application_instance * getRealInstance( const Registry * reg, lazyFileOffset begin, instanceID instance,
|
||||
const std::string & typeName = "", const std::string & schName = "", bool header = false );
|
||||
|
||||
/** Return one indexed source record without materializing it. The
|
||||
* stream position is restored before returning. This is intended
|
||||
* for lightweight adapters which can detach scalar/reference data
|
||||
* directly from Part 21 source. */
|
||||
std::string sourceRecord( lazyFileOffset begin, uint64_t length );
|
||||
|
||||
sectionID ID() const {
|
||||
return _sectionID;
|
||||
}
|
||||
@@ -91,13 +116,15 @@ class SC_LAZYFILE_EXPORT sectionReader {
|
||||
/** returns the type string for an instance, read straight from the file
|
||||
* if this function changes, probably need to change nextInstance() as well
|
||||
* don't check errors - they would have been encountered during the initial file scan, and the file is still open so it can't have been modified */
|
||||
const char * getType( long int offset ) {
|
||||
const char * getType( lazyFileOffset offset ) {
|
||||
if( offset <= 0 ) {
|
||||
return 0;
|
||||
}
|
||||
_file.seekg( offset );
|
||||
_file.seekg( static_cast<std::streamoff>( offset ) );
|
||||
readInstanceNumber();
|
||||
skipWS();
|
||||
if( !skipTokenSeparators() ) return 0;
|
||||
if( _file.peek() == '&' && !skipScope() ) return 0;
|
||||
if( !skipTokenSeparators() ) return 0;
|
||||
return getDelimitedKeyword( ";( /\\" );
|
||||
}
|
||||
|
||||
@@ -112,4 +139,3 @@ class SC_LAZYFILE_EXPORT sectionReader {
|
||||
};
|
||||
|
||||
#endif //SECTIONREADER_H
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
set(CORE_HDRS
|
||||
aggrTypeDescriptor.h
|
||||
attrDescriptor.h
|
||||
attrDescriptorList.h
|
||||
baseType.h
|
||||
complexSupport.h
|
||||
create_Aggr.h
|
||||
derivedAttribute.h
|
||||
dictSchema.h
|
||||
dictdefs.h
|
||||
dictionaryInstance.h
|
||||
dispnode.h
|
||||
dispnodelist.h
|
||||
entityDescriptor.h
|
||||
entityDescriptorList.h
|
||||
enumTypeDescriptor.h
|
||||
ExpDict.h
|
||||
explicitItemId.h
|
||||
globalRule.h
|
||||
implicitItemId.h
|
||||
instmgr.h
|
||||
interfaceSpec.h
|
||||
interfacedItem.h
|
||||
inverseAttribute.h
|
||||
inverseAttributeList.h
|
||||
mgrnode.h
|
||||
mgrnodearray.h
|
||||
mgrnodelist.h
|
||||
needFunc.h
|
||||
read_func.h
|
||||
realTypeDescriptor.h
|
||||
Registry.h
|
||||
schRename.h
|
||||
schemaInit.h
|
||||
schemaModule.h
|
||||
sdai.h
|
||||
sdaiApplication_instance.h
|
||||
sdaiSelect.h
|
||||
selectTypeDescriptor.h
|
||||
SingleLinkList.h
|
||||
STEPaggregate.h
|
||||
STEPaggrBinary.h
|
||||
STEPaggrEntity.h
|
||||
STEPaggrEnum.h
|
||||
STEPaggrGeneric.h
|
||||
STEPaggrInt.h
|
||||
STEPaggrReal.h
|
||||
STEPaggrSelect.h
|
||||
STEPaggrString.h
|
||||
STEPattribute.h
|
||||
STEPattributeList.h
|
||||
STEPcomplex.h
|
||||
STEPinvAttrList.h
|
||||
STEPundefined.h
|
||||
stringTypeDescriptor.h
|
||||
SubSuperIterators.h
|
||||
typeDescriptor.h
|
||||
typeDescriptorList.h
|
||||
typeOrRuleVar.h
|
||||
uniquenessRule.h
|
||||
whereRule.h
|
||||
)
|
||||
|
||||
install(FILES ${CORE_HDRS}
|
||||
DESTINATION ${INCLUDE_DIR}/stepcode/clstepcore)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
@@ -15,20 +15,20 @@
|
||||
*/
|
||||
|
||||
#include <sc_export.h>
|
||||
#include <sdai.h>
|
||||
#include "clstepcore/sdai.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <assert.h>
|
||||
|
||||
#include <SingleLinkList.h>
|
||||
#include "clstepcore/SingleLinkList.h"
|
||||
|
||||
#include <baseType.h>
|
||||
#include <dictdefs.h>
|
||||
#include <Str.h>
|
||||
#include "clstepcore/baseType.h"
|
||||
#include "clstepcore/dictdefs.h"
|
||||
#include "clutils/Str.h"
|
||||
|
||||
// each of these contains linked list, list node, iterator
|
||||
#include "attrDescriptorList.h"
|
||||
#include "clstepcore/attrDescriptorList.h"
|
||||
#include "inverseAttributeList.h"
|
||||
#include "typeDescriptorList.h"
|
||||
#include "entityDescriptorList.h"
|
||||
@@ -37,12 +37,12 @@
|
||||
#include "typeDescriptor.h"
|
||||
#include "entityDescriptor.h"
|
||||
#include "enumTypeDescriptor.h"
|
||||
#include "attrDescriptor.h"
|
||||
#include "derivedAttribute.h"
|
||||
#include "clstepcore/attrDescriptor.h"
|
||||
#include "clstepcore/derivedAttribute.h"
|
||||
#include "inverseAttribute.h"
|
||||
|
||||
#include "create_Aggr.h"
|
||||
#include "dictionaryInstance.h"
|
||||
#include "clstepcore/create_Aggr.h"
|
||||
#include "clstepcore/dictionaryInstance.h"
|
||||
|
||||
#include "uniquenessRule.h"
|
||||
#include "whereRule.h"
|
||||
@@ -53,10 +53,10 @@
|
||||
#include "interfaceSpec.h"
|
||||
#include "typeOrRuleVar.h"
|
||||
#include "globalRule.h"
|
||||
#include "dictSchema.h"
|
||||
#include "clstepcore/dictSchema.h"
|
||||
#include "schRename.h"
|
||||
|
||||
#include "aggrTypeDescriptor.h"
|
||||
#include "clstepcore/aggrTypeDescriptor.h"
|
||||
#include "selectTypeDescriptor.h"
|
||||
#include "stringTypeDescriptor.h"
|
||||
#include "realTypeDescriptor.h"
|
||||
@@ -13,11 +13,11 @@
|
||||
*/
|
||||
|
||||
#include <sc_export.h>
|
||||
#include <sdai.h>
|
||||
#include <errordesc.h>
|
||||
#include <sc_hash.h>
|
||||
#include <Str.h>
|
||||
#include <complexSupport.h>
|
||||
#include "clstepcore/sdai.h"
|
||||
#include "clutils/errordesc.h"
|
||||
#include "clutils/sc_hash.h"
|
||||
#include "clutils/Str.h"
|
||||
#include "clstepcore/complexSupport.h"
|
||||
|
||||
|
||||
// defined and created in Registry.cc
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef STEPAGGRBINARY_H
|
||||
#define STEPAGGRBINARY_H
|
||||
|
||||
#include "STEPaggregate.h"
|
||||
#include "clstepcore/STEPaggregate.h"
|
||||
#include <sc_export.h>
|
||||
|
||||
/** \file STEPaggrBinary.h
|
||||
@@ -5,7 +5,7 @@
|
||||
* classes EntityAggregate, EntityNode
|
||||
*/
|
||||
|
||||
#include "STEPaggregate.h"
|
||||
#include "clstepcore/STEPaggregate.h"
|
||||
#include <sc_export.h>
|
||||
|
||||
class SC_CORE_EXPORT EntityAggregate : public STEPaggregate {
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef STEPAGGRENUM_H
|
||||
#define STEPAGGRENUM_H
|
||||
|
||||
#include "STEPaggregate.h"
|
||||
#include "clstepcore/STEPaggregate.h"
|
||||
#include "sc_export.h"
|
||||
/** \file StepaggrEnum.h
|
||||
* classes EnumAggregate, LOGICALS, BOOLEANS, EnumNode
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
/**
|
||||
* \class EnumAggregate
|
||||
* This is a minimal representions for a collection of SDAI_Enum
|
||||
* This is a minimal representation for a collection of SDAI_Enum
|
||||
*/
|
||||
class SC_CORE_EXPORT EnumAggregate : public STEPaggregate {
|
||||
public:
|
||||
@@ -55,7 +55,7 @@ SC_CORE_EXPORT BOOLEANS * create_BOOLEANS();
|
||||
|
||||
/**
|
||||
* * \class EnumNode
|
||||
** This is a minimal representions for node in lists of SDAI_Enum
|
||||
** This is a minimal representation for node in lists of SDAI_Enum
|
||||
*/
|
||||
class SC_CORE_EXPORT EnumNode : public STEPnode {
|
||||
public:
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef STEPAGGRGENERIC_H
|
||||
#define STEPAGGRGENERIC_H
|
||||
|
||||
#include "STEPaggregate.h"
|
||||
#include "clstepcore/STEPaggregate.h"
|
||||
#include <sc_export.h>
|
||||
|
||||
/** \file STEPaggrGeneric.h
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef STEPAGGRINT_H
|
||||
#define STEPAGGRINT_H
|
||||
|
||||
#include "STEPaggregate.h"
|
||||
#include "clstepcore/STEPaggregate.h"
|
||||
#include <sc_export.h>
|
||||
|
||||
class SC_CORE_EXPORT IntAggregate : public STEPaggregate {
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef STEPAGGRREAL_H
|
||||
#define STEPAGGRREAL_H
|
||||
|
||||
#include "STEPaggregate.h"
|
||||
#include "clstepcore/STEPaggregate.h"
|
||||
#include <sc_export.h>
|
||||
|
||||
class SC_CORE_EXPORT RealAggregate : public STEPaggregate {
|
||||
@@ -1,9 +1,11 @@
|
||||
#ifndef STEPAGGRSELECT_H
|
||||
#define STEPAGGRSELECT_H
|
||||
|
||||
#include "STEPaggregate.h"
|
||||
#include "clstepcore/STEPaggregate.h"
|
||||
#include <sc_export.h>
|
||||
|
||||
class SelectTypeDescriptor;
|
||||
|
||||
/** \file STEPaggrSelect.h
|
||||
* classes SelectAggregate, SelectNode
|
||||
*/
|
||||
@@ -11,9 +13,12 @@
|
||||
|
||||
/**
|
||||
* * \class SelectAggregate
|
||||
** This is a minimal represention for a collection of SDAI_Select
|
||||
** This is a minimal representation for a collection of SDAI_Select
|
||||
*/
|
||||
class SC_CORE_EXPORT SelectAggregate : public STEPaggregate {
|
||||
protected:
|
||||
const SelectTypeDescriptor * _select_type;
|
||||
|
||||
public:
|
||||
virtual Severity ReadValue( istream & in, ErrorDescriptor * err,
|
||||
const TypeDescriptor * elem_type,
|
||||
@@ -24,7 +29,7 @@ public:
|
||||
virtual SingleLinkNode * NewNode();
|
||||
virtual STEPaggregate & ShallowCopy( const STEPaggregate & );
|
||||
|
||||
SelectAggregate();
|
||||
explicit SelectAggregate( const SelectTypeDescriptor * select_type = 0 );
|
||||
virtual ~SelectAggregate();
|
||||
};
|
||||
typedef SelectAggregate * SelectAggregateH;
|
||||
@@ -35,7 +40,7 @@ typedef SelectAggregate_ptr SelectAggregate_var;
|
||||
|
||||
/**
|
||||
* * \class SelectNode
|
||||
** This is a minimal representions for node in lists of SDAI_Select
|
||||
** This is a minimal representation for node in lists of SDAI_Select
|
||||
*/
|
||||
class SC_CORE_EXPORT SelectNode : public STEPnode {
|
||||
public:
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef STEPAGGRSTRING_H
|
||||
#define STEPAGGRSTRING_H
|
||||
|
||||
#include "STEPaggregate.h"
|
||||
#include "clstepcore/STEPaggregate.h"
|
||||
#include <sc_export.h>
|
||||
|
||||
/** \file STEPaggrString.h
|
||||
@@ -17,11 +17,11 @@ class STEPaggregate;
|
||||
class TypeDescriptor;
|
||||
|
||||
#include <sc_export.h>
|
||||
#include <errordesc.h>
|
||||
#include <SingleLinkList.h>
|
||||
#include <baseType.h>
|
||||
#include <sdai.h>
|
||||
#include <STEPundefined.h>
|
||||
#include "clutils/errordesc.h"
|
||||
#include "clstepcore/SingleLinkList.h"
|
||||
#include "clstepcore/baseType.h"
|
||||
#include "clstepcore/sdai.h"
|
||||
#include "clstepcore/STEPundefined.h"
|
||||
#include <string>
|
||||
|
||||
#define AGGR_NULL &NilSTEPaggregate
|
||||
@@ -88,6 +88,11 @@ class SC_CORE_EXPORT STEPnode : public SingleLinkNode {
|
||||
protected:
|
||||
int _null;
|
||||
|
||||
/// nodes must start out null; several StrToVal/STEPread paths leave
|
||||
/// _null untouched on failure and would otherwise read uninitialised.
|
||||
STEPnode() : _null( 1 ) {
|
||||
}
|
||||
|
||||
public:
|
||||
int is_null() {
|
||||
return _null;
|
||||
@@ -110,14 +115,14 @@ public:
|
||||
};
|
||||
typedef STEPnode * STEPnodeH;
|
||||
|
||||
#include "STEPaggrGeneric.h"
|
||||
#include "STEPaggrEntity.h"
|
||||
#include "STEPaggrSelect.h"
|
||||
#include "STEPaggrString.h"
|
||||
#include "STEPaggrBinary.h"
|
||||
#include "STEPaggrEnum.h"
|
||||
#include "STEPaggrReal.h"
|
||||
#include "STEPaggrInt.h"
|
||||
#include "clstepcore/STEPaggrGeneric.h"
|
||||
#include "clstepcore/STEPaggrEntity.h"
|
||||
#include "clstepcore/STEPaggrSelect.h"
|
||||
#include "clstepcore/STEPaggrString.h"
|
||||
#include "clstepcore/STEPaggrBinary.h"
|
||||
#include "clstepcore/STEPaggrEnum.h"
|
||||
#include "clstepcore/STEPaggrReal.h"
|
||||
#include "clstepcore/STEPaggrInt.h"
|
||||
|
||||
/******************************************************************
|
||||
** FIXME The following classes are currently stubs
|
||||
@@ -15,10 +15,10 @@
|
||||
|
||||
#include <sc_export.h>
|
||||
#include <stdio.h>
|
||||
#include <errordesc.h>
|
||||
#include <baseType.h>
|
||||
#include "clutils/errordesc.h"
|
||||
#include "clstepcore/baseType.h"
|
||||
|
||||
#include <sdai.h>
|
||||
#include "clstepcore/sdai.h"
|
||||
|
||||
/** \def REAL_NUM_PRECISION
|
||||
* this is used to set a const int Real_Num_Precision
|
||||
@@ -75,21 +75,15 @@ extern SC_CORE_EXPORT void PushPastAggr1Dim( istream & in, std::string & s, Erro
|
||||
class SC_CORE_EXPORT STEPattribute {
|
||||
friend ostream & operator<< ( ostream &, STEPattribute & );
|
||||
friend class SDAI_Application_instance;
|
||||
protected:
|
||||
bool _derive;
|
||||
bool _mustDeletePtr; ///if a member uses new to create an object in ptr
|
||||
ErrorDescriptor _error;
|
||||
STEPattribute * _redefAttr;
|
||||
const AttrDescriptor * aDesc;
|
||||
int refCount;
|
||||
|
||||
public:
|
||||
/** \union ptr
|
||||
** You know which of these to use based on the return value of
|
||||
** NonRefType() - see below. BASE_TYPE is defined in baseType.h
|
||||
** This variable points to an appropriate member variable in the entity
|
||||
** class in the generated schema class library (the entity class is
|
||||
** inherited from SDAI_Application_instance)
|
||||
*/
|
||||
** You know which of these to use based on the return value of
|
||||
** NonRefType() - see below. BASE_TYPE is defined in baseType.h
|
||||
** This variable points to an appropriate member variable in the entity
|
||||
** class in the generated schema class library (the entity class is
|
||||
** inherited from SDAI_Application_instance)
|
||||
*/
|
||||
union attrUnion {
|
||||
SDAI_String * S; // STRING_TYPE
|
||||
SDAI_Integer * i; // INTEGER_TYPE (Integer is a long int)
|
||||
@@ -103,9 +97,22 @@ class SC_CORE_EXPORT STEPattribute {
|
||||
void * p;
|
||||
} ptr;
|
||||
|
||||
|
||||
protected:
|
||||
bool _derive;
|
||||
bool _mustDeletePtr; ///if a member uses new to create an object in ptr
|
||||
ErrorDescriptor _error;
|
||||
STEPattribute * _redefAttr;
|
||||
public:
|
||||
const AttrDescriptor * aDesc;
|
||||
|
||||
protected:
|
||||
int refCount;
|
||||
|
||||
char SkipBadAttr( istream & in, char * StopChars );
|
||||
void AddErrorInfo();
|
||||
void STEPwriteError( ostream& out, unsigned int line, const char* desc );
|
||||
void DeleteOwnedPtr();
|
||||
|
||||
public:
|
||||
void incrRefCount() {
|
||||
@@ -137,6 +144,7 @@ class SC_CORE_EXPORT STEPattribute {
|
||||
|
||||
/// return the attr value as a string
|
||||
string asStr( const char * currSch = 0 ) const;
|
||||
const char * asStr( std::string &, const char * = 0 ) const;
|
||||
|
||||
/// put the attr value in ostream
|
||||
void STEPwrite( ostream & out = cout, const char * currSch = 0 );
|
||||
@@ -167,11 +175,6 @@ class SC_CORE_EXPORT STEPattribute {
|
||||
SCLundefined * Undefined();
|
||||
///@}
|
||||
|
||||
/// allows direct access to the union containing attr data (dangerous!)
|
||||
attrUnion * Raw() {
|
||||
return & ptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* These functions allow setting the attribute value.
|
||||
* Attr type is verified using an assertion.
|
||||
@@ -206,7 +209,7 @@ class SC_CORE_EXPORT STEPattribute {
|
||||
}
|
||||
|
||||
const char * Name() const;
|
||||
const char * TypeName() const;
|
||||
std::string TypeName() const;
|
||||
BASE_TYPE Type() const;
|
||||
BASE_TYPE NonRefType() const;
|
||||
BASE_TYPE BaseType() const;
|
||||
@@ -230,6 +233,14 @@ class SC_CORE_EXPORT STEPattribute {
|
||||
memset( & ptr, 0, sizeof( ptr ) );
|
||||
}
|
||||
~STEPattribute();
|
||||
/** Construct storage owned by this attribute from its descriptor.
|
||||
*
|
||||
* Generated early-bound classes normally pass a pointer to one of
|
||||
* their data members to the typed constructors below. Late-bound
|
||||
* instances have no generated data members, so this constructor
|
||||
* allocates the corresponding value object instead.
|
||||
*/
|
||||
explicit STEPattribute( const class AttrDescriptor & d );
|
||||
// INTEGER
|
||||
STEPattribute( const class AttrDescriptor & d, SDAI_Integer * p );
|
||||
// BINARY
|
||||
@@ -16,7 +16,7 @@
|
||||
class STEPattribute;
|
||||
|
||||
#include <sc_export.h>
|
||||
#include <SingleLinkList.h>
|
||||
#include "clstepcore/SingleLinkList.h"
|
||||
|
||||
class STEPattributeList;
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
#define STEPCOMPLEX_H
|
||||
|
||||
#include <sc_export.h>
|
||||
#include <errordesc.h>
|
||||
#include <sdai.h>
|
||||
#include <baseType.h>
|
||||
#include <ExpDict.h>
|
||||
#include <Registry.h>
|
||||
#include "clutils/errordesc.h"
|
||||
#include "clstepcore/sdai.h"
|
||||
#include "clstepcore/baseType.h"
|
||||
#include "clstepcore/ExpDict.h"
|
||||
#include "clstepcore/Registry.h"
|
||||
|
||||
#include <list>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
class Inverse_attribute;
|
||||
|
||||
#include <sc_export.h>
|
||||
#include <SingleLinkList.h>
|
||||
#include "clstepcore/SingleLinkList.h"
|
||||
|
||||
class STEPinvAttrList;
|
||||
class EntityAggregate;
|
||||
@@ -13,9 +13,9 @@
|
||||
*/
|
||||
|
||||
#include <sc_export.h>
|
||||
#include <errordesc.h>
|
||||
#include "clutils/errordesc.h"
|
||||
#include <string>
|
||||
#include <read_func.h>
|
||||
#include "clstepcore/read_func.h"
|
||||
|
||||
class SC_CORE_EXPORT SCLundefined {
|
||||
protected:
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user