Skip to content

Commit

Permalink
libCOMBINE: allow a COMBINE archive to be initialised using some file…
Browse files Browse the repository at this point in the history
… contents.
  • Loading branch information
agarny authored Nov 21, 2024
2 parents 6af3666 + af862ed commit f7e1be2
Show file tree
Hide file tree
Showing 205 changed files with 9,463 additions and 2,042 deletions.
4 changes: 2 additions & 2 deletions .codespellexclude
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
afterAll(() => {
IssuePtrs mErrors;
return !mErrors.empty();
mErrors.push_back(issue);
return mErrors.size();
return mErrors;
mErrors.push_back(issue);
mErrors.clear();
return pimpl()->mErrors;
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -388,12 +388,12 @@ jobs:
cd build
${{ matrix.context }} cmake -G Ninja -DBUILD_TYPE=${{ matrix.build_type }} -DCODE_ANALYSIS=${{ matrix.code_analysis }} -DCODE_COVERAGE=${{ matrix.code_coverage }} -DDOCUMENTATION=${{ matrix.documentation }} -DINSTALL_PREFIX=${{ github.workspace }}/install -DJAVASCRIPT_BINDINGS=${{ matrix.javascript_bindings }} -DJAVASCRIPT_UNIT_TESTING=${{ matrix.javascript_unit_testing }} -DMEMORY_CHECKS=${{ matrix.memory_checks }} -DPYTHON_BINDINGS=${{ matrix.python_bindings }} -DPYTHON_UNIT_TESTING=${{ matrix.python_unit_testing }} -DSHARED_LIBS=${{ matrix.shared_libs }} -DUNIT_TESTING=${{ matrix.unit_testing }} ..
- name: Build libOpenCOR
if: ${{ (matrix.unit_testing == 'ON') || (matrix.javascript_unit_testing == 'ON') || (matrix.code_analysis == 'OFF') || (matrix.code_coverage == 'OFF') || (matrix.memory_checks == 'OFF') }}
if: ${{ (matrix.unit_testing == 'ON') || (matrix.javascript_unit_testing == 'ON') || (matrix.code_analysis == 'ON') || (matrix.code_coverage == 'ON') || (matrix.memory_checks == 'ON') }}
run: |
cd build
ninja
- name: Unit testing
if: ${{ (matrix.unit_testing == 'ON') && (matrix.code_analysis == 'OFF') && (matrix.code_coverage == 'OFF') && (matrix.memory_checks == 'OFF') }}
if: ${{ (matrix.unit_testing == 'ON') || (matrix.code_analysis == 'OFF') || (matrix.code_coverage == 'ON') || (matrix.memory_checks == 'ON') }}
run: |
cd build
ninja ${{ matrix.target }}
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ else()
if(JAVASCRIPT_BINDINGS_AVAILABLE)
if(JAVASCRIPT_UNIT_TESTING_AVAILABLE)
set(LIBOPENCOR_JAVASCRIPT_UNIT_TESTING_DOCSTRING "Enable JAVASCRIPT unit testing.")
set(LIBOPENCOR_JAVASCRIPT_UNIT_TESTING OFF CACHE BOOL "${LIBOPENCOR_JAVASCRIPT_UNIT_TESTING_DOCSTRING}")
set(LIBOPENCOR_JAVASCRIPT_UNIT_TESTING ${LIBOPENCOR_JAVASCRIPT_BINDINGS} CACHE BOOL "${LIBOPENCOR_JAVASCRIPT_UNIT_TESTING_DOCSTRING}")
endif()

if(NOT "${JAVASCRIPT_UNIT_TESTING}" STREQUAL "" AND JAVASCRIPT_UNIT_TESTING_AVAILABLE)
Expand Down Expand Up @@ -372,7 +372,7 @@ else()
if(PYTHON_BINDINGS_AVAILABLE)
if(PYTHON_UNIT_TESTING_AVAILABLE)
set(LIBOPENCOR_PYTHON_UNIT_TESTING_DOCSTRING "Enable Python unit testing.")
set(LIBOPENCOR_PYTHON_UNIT_TESTING OFF CACHE BOOL "${LIBOPENCOR_PYTHON_UNIT_TESTING_DOCSTRING}")
set(LIBOPENCOR_PYTHON_UNIT_TESTING ${LIBOPENCOR_PYTHON_BINDINGS} CACHE BOOL "${LIBOPENCOR_PYTHON_UNIT_TESTING_DOCSTRING}")
endif()

if(NOT "${PYTHON_UNIT_TESTING}" STREQUAL "" AND PYTHON_UNIT_TESTING_AVAILABLE)
Expand Down
57 changes: 57 additions & 0 deletions cmake/base64encoder.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
Copyright libOpenCOR contributors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#include "../extern/modp_b64/modp_b64.h"

#include <filesystem>
#include <fstream>
#include <iostream>

int main(int pArgC, char *pArgV[])
{
// Convert the given file to a base64-encoded string.

if (pArgC != 2) {
std::cerr << "Usage: " << pArgV[0] << " <file>" << std::endl;

return 1;
}

std::uintmax_t fileSize = std::filesystem::file_size(pArgV[1]);
char *buffer = new char[fileSize];
std::ifstream file(pArgV[1], std::ios::binary);

file.read(buffer, fileSize);

if (!file) {
std::cerr << "Error: the file could not be read." << std::endl;

return 1;
}

file.close();

char *base64 = new char[modp_b64_encode_len(fileSize)];

modp_b64_encode(base64, buffer, fileSize);

std::cout << base64 << std::endl;

delete[] base64;
delete[] buffer;

return 0;
}
3 changes: 1 addition & 2 deletions cmake/clcachewrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ limitations under the License.

int main(int pArgC, char *pArgV[])
{
// Call clcache with the given arguments, except the first one, which is the
// full path to the MSVC compiler.
// Call clcache with the given arguments, except the first one, which is the full path to the MSVC compiler.

#define STRING_SIZE 32768

Expand Down
11 changes: 11 additions & 0 deletions cmake/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -386,14 +386,25 @@ endfunction()

function(prepare_test TARGET)
# Prepare the given test.
# Note: we don't want modp_b64.cc to be subjected to Clang-Tidy, hence we compile it separately. From Cmake 3.27,
# we could use the SKIP_LINTING property to exclude it from Clang-Tidy, but for some reasons it's not working,
# so we compile it separately (as suggested at https://stackoverflow.com/a/75858167).

add_executable(${TARGET}
${ARGN})

add_dependencies(${TARGET} ${CMAKE_PROJECT_NAME})

set(MODP_B64_TARGET ${TARGET}_modp_b64)

add_library(${MODP_B64_TARGET} OBJECT ${CMAKE_SOURCE_DIR}/extern/modp_b64/modp_b64.cc)

set_target_properties(${MODP_B64_TARGET} PROPERTIES
CXX_CLANG_TIDY "")

target_link_libraries(${TARGET} PRIVATE
gtest_main
${MODP_B64_TARGET}
${CMAKE_PROJECT_NAME})

configure_target(${TARGET})
Expand Down
6 changes: 3 additions & 3 deletions cmake/environmentchecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,12 @@ if(PYTHON_UNIT_TESTING_AVAILABLE AND PYTHON_EXE)
endif()
endif()

if( (APPLE AND LEAKS_EXE)
OR (NOT WIN32 AND PYTHON_EXE AND VALGRIND_EXE))
if( (APPLE AND PYTHON_EXE AND LEAKS_EXE)
OR (NOT APPLE AND NOT WIN32 AND PYTHON_EXE AND VALGRIND_EXE))
set(MEMORY_CHECKS_AVAILABLE TRUE)
else()
if(APPLE)
set(MEMORY_CHECKS_ERROR_MESSAGE "Memory checks are requested but the leaks tool could not be found.")
set(MEMORY_CHECKS_ERROR_MESSAGE "Memory checks are requested but Python and/or the leaks tool could not be found.")
else()
set(MEMORY_CHECKS_ERROR_MESSAGE "Memory checks are requested but Python and/or Valgrind could not be found.")
endif()
Expand Down
2 changes: 1 addition & 1 deletion cmake/packages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ function(retrieve_package PACKAGE_NAME PACKAGE_VERSION PACKAGE_REPOSITORY RELEAS
if("${PACKAGE_NAME}" STREQUAL "libCellML")
#---GRY--- THIS IS TEMPORARY UNTIL libCellML HAS AN OFFICIAL RELEASE WITH THE INTERPRETER.

set(PACKAGE_URL "https://github.com/agarny/${PACKAGE_REPOSITORY}/releases/download/584ebb5/${PACKAGE_FILE}")
set(PACKAGE_URL "https://github.com/agarny/${PACKAGE_REPOSITORY}/releases/download/707e211/${PACKAGE_FILE}")
endif()

file(DOWNLOAD ${PACKAGE_URL} ${REAL_PACKAGE_FILE} STATUS STATUS)
Expand Down
3 changes: 2 additions & 1 deletion extern/README.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
`libOpenCOR <https://opencor.ws/libopencor/index.html>`__ relies on the following external projects:

- `GoogleTest <https://github.com/google/googletest>`__ `1.15.2 <https://github.com/google/googletest/releases/tag/v1.15.2>`__; and
- `GoogleTest <https://github.com/google/googletest>`__ `1.15.2 <https://github.com/google/googletest/releases/tag/v1.15.2>`__;
- `modp_b64 <https://chromium.googlesource.com/chromium/src/third_party/modp_b64/>`__ at commit `7c1b327 <https://chromium.googlesource.com/chromium/src/third_party/modp_b64/+/7c1b3276e72757e854b5b642284aa367436a4723>`__; and
- `nanobind <https://github.com/wjakob/nanobind>`__ `2.1.0 <https://github.com/wjakob/nanobind/releases/tag/v2.1.0>`__.
11 changes: 11 additions & 0 deletions extern/modp_b64/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright 2013 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

static_library("modp_b64") {
sources = [
"modp_b64.cc",
"modp_b64.h",
"modp_b64_data.h",
]
}
3 changes: 3 additions & 0 deletions extern/modp_b64/DEPS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include_rules = [
'+build',
]
6 changes: 6 additions & 0 deletions extern/modp_b64/DIR_METADATA
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
monorail: {
component: "Internals"
}
buganizer_public: {
component_id: 1456292
}
33 changes: 33 additions & 0 deletions extern/modp_b64/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
* MODP_B64 - High performance base64 encoder/decoder
* Version 1.3 -- 17-Mar-2006
* http://modp.com/release/base64
*
* Copyright (c) 2005, 2006 Nick Galbreath -- nickg [at] modp [dot] com
* 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.
*
* Neither the name of the modp.com nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE 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
* OWNER 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.
1 change: 1 addition & 0 deletions extern/modp_b64/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pkasting@chromium.org
24 changes: 24 additions & 0 deletions extern/modp_b64/README.chromium
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Name: modp base64 decoder
Short Name: stringencoders
URL: https://github.com/client9/stringencoders
Version: 2.0.0
Revision: 26701a1c1fcb98ae43eefcaee23abc58459a6e59
License: BSD-3-Clause
License File: LICENSE
Security Critical: yes
Shipped: yes

Description:
The source code was modified from upstream as follows:
- Removed the inclusion of modp's config.h
- Fixed compilation errors that occur under VC8
- Renamed modp_b64.c to modp_b64.cc to force it to be compiled as C++ and so
the inclusion of basictypes.h could be possible
- Made code safe on 64-bit systems
- Removed misaligned read/writes on little-endian systems
- Removed unreachable code
- Extended the API so callers can avoid overload for base64 encode
- Removed big endian support entirely
- Removed std::string APIs
- Added multiple decoding options to support Blink callers
- Added modp_b64_encode_data which doesn't append a null terminator
Loading

0 comments on commit f7e1be2

Please sign in to comment.