Skip to content

Commit b577921

Browse files
committed
use docker to test ubuntu builds
1 parent 242d1d3 commit b577921

22 files changed

+447
-233
lines changed

CMakeLists.txt

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.12)
22
project(ComputerAlgebraSystem
3-
VERSION 0.0.1
3+
VERSION 0.1.0
44
DESCRIPTION "A computer algebra system"
55
LANGUAGES CXX)
66

@@ -9,22 +9,27 @@ set(CMAKE_CXX_EXTENSIONS OFF)
99
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1010
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
1111

12-
include(FetchContent)
13-
1412
if (CMAKE_BUILD_TYPE MATCHES Debug)
15-
add_compile_options(
16-
-Wall
17-
-Wextra
18-
-fsanitize=address
19-
-fsanitize=undefined
20-
)
21-
add_link_options(
22-
-fsanitize=address
23-
-fsanitize=undefined
24-
)
13+
if (MSVC)
14+
message(STATUS "MSVC debug build.")
15+
add_compile_options(/W4 /WX)
16+
else()
17+
message(STATUS "GCC/Clang debug build.")
18+
add_compile_options(-Wall -Wextra)
19+
endif()
20+
21+
# Enable ASAN and UBSAN
22+
if (MSVC)
23+
add_compile_options(/fsanitize=address,undefined)
24+
add_link_options(/fsanitize=address,undefined)
25+
else()
26+
add_compile_options(-fsanitize=address,undefined -fno-omit-frame-pointer)
27+
add_link_options(-fsanitize=address,undefined -fno-omit-frame-pointer)
28+
endif()
2529
endif()
2630

2731
add_subdirectory("cas")
32+
include(FetchContent)
2833

