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

Cross Platform Build System #48

Closed
peschkaj opened this issue Oct 14, 2012 · 9 comments
Closed

Cross Platform Build System #48

peschkaj opened this issue Oct 14, 2012 · 9 comments

Comments

@peschkaj
Copy link
Contributor

Placeholder for discussion about how to best create cross-platform builds for CorrugatedIron.

@OJ
Copy link
Contributor

OJ commented Oct 14, 2012

I'm happy to be the first to chime in.

Right now, CI is a single binary. While it has deps now that live in the source tree, the work I've done for 1.2 support includes the removal of these. So we are literally on single DLL being built.

In my humble opinion bringing in a build system for this is overkill. If we keep everything in the VS2010 solution then

  • On WIndows single .cmd file can invoke msbuild which can build the entire project from scratch using the .sln file.
  • For mono users a single shell script can kick off xbuild which can do exactly the same thing.
  • A batch file or PS script can the generate nuget package and pull the version from the DLL.

Outside of this, I have no idea what else is needed, or why. I think that this is all that's needed. It's simple, requires very little to no maintenance and already work snow (we just need to tidy it up a bit).

I'm keen to hear the reasons for bringing in any build system when the library that we're creating it so simple.

Cheers!

@Iristyle
Copy link

I left a few comments over here -> #47 (comment)

I agree with the concept of keep it simple as well... but you might want to think about taking the steps necessary to automate this on TravisCI so that you can verify Mono support.

@peschkaj
Copy link
Contributor Author

What's the set up effort around TravisCI look like? I haven't gotten around to setting it up, yet. Right now, Mono verification happens on my laptop. Mono 3.0 hitting full release should change some aspects of what we do, as well.

@Iristyle
Copy link

Add a .travis.yml file, and tell Travis to build it for you.

From the other thread, here's how libgit2sharp does it. I assume they're using the CMake b/c they're working off of libgit2 C bindings and need to do a mixed mode asm. Obviously that's not necessary for Corrugated Iron.

# Travis-CI Build for libgit2sharp
# see travis-ci.org for details

language: c

# Make sure CMake is installed
install:
 - sudo apt-get install cmake mono-devel mono-gmcs

# Run the Build script
script:
 - git submodule update --init
 - mkdir cmake-build
 - cd cmake-build
 - cmake -DTHREADSAFE=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_CLAR=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=./libgit2-bin ../libgit2
 - export LD_LIBRARY_PATH=$PWD/libgit2-bin/lib
 - cmake --build . --target install
 - cd ..

# Run Tests
after_script:
 - xbuild CI-build.msbuild /t:Deploy

# Only watch the development branch
branches:
 only:
   - vNext

# Notify development list when needed
notifications:
 recipients:
   - emeric.fermas@gmail.com
 email:
   on_success: change
   on_failure: always

Their msbuild script is pretty basic as well

<Project DefaultTargets="Deploy" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition="'$(Configuration)' == ''">Release</Configuration>
    <RootDir>$(MSBuildProjectDirectory)</RootDir>
    <TestBuildDir>$(RootDir)\LibGit2Sharp.Tests\bin\$(Configuration)</TestBuildDir>
    <DeployFolder>$(RootDir)\Build</DeployFolder>
  </PropertyGroup>

  <UsingTask AssemblyFile="$(MSBuildProjectDirectory)/Lib/xUnit/xunit.runner.msbuild.dll"
               TaskName="Xunit.Runner.MSBuild.xunit" />
  <Target Name="Clean">
    <Message Text="Commit SHA = $(CommitSha)" />

    <WriteLinesToFile Condition="'$(CommitSha)' != ''"
        File="$(RootDir)\LibGit2Sharp\libgit2sharp_hash.txt"
        Lines="$(CommitSha)"
        Overwrite="true" />

    <!-- Workaround for xbuild -->
    <Exec Condition=" ('$(OS)' != 'Windows_NT') " Command=" rm -r -f $(DeployFolder) " />
    <Exec Condition=" ('$(OS)' != 'Windows_NT') " Command=" rm -r -f $(TestBuildDir) " />

    <RemoveDir Directories="$(DeployFolder)" Condition="Exists('$(DeployFolder)')" />
    <RemoveDir Directories="$(TestBuildDir)" Condition="Exists('$(TestBuildDir)')" />
  </Target>

  <Target Name="Init" DependsOnTargets="Clean">
    <MakeDir Directories="$(DeployFolder)" />
  </Target>

  <Target Name="Build" DependsOnTargets="Init">
    <MSBuild
      Projects="LibGit2Sharp.sln"
      Targets="Build"
      Properties="Configuration=$(Configuration);TrackFileAccess=false" />
  </Target>

  <Target Name="Test" DependsOnTargets="Build">
    <xunit Assembly="$(TestBuildDir)/LibGit2Sharp.Tests.dll" Xml="$(DeployFolder)/Test-result.xml" />
  </Target>

  <Target Name="Deploy" DependsOnTargets="Test">
    <CreateItem Include="$(TestBuildDir)\LibGit2*.*">
        <Output TaskParameter="Include" ItemName="OutputFiles" />
    </CreateItem>
    <Copy SourceFiles="@(OutputFiles)"
        DestinationFiles="@(OutputFiles->'$(DeployFolder)\%(RecursiveDir)%(Filename)%(Extension)')" />

    <CreateItem Include="$(TestBuildDir)\NativeBinaries\**\*.*">
        <Output TaskParameter="Include" ItemName="NativeBinaries" />
    </CreateItem>
    <Copy SourceFiles="@(NativeBinaries)"
      DestinationFiles="@(NativeBinaries->'$(DeployFolder)\NativeBinaries\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
  </Target>
</Project>

@OJ
Copy link
Contributor

OJ commented Nov 17, 2012

Thanks for this info! I'm sure it'll be a big help. At this point we're going to for simple. Command line scripts to build and wired into Travis, as suggested, to get CI builds going so that the world can see that things are working. This will include the non-live tests (live tests would be a bit hard to verify).

I'll be aiming to get this included when we finish 1.0.

@Iristyle
Copy link

I'm going to Well, Actually you ;0

You can do live db tests under Travis tests by including

services:
  - riak

@OJ
Copy link
Contributor

OJ commented Nov 17, 2012

Very nice! Thanks for the reference. Perhaps we shall consider wiring those live tests in as well :)

Thanks for the Well, Actually.. :)

@OJ
Copy link
Contributor

OJ commented Dec 6, 2012

So the decision for v1.0.0 is to stick with what we have. That is, we'll use our command line scrips that work on *nix and Windows. On Windows a nuget package is generated as well.

A single build script which builds the projects is more than enough for now. I might put something in down the track to run the tests.

Down the track we'll enhance this to run unit tests and get it into Travis CI. I'll leave this issue open so that we address it later on but I'm going to remove it from the v1.0 milestone.

Cheers!

@peschkaj
Copy link
Contributor Author

Existing hackery of shell scripts seems to work well. Closing this issue as worksforme

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

No branches or pull requests

3 participants