Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install cmake on startup #66

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f09d1dd
Added old implementation of automatic cmake install
maxarfvidssonnilsson Nov 1, 2021
8333cc3
Revert "Added old implementation of automatic cmake install"
maxarfvidssonnilsson Nov 2, 2021
cc4c5cd
temp
maxarfvidssonnilsson Nov 2, 2021
ccf0f6b
Added http request node to entry.tscn
maxarfvidssonnilsson Nov 3, 2021
58764fe
Changed implementation for new Is cmake available method
maxarfvidssonnilsson Nov 4, 2021
46fe398
Revert "Changed implementation for new Is cmake available method"
maxarfvidssonnilsson Nov 8, 2021
f3ebb67
Revert "Added http request node to entry.tscn"
maxarfvidssonnilsson Nov 8, 2021
3f5f853
Revert "temp"
maxarfvidssonnilsson Nov 8, 2021
92464cb
added auto copy for libSMCE.dll file
maxarfvidssonnilsson Nov 8, 2021
cbd43f2
Merge branch 'Adding-automatic-copying-for-libsmce.dll' into Install-…
maxarfvidssonnilsson Nov 8, 2021
8be00de
re-added the old solution since it might actually work after all
maxarfvidssonnilsson Nov 8, 2021
0760414
Added missing header
maxarfvidssonnilsson Nov 10, 2021
d5cd016
[CMake] Implement AUTO linkage for libSMCE + minor cleanups
AeroStun Nov 26, 2021
83041ae
Show list of compilers in frontend while using fake data.
tim-gr Nov 18, 2021
f8d0f69
Save compiler selection (right now with index in list)
tim-gr Nov 18, 2021
6415deb
Update Repository information
tim-gr Nov 27, 2021
d8a7793
Try out upstream libSMCE.
tim-gr Nov 28, 2021
bc3fbf3
Use task10 backend from source (GitHub-Repository)
tim-gr Nov 29, 2021
a54aa4c
Load actual backend data
tim-gr Nov 29, 2021
6ac20aa
Merge branch 'task10frontend' into Install-cmake-on-startup
maxarfvidssonnilsson Nov 30, 2021
a4cbb0e
Revert "Merge branch 'task10frontend' into Install-cmake-on-startup"
maxarfvidssonnilsson Nov 30, 2021
de5b615
copied over setupfile from task10 branch
maxarfvidssonnilsson Nov 30, 2021
abca734
copied over changes to CMakeLists from task10 branch
maxarfvidssonnilsson Nov 30, 2021
2057f8a
switched backend version
maxarfvidssonnilsson Nov 30, 2021
39e8f19
Bug fix
maxarfvidssonnilsson Dec 2, 2021
2c5d65f
Temp commit with recent work
maxarfvidssonnilsson Dec 2, 2021
80d2504
added custom download path that adapts to different operating systems
maxarfvidssonnilsson Dec 4, 2021
54c6aff
Cleaned up the prints and added back cmake check.
maxarfvidssonnilsson Dec 4, 2021
9534717
fixed issue where return value from check_cmake_availability() would …
maxarfvidssonnilsson Dec 4, 2021
8d79597
godot crashed so I commit just in case
maxarfvidssonnilsson Dec 5, 2021
b2e5fd2
safty push.
maxarfvidssonnilsson Dec 6, 2021
698c381
fixed two bugs
maxarfvidssonnilsson Jan 4, 2022
c902038
removed old comments and prints.
maxarfvidssonnilsson Jan 4, 2022
b950395
removed git history file
maxarfvidssonnilsson Jan 6, 2022
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
75 changes: 75 additions & 0 deletions CMake/Modules/setupSMCE.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#
# SetupSMCE.cmake
# Copyright 2021 ItJustWorksTM
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

include_guard ()

set (SMCEGD_SMCE_LINKING "SOURCE")

