Use SQLite with biicode - sqlite

So far I have been able to succesfully use boost, cereal and gtest using biicode but I am having troubles with sqlite. I am trying to use it doing the following:
#include <sqlite3.h>
So I edited my biicode.conf to include those lines, including the alising for the header:
[requirements]
sqlite/sqlite:9
[includes]
sqlite.h: sqlite/sqlite/sqlite3/sqlite3.h
But when I try to call bii cpp:build it does the following
WARN: Removing unused reference to "sqlite/sqlite: 9" from myuser/test "requirements"
Then I ended up with the expected:
database_impl.cpp:(.text+0x516): undefined reference to `sqlite3_exec'
Surprisingly, the compilation succedd even though sqlite3.h is obviously not included but that's maybe because the call to sqlite is from a template function.
I have looked at the example but CMakeList.txt does not seem to add any additional includes directories. For example for boost I had to add:
SET(Boost_USE_STATIC_LIBS OFF)
bii_find_boost(COMPONENTS chrono system filesystem log thread REQUIRED)
target_include_directories(${BII_BLOCK_TARGET} INTERFACE ${Boost_INCLUDE_DIRS})
target_link_libraries(${BII_BLOCK_TARGET} INTERFACE ${Boost_LIBRARIES})
But the two examples I found here and here don't seem to add anything to the includes directories, not even a link folder. I suppose sqlite has to be compiled with your sources so how do I make biicode add those files to my projects automatically ?

There're several problems. You just wrote in [includes] section sqlite.h instead of sqlite3.h and you should only write the prefix, sqlite/sqlite/sqlite3, later instead of the full dependency name.
Then, you can solve it so:
[requirements]
sqlite/sqlite: 9
[includes]
sqlite3.h: sqlite/sqlite/sqlite3
Or, you could try the SQLite version uploaded into fenix user:
[requirements]
fenix/sqlite: 0
[includes]
sqlite3.h: fenix/sqlite
Don't worry about a "WARN" message that says biicode is ignoring sqlite3.c file because it's harcoded into the block CMakeLists.txt to catch this file ;)
Note: you should write your external #includes's with double quotes instead of <>, because the last ones are referred to system headers and biicode could be using some system deps and you don't realize it.

Related

Flow-typed - Generate Libdef

I'm using Flow to help author a JS project. If I want to provide a libdef file to supplement it do I need to create it manually, or am I able to execute some magic command that I'm not aware of yet which will generate the lib def for me?
Something like $ flow-typed doyourmagic would be nice.
EDIT:
Found this https://stackoverflow.com/a/38906578/192999
Which says:
There's two things:
If the file is owned by you (i.e. not a third party lib inside node_modules or such), then you can create a *.js.flow file next to it that documents its exports.
If the file is not owned by you (i.e. third party lib inside node_modules or such), then you can create a libdef file inside flow-typed/name-of-library.js
For .js.flow files
you write the definitions like this:
// #flow
declare module.exports: { ... }
For libdef files you write the definitions like this:
declare module "my-third-party-library" { declare module.exports: {... } }
For my question I fall into the "is owned by you" camp.
I guess I'm confused as to:
How I write these files.
How/where I publish these files to package it up for another project to reference.
Also, why do I need to create the .js.flow file manually? Can this not be magically generated? Perhaps that's the intention going forward but not implemented yet.
I found a nice guide showing how to package flow code together with the compiled code. So:
You do not have to write your own libdefs, you can use the entire flow source code. If you want a definition with only the type declarations, you can look into flow gen-flow-files, although that is still experimental and might fail.
You can package them as *.js.flow and the flow checker will automatically pick those up when you import your library.

How can I use reflection with Java 9 on the Java internals?

We use this type of Reflection only in our test framework and not in production. We want add some jar files to the app classloader depending of our test code. Is there any workaround for it? How can we get access to not exported classes?
java.lang.reflect.InaccessibleObjectException: Unable to make member of class jdk.internal.loader.ClassLoaders$AppClassLoader accessible: module java.base does not export jdk.internal.loader to unnamed module #9f73a2
at jdk.internal.reflect.Reflection.throwInaccessibleObjectException(Reflection.java:414)
at java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:174)
at java.lang.reflect.Method.checkCanSetAccessible(Method.java:191)
at java.lang.reflect.Method.setAccessible(Method.java:185)
Accessing module-internal classes can not be done from code. This is on purpose. But there is a workaround from the command line - a non-standardized option on java that does what you want:
--add-exports <module>/<package>=<target-module>(,<target-module>)*
updates <module> to export <package> to <target-module>,
regardless of module declaration.
<target-module> can be ALL-UNNAMED to export to all
unnamed modules.
Note
Java 9 is a moving target and the exact syntax has been changed a couple of times - as was this answer. This means (a) some of the comments below may seem outdated and (b) the flag might not work exactly like that. Please leave a comment and it will get fixed.

Compiling code + ydn with Closure Compiler

I'm trying to take advantage of Google Closure Compiler minification by writing a database script of my own and compiling it with the pre-compiled ydn. To get a basic first version working I'm trying to rewrite the todo list demo from the project. Unfortunately, I don't understand how to keep namespaces for ydn functions preserved in the compiled output file.
Here's what I've written so far: http://pastebin.com/6YhnRuD5
When the code compiles in advanced mode, the "ydn.db.Storage" from "db = new ydn.db.Storage(dbName, Schema)" gets munged into "ydn.db.c$" making it unusable. The goog.exportSymbol at the bottom of the file doesn't seem to save the function names either.
Does anyone know how to rewrite this with Google Closure Compiler? Should this be compiled directly with the ydn source code instead?
The goog.exportSymbol at the bottom of the file doesn't seem to save the function names either.
It should.
goog.exportSymbol("ydn.db.Storage");
should be
goog.exportSymbol('ydn.db.Storage', ydn.db.Storage);

How can I programmatically add build files to Xcode4?

I've been trying to figure out how to programmatically add files to an Xcode4 project and it seemed like AppleScript would be the way to go, however I'm running into "missing value" errors.
Here's the code I've got:
tell application "Xcode"
set theProject to first project
set theTarget to first target of theProject
set theBuildPhase to compile sources phase of theTarget
tell first group of theProject
set theFileRef to make new file reference with properties {full path:"/Users/jeff/Projects/XcodeTest/XcodeTest/MyViewController.h", name:"MyViewController.h", path:"XcodeTest/MyViewController.h", path type:group relative}
add theFileRef to theProject
end tell
--tell theBuildPhase to make new build file with properties {build phase:theBuildPhase, name:"MyViewController.h", file reference:theFileRef, target:theTarget, project:theProject}
end tell
I've tried the commented-out line instead of the add-command as well, but that doesn't work either (I get "missing value").
The 'add' error is:
error "Xcode got an error: file reference id \"251AD3431432472E006E300F\" of Xcode 3 group id \"251AD32C14324645006E300F\" of project \"XcodeTest\" of workspace document \"XcodeTest.xcodeproj/project.xcworkspace\" doesn’t understand the add message." number -1708 from file reference id "251AD3431432472E006E300F" of Xcode 3 group id "251AD32C14324645006E300F" of project "XcodeTest" of workspace document "XcodeTest.xcodeproj/project.xcworkspace"
The "make new reference" does add the file to the list of files in Xcode, but I also need it to be added to the project target so that I can add actions and outlets to the file from Xcode w/o having to first check the checkbox to add it to the "target membership".
I ended up sending this question to the devs on the xcode developer list and the response I got was effectively "you can't".
This appears to be completely broken in Xcode4, but I've seen a project that does it. I think what they are doing is parsing and modifying the "project.pbxproj" file directly. (this file is hidden inside the xcodeproj bundle)
The file is a GUID soup, but once you look at it for a while it seems possible to safely modify it, especially if you are only adding stuff.
Edit:
Found this stackoverflow answer that might help.
Tutorial or Guide for Scripting XCode Build Phases
There is a poorly documented user defined build setting that can be added. Files can be both excluded and included from compilation
Go to your target's Build Settings > Tap the + button > Add User-Defined Setting
The key is either INCLUDED_SOURCE_FILE_NAMES or EXCLUDED_SOURCE_FILE_NAMES
The value is a space separated list of file paths
See reference:
http://lists.apple.com/archives/xcode-users/2009/Jun/msg00153.html

What is the purpose of files[] in .info?

I've just started learning discovering the changes to Drupal 7, and I just found the files[] array now required in the mymodule.info. From what I've found, it is required to add the mymodule.module file to the list, but what other uses does it have?
From what I've read I figured I should be able to separate my code into several files, for example I wanted to make a mymodule.blocks.inc to contain all the code for my blocks, but it seems like the mymodule_block_info() function never runs.
Am I doing something wrong, or is this not how it is supposed to be used?
As the documentation says:
files (Optional) Drupal now supports a dynamic-loading code registry.
To support it, all modules must now declare any code files containing class or interface declarations in the .info file.
This is only used if the file you specify in files[] contains a class or an interface. If so, the file will be auto-loaded only when needed.
No other files should be declared using files[].
At the beginning it was to make a files registry for each module, but it's not longer used as Drupal do it by himself.
If you want separate your module in multiple files, you should include them in the top of your .module file.
The way I see it, files specified as files[] are meant to be supporting files and called upon when needed. Implemented default Drupal hooks should be specified in the .module file or in the $module.$group.inc file in order for Drupal to recognize them. See hook_hook_info().
Also, see the note in the documentation under files at http://drupal.org/node/542202.

Resources