Skip to content

Commit fafe713

Browse files
committed
Break batch analysis CMake/pre-processor variable up into GUI and CLI components since we may want to use one but not the other
1 parent f6b8180 commit fafe713

File tree

17 files changed

+77
-66
lines changed

17 files changed

+77
-66
lines changed

CMakeLists.txt

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.1...3.20 FATAL_ERROR)
1+
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
22

33
project(InterSpec VERSION 1.0.14)
44

@@ -139,14 +139,15 @@ if(BUILD_FOR_WEB_DEPLOYMENT)
139139
set(PERFORM_DEVELOPER_CHECKS OFF CACHE INTERNAL "")
140140
set(SpecUtils_ENABLE_EQUALITY_CHECKS OFF CACHE INTERNAL "")
141141
set(USE_SPECRUM_FILE_QUERY_WIDGET OFF)
142-
set(USE_BATCH_TOOLS OFF)
143142
endif(BUILD_FOR_WEB_DEPLOYMENT)
144143

145144

146145
if( IOS OR ANDROID OR BUILD_FOR_WEB_DEPLOYMENT )
147-
set( USE_BATCH_TOOLS OFF CACHE INTERNAL "")
148-
else( )
149-
option( USE_BATCH_TOOLS "Enables (command line for now) batch processing." ON )
146+
set(USE_BATCH_CLI_TOOLS OFF CACHE INTERNAL "")
147+
set(USE_BATCH_GUI_TOOLS OFF CACHE INTERNAL "")
148+
else()
149+
option( USE_BATCH_CLI_TOOLS "Enables command line batch processing." ON )
150+
option( USE_BATCH_GUI_TOOLS "Enables GUI batch processing." ON )
150151
endif()
151152