if (SMCEGD_SMCE_LINKING STREQUAL "AUTO")
find_package (SMCE 1.4)
if (SMCE_FOUND)
if (TARGET SMCE::SMCE)
set (SMCEGD_SMCE_LINKING "SHARED")
elseif (TARGET SMCE::SMCE_static)
set (SMCEGD_SMCE_LINKING "STATIC")
endif ()
else ()
set (SMCEGD_SMCE_LINKING "SOURCE")
endif ()
message (STATUS "Resolved SMCEGD_SMCE_LINKING: AUTO -> ${SMCEGD_SMCE_LINKING}")
endif ()

if (SMCEGD_SMCE_LINKING STREQUAL "SHARED")
find_package (SMCE 1.4 REQUIRED)
if (NOT TARGET SMCE::SMCE)
message (FATAL_ERROR "Shared link requested but libSMCE shared library not installed")
endif ()
add_library (smcegd_SMCE ALIAS SMCE::SMCE)
elseif (SMCEGD_SMCE_LINKING STREQUAL "STATIC")
find_package (SMCE 1.4 REQUIRED)
if (NOT TARGET SMCE::SMCE_static)
message (FATAL_ERROR "Static link requested but libSMCE static library not installed")
endif ()
add_library (smcegd_SMCE ALIAS SMCE::SMCE_static)
elseif (SMCEGD_SMCE_LINKING STREQUAL "SOURCE")
include (FetchContent)
FetchContent_Declare (libsmce
#GIT_REPOSITORY "https://github.com/ItJustWorksTM/libSMCE"
#GIT_TAG master
GIT_REPOSITORY "https://github.com/Team-3-Software-Evolution-Project/libSMCE"
GIT_TAG Add-cmake-check
GIT_SHALLOW On
)
FetchContent_GetProperties (libsmce)
if (NOT libsmce_POPULATED)
FetchContent_Populate (libsmce)

file (READ "${libsmce_SOURCE_DIR}/CMakeLists.txt" libsmce_cmakelists)
string (REPLACE "add_dependencies (SMCE ArdRtRes)" "add_dependencies (SMCE_static ArdRtRes)" libsmce_cmakelists "${libsmce_cmakelists}")
file (WRITE "${libsmce_SOURCE_DIR}/CMakeLists.txt" "${libsmce_cmakelists}")
file (APPEND "${libsmce_SOURCE_DIR}/CMakeLists.txt" "set (SMCE_RESOURCES_ARK \"\${SMCE_RESOURCES_ARK}\" CACHE INTERNAL \"\")\n")

set (SMCE_BUILD_SHARED Off CACHE INTERNAL "")
set (SMCE_BUILD_STATIC On CACHE INTERNAL "")
set (SMCE_CXXRT_LINKING "${SMCEGD_CXXRT_LINKING}" CACHE INTERNAL "" FORCE)
set (SMCE_BOOST_LINKING "SOURCE" CACHE INTERNAL "")
add_subdirectory ("${libsmce_SOURCE_DIR}" "${libsmce_BINARY_DIR}" EXCLUDE_FROM_ALL)
endif ()
add_library (smcegd_SMCE ALIAS SMCE_static)
else ()
message (FATAL_ERROR "SMCEGD_SMCE_LINKING: Unknown final link mode ${SMCEGD_SMCE_LINKING}")
endif ()
40 changes: 17 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

cmake_minimum_required (VERSION 3.17)

set (SMCEGD_SMCE_LINKING "SOURCE")

