Commit Graph

524 Commits

Author SHA1 Message Date
Max Radermacher
faea3c50bf Fix l10n_lint URL 2022-05-20 10:12:52 -07:00
Max Radermacher
bbb69e8d74 Check for malformed .stringsdict files
If they’re malformed, Xcode builds will fail while trying to copy the
plist files to the bundle.
2022-05-20 10:12:52 -07:00
Jordan Rose
e9b6439518 Un-nest builders for our proto wrapper types
We expose many of these builders to Objective-C, but Swift is unable
to map forward-declarations of those types (@class) back to the real
Swift classes because they're nested within the protos. Since we're
already using fully-qualified names even in Swift (e.g.
"SSKProtoContentBuilder"), nesting isn't worth the trouble it's
causing.
2022-05-19 15:40:21 -07:00
Max Radermacher
a55da92c2b Add script to symbolicate .ips files 2022-05-19 12:56:08 -07:00
Martin Böttcher
89dbebe442 mixing the pluralaware strings uses the main language if appropriate 2022-05-18 11:02:45 -07:00
Martin Böttcher
0269dacd11
improved placeholder checks (#4306) 2022-05-12 08:41:50 +02:00
Ehren Kret
98e3f8d742 Fix update_plist_info.sh to not assume no decorate on git log 2022-05-10 19:49:30 -05:00
Martin Böttcher
d012924c71
added placeholder checks (#4295) 2022-05-10 19:50:56 +02:00
Evan Hahn
7149dd6c99 Autoformat precommit script
This auto-formats the precommit script with [Black][0]. I made no manual
changes as part of this commit.

[0]: https://github.com/psf/black
2022-05-10 12:40:13 -05:00
Evan Hahn
8170bacc0f Harden upload_metadata script
This change:

- Fixes some warnings reported by [Shellcheck][0]. Notably, if your repo
  is in a folder with a space (e.g., `/Users/foo/My Code/Signal-iOS`),
  this script wouldn't work.
- Adds `set -u` to error when using unbound variables, in case we make a
  mistake
- Adds `set -o pipefail` to error if piping fails. Not used by this
  script, but I put this line in all my shell script just in case

Tested this when taking 5.37.0 to production and it worked fine.

[0]: https://www.shellcheck.net/
2022-05-05 10:13:47 -05:00
Evan Hahn
df8592fa23 Fix SwiftLint switch_case_alignment violations
_I recommend reviewing this with whitespace changes disabled._

Bad:

```swift
switch foo {
    case .one: return 1
    case .two: return 2
}
```

Good:

```swift
switch foo {
case .one: return 1
case .two: return 2
}
```

See [the rule's documentation][0] for more.

[0]: https://realm.github.io/SwiftLint/switch_case_alignment.html
2022-05-03 12:15:05 -05:00
Evan Hahn
5be42da750 Change references from master to main
_I recommend reviewing this with whitespace changes disabled._

Signal has renamed its primary branch to `main`. This updates references
to the old name, `master`, to either reference `main` or a specific
commit hash.

I also fixed a couple of small whitespace issues in a file I was
editing.
2022-05-02 10:30:40 -05:00
Evan Hahn
421b69ce21 Ignore some 5.36 tags in reverse integration check script
We cherry-picked stuff into that branch, rather than the other way
around.
2022-04-28 17:01:23 -05:00
Martin Böttcher
54b743de2d
moved older stringsdict changes into new branch; minor changes (#4205)
moved older stringsdict changes into new branch
2022-04-28 17:41:43 +02:00
Evan Hahn
72a05b2be1 Revert "Speed up compilation by tweaking emoji code"
This reverts commit 3c26cb56f7, because it
caused compilation to slow down (the opposite of the original goal!).
2022-04-25 12:41:59 -07:00
Evan Hahn
3c26cb56f7 Speed up compilation by tweaking emoji code
I profiled our Swift code with the following flags:

    -Xfrontend -warn-long-function-bodies=100 -Xfrontend -warn-long-expression-type-checking=100

Lots of stuff took longer than 100ms, but only one function took longer
than 10 seconds: `EmojiWithSkinTones#init(rawValue: String)` took 12
seconds. Presumably, this was because it had a call to `self.init` once
per emoji. Now we do it once, which cuts the compile time from ~12.3
seconds to ~1.9.

There was another long-running one, `emojiPerSkinTonePermutation`, which
also took a fairly long time, and this cut it down a bit.

There's more we can do to speed up our builds (see links below) and this
shouldn't change incremental ones much (unless you're changing these
files) but it was low-hanging fruit.

Resources to speed up builds, some of which are old:

- ["Build performance analysis for speeding up Xcode builds"][0]
- ["Improving the Speed of Incremental Builds"][1]
- ["How to make Swift compile faster"][2]
- ["Speed up Swift compile time"][3]
- ["Optimizing Swift build times"][4]
- ["Improving Swift compile times"][5]
- ["Regarding Swift build time optimizations"][6]

[0]: https://www.avanderlee.com/optimization/analysing-build-performance-xcode/
[1]: https://developer.apple.com/documentation/xcode/improving-the-speed-of-incremental-builds
[2]: https://www.hackingwithswift.com/articles/11/how-to-make-swift-compile-faster
[3]: https://medium.com/hackernoon/speed-up-swift-compile-time-6f62d86f85e6
[4]: https://github.com/fastred/Optimizing-Swift-Build-Times
[5]: https://www.swiftbysundell.com/articles/improving-swift-compile-times/
[6]: https://medium.com/@RobertGummesson/regarding-swift-build-time-optimizations-fc92cdd91e31
2022-04-23 11:27:39 -05:00
Evan Hahn
32476f0fa7 Improve script to find unused strings
This script broke in the migration to Python 3 (see
1101db6a29). This change fixes those bugs,
and also:

1. Allows you to supply multiple source directories. Previously, you
   could only provide one, which meant that you'd see lots of unused
   strings, even though they were used in a different folder.
2. Adds usage instructions with `--help`, thanks to Python's `argparse`
   module.
3. Quits with a `1` status code if any unused strings are found.
4. Prints unused strings instead of used ones.
5. Speeds up the script by only searching for keys. Previously, it'd
   also look for comments and blank lines in the `Localizable.strings`
   file.
6. Speeds up the script by only reading files once, instead of once per
   key.
2022-04-15 15:28:15 -05:00
Jordan Rose
49608044b7 SSK: Remove obsolete OWSMessageDecryptJob
This hasn't been used since before GRDB.
2022-04-11 14:46:43 -07:00
Evan Hahn
8b072620a6 Add "Donation Receipts" view 2022-04-11 16:21:12 -05:00
Evan Hahn
b739f739e7 Fix Python deprecation warning in reverse integration check script
This quiets the following deprecation warning:

    ./Scripts/reverse_integration_check.py:56: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
      tag for tag in unmerged_tags if LooseVersion(tag) > LooseVersion(epoch_tag)

[`distutils.LooseVersion` will be removed in Python 3.12][0], and there
doesn't seem to be an equivalent in the standard library. I implemented
a simple `Version` class to replicate this functionality.

(I also looked into other solutions, such as rewriting the script in
Swift, but this seems like the right solution for now.)

[0]: https://peps.python.org/pep-0632/
2022-04-09 16:36:44 -05:00
Evan Hahn
7b09dc609e Ignore 5.23.0.22-beta tag in reverse integration check script
This adds `5.23.0.22-beta` to our list of ignored tags, to avoid this error when running the script:

    RuntimeError: 💥 Found unmerged tags: ['5.23.0.22-beta']

We saw this error when deploying 5.25.
2022-04-09 16:31:48 -05:00
Jordan Rose
8c1a31e094 auto-genstrings: Fix OWSLocalizedString breakage
genstrings warns on non-constant strings being passed to
NSLocalizedString, but that happens precisely when we define
OWSLocalizedString. Skip the two files where we define it (one for
each language).

While here:
- Use find's -exec feature rather than a separate xargs invocation.
- Make the script shellcheck-clean.
2022-04-05 10:48:05 -07:00
Michelle Linington
0f3a2b4c2e Perform emoji mapping in EmojiGenerator 2022-04-01 14:55:30 -07:00
Nora Trapp
378cc730d1 codegen 2022-03-31 00:37:56 -07:00
Nora Trapp
014fe25b16 sds codegen 2022-03-31 00:34:33 -07:00
Nora Trapp
536c7170df sds codegen 2022-03-31 00:34:32 -07:00
Nora Trapp
e95e392494 Add story context to TSInteraction 2022-03-31 00:34:32 -07:00
Evan Hahn
e8b4b8f15c Scripts: subprocess.check_output should use text=True for compatibility
In Python 2, `subprocess.check_output` returns a string. In Python 3, it
returns a byte string unless you provide `text=True`.

This makes sure all calls have that option for compatibility.

Also, my editor was auto-formatting these with [Black][0], which I
didn't prevent, so now these files are formatted a little better.

[0]: https://github.com/psf/black
2022-03-24 17:28:12 -05:00
Evan Hahn
16aa421d3e More Python 3 script fixes 2022-03-24 10:28:27 -05:00
Evan Hahn
d7c33eb211 Speed up pre-commit script
On my machine, the `./precommit.py --all` took 344.15 seconds (more than
5 minutes). This change speeds it up so that it takes less than 10
seconds.

It primarily achieves this by running `swiftlint` twice instead of twice
per file. There are some other smaller changes, too:

- Use a `set` for common operations
- Avoid a needless call to `text.split`
- Use built-in `pathlib.Path().parts` instead of a home-rolled solution

Tested this by running `./precommit.py` with all flags.
2022-03-23 09:43:21 -05:00
Evan Hahn
a7d5f778e2 Fix pre-commit block format script
Python 3 removed the [`cmp` function][0] which this script relied on.
Calling it was unnecessary, so I removed it (and cleaned up some of the
surrounding code).

Tested this with the `--all`, `--path`, and `--ref` flags.

[0]: https://docs.python.org/2.7/library/functions.html#cmp
2022-03-22 13:33:32 -05:00
Evan Hahn
c254811765 Remove unnecessary coding: utf-8 heading from Python scripts
Python 3 uses UTF-8 for source files by default. This removes the
unnecessary `coding: utf-8` declaration comment from all files.
2022-03-21 14:43:45 -05:00
Evan Hahn
1101db6a29 Upgrade scripts to Python 3
Python 2 was [removed from macOS in 12.3][0]. This change:

- Automatically converts many files with [2to3][1]
- Manually updates all [shebangs][2] to use `python3` instead of
  versionless `python` or `python2.7`
- Manually applies a few fixes, many of which were noted by 2to3
- Manually undoes a few fixes that were automatically done by 2to3

[0]: https://www.macrumors.com/2022/01/28/apple-removing-python-2-in-macos-12-3/
[1]: https://docs.python.org/3/library/2to3.html
[2]: https://en.wikipedia.org/wiki/Shebang_(Unix)
2022-03-21 12:58:33 -05:00
Dimitris Apostolou
62724cf0be Fix typos 2022-03-18 11:31:06 -07:00
Martin Böttcher
eedfd70f3e merged master and pod files 2022-03-15 12:49:11 +01:00
Martin Böttcher
c2d93547ae minor changes due to changed name of NSLocalizedStringFromAppBundle (now OWSLocalizedString) and new location of swift function and preprocessor definition 2022-03-11 14:08:26 +01:00
Jordan Rose
15d13517fa Add SDSCursor protocol, for common functionality across cursors 2022-03-07 15:01:39 -08:00
Martin Böttcher
c0adfbfb32 NSLocalizedString is replaced by NSLocalizedStringFromAppBundle (reading strings from the bundle of the main app) for all source files called by an app extension and the localizable files are removed for the app extension targets. 2022-03-07 13:29:06 +01:00
Michelle Linington
a348495786 Swap hands 2022-03-03 17:11:23 -08:00
Michelle Linington
614807de65 Update to Emoji 14 2022-03-03 17:11:23 -08:00
Michelle Linington
886a9f8e6f Generate CDS protos 2022-02-22 12:41:04 -08:00
Jordan Rose
61232780ee Don't reindex conversations on every model change
Every single message updates a TSThread model, but only a change in a
member's profile name or phone number, or a change to a group's model,
can update the indexing information. Turn 'shouldBeIndexedForFTS' into
a tri-state 'FTSIndexMode' with options 'never', 'manualUpdates', and
'always', and use 'manualUpdates' for TSThreads. Then explicitly
reindex on any of the changes listed above.
2022-02-01 15:05:34 -08:00
Michelle Linington
220a49134e Fix lint script 2022-01-31 11:00:13 -08:00
Michelle Linington
e19b800b17 Merge branch 'release/5.27.0' 2022-01-28 13:37:59 -08:00
Michelle Linington
e3d18733da Bump copyright 2022-01-28 13:23:47 -08:00
Jordan Rose
01fc3945ae Fix setup_private_pods script for newly-cloned repos
- The Pods/ directory always exists even before submodules have been
  initialized; check for Pods/.git instead, which may be a file or
  a folder depending on how the submodule was set up.

- When cloning for the first time, make sure the remote is called
  'private' so that later updates will reference it correctly. Also
  run `git submodule absorbgitdirs` so that git stores the submodule
  state inside the top-level .git directory.

- For an existing directory, simplify the check for the presence of
  a proper 'private' remote.

- Check that we're running from the repository root so we don't get
  weird errors or do random clones.

- Make the script Shellcheck-clean.
2022-01-28 10:04:00 -08:00
Michelle Linington
e3f1efb459 Update comment 2022-01-25 16:59:59 -08:00
Michelle Linington
30f51a10d0 Allow specifying of build variants from build tag script
ASC will assign its own build numbers to our builds independent of what
our plist requests. Right now, we're in a situation where a failed build
has forced our local and ASC variants out-of-sync. This change allows
the version flag to specify a fix to re-sync.
2022-01-25 16:56:37 -08:00
Ehren Kret
528257e705 Remove unused files 2022-01-10 10:50:09 -06:00
Matthew Chen
726fa6577f Fix bug around handling forward declarations of obj-c protocols in precommit script. 2021-11-23 14:16:35 -03:00