Skip to content

12 29 #244

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

Merged
merged 36 commits into from
Jun 26, 2025
Merged

12 29 #244

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
e1dab04
ANDROID: update USB api to allow setting baud rate and timeout
chrisws Mar 30, 2025
82c463c
ANDROID: experimental bluetooth support
chrisws Apr 5, 2025
1f9b998
ANDROID: fixed some intellij inspection issues
chrisws Apr 14, 2025
c7c3566
Removes IOIO-OTG support for now
chrisws Apr 14, 2025
2907bde
TEENSY: serial receive now takes buffer size arg
chrisws Apr 14, 2025
75438c3
TEENSY: update demo
chrisws Apr 14, 2025
a0b0784
ANDROID: update sound sample
chrisws Apr 19, 2025
e8e768e
COMMON: bump version
chrisws Apr 19, 2025
ac35055
ANDROID: update file UI dependencies
chrisws Apr 19, 2025
d978842
ANDROID: allow android.speak to take addtional non-string args
chrisws Apr 19, 2025
6c38f2b
ANDROID: update SOUND implementation to avoid skips
chrisws Apr 19, 2025
aad80fc
ANDROID: update SOUND implementation to avoid skips
chrisws Apr 19, 2025
cec6cb7
ANDROID: minor fix for PEN(3)
chrisws Apr 26, 2025
2c26e10
Merge branch 'smallbasic:master' into 12_29
chrisws May 3, 2025
fedfbcc
SDL: upgrade to SDL v 3.x
chrisws May 5, 2025
6d2bf2d
ANDROID: update bluetooth permissions for older android versions #242
chrisws May 6, 2025
c42cba8
ANDROID: updated file selection handling for new MUI grid version
chrisws May 6, 2025
9c9ae77
ANDROID: update bluetooth handling for older android devices
chrisws May 10, 2025
ad5a33b
COMMON: fix issue with space char before import 'c-module'
chrisws May 17, 2025
e46505d
ANDROID: implemented find command
chrisws May 18, 2025
ac23ca3
UI: update help display
chrisws May 24, 2025
77c221f
UI: update help display
chrisws May 24, 2025
bed7c3d
UI: update help display
chrisws May 24, 2025
740decc
UI: experimental keypad to replace android keypad
chrisws May 27, 2025
8955be7
UI: experimental keypad to replace android keypad
chrisws May 28, 2025
99742e9
UI: experimental keypad to replace android keypad
chrisws May 29, 2025
fb6b2c3
UI: experimental keypad to replace android keypad
chrisws Jun 5, 2025
02364ef
COMMON: resolved some compiler warnings
chrisws Jun 6, 2025
bd05aac
COMMON: update dependencies
chrisws Jun 6, 2025
230060f
SDL: added cmake build scripts for use with clion (free version)
chrisws Jun 7, 2025
1c22dfa
UI: experimental keypad to replace android keypad
chrisws Jun 7, 2025
2709c3f
UI: experimental keypad to replace android keypad
chrisws Jun 8, 2025
8c6752f
UI: experimental keypad to replace android keypad
chrisws Jun 11, 2025
da9d224
UI: experimental keypad to replace android keypad
chrisws Jun 13, 2025
05e366d
UI: experimental keypad to replace android keypad
chrisws Jun 14, 2025
6094d3a
UI: experimental keypad to replace android keypad
chrisws Jun 17, 2025
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
209 changes: 209 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
# SmallBASIC
# Copyright(C) 2025 Chris Warren-Smith.
#
# This program is distributed under the terms of the GPL v2.0 or later
# Download the GNU Public License (GPL) from www.gnu.org
#

