Skip to content
This repository has been archived by the owner on Jan 22, 2019. It is now read-only.

Serialise empty model to XML #49

Open
wants to merge 47 commits into
base: develop
Choose a base branch
from
Open

Serialise empty model to XML #49

wants to merge 47 commits into from

Conversation

codecurve
Copy link
Contributor

This is for #31

Randall Britten added 3 commits March 27, 2015 16:08
Schema has been used to generate XML serialisation/
deserialisation code, based on Cellml_1_2.xsd.

Notes:
- CodeSynthesis XSD used as follows:
    ./generate.sh
  This creates Cellml_1_2.cpp and .h.

- This approach of starting with an essentially blank schema document
  is not my preferred approach, but I was outvoted.
  My personal preference would have been to work incrementally, starting with the
  existing schema for CellML 1.1 and making only the changes that pertain to the
  differences between CellML 1.1 and the draft for CellML 1.2.
  A demonstration of that was done as shown here:
  https://github.com/codecurve/libcellml/blob/04de33845306a6468d389fd8a1be25e7405221e7/src/cellml_1_2.xsd
  as well as the commits that followed it.
Test was previously intended to fail.
As per http://stackoverflow.com/a/6847817

Note: this had to be redone, since the CMake refactor, it
somehow got lost, see 89c624b
@agarny
Copy link
Contributor

agarny commented Mar 29, 2015

A few remarks:

Randall Britten added 4 commits March 30, 2015 10:16
As suggested by @agarny as part of review on #49.
As suggested by @agarny on review comment for #49.
As suggested by @agarny on review comment for #49.
@codecurve
Copy link
Contributor Author