152153
if(MSVC)
@@ -171,11 +172,13 @@ set(MAX_SPECTRUM_MEMMORY_SIZE_MB 256
171172
# If we are creating the normal InterSpec executable, and the InterSpec_batch executable,
172173
# we will compile LibInterSpec as a shared library, so both exes can use it; otherwise
173174
# we will create a static library, and statically link it into our final executable.
174-
# (Electron doesnt need a separate exe for batch)
175-
if( ((USE_BATCH_TOOLS AND NOT BUILD_AS_ELECTRON_APP) OR BUILD_AS_OSX_APP) AND NOT BUILD_AS_UNIT_TEST_SUITE )
175+
# (Electron doesnt need a separate exe for batch, and we dont care abour disk space for unit tests)
176+
if( USE_BATCH_CLI_TOOLS AND NOT BUILD_AS_ELECTRON_APP AND NOT BUILD_AS_UNIT_TEST_SUITE )
176177
set( INTERSPEC_LIB_TYPE SHARED )
178+
set( BUILD_LibInterSpec_SHARED ON )
177179
else()
178180
set( INTERSPEC_LIB_TYPE STATIC )
181+
set( BUILD_LibInterSpec_SHARED OFF )
179182
endif()
180183

181184

@@ -590,21 +593,25 @@ if( USE_REL_ACT_TOOL )
590593
endif( USE_REL_ACT_TOOL )
591594

592595

593-
if( USE_BATCH_TOOLS )
596+
if( USE_BATCH_CLI_TOOLS )
597+
list( APPEND sources src/BatchCommandLine.cpp )
598+
list( APPEND headers InterSpec/BatchCommandLine.h )
599+
endif( USE_BATCH_CLI_TOOLS )
600+
601+
602+
if( USE_BATCH_GUI_TOOLS )
594603
list( APPEND sources
595-
src/BatchCommandLine.cpp
596604
src/BatchGuiWidget.cpp
597605
src/BatchGuiAnaWidget.cpp
598606
src/BatchGuiInputFile.cpp
599607
)
600608

601609
list( APPEND headers
602-
InterSpec/BatchCommandLine.h
603610
InterSpec/BatchGuiWidget.h
604611
InterSpec/BatchGuiAnaWidget.h
605612
InterSpec/BatchGuiInputFile.h
606613
)
607-
endif( USE_BATCH_TOOLS )
614+
endif( USE_BATCH_GUI_TOOLS )
608615

609616
if( (NOT IOS) AND (NOT ANDROID) AND (NOT BUILD_FOR_WEB_DEPLOYMENT) )
610617
list( APPEND sources src/DirectorySelector.cpp )
@@ -736,13 +743,13 @@ if(WIN32)
736743
target_compile_definitions( InterSpecLib PRIVATE InterSpec_EXPORTS )
737744
add_definitions( /bigobj )
738745

739-
if( USE_BATCH_TOOLS )
746+
if( INTERSPEC_LIB_TYPE STREQUAL "SHARED" )
740747
# We get error compiling multi-processor debug build of shared LibInterSpec, presumably due to some
741748
# file locking issues, so only enable parallel builds for release, if we are building shared LibInterSpec
742749
target_compile_options( InterSpecLib PUBLIC $<$<CONFIG:Release>:/MP> )
743-
else( USE_BATCH_TOOLS )
750+
else()
744751
add_definitions( /MP )
745-
endif( USE_BATCH_TOOLS )
752+
endif()
746753
endif(WIN32)
747754

748755
target_link_libraries(
@@ -856,7 +863,7 @@ if( BUILD_AS_OSX_APP )
856863
${FOUNDATION_LIBRARY}
857864
)
858865

859-
if( USE_BATCH_TOOLS )
866+
if( INTERSPEC_LIB_TYPE STREQUAL "SHARED" )
860867
set_target_properties( InterSpecLib PROPERTIES
861868
FRAMEWORK TRUE
862869
FRAMEWORK_VERSION A
@@ -875,7 +882,7 @@ if( BUILD_AS_OSX_APP )
875882
set_target_properties( InterSpecLib PROPERTIES
876883
PUBLIC_HEADER "InterSpec_config.h"
877884
)
878-
endif( USE_BATCH_TOOLS )
885+
endif( INTERSPEC_LIB_TYPE STREQUAL "SHARED" )
879886
endif( BUILD_AS_OSX_APP )
880887

881888

InterSpec/AppUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ namespace AppUtils
7070
/** Sanatizes a string so it can be a CSS class name. */
7171
//std::string sanitize_css_class_name( const std::string &src_name );
7272

73-
#if( USE_BATCH_TOOLS || BUILD_AS_LOCAL_SERVER || BUILD_FOR_WEB_DEPLOYMENT )
73+
#if( USE_BATCH_CLI_TOOLS || BUILD_AS_LOCAL_SERVER || BUILD_FOR_WEB_DEPLOYMENT )
7474
/** Returns the terminal character width */
7575
InterSpec_API unsigned terminal_width();
7676
#endif

InterSpec/InterSpec_config.h.in

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#cmakedefine01 BUILD_AS_ELECTRON_APP
2929
#cmakedefine01 BUILD_AS_WX_WIDGETS_APP
3030
#cmakedefine01 BUILD_FOR_WEB_DEPLOYMENT
31+
#cmakedefine01 BUILD_LibInterSpec_SHARED
3132

3233
#cmakedefine01 PERFORM_DEVELOPER_CHECKS
3334
#cmakedefine01 USE_OSX_NATIVE_MENU
@@ -52,7 +53,8 @@
5253
#cmakedefine01 USE_DETECTION_LIMIT_TOOL
5354
#cmakedefine01 USE_QR_CODES
5455
#cmakedefine01 USE_REMOTE_RID
55-
#cmakedefine01 USE_BATCH_TOOLS
56+
#cmakedefine01 USE_BATCH_CLI_TOOLS
57+
#cmakedefine01 USE_BATCH_GUI_TOOLS
5658
#cmakedefine01 USE_LLM_INTERFACE
5759
// TODO: figure out stuff behind enabling/requiring MCP authorization a little better.
5860
#define MCP_ENABLE_AUTH 1
@@ -110,10 +112,10 @@ void log_developer_error( const char *location, const char *error );
110112

111113
#define InterSpec_PHONE_ROTATE_FOR_TABS 1
112114

113-
// On Windows, we will compile LibInterSpec as a shared DLL only when
114-
// `USE_BATCH_TOOLS` is enabled - so in this case we need to export the functions
115+
// On Windows, we will compile LibInterSpec as a shared DLL when building for
116+
// command-line batch tools - so in this case we need to export the functions
115117
// we will want to use from the DLL.
116-
#if( (USE_BATCH_TOOLS && !BUILD_AS_ELECTRON_APP) && (defined(WIN32) || defined(UNDER_CE) || defined(_WIN32) || defined(WIN64)) )
118+
#if( BUILD_LibInterSpec_SHARED && (defined(WIN32) || defined(UNDER_CE) || defined(_WIN32) || defined(WIN64)) )
117119
#ifdef InterSpec_EXPORTS
118120
#define InterSpec_API __declspec(dllexport)
119121
#else

InterSpec/SpecMeasManager.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ class SpecMeasManager : public Wt::WObject
391391
FileDragUploadResource *foregroundDragNDrop();
392392
FileDragUploadResource *secondForegroundDragNDrop();
393393
FileDragUploadResource *backgroundDragNDrop();
394-
#if( USE_BATCH_TOOLS )
394+
#if( USE_BATCH_GUI_TOOLS )
395395
FileDragUploadResource *batchDragNDrop();
396396
#endif
397397

@@ -438,7 +438,7 @@ class SpecMeasManager : public Wt::WObject
438438
SimpleDialog *dialog,
439439
Wt::WApplication *app );
440440

441-
#if( USE_BATCH_TOOLS )
441+
#if( USE_BATCH_GUI_TOOLS )
442442
void showBatchDialog();
443443
void handleBatchDialogFinished();
444444
#endif
@@ -525,7 +525,7 @@ class SpecMeasManager : public Wt::WObject
525525
FileDragUploadResource *m_foregroundDragNDrop;
526526
FileDragUploadResource *m_secondForegroundDragNDrop;
527527
FileDragUploadResource *m_backgroundDragNDrop;
528-
#if( USE_BATCH_TOOLS )
528+
#if( USE_BATCH_GUI_TOOLS )
529529
FileDragUploadResource *m_batchDragNDrop;
530530
#endif
531531

@@ -559,7 +559,7 @@ class SpecMeasManager : public Wt::WObject
559559
/** Dialog created when a non-spectrum file is dropped on the app. */
560560
SimpleDialog *m_nonSpecFileDialog;
561561

562-
#if( USE_BATCH_TOOLS )
562+
#if( USE_BATCH_GUI_TOOLS )
563563
/** Dialog created when a batch of files is dropped on the app. */
564564
BatchGuiDialog *m_batchDialog;
565565
#endif

main.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#include "InterSpec/InterSpec.h"
4444
#include "InterSpec/InterSpecServer.h"
4545

46-
#if( USE_BATCH_TOOLS )
46+
#if( USE_BATCH_CLI_TOOLS )
4747
#include "InterSpec/BatchCommandLine.h"
4848
#endif
4949

@@ -70,7 +70,7 @@ int main( int argc, char **argv )
7070
int server_port_num;
7171
std::string docroot, wt_config, user_data_dir;
7272

73-
#if( USE_BATCH_TOOLS )
73+
#if( USE_BATCH_CLI_TOOLS )
7474
bool batch_peak_fit = false, batch_act_fit = false;
7575
#endif
7676

@@ -115,7 +115,7 @@ int main( int argc, char **argv )
115115
("static-data-dir", "The static data directory (e.g., 'data' dir that holds cross-sections, "
116116
"nuclear-data, etc) to use. If not specified, uses 'data' in the `docroot` directory."
117117
)
118-
#if( USE_BATCH_TOOLS )
118+
#if( USE_BATCH_CLI_TOOLS )
119119
("batch-peak-fit", po::value<bool>(&batch_peak_fit)->implicit_value(true)->default_value(false),
120120
"Batch-fit peaks.\n"
121121
"\tUse '--batch-peak-fit --help' to see available options."
@@ -132,7 +132,7 @@ int main( int argc, char **argv )
132132
{
133133
po::parsed_options parsed_opts
134134
= po::command_line_parser(argc,argv)
135-
#if( USE_BATCH_TOOLS )
135+
#if( USE_BATCH_CLI_TOOLS )
136136
.allow_unregistered()
137137
#endif
138138
.options(cl_desc)
@@ -148,7 +148,7 @@ int main( int argc, char **argv )
148148
}//try catch
149149

150150

151-
#if( USE_BATCH_TOOLS )
151+
#if( USE_BATCH_CLI_TOOLS )
152152
const bool is_batch = (batch_peak_fit || batch_act_fit);
153153
#else
154154
const bool is_batch = false;
@@ -313,7 +313,7 @@ int main( int argc, char **argv )
313313
//return RelActAutoDev::dev_code();
314314
#endif
315315

316-
#if( USE_BATCH_TOOLS )
316+
#if( USE_BATCH_CLI_TOOLS )
317317
if( is_batch )
318318
return BatchCommandLine::run_batch_command( argc, argv );
319319
#endif

src/AppUtils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ namespace AppUtils
230230
}//string sanitize_css_class_name( const string &src_name )
231231
*/
232232

233-
#if( USE_BATCH_TOOLS || BUILD_AS_LOCAL_SERVER || BUILD_FOR_WEB_DEPLOYMENT )
233+
#if( USE_BATCH_CLI_TOOLS || BUILD_AS_LOCAL_SERVER || BUILD_FOR_WEB_DEPLOYMENT )
234234
#if defined(__APPLE__) || defined(unix) || defined(__unix) || defined(__unix__)
235235
unsigned terminal_width()
236236
{
@@ -256,7 +256,7 @@ unsigned terminal_width()
256256
#else
257257
static_assert( 0, "Not unix and not win32? Unsupported getting terminal width" );
258258
#endif
259-
#endif //#if( USE_BATCH_TOOLS || BUILD_AS_LOCAL_SERVER )
259+
#endif //#if( USE_BATCH_CLI_TOOLS || BUILD_AS_LOCAL_SERVER )
260260

261261

262262
uint32_t compile_date_as_int()

src/InterSpec.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1691,7 +1691,7 @@ void InterSpec::initDragNDrop()
16911691
doJavaScript( "$('.Wt-domRoot').data('SecondUpUrl','" +
16921692
m_fileManager->secondForegroundDragNDrop()->url() + "');" );
16931693

1694-
#if( USE_BATCH_TOOLS )
1694+
#if( USE_BATCH_GUI_TOOLS )
16951695
doJavaScript( "$('.Wt-domRoot').data('BatchUploadEnabled', true);" );
16961696
doJavaScript( "$('.Wt-domRoot').data('BatchUpUrl','" +
16971697
m_fileManager->batchDragNDrop()->url() + "');" );

src/SpecMeasManager.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
#include "InterSpec/QRSpectrum.h"
155155
#endif
156156

157-
#if( USE_BATCH_TOOLS )
157+
#if( USE_BATCH_GUI_TOOLS )
158158
#include "InterSpec/BatchGuiWidget.h"
159159
#endif
160160

@@ -1447,7 +1447,7 @@ SpecMeasManager::SpecMeasManager( InterSpec *viewer )
14471447
m_foregroundDragNDrop( new FileDragUploadResource(this) ),
14481448
m_secondForegroundDragNDrop( new FileDragUploadResource(this) ),
14491449
m_backgroundDragNDrop( new FileDragUploadResource(this) ),
1450-
#if( USE_BATCH_TOOLS )
1450+
#if( USE_BATCH_GUI_TOOLS )
14511451
m_batchDragNDrop( nullptr ),
14521452
#endif
14531453
m_multiUrlSpectrumDialog( nullptr ),
@@ -1456,7 +1456,7 @@ SpecMeasManager::SpecMeasManager( InterSpec *viewer )
14561456
m_previousStatesDialog( nullptr ),
14571457
m_processingUploadDialog( nullptr ),
14581458
m_nonSpecFileDialog( nullptr ),
1459-
#if( USE_BATCH_TOOLS )
1459+
#if( USE_BATCH_GUI_TOOLS )
14601460
m_batchDialog( nullptr ),
14611461
#endif
14621462
m_processingUploadTimer{}
@@ -1502,7 +1502,7 @@ SpecMeasManager::SpecMeasManager( InterSpec *viewer )
15021502
m_backgroundDragNDrop->dataReceived().connect( boost::bind( &SpecMeasManager::handleDataRecievedStatus, this,
15031503
boost::placeholders::_1, boost::placeholders::_2, SpectrumType::Background ) );
15041504

1505-
#if( USE_BATCH_TOOLS )
1505+
#if( USE_BATCH_GUI_TOOLS )
15061506
m_batchDragNDrop = new FileDragUploadResource( this );
15071507
m_batchDragNDrop->fileDrop().connect( this, &SpecMeasManager::showBatchDialog );
15081508
#endif
@@ -1661,7 +1661,7 @@ FileDragUploadResource *SpecMeasManager::backgroundDragNDrop()
16611661
return m_backgroundDragNDrop;
16621662
}
16631663

1664-
#if( USE_BATCH_TOOLS )
1664+
#if( USE_BATCH_GUI_TOOLS )
16651665
FileDragUploadResource *SpecMeasManager::batchDragNDrop()
16661666
{
16671667
return m_batchDragNDrop;
@@ -3809,7 +3809,7 @@ void SpecMeasManager::handleFileDrop( const std::string &name,
38093809
}//handleFileDrop(...)
38103810

38113811

3812-
#if( USE_BATCH_TOOLS )
3812+
#if( USE_BATCH_GUI_TOOLS )
38133813
void SpecMeasManager::showBatchDialog()
38143814
{
38153815
if( m_batchDialog )

target/batch/batch_main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#include "target/osx/macOsUtils.h"
4444
#endif
4545

46-
static_assert( USE_BATCH_TOOLS, "You must have USE_BATCH_TOOLS enabled to build this code" );
46+
static_assert( USE_BATCH_CLI_TOOLS, "You must have USE_BATCH_CLI_TOOLS enabled to build this code" );
4747

4848

4949
#ifdef _WIN32

target/docker/build_instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ apk update
5858
apk add --no-cache alpine-sdk cmake patch linux-headers suitesparse-dev patch curl uglify-js uglifycss git
5959

6060
# If you want to CMake Fetch to build the dependencies, you can:
61-
cmake -B ./build_alpine -DInterSpec_FETCH_DEPENDENCIES=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_FOR_WEB_DEPLOYMENT=ON -DUSE_REL_ACT_TOOL=ON -DBUILD_AS_LOCAL_SERVER=OFF -DBoost_INCLUDE_DIR=./build/_deps/boost-src/libs -DUSE_SEARCH_MODE_3D_CHART=ON -DUSE_QR_CODES=ON -DUSE_DETECTION_LIMIT_TOOL=ON -DUSE_BATCH_TOOLS=OFF -DCMAKE_EXE_LINKER_FLAGS="-static -static-libgcc -static-libstdc++" -DCMAKE_FIND_LIBRARY_SUFFIXES=".a" ./src/
61+
cmake -B ./build_alpine -DInterSpec_FETCH_DEPENDENCIES=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_FOR_WEB_DEPLOYMENT=ON -DUSE_REL_ACT_TOOL=ON -DBUILD_AS_LOCAL_SERVER=OFF -DBoost_INCLUDE_DIR=./build/_deps/boost-src/libs -DUSE_SEARCH_MODE_3D_CHART=ON -DUSE_QR_CODES=ON -DUSE_DETECTION_LIMIT_TOOL=ON -DUSE_BATCH_CLI_TOOLS=OFF -DUSE_BATCH_GUI_TOOLS=OFF -DCMAKE_EXE_LINKER_FLAGS="-static -static-libgcc -static-libstdc++" -DCMAKE_FIND_LIBRARY_SUFFIXES=".a" ./src/
6262

6363
# Or if you prefer, you can build a "prefix" you can use in later Docker sessions, via:
6464
#./target/patches/dep_build_linux.sh /work/src/ /tmp/ /work/src/alpine_prefix

0 commit comments

Comments
 (0)