Skip to content

Commit

Permalink
Implement a command-line interface.
Browse files Browse the repository at this point in the history
This commit adds a basic command-line interface. This interface
allows rendering thumbnails and exporting data in batch mode.
  • Loading branch information
whitequark committed Nov 29, 2016
1 parent dbc567e commit 47244c5
Show file tree
Hide file tree
Showing 11 changed files with 420 additions and 85 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ New rendering features:
* The "Show/hide outlines" button is now independent from "Show/hide edges".

Other new features:
* New command-line interface, for batch exporting and more.
* New command for measuring total length of selected entities,
"Analyze → Measure Perimeter".
* New link to match the on-screen size of the sketch with its actual size,
Expand Down
18 changes: 6 additions & 12 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,22 @@ before_build:
- cmake -G"Visual Studio 12" -T v120 ..
build_script:
- msbuild "src\solvespace.vcxproj" /verbosity:minimal /property:Configuration=%BUILD_TYPE% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
- msbuild "test\solvespace_testsuite.vcxproj" /verbosity:minimal /property:Configuration=%BUILD_TYPE% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
- msbuild "src\solvespace-cli.vcxproj" /verbosity:minimal /property:Configuration=%BUILD_TYPE% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
- msbuild "test\solvespace-testsuite.vcxproj" /verbosity:minimal /property:Configuration=%BUILD_TYPE% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
test_script:
- bin\%BUILD_TYPE%\solvespace_testsuite.exe
- bin\%BUILD_TYPE%\solvespace-testsuite.exe
artifacts:
- path: build\bin\%BUILD_TYPE%\solvespace.exe
name: solvespace.exe
- path: build\bin\%BUILD_TYPE%\solvespace-cli.exe
name: solvespace-cli.exe
- path: build\bin\%BUILD_TYPE%\solvespace.pdb
name: solvespace.pdb
deploy:
# Releases to solvespace/solvespace
- provider: GitHub
auth_token:
secure: P9/pf2nM+jlWKe7pCjMp41HycBNP/+5AsmE/TETrDUoBOa/9WFHelqdVFrbRn9IC
description: ""
artifact: solvespace.exe
on:
appveyor_repo_tag: true
# Releases to whitequark/solvespace (to be removed)
- provider: GitHub
auth_token:
secure: Flqxu1cz6PyxVT1wzTP4bSrQOY8wFrO7pJxYxvjEkLqIUU4dsDQrs2rac/A9deet
description: ""
artifact: solvespace.exe
artifact: solvespace.exe,solvespace-cli.exe,solvespace.pdb
on:
appveyor_repo_tag: true
9 changes: 5 additions & 4 deletions bench/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ foreach(pkg_config_lib CAIRO)
link_directories(${${pkg_config_lib}_LIBRARY_DIRS})
endforeach()

add_executable(solvespace_benchmark
add_executable(solvespace-benchmark
harness.cpp
$<TARGET_PROPERTY:resources,EXTRA_SOURCES>)

target_link_libraries(solvespace_benchmark
solvespace_headless)
target_link_libraries(solvespace-benchmark
solvespace-core
solvespace-headless)

add_dependencies(solvespace_benchmark
add_dependencies(solvespace-benchmark
resources)
126 changes: 75 additions & 51 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ endif()

# solvespace library

set(solvespace_cad_HEADERS
set(solvespace_core_HEADERS
config.h
dsc.h
expr.h
Expand All @@ -139,7 +139,7 @@ set(solvespace_cad_HEADERS
render/gl2shader.h
srf/surface.h)

set(solvespace_cad_SOURCES
set(solvespace_core_SOURCES
bsp.cpp
clipboard.cpp
confscreen.cpp
Expand Down Expand Up @@ -186,100 +186,124 @@ set(solvespace_cad_SOURCES
srf/surfinter.cpp
srf/triangulate.cpp)

set(solvespace_cad_gl_SOURCES
set(solvespace_core_gl_SOURCES
export.cpp
solvespace.cpp)

add_library(solvespace_cad STATIC
add_library(solvespace-core STATIC
${util_SOURCES}
${solvespace_cad_HEADERS}
${solvespace_cad_SOURCES})
${solvespace_core_HEADERS}
${solvespace_core_SOURCES})

target_link_libraries(solvespace_cad
target_link_libraries(solvespace-core
dxfrw
${util_LIBRARIES}
${ZLIB_LIBRARY}
${PNG_LIBRARY}
${FREETYPE_LIBRARY}
${Backtrace_LIBRARIES})

target_compile_options(solvespace_cad
target_compile_options(solvespace-core
PRIVATE ${COVERAGE_FLAGS})

# solvespace gui executable
# solvespace graphical executable

add_executable(solvespace WIN32 MACOSX_BUNDLE
${solvespace_cad_gl_SOURCES}
${solvespace_core_gl_SOURCES}
${platform_SOURCES}
$<TARGET_PROPERTY:resources,EXTRA_SOURCES>)

add_dependencies(solvespace
resources)

target_link_libraries(solvespace
solvespace_cad
solvespace-core
${OPENGL_LIBRARIES}
${platform_LIBRARIES}
${COVERAGE_LIBRARY})

if(WIN32 AND NOT MINGW)
if(MSVC)
set_target_properties(solvespace PROPERTIES
LINK_FLAGS "/MANIFEST:NO /SAFESEH:NO")
endif()

# solvespace headless library

set(headless_SOURCES
platform/headless.cpp
render/rendercairo.cpp)

add_library(solvespace-headless STATIC EXCLUDE_FROM_ALL
${solvespace_core_gl_SOURCES}
${headless_SOURCES})

target_compile_definitions(solvespace-headless
PRIVATE -DHEADLESS)

target_include_directories(solvespace-headless
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})

target_link_libraries(solvespace-headless
solvespace-core
${CAIRO_LIBRARIES})

target_compile_options(solvespace-headless
PRIVATE ${COVERAGE_FLAGS})

# solvespace command-line executable

add_executable(solvespace-cli
platform/climain.cpp
$<TARGET_PROPERTY:resources,EXTRA_SOURCES>)

target_link_libraries(solvespace-cli
solvespace-core
solvespace-headless)

add_dependencies(solvespace-cli
resources)

# solvespace unix package

if(NOT (WIN32 OR APPLE))
install(TARGETS solvespace solvespace-cli
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()

# solvespace macOS package

if(APPLE)
set(bundle solvespace)
set(bundle_bin ${EXECUTABLE_OUTPUT_PATH}/${bundle}.app/Contents/MacOS)

add_custom_command(TARGET solvespace POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:solvespace-cli> ${bundle_bin}
COMMENT "Bundling executable solvespace-cli"
VERBATIM)

foreach(lib ${platform_BUNDLED_LIBS})
get_filename_component(name ${lib} NAME)
set(target ${CMAKE_CURRENT_BINARY_DIR}/solvespace.app/Contents/MacOS/${name})

execute_process(COMMAND otool -D ${lib}
OUTPUT_VARIABLE canonical_lib OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX REPLACE "^.+:\n" "" canonical_lib ${canonical_lib})
add_custom_command(TARGET solvespace POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${lib} ${target}
add_custom_command(TARGET ${bundle} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${lib} ${bundle_bin}/${name}
COMMAND install_name_tool -change ${canonical_lib} @executable_path/${name}
$<TARGET_FILE:${bundle}>
COMMAND install_name_tool -change ${canonical_lib} @executable_path/${name}
$<TARGET_FILE:solvespace>
$<TARGET_FILE:solvespace-cli>
COMMENT "Bundling shared library ${lib}"
VERBATIM)
endforeach()

set(bundle solvespace)
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${bundle}.dmg
COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/${bundle}.dmg
COMMAND hdiutil create -srcfolder ${CMAKE_CURRENT_BINARY_DIR}/${bundle}.app
${CMAKE_BINARY_DIR}/${bundle}.dmg
add_custom_command(OUTPUT ${EXECUTABLE_OUTPUT_PATH}/${bundle}.dmg
COMMAND ${CMAKE_COMMAND} -E remove ${EXECUTABLE_OUTPUT_PATH}/${bundle}.dmg
COMMAND hdiutil create -srcfolder ${EXECUTABLE_OUTPUT_PATH}/${bundle}.app
${EXECUTABLE_OUTPUT_PATH}/${bundle}.dmg
DEPENDS $<TARGET_FILE:${bundle}>
COMMENT "Building ${bundle}.dmg"
VERBATIM)
add_custom_target(${bundle}-dmg ALL
DEPENDS ${CMAKE_BINARY_DIR}/${bundle}.dmg)
endif()

if(NOT WIN32)
install(TARGETS solvespace
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
BUNDLE DESTINATION .)
DEPENDS ${EXECUTABLE_OUTPUT_PATH}/${bundle}.dmg)
endif()

# solvespace headless library

set(headless_SOURCES
platform/headless.cpp
render/rendercairo.cpp)

add_library(solvespace_headless STATIC EXCLUDE_FROM_ALL
${solvespace_cad_gl_SOURCES}
${headless_SOURCES})

target_compile_definitions(solvespace_headless
PRIVATE -DHEADLESS)

target_include_directories(solvespace_headless
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})

target_link_libraries(solvespace_headless
solvespace_cad
${CAIRO_LIBRARIES})

target_compile_options(solvespace_headless
PRIVATE ${COVERAGE_FLAGS})

0 comments on commit 47244c5

Please sign in to comment.