Author Topic: Scriptbasic Build Linux  (Read 30757 times)

Offline AIR

  • BASIC Developer
  • Posts: 781
Re: Scriptbasic Build Linux
« Reply #60 on: November 29, 2018, 10:57:45 PM »
The instructions using 7z was confusing and the 7za a -sfx sb64.run ~/Projects/sb/sb64 command didn't work.

That's because you're supposed to RUN the file as a program, not run 7za against it.  It's a self-extracting archive

./sb64.run

The segfault is an issue with scriba itself, I've been trying to track down why it only happens when you don't pass any arguments.  It works fine otherwise.

Fixed.  Reuploaded the sb64.run file.  Pushed fix up to my repository.
« Last Edit: November 29, 2018, 11:36:40 PM by AIR »

Offline John

  • Forum Support / SB Dev
  • Posts: 2999
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #61 on: November 29, 2018, 11:47:29 PM »
Great!

I'll start over and not over think this.

How do I retain your commit info from your private repo and push it to the public version?
« Last Edit: November 29, 2018, 11:49:56 PM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 2999
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux - Android
« Reply #62 on: November 30, 2018, 01:01:25 AM »
When I get time, I might try to get a refresh on the Android Linux version as a .apk installable app.

FYI: My Samsung S8+ is not rooted.

Quote

C4droid is the most powerful C/C++ IDE + C/C++ compiler for Android.

Features:
Offline C/C++ compiler: create your own applications on Android device and run them even without Internet access
Qt, SDL, SDL2, Allegro, SFML, FLTK and NativeActivity support for graphics
Export & share your programs as APK or binaries
Debugger with breakpoints and watches
CMake and Makefile support: use the same build scripts as on your PC (BusyBox is included)
Source code editor with syntax highlighting, tabs, code completion, code formatting, file association and undo/redo
No root required (but C4droid can use it for your programs if you want)
Full ANSI C and ISO C99 support with TCC (Tiny C Compiler) + musl libc
Fully-functional C++ compiler, complete C++11 support with GCC
Git integration
Customizable GUI, choose where to place tabs and buttons by yourself, themes are also supported
Semi-automatic open-source library porting feature for enhanced programming & education

C4droid is designed to be user-friendy out-of-the-box, but nothing is perfect, so here are some answers for questions that can appear:

How to use Makefiles, multifile projects, etc?
Long-click compile button (or select "compilation settings" if buttons are hidden/moved) and configure current directory to use the mode you want.
Note that C4droid will create .c4droid configuration file when you press Ok. Some modes (like makefile) require to enter result executable file name, don't forget to do that.
After doing that all use compile and run buttons to build and run your app as regular.

How to use graphics libraries in single-file mode?
Just install SDL plugin and select G++ compiler in C4droid preferences.
Note that C4droid chooses app mode using a very simple source code analysis:
every graphics mode is detected with corresponding include string (e.g. SDL is detected with #include "SDL.h", check bundled examples for more info). Commenting out these lines will not have any effect.
If you are compiling a single-file Qt app, you should also add #include "yoursourcefilenamewithcpp.moc" to the end of source code file also.

How to install C++ support manually?
C4droid will ask you to install C++ support at first startup and will configure itself in semi-automatic mode.
If you want to do that manually, you need:
0) Enough (100MB) internal memory OR root rights
1) Install GCC plugin
2) Select G++ compiler in C4droid preferences
Note that if you want to use C4droid as a C compiler, it is better to select GCC, not G++.

How to build and install libraries?
Almost the same way as regular Makefile building except for that most probably some patching may be required.
Currently tested libraries are gmp(internal memory only),mpfr,mpc,libxml2,neon,sqlite,SDL_gfx(--disable-mmx required).

Which gestures/keyboard shortcuts does C4droid support?
Long-click gestures:
New button: delete current file.
Save button: save as.
Open button: recent files.
Run button: run with arguments.
Compile button: configure current directory.
Tab: close tab.

