Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions CMakeLists.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ add_compile_definitions(F_CPU=16000000)

%build_flags%

# Capture the effective build-time flags for the -v/--version output.
string(TOUPPER "${CMAKE_BUILD_TYPE}" _sim_build_type)
if(_sim_build_type STREQUAL "")
set(SIM_BUILD_TYPE "None")
else()
set(SIM_BUILD_TYPE "${CMAKE_BUILD_TYPE}")
endif()
string(STRIP "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${_sim_build_type}}" SIM_C_FLAGS)
configure_file(
${CMAKE_CURRENT_LIST_DIR}/../src/build_info.h.in
${CMAKE_CURRENT_BINARY_DIR}/build_info.h
@ONLY
)

include(../src/grbl/CMakeLists.txt)

if (WIN32)
Expand Down Expand Up @@ -53,13 +67,16 @@ add_executable(grblHAL_sim
${platform_SRC}
)

target_link_libraries(grblHAL_sim PRIVATE
target_link_libraries(grblHAL_sim PRIVATE
m
grbl
${platform_LIB}
)

add_executable(grblHAL_validator
# Generated build_info.h lands in the build dir.
target_include_directories(grblHAL_sim PRIVATE ${CMAKE_CURRENT_BINARY_DIR})

add_executable(grblHAL_validator
../src/eeprom.c
../src/grbl_eeprom_extensions.c
../src/validator.c
Expand Down
21 changes: 19 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ project(grblHAL-sim C)
add_compile_definitions(F_CPU=16000000)
#add_compile_definitions(SQUARING_ENABLED=1)

# Capture the effective build-time flags for the -v/--version output.
string(TOUPPER "${CMAKE_BUILD_TYPE}" _sim_build_type)
if(_sim_build_type STREQUAL "")
set(SIM_BUILD_TYPE "None")
else()
set(SIM_BUILD_TYPE "${CMAKE_BUILD_TYPE}")
endif()
string(STRIP "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${_sim_build_type}}" SIM_C_FLAGS)
configure_file(
${CMAKE_CURRENT_LIST_DIR}/src/build_info.h.in
${CMAKE_CURRENT_BINARY_DIR}/build_info.h
@ONLY
)

include(src/grbl/CMakeLists.txt)

if (WIN32)
Expand Down Expand Up @@ -51,13 +65,16 @@ add_executable(grblHAL_sim
${platform_SRC}
)

target_link_libraries(grblHAL_sim PRIVATE
target_link_libraries(grblHAL_sim PRIVATE
m
grbl
${platform_LIB}
)

add_executable(grblHAL_validator
# Generated build_info.h lands in the build dir.
target_include_directories(grblHAL_sim PRIVATE ${CMAKE_CURRENT_BINARY_DIR})

add_executable(grblHAL_validator
src/eeprom.c
src/grbl_eeprom_extensions.c
src/validator.c
Expand Down
10 changes: 10 additions & 0 deletions src/build_info.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* Generated by CMake from build_info.h.in - do not edit directly. */
#ifndef _BUILD_INFO_H_
#define _BUILD_INFO_H_

#define SIM_BUILD_TYPE "@SIM_BUILD_TYPE@"
#define SIM_C_FLAGS "@SIM_C_FLAGS@"
#define SIM_COMPILER "@CMAKE_C_COMPILER_ID@ @CMAKE_C_COMPILER_VERSION@"
#define SIM_TARGET "@CMAKE_SYSTEM_NAME@ @CMAKE_SYSTEM_PROCESSOR@"

#endif
26 changes: 26 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "simulator.h"
#include "eeprom.h"
#include "grbl_interface.h"
#include "build_info.h"

#include "grbl/grbllib.h"

Expand Down Expand Up @@ -70,6 +71,7 @@ void print_usage(const char* badarg)
" -p <port> : port to open raw telnet communication.\n"
" -c<comment_char> : character to print before each line from grbl. default = '#'\n"
" -n : no comments before grbl response lines.\n"
" -v : print version and build information.\n"
" -h : this help.\n"
"\n"
" <time_step> and <block_file> can be specifed with option flags or positional parameters\n"
Expand All @@ -79,6 +81,21 @@ void print_usage(const char* badarg)
progname);
}

void print_version(void)
{
printf("grblHAL simulator\n"
" Build type : %s\n"
" Compiler : %s\n"
" Target : %s\n"
" C flags : %s\n"
" Built : %s %s\n",
SIM_BUILD_TYPE,
SIM_COMPILER,
SIM_TARGET,
SIM_C_FLAGS[0] ? SIM_C_FLAGS : "(none)",
__DATE__, __TIME__);
}

//wrapper for thread interface
PLAT_THREAD_FUNC(grbl_main_thread, exit)
{
Expand Down Expand Up @@ -199,6 +216,11 @@ int main(int argc, char *argv[])
argv++; argc--;
if (argv[0][0] == '-') {

if (!strcmp(argv[0], "--version")) {
print_version();
return EXIT_SUCCESS;
}

switch(argv[0][1]){

case 'c': //set Comment char
Expand Down Expand Up @@ -259,6 +281,10 @@ int main(int argc, char *argv[])
args.port = atoi(*argv);
break;

case 'v':
print_version();
return EXIT_SUCCESS;

case 'h':
print_usage(NULL);
return EXIT_SUCCESS;
Expand Down
Loading