project (godot-smce VERSION 1.3.2 LANGUAGES CXX)
list (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMake/Modules")
include (UserConfigVars)
Expand All @@ -35,18 +37,6 @@ set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (CMAKE_CXX_EXTENSIONS OFF)
set (CMAKE_POSITION_INDEPENDENT_CODE ON)

find_package (Threads REQUIRED)
find_package (SMCE 1.4 REQUIRED)

set (SMCE_TARGET SMCE::SMCE)
if (SMCEGD_SMCE_LINKING STREQUAL "STATIC")
if (NOT TARGET SMCE::SMCE_static)
message (FATAL_ERROR "Static link requested but libSMCE static library not installed")
endif ()
set (SMCE_TARGET SMCE::SMCE_static)
message (STATUS "libSMCE statically linked")
endif ()

if (APPLE)
set (CMAKE_BUILD_RPATH "@loader_path/../Frameworks;${CMAKE_BUILD_RPATH}")
set (CMAKE_INSTALL_RPATH "@loader_path/../Frameworks;${CMAKE_INSTALL_RPATH}")
Expand All @@ -56,7 +46,12 @@ include (CheckIPOSupported)
check_ipo_supported (RESULT CMAKE_IPO_SUPPORTED LANGUAGES CXX)
set (CMAKE_INTERPROCEDURAL_OPTIMIZATION ${CMAKE_IPO_SUPPORTED})

include (FetchContent)
find_package (Threads REQUIRED)
include (SetupSMCE)
if (SMCEGD_BUNDLE_DEPS AND NOT SMCEGD_SMCE_LINKING STREQUAL "SHARED")
message (FATAL_ERROR "SMCEGD_BUNDLE_DEPS may only be set to True when SMCEGD_SMCE_LINKING resolves to \"SHARED\"")
endif ()

list (APPEND GDCPP_NEEDED_CLASSES Reference Node Resource _ResourceLoader)
include (SetupGodotCpp)

Expand All @@ -70,10 +65,10 @@ target_sources (godot-smce PRIVATE
src/bind/UartSlurper.cxx
src/bind/BoardConfig.cxx
src/bind/FrameBuffer.cxx
)
)

target_include_directories (godot-smce PUBLIC include)
target_link_libraries (godot-smce PUBLIC godot-cpp ${SMCE_TARGET})
target_link_libraries (godot-smce PUBLIC godot-cpp smcegd_SMCE)

if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set_target_properties (godot-smce PROPERTIES LINK_FLAGS_RELEASE -s)
Expand All @@ -82,18 +77,17 @@ if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
endif ()
endif ()

get_target_property (SMCE_RT_RES SMCE::SMCE RESOURCES_ARCHIVE)

file (MAKE_DIRECTORY "${PROJECT_SOURCE_DIR}/project/gdnative/lib/RtResources")
add_custom_command (TARGET godot-smce POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy "$<TARGET_FILE:godot-smce>" "${PROJECT_SOURCE_DIR}/project/gdnative/lib/"
COMMAND "${CMAKE_COMMAND}" -E tar xf "${SMCE_RT_RES}"
COMMAND "${CMAKE_COMMAND}" -E tar xf "${SMCE_RESOURCES_ARK}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_FILE:smcegd_SMCE>" "${PROJECT_SOURCE_DIR}/project/gdnative/lib/"
COMMAND "${CMAKE_COMMAND}" -E copy_directory "./RtResources" "${PROJECT_SOURCE_DIR}/project/share/RtResources"
COMMAND "${CMAKE_COMMAND}" -E rm -rf "./RtResources"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
)
)

include(GNUInstallDirs)
include (GNUInstallDirs)

if (NOT GODOT_DEBUG)
set (GODOT_BUILD_TYPE "GodotRelease")
Expand All @@ -117,7 +111,7 @@ endif ()
file (REMOVE_RECURSE "${PROJECT_BINARY_DIR}/export")
file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/export")

if (SMCEGD_BUNDLE_DEPS)
if (SMCEGD_BUNDLE_DEPS AND SMCEGD_SMCE_LINKING STREQUAL "SHARED")
if (UNIX AND NOT APPLE)
set (SMCE_DYLIB_VER_SUFFIX ".1")
elseif (APPLE)
Expand All @@ -126,8 +120,8 @@ if (SMCEGD_BUNDLE_DEPS)

