Skip to content

Commit

Permalink
Refactors build scripts and ensures the generated cpp is compiled int…
Browse files Browse the repository at this point in the history
…o object files (#333)
  • Loading branch information
StephenNneji authored Feb 7, 2025
1 parent d42337d commit f963317
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 75 deletions.
6 changes: 3 additions & 3 deletions buildScript.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
% Go to the correct compile directory
compilePath = fullfile(thisPath,'compile','reflectivityCalculation');
cd(compilePath);
reflectivityCalculationCompileScript
reflectivityCalculationMexBuild;

compilePath = fullfile(thisPath,'compile','fullCompile');
cd(compilePath);
ratMainCompileScript;
ratMainMexBuild;
ratMainCodeGen;

compilePath = fullfile(thisPath,'compile','customWrapper');
cd(compilePath);
wrapperCompileScript;
wrapperMexBuild;

% Return to RAT root directory
cd(thisPath);
1 change: 1 addition & 0 deletions compile/customWrapper/classHandle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ template<class base> class ClassHandle
class CallbackInterface
{
public:
virtual ~CallbackInterface() = default;
virtual void invoke(std::vector<double>& params, std::vector<double>& bulk_in, std::vector<double>& bulk_out,
int contrast, std::vector<double>& tempOutput, double *outputSize, double *roughness)=0;
virtual void invoke(std::vector<double>& params, std::vector<double>& bulk_in, std::vector<double>& bulk_out,
Expand Down
File renamed without changes.
23 changes: 9 additions & 14 deletions compile/fullCompile/ratMainCodeGen.m
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
% RATMAin_COMPILE_SCRIPT Generate MEX-function
% RATMain_mex from RATMain.
% ratMAinCodeGen
%
% Generates CPP source code from RATMain and builds object code.

%
% See also CODER, CODER.CONFIG, CODER.TYPEOF, CODEGEN.

%% Deal with globals
global DEBUG
DEBUG = 0;

%% Create configuration object of class 'coder.MexCodeConfig'.
% Create configuration object of class 'coder.CodeConfig'.
cfg = coder.config('lib');
cfg.GenerateReport = true;
cfg.ReportPotentialDifferences = false;
cfg.GenCodeOnly = true;
cfg.GenCodeOnly = false;
cfg.InlineBetweenUserFunctions = 'Readability';
cfg.InlineBetweenMathWorksFunctions = 'Readability';
cfg.InlineBetweenUserAndMathWorksFunctions = 'Readability';
Expand All @@ -24,12 +18,13 @@
cfg.RunInitializeFcn = false;
cfg.DataTypeReplacement = 'CoderTypeDefs';

%% Define the input argument types..
% Define the input argument types..
ARGS = makeCompileArgsFull();

%% Run the compile
% Run the compile
includeDirs = getappdata(0,'includeDirs');
includes = cell(length(includeDirs)*2, 1);
includes(1:2:end) = {'-I'};
includes(2:2:end) = includeDirs;
codegen('RATMain', '-config', cfg, '-args', ARGS{1}, includes{:});

codegen('RATMain', '-globals', '{"DEBUG", 0}', '-config', cfg, '-args', ARGS{1}, includes{:});
27 changes: 0 additions & 27 deletions compile/fullCompile/ratMainCompileScript.m

This file was deleted.

20 changes: 20 additions & 0 deletions compile/fullCompile/ratMainMexBuild.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
% ratMainMexBuild
%
% Generates MEX-function (RATMain_mex) from RATMain.

% Create configuration object of class 'coder.MexCodeConfig'.
cfg = coder.config('mex');
cfg.GenerateReport = true;
cfg.EnableJIT = false;
cfg.EnableOpenMP = true;
cfg.TargetLang = 'C++';

% Define the input argument types..
ARGS = makeCompileArgsFull();

% Run the compile
includeDirs = getappdata(0,'includeDirs');
includes = cell(length(includeDirs)*2, 1);
includes(1:2:end) = {'-I'};
includes(2:2:end) = includeDirs;
codegen('RATMain', '-globals', '{"DEBUG", 0}', '-config', cfg, '-args', ARGS{1}, includes{:});
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
% REFLECTIVITY_CALCULATION_CODEONLY_SCRIPT Generate static library
% reflectivityCalculation from reflectivityCalculation.
% reflectivityCalculationCodeGen
%
% Script generated from project 'reflectivityCalculation.prj' on 07-Jul-2021.
%
% See also CODER, CODER.CONFIG, CODER.TYPEOF, CODEGEN.
% Generates C++ source code from reflectivityCalculation.

%% Create configuration object of class 'coder.CodeConfig'.
% Create configuration object of class 'coder.CodeConfig'.
cfg = coder.config('lib');
cfg.GenerateReport = true;
cfg.ReportPotentialDifferences = false;
Expand All @@ -17,14 +14,13 @@
cfg.PreserveVariableNames = 'UserNames';
cfg.CppNamespace = 'RAT';
cfg.PreserveArrayDimensions = true;
%cfg.MATLABSourceComments = true;
cfg.CodeFormattingTool = 'MathWorks';
cfg.RunInitializeFcn = false;
cfg.DataTypeReplacement = 'CoderTypeDefs';

ARGS = makeCompileArgs();

%% Invoke MATLAB Coder.
% Invoke MATLAB Coder.
includeDirs = getappdata(0,'includeDirs');
includes = cell(length(includeDirs)*2, 1);
includes(1:2:end) = {'-I'};
Expand Down

This file was deleted.

19 changes: 19 additions & 0 deletions compile/reflectivityCalculation/reflectivityCalculationMexBuild.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
% reflectivityCalculationMexBuild
%
% Generates MEX-function (reflectivityCalculation_mex) from reflectivityCalculation.

% Create configuration object of class 'coder.MexCodeConfig'.
cfg = coder.config('mex');
cfg.GenerateReport = true;
cfg.EnableJIT = false;
cfg.EnableOpenMP = true;
cfg.TargetLang = 'C++';

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

includeDirs = getappdata(0,'includeDirs');
includes = cell(length(includeDirs)*2, 1);
includes(1:2:end) = {'-I'};
includes(2:2:end) = includeDirs;
codegen('reflectivityCalculation', '-config', cfg, '-args', ARGS{1}, includes{:});

0 comments on commit f963317

Please sign in to comment.