Skip to content

Commit

Permalink
latest from "nitro"
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Smith committed Jun 29, 2022
1 parent cd82b5f commit 0926d6d
Show file tree
Hide file tree
Showing 19 changed files with 282 additions and 38 deletions.
72 changes: 72 additions & 0 deletions externals/nitro/.github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ "master" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "master" ]
schedule:
- cron: '19 23 * * 3'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'cpp' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
56 changes: 56 additions & 0 deletions externals/nitro/.github/workflows/frequent_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Build, unittest

on: [push]


jobs:
build-windows:
name: Windows
runs-on: [windows-latest]

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.7'
- name: configure
run: |
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=installWindows-Github -DPYTHON_VERSION="3.7" ..
- name: make
run: |
cd build
cmake --build . --config Release -j 2
cmake --build . --config Release --target install
- name: test
run: |
cd build
ctest -C Release --output-on-failure
build-linux:
name: Linux
runs-on: [ubuntu-latest]

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.7'
- name: configure
run: |
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=installLinux-Github -DPYTHON_VERSION=3.7 ..
- name: make
run: |
cd build
# using the default number of threads (-j) causes G++ to crash
cmake --build . -j 2
cmake --build . --target install
- name: test
run: |
cd build
ctest --output-on-failure
62 changes: 62 additions & 0 deletions externals/nitro/.github/workflows/master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Build, unittest

on:
push:
branches: master
pull_request:
branches: master


jobs:
build-windows:
name: Windows
runs-on: [windows-latest]

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.7'
- name: configure
run: |
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=installWindows-Github -DPYTHON_VERSION="3.7" ..
- name: make
run: |
cd build
cmake --build . --config Release -j
cmake --build . --config Release --target install
- name: test
run: |
cd build
ctest -C Release
build-linux:
name: Linux
runs-on: [ubuntu-latest]

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.7'
- name: configure
run: |
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=installLinux-Github -DPYTHON_VERSION=3.7 ..
- name: make
run: |
cd build
# using the default number of threads (-j) causes G++ to crash
cmake --build . -j 2
cmake --build . --target install
- name: test
run: |
cd build
ctest
22 changes: 22 additions & 0 deletions externals/nitro/.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
image: continuumio/anaconda3:5.0.1

before_script:
- python -V # Print out python version for debugging
- echo "deb [check-valid-until=no] http://archive.debian.org/debian jessie-backports main" > /etc/apt/sources.list.d/jessie-backports.list
- sed -i '/deb http:\/\/deb.debian.org\/debian jessie-updates main/d' /etc/apt/sources.list
- apt-get -o Acquire::Check-Valid-Until=false update
- apt-get install -y build-essential
- pip install cython Deprecated==1.1

run:
tags:
- docker
script:
- python waf configure --prefix=install --enable-debugging
- python waf build
- python waf install
- (cd modules/python/cython; python setup.py bdist_wheel)
artifacts:
paths:
- install/*
- modules/python/cython/dist/*.whl
25 changes: 25 additions & 0 deletions externals/nitro/dot-github-workflows-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Mac

on: [push]


jobs:
build-mac:
runs-on: [macos-latest]

steps:
- uses: actions/checkout@v2
- name: configure
run: |
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=installWindows-Github ..
- name: make
run: |
cd build
cmake --build . -j
cmake --build . --target install
- name: test
run: |
cd build
ctest
3 changes: 1 addition & 2 deletions externals/nitro/modules/c++/nitf-c++.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{8F357A19-799E-4971-850E-3F28485C130B}</ProjectGuid>
<RootNamespace>nitro</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>nitf-c++</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
Expand Down Expand Up @@ -232,7 +233,6 @@
<TreatWarningAsError>true</TreatWarningAsError>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<SupportJustMyCode>true</SupportJustMyCode>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
</ClCompile>
<Link>
<SubSystem>
Expand Down Expand Up @@ -260,7 +260,6 @@
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<EnforceTypeConversionRules>true</EnforceTypeConversionRules>
<WarningLevel>Level3</WarningLevel>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
</ClCompile>
<Link>
<SubSystem>
Expand Down
14 changes: 7 additions & 7 deletions externals/nitro/modules/c++/nitf/include/nitf/ByteProvider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ struct NITRO_NITFCPP_API ByteProvider
}

//! \return The raw file header bytes
const std::vector<nitf::byte>& getFileHeader() const noexcept
const std::vector<sys::byte>& getFileHeader() const noexcept
{
return mFileHeader;
}
Expand All @@ -144,7 +144,7 @@ struct NITRO_NITFCPP_API ByteProvider
* \return The raw bytes for each image subheader. Vector size matches the
* number of image segments.
*/
const std::vector<std::vector<nitf::byte> >& getImageSubheaders() const noexcept
const std::vector<std::vector<sys::byte> >& getImageSubheaders() const noexcept
{
return mImageSubheaders;
}
Expand All @@ -154,7 +154,7 @@ struct NITRO_NITFCPP_API ByteProvider
* \return The raw bytes for each DES (subheader immediately followed by
* raw DES data). Vector size matches the number of data extension segments.
*/
const std::vector<nitf::byte>& getDesSubheaderAndData() const noexcept
const std::vector<sys::byte>& getDesSubheaderAndData() const noexcept
{
return mDesSubheaderAndData;
}
Expand Down Expand Up @@ -273,7 +273,7 @@ struct NITRO_NITFCPP_API ByteProvider
size_t numRowsPerBlock = 0, size_t numColsPerBlock = 0);

static void copyFromStreamAndClear(io::ByteStream& stream,
std::vector<nitf::byte>& rawBytes);
std::vector<sys::byte>& rawBytes);
static void copyFromStreamAndClear(io::ByteStream& stream,
std::vector<std::byte>& rawBytes);

Expand Down Expand Up @@ -366,11 +366,11 @@ struct NITRO_NITFCPP_API ByteProvider

std::vector<SegmentInfo> mImageSegmentInfo; // Per segment

std::vector<nitf::byte> mFileHeader;
std::vector<std::vector<nitf::byte> > mImageSubheaders; // Per segment
std::vector<sys::byte> mFileHeader;
std::vector<std::vector<sys::byte> > mImageSubheaders; // Per segment

// All DES subheaders and data together contiguously
std::vector<nitf::byte> mDesSubheaderAndData;
std::vector<sys::byte> mDesSubheaderAndData;

std::vector<nitf::Off> mImageSubheaderFileOffsets; // Per segment
nitf::Off mDesSubheaderFileOffset = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ struct NITRO_NITFCPP_API CompressedByteProvider : public ByteProvider
size_t seg,
size_t startRow,
size_t numRowsToWrite,
const nitf::byte* imageData,
const sys::byte* imageData,
nitf::Off& fileOffset,
NITFBufferList& buffers) const;
size_t addImageData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,11 @@ struct NITRO_NITFCPP_API ImageBlocker /*final*/ // no "final", SWIG doesn't li
size_t& lastBlockWithinLastSeg) const;

void blockImpl(size_t seg,
const nitf::byte* input,
const sys::byte* input,
size_t numValidRowsInBlock,
size_t numValidColsInBlock,
size_t numBytesPerPixel,
nitf::byte* output) const noexcept
sys::byte* output) const noexcept
{
block(input, numBytesPerPixel, mNumCols, mNumRowsPerBlock[seg],
mNumColsPerBlock, numValidRowsInBlock, numValidColsInBlock,
Expand Down Expand Up @@ -336,10 +336,10 @@ struct NITRO_NITFCPP_API ImageBlocker /*final*/ // no "final", SWIG doesn't li
input += mNumCols * numBytesPerPixel * (numValidRowsInBlock - 1);
}
void blockAcrossRow(size_t seg,
const nitf::byte*& input,
const sys::byte*& input,
size_t numValidRowsInBlock,
size_t numBytesPerPixel,
nitf::byte*& output) const noexcept
sys::byte*& output) const noexcept
{
blockAcrossRowImpl(seg, input, numValidRowsInBlock, numBytesPerPixel, output);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ DECLARE_CLASS(ImageReader)
* \param padded Returns TRUE if pad pixels may have been read
*/
void read(const nitf::SubWindow & subWindow, uint8_t ** user, int * padded);
void read(const nitf::SubWindow & subWindow, nitf::byte** user, int * padded)
void read(const nitf::SubWindow & subWindow, sys::byte** user, int * padded)
{
void* user_ = user;
read(subWindow, static_cast<uint8_t**>(user_), padded);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ struct NITRO_NITFCPP_API NITFBufferList
*/
const void* getBlock(size_t blockSize,
size_t blockIdx,
std::vector<nitf::byte>& scratch,
std::vector<sys::byte>& scratch,
size_t& numBytes) const;
const void* getBlock(size_t blockSize,
size_t blockIdx,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ struct NITRO_NITFCPP_API SegmentMemorySource : public SegmentSource
* \param copyData Whether or not to make a copy of the data. If this is
* false, the data must outlive the memory source.
*/
SegmentMemorySource(const nitf::byte* data, nitf::Off size, nitf::Off start,
SegmentMemorySource(const sys::byte* data, nitf::Off size, nitf::Off start,
int byteSkip, bool copyData);

SegmentMemorySource(const std::span<const std::byte>& data, nitf::Off start,
int byteSkip, bool copyData);
SegmentMemorySource(const std::span<const nitf::byte>& data, nitf::Off start,
SegmentMemorySource(const std::span<const sys::byte>& data, nitf::Off start,
int byteSkip, bool copyData);
SegmentMemorySource(const std::vector<std::byte>& data, nitf::Off start,
int byteSkip, bool copyData);
SegmentMemorySource(const std::vector<nitf::byte>& data, nitf::Off start,
SegmentMemorySource(const std::vector<sys::byte>& data, nitf::Off start,
int byteSkip, bool copyData);
SegmentMemorySource(const std::string& data, nitf::Off start,
int byteSkip, bool copyData);
Expand Down
Loading

0 comments on commit 0926d6d

Please sign in to comment.