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

Android builds broken by datafiles.c #1222

Closed
bob-the-hamster opened this issue Nov 1, 2021 · 3 comments
Closed

Android builds broken by datafiles.c #1222

bob-the-hamster opened this issue Nov 1, 2021 · 3 comments
Labels
build process To do with compiling the OHRRPGCE os: android Specific to Android release-blocker For any bug that is currently blocking the next stable release
Milestone

Comments

@bob-the-hamster
Copy link
Collaborator

Android builds have been broken by the addition of datafiles.c

jni/../jni/application/ohrrpgce/tmp//filelayer.cpp:702: error: undefined reference to 'embedded_files_table'
collect2: error: ld returned 1 exit status
/home/james/misc/android-ndk-r12b/build/core/build-binary.mk:677: recipe for target 'obj/local/armeabi/libapplication.so' failed
make: *** [obj/local/armeabi/libapplication.so] Error 1

tmc correctly points out:

Oops. Probably because datafiles.c is generate under build/ so doesn't
get symlinked into android/tmp.

A quick hack to fix that does avoid the first error message:

Index: ohrbuild.py
===================================================================
--- ohrbuild.py	(revision 12602)
+++ ohrbuild.py	(working copy)
@@ -495,7 +495,12 @@
             source_nodes += [node]
         else:
             # node.sources[0] itself is a path in build/ (to a nonexistent file)
-            source_files.append (node.sources[0].srcnode().abspath)
+            if node.sources[0].name.endswith('datafiles.c'):
+                # special case for datafiles.c which is created in builds dir
+                p = node.sources[0].srcnode().abspath
+                source_files.append (os.path.join(os.path.dirname(p), "build", os.path.basename(p)))
+            else:
+                source_files.append (node.sources[0].srcnode().abspath)
             source_nodes += node.sources
 
     # hacky. Copy the right source files to a temp directory because the Android.mk used

However, then compiling for android results in a colossal cascade of errors like this:

jni/../jni/application/ohrrpgce/tmp//datafiles.c:4:3: error: 'R' undeclared here (not in a function)
   R,E,L,D,^A,^M, , , ,<A6>,^G, , ,<95>,^G, , , , ,^F,^E, , , ,^A,^B,@,^A, ,^E, , , ,^B,^B,<C8>, , ,^D, ,
   ^
jni/../jni/application/ohrrpgce/tmp//datafiles.c:4:5: error: 'E' undeclared here (not in a function)
   R,E,L,D,^A,^M, , , ,<A6>,^G, , ,<95>,^G, , , , ,^F,^E, , , ,^A,^B,@,^A, ,^E, , , ,^B,^B,<C8>, , ,^D, ,
     ^
jni/../jni/application/ohrrpgce/tmp//datafiles.c:4:7: error: 'L' undeclared here (not in a function)
   R,E,L,D,^A,^M, , , ,<A6>,^G, , ,<95>,^G, , , , ,^F,^E, , , ,^A,^B,@,^A, ,^E, , , ,^B,^B,<C8>, , ,^D, ,
       ^
jni/../jni/application/ohrrpgce/tmp//datafiles.c:4:9: error: 'D' undeclared here (not in a function)
   R,E,L,D,^A,^M, , , ,<A6>,^G, , ,<95>,^G, , , , ,^F,^E, , , ,^A,^B,@,^A, ,^E, , , ,^B,^B,<C8>, , ,^D, ,
         ^
jni/../jni/application/ohrrpgce/tmp//datafiles.c:4:3: error: stray '\1' in program
   R,E,L,D,^A,^M, , , ,<A6>,^G, , ,<95>,^G, , , , ,^F,^E, , , ,^A,^B,@,^A, ,^E, , , ,^B,^B,<C8>, , ,^D, ,
   ^
jni/../jni/application/ohrrpgce/tmp//datafiles.c:4:12: error: expected expression before ',' token
   R,E,L,D,^A,^M, , , ,<A6>,^G, , ,<95>,^G, , , , ,^F,^E, , , ,^A,^B,@,^A, ,^E, , , ,^B,^B,<C8>, , ,^D, ,
            ^
jni/../jni/application/ohrrpgce/tmp//datafiles.c:5:2: warning: null character(s) ignored
    , ,^C,^A,<FF>, ,^D, , , ,^D,^A,<FF>, ,^M, , , ,^E,^F, ,C,o,n,t,a,i,n,e,r, ,[,^G, , ,^F, ,^B,*,^F,
@bob-the-hamster bob-the-hamster added build process To do with compiling the OHRRPGCE os: android Specific to Android release-blocker For any bug that is currently blocking the next stable release labels Nov 1, 2021
@bob-the-hamster bob-the-hamster added this to the Ichorescent milestone Nov 1, 2021
@bob-the-hamster
Copy link
Collaborator Author

Re-opening. The last commit fixed the problem where the Android build had data files.c symlinked wrong, but the "undeclared here (not in a function)" errors are still happening

@rversteegen
Copy link
Contributor

It compiles fine for me. I think I misinterpreted the error you posted as being that you had managed to make datafiles.c a symlink to one of the sourceslice files, but now it looks like actually generate_datafiles_c is broken, not converting the bytes of the input to integers. But why does it only break when you attempt to build for android? Probably it's the python version or $LANG you are using when doing that.

        with open(path, 'rb') as datafile:
            data = datafile.read()
            ...
            for offset in range(0, len(data), 40):
                row = data[offset : offset + 40]
                ret += '  ' + ','.join(str(byte) for byte in row) + ',\n'

The problem seems to be str

@rversteegen
Copy link
Contributor

Should be fixed now although I haven't gotten the commit email (I may have overloaded the mail server!); I tested with Python 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build process To do with compiling the OHRRPGCE os: android Specific to Android release-blocker For any bug that is currently blocking the next stable release
Projects
None yet
Development

No branches or pull requests

2 participants