JacORB: changing prefix and suffix - ant

I would like to change package prefix and suffix in my ant build while generating java from idl. This has to be generic solution! The idea goes like that:
I have idl files (ONE.idl, TWO.idl) with namespace ONE_cb in first and TWO_cb in second (as _cb suffix is required for c++ compatibility). TWO_cb has atributes from ONE_cb, ONE_cb has only basic types. I want to change that to packages going like com.example.ONE and com.example.TWO.
I'm using JacORB 3.6. and I don't know how to do it.
My code looks like that:
<target name="idlj-generate">
<idl2java
srcdir="${psm.dir}/${project}/"
destdir="${build.generated.dir}"
includepath="${psm.dir}"
all="true">
<define key="__JACORB_GENERATE__"/>
<i2jpackage names=":com.example"/>
<i2jpackage names="_cb:"/>
</idl2java>
</target>
It doesn't work. As I stated before it has to be generic solution. adding
<i2jpackage names="TWO_cb:TWO"/> //option 2
<i2jpackage names="ONE_cb:ONE"/> //option 2b
Is not acceptable
Thank you for Your time.

If I understand you correctly you have something like
module ONE_cb
{
...
}
but you want it to be
com.example.ONE { ... }
This is feasible with i2jpackage e.g.
idl -forceOverwrite -d /tmp/generated -i2jpackage ONE_cb:com.example.ONE myfile.idl
The problem you have is that you are compiling both files at once. Remove the "all" and try compiling them in two phases.
If you are using Maven I would also recommend trying org.codehaus.mojo:idlj-maven-plugin as you can do multiple executions very easily with that.
To use multiple i2jpackage I got it working with
idl -forceOverwrite -d /tmp/generated -all -i2jpackagefile /tmp/file antBugJac608-2.idl
(where antBugJac608-2 #includes antBugJac608).

For various research I concluded that generic solution is immpossible.
Only way to perform changing prefix and suffix the same time is to explicite set all included names.

Related

How to write Bazel rules that work with external repositories?

The Bazel Starlark API does strange things with files in external repositories. I have the following Starlark snippet:
print(ctx.genfiles_dir)
print(ctx.genfiles_dir.path)
print(output_filename)
ret = ctx.new_file(ctx.genfiles_dir, output_filename)
print(ret.path)
It is creating the following output:
DEBUG: build_defs.bzl:292:5: <derived root>
DEBUG: build_defs.bzl:293:5: bazel-out/k8-fastbuild/genfiles
DEBUG: build_defs.bzl:294:5: google/protobuf/descriptor.upb.c
DEBUG: build_defs.bzl:296:5: bazel-out/k8-fastbuild/genfiles/external/com_google_protobuf/google/protobuf/descriptor.upb.c
That extra external/com_google_protobuf comes seemingly out of nowhere, and it makes my rule fail:
I tell protoc to generate into ctx.genfiles_dir.path (which is bazel-out/k8-fastbuild/genfiles).
So protoc generates bazel-out/k8-fastbuild/genfiles/google/protobuf/descriptor.upb.c
Bazel fails because I didn't generate bazel-out/k8-fastbuild/genfiles/external/com_google_protobuf/google/protobuf/descriptor.upb.c
Likewise, when I try to call file.short_path on a source file from an external repository, I get a result like ../com_google_protobuf/google/protobuf/descriptor.proto. This seems quite unhelpful, so I just wrote some manual code to strip off the leading ../com_google_protobuf/.
Am I missing something? How can I write this rule in a way that doesn't feel like I'm fighting Bazel the whole time?
Am I missing something?
The basic problem, as you already realized, is that you have two path "namespaces" the one that protoc sees (i.e. import paths) and the one that bazel sees (i.e. the path you pass to declare_file().
2 things to note:
1) All paths declared with declare_file() get the path <bin dir>/<package path incl. workspace>/<path you passed to declare_file()>
2) All actions are executed from <bin dir> (unless output_to_genfils=True in which case this switches to <gen dir> as in your example.
Trying to solve the exact same problem you encountered, I resorted to stripping the known path from the output_file's path to determine which directory to pass as p:
# This code is run from the context of the external protobuf dependency
proto_path = "google/a/b.proto"
output_file = ctx.actions.declare_file(proto_path)
# output_file.path would be `<gen_dir>/external/protobuf/google/a/b.proto`
# Strip the known proto_path from output_file.path
protoc_prefix = output_file.path[:-len(proto_path)]
print(protoc_prefix) # Prints: <gen_dir>/external/protobuf
command = "{protoc} {proto_paths} {cpp_out} {plugin} {plugin_options} {proto_file}".format(
...
cpp_out = "--cpp_out=" + protoc_prefix,
...
)
Alternatives
You may also be able to construct the same path with ctx.bin_dir, ctx.label.workspace_name, ctx.label.package, and ctx.label.name.
Misc.
proto_library recently gained an attribute strip_import_prefix. When used, the above is not correct, as all dependent files are symlinked into a new directory from which they have the relative paths declared with strip_import_prefix.
The path format is:
<bin dir>/<repo>/<package>/_virtual_base/<label name>/<path `import`ed in .proto files>
i.e.
<bin dir>/external/protobuf/_virtual_base/b_proto/google/a/b.proto
Assuming you are building an external repo called protobuf, which contains a BUILD file at its root with a target named b_proto, which in turn, relies on a proto_library wrapping google/a/b.proto AND uses the strip_import_prefix attribute.

How to upload pie file successfully in GraphDB by ontotext

I have the pie file which is used for inference in GraphDB ontotext. I have written the ruleset correctly. while uploading the file it seems ok. But, while creating the repository, it is showing the “Invalid Ruleset file. Please upload valid one” I think the issue is related to the hidden character present inside the file. How to get out if such characters. My file content is :
Prefices
{
rdf : http://www.w3.org/1999/02/22-rdf-syntax-ns#
owl : http://www.w3.org/2002/07/owl#
abc : http://www.xyzabc.com/schema/abcentity#
}
Axioms
{
<abc:isLocatedIn> <rdf:type> <owl:ObjectProperty>
}
Rules
{
Id: isLocatedInHierarchy
a <abc:isLocatedIn> b [Constraint a != b]
b <abc:isLocatedIn> c [Constraint b != c]
a <abc:isLocatedIn> c [Constraint a != c]
}
hidden character present inside the file
Do you mean a Unicode BOM mark? Get an editor that can save without such mark (I strongly recommend Akelpad: http://akelpad.sourceforge.net/), or just save in ASCII.
BTW, writing PIE files with per-property rules is not a good idea. Instead, use a generic rule for transitive property and then declare abc:isLocatedIn transitive in your ontology. The cheapest builtin in which such rule is included is rdfsPlus-optimized. If you select it, then you add to your ontology
abc:isLocatedIn a owl:TransitiveProperty.
However, it's a better idea to keep a "step" property abc:isLocatedIn and then a transitive property on top of it, eg abc:isLocatedTransitive:
abc:isLocatedTransitive a owl:TransitiveProperty.
abc:isLocatedIn rdfs:subPropertyOf abc:isLocatedTransitive.
Finally, there's a more efficient way to compute the transitive closure, see http://rawgit2.com/VladimirAlexiev/my/master/pubs/extending-owl2/index.html#sec-3-1:
abc:isLocatedTransitive ptop:transitiveOver abc:isLocatedIn.
abc:isLocatedIn rdfs:subPropertyOf abc:isLocatedTransitive.
I was also been able to upload successfully your .pie file. Maybe the issue is related to the computer locale or something in the environment. If you are using Windows Notepad++ seems like a logical choice. I guess there is an option to view all the hidden characters, but I've never used it. If you are using Linux there are plenty of choices, even included one like vim or nano which will work just fine.

Using premake with multi localizations

I work with premake 5 for few days now. I'm currently trying to port our VS2015 solution (mainly C++ native and CLI projects) to a premake 5 solution. I had no problem so far but now I'm not able to build resource libraries for all languages we localize our assemblies to. For example, if we have fr and es (for French and Spanich), we should have an assembly split like this:
foo.dll (default, English),
satellites foo.resources.dll for each other languages (separated in different folders of course).
But I'm not able (read: I don't know how) to write the lua script correctly.
Does someone know how to generate localized (AKA satellite) assemblies with premake5?
Thanks for your help!
EDIT 1
I added this to my lua script:
files({"/**.resx"})
It added the .resx files to the .vcxproj file but rather than being included like this:
<EmbeddedResource Include="bar.resx"/>
they are included like this:
<None Include="bar.resx"/>
What's going on?
EDIT 2
I then added:
filter "files:**.resx"
buildaction "Embed"
But it remains the same. I found in premake 5 doc that buildaction was only supported in C# (my code is in C++/CLI). If this is true (it seems to be) is there a way to go deeper with my script to add, say, XML entries directly to the .vcxproj?
Well... after a lot of tries, I found a way. I just added a new (file) category for EmbeddedResource like this:
premake.vstudio.vc2010.categories.EmbeddedResource = {
name = "EmbeddedResource",
extensions = {".resx"},
priority = 50, -- arbitrary number, I saw priorities are 0, 1, 2...
emitFiles = function(prj, group)
premake.vstudio.vc2010.emitFiles(
prj,
group,
"EmbeddedResource",
{premake.vstudio.vc2010.generatedFile} -- cannot explain this...
)
end,
emitFilter = function(prj, group)
premake.vstudio.vc2010.filterGroup(prj, group, "EmbeddedResource")
end
}
Hope it can help...

How to specify multiple binding files in gradle for ant xjc task

I have multiple bindings(xjb files) in the gradle project. When generating JAXB classes for a xsd(C.xsd). I want to use the previously generated binding files for A.xjb & B.xjb since C.xsd refers to A.xsd & B.xsd
The below ant xjc task works if I don't have anyother bindings in same path but I want specify explicity A.xjb & B.xjb bindings. How to go about same, I tried various options but nothing seems working. Any help greatly appreciated.
ant.xjc(destdir : '${jaxbDest}', removeOldOutput:'yes', extension:'true') {
arg(line:'-Xequals -XhashCode -XtoString -Xcopyable')
schema(dir:'src/main/schema', includes:'C.xsd')
binding(dir:'src/main/schema', includes:'*.xjb)
}
Thanks
Ravi
According to this documentation for the ant xjc task -
"To specify more than one external binding file at the same time, use a nested element, which has the same syntax as fileset."
In gradle it would look like this:
binding(dir:'src/main/schema'){
include(name:'A.xjb')
include(name:'B.xjb')
}
I think this would also work:
binding(dir:'src/main/schema', includes:'A.xjb,B.xjb')

How do I make sure that a directory name is quoted in OMake?

I have a relatively complicated suite of OMake files designed for cross-compiling on a specific platform. My source is in C++.
I'm building from Windows and I need to pass to the compiler include directories which have spaces in their names. The way that the includes string which is inserted in the command line to compile files is created is by the line:
public.PREFIXED_INCLUDES = $`(addprefix $(INCLUDES_OPT), $(set $(absname $(INCLUDES))))
At some other point in the OMake files I have a line like:
INCLUDES += $(dir "$(LIBRARY_LOCATION)/Path with spaces/include")
In the middle of the command line this expands to:
-IC:\Library location with spaces\Path with spaces\include
I want it to expand to:
-I"C:\Library location with spaces\Path with spaces\include"
I don't want to change anything but the "INCLUDES += ..." line if possible, although modifying something else in that file is also fine. I don't want to have to do something like change the definition of PREFIXED_INCLUDES, as that's in a suite of OMake files which are part of an SDK which may change beneath me. Is this possible? If so, how can I do it? If not, in what ways can I make sure that includes with spaces in them are quoted by modifying little makefile code (hopefully one line)?
The standard library function quote adds escaped quotes around its argument, so it should do the job:
INCLUDES += $(quote $(dir "$(LIBRARY_LOCATION)/Path with spaces/include"))
If needed, see quote in Omake manual.
In case someone else is having the same problem, I thought I'd share the solution I eventually went with, having never figured out how to surround with quotes. Instead of putting quotes around a name with spaces in it I ended up converting the path to the short (8.3) version. I did this via a a simple JScript file called shorten.js and a one line OMake function.
The script:
// Get Access to the file system.
var FileSystemObject = WScript.CreateObject("Scripting.FileSystemObject");
// Get the short path.
var shortPath = FileSystemObject.GetFolder(WScript.Arguments(0)).ShortPath;
// Output short path.
WScript.StdOut.Write(shortPath);
The function:
ShortDirectoryPath(longPath) =
return $(dir $(shell cscript /Nologo $(dir ./tools/shorten.js) "$(absname $(longPath))"))
So now I just use a line like the following for includes:
INCLUDES += $(ShortDirectoryPath $(dir "$(LIBRARY_LOCATION)/Path with spaces/include"))

Resources