2934
FetchContent_Declare(glfw
3035
GIT_REPOSITORY https://github.com/glfw/glfw
@@ -50,6 +55,7 @@ if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
5055
src/render/metal/Window.h
5156
src/render/metal/Grid.h
5257
src/render/metal/Surface.h
58+
src/render/metal/Model.h
5359
src/render/metal/shader.metal
5460
${imgui_SOURCE_DIR}/imgui.cpp
5561
${imgui_SOURCE_DIR}/imgui_demo.cpp
@@ -65,6 +71,7 @@ if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
6571
"-framework Cocoa"
6672
"-framework MetalKit"
6773
"-framework ModelIO")
74+
6875
elseif (CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Windows")
6976
message(STATUS "Windows or Linux OS detected - Using OpenGL for graphics")
7077
set(MAIN_FILE "src/render/opengl/main.cpp")
@@ -75,4 +82,4 @@ elseif (CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Windows"
7582
endif()
7683

7784
add_executable(${PROJECT_NAME} ${MAIN_FILE} ${HEADERS_AMD_SOURCES})
78-
target_link_libraries(${PROJECT_NAME} PRIVATE "cas" ${LINK_LIBS})
85+
target_link_libraries(${PROJECT_NAME} PRIVATE "cas" ${LINK_LIBS})

Dockerfile-Ubuntu

Lines changed: 0 additions & 22 deletions
This file was deleted.

Dockerfile-Windows

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Used to test Windows builds
22

3-
FROM mcr.microsoft.com/windows/servercore:ltsc2019
3+
FROM mcr.microsoft.com/dotnet/sdk:5.0
44

55
# Install MinGW
66
RUN powershell -Command \
@@ -24,3 +24,17 @@ COPY . /cas-mingw
2424
# Build project
2525
WORKDIR /cas-mingw
2626
RUN .\build.bat
27+
28+
# Run debug tests
29+
#WORKDIR /cas-mingw/build-debug/cas
30+
#RUN ctest
31+
32+
# Run release tests
33+
#WORKDIR /cas-mingw/build-release/cas
34+
#RUN ctest'
35+
36+
# Run executable
37+
WORKDIR /cas-mingw/build-debug
38+
CMD [".\ComputerAlgebraSystem.exe"]
39+
40+

benchmark.sh

Lines changed: 0 additions & 10 deletions
This file was deleted.
File renamed without changes.

cas/include/cas/CAS.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#define CAS_NAMESPACE namespace cas {
99
#define CAS_NAMESPACE_END }
1010

11-
#include "cas/data/VariableMap.h"
1211
#include <cmath>
1312
#include <cstddef>
1413
#include <unordered_set>

cas/include/cas/data/VariableMap.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
// Created by Abd-El-Aziz Zayed on 2022-12-30.
33
//
44

5-
#ifndef VARIABLEMAP_H
6-
#define VARIABLEMAP_H
7-
5+
#ifndef CAS_VARIABLEMAP_H
6+
#define CAS_VARIABLEMAP_H
87

98
#include <cas/CAS.h>
109
#include <iterator>
1110
#include <stdexcept>
11+
#include <vector>
1212

1313
CAS_NAMESPACE
1414

@@ -55,6 +55,8 @@ class VariableMap {
5555
VariableMap& operator=(const VariableMap&) = delete;
5656

5757
void clear();
58+
void clear(char var);
59+
void clearExceptXY();
5860

5961
[[nodiscard]] bool contains(char var) const;
6062

@@ -63,6 +65,8 @@ class VariableMap {
6365
double& operator[](char var);
6466
double at(char var) const;
6567

68+
size_t size() const;
69+
6670
VariableMapIterator begin();
6771
VariableMapIterator end();
6872

@@ -74,6 +78,7 @@ class VariableMap {
7478

7579
private:
7680
static std::invalid_argument variableNotFoundException(char var);
81+
static std::invalid_argument invalidVariableException(char var);
7782

7883
static bool lowercase(char c, size_t& index);
7984
static bool uppercase(char c, size_t& index);
@@ -88,4 +93,4 @@ class VariableMap {
8893

8994
CAS_NAMESPACE_END
9095

91-
#endif//VARIABLEMAP_H
96+
#endif//CAS_VARIABLEMAP_H

cas/include/cas/latex/LatexRenderer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#define CAS_LATEXRENDERER_H
77

88
#include "cas/node/IRepresentableMath.h"
9-
#import "cas/plot/Function.h"
9+
#include "cas/plot/Function.h"
1010
#include "cpr/cpr.h"
1111

1212
CAS_NAMESPACE

cas/include/cas/node/IMath.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
#ifndef CAS_IMATH_H
66
#define CAS_IMATH_H
77

8-
#include "cas/CAS.h"
98
#include <cmath>
9+
#include "cas/CAS.h"
10+
#include "cas/data/VariableMap.h"
1011

1112
CAS_NAMESPACE
1213

cas/src/core/data/VariableMap.cpp

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include <sstream>
77
#include <string>
88
#include <utility>
9-
#include <vector>
109

1110
CAS_NAMESPACE
1211

@@ -31,7 +30,7 @@ void VariableMap::insert(char var, double value) {
3130
uppercaseVariables.letters++;
3231
}
3332
} else {
34-
throw std::invalid_argument("Variable is not a letter.");
33+
throw invalidVariableException(var);
3534
}
3635
}
3736

@@ -48,7 +47,7 @@ double& VariableMap::operator[](char var) {
4847
}
4948
throw variableNotFoundException(var);
5049
}
51-
throw std::invalid_argument("Variable is not a letter.");
50+
throw invalidVariableException(var);
5251
}
5352

5453
double VariableMap::at(char var) const {
@@ -64,7 +63,7 @@ double VariableMap::at(char var) const {
6463
}
6564
throw variableNotFoundException(var);
6665
}
67-
throw std::invalid_argument("Variable is not a letter.");
66+
throw invalidVariableException(var);
6867
}
6968

7069
VariableMapIterator VariableMap::begin() {
@@ -136,14 +135,45 @@ bool VariableMap::contains(char var) const {
136135
} else if (uppercase(var, index)) {
137136
return uppercaseVariables.validLetter[index];
138137
}
139-
throw variableNotFoundException(var);
138+
throw invalidVariableException(var);
140139
}
141140

142141
void VariableMap::clear() {
143142
lowercaseVariables = {};
144143
uppercaseVariables = {};
145144
}
146145

146+
void VariableMap::clear(char var) {
147+
size_t index = 0;
148+
if (lowercase(var, index)) {
149+
if (lowercaseVariables.validLetter[index]) {
150+
lowercaseVariables.validLetter[index] = false;
151+
lowercaseVariables.letters--;
152+
}
153+
} else if (uppercase(var, index)) {
154+
if (uppercaseVariables.validLetter[index]) {
155+
uppercaseVariables.validLetter[index] = false;
156+
uppercaseVariables.letters--;
157+
}
158+
} else {
159+
throw invalidVariableException(var);
160+
}
161+
}
162+
163+
void VariableMap::clearExceptXY() {
164+
double x = at('x');
165+
double y = at('y');
166+
167+
clear();
168+
169+
insert('x', x);
170+
insert('y', y);
171+
}
172+
173+
size_t VariableMap::size() const {
174+
return lowercaseVariables.letters + uppercaseVariables.letters;
175+
}
176+
147177
std::string VariableMap::str() const {
148178
std::stringstream ss;
149179

@@ -160,6 +190,10 @@ std::invalid_argument VariableMap::variableNotFoundException(char var) {
160190
return std::invalid_argument("Variable " + std::string(1, var) + " is not in the map.");
161191
}
162192

193+
std::invalid_argument VariableMap::invalidVariableException(char var) {
194+
return std::invalid_argument("Variable " + std::string(1, var) + " is not a letter.");
195+
}
196+
163197
bool VariableMap::lowercase(char c, size_t& index) {
164198
bool isLowercase = c >= 'a' && c <= 'z';
165199

0 commit comments

Comments
 (0)