oasis
oasis copied to clipboard
CompiledObject: Both
This feature request has been migrated from artifact #860 on forge.ocamlcore.org. It was assigned to user102.
user824 posted on 2011-01-03 17:34:16:
Sometimes I want to build same target both as bytecode and native. For example: unit-tests. I want to make sure that my application works both as bytecode and as native executable. Currently this means I need to create 2 executable targets, with same dependencies and everything listed, except first one is CompiledObject: Byte, and second one is CompiledObject: Native Build$: flag(is_native).
Another example: libraries. If you ship libraries you usually want to ship both bytecode and native ones.
It'd be nice if _oasis supported an CompiledObject: Both, that will build both native and bytecode executables if is_native, and only bytecode if native is not available. The executables will then be called .byte and .native as usual with ocamlbuild.
user102 replied on 2011-01-03 23:32:33:
Hello,
First libraries: using CompiledObject: Best for libraries, generates bytecode and native versions. So in the case of library, I don't think Both is mandatory.
Concerning executables, I think this feature is maybe a little bit an exceptional case. I mean that you will deliver only a bytecode or a native targets. I agree that this can be useful for debugging, but for now I'll need to think about it -- I am not convince that is such a common case.
user116 replied on 2011-01-26 11:04:15:
I second this request - it is useful for tests.
user102 replied on 2011-01-26 14:21:48:
I feel that I will need to acknowledge the popular pressure!
What about adding Both to "Best, Native, Byte" that will: force to build both native and byte version for applications. If it is not possible, the build will fail. "Both" will not be accepted for libraries.
For an "Executable test" the variable $test will point to the best version (byte or native) and $test_byte and $test_native to byte and native executable.
Is it ok for both of you ?
user824 replied on 2011-01-26 18:05:15:
Works for me.
user116 replied on 2011-01-26 20:59:40:
If it is not possible, the build will fail. Better not. Then test stage looks like : Test main Run: $test_byte if $is_native Run: $test_native
user102 replied on 2011-01-26 21:26:27:
$test = test.native or test.byte $test_byte = test.byte $test_native = test.native
Test main Run: $test
On arch that doesn't have ocamlopt anyway, we won't compile native application anyway and $test = test.byte (and $test_native won't be set)
Is it better ?
user116 replied on 2011-01-27 08:47:30:
Hm, this is the same that was proposed @2011-01-26 14:21? Usecase that I have in mind - test target that builds both byte and native versions of executable and runs them. Currently this can only be achieved with two executable sections. With "CompiledObject: Both" that doesn't fail it becomes possible to run both with simple is_native check in Test section for non-native archs. "CompiledObject: Both" that fails on non-native arch is useless in such setup.
user102 replied on 2011-01-27 10:48:16:
Yes, "Both" won't fail on non native arch. This is the difference with @2011-01-26 14:21.