Keyboard shortcuts:
Ctrl-C, Ctrl-V, Ctrl-X for Copy, Paste and Cut
Ctrl-S, Ctrl-O for Save/Open
Ctrl-Z, Ctrl-Y for Undo/Redo.
Ctrl-L for "go to Line"
Ctrl-F for Find
Ctrl-A for select All
Ctrl-B for Build/compile
Ctrl-R for Run
Ctrl-Space/Ctrl-D for autocompletion (Ctrl-Space may be reserved by Android)

Report bugs at n0n3m4@gmail.com.

C4droid stands for "c for android" (or "c++ for android").
C4droid is not an online compiler, so it uses real binaries.
Some binaries in APK are licensed under (L)GPL, email me for the source code (Tiny C compiler, GCC, BusyBox, etc.)
Android is a trademark of Google Inc.
Qt is a registered trademark of Digia.

Code: C
  1. #include <FL/Fl.H>
  2. #include <FL/Fl_Window.H>
  3. #include <FL/Fl_Box.H>
  4.  
  5. int main(int argc, char **argv) {
  6.     Fl_Window *window = new Fl_Window(600,800);
  7.     Fl_Box *box = new Fl_Box(300-260/2,400-100/2,260,100,"Hello, world!");
  8.     box->box(FL_UP_BOX);
  9.     box->labelsize(36);
  10.     box->labelfont(FL_BOLD+FL_ITALIC);
  11.     box->labeltype(FL_SHADOW_LABEL);           
  12.     window->end();
  13.     window->show(argc, argv);    
  14.     return Fl::run();
  15. }
  16.  

BaCon FLTK Android - sounds more like Windows emulating Android
« Last Edit: November 30, 2018, 02:44:27 AM by John »

Offline AIR

  • BASIC Developer
  • Posts: 781
Re: Scriptbasic Build Linux
« Reply #63 on: November 30, 2018, 09:34:55 AM »
Great!

I'll start over and not over think this.

How do I retain your commit info from your private repo and push it to the public version?

I just made my repo public.  John, do NOT delete any branches, they're there for a reason.

https://sandbox.allbasic.info/AIR/sb-dev

Offline John

  • Forum Support / SB Dev
  • Posts: 2999
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #64 on: November 30, 2018, 09:42:39 AM »
At least folks can see your work in real time and not have to wait on me to get it moved to the scriptbasic project repo.

You be alpha and I'll be beta.  :)

I would NEVER modify your repo.

« Last Edit: November 30, 2018, 11:00:12 AM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 2999
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #65 on: November 30, 2018, 01:13:25 PM »
Thanks AIR for the update to your SB-DEV repo README indicating what dependencies are needed by platform.

Offline John

  • Forum Support / SB Dev
  • Posts: 2999
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #66 on: November 30, 2018, 02:45:56 PM »
I gave your sb64.run a try and I'm still getting the segfault and the environment isn't being setup.

Code: [Select]
rs@jrs-laptop:~/sb$ ./sb64.run

7-Zip SFX 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
p7zip Version 9.20 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,4 CPUs)

Processing archive: ./sb64.run

