Relocating a Matlab Compiler project to a directory alongside source tree

2 ビュー (過去 30 日間)
Andrew Janke
Andrew Janke 2018 年 6 月 19 日
コメント済み: Andrew Janke 2021 年 8 月 30 日
I have a large codebase that I compile using a few *.prj Matlab Compiler project files. I would like to relocate the *.prj files into their own subdirectory to keep my project's repo structure tidy. But when I do so, every time I run the compiler, it adds a big fileset.depfun section containing the absolute paths to all the *.m files in my source tree. And it changes the target output directory.
How can I keep it from doing this?
Here are the details:
I'm on Windows running Matlab R2016b.
We'll call my program the Foo application.
My current source tree layout is this:
  • C:\Foo - the main directory I do all my project stuff in
  • C:\Foo\*.prj - the current location of my project files (outside of source control)
  • C:\Foo\trunk - the Subversion-controlled working directory where I check out my source tree
  • C:\Foo\trunk\src - where all my M-files for the project live
I want to change it to be like this:
  • C:\Foo - the main directory I do all my project stuff in
  • C:\Foo\trunk - the Subversion-controlled working directory where I check out my source tree
  • C:\Foo\trunk\tools - where I keep my build & release tools (in source control now)
  • C:\Foo\trunk\tools\*.prj - new home for all those Matlab Compiler project files
  • C:\Foo\trunk\src - where all my M-files for the project live, same as before
When I moved the *.prj files over to this new structure, I opened them up in a text editor and manually edited the paths in them.
<deployment-project plugin="plugin.ezdeploy" plugin-version="1.0">
<configuration build-checksum="2118345216" file="C:\Foo\trunk\tools\FooSdk.prj" location="C:\Foo\trunk\tools" name="FooSdk" preferred-package-location="C:\Foo\FooSdk\for_redistribution" preferred-package-type="package.type.exe" target="target.ezdeploy.library" target-name="Library Compiler">
...
<fileset.exports>
<file>${PROJECT_ROOT}\..\compiled\sdk\net\Configuration.m</file>
<file>${PROJECT_ROOT}\..\compiled\sdk\net\EntryGateway.m</file>
</fileset.exports>
<fileset.classes>
<entity.package name="">
<entity.class name="FooSdk">
<file>${PROJECT_ROOT}\..\compiled\sdk\net\EntryGateway.m</file>
</entity.class>
</entity.package>
</fileset.classes>
<fileset.resources>
<file>${MATLAB_ROOT}\toolbox\local\pathdef.m</file>
<file>${MATLAB_ROOT}\toolbox\local\userpath.m</file>
<file>${PROJECT_ROOT}\..\lib</file>
<file>${PROJECT_ROOT}\..\src</file>
</fileset.resources>
...
<build-deliverables>
<file location="${PROJECT_ROOT}\..\..\RmaSdk\for_testing" name="RmaSdk.dll" optional="false">C:\RMAStudio\RmaSdk\for_testing\RmaSdk.dll</file>
<file location="${PROJECT_ROOT}\..\..\RmaSdk\for_testing" name="readme.txt" optional="true">C:\RMAStudio\RmaSdk\for_testing\readme.txt</file>
<file location="${PROJECT_ROOT}\..\..\RmaSdk\for_testing" name="RmaSdk_overview.html" optional="false">C:\RMAStudio\RmaSdk\for_testing\RmaSdk_overview.html</file>
<file location="${PROJECT_ROOT}\..\..\RmaSdk\for_testing" name="RmaSdkNative.dll" optional="false">C:\RMAStudio\RmaSdk\for_testing\RmaSdkNative.dll</file>
</build-deliverables>
When I opened up the project file in the App Compiler App, it succeeded in compiling the library without any settings changes. But then when the compilation was complete and I tried to close the dialog, it asked me if I wanted to save my changes. I chose Yes, and then when I looked at the project file afterwards, it had a new fileset.depfun element with 1400 files in it, all with absolute paths, like this:
<fileset.depfun>
<file>C:\Foo\trunk\src\+foo\+assetmodel\+outage\+whatever\constant.m</file>
<file>C:\Foo\trunk\src\+foo\+assetmodel\+outage\+whatever\derate.m</file>
<file>C:\Foo\trunk\src\+foo\+assetmodel\+outage\+whatever\emergency.m</file>
<file>C:\Foo\trunk\src\+foo\+assetmodel\+outage\+whatever\object.m</file>
<file>C:\Foo\trunk\src\+foo\+assetmodel\+outage\+whatever\outage.m</file>
<file>C:\Foo\trunk\src\+foo\+assetmodel\+outage\+model\constant.m</file>
...
and preferred-package-location had changed:
<configuration build-checksum="120092597" file="C:\Foo\trunk\tools\FooSdk.prj" location="C:\Foo\trunk\tools" name="FooSdk" preferred-package-location="C:\Foo\trunk\tools\FooSdk\for_redistribution" preferred-package-type="package.type.exe" target="target.ezdeploy.library" target-name="Library Compiler">
and the build-deliverables locations had changed.
<build-deliverables>
<file location="${PROJECT_ROOT}\FooSdk\for_testing" name="FooSdkNative.dll" optional="false">C:\Foo\trunk\tools\FooSdk\for_testing\FooSdkNative.dll</file>
<file location="${PROJECT_ROOT}\FooSdk\for_testing" name="readme.txt" optional="true">C:\Foo\trunk\tools\FooSdk\for_testing\readme.txt</file>
<file location="${PROJECT_ROOT}\FooSdk\for_testing" name="FooSdk.dll" optional="false">C:\Foo\trunk\tools\FooSdk\for_testing\FooSdk.dll</file>
<file location="${PROJECT_ROOT}\FooSdk\for_testing" name="FooSdk_overview.html" optional="false">C:\Foo\trunk\tools\FooSdk\for_testing\FooSdk_overview.html</file>
</build-deliverables>
Is there any way to get it to not do that?
  3 件のコメント
Andrew Janke
Andrew Janke 2019 年 3 月 3 日
Nope. I ended up just sticking all my *.prj files in the root of my source tree, and apologizing to my coworkers for the clutter. Sorry.
Andrew Janke
Andrew Janke 2021 年 8 月 30 日
I think this might have broader implications: the baking in of absolute paths into the Matlab Compiler .prj files makes it difficult for a Matlab Compiler project to be shared between multiple developers, who might want to check out the repo to different locations on their disks. In particular, developers might want to check out the repo to somewhere under their home directory (I think this is pretty common). On all 3 big OSes, the username is part of the absolute path to locations under a user's home directory, so this baking-in means that you can't easily share project files between users who have different usernames. And most users do have different usernames.
In my MatlabProjectTemplate thingie (https://github.com/janklab/MatlabProjectTemplate) I addressed this by creating a .prj.in template file that has relative paths in it, which are munged in to absolute paths in a generated .prj file at build time.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Compiler についてさらに検索

製品


リリース

R2016b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by