-
Notifications
You must be signed in to change notification settings - Fork 1
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
[WIP] WASM #15
Draft
Raffaello
wants to merge
17
commits into
master
Choose a base branch
from
wasm
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
[WIP] WASM #15
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b0a0342
why is required to update the badge url? :finnadie:
Raffaello ad394ca
Merge branch 'master' of https://github.com/Raffaello/sdl2-vga-terminal
Raffaello 2d4f570
Codacy review (#10)
Raffaello 19823ac
review codacy unused var
Raffaello 244f0c8
review codacy unused var
Raffaello 07fd640
Cherry picks (#12)
Raffaello adea14b
renamed tests
Raffaello 3b6b780
shared/static build option
Raffaello fc9cf1a
reorganizing for shared and static lib (#13)
Raffaello a9a5137
fix r/b channel palette
Raffaello 81191a1
autoscroll flag
Raffaello 9e9e039
vgaterminal getMode method
Raffaello 7cc4cc4
code review
Raffaello a18d3e0
clean code
Raffaello c1ac525
autoscroll flag (#14)
Raffaello a88cec5
[WIP] draft, got stuck on rendering
Raffaello 9a6bf57
[wip] ???
Raffaello File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#/bin/bash | ||
|
||
### More as a reminder to build it. | ||
|
||
mkdir build | ||
cd build | ||
## emcc need to be in the path. (run source emcsdk_env.sh) | ||
emcc -std=c++17 ../sdl2-vga-terminal/examples/wasm.cpp ../sdl2-vga-terminal/src/Window.cpp ../sdl2-vga-terminal/src/VgaTerminal.cpp -I ../sdl2-vga-terminal/src/ -s USE_SDL=2 -o v.html | ||
python -m http.server 8080 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,112 @@ | ||
cmake_minimum_required (VERSION 3.8) | ||
|
||
set (CMAKE_CXX_STANDARD 17) | ||
set (CMAKE_C_STANDARD 11) | ||
set (CMAKE_DEBUG_POSTFIX d) | ||
|
||
find_package(SDL2 CONFIG REQUIRED) | ||
|
||
|
||
############################ Shared lib ###################################### | ||
include(GenerateExportHeader) | ||
add_library(vga-terminal-lib SHARED) | ||
add_library(vga-terminal SHARED) | ||
generate_export_header( | ||
vga-terminal-lib | ||
BASE_NAME vga-terminal-lib | ||
vga-terminal | ||
BASE_NAME vga-terminal | ||
EXPORT_MACRO_NAME VGA_TERMINAL_EXPORT | ||
EXPORT_FILE_NAME vga-terminal-export.h | ||
STATIC_DEFINE vga-terminal-lib_BUILD_AS_STATIC | ||
) | ||
install( | ||
TARGETS vga-terminal-lib | ||
EXPORT vga-terminal-lib-config | ||
TARGETS vga-terminal | ||
EXPORT vga-terminal-config | ||
DESTINATION lib | ||
PUBLIC_HEADER DESTINATION inc | ||
PUBLIC_HEADER DESTINATION include | ||
) | ||
install(FILES | ||
${CMAKE_CURRENT_SOURCE_DIR}/include/vga-terminal.h | ||
$<TARGET_FILE_DIR:vga-terminal-lib>/vga-terminal-export.h | ||
DESTINATION inc | ||
$<TARGET_FILE_DIR:vga-terminal>/vga-terminal-export.h | ||
DESTINATION include | ||
) | ||
install(FILES | ||
$<TARGET_FILE:SDL2::SDL2> | ||
DESTINATION lib | ||
) | ||
export(TARGETS vga-terminal-lib | ||
export(TARGETS vga-terminal | ||
FILE ${CMAKE_BINARY_DIR}/vga-terminal.cmake | ||
) | ||
install(EXPORT | ||
vga-terminal-lib-config DESTINATION cmake | ||
vga-terminal-config DESTINATION cmake | ||
) | ||
target_include_directories(vga-terminal-lib PUBLIC | ||
$<BUILD_INTERFACE:$<TARGET_FILE_DIR:vga-terminal-lib>> | ||
target_include_directories(vga-terminal PUBLIC | ||
$<BUILD_INTERFACE:$<TARGET_FILE_DIR:vga-terminal>> | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:include> | ||
) | ||
target_sources(vga-terminal-lib PRIVATE | ||
target_sources(vga-terminal PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/Window.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/VgaTerminal.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/vga-terminal.cpp | ||
) | ||
target_link_libraries(vga-terminal-lib SDL2::SDL2 SDL2::SDL2main) | ||
target_link_libraries(vga-terminal SDL2::SDL2 SDL2::SDL2main) | ||
|
||
|
||
################ Shared code among exe and tests ############################# | ||
add_library(vga-terminal OBJECT) | ||
target_sources(vga-terminal PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/VgaTerminal.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/Window.cpp | ||
########################### Static Lib ####################################### | ||
add_library(vga-terminal-static STATIC) | ||
install( | ||
TARGETS vga-terminal-static | ||
EXPORT vga-terminal-static-config | ||
DESTINATION static/lib | ||
PUBLIC_HEADER DESTINATION static/include | ||
) | ||
install(FILES | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/VgaTerminal.hpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/Window.hpp | ||
DESTINATION static/include | ||
) | ||
|
||
target_include_directories(vga-terminal PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) | ||
target_link_libraries(vga-terminal PUBLIC SDL2::SDL2 SDL2::SDL2main) | ||
|
||
export(TARGETS vga-terminal-static | ||
FILE ${CMAKE_BINARY_DIR}/vga-terminal-static.cmake | ||
) | ||
install(EXPORT | ||
vga-terminal-static-config DESTINATION static/cmake | ||
) | ||
target_include_directories(vga-terminal-static PUBLIC | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src> | ||
$<INSTALL_INTERFACE:static/include> | ||
) | ||
target_sources(vga-terminal-static PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/Window.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/VgaTerminal.cpp | ||
) | ||
target_link_libraries(vga-terminal-static SDL2::SDL2 SDL2::SDL2main) | ||
|
||
############################## Main Example ################################## | ||
add_executable (${PROJECT_NAME} "sdl2-vga-terminal.cpp") | ||
add_dependencies(${PROJECT_NAME} vga-terminal) | ||
target_link_libraries(${PROJECT_NAME} vga-terminal) | ||
|
||
################ Shared code among exe and tests ############################# | ||
add_library(vga-terminal-obj OBJECT) | ||
target_sources(vga-terminal-obj PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/VgaTerminal.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/Window.cpp | ||
) | ||
|
||
################## C example using SO/DLL with lazy loading ################## | ||
add_executable (${PROJECT_NAME}-so "sdl2-vga-terminal-so.c") | ||
add_dependencies(${PROJECT_NAME}-so vga-terminal-lib) | ||
target_link_libraries(${PROJECT_NAME}-so vga-terminal-lib) | ||
if(MSVC) | ||
target_link_options(${PROJECT_NAME}-so PRIVATE | ||
"/INCREMENTAL" | ||
"/DELAYLOAD:$<TARGET_FILE_NAME:vga-terminal-lib>" | ||
"/DELAY:UNLOAD" | ||
target_include_directories(vga-terminal-obj PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) | ||
if(WITH_SDL2_STATIC) | ||
target_link_libraries(vga-terminal-obj PUBLIC SDL2::SDL2-static SDL2::SDL2main) | ||
else() | ||
install(FILES | ||
$<TARGET_FILE:SDL2::SDL2> | ||
DESTINATION static/lib | ||
) | ||
target_link_libraries(vga-terminal-obj PUBLIC SDL2::SDL2 SDL2::SDL2main) | ||
endif() | ||
|
||
|
||
################## C example using SO/DLL run-time loading ################## | ||
add_executable (${PROJECT_NAME}-load-so "sdl2-vga-terminal-load-so.c") | ||
target_link_libraries(${PROJECT_NAME}-load-so PUBLIC SDL2::SDL2 SDL2::SDL2main) | ||
### Examples | ||
if(WITH_EXAMPLES) | ||
add_subdirectory("examples") | ||
endif() | ||
|
||
|
||
############################### tests | ||
############################### tests ######################################## | ||
if(WITH_TEST) | ||
add_subdirectory("test") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
cmake_minimum_required (VERSION 3.8) | ||
|
||
|
||
############################## Main Example ################################## | ||
add_executable (${PROJECT_NAME} "sdl2-vga-terminal.cpp") | ||
add_dependencies(${PROJECT_NAME} vga-terminal-obj) | ||
target_link_libraries(${PROJECT_NAME} vga-terminal-obj) | ||
|
||
|
||
################## C example using SO/DLL with lazy loading ################## | ||
add_executable (${PROJECT_NAME}-so "sdl2-vga-terminal-so.c") | ||
add_dependencies(${PROJECT_NAME}-so vga-terminal) | ||
target_link_libraries(${PROJECT_NAME}-so vga-terminal) | ||
add_custom_command(TARGET "${PROJECT_NAME}-so" POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:vga-terminal> $<TARGET_FILE_DIR:${PROJECT_NAME}-so> | ||
) | ||
if(MSVC) | ||
target_link_options(${PROJECT_NAME}-so PRIVATE | ||
"/INCREMENTAL" | ||
"/DELAYLOAD:$<TARGET_FILE_NAME:vga-terminal>" | ||
"/DELAY:UNLOAD" | ||
) | ||
endif() | ||
|
||
|
||
################## C example using SO/DLL run-time loading ################## | ||
add_executable (${PROJECT_NAME}-load-so "sdl2-vga-terminal-load-so.c") | ||
target_link_libraries(${PROJECT_NAME}-load-so PUBLIC SDL2::SDL2 SDL2::SDL2main) | ||
add_custom_command(TARGET "${PROJECT_NAME}-load-so" POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:vga-terminal> $<TARGET_FILE_DIR:${PROJECT_NAME}-load-so> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: Ensure that the full path to the library is specified, or current directory may be used (CWE-829, CWE-20). Use registry entry or GetWindowsDirectory to find library path, if you aren't already.