Extracting  sb64/bin/sbhttpd
Extracting  sb64/bin/scriba
Extracting  sb64/sb.png
Extracting  sb64/include/cgi.bas
Extracting  sb64/include/curl.bas
Extracting  sb64/include/curses.bas
Extracting  sb64/include/dbg.bas
Extracting  sb64/include/dyc.bas
Extracting  sb64/include/ftpd.bas
Extracting  sb64/include/hash.bas
Extracting  sb64/include/json.bas
Extracting  sb64/include/mt.bas
Extracting  sb64/include/mxml.bas
Extracting  sb64/include/mysql.bas
Extracting  sb64/include/nt.bas
Extracting  sb64/include/odbc.bas
Extracting  sb64/include/sdbg.bas
Extracting  sb64/include/slre.bas
Extracting  sb64/include/sqlite.bas
Extracting  sb64/include/t.bas
Extracting  sb64/include/trial.bas
Extracting  sb64/include/ux.bas
Extracting  sb64/include/zlib.bas
Extracting  sb64/sb.sh
Extracting  sb64/module/blah.so
Extracting  sb64/module/cgi.so
Extracting  sb64/module/curl.so
Extracting  sb64/module/curses.so
Extracting  sb64/module/dbg.so
Extracting  sb64/module/hash.so
Extracting  sb64/module/json.so
Extracting  sb64/lib/libscriba.so
Extracting  sb64/module/mt.so
Extracting  sb64/module/mxml.so
Extracting  sb64/module/mysql.so
Extracting  sb64/module/odbc.so
Extracting  sb64/module/sdbg.so
Extracting  sb64/module/slre.so
Extracting  sb64/module/sqlite.so
Extracting  sb64/module/t.so
Extracting  sb64/module/trial.so
Extracting  sb64/module/ux.so
Extracting  sb64/module/zlib.so
Extracting  sb64/lib/libscriba.a
Extracting  sb64/lib/lscriba.a
Extracting  sb64/sb.desktop
Extracting  sb64/.DirIcon
Extracting  sb64/module
Extracting  sb64/lib
Extracting  sb64/include
Extracting  sb64/bin
Extracting  sb64

Everything is Ok
jrs@jrs-laptop:~/sb$ cd sb64
jrs@jrs-laptop:~/sb/sb64$ ls -l
total 32
drwxr-xr-x 2 jrs jrs 4096 Nov 28 21:23 bin
drwxr-xr-x 2 jrs jrs 4096 Nov 28 21:26 include
drwxr-xr-x 2 jrs jrs 4096 Nov 28 21:24 lib
drwxr-xr-x 2 jrs jrs 4096 Nov 29 23:30 module
-rw-r--r-- 1 jrs jrs  143 Nov 28 21:32 sb.desktop
-rw-r--r-- 1 jrs jrs 7474 Nov 28 21:32 sb.png
-rwxr-xr-x 1 jrs jrs  702 Nov 29 21:25 sb.sh
jrs@jrs-laptop:~/sb/sb64$ cat sb.sh
#!/bin/bash

# check if script is being run
# or if it's being sourced.
(return 2>/dev/null) && sourced=1 || sourced=0

if (( sourced == 0 ));then
    WORKDIR=$(dirname "$(readlink -f "$0")")
else
    WORKDIR=$(pwd -P)
fi

export PATH=$PATH:"${WORKDIR}"/bin
TEXT_CONF=$(mktemp)
BINARY_CONF=$(mktemp)
CONFIG="dll \".so\"
module \"${WORKDIR}/module/\"
include \"${WORKDIR}/include/\"
maxstep 0
maxlocalstep 0
maxlevel 29666
maxmem 0
"
echo "$CONFIG" > "${TEXT_CONF}"
scriba -f ${BINARY_CONF} -k ${TEXT_CONF} 2>/dev/null
export SCRIBACONF="${BINARY_CONF}"

if (( sourced == 0 )); then
    scriba $@
    [[ -e "${TEXT_CONF}" ]] && rm "${TEXT_CONF}"
    [[ -e "${BINARY_CONF}" ]] && rm "${BINARY_CONF}"
fi

jrs@jrs-laptop:~/sb/sb64$ ./sb.sh
Usage: basic [options] program.bas

options: -o file_name
            specify output file, save binary format to file but don't execute
         -b file_name
            load binary format from file and execute
         -n
            do not use cache (no save, no load)
         -e
            execute after binary format was saved
         -v
            print version info and stop
         -c
            inform scriba that this is a CGI script.
         -C
            save C program output.
         -E
            save executable output. (may not work under some OS)
         -p preprocessor
            specify external preprocessor.
         -i preprocessor
            specify internal preprocessor.
         -f configurationfile
            specify configuration file
         -d
            debug module error (UNIX only)
         -k text_config_file
            compile the configuration file to binary
         -D
            dump the configuration file in text format
./sb.sh: line 32:  4628 Segmentation fault      (core dumped) scriba $@
jrs@jrs-laptop:~/sb/sb64$

