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

Commands for CMake #3

Merged
merged 24 commits into from
Apr 8, 2021
Merged

Conversation

iguessthislldo
Copy link
Member

@iguessthislldo iguessthislldo commented Dec 12, 2018

Added cmake, print_cmake_version, and cmake_cmd commands, new <arg> syntax, and tests for the new changes. Simplest use of cmake command is:

<command name="cmake" dir="the_project"/>

Where the_project is the directory with the CMakeLists.txt file to build. Default parameters can be changed using new <arg> tags. This is equivalent to the command above:

<command name="cmake" dir="the_project">
  <arg name="build_dir">build</arg>
  <arg name="config_args">..</arg>
  <arg name="build_args">--build .</arg>
</command>

Also added a separate command to invoke CMake directly:

<command name="cmake_cmd" options="-E capabilities"/>

Also changed the file_manipulation command to support the new <arg> tags while keeping it compatible with the previous behavior. These two commands are equivalent:

<command name="file_manipulation" options="type=create file=file.txt">
 <arg name="output">
if (x &gt; 5)
 print("Greater than 5");
 </arg>
</command>
<command name="file_manipulation"  options="type=create file=file.txt">
if (x &gt; 5)
  print("Greater than 5");
</command>

@iguessthislldo iguessthislldo reopened this Jan 1, 2020
@iguessthislldo
Copy link
Member Author

I've reopened this because I would like to be able to use these commands now. I don't completely remember why I closed it. I think it was that I didn't like you manually to change directories to and back as show in the example above, where as with anonymous shell you can cd in each command and it will automatically come back. I don't think I can simplify any more though, so I'm fine with how it is now.

@iguessthislldo
Copy link
Member Author

Alternatively I could merge all these actictions:

  <command name="file_manipulation" options="type=rmmkcd file=build"/>
  <command name="cmake" options=".."/>
  <command name="cmake" options="--build ."/>
  <command name="file_manipulation" options="type=chdir"/>

into the cmake command, so it would look something like:

  <command name="cmake" options="replace=build .."/>

@mitza-oci
Copy link
Member

Alternatively I could merge all these actictions:

  <command name="file_manipulation" options="type=rmmkcd file=build"/>
  <command name="cmake" options=".."/>
  <command name="cmake" options="--build ."/>
  <command name="file_manipulation" options="type=chdir"/>

into the cmake command, so it would look something like:

  <command name="cmake" options="replace=build .."/>

I like the alternative you've shown here. That seems to fit with the way most of the autobuild commands work.

@iguessthislldo
Copy link
Member Author

The only issue I have with that approach is that I would like to address three different kinds of options: the output directory name/location, the arguments to cmake and the arguments to cmake --build and I would like to be able to define them all, but I'm not sure how to that.

@mitza-oci
Copy link
Member

The only issue I have with that approach is that I would like to address three different kinds of options: the output directory name/location, the arguments to cmake and the arguments to cmake --build and I would like to be able to define them all, but I'm not sure how to that.

Many autobuild commands use <variable> XML elements to set additional parameters.

Or how about something like this, a hybrid of the options you discussed before:

  <command name="file_manipulation" options="type=rmmk file=build"/>
  <command name="cmake" options="dir=build .."/>
  <command name="cmake" options="dir=build --build ."/>

@iguessthislldo
Copy link
Member Author

Another idea is to extend the parser to accept tags inside the command tag like so:

<command name="cmake"/>
  <opt name="dir">build_dir_name</option>
  <opt name="config_args">--an-arg-for-config ..</opt>
  <opt name="build_args">--another-arg-for-build</opt>
</command>

This would have to resolved with #19, so I'm thinking it could be generalized that values inside the options attribute of command could be also be passed as separate opt tags:

<command name="file_manipulation"  options="type=create file=setenv.sh">
  <opt name="output">
export ACE_ROOT="${ACE_WORKSPACE}/ATCD/ACE"
export CIAO_ROOT="${ACE_WORKSPACE}/ATCD/CIAO"
export DANCE_ROOT="${ACE_WORKSPACE}/ATCD/DAnCE"
export DDS_ROOT="${WORKSPACE}/OpenDDS"
export LD_LIBRARY_PATH="/usr/sfw/lib:/usr/local/lib:${WORKSPACE}/OpenDDS/lib:${ACE_WORKSPACE}/ATCD/ACE/lib:"
export MPC_ROOT="/home/taoadmin/MPC"
export OPENDDS_RTPS_DEFAULT_D0="146"
export PATH="${WORKSPACE}/OpenDDS/bin:${ACE_WORKSPACE}/ATCD/ACE/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/ccs/bin:"
export TAO_ROOT="${ACE_WORKSPACE}/ATCD/TAO"
  </opt>
</command>

@mitza-oci
Copy link
Member

That seems like more than you really need. Can it parse XML Attributes?

<command name="cmake" dir="build_dir_name" config_args="args1" build_args="args2"/>

command/file_manipulation.pm Outdated Show resolved Hide resolved
command/file_manipulation.pm Outdated Show resolved Hide resolved
command/file_manipulation.pm Outdated Show resolved Hide resolved
@iguessthislldo
Copy link
Member Author

That seems like more than you really need. Can it parse XML Attributes?

Yes, but they'd be common to all command tags, so I don't think that's the right way to extend this. There is already a dir (with other names) attribute. I'd have to see what it does now, but it makes sense to reuse that if possible. For the cmake specific stuff, I checked the <opt> tag code I have locally that I haven't push is almost done, just needs to be cleaned up. I really think it's the way to go instead of continuing to shove things inside the attributes.

@iguessthislldo
Copy link
Member Author

So I realized chdir isn't necessary in other commands other than cmake because the dir command attribute seems to change the directory in a lot of commands. chdir command also doesn't work with these other commands how it is now because the commands are calling chdir($root) at the start to support the dir attribute. I thought it was working because it was working with cmake, but that's because I don't have that chdir call.

So I'm going to remove chdir in addition to rmmkcd and have cmake support dir.

This also adds new syntax for <arg> tags that go inside <command> tags.
This has been made backwards compatible with the syntax from
DOCGroup#19 which also uses the
contents of <command> tags as file output.

Finally this also adds a `cmake_cmd` to directly invoke CMake.
@iguessthislldo
Copy link
Member Author

Okay so I took the existing work I had locally and cleaned it up. I also renamed opt tags to arg to attempt to avoid confusion with the options attribute, though I'm not sure how much it helps. Using the dir attribute, the most complicated cmake command looks like this:

<command name="cmake" dir="the_project">
  <arg name="build_dir">build</arg>
  <arg name="config_args">..</arg>
  <arg name="build_args">--build .</arg>
</command>

But if using all the default args like above, it can just be this:

<command name="cmake" dir="the_project"/>

Also added a separate command to invoke CMake directly:

<command name="cmake_cmd" options="-E capabilities"/>

Unlike what I previously stated over a year ago, I was able to keep file_manipulation backwards compatible and make it able to accept the new <arg> tags, so the following two are equivalent:

<command name="file_manipulation" options="type=create file=file.txt">
 <arg name="output">
if (x &gt; 5)
 print("Greater than 5");
 </arg>
</command>
<command name="file_manipulation"  options="type=create file=file.txt">
if (x &gt; 5)
  print("Greater than 5");
</command>

This allows new args to be added to file_manipulation in the future.

Finally I added tests and a workflow to run them. They are fairly basic, but at least it's something. I was thinking we could also add simple scoreboard tests since we've been having trouble with that lately.

@iguessthislldo iguessthislldo changed the title Added print_cmake_version and cmake commands Added print_cmake_version and cmake commands Mar 25, 2021
@iguessthislldo iguessthislldo changed the title Added print_cmake_version and cmake commands Added print_cmake_version and cmake commands Mar 25, 2021
@iguessthislldo iguessthislldo changed the title Added print_cmake_version and cmake commands Commands for CMake Mar 25, 2021
command/cmake.pm Outdated Show resolved Hide resolved
command/cmake.pm Outdated Show resolved Hide resolved
command/print_cmake_version.pm Outdated Show resolved Hide resolved
@iguessthislldo iguessthislldo merged commit 9d0f025 into DOCGroup:master Apr 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants