Skip to content

Commit aaf3277

Browse files
committed
automatic template update of MCS-04 Analyzer
1 parent 7ba5f20 commit aaf3277

File tree

7 files changed

+343
-0
lines changed

7 files changed

+343
-0
lines changed

.clang-format

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Logic style
2+
Language: Cpp
3+
# manually added flags
4+
FixNamespaceComments: 'false'
5+
SortIncludes: 'false'
6+
7+
8+
# flags copied from web editor, https://zed0.co.uk/clang-format-configurator/
9+
AllowShortBlocksOnASingleLine: 'false'
10+
AllowShortCaseLabelsOnASingleLine: 'false'
11+
AllowShortFunctionsOnASingleLine: None
12+
AllowShortIfStatementsOnASingleLine: 'false'
13+
AllowShortLoopsOnASingleLine: 'false'
14+
AlwaysBreakAfterReturnType: None
15+
AlwaysBreakTemplateDeclarations: 'true'
16+
BreakBeforeBraces: Allman
17+
ColumnLimit: '140'
18+
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
19+
ContinuationIndentWidth: '4'
20+
Cpp11BracedListStyle: 'false'
21+
IndentWidth: '4'
22+
KeepEmptyLinesAtTheStartOfBlocks: 'false'
23+
MaxEmptyLinesToKeep: '2'
24+
NamespaceIndentation: All
25+
PointerAlignment: Left
26+
SpaceBeforeParens: Never
27+
SpaceInEmptyParentheses: 'false'
28+
SpacesInCStyleCastParentheses: 'true'
29+
SpacesInParentheses: 'true'
30+
SpacesInSquareBrackets: 'true'
31+
TabWidth: '4'
32+
UseTab: Never

.github/workflows/build.yml

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [master]
6+
tags:
7+
- '*'
8+
pull_request:
9+
branches: [master]
10+
11+
jobs:
12+
windows:
13+
runs-on: windows-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
- name: Build
17+
run: |
18+
cmake -B ${{github.workspace}}/build -A x64
19+
cmake --build ${{github.workspace}}/build --config Release
20+
- name: Upload windows build
21+
uses: actions/upload-artifact@v3
22+
with:
23+
name: windows
24+
path: ${{github.workspace}}/build/Analyzers/Release/*.dll
25+
macos:
26+
runs-on: macos-latest
27+
steps:
28+
- uses: actions/checkout@v3
29+
- name: Build
30+
run: |
31+
cmake -B ${{github.workspace}}/build/x86_64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=x86_64
32+
cmake --build ${{github.workspace}}/build/x86_64
33+
cmake -B ${{github.workspace}}/build/arm64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=arm64
34+
cmake --build ${{github.workspace}}/build/arm64
35+
- name: Upload MacOS x86_64 build
36+
uses: actions/upload-artifact@v3
37+
with:
38+
name: macos_x86_64
39+
path: ${{github.workspace}}/build/x86_64/Analyzers/*.so
40+
- name: Upload MacOS arm64 build
41+
uses: actions/upload-artifact@v3
42+
with:
43+
name: macos_arm64
44+
path: ${{github.workspace}}/build/arm64/Analyzers/*.so
45+
linux:
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@v3
49+
- name: Build
50+
run: |
51+
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release
52+
cmake --build ${{github.workspace}}/build
53+
env:
54+
CC: gcc-10
55+
CXX: g++-10
56+
- name: Upload Linux build
57+
uses: actions/upload-artifact@v3
58+
with:
59+
name: linux
60+
path: ${{github.workspace}}/build/Analyzers/*.so
61+
publish:
62+
needs: [windows, macos, linux]
63+
runs-on: ubuntu-latest
64+
steps:
65+
- name: download individual builds
66+
uses: actions/download-artifact@v3
67+
with:
68+
path: ${{github.workspace}}/artifacts
69+
- name: zip
70+
run: |
71+
cd ${{github.workspace}}/artifacts
72+
zip -r ${{github.workspace}}/analyzer.zip .
73+
- uses: actions/upload-artifact@v3
74+
with:
75+
name: all-platforms
76+
path: ${{github.workspace}}/artifacts/**
77+
- name: create release
78+
uses: softprops/action-gh-release@v1
79+
if: startsWith(github.ref, 'refs/tags/')
80+
with:
81+
files: ${{github.workspace}}/analyzer.zip

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

CMakeLists.txt

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
cmake_minimum_required (VERSION 3.11)
2+
project(mcs04_analyzer)
3+
4+
add_definitions( -DLOGIC2 )
5+
6+
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14" CACHE STRING "Minimum supported MacOS version" FORCE)
7+
8+
# enable generation of compile_commands.json, helpful for IDEs to locate include files.
9+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
10+
11+
# custom CMake Modules are located in the cmake directory.
12+
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
13+
14+
include(ExternalAnalyzerSDK)
15+
16+
set(SOURCES
17+
src/MCS04Analyzer.cpp
18+
src/MCS04Analyzer.h
19+
src/MCS04AnalyzerResults.cpp
20+
src/MCS04AnalyzerResults.h
21+
src/MCS04AnalyzerSettings.cpp
22+
src/MCS04AnalyzerSettings.h
23+
src/MCS04Disasm.cpp
24+
src/MCS04Disasm.h
25+
src/MCS04SimulationDataGenerator.cpp
26+
src/MCS04SimulationDataGenerator.h
27+
)
28+
29+
add_analyzer_plugin(mcs04_analyzer SOURCES ${SOURCES})

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Saleae
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Saleae MCS-04 Analyzer
2+
3+
Saleae MCS-04 Analyzer
4+
5+
## Getting Started
6+
7+
The following documentation describes how to build this analyzer locally. For more detailed information about the Analyzer SDK, debugging, CI builds, and more, check out the readme in the Sample Analyzer repository.
8+
9+
https://github.com/saleae/SampleAnalyzer
10+
11+
### MacOS
12+
13+
Dependencies:
14+
15+
- XCode with command line tools
16+
- CMake 3.13+
17+
- git
18+
19+
Install command line tools after XCode is installed:
20+
21+
```
22+
xcode-select --install
23+
```
24+
25+
Then open XCode, open Preferences from the main menu, go to locations, and select the only option under 'Command line tools'.
26+
27+
Install CMake on MacOS:
28+
29+
1. Download the binary distribution for MacOS, `cmake-*-Darwin-x86_64.dmg`
30+
2. Install the usual way by dragging into applications.
31+
3. Open a terminal and run the following:
32+
33+
```
34+
/Applications/CMake.app/Contents/bin/cmake-gui --install
35+
```
36+
37+
_Note: Errors may occur if older versions of CMake are installed._
38+
39+
Build the analyzer:
40+
41+
```
42+
mkdir build
43+
cd build
44+
cmake ..
45+
cmake --build .
46+
```
47+
48+
### Ubuntu 18.04+
49+
50+
Dependencies:
51+
52+
- CMake 3.13+
53+
- gcc 4.8+
54+
- git
55+
56+
Misc dependencies:
57+
58+
```
59+
sudo apt-get install build-essential
60+
```
61+
62+
Build the analyzer:
63+
64+
```
65+
mkdir build
66+
cd build
67+
cmake ..
68+
cmake --build .
69+
```
70+
71+
### Windows
72+
73+
Dependencies:
74+
75+
- Visual Studio 2019
76+
- CMake 3.13+
77+
- git
78+
79+
**Visual Studio 2019**
80+
81+
_Note - newer and older versions of Visual Studio are likely to work._
82+
83+
Setup options:
84+
85+
- Workloads > Desktop & Mobile > "Desktop development with C++"
86+
87+
Note - if CMake has any problems with the MSVC compiler, it's likely a component is missing.
88+
89+
**CMake**
90+
91+
Download and install the latest CMake release here.
92+
https://cmake.org/download/
93+
94+
**git**
95+
96+
Download and install git here.
97+
https://git-scm.com/
98+
99+
Build the analyzer:
100+
101+
```
102+
mkdir build
103+
cd build
104+
cmake .. -A x64
105+
```
106+
107+
Then, open the newly created solution file located here: `build\mcs04_analyzer.sln`
108+
109+
Optionally, build from the command line without opening Visual Studio:
110+
111+
```
112+
cmake --build .
113+
```
114+
115+
The built analyzer DLLs will be located here:
116+
117+
`build\Analyzers\Debug`
118+
119+
`build\Analyzers\Release`
120+
121+
For debug and release builds, respectively.
122+

cmake/ExternalAnalyzerSDK.cmake

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
include(FetchContent)
2+
3+
# Use the C++11 standard
4+
set(CMAKE_CXX_STANDARD 11)
5+
6+
set(CMAKE_CXX_STANDARD_REQUIRED YES)
7+
8+
if (NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY OR NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
9+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin/)
10+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin/)
11+
endif()
12+
13+
# Fetch the Analyzer SDK if the target does not already exist.
14+
if(NOT TARGET Saleae::AnalyzerSDK)
15+
FetchContent_Declare(
16+
analyzersdk
17+
GIT_REPOSITORY https://github.com/saleae/AnalyzerSDK.git
18+
GIT_TAG master
19+
GIT_SHALLOW True
20+
GIT_PROGRESS True
21+
)
22+
23+
FetchContent_GetProperties(analyzersdk)
24+
25+
if(NOT analyzersdk_POPULATED)
26+
FetchContent_Populate(analyzersdk)
27+
include(${analyzersdk_SOURCE_DIR}/AnalyzerSDKConfig.cmake)
28+
29+
if(APPLE OR WIN32)
30+
get_target_property(analyzersdk_lib_location Saleae::AnalyzerSDK IMPORTED_LOCATION)
31+
if(CMAKE_LIBRARY_OUTPUT_DIRECTORY)
32+
file(COPY ${analyzersdk_lib_location} DESTINATION ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
33+
else()
34+
message(WARNING "Please define CMAKE_RUNTIME_OUTPUT_DIRECTORY and CMAKE_LIBRARY_OUTPUT_DIRECTORY if you want unit tests to locate ${analyzersdk_lib_location}")
35+
endif()
36+
endif()
37+
38+
endif()
39+
endif()
40+
41+
function(add_analyzer_plugin TARGET)
42+
set(options )
43+
set(single_value_args )
44+
set(multi_value_args SOURCES)
45+
cmake_parse_arguments( _p "${options}" "${single_value_args}" "${multi_value_args}" ${ARGN} )
46+
47+
48+
add_library(${TARGET} MODULE ${_p_SOURCES})
49+
target_link_libraries(${TARGET} PRIVATE Saleae::AnalyzerSDK)
50+
51+
set(ANALYZER_DESTINATION "Analyzers")
52+
install(TARGETS ${TARGET} RUNTIME DESTINATION ${ANALYZER_DESTINATION}
53+
LIBRARY DESTINATION ${ANALYZER_DESTINATION})
54+
55+
set_target_properties(${TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${ANALYZER_DESTINATION}
56+
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${ANALYZER_DESTINATION})
57+
endfunction()

0 commit comments

Comments
 (0)