Offline AIR

  • BASIC Developer
  • Posts: 781
Re: Scriptbasic Build Linux
« Reply #67 on: November 30, 2018, 02:51:08 PM »
Try this one.

Offline John

  • Forum Support / SB Dev
  • Posts: 2999
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #68 on: November 30, 2018, 02:56:46 PM »
I had to rename the scriba in my /usr/bin which stopped the confusion. It's not segfaulting but the environment isn't being setup.

Code: [Select]
jrs@jrs-laptop:~/sb$ ./sb64.run

7-Zip SFX 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
p7zip Version 9.20 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,4 CPUs)

Processing archive: ./sb64.run

Extracting  sb64/bin/sbhttpd
Extracting  sb64/bin/scriba
Extracting  sb64/sb.png
Extracting  sb64/include/cgi.bas
Extracting  sb64/include/curl.bas
Extracting  sb64/include/curses.bas
Extracting  sb64/include/dbg.bas
Extracting  sb64/include/dyc.bas
Extracting  sb64/include/ftpd.bas
Extracting  sb64/include/hash.bas
Extracting  sb64/include/json.bas
Extracting  sb64/include/mt.bas
Extracting  sb64/include/mxml.bas
Extracting  sb64/include/mysql.bas
Extracting  sb64/include/nt.bas
Extracting  sb64/include/odbc.bas
Extracting  sb64/include/sdbg.bas
Extracting  sb64/include/slre.bas
Extracting  sb64/include/sqlite.bas
Extracting  sb64/include/t.bas
Extracting  sb64/include/trial.bas
Extracting  sb64/include/ux.bas
Extracting  sb64/include/zlib.bas
Extracting  sb64/sb.sh
Extracting  sb64/module/blah.so
Extracting  sb64/module/cgi.so
Extracting  sb64/module/curl.so
Extracting  sb64/module/curses.so
Extracting  sb64/module/dbg.so
Extracting  sb64/module/hash.so
Extracting  sb64/module/json.so
Extracting  sb64/lib/libscriba.so
Extracting  sb64/module/mt.so
Extracting  sb64/module/mxml.so
Extracting  sb64/module/mysql.so
Extracting  sb64/module/odbc.so
Extracting  sb64/module/sdbg.so
Extracting  sb64/module/slre.so
Extracting  sb64/module/sqlite.so
Extracting  sb64/module/t.so
Extracting  sb64/module/trial.so
Extracting  sb64/module/ux.so
Extracting  sb64/module/zlib.so
Extracting  sb64/lib/libscriba.a
Extracting  sb64/lib/lscriba.a
Extracting  sb64/sb.desktop
Extracting  sb64/.DirIcon
Extracting  sb64/module
Extracting  sb64/lib
Extracting  sb64/include
Extracting  sb64/bin
Extracting  sb64

Everything is Ok
jrs@jrs-laptop:~/sb$ cd sb64
jrs@jrs-laptop:~/sb/sb64$ ls -l
total 32
drwxr-xr-x 2 jrs jrs 4096 Nov 28 21:23 bin
drwxr-xr-x 2 jrs jrs 4096 Nov 28 21:26 include
drwxr-xr-x 2 jrs jrs 4096 Nov 28 21:24 lib
drwxr-xr-x 2 jrs jrs 4096 Nov 29 23:30 module
-rw-r--r-- 1 jrs jrs  143 Nov 28 21:32 sb.desktop
-rw-r--r-- 1 jrs jrs 7474 Nov 28 21:32 sb.png
-rwxr-xr-x 1 jrs jrs  702 Nov 29 21:25 sb.sh
jrs@jrs-laptop:~/sb/sb64$ ./sb.sh
Usage: basic [options] program.bas

