Skip to content
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

add the assets folder to the apk #235

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

kochol
Copy link
Contributor

@kochol kochol commented Jul 28, 2019

add the assets folder to the apk if the folder exists

add the assets folder to the apk if the folder exists
@floooh
Copy link
Owner

floooh commented Aug 2, 2019

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).

@kochol
Copy link
Contributor Author

kochol commented Aug 3, 2019

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?

@floooh
Copy link
Owner

floooh commented Aug 4, 2019

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

def isDirty(version, inputs, outputs) :

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

@kochol
Copy link
Contributor Author

kochol commented Aug 6, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants