Wetspot compiled to javascript
Re: Wetspot compiled to javascript
The real missing piece is that Android is supposed to compile from Java code, not from c/c++/llm . A code made in FreeBasic would need Android NDK, not just Android SDK
Re: Wetspot compiled to javascript
Still no clues for the error I get?
Re: Wetspot compiled to javascript
Ok, found the issue: the compiler used llvm-as while it should use emscripten itself.
I used the version https://github.com/jayrm/fbc/tree/emscripten. Looks like to remove the error I had to modify the file fbc.bas
Here is the change I made:
I hope it can help someone
I used the version https://github.com/jayrm/fbc/tree/emscripten. Looks like to remove the error I had to modify the file fbc.bas
Here is the change I made:
Code: Select all
--- fbc.bas 2020-08-31 20:48:38.000000000 +0200
+++ src/compiler/fbc.bas 2020-10-31 01:26:07.016517629 +0100
@@ -133,7 +133,7 @@
static shared as zstring * 16 toolnames(0 to FBCTOOL__COUNT-1) = _
{ _
"as", "ar", "ld", "gcc", "llc", "dlltool", "GoRC", "windres", "cxbe", "dxe3gen", _
- "llvm-as", _
+ "emcc", _
"emar", _
"emcc", _
"emcc" _
@@ -2634,7 +2634,7 @@
if( fbGetOption( FB_COMPOPT_TARGET ) <> FB_COMPTARGET_JS ) then
ext = @".asm"
else
- ext = @".llvm"
+ ext = @".s"
end if
if( stage = 1 ) then
@@ -3152,6 +3152,11 @@
end if
endif
end if
+
+ if( fbGetOption( FB_COMPOPT_TARGET ) = FB_COMPTARGET_JS ) then
+ ln += "-c "
+ end if
+
ln += """" + hGetAsmName( module, 2 ) + """ "
ln += "-o """ + *module->objfile + """"
ln += fbc.extopt.gas
Re: Wetspot compiled to javascript
Interesting, because Emscripten manual states that it's possible to use it with Cordova:Landeel wrote:Cordova can turn HTML/javascript into an Android app. So we could make Android apps using FreeBASIC. Just that.
Since it's supposed to use JIT compiling, and since JIT compiling is used for normal Android apps (they are usually made in Java) performances should be pretty close. For better performances FreeBasic should emit a C code and compile it with Android NDK (but it would still need a JAVA frontend).Add another value for ENVIRONMENT named 'webview' - it is a companion option for 'web' and enables some additional compatibility checks so that generated code works both in normal web and in a webview like Cordova.
Although for most apps for smartphones performances seem not to be a real concern, since the app spends most of its time in idle mode waiting for user input, and in many cases it just acts as a front end for cloud services, and does not perform any real computation.
Re: Wetspot compiled to javascript
Looks like there are three ways to make native android apps: they can be made in Java or Kotlin (another programming language evolved from Java), and this is the recommended method by Google. They can be compile specifically for the phone processor, using the Android NDK, or they can be made as web pages (since most apps are actually not much more than a web client anyway) and embedded in an android app using theAPI Webview (that is what Cordova does)
Since neither FreeBasic, nor C or C++ can emit Java or Kotlin code, the first option is not possible: anyone who wants to develop an app using the Android SDK has to learn Java or Kotlin. If we are going to use FreeBasic for Android we should pick one of the alternatives.
The NDK would likely be able to exploit the best speed of the device, although it would require a new target for the FreeBasic compiler, then you'd have to also install both Android SDK and Android NDK
As far as I understand, the open source programs originally developed for PC and then ported to Android (the mobile version of DosBox, for example, or the Unity runtime) use that solution
The Cordova solution is likely slower, but safer, since the code is executed at higher level. Also, I have read that a new kind of apps is appearing, called PWA (Progressive Web Apps): they start as web apps, usable from browser, with no need for installing. If the user likes them, they can be added to the main screen and to the app list, to be managed like apps. They might become the new trend.
Another advantage of the Cordova solution over developing apps in Java/Kotlin is that an app made in that way could be ported almost as easily to iOS as it is to Android. And about 25% of mobile devices are based on iOS.
Since neither FreeBasic, nor C or C++ can emit Java or Kotlin code, the first option is not possible: anyone who wants to develop an app using the Android SDK has to learn Java or Kotlin. If we are going to use FreeBasic for Android we should pick one of the alternatives.
The NDK would likely be able to exploit the best speed of the device, although it would require a new target for the FreeBasic compiler, then you'd have to also install both Android SDK and Android NDK
As far as I understand, the open source programs originally developed for PC and then ported to Android (the mobile version of DosBox, for example, or the Unity runtime) use that solution
The Cordova solution is likely slower, but safer, since the code is executed at higher level. Also, I have read that a new kind of apps is appearing, called PWA (Progressive Web Apps): they start as web apps, usable from browser, with no need for installing. If the user likes them, they can be added to the main screen and to the app list, to be managed like apps. They might become the new trend.
Another advantage of the Cordova solution over developing apps in Java/Kotlin is that an app made in that way could be ported almost as easily to iOS as it is to Android. And about 25% of mobile devices are based on iOS.
Re: Wetspot compiled to javascript
That's correct. And yes, fbgfx is the missing piece for a complete Android port of FB; without it you need to use some other library, like SDL. Crosscompiling C to Android with the NDK is very straightforward. It used to be that a lot of standard C/Unix APIs were missing, but it's gotten so much better. (Given that they had a whole Java VM, they really should have started with a decent libc instead of writing their own crap one to save a few KB and spending the last 12 years fixing its bugs and missing features).angros47 wrote:The NDK would likely be able to exploit the best speed of the device, although it would require a new target for the FreeBasic compiler, then you'd have to also install both Android SDK and Android NDK
As far as I understand, the open source programs originally developed for PC and then ported to Android (the mobile version of DosBox, for example, or the Unity runtime) use that solution
And here is an fbc with an Android target. We use it for the Android port of the OHRRPGCE.
I hadn't heard of PWAs. Interesting.
Re: Wetspot compiled to javascript
That is cool! I had no idea that some software for Android was already developed in FreeBasic!
I wonder... do you have SDK and NDK installed, then? Are you an Android developer?
I wonder... do you have SDK and NDK installed, then? Are you an Android developer?
Re: Wetspot compiled to javascript
Yes, you need both SDK and NDK. Well, actually, you probably technically don't need the SDK to compile FB commandline programs for Android, but the SDK includes the adb tool you need to actually push a binary to a device and to get a shell so you can run them.
Compiling commandline Android programs is easy, fbc can do it directly. Using my branch (which doesn't do much to fbc aside from add new targets and archs), you just need set PATH correctly and run e.g..
A mess of more detailed examples here.
Aside from this FB port I don't write Android apps and know very little about doing so using Java.
Edit: To answer the question I guess you were interested in, if FB had full Android support, would you need to install the SDK? I think the answer is feasibly no, just the NDK (which is still ~450MB). Because the Java part of libfbgfx could just be compiled once, with the exception of
1) the classpath for the app (like com.google.gtalk) is embedded in the .dex compiled Java files, but I believe it wouldn't be very hard to patch these files, or maybe it doesn't actually matter; and
2) the .apk codesigning and (trivial) zipalign utilities, which I think are small standalone utilities that could be distributed separately.
Aside from those, an .apk is just a zip file and a small utility could be written to produce them without the SDK.
(I'm interested in: will OHRRPGCE users need the SDK/NDK to package their games as an .apk themselves, instead of us doing it for them? Same answer, except they don't need the NDK either.)
Compiling commandline Android programs is easy, fbc can do it directly. Using my branch (which doesn't do much to fbc aside from add new targets and archs), you just need set PATH correctly and run e.g.
Code: Select all
fbc -target aarch64-linux-androideabi prog.bas
A mess of more detailed examples here.
Aside from this FB port I don't write Android apps and know very little about doing so using Java.
Edit: To answer the question I guess you were interested in, if FB had full Android support, would you need to install the SDK? I think the answer is feasibly no, just the NDK (which is still ~450MB). Because the Java part of libfbgfx could just be compiled once, with the exception of
1) the classpath for the app (like com.google.gtalk) is embedded in the .dex compiled Java files, but I believe it wouldn't be very hard to patch these files, or maybe it doesn't actually matter; and
2) the .apk codesigning and (trivial) zipalign utilities, which I think are small standalone utilities that could be distributed separately.
Aside from those, an .apk is just a zip file and a small utility could be written to produce them without the SDK.
(I'm interested in: will OHRRPGCE users need the SDK/NDK to package their games as an .apk themselves, instead of us doing it for them? Same answer, except they don't need the NDK either.)
Re: Wetspot compiled to javascript
Thank you for your answer. I never experimented with NDK because all tutorials I have seen stated that SDK, too, is required (and I don't want to install 1+ GB of frameworks, plus the JVM, for something I am not going to use)
I wonder, if you have NDK already installed, have you tried compiling my OpenB3D library? (I am curious to know if it can work on Android. It seems to work on Emscripten)
I wonder, if you have NDK already installed, have you tried compiling my OpenB3D library? (I am curious to know if it can work on Android. It seems to work on Emscripten)