options: -o file_name
            specify output file, save binary format to file but don't execute
         -b file_name
            load binary format from file and execute
         -n
            do not use cache (no save, no load)
         -e
            execute after binary format was saved
         -v
            print version info and stop
         -c
            inform scriba that this is a CGI script.
         -C
            save C program output.
         -E
            save executable output. (may not work under some OS)
         -p preprocessor
            specify external preprocessor.
         -i preprocessor
            specify internal preprocessor.
         -f configurationfile
            specify configuration file
         -d
            debug module error (UNIX only)
         -k text_config_file
            compile the configuration file to binary
         -D
            dump the configuration file in text format
jrs@jrs-laptop:~/sb/sb64$ scriba -v
bash: /usr/bin/scriba: No such file or directory
jrs@jrs-laptop:~/sb/sb64$

Offline John

  • Forum Support / SB Dev
  • Posts: 2999
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #69 on: November 30, 2018, 03:15:09 PM »
This works.


jrs@jrs-laptop:~/sb/sb64$ source sb.sh
jrs@jrs-laptop:~/sb/sb64$ scriba -v
ScriptBasic v2.1
Variation >>STANDARD<< build 1
Magic value 859037488
Node size is 24
Extension interface version is 11
Compilation: Nov 30 2018 02:25:18
jrs@jrs-laptop:~/sb/sb64$ scriba -D
dll ".so"
module "/home/jrs/sb/sb64/module/"
include "/home/jrs/sb/sb64/include/"
maxstep 0
maxlocalstep 0
maxlevel 29666
maxmem 0
jrs@jrs-laptop:~/sb/sb64$


Code: [Select]
Extracting  sb64/module/blah.so

What's that?
« Last Edit: November 30, 2018, 03:20:09 PM by John »

Offline AIR

  • BASIC Developer
  • Posts: 781
Re: Scriptbasic Build Linux
« Reply #70 on: November 30, 2018, 03:35:04 PM »
test i haven't removed

Offline AIR

  • BASIC Developer
  • Posts: 781
Re: Scriptbasic Build Linux
« Reply #71 on: November 30, 2018, 03:42:26 PM »
I had to rename the scriba in my /usr/bin which stopped the confusion. It's not segfaulting but the environment isn't being setup.


Your global configuration may be part of the issue.  Again, I don't set up a global config so that I can test multiple versions/scenarios with no conflicts.

Offline John

  • Forum Support / SB Dev
  • Posts: 2999
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #72 on: November 30, 2018, 06:01:35 PM »
The source option works fine. Just running the sb.sh alone fails to setup the environment. There is nothing in the .bashrc setting up SB.

Under Linux, if SB can't find it's config file, it looks in its default location /etc/scriba.
« Last Edit: November 30, 2018, 06:09:27 PM by John »

Offline AIR

  • BASIC Developer
  • Posts: 781
Re: Scriptbasic Build Linux
« Reply #73 on: November 30, 2018, 07:08:37 PM »
The source option works fine. Just running the sb.sh alone fails to setup the environment. There is nothing in the .bashrc setting up SB.

Under Linux, if SB can't find it's config file, it looks in its default location /etc/scriba.

If you do: ./sb.sh -D what does it show?  I may need to move the addition of the path to the front, instead of the back.  Doing it like that would have allowed you to keep your /usr/bin/scriba in place.

Understand that when you run the script, it's setting up a temporary environment, so when you run a script via ./sb.sh <path to bas> it should work.  It works on my Mac/LinBox/RPi.  Once that's done, the environment reverts to what it was before calling the sb.sh script.  It's the same concept that AppImages use.

Sourcing the sb.sh alters the environment for that terminal session.  If you open another terminal, you'll see that the environment is the default you have set up.

AIR.

Offline John

  • Forum Support / SB Dev
  • Posts: 2999
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #74 on: November 30, 2018, 07:15:12 PM »
Quote from: AIR
f you do: ./sb.sh -D what does it show?


jrs@jrs-laptop:~/sb/sb64$  ./sb.sh -D
dll ".so"
module "/home/jrs/sb/sb64/module/"
include "/home/jrs/sb/sb64/include/"
maxstep 0
maxlocalstep 0
maxlevel 29666
maxmem 0
jrs@jrs-laptop:~/sb/sb64$