fips icon indicating copy to clipboard operation
fips copied to clipboard

add the assets folder to the apk

Open kochol opened this issue 6 years ago • 4 comments

add the assets folder to the apk if the folder exists

kochol avatar Jul 28 '19 05:07 kochol

Hi, good idea, but IMHO a bit too hardwired. I think the asset directory should be provided from the outside through a command line arg to android-create-apk.py, and maybe exposed as a cmake macro.

I'll keep the PR open as a reminder, we'll also need a similar solution for iOS sooner or later. For instance the last batch of sokol_fetch.h samples doesn't work yet neither on Android nor iOS, not only because the assets are not copied, but also because sokol_fetch.h doesn't know the root path of the asset directory (I'd like to create some sort of sokol_filesystem_util.h header for stuff like this).

floooh avatar Aug 02 '19 09:08 floooh

I see that you load assets from an URL in Oryol and not the filesystem so I thought you do the same in Sokol.

Having a macro is a good one. I use a generator that creates a CPP file for versioning the assets something like: int Version = 20; And increase the number every time if assets files changes to force a build and call the create apk script.

But the first time I call fips build the new code builds but doesn't create apk then next time I call build creates apk. I can not find the bug. Do you have any idea?

kochol avatar Aug 03 '19 02:08 kochol

Have a look at the 'isDirty' helper function in fips:

https://github.com/floooh/fips/blob/9e1433289ce5af6932d2e9db7fec2a740a9163dd/generators/genutil.py#L70

This takes a Version number and a list of input and output files. The Version number mechanism is mainly useful for actual code-generation scenarios, the isDirty function will basically check the output files for the magic string #version:N# (in the first 4 lines of the file) where N is the version number arg. For this to work, an asset-copying generator script must write some sort of dummy source file with this string in the header.

In addition, isDirty() does a timestamp check, if any input file's modification date is newer than any outputs, the function will also return true (this timestamp check makes a lot more sense with asset-copying scripts, if any of the asset source file has been modified, copying will take place).

The file copying generator script here should do the right thing: https://github.com/floooh/sokol-samples/blob/master/fips-files/generators/copy.py

floooh avatar Aug 04 '19 09:08 floooh

This is my generator https://github.com/kochol/ariyana/blob/master/fips-files/generators/Assets.py

I think the problem is not with my generator because the generator change the files but in the next compilation the fips create the apk.

It looks like the create apk script calls before the generators.

kochol avatar Aug 06 '19 04:08 kochol