Thanks @agarny
I've renamed to cellml_1_2.*, as you suggested (i.e. starting on lowercase) (see a357443).
I think we plan to support multiple versions of CellML, so it will be necessary to distinguish these, hence the _1_2 for v1.2 is necessary (IMHO).
Yes, I am attempting to follow the Google style guide.
I've changed the use of auto that you highlighted to explicitly stating the type, and also to using a const reference, which is more correct, thanks for suggesting that. (see 2154983)
Last week I asked @hsorby to upgrade the Ubuntu cmake to v3.2, I think he might do it today.
I've eliminated use of using namespace directives (see 4b12cc5)
I've made the comments consistently end with full stops (see c4431f0).
I'm waiting for @hsorby for access to the Windows Build slave to try and work out why it has unresolved symbols during linking, since it links fine on my Windows box.
The "wrong indentation" is required in order to use the raw string literals. For the tests I did when I previously made quite a bit of progress serialising CellML v1.2 models with components, units and variables, I used raw string literals for the expected XML strings, and it is far more readable (see https://github.com/codecurve/libcellml/blob/e7a0fc5fe60be981f82da481710c05d8a473babb/tests/XmlBindingsSerialisationTest.cpp#L14-L21 for example)

Also, copy semantics better than reference for std::string
in this case, I think, since move constructor will be invoked.
@codecurve
Copy link
Contributor Author

@agarny Good catch, thanks, I've addressed that now. (See cf391bb).
I guess it is a matter of taste. My personal guideline is to try and reduce clutter, so if I'm only resolving scope once, no using is needed, but more than once seems to reduce clutter, IMHO.

@codecurve
Copy link
Contributor Author

I've managed to reproduce the failed Windows link on my Windows PC by setting the LIBCELLML_ENABLE_SHARED cmake flag. I'm trying @agarny's suggestion as shown here:
https://github.com/opencor/opencor/blob/master/src/plugins/miscellaneous/Compiler/src/compilerglobal.h#L25
and here
https://github.com/opencor/opencor/blob/master/src/plugins/miscellaneous/Compiler/src/compilerengine.h#L55

@codecurve
Copy link
Contributor Author

Windows build now working, see 89b2f09.

This is in order to get Ubuntu build slave result.
(This will be reverted once cmake update done on build slave).
@agarny
Copy link
Contributor

agarny commented Mar 29, 2015

I seem to remember reading somewhere that there is a need for CMake 3.2, so how come everything is building fine using CMake 3.1.1 on Ubuntu (through BuildBot)?

Otherwise, I can see that there is a warning on the Ubuntu build: http://autotest.bioeng.auckland.ac.nz/libcellml-buildbot/builders/Unit%20Tests%20Builder%20Ubuntu%2014.04%2064%20Bit/builds/86/steps/compile/logs/stdio. I don't know what has been agreed, if anything, regarding warnings, but personally I would consider them as errors (i.e. build libCellML using /WX or -Werror on Windows and Linux/OS X, respectively).

This eliminates the warning on Linux that a deprecated
header was included.
@codecurve
Copy link
Contributor Author

Ubuntu cmake 3.1.1 seems to do mostly the correct thing, but 3.2 is required on Windows and OS X.
I've eliminated the warning, see 799e632.
As for setting the flags so warnings are treated as errors, I'm neutral, but I do think that is a separate issue and pull request, so I'll add an issue for it.

@codecurve
Copy link
Contributor Author

I've added #50 regarding the "compile warnings as errors" question.

DRY (Don't Repeat Yourself) principle: set flags in one place
and reuse from other locations.
@codecurve
Copy link
Contributor Author

"CMake macro for things that are going to be common" - done, see 54de041.
#50 - done, as discussed with @agarny we decided to tack it onto this one, rather than make a separate pull request.

@jonc125
Copy link

jonc125 commented Mar 30, 2015

On the using question, if a particular term is being used multiple times within a single function then it's reasonable to start the function with a using ns1::ns2::term for instance. The downside of doing so at a whole file level is that it's less clear what's in scope, and hence harder to read & reuse code. A using namespace declaration is even worse from this perspective, and even at a function level can lead to issues from scope pollution.

Randall Britten added 2 commits March 31, 2015 09:34
Thanks @agarny for catching that.

Note: Warnings are now treated as errors, and build fails.
Note that the in-memory representation of the model is unused.
I think this is probably OK, since there is only one way of serialising
an empty model anyway.
@hsorby
Copy link
Contributor

hsorby commented Mar 30, 2015

I'm not a big fan of this approach with regards to the bulk setting of the compiler flags. I think this should be set on a per target basis.

The conditional tests for compiler options should be based on the compiler and not the platform.

This is no longer needed:

To work around a bug conditionally set the CXX_STANDARD property

if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
set_target_properties(cellml PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON)
endif()

I don't understand why this header guard has been changed to this:

#ifndef SRC_API_LIBCELLML_VERSION_H_

I would also set the CMAKE_MODULE_PATH and then just include the common.cmake file.

The name of the macro is misleading it really should be set_compiler_flags, and as I said earlier this should be done on per target basis.

@codecurve
Copy link
Contributor Author

codecurve commented Mar 30, 2015 via email

@hsorby
Copy link
Contributor

hsorby commented Mar 30, 2015

The document string in this line isn't correct.

set( CMAKE_CODEBLOCKS_EXECUTABLE "" CACHE INTERNAL "Internalise BUILD_SHARED_LIBS" FORCE )

@codecurve
Copy link
Contributor Author

Done, see b603ca1

(In reply to cellml/libcellml#49 (comment))

@agarny
Copy link
Contributor

agarny commented Apr 1, 2015

Fine by me.

@codecurve
Copy link
Contributor Author

20 hours have passed since all review items have been addressed (as far as I can tell). I think this can be merged, please.

@hsorby
Copy link
Contributor

hsorby commented Apr 2, 2015

the header file ${CMAKE_CURRENT_SOURCE_DIR}/cellml_1_2.h is listed as an API header file but this is not the case

@hsorby
Copy link
Contributor

hsorby commented Apr 2, 2015

the ${CMAKE_INSTALL_PREFIX}/ is not required in the install(FILES command

@codecurve
Copy link
Contributor Author

Done, thanks. See 6896bff.

the header file ${CMAKE_CURRENT_SOURCE_DIR}/cellml_1_2.h is listed as an API header file but this is not the case

It gets prepended anyway, remaining string is a relative path.
@hsorby pointed this out, thanks.
@codecurve
Copy link
Contributor Author

Done, see f7bcb5b

the ${CMAKE_INSTALL_PREFIX}/ is not required in the install(FILES command

@hsorby
Copy link
Contributor

hsorby commented Apr 2, 2015

I have created another pull request onto @codecurve empty-model-01 branch with the changes to the CMake related files that make me happy.

A few other points:

  • I would think the generated files should be in a directory named 'generated' under the source tree
  • the xsd, generate.sh script and xsd-options.txt files placed in a 'utils' directory as a sibling of the src directory
  • the type-naming and function-naming options for the generation be set to 'knr' and not 'java'
    • not so fussed on this it seems you gain a little with the method names but lose on class names (although I do think java sends the wrong message :) )

codecurve and others added 6 commits April 2, 2015 15:08
Changes to CMake related files
…include directories. It would appear gtest is not very conformant to CMake best practices.
Got a bit carried away with my deletions
… into empty-model-01

Conflicts resolved:
	src/CMakeLists.txt
@codecurve
Copy link
Contributor Author

Done, see 49051a6 and 3677047

A few other points:

  • I would think the generated files should be in a directory named 'generated' under the source tree
  • the xsd, generate.sh script and xsd-options.txt files placed in a 'utils' directory as a sibling of the src directory

@codecurve
Copy link
Contributor Author

I chatted with @hsorby, and we agreed that keeping XSD generator options for "type-naming" and "function-naming" set to java is the best option for generated code, knr is too different from our target style, and it is not worth the cost to customise generation to exactly match our target style.

  • the type-naming and function-naming options for the generation be set to 'knr' and not 'java'

Rather than by adding `generated` as include search path.
That way, it is clearer in source code when generated code is
being used.  @hsorby suggested this.
@codecurve
Copy link
Contributor Author

Buildbot fail was not due to any problem in code, but due to download problem.
Passed on Window and Linux slaves, and builds and tests pass on my mac.
Sadly, there is no way yet to trigger a retry of a given build.

@nickerso
Copy link
Contributor

nickerso commented Apr 4, 2015

HI Randall, we can manually trigger a changeset to be redelivered - just ask. In this case though, the download problem for the mac machine is still there.

@codecurve
Copy link
Contributor Author

I have tried to access the Mac build slave that is having trouble with the download, but either my password has been changed, or I forgot it. Anyway, I have a mirror branch in my repo (https://github.com/codecurve/libcellml/tree/empty-model-0-travis-on-02), which has Travis enabled, and as you can see, both Mac and Linux builds passing there. See https://travis-ci.org/codecurve/libcellml/builds/57134328

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

Successfully merging this pull request may close these issues.

5 participants