set(VERSION "12.29")
cmake_minimum_required(VERSION 3.10)
project(SmallBASIC VERSION ${VERSION} LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# cmake -DWITH_DEBUG=ON
option(WITH_DEBUG "Enable debug build" OFF)

function(writeConfig)
execute_process(
COMMAND date +"%a, %d %b %Y"
OUTPUT_VARIABLE BUILD_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(BUILD_DATE "${BUILD_DATE}")

execute_process(
COMMAND bash -c "awk -F '.' '{printf \"0x%02d%02d%02d\", \$1, \$2, \$3}' <<< \"${VERSION}\""
OUTPUT_VARIABLE SB_DWORD_VER
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(SB_DWORD_VER "${SB_DWORD_VER}")

configure_file(
${CMAKE_SOURCE_DIR}/ide/config.h.in
${CMAKE_BINARY_DIR}/config.h
)
endfunction()

function(checkDebugMode)
if(WITH_DEBUG)
set(SANITIZER_FLAGS "-fstack-protector-all -fno-omit-frame-pointer -fsanitize=address,undefined")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SANITIZER_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SANITIZER_FLAGS}")
message(STATUS "Debug mode enabled via --with-debug")
endif()
endfunction()

function(buildSDL)
# Initialize variables
set(TARGET "Building SDL version.")
set(PACKAGE_CFLAGS "")
set(PACKAGE_LIBS "")

# check dependencies using pkg-config
find_package(SDL3 REQUIRED)
find_package(PkgConfig REQUIRED)

pkg_check_modules(SDL3 REQUIRED sdl3)
include_directories(${SDL3_INCLUDE_DIRS})
add_compile_options(${SDL3_CFLAGS_OTHER})

pkg_check_modules(FREETYPE2 REQUIRED freetype2)
include_directories(${FREETYPE2_INCLUDE_DIRS})
add_compile_options(${FREETYPE2_CFLAGS_OTHER})

# check for xxd command
find_program(XXD_EXECUTABLE xxd)
if(NOT XXD_EXECUTABLE)
message(FATAL_ERROR "xxd command not installed: configure failed.")
endif()

# platform-specific configurations
if(WIN32)
set(PACKAGE_CFLAGS "${PACKAGE_CFLAGS} -D__USE_MINGW_ANSI_STDIO")
add_compile_definitions(_USE_MATH_DEFINES)
add_compile_definitions(_Win32)
set(PACKAGE_LIBS "${PACKAGE_LIBS} -lwsock32 -lws2_32 -static-libgcc -static-libstdc++")
elseif(APPLE)
pkg_check_modules(FONTCONFIG REQUIRED fontconfig>=2.2)
set(PACKAGE_CFLAGS "${PACKAGE_CFLAGS} ${FONTCONFIG_CFLAGS}")
set(PACKAGE_LIBS "${PACKAGE_LIBS} -ldl ${FONTCONFIG_LIBS}")
else()
pkg_check_modules(FONTCONFIG REQUIRED fontconfig>=2.2)
include_directories(${FONTCONFIG_INCLUDE_DIRS})
add_compile_options(${FONTCONFIG_CFLAGS_OTHER})
execute_process(
COMMAND ${XXD_EXECUTABLE} -i images/sb-desktop-128x128.png
OUTPUT_FILE ${CMAKE_BINARY_DIR}/src/platform/sdl/icon.h
)
endif()

# Set compiler flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PACKAGE_CFLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -std=c++14")

# Define SDL version
execute_process(
COMMAND pkg-config --modversion sdl3
OUTPUT_VARIABLE _SDL_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)

# message("SDL version: ${_SDL_VERSION}")
set(BUILD_DATE `date +"%a, %d %b %Y"`)
set(_SDL_VERSION ${_SDL_VERSION})
set(_SDL ON)
set(_UnixOS ON)
set(IMPL_DEV_READ ON)
set(IMPL_LOG_WRITE ON)

# Process assets
execute_process(
COMMAND ${XXD_EXECUTABLE} -i src/platform/android/app/src/main/assets/main.bas
OUTPUT_FILE ${CMAKE_BINARY_DIR}/src/platform/sdl/main_bas.h
)
writeConfig()
endfunction()

message("generating kwp.h")
execute_process(
COMMAND bash -c "(cd ../documentation && g++ -o build_kwp build_kwp.cpp && ./build_kwp > ../src/ui/kwp.h)"
)

checkDebugMode()
buildSDL()

set(COMMON_DIR ${CMAKE_SOURCE_DIR}/src/common)
set(LIB_DIR ${CMAKE_SOURCE_DIR}/src/lib)
set(UI_DIR ${CMAKE_SOURCE_DIR}/src/ui)
set(SDL_DIR ${CMAKE_SOURCE_DIR}/src/platform/sdl)

set(SOURCES
${LIB_DIR}/match.c
${LIB_DIR}/str.c
${LIB_DIR}/matrix.c
${LIB_DIR}/xpm.c
${LIB_DIR}/lodepng/lodepng.cpp
${COMMON_DIR}/bc.c
${COMMON_DIR}/blib.c
${COMMON_DIR}/blib_func.c
${COMMON_DIR}/blib_math.c
${COMMON_DIR}/brun.c
${COMMON_DIR}/ceval.c
${COMMON_DIR}/random.c
${COMMON_DIR}/eval.c
${COMMON_DIR}/plugins.c
${COMMON_DIR}/fmt.c
${COMMON_DIR}/kw.c
${COMMON_DIR}/proc.c
${COMMON_DIR}/sberr.c
${COMMON_DIR}/scan.c
${COMMON_DIR}/str.c
${COMMON_DIR}/tasks.c
${COMMON_DIR}/hashmap.c
${COMMON_DIR}/var_map.c
${COMMON_DIR}/var_eval.c
${COMMON_DIR}/keymap.c
${COMMON_DIR}/units.c
${COMMON_DIR}/var.c
${COMMON_DIR}/device.c
${COMMON_DIR}/blib_db.c
${COMMON_DIR}/blib_graph.c
${COMMON_DIR}/blib_sound.c
${COMMON_DIR}/screen.c
${COMMON_DIR}/system.c
${COMMON_DIR}/random.c
${COMMON_DIR}/eval.c
${COMMON_DIR}/file.c
${COMMON_DIR}/ffill.c
${COMMON_DIR}/fs_serial.c
${COMMON_DIR}/fs_socket_client.c
${COMMON_DIR}/fs_stream.c
${COMMON_DIR}/g_line.c
${COMMON_DIR}/geom.c
${COMMON_DIR}/inet2.c
${COMMON_DIR}/pfill.c
${COMMON_DIR}/plot.c
${UI_DIR}/graphics.cpp
${UI_DIR}/ansiwidget.cpp
${UI_DIR}/window.cpp
${UI_DIR}/screen.cpp
${UI_DIR}/system.cpp
${UI_DIR}/form.cpp
${UI_DIR}/inputs.cpp
${UI_DIR}/textedit.cpp
${UI_DIR}/keypad.cpp
${UI_DIR}/image.cpp
${UI_DIR}/image_codec.cpp
${UI_DIR}/strlib.cpp
${UI_DIR}/audio.cpp
${SDL_DIR}/main.cpp
${SDL_DIR}/display.cpp
${SDL_DIR}/runtime.cpp
${SDL_DIR}/settings.cpp
${SDL_DIR}/editor.cpp
${SDL_DIR}/syswm.cpp
)

include_directories(
${SDL3_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/src
${CMAKE_BINARY_DIR}
)

add_executable(sbasicg ${SOURCES})

target_link_libraries(sbasicg ${SDL3_LIBRARIES} m)
target_link_libraries(sbasicg ${FREETYPE2_LIBRARIES})
target_link_libraries(sbasicg ${FONTCONFIG_LIBRARIES})
9 changes: 9 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
2025-04-26 (12.29)
ANDROID: minor fix for PEN(3)

2025-04-19 (12.29)
ANDROID: experimental bluetooth support
ANDROID: update SOUND implementation to avoid skips
ANDROID: update USB api to allow setting baud rate and timeout
ANDROID: allow android.speak to take additional non-string args

2025-02-18 (12.28)
ANDROID: added experimental usb communication support

Expand Down
48 changes: 20 additions & 28 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
dnl
dnl Configure script for SmallBASIC
dnl
dnl Copyright(C) 2001-2020 Chris Warren-Smith.
dnl Copyright(C) 2001-2025 Chris Warren-Smith.
dnl
dnl This program is distributed under the terms of the GPL v2.0
dnl Download the GNU Public License (GPL) from www.gnu.org
dnl

AC_INIT([smallbasic], [12.28])
AC_INIT([smallbasic], [12.29])
AC_CONFIG_SRCDIR([configure.ac])

AC_CANONICAL_TARGET
Expand Down Expand Up @@ -81,8 +81,10 @@ function checkDebugMode() {
AC_MSG_RESULT([$with_debug])
if test "$with_debug" = "yes" || test "$with_debug" = "full"
then
CFLAGS="${CFLAGS} -g -O0 -fstack-protector-all"
CXXFLAGS="${CXXFLAGS} -g -O0 -fstack-protector-all"
DEBUG_FLAGS="-g -O1 -fstack-protector-all -fno-omit-frame-pointer"
#-fsanitize=address,undefined"
CFLAGS="${DEBUG_FLAGS}"
CXXFLAGS="${DEBUG_FLAGS}"
AC_DEFINE(_DEBUG, 1, [debugging build enabled])
fi
AC_SUBST(CFLAGS)
Expand Down Expand Up @@ -170,10 +172,7 @@ function buildSDL() {
TARGET="Building SDL version."
defaultConditionals

AC_CHECK_PROG(have_sdl, sdl2-config, [yes], [no])
if test "${have_sdl}" = "no" ; then
AC_MSG_ERROR([libsdl2-dev not installed: configure failed.])
fi
PKG_CHECK_MODULES([SDL3], [sdl3])

SAVED_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS `pkg-config freetype2 --cflags`"
Expand All @@ -197,7 +196,7 @@ function buildSDL() {
PACKAGE_CFLAGS="${PACKAGE_CFLAGS} -mms-bitfields"
PACKAGE_LIBS="${PACKAGE_LIBS} -lwsock32 -lws2_32 -static-libgcc -static-libstdc++"
PACKAGE_LIBS="${PACKAGE_LIBS} -Wl,-Bstatic -Wl,-Map=output.map"
PACKAGE_LIBS="${PACKAGE_LIBS} `sdl2-config --static-libs` `pkg-config freetype2 --libs --static`"
PACKAGE_LIBS="${PACKAGE_LIBS} ${SDL3_LIBS} `pkg-config freetype2 --libs --static`"
AC_DEFINE(_Win32, 1, [Windows build])
;;

Expand All @@ -212,7 +211,7 @@ function buildSDL() {
dnl backlinking support for modules
PACKAGE_LIBS="${PACKAGE_LIBS} -ldl"
PACKAGE_LIBS="${PACKAGE_LIBS} ${FONTCONFIG_LIBS}"
PACKAGE_LIBS="${PACKAGE_LIBS} `sdl2-config --libs` `pkg-config freetype2 --libs`"
PACKAGE_LIBS="${PACKAGE_LIBS} ${SDL3_LIBS} `pkg-config freetype2 --libs`"
;;

*)
Expand All @@ -225,32 +224,25 @@ function buildSDL() {

(cd images && xxd -i sb-desktop-128x128.png > ../src/platform/sdl/icon.h)

HAVE_SDL2_STATIC=yes
AC_MSG_CHECKING([if installed SDL2 supports static libs])
AC_PATH_PROGS_FEATURE_CHECK([SDL2_STATIC_TMP], [sdl2-config],
AS_IF([`"$ac_path_SDL2_STATIC_TMP" --static-libs 2>&1 | sed '/Usage/!{q1};' > /dev/null`], [HAVE_SDL2_STATIC=no]))
AC_MSG_RESULT([$HAVE_SDL2_STATIC])

if test "x$HAVE_SDL2_STATIC" = "xno"; then
SDL_LIBS=`sdl2-config --libs`
else
SDL_LIBS=`sdl2-config --static-libs`
fi
AC_MSG_CHECKING([for SDL3 library linking])
SDL3_LIBS=`pkg-config sdl3 --libs --static`
AC_MSG_RESULT([$SDL3_LIBS])

dnl backlinking support for modules
PACKAGE_LIBS="${PACKAGE_LIBS} -ldl -no-pie"
PACKAGE_LIBS="${PACKAGE_LIBS} ${FONTCONFIG_LIBS}"

PACKAGE_LIBS="-static-libgcc ${PACKAGE_LIBS} ${SDL_LIBS} `pkg-config freetype2 --libs`"
PACKAGE_LIBS="-static-libgcc ${PACKAGE_LIBS} ${SDL3_LIBS} `pkg-config freetype2 --libs`"
esac

PACKAGE_CFLAGS="${PACKAGE_CFLAGS} `sdl2-config --cflags` `pkg-config freetype2 --cflags` -fno-exceptions"
SDL3_CFLAGS=`pkg-config sdl3 --cflags`
PACKAGE_CFLAGS="${PACKAGE_CFLAGS} ${SDL3_CFLAGS} `pkg-config freetype2 --cflags` -fno-exceptions"
CXXFLAGS="${CXXFLAGS} -fno-rtti -std=c++14"

dnl preconfigured values for SDL build
AC_DEFINE_UNQUOTED([_SDL_VERSION], ["`sdl2-config --version` "], [SDL library version])
SDL3_VERSION=`pkg-config sdl3 --modversion`
AC_DEFINE_UNQUOTED([_SDL_VERSION], ["${SDL3_VERSION} "], [SDL library version])
AC_DEFINE(_SDL, 1, [Defined when building SDL version])
AC_DEFINE(_UnixOS, 1, [Building under Unix like systems.])
AC_DEFINE(_UnixOS, 1, [Building under Unix-like systems.])
AC_DEFINE(IMPL_DEV_READ, 1, [Implement dev_read()])
AC_DEFINE(IMPL_LOG_WRITE, 1, [Driver implements lwrite()])

Expand Down Expand Up @@ -529,8 +521,8 @@ echo "PACKAGE_LIBS=${PACKAGE_LIBS}"

if test x$ac_build_sdl = xyes; then
echo
echo "sdl2: `sdl2-config --version`"
echo "freetype: `pkg-config --version freetype2`"
echo "sdl3: `pkg-config sdl3 --modversion`"
echo "freetype: `pkg-config freetype2 --modversion`"
fi

echo
Expand Down
1 change: 1 addition & 0 deletions documentation/build_kwp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ int main(int argc, char *argv[]) {
}

fprintf(stdout, "/* automagicaly generated file */\n");
fprintf(stdout, "#pragma once\n");
fprintf(stdout, "static struct KEYWORD_HELP {\n");
fprintf(stdout, " const char *package;\n");
fprintf(stdout, " const char *keyword;\n");
Expand Down
Loading