Skip to content

Commit ec2fa4a

Browse files
committed
Revamp the build system
1 parent bc65f6d commit ec2fa4a

File tree

5 files changed

+91
-29
lines changed

5 files changed

+91
-29
lines changed

.github/workflows/runTests.yml

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,51 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
jobs:
14-
test:
14+
build_cpp:
15+
runs-on: Linux
16+
steps:
17+
- name: Checkout RAT
18+
uses: actions/checkout@v4
19+
- name: Generate CPP
20+
uses: matlab-actions/run-command@v2
21+
with:
22+
command: addPaths; generateCpps;
23+
- name: Upload cppDeploy
24+
uses: actions/upload-artifact@v4
25+
with:
26+
name: cppDeploy
27+
retention-days: 1
28+
path: compile/fullCompile/cppDeploy/
29+
- name: Upload cppDeploy
30+
uses: actions/upload-artifact@v4
31+
with:
32+
name: codegen
33+
retention-days: 1
34+
path: compile/fullCompile/codegen/
35+
36+
build_and_test_mex:
1537
strategy:
1638
matrix:
17-
platform: [Windows, Linux, macOS]
39+
platform: [windows-latest, ubuntu-latest, macos-15-intel, macos-latest]
1840
runs-on: ${{ matrix.platform }}
1941

2042
steps:
2143
- name: Checkout RAT
2244
uses: actions/checkout@v4
23-
- name: Build Mex
24-
uses: matlab-actions/run-command@v2
45+
- name: Download Mex CPP
46+
uses: actions/download-artifact@v4
47+
with:
48+
name: codgen
49+
path: compile/fullCompile/codegen/
50+
- name: Set up MATLAB
51+
uses: matlab-actions/setup-matlab@v2
2552
with:
26-
command: buildScript
27-
- name: Run tests
53+
release: R2023a
54+
products: Parallel_Computing_Toolbox
55+
- name: Build Mex and Run Tests
2856
uses: matlab-actions/run-command@v2
2957
with:
30-
command: testScript
58+
command: addPaths; generateMexFromCpp; testScript
3159
- name: Create build archive (Windows and macOS)
3260
if: runner.os != 'Linux'
3361
run: tar --exclude="**/-lang:c++.zip" --exclude=".git*/" --exclude="htmlcov/" -acvf ../${{ runner.os }}.zip *
@@ -41,18 +69,6 @@ jobs:
4169
name: ${{ runner.os }}
4270
retention-days: 1
4371
path: ${{ runner.os }}.zip
44-
- name: Create cppDeploy
45-
if: runner.os == 'Linux'
46-
uses: matlab-actions/run-command@v2
47-
with:
48-
command: cppDeploy
49-
- name: Upload cppDeploy
50-
if: runner.os == 'Linux'
51-
uses: actions/upload-artifact@v4
52-
with:
53-
name: cppDeploy
54-
retention-days: 1
55-
path: compile/fullCompile/cppDeploy/
5672

5773
deploy-nightly:
5874
if: github.ref == 'refs/heads/master'
@@ -96,4 +112,4 @@ jobs:
96112
git config user.email [email protected]
97113
git add -A
98114
git commit -m "Deploy Source Code" || true
99-
git push
115+
git push

buildScript.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
pwd;
21
addPaths;
2+
root = getappdata(0,'root');
33

44
% Save this path
55
thisPath = pwd;
66

77
% Go to the correct compile directory
8-
compilePath = fullfile(thisPath,'compile','reflectivityCalculation');
8+
compilePath = fullfile(root,'compile','reflectivityCalculation');
99
cd(compilePath);
1010
reflectivityCalculationMexBuild;
1111

12-
compilePath = fullfile(thisPath,'compile','fullCompile');
12+
compilePath = fullfile(root,'compile','fullCompile');
1313
cd(compilePath);
1414
ratMainMexBuild;
1515
ratMainCodeGen;
1616

17-
compilePath = fullfile(thisPath,'compile','customWrapper');
17+
compilePath = fullfile(root,'compile','customWrapper');
1818
cd(compilePath);
1919
wrapperMexBuild;
2020

compile/fullCompile/generateCpps.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
% Save this path
2+
thisPath = pwd;
3+
4+
[compilePath, ~, ~] = fileparts(mfilename("fullpath"));
5+
6+
cd(compilePath);
7+
ratMainMexBuild;
8+
ratMainCodeGen;
9+
cppDeploy;
10+
11+
% Return to initial directory
12+
cd(thisPath);
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
root = getappdata(0,'root');
2+
mex_path = [fullfile(root, 'compile', 'fullCompile', 'codegen', 'mex', 'RATMain'), filesep];
3+
mex_interface_path = [fullfile(mex_path, 'interface'), filesep];
4+
5+
includeDirs = getappdata(0,'includeDirs');
6+
includes = strcat(repmat({'-I'}, 1, length(includeDirs)), includeDirs);
7+
includes{end+1} = ['-I', mex_path];
8+
includes{end+1} = ['-I', fullfile(mex_path, 'interface')];
9+
10+
sources = {dir([mex_path, '*.cpp']).name};
11+
sources = strcat(repmat({mex_path}, 1, length(sources)), sources);
12+
sources{end+1} = [mex_interface_path, '_coder_RATMain_api.cpp'];
13+
sources{end+1} = [mex_interface_path, '_coder_RATMain_info.cpp'];
14+
15+
main_file = [mex_interface_path, '_coder_RATMain_mex.cpp'];
16+
if ismac
17+
if strcmp(computer('arch'), 'maci64')
18+
ompLib = {['-L', fullfile(matlabroot, 'sys', 'os', 'maci64')], '-liomp5'};
19+
else
20+
ompLib = {['-L', fullfile(matlabroot, 'toolbox', 'eml', 'externalDependency', 'omp', 'maca64', 'lib')], '-lomp'};
21+
end
22+
includes{end+1} = ['-I', fullfile(matlabroot, 'toolbox', 'eml', 'externalDependency', 'omp', computer('arch'), 'include')];
23+
mex(includes{:}, 'CXXFLAGS=$CXXFLAGS -fPIC -Xpreprocessor -fopenmp -fvisibility=default -ffp-contract=off -std=c++11 -stdlib=libc++', main_file, sources{:}, '-output', 'RATMain_mex', '-v', '-lemlrt', '-lmwmathutil', '-lmwblas', '-lmwlapack', ompLib{:})
24+
elseif isunix
25+
mex(includes{:}, 'CXXFLAGS=$CXXFLAGS -fopenmp -fvisibility=default -std=c++11', main_file, sources{:}, '-output', 'RATMain_mex', '-v', '-lemlrt', '-lmwmathutil', '-lmwblas', '-lmwlapack', ['-L"', matlabroot, '/sys/os/glnxa64"'], '-liomp5')
26+
else
27+
mex(includes{:}, 'COMPFLAGS=$COMPFLAGS /openmp -DHAVE_LAPACK_CONFIG_H -DLAPACK_COMPLEX_STRUCTURE -DMW_HAVE_LAPACK_DECLS -DMW_NEEDS_VERSION_H', main_file, sources{:}, '-output', 'RATMain_mex', '-v', '-llibemlrt', '-llibmwmathutil', '-lmwblas', '-lmwlapack')
28+
end
29+
30+
% Build custom file wrapper
31+
thisPath = pwd;
32+
cd(fullfile(root,'compile','customWrapper'));
33+
wrapperMexBuild;
34+
cd(thisPath);

compile/reflectivityCalculation/reflectivityCalculationMexBuild.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
% Generates MEX-function (reflectivityCalculation_mex) from reflectivityCalculation.
44

55
% Create configuration object of class 'coder.MexCodeConfig'.
6-
cfg = coder.config('mex');
7-
cfg.GenerateReport = true;
8-
cfg.EnableJIT = false;
9-
cfg.EnableOpenMP = true;
10-
cfg.TargetLang = 'C++';
6+
% cfg = coder.config('mex');
7+
% cfg.GenerateReport = true;
8+
% cfg.EnableJIT = false;
9+
% cfg.EnableOpenMP = true;
10+
% cfg.TargetLang = 'C++';
1111

1212
% Define the input argument types..
1313
ARGS = makeCompileArgs();

0 commit comments

Comments
 (0)