set (SMCE_DYNLIB_FILE "$<TARGET_FILE_DIR:godot-smce>/${CMAKE_SHARED_LIBRARY_PREFIX}SMCE${SMCE_DYLIB_VER_PRESUFFIX}${CMAKE_SHARED_LIBRARY_SUFFIX}${SMCE_DYLIB_VER_SUFFIX}")
add_custom_command (TARGET godot-smce POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_FILE:SMCE::SMCE>" "${SMCE_DYNLIB_FILE}"
)
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_FILE:SMCE::SMCE>" "${SMCE_DYNLIB_FILE}"
)
endif ()

install (CODE "find_program (GODOT_EXECUTABLE NAMES godot3-headless godot-headless godot3-server godot-server godot3 godot REQUIRED)")
Expand Down
1 change: 1 addition & 0 deletions include/bind/Toolchain.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class Toolchain : public Node {
String resource_dir();
String cmake_path();
Ref<GDResult> check_suitable_environment();
Ref<GDResult> check_cmake_availability();
String get_log();

bool is_building() { return building; }
Expand Down
71 changes: 69 additions & 2 deletions project/Entry.gd
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export var main_scene: PackedScene = null
onready var _header: Label = $Header
onready var _log: RichTextLabel = $Log
onready var _button: Button = $Button
onready var _request: HTTPRequest = $HTTPRequest

var error: String = ""

Expand Down Expand Up @@ -49,7 +50,6 @@ func _ready():
print("Executable: %s" % exec_path)
print("Mode: %s" % "Debug" if OS.is_debug_build() else "Release")
print("User dir: %s" % Global.user_dir)
print()

var dir = Directory.new()

Expand All @@ -70,6 +70,10 @@ func _ready():
var bar = Toolchain.new()
if ! is_instance_valid(bar):
return _error("Shared library not loaded")

var cmake_exec = yield(_download_cmake(), "completed")
if ! cmake_exec:
return _error("Failed to retrieve cmake")

var res = bar.init(Global.user_dir)
if ! res.ok():
Expand All @@ -81,7 +85,7 @@ func _ready():

# somehow destroys res://
ModManager.load_mods()

_continue()

func _continue():
Expand All @@ -103,3 +107,66 @@ func _error(message: String) -> void:

func _on_clipboard_copy() -> void:
OS.clipboard = error
var cmakeVersion = "3.19.6"
var osi = {
"X11": ["cmake-%s-Linux-x86_64.tar.gz"%cmakeVersion, "cmake-%s-Linux-x86_64.tar"%cmakeVersion, "/bin/cmake"],
"OSX": ["cmake-%s-macos-universal.tar.gz"%cmakeVersion, "cmake-%s-macos-universal.tar"%cmakeVersion, "/CMake.app/Contents/bin/cmake"], # people using < macos 10.13 will have more problems anyways
"Windows": ["cmake-%s-win32-x86.zip"%cmakeVersion, "cmake-%s-win32-x86"%cmakeVersion, "/bin/cmake.exe"]
}


func _download_cmake():
yield(get_tree(), "idle_frame")
var toolchain = Toolchain.new()
toolchain.init(Global.user_dir)
print("Looking for CMake...")
if !toolchain.check_cmake_availability().ok():
toolchain.free()
print("CMake not found")

# If you want to promt the user with a window asking if they want to
# install cmake it could be added here. As it is now cmake will be installed
# without asking the user for permission.

print("Downloading CMake...")

var da = osi.get(OS.get_name())
var file: String = da[0]
var file_path = OS.get_user_data_dir() + ("\\%s" % file)

_request.download_file = file_path + ".download"
var url: String = "https://github.com/Kitware/CMake/releases/download/v%s/%s" % [cmakeVersion, file]
var res = _request.request(url)
var dir = Directory.new()
if ! res:
var ret = yield(_request, "request_completed")
dir.copy(_request.download_file, file_path)
dir.remove(_request.download_file)
print("CMake Downloaded")
else:
print("Download Failed")
return null
print("Installing CMake...")

var cmake_installation_path: String = Global.usr_dir_plus("RtResources")
if ! Util.unzip(Util.user2abs(file_path), cmake_installation_path):
print("unzip failed")
return null
dir.remove(file_path)
dir.open(cmake_installation_path)
dir.rename (da[1], "CMake")

var cmake_exec = cmake_installation_path + "/CMake" + da[2]
var cmake_ver = []
var cmake_res = OS.execute(cmake_exec, ["--version"], true, cmake_ver)
if cmake_res != 0:
print("Installation Failed") # maybe not propper to say installation failed here. Maybe replace with: "something went wrong"?
return false

print("--\n%s--" % cmake_ver.front())
print("CMake Installed")
return cmake_exec
else:
print("CMake Found")
toolchain.free()
return true
3 changes: 3 additions & 0 deletions project/Entry.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,6 @@ text = "Copy to clipboard"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="HTTPRequest" type="HTTPRequest" parent="."]
use_threads = true
Binary file added project/media/models/tereno/Montaᅢᄆa.material
Binary file not shown.
22 changes: 11 additions & 11 deletions project/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://src/attachments/AnalogRaycast.gd"
}, {
"base": "Reference",
"base": "",
"class": "AnyTask",
"language": "NativeScript",
"path": "res://src/bind/AnyTask.gdns"
}, {
"base": "Reference",
"base": "ButtonGroup",
"class": "BButtonGroup",
"language": "GDScript",
"path": "res://src/utilities/toggleable_bgroup/BButtonGroup.gd"
}, {
"base": "Node",
"base": "",
"class": "Board",
"language": "NativeScript",
"path": "res://src/bind/Board.gdns"
Expand Down Expand Up @@ -54,17 +54,17 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://src/utilities/control_util/ControlUtil.gd"
}, {
"base": "Reference",
"base": "",
"class": "FrameBufferConfig",
"language": "NativeScript",
"path": "res://src/bind/FrameBufferConfig.gdns"
}, {
"base": "Reference",
"base": "",
"class": "GDResult",
"language": "NativeScript",
"path": "res://src/bind/GDResult.gdns"
}, {
"base": "Reference",
"base": "",
"class": "GpioDriverConfig",
"language": "NativeScript",
"path": "res://src/bind/GpioDriverConfig.gdns"
Expand Down Expand Up @@ -104,7 +104,7 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://src/bind/SMCE.gd"
}, {
"base": "Reference",
"base": "",
"class": "SecureDigitalStorage",
"language": "NativeScript",
"path": "res://src/bind/SecureDigitalStorage.gdns"
Expand All @@ -124,7 +124,7 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://src/ui/simple_notification/SimpleNotification.gd"
}, {
"base": "Reference",
"base": "",
"class": "Sketch",
"language": "NativeScript",
"path": "res://src/bind/Sketch.gdns"
Expand All @@ -144,12 +144,12 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://src/ui/temp_tween/TempTween.gd"
}, {
"base": "Node",
"base": "",
"class": "Toolchain",
"language": "NativeScript",
"path": "res://src/bind/Toolchain.gdns"
}, {
"base": "Reference",
"base": "",
"class": "UartChannelConfig",
"language": "NativeScript",
"path": "res://src/bind/UartChannelConfig.gdns"
Expand Down Expand Up @@ -329,7 +329,6 @@ file_logging/enable_file_logging=true
[rendering]

threads/thread_model=2
quality/filters/anisotropic_filter_level=2
quality/directional_shadow/size=2048
quality/shadow_atlas/size=2048
quality/shadow_atlas/quadrant_3_subdiv=3
Expand All @@ -338,6 +337,7 @@ quality/reflections/texture_array_reflections=false
quality/reflections/high_quality_ggx=false
quality/reflections/irradiance_max_size=32
quality/shading/force_blinn_over_ggx=true
quality/filters/anisotropic_filter_level=2
quality/subsurface_scattering/quality=0
quality/reflections/atlas_size=0
quality/reflections/atlas_subdiv=16
Expand Down
Loading