Skip to content

Commit

Permalink
ONE BUILD SCRIPT TO RULE THEM ALL!
Browse files Browse the repository at this point in the history
Adds a cross-platform script that automates the process of creating a
build directory and compiling MuseScore. Run the script like this:

    $ cmake -P build.cmake [args...]

This works in all shells on all platforms. Developers with a Unix-like
environment (including Git Bash on Windows) can also use:

    $ ./build.cmake [args...]

Build step arguments:

    clean       Delete the build directory.
    configure   Create a build directory and run CMake inside it.
    build       Compile code using the native build tool.
    install     Copy compiled files to final destinations.
    run         Run the installed program.

Each step implies all previous steps except 'clean' and 'run', which
are only performed when explictly requested. If no steps are given then
the configure, build, and install steps are performed by default.

All other arguments are passed to CMake during configuration.

Example command:

    $ cmake -P build.cmake -GNinja -DCMAKE_BUILD_TYPE=Debug
    $ cmake -P build.cmake -GNinja -DCMAKE_BUILD_TYPE=Debug run -F

This creates and installs a Debug build using the Ninja generator, and
then runs the compiled program with the -F option to perform a factory
reset, thereby ensuring it is in the initial state.

Overrides:

If you frequently need to build with non-default settings then you can
create a file build_overrides.cmake with all your personal settings to
avoid having to pass them in on the command line each time.

    # build_overrides.cmake example file

    set(ENV{QTDIR} "$ENV{HOME}/Qt/5.15.2/gcc_64")
    list(APPEND CONFIGURE_ARGS -GNinja -DCMAKE_BUILD_TYPE=Debug)

This file is ignored by Git to prevent it being shared with other
developers, but you could always copy another file into its place
(e.g. during a CI build on GitHub Actions).
  • Loading branch information
shoogle authored and igorkorsukov committed Mar 5, 2021
1 parent 4be754d commit 18f8578
Show file tree
Hide file tree
Showing 10 changed files with 476 additions and 71 deletions.
12 changes: 11 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
build/PortableApps/**/*.ini eol=crlf
build/PortableApps/**/*.txt eol=crlf
build/PortableApps/**/*.ini.in eol=crlf
build/PortableApps/**/*.html eol=crlf
build/PortableApps/**/*.html eol=crlf

# Shell scripts with shebang lines must have LF line endings
*.sh text eol=lf
*.py text eol=lf
*.ps1 text eol=lf
build.cmake text eol=lf

# Batch files need CRLF line endings
*.bat text eol=crlf
*.cmd text eol=crlf
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*.autosave
.qped
.directory
/builds
/build_overrides.cmake
build.release
build.debug
build.install
Expand Down
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#=============================================================================

$(warning DEPRECATION NOTICE. This method of compiling will soon be removed.)
$(warning )
$(warning Please use 'build.cmake' instead:)
$(warning )
$(warning $ $$ ./build.cmake)
$(warning )
$(warning See https://github.com/musescore/MuseScore/pull/7531 for details.)
$(warning )

CPUS := $(shell getconf _NPROCESSORS_ONLN 2>/dev/null || getconf NPROCESSORS_ONLN 2>/dev/null || echo 1)

PREFIX = "/usr/local"
Expand Down Expand Up @@ -191,7 +200,7 @@ portable: install

installdebug: debug
cd build.debug \
&& make install
&& make install

uninstall:
cd build.release \
Expand Down Expand Up @@ -231,5 +240,3 @@ unix:

zip:
zip -q -r MuseScore-${VERSION}.zip * -x .git\* -x vtest/html\*


11 changes: 9 additions & 2 deletions Makefile.mingw
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#=============================================================================

$(warning DEPRECATION NOTICE. This method of compiling will soon be removed.)
$(warning )
$(warning Please use 'build.cmake' instead with these options:)
$(warning )
$(warning $ $$ cmake -P build.cmake -G "MinGW Makefiles")
$(warning )
$(warning See https://github.com/musescore/MuseScore/pull/7531 for details.)
$(warning )

VERSION := $(cmake -P config.cmake | sed -n -e "s/^.*VERSION *//p")
BUILD_NUMBER=""
CPUS = %NUMBER_OF_PROCESSORS%
Expand Down Expand Up @@ -59,5 +68,3 @@ version:

clean:
-rmdir /S/Q build.debug build.release win32install


12 changes: 10 additions & 2 deletions Makefile.osx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#=============================================================================

$(warning DEPRECATION NOTICE. This method of compiling will soon be removed.)
$(warning )
$(warning Please use 'build.cmake' instead with these options:)
$(warning )
$(warning $ $$ ./build.cmake -G Xcode)
$(warning )
$(warning See https://github.com/musescore/MuseScore/pull/7531 for details.)
$(warning )

VERSION := $(cmake -P config.cmake | sed -n -e "s/^.*VERSION *//p")
BUILD_NUMBER = ""
PREFIX=../applebuild
Expand Down Expand Up @@ -104,12 +113,11 @@ ci:
-DCRASH_REPORT_URL="${CRASH_REPORT_URL}" \
.. -G Xcode; \
xcodebuild -project ${XCODEPROJ} -target lrelease; \
$(FORMATTER_START) xcodebuild -project ${XCODEPROJ} -configuration Release -target install $(FORMATTER_END);
$(FORMATTER_START) xcodebuild -project ${XCODEPROJ} -configuration Release -target install $(FORMATTER_END);

#
# clean out of source build
#
clean:
-rm -rf build.release build.debug build.xcode
-rm -rf applebuild

29 changes: 14 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![MuseScore](assets/musescore_logo_full.png)
![MuseScore](assets/musescore_logo_full.png)
Music notation and composition software

[![License: GPL v2](https://img.shields.io/badge/License-GPL%20v2-blue.svg)](https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
Expand Down Expand Up @@ -45,30 +45,29 @@ Otherwise, you can just download the latest source release tarball from the [Rel
cd MuseScore-x.x.x

### Release Build
To compile MuseScore, type:
To compile MuseScore for release, type:

make release
cmake -P build.cmake -DCMAKE_BUILD_TYPE=Release

If something goes wrong, then remove the whole build subdirectory with `make clean` and start new with `make release`.
If something goes wrong, append the word "clean" to the above command to delete the build subdirectory:

### Running
To start MuseScore, type:
cmake -P build.cmake -DCMAKE_BUILD_TYPE=Release clean

./build.release/mscore/mscore
Then try running the first command again.

The Start Center window will appear on every invocation until you disable that setting via the "Preferences" dialog.
### Running
To start MuseScore, type:

### Installing
To install to default prefix using root user, type:
cmake -P build.cmake -DCMAKE_BUILD_TYPE=Release run

sudo make install
Or run the compiled executable directly.

### Debug Build
A debug version can be built by doing `make debug` instead of `make release`.

To run the debug version, type:
A debug version can be built and run by replacing `-DCMAKE_BUILD_TYPE=Release`
with `-DCMAKE_BUILD_TYPE=Debug` in the above commands.

./build.debug/mscore/mscore
If you omit the `-DCMAKE_BUILD_TYPE` option entirely then `RelWithDebInfo` is
used by default, as it provides a useful compromise between Release and Debug.

### Testing
See [mtest/README.md](/mtest/README.md) or [the developer handbook](https://musescore.org/handbook/developers-handbook/finding-your-way-around/automated-tests) for instructions on how to run the test suite.
Expand Down
Loading

0 comments on commit 18f8578

